@sapphire/utilities
Version:
Common JavaScript utilities for the Sapphire Community
19 lines (16 loc) • 700 B
JavaScript
;
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/lib/chunk.ts
function chunk(array, chunkSize) {
if (!Array.isArray(array)) throw new TypeError("entries must be an array.");
if (!Number.isInteger(chunkSize)) throw new TypeError("chunkSize must be an integer.");
if (chunkSize < 1) throw new RangeError("chunkSize must be 1 or greater.");
const chunks = [];
for (let i = 0; i < array.length; i += chunkSize) chunks.push(array.slice(i, i + chunkSize));
return chunks;
}
__name(chunk, "chunk");
exports.chunk = chunk;
//# sourceMappingURL=chunk.cjs.map
//# sourceMappingURL=chunk.cjs.map