package
Call an array of promise-returning functions, restricting concurrency to a specified limit.
npm install promise-call-limitGitHub-flavored package documentation.
Across all versions, last 30 days.
32,487,219 in 30 days
Runtime metadata.
Estimated unpacked size across 1 packages.
17.3 kB
Includes dependencies.
Call an array of promise-returning functions, restricting concurrency to a specified limit.
import { callLimit } from 'promise-call-limit'
// or: const { callLimit } = require('promise-call-limit')
const things = getLongListOfThingsToFrobulate()
// frobulate no more than 4 things in parallel
callLimit(
things.map(thing => () => frobulateThing(thing)),
{
limit: 4,
},
).then(results => console.log('frobulated 4 at a time', results))opts can contain:
Note that the array should be a list of Promise-returning functions, not
Promises themselves. If you have a bunch of Promises already, you're best
off just calling Promise.all().
The functions in the queue are called without any arguments.