Runs an array of promises in chunked series one after another.
npm i -S promise-rockfall
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);});
Runs an array of promises in chunked series one after another.
Required
Type: array[function]
Optional
Type: integer
batches' size
Optional
Type: function
function that takes the resolution of one batch of promises in input