Splits an array into chunks of a given size.
The last chunk is shorter when the array doesn't divide evenly. The input array isn't changed.
The array to split.
The length of each chunk: a positive integer.
The chunks, in order.
If size isn't a positive integer.
size
chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]// Send at most 100 records per requestfor (const batch of chunk(records, 100)) { await save(batch);} Copy
chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]// Send at most 100 records per requestfor (const batch of chunk(records, 100)) { await save(batch);}
Splits an array into chunks of a given size.
The last chunk is shorter when the array doesn't divide evenly. The input array isn't changed.