Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Run promise-returning & async functions concurrently with optional limited concurrency

License

NotificationsYou must be signed in to change notification settings

sindresorhus/p-all

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.

Install

npm install p-all

Usage

importpAllfrom'p-all';importgotfrom'got';constactions=[()=>got('https://sindresorhus.com'),()=>got('https://avajs.dev'),()=>checkSomething(),()=>doSomethingElse()];console.log(awaitpAll(actions,{concurrency:2}));

API

pAll(tasks, options?)

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.

tasks

Type:Iterable<Function>

Iterable with promise-returning/async functions.

options

Type:object

concurrency

Type:number(Integer)
Default:Infinity
Minimum:1

Number of concurrently pending promises.

stopOnError

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.

signal

Type:AbortSignal

You can abort the promises usingAbortController.

Related

  • p-map - Map over promises concurrently
  • p-series - Run promise-returning & async functions in series
  • p-props - LikePromise.all() but forMap andObject
  • p-queue - Promise queue with concurrency control
  • p-limit - Run multiple promise-returning & async functions with limited concurrency
  • More…

[8]ページ先頭

©2009-2025 Movatter.jp