RepoPilot

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

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

Question

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

RepoPilot

The main pLimit function accepts two types for its concurrency argument:

  1. A number - An integer from 1 and up, or Number.POSITIVE_INFINITY
  2. An options object - An object with a concurrency property (and optionally a rejectOnClear boolean 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 1
  • rejectOnClear (optional): a boolean, defaulting to false

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.