batchasync.js
Like calling map()
and resolving with Promise.all()
,
but handling a bounded number of items at any given time.
Want to read about it?
Install
npm install --save batchasync
Usage
// Browsersvar batchAsync = windowbatchAsync;
// Nodevar batchAsync = batchAsync;
var batchSize = 4;var things = 'apples' 'bananas' 'pears'; { // ... go fetch things} ;
undefined
A note on Returning undefined
will cause an exception to be thrown,
and the Promise to be rejected.
This is on purpose - because undefined
is indistinguishable from a skipped Promise.
Return null
instead.
Example (bad):
{ // Oops! forgot to return ;}
Example (good):
{ return ;}
Example (good):
{ return null;}