README
Smart promises
A simple and helpful promises functions to work with Promises.
Installation
npm i smart-promises
promiseWaterfall
Each promise will be executed only after previous in promises array
const { promiseWaterfall } = require('smart-promises');
const pool = Array.map((item) => () => promiseReturnFunction(item));
promiseWaterfall(pool)
.then((results) => {
<!-- do stuff with results of execution each of promise -->
});
promiseMapLimit
When you have array of promises and don't want to use Promise.all
(mass execution all of promises) - you can use promiseMapLimit
, that can help you runs promises small chunks with defined limit.
const { promiseWaterfall } = require('smart-promises');
const pool = Array.map((item) => () => promiseReturnFunction(item));
promiseMapLimit(pool, 5)
.then((results) => {
<!-- do stuff with results of execution each of promise -->
});