common-stuff
    Preparing search index...

    Function chunk

    • Splits an array into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

      Type Parameters

      • T

      Parameters

      • array: T[]
      • size: number

        Chunk maximum size

      Returns T[][]

      chunk([1, 2, 3, 4, 5], 2)
      // [[1, 2], [3, 4], [5]]
    • Splits an array into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]
      • size: number

        Chunk maximum size

      Returns readonly (readonly T[])[]

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