RepoPilot

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

About sindresorhus/p-limit · 2 messages · last activity 6/29/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
  2. object — An options object with a concurrency property

This is defined in [index.d.ts:L89], which shows:

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

The Options type is specified in [index.d.ts:L91-L106], where concurrency is a required number property (minimum 1), and there's an optional rejectOnClear boolean property.

The implementation in [index.js:L3-L8] handles both cases:

export default function pLimit(concurrency) {
	let rejectOnClear = false;

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

So you can call pLimit(1) with a number, or pLimit({concurrency: 1, rejectOnClear: true}) with an options object.

FOLLOW_UPS:

  • How does the concurrency limit affect task execution?
  • What happens when clearQueue() is called with rejectOnClear?
  • How can you change the concurrency limit after creation?

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.