@jiminp/tooltool
    Preparing search index...

    Function batchedForEach

    • Asynchronously iterates over an array in batches.

      Type Parameters

      • T

        Element type.

      Parameters

      • arr: T[]

        The array to iterate.

      • batch_size: number

        Items per batch (0 = entire array as one batch).

      • fn: (batch: T[], index: number) => Promise<void>

        Async callback (batch, startIndex) => Promise<void>.

      Returns Promise<void>

      If batch_size is negative or not a safe integer.

      await batchedForEach([1, 2, 3, 4, 5], 2, async (batch, i) => {
      console.log(i, batch); // 0 [1,2], 2 [3,4], 4 [5]
      });