limit-concurrency
v1.0.0
Published
Applies a concurrency limit to your function
Downloads
10
Readme
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
})()