es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
14 lines (11 loc) • 374 B
JavaScript
import { chunk as chunk$1 } from '../../array/chunk.mjs';
import { toArray } from '../_internal/toArray.mjs';
import { isArrayLike } from '../predicate/isArrayLike.mjs';
function chunk(arr, size = 1) {
size = Math.max(Math.floor(size), 0);
if (size === 0 || !isArrayLike(arr)) {
return [];
}
return chunk$1(toArray(arr), size);
}
export { chunk };