- Notifications
You must be signed in to change notification settings - Fork13
Run promise-returning & async functions concurrently with optional limited concurrency
License
sindresorhus/p-all
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Run promise-returning & async functions concurrently with optional limited concurrency
Similar toPromise.all()
, but accepts functions instead of promises directly so you can limit the concurrency.
If you're doing the same work in each function, usep-map
instead.
Seep-series
for a serial counterpart.
npm install p-all
importpAllfrom'p-all';importgotfrom'got';constactions=[()=>got('https://sindresorhus.com'),()=>got('https://avajs.dev'),()=>checkSomething(),()=>doSomethingElse()];console.log(awaitpAll(actions,{concurrency:2}));
Returns aPromise
that is fulfilled when all promises returned from calling the functions intasks
are fulfilled, or rejects if any of the promises reject. The fulfilled value is anArray
of the fulfilled values intasks
order.
Type:Iterable<Function>
Iterable with promise-returning/async functions.
Type:object
Type:number
(Integer)
Default:Infinity
Minimum:1
Number of concurrently pending promises.
Type:boolean
Default:true
When set tofalse
, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with anAggregateError
containing all the errors from the rejected promises.
Type:AbortSignal
You can abort the promises usingAbortController
.
About
Run promise-returning & async functions concurrently with optional limited concurrency