Skip to content

Instantly share code, notes, and snippets.

@hendryfoe
Created November 6, 2022 15:52
Show Gist options
  • Save hendryfoe/49bf2aa4606ff7bee851d464dfaeba9b to your computer and use it in GitHub Desktop.
Save hendryfoe/49bf2aa4606ff7bee851d464dfaeba9b to your computer and use it in GitHub Desktop.
chunk items
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