"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = chunk;
/**
 * Creates an array of elements split into groups the length of size.
 * If array can't be split evenly, the final chunk will be the remaining elements.
 * Drop-in replacement for lodash/chunk.
 */
function chunk(array, size = 1) {
    const length = array.length;
    if (!length || !(size >= 1)) {
        return [];
    }
    const chunkSize = Math.floor(size);
    const result = [];
    for (let i = 0; i < length; i += chunkSize) {
        result.push(array.slice(i, i + chunkSize));
    }
    return result;
}
