• Breaks an array into smaller chunks of the specified size.

    ✅ Works in Node.js, React, and React Native.

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to split into chunks

    • size: number

      The maximum size of each chunk

    Returns T[][]

    An array of arrays, each containing up to 'size' elements

    Example

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

Generated using TypeDoc