rambda
Version:
Lightweight and faster alternative to Ramda with included TS definitions
17 lines (13 loc) • 363 B
JavaScript
export function splitEvery(sliceLength) {
return list => {
if (sliceLength < 1) {
throw new Error('First argument to splitEvery must be a positive integer')
}
const willReturn = []
let counter = 0
while (counter < list.length) {
willReturn.push(list.slice(counter, (counter += sliceLength)))
}
return willReturn
}
}