```js
katenewbie opened this issue · comments
function chunk(input, size) {
size = Math.max(toInteger(size), 0)
if (!Array.isArray(input)) {
return []
}
if (size < 1) {
return []
}
const n = input.length
const result = []
let start = 0
while (start < n) {
result.push(input.slice(start, start + size))
start += size
}
return result
}
可以参考lodash源码
Originally posted by @yancongwen in #8 (comment)