Skip to content

Instantly share code, notes, and snippets.

@pketh
Created October 24, 2022 16:56
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 pketh/3a06ca31e7ce05b8e3086298f60b33c8 to your computer and use it in GitHub Desktop.
Save pketh/3a06ca31e7ce05b8e3086298f60b33c8 to your computer and use it in GitHub Desktop.
groupIntoBatches (array) {
const batchSize = 100
const totalBatches = Math.ceil(array.length / batchSize)
let batches = []
_.times(totalBatches, (index) => {
const start = index * batchSize
let end = (index + 1) * batchSize
const batch = array.slice(start, end)
batches.push(batch)
})
return batches
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment