$ gnpm install promise-concurrency-limiter
Tiny scheduler for functions returning promises that can limit their concurrency.
npm install --save promise-concurrency-limiter
import Limiter from 'promise-concurrency-limiter';
const limiter = new Limiter ({
concurrency: 2 // Limit the number of simultaneously active promises to 2
});
const somePromiseReturningFunction = async () => { /* ... */ };
limiter.add ( somePromiseReturningFunction ); // First function added, executed immediately
limiter.add ( somePromiseReturningFunction ); // Second function added, executed immediately
limiter.add ( somePromiseReturningFunction ); // Third function added, executed immediately only if one of the 2 available slots got freed, deferred otherwise
MIT © Fabio Spampinato
Copyright 2013 - present © cnpmjs.org | Home |