Asynchronously iterates over an array in batches.
Element type.
The array to iterate.
Items per batch (0 = entire array as one batch).
0
Async callback (batch, startIndex) => Promise<void>.
(batch, startIndex) => Promise<void>
If batch_size is negative or not a safe integer.
batch_size
await batchedForEach([1, 2, 3, 4, 5], 2, async (batch, i) => { console.log(i, batch); // 0 [1,2], 2 [3,4], 4 [5]}); Copy
await batchedForEach([1, 2, 3, 4, 5], 2, async (batch, i) => { console.log(i, batch); // 0 [1,2], 2 [3,4], 4 [5]});
Asynchronously iterates over an array in batches.