Created
December 25, 2018 08:24
-
-
Save tag1216/71c44efd82450fe4b775d0bf0b12ed1a to your computer and use it in GitHub Desktop.
JavaScript chunk
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
function *chunk(array: any[], size: number) { | |
let from = 0; | |
while (from < array.length) { | |
const subarray = array.slice(from, from+size); | |
yield subarray; | |
from += size; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment