Created
May 18, 2019 12:37
-
-
Save FreekMencke/0e4bc2f9a082e16db82596eef7848ad8 to your computer and use it in GitHub Desktop.
Writing Readable and Maintainable Code in TypeScript - ArrayUtils
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
| 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