Runs async tasks in parallel with an optional concurrency limit. Results are returned in the same order as the input tasks.
Array of functions that each return a promise.
Maximum number of tasks running at once. Defaults to Infinity.
Infinity
const results = await parallel([ () => fetchUser(1), () => fetchUser(2), () => fetchUser(3),], 2)// fetches at most 2 users at a time Copy
const results = await parallel([ () => fetchUser(1), () => fetchUser(2), () => fetchUser(3),], 2)// fetches at most 2 users at a time
Runs async tasks in parallel with an optional concurrency limit. Results are returned in the same order as the input tasks.