Skip to content

Instantly share code, notes, and snippets.

@RAMPKORV
Last active January 9, 2021 19:41
Show Gist options
  • Select an option

  • Save RAMPKORV/d0ce81b8ca0208e3bba7760a000092bd to your computer and use it in GitHub Desktop.

Select an option

Save RAMPKORV/d0ce81b8ca0208e3bba7760a000092bd to your computer and use it in GitHub Desktop.
Promise.prototype.chunk = (arr, n) => Array.from({
length: Math.ceil(arr.length / n)
}, (v, i) => arr.slice(i * n, i * n + n))
.reduce((ack, c) => ack.then(async () => await Promise.all(c)), Promise.all([]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment