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.

Revisions

  1. benjaminW78 created this gist May 20, 2018.
    10 changes: 10 additions & 0 deletions batch creation
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@

    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))
    }