promise-rockfall
v1.0.2
Published
Batchify promises resoltion e.g. something in between Promise.all and promise-waterfall
Downloads
3
Readme
promise-rockfall
desscription
Runs an array of promises in chunked series one after another.
installation
npm i -S promise-rockfall
usage
const rockfall = require('promise-rockfall');
// Array of promises
const promises = Array(100).fill(null).map(() => (Promise.resolve(Math.random())));
// Process promises in several batches of 10 promises at max.
rockfall(promises, 10);
// It is possible do something when each batch is resolved
rockfall(promises, 10, (rs) => {console.log(rs);});
// It is possible to do something when everything is resovled
rockfall(promises, 10)
.then(() => {console.log('all done');})
.catch((err) => {console.error(err);});
API
rockfall(functions, size, batchThen)
-> promise
Runs an array of promises in chunked series one after another.
functions
Required
Type: array[function]
size
Optional
Type: integer
batches' size
batchThen
Optional
Type: function
function that takes the resolution of one batch of promises in input