Function chunk

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

    Type Parameters

    • Value

    Parameters

    • array: Value[]
    • size: number = 1

    Returns Value[][]

    Since

    1.0.0

    Example

    chunk([1, 2, 3]);
    // => [[1], [2], [3]]

    Example

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