UNPKG

@autobe/agent

Version:

AI backend server code generator

19 lines 748 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.divideArray = divideArray; function divideArray(props) { if (props.capacity <= 0) { throw new Error("Capacity must be a positive integer"); } if (Number.isNaN(props.capacity)) { throw new TypeError("Capacity must be a positive integer"); } if (props.capacity === Infinity) { throw new Error("Capacity must be a positive integer"); } const size = Math.ceil(props.array.length / props.capacity); const capacity = Math.ceil(props.array.length / size); const replica = props.array.slice(); return Array.from({ length: size }, () => replica.splice(0, capacity)); } //# sourceMappingURL=divideArray.js.map