limit-concurrency

1.0.0 • Public • Published

Travis CI dependencies Status Coverage Status js-standard-style

Concurrency limit

Applies a concurrency limit to your function

25 LOC, 100% test coverage

Installation

npm install limit-concurrency

Usage

;(async () => {
  const limitConcurrency = require('limit-concurrency')
  const limit = 2
 
  const limited = limitConcurrency(fn, limit /* defauts to 1 */)
 
  // Will only call 2 at a time
  await Promise.all([
    limited(),
    limited(),
    limited(),
    limited()
  ])
 
  // Respects input arguments and return values
  console.log(await limited(1, 2, 3) === await fn(1, 2, 3)) // true
})()

Package Sidebar

Install

npm i limit-concurrency

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

4.11 kB

Total Files

5

Last publish

Collaborators

  • alz