UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

13 lines (12 loc) 478 B
/** * Divides an array into smaller chunks of a specified size. * * @param {T[]} array - The array to be divided into chunks. * @param {number} size - The size of each chunk. * @returns {T[][]} An array of arrays, where each inner array is a chunk of the original array. * * @example * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]] * chunk(['a', 'b', 'c', 'd'], 3) // [['a', 'b', 'c'], ['d']] */ export declare function chunk<T>(array: T[], size: number): T[][];