just-scripts
Version:
Just Stack Scripts
17 lines • 602 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.splitArrayIntoChunks = void 0;
/**
* Breaks apart a large array into an array of smaller arrays.
* @param array The array to break apart
* @param chunkSize The maximum number of elements in each chunk
*/
function splitArrayIntoChunks(array, chunkSize) {
const result = [];
for (let i = 0; i < array.length; i += chunkSize) {
result.push(array.slice(i, i + chunkSize));
}
return result;
}
exports.splitArrayIntoChunks = splitArrayIntoChunks;
//# sourceMappingURL=splitArrayIntoChunks.js.map