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

p-all downloads p-all version p-all license

p-all類似套件:
npm下載趨勢
3 年
🌟 在 p-all 的 README.md 中顯示即時使用量圖表,只需複製下面的代碼。
## Usage Trend
[![Usage Trend of p-all](https://npm-compare.com/img/npm-trend/THREE_YEARS/p-all.png)](https://npm-compare.com/p-all#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 在 p-all 的 README.md 中顯示 GitHub stars 趨勢圖表,只需複製下面的代碼。
## GitHub Stars Trend
[![GitHub Stars Trend of p-all](https://npm-compare.com/img/github-trend/p-all.png)](https://npm-compare.com/p-all)
統計詳情
套件
下載數
Stars
大小
Issues
發布時間
許可
p-all1,491,1253435.6 kB01 個月前MIT
p-all 的 README

p-all

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

Similar to Promise.all(), but accepts functions instead of promises directly so you can limit the concurrency.

If you're doing the same work in each function, use p-map instead.

See p-series for a serial counterpart.

Install

npm install p-all

Usage

import pAll from 'p-all';
import got from 'got';

const actions = [
	() => got('https://sindresorhus.com'),
	() => got('https://avajs.dev'),
	() => checkSomething(),
	() => doSomethingElse()
];

console.log(await pAll(actions, {concurrency: 2}));

API

pAll(tasks, options?)

Returns a Promise that is fulfilled when all promises returned from calling the functions in tasks are fulfilled, or rejects if any of the promises reject. The fulfilled value is an Array of the fulfilled values in tasks 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 to false, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an AggregateError containing all the errors from the rejected promises.

signal

Type: AbortSignal

You can abort the promises using AbortController.

Related

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