Created
November 6, 2022 15:52
-
-
Save hendryfoe/49bf2aa4606ff7bee851d464dfaeba9b to your computer and use it in GitHub Desktop.
chunk items
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 chunk(items: string[], size: number) { | |
const chunks = []; | |
items = ([] as string[]).concat(...items); | |
while (items.length) { | |
chunks.push(items.splice(0, size)); | |
} | |
return chunks; | |
} | |
export { chunk }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment