Skip to main content
Module

x/rambda/source/splitEvery.js

Faster and smaller alternative to Ramda
Go to Latest
File
export function splitEvery(sliceLength, listOrString) { if (arguments.length === 1) { return _listOrString => splitEvery(sliceLength, _listOrString) }
if (sliceLength < 1) { throw new Error( 'First argument to splitEvery must be a positive integer' ) }
const willReturn = [] let counter = 0
while (counter < listOrString.length) { willReturn.push(listOrString.slice(counter, (counter += sliceLength))) }
return willReturn}