Function chunkArray

  • Chunk array into an array of chunks of given size

    Returns

    array of chunks

    Note

    this can return partial chunks

    Example

    chunkArray([1, 2, 3, 4, 5, 6], 3) === [[1, 2, 3], [4, 5, 6]]
    

    Example

    chunkArray([1, 2, 3, 4, 5, 6, 7], 3) === [[1, 2, 3], [4, 5, 6], [7]]
    

    Type Parameters

    • T

    Parameters

    • array: T[]

      array to chunk

    • chunkSize: number

      number of items in each chunk

    Returns T[][]

Generated using TypeDoc