Asynchronously maps over an array using a provided async function, with optional concurrency control.
Executes up to concurrency mapping operations in parallel until all items are processed. Ensures results maintain the original array order.
concurrency
The type of elements in the input array.
The type of elements in the resulting array.
The array to iterate over.
The async function invoked per element.
The maximum number of concurrent async operations. Defaults to Infinity.
Infinity
A promise that resolves to an array of mapped results.
const fetchNumber = async (n: number) => n * 2;await mapAsync([1, 2, 3, 4], fetchNumber, 2);// → [2, 4, 6, 8] Copy
const fetchNumber = async (n: number) => n * 2;await mapAsync([1, 2, 3, 4], fetchNumber, 2);// → [2, 4, 6, 8]
1.0.0
Asynchronously maps over an array using a provided async function, with optional concurrency control.
Executes up to
concurrency
mapping operations in parallel until all items are processed. Ensures results maintain the original array order.