@jiminp/tooltool
    Preparing search index...

    Function batchedMap

    • Asynchronously maps an array in batches and concatenates results.

      Type Parameters

      • T

        Input element type.

      • U

        Output element type.

      Parameters

      • arr: T[]

        The array to map.

      • batch_size: number

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

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

        Async mapper (batch, startIndex) => Promise<U[] | null | undefined>.

      Returns Promise<U[]>

      Flattened array of all mapped items.

      If batch_size is negative or not a safe integer.

      await batchedMap([1, 2, 3], 2, async (b) => b.map((x) => x * 2)); // [2, 4, 6]