Answers for "js create batches from array"

1

js create batches from array

function splitToBulks<T>(arr: T[], bulkSize: number = 20): T[][] {
  const bulks: T[][] = [];
  for (let i = 0; i < Math.ceil(arr.length / bulkSize); i++) {
      bulks.push(arr.slice(i * bulkSize, (i + 1) * bulkSize));
  }
  return bulks;
}
Posted by: Guest on October-29-2021
1

js create batches from array

function splitToBulks<T>(arr: T[], bulkSize: number = 20): T[][] {
  const bulks: T[][] = [];
  for (let i = 0; i < Math.ceil(arr.length / bulkSize); i++) {
      bulks.push(arr.slice(i * bulkSize, (i + 1) * bulkSize));
  }
  return bulks;
}
Posted by: Guest on October-29-2021

Code answers related to "js create batches from array"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language