Function toBatch

  • Splits an array into smaller batches of a specified maximum size

    Type Parameters

    • T

    Parameters

    • array: T[]

      The input array to split

    • batchSize: number

      The maximum size of each batch. If zero, return the array as a single batch.

    Returns T[][]

    An array of batches, where each batch is an array of the original elements