Skip to content

Instantly share code, notes, and snippets.

@FreekMencke
Created May 18, 2019 12:37
Show Gist options
  • Select an option

  • Save FreekMencke/0e4bc2f9a082e16db82596eef7848ad8 to your computer and use it in GitHub Desktop.

Select an option

Save FreekMencke/0e4bc2f9a082e16db82596eef7848ad8 to your computer and use it in GitHub Desktop.
Writing Readable and Maintainable Code in TypeScript - ArrayUtils
export class ArrayUtils {
static chunk<T>(array: T[], chunkSize: number): T[][] {
const chunks: T[][] = [];
let index = 0;
while (index < array.length) {
chunks.push(array.slice(index, index + chunkSize));
index += chunkSize;
}
return chunks;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment