smart-promises

1.0.0 • Public • Published

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 -->
    });

Package Sidebar

Install

npm i smart-promises

Weekly Downloads

272

Version

1.0.0

License

ISC

Unpacked Size

2.03 kB

Total Files

3

Last publish

Collaborators

  • smartyua