UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

21 lines (20 loc) 623 B
"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; }