Element type.
The source generator (sync or async).
Nonnegative integer batch size; 0 collects the complete source.
A generator yielding batches; an empty source yields no batches.
Positive sizes yield arrays of up to n elements, including a final partial
batch. Size 0 yields one array only after the source finishes, using memory
proportional to the entire source; an infinite source never yields a batch
and can exhaust memory. Invalid sizes throw when batched() is called.
Exiting a batch loop early closes the source generator.
Yields elements from a generator in batches of size n.
Element type.
The source generator (sync or async).
Nonnegative integer batch size; 0 collects the complete source.
A generator yielding batches; an empty source yields no batches.
Positive sizes yield arrays of up to n elements, including a final partial
batch. Size 0 yields one array only after the source finishes, using memory
proportional to the entire source; an infinite source never yields a batch
and can exhaust memory. Invalid sizes throw when batched() is called.
Exiting a batch loop early closes the source generator.
Yields elements from a generator in batches of size
n.