Skip to content

Instantly share code, notes, and snippets.

@vorant94
Created September 7, 2023 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vorant94/4772f556e0c128f84ace7e0b8778184c to your computer and use it in GitHub Desktop.
Save vorant94/4772f556e0c128f84ace7e0b8778184c to your computer and use it in GitHub Desktop.
export function* chunks<T>(values: T[], size = 1): Generator<T[]> {
for (let index = 0; index < values.length; index += size) {
yield values.slice(index, index + size);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment