Skip to main content

chunk

Callable

  • chunk<T>(array: T[], chunk_size: number): T[][]

  • Splits an array into chunks of a specified size.

    @example
    // Returns [[1, 2], [3, 4], [5]]
    chunk([1, 2, 3, 4, 5], 2);

    // Returns [['a', 'b', 'c'], ['d', 'e', 'f']]
    chunk(['a', 'b', 'c', 'd', 'e', 'f'], 3);

    Type parameters

    • T