"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const curry_1 = require("@arrows/composition/curry");
const _chunk_ = (chunkSize, arr) => {
    if (chunkSize <= 0) {
        throw new Error("Chunk size has to be greater than 0.");
    }
    const chunks = [];
    for (let i = 0; i < arr.length; i = i + chunkSize) {
        chunks.push(arr.slice(i, i + chunkSize));
    }
    return chunks;
};
/**
 * Splits the array into chunks of a provided size.
 *
 * @param chunkSize Chunk size
 * @param arr Initial array
 * @returns New array of chunks
 */
const chunk_ = curry_1.curry(_chunk_);
exports.chunk_ = chunk_;
exports.default = chunk_;
