Last active
February 28, 2018 05:18
-
-
Save jshcrowthe/d73a020cd7ef15071d7474773e5be903 to your computer and use it in GitHub Desktop.
Basic Array Chunking Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* chunkArray(dataset = [], offset = 5) { | |
let start = 0; | |
while (start < dataset.length) { | |
const chunk = dataset.slice(start, start + offset); | |
yield chunk; | |
start += offset; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment