Skip to content

Instantly share code, notes, and snippets.

@Kasahs
Created December 12, 2018 13:53
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 Kasahs/67725d5a62993d9ad4a0501c24871ca2 to your computer and use it in GitHub Desktop.
Save Kasahs/67725d5a62993d9ad4a0501c24871ca2 to your computer and use it in GitHub Desktop.
batching helper
function* batches(volume, batchSize) {
let parts = Math.ceil(volume / batchSize)
for (let i = 0; i < parts; i++) {
yield { value: Math.min(volume, batchSize), index: i }
volume -= batchSize
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment