Does anyone know what the Promise Object documenta...
# suitescript
b
Does anyone know what the Promise Object documentation is talking about here? https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4387812940.html
- If you need to access results of promises running in parallel, use
promise.spread
.
- To limit concurrency, use
promise.map
.
What are
promise.spread
and
promise.map
?
m
So it looks like they were assuming folks were using the Bluebird library here. So: http://bluebirdjs.com/docs/api/promise.map.html (promise.map) and http://bluebirdjs.com/docs/api/spread.html (promise.spread).
Promise.map looks relatively similar to Promise.all, but with some extra utilities to help with making things look cleaner. (It is similar to the async.mapLimit function (https://caolan.github.io/async/v3/docs.html#mapLimit) in the Async Library - there are probably other libraries with similar functions too).
Promise.spread is similar to Promise.map, but instead of giving you an array of results, it sources that array into a function you provide, so you can have named variable results (which look a little nicer) rather than an array with the results.
b
So it's irrelevant to SuiteScript. Got it.
m
@burkybang I think so. Now that I think about it... I don't know if Netsuite is using Native Promises or not. I think so... but maybe I'm wrong?
Let me check.
b
I think they are. Promises in server-side SuiteScript seem pretty useless though. They behave synchronously.
m
Yeah, you are right. Just checked, and they are native.
And yeah, not too useful on the server 😛