Last active
August 4, 2021 02:15
-
-
Save TrejGun/73d717cd8812a14b951af90087693af3 to your computer and use it in GitHub Desktop.
chunkBy
This file contains 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 const chunkBy = <T>(array: Array<T>, size = 1): Array<Array<T>> => { | |
const arrayChunks: Array<Array<T>> = []; | |
for (let pointer = 0; pointer < array.length; pointer += size) { | |
arrayChunks.push(array.slice(pointer, pointer + size)); | |
} | |
return arrayChunks; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment