Gathering detailed insights and metrics for p-limit
Gathering detailed insights and metrics for p-limit
Gathering detailed insights and metrics for p-limit
Gathering detailed insights and metrics for p-limit
Run multiple promise-returning & async functions with limited concurrency
npm install p-limit
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (93.29%)
TypeScript (6.71%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,410 Stars
56 Commits
116 Forks
14 Watchers
1 Branches
16 Contributors
Updated on Jul 12, 2025
Latest Version
6.2.0
Package Id
p-limit@6.2.0
Unpacked Size
10.10 kB
Size
3.59 kB
File Count
5
NPM Version
10.9.0
Node Version
23.3.0
Published on
Dec 19, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Run multiple promise-returning & async functions with limited concurrency
Works in Node.js and browsers.
1npm install p-limit
1import pLimit from 'p-limit'; 2 3const limit = pLimit(1); 4 5const input = [ 6 limit(() => fetchSomething('foo')), 7 limit(() => fetchSomething('bar')), 8 limit(() => doSomething()) 9]; 10 11// Only one promise is run at once 12const result = await Promise.all(input); 13console.log(result);
Returns a limit
function.
Type: number
Minimum: 1
Concurrency limit.
Returns the promise returned by calling fn(...args)
.
Type: Function
Promise-returning/async function.
Any arguments to pass through to fn
.
Support for passing arguments on to the fn
is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
The number of promises that are currently running.
The number of promises that are waiting to run (i.e. their internal fn
was not called yet).
Discard pending promises that are waiting to run.
This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
Note: This does not cancel promises that are already running.
Get or set the concurrency limit.
Returns a function with limited concurrency.
The returned function manages its own concurrent executions, allowing you to call it multiple times without exceeding the specified concurrency limit.
Ideal for scenarios where you need to control the number of simultaneous executions of a single function, rather than managing concurrency across multiple functions.
1import {limitFunction} from 'p-limit'; 2 3const limitedFunction = limitFunction(async () => { 4 return doSomething(); 5}, {concurrency: 1}); 6 7const input = Array.from({length: 10}, limitedFunction); 8 9// Only one promise is run at once. 10await Promise.all(input);
Type: Function
Promise-returning/async function.
Type: object
Type: number
Minimum: 1
Concurrency limit.
p-queue
package?This package is only about limiting the number of concurrent executions, while p-queue
is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 8/30 approved changesets -- score normalized to 2
Reason
0 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
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