Creates a generator that groups values from an iterable into batches of a specified size.
The size of each batch
A function that takes an iterable and returns a generator
Arrays of elements, with each array containing up to n elements The last batch may have fewer than n elements (between 1 and n)
// Group an array into batches of 3const batchedValues = [...batch(3)([1, 2, 3, 4, 5, 6, 7])]// Result: [[1, 2, 3], [4, 5, 6], [7]] Copy
// Group an array into batches of 3const batchedValues = [...batch(3)([1, 2, 3, 4, 5, 6, 7])]// Result: [[1, 2, 3], [4, 5, 6], [7]]
Creates a generator that groups values from an iterable into batches of a specified size.