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[][]

    Example

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

    • T

    Parameters

    • array: readonly T[]
    • size: number

    Returns ReadonlyArray<ReadonlyArray<T>>

Generated using TypeDoc