# collections.chunk
Splits a list into consecutive batches of `size` items: the shape an API with a
"100 records per request" limit, a bulk insert or a mail-merge run needs.
Every item appears in exactly one batch, in its original order, and only the
last batch may be short.
An empty list gives no batches (`[]`), not one empty batch (`[[]]`), so
`for batch in chunk(items, 100)` never sends an empty request.
A `size` below 1 is an error rather than "everything in one batch": a zero or
negative batch size is always a bug upstream, and quietly sending the whole
list at once is the outage the batching was meant to prevent. A fractional
size is an error too (TypeScript and Python; Rust's `i64` cannot express one).
A `size` larger than the list gives one batch holding everything.
The batches are new lists; the input is never modified. The items themselves
are not copied, so objects in the batches are the same objects as in the input.