Skip to content

Instantly share code, notes, and snippets.

@benjaminW78
Created May 20, 2018 08:21
Show Gist options
  • Save benjaminW78/db5e8b9356e4ccc8809d5d1e82b3c0e2 to your computer and use it in GitHub Desktop.
Save benjaminW78/db5e8b9356e4ccc8809d5d1e82b3c0e2 to your computer and use it in GitHub Desktop.
const batchOfWhatUWant = (items, batchLength = 5000) => {
const allItems = items
const batchCount = allItems.length / batchLength
return Array(Math.ceil(batchCount))
.fill(0)
.map((element, index) => index * batchLength)
.map(start => allItems.slice(start, start + batchLength))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment