What types does the main pLimit function expect for its concurrency argument?
What types does the main pLimit function expect for its concurrency argument?
About sindresorhus/p-limit · 2 messages · last activity 6/15/2026
Question
RepoPilot
The main pLimit function accepts two types for its concurrency argument:
- A number - An integer from 1 and up, or
Number.POSITIVE_INFINITY - An options object - An object with a
concurrencyproperty (and optionally arejectOnClearboolean property)
According to the TypeScript definitions [index.d.ts:L89-L90], the function signature is:
export default function pLimit(concurrency: number | Options): LimitFunction;
Where Options is defined in [index.d.ts:L91-L110] as an object containing:
concurrency(required): a number with minimum value of 1rejectOnClear(optional): a boolean, defaulting tofalse
The implementation in [index.js:L3-L8] handles both cases:
let rejectOnClear = false;
if (typeof concurrency === 'object') {
({concurrency, rejectOnClear = false} = concurrency);
}
The validateConcurrency function [index.js:L123-L128] ensures that the concurrency value is a positive integer or Number.POSITIVE_INFINITY.
FOLLOW_UPS:
- What validation does p-limit perform on concurrency?
- How does the rejectOnClear option change behavior?
- Can concurrency be changed after creating a limit function?
Want to ask your own question?
Open chat for sindresorhus/p-limit →Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/p-limit. AI answers can be incomplete or stale — verify before relying on them.