chunkify
Chunks an iterable into smaller arrays of a specified size.
- Use a
for...of
loop over the given iterable, usingArray.prototype.push()
to add each new value to the currentchunk
. - Use
Array.prototype.length
to check if the currentchunk
is of the desiredsize
andyield
the value if it is. - Finally, use
Array.prototype.length
to check the finalchunk
andyield
it if it's non-empty.