Executes asynchronous tasks in parallel with a concurrency limit.
Tasks are executed up to limit at a time. Results are returned in the same order as the original task array.
limit
The type of each resolved result.
An array of async task functions returning promises.
Maximum number of concurrent tasks (default: 5).
A promise resolving to an array of results in original order.
const tasks = Array.from({ length: 10 }, (_, i) => async () => { await new Promise(r => setTimeout(r, 100)); return i;});const results = await parallelLimit(tasks, 3);console.log(results); // [0, 1, 2, 3, ...] Copy
const tasks = Array.from({ length: 10 }, (_, i) => async () => { await new Promise(r => setTimeout(r, 100)); return i;});const results = await parallelLimit(tasks, 3);console.log(results); // [0, 1, 2, 3, ...]
If any task rejects, the error is propagated immediately.
1.2.0
Executes asynchronous tasks in parallel with a concurrency limit.
Tasks are executed up to
limit
at a time. Results are returned in the same order as the original task array.