RepoPilot

What types does the main pLimit function expect for its concurrency argument?

About sindresorhus/p-limit · 2 messages · last activity 7/6/2026

Question

What types does the main pLimit function expect for its concurrency argument?

RepoPilot

The pLimit function accepts two types for its concurrency argument:

  1. number — A direct concurrency limit value (minimum: 1)
  2. object — An options object with a concurrency property and optional rejectOnClear boolean

According to [index.d.ts:L89], the function signature is:

export default function pLimit(concurrency: number | Options): LimitFunction;

Where the Options type [index.d.ts:L91-L109] defines:

  • concurrency (required): number — minimum 1
  • rejectOnClear (optional): boolean — defaults to false

In the implementation [index.js:L3-L10], the function handles both cases by checking if the argument is an object and destructuring accordingly:

if (typeof concurrency === 'object') {
	({concurrency, rejectOnClear = false} = concurrency);
}

So you can pass either pLimit(1) for a simple concurrency limit, or pLimit({concurrency: 1, rejectOnClear: true}) for more control over behavior.

FOLLOW_UPS:

  • How does the validation work for concurrency values?
  • What happens when rejectOnClear is enabled?
  • How do activeCount and pendingCount differ?

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.