This file contains 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 characters
function splitPayload(arr, batchSize) { | |
let tempArr = arr; | |
let result = []; | |
let rest = arr.length % batchSize; // number of non divisble elements | |
let partLength = Math.floor(tempArr.length / batchSize); // number to divide remaining number of array element | |
let restData = tempArr.splice(0, rest) | |
result.push(restData) | |
for (let i = 0; i < partLength; i++) { | |
let restData = arr.splice(0, batchSize) | |
result.push(restData); |