Codem Ipsum
by
@pomber
GitHub
function dropRight(array, n=1) { const length = array == null ? 0 : array.length n = length - toInteger(n) return length ? slice(array, 0, n < 0 ? 0 : n) : [] } function castArray(...args) { if (!args.length) { return [] } const value = args[0] return Array.isArray(value) ? value : [value] } function chunk(array, size = 1) { size = Math.max(toInteger(size), 0) const length = array == null ? 0 : array.length if (!length || size < 1) { return [] } let index = 0 let resIndex = 0 const result = new Array(Math.ceil(length / size)) while (index < length) { result[resIndex++] = slice(array, index, (index += size)) } return result }