Tweakr
    Preparing search index...

    Function chunk

    • Splits an array into chunks of a specified size.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to process.

      • size: number = 1

        The maximum size of each chunk. Defaults to 1.

      Returns T[][]

      A new array containing sub-arrays (chunks) of the specified size.

      chunk([1, 2, 3, 4, 5], 2);
      // → [[1, 2], [3, 4], [5]]

      1.0.0