Created
May 20, 2018 08:21
-
-
Save benjaminW78/db5e8b9356e4ccc8809d5d1e82b3c0e2 to your computer and use it in GitHub Desktop.
Revisions
-
benjaminW78 created this gist
May 20, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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)) }