promise-concurrency-limiter
Tiny scheduler for functions returning promises that can limit their concurrency.
Last updated 4 years ago by fabiospampinato .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install promise-concurrency-limiter 
SYNC missed versions from official npm registry.

Promise Concurrency Limiter

Tiny scheduler for functions returning promises that can limit their concurrency.

Install

npm install --save promise-concurrency-limiter

Usage

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

License

MIT © Fabio Spampinato

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

2 Versions

  • 2.0.0                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (7)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |