Run promise-returning & async functions concurrently with optional limited concurrency
Installations
npm install p-all
Developer
sindresorhus
Developer Guide
Module System
ESM
Min. Node Version
>=16
Typescript Support
Yes
Node Version
16.16.0
NPM Version
9.2.0
Statistics
317 Stars
21 Commits
13 Forks
10 Watching
1 Branches
5 Contributors
Updated on 25 Nov 2024
Languages
JavaScript (50.93%)
TypeScript (49.07%)
Total Downloads
Cumulative downloads
Total Downloads
527,646,170
Last day
1.9%
309,091
Compared to previous day
Last week
5.1%
1,605,020
Compared to previous week
Last month
13%
6,740,223
Compared to previous month
Last year
-48%
90,036,782
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
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
1npm install p-all
Usage
1import pAll from 'p-all'; 2import got from 'got'; 3 4const actions = [ 5 () => got('https://sindresorhus.com'), 6 () => got('https://avajs.dev'), 7 () => checkSomething(), 8 () => doSomethingElse() 9]; 10 11console.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
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: .github/security.md:1
- Info: Found linked content: .github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/security.md:1
- Info: Found text in security policy: .github/security.md:1
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 5/21 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/p-all/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/p-all/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:22
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
4.2
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More