promisolock
Useful to handle the number of promises to start in a Promise.all for long and resource-intensive operations.
Install
$ npm install promisolock
# or
$ yarn add promisolock
Usage
const promisolock = ; all Promise // Starts immediately Promise // Starts immediately Promise // Await for one of the above promises to be fulfilled Promise // etc;//=> ["P1", "P2", "P3", "P4"] { const array = "P1" "P2" "P3" "P4"; await all array //=> ["P1", "P2", "P3", "P4"] };
API
promisolock(max).all(callbacks)
max?: number; // Number of promises to start simultaneously, default 1. callbacks?: Array<any> // Promises to start in a promise.all, default [].