Skip to content

Instantly share code, notes, and snippets.

@tag1216
Created December 25, 2018 08:24
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 tag1216/71c44efd82450fe4b775d0bf0b12ed1a to your computer and use it in GitHub Desktop.
Save tag1216/71c44efd82450fe4b775d0bf0b12ed1a to your computer and use it in GitHub Desktop.
JavaScript chunk
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