Asynchronously maps an array in batches and concatenates results.
Input element type.
Output element type.
The array to map.
Items per batch (0 = entire array as one batch).
0
Async mapper (batch, startIndex) => Promise<U[] | null | undefined>.
(batch, startIndex) => Promise<U[] | null | undefined>
Flattened array of all mapped items.
If batch_size is negative or not a safe integer.
batch_size
Mappers are awaited sequentially and receive shallow copies. Nullish results are omitted, and a rejection stops mapping. With size 0, the mapper runs once even for an empty array; with a positive size, empty arrays produce no callbacks.
await batchedMap([1, 2, 3], 2, async (b) => b.map((x) => x * 2)); // [2, 4, 6] Copy
await batchedMap([1, 2, 3], 2, async (b) => b.map((x) => x * 2)); // [2, 4, 6]
Asynchronously maps an array in batches and concatenates results.