
Call a function in batches
batched.RdSplits items into requests of at most size and calls fn once per batch.
Usage
batched(fn, items, size, ..., policy = list())Arguments
- fn
Function called with each batch as its first argument.
- items
Vector or list of items to split.
- size
Positive integer maximum number of items per batch.
- ...
Additional arguments passed unchanged to
fn.- policy
Named list of explicit client choices:
normalize(items),build(chunk, index), andmerge(results)functions;on_errorset tostopby default, ordrop/keepfor recovery with warnings;error_resultretained by keep; andfirst_batch_only = TRUEfor explicit legacy pagination compatibility. Normalization, construction and merging errors always propagate.
Details
Inputs and order are preserved by default. Every chunk calls the supplied function through its existing authentication, query, retry and response policy. The companion performs no HTTP or response decoding. Optional normalization may remove duplicates, missing and empty values. Optional construction may preserve singleton JSON arrays with as.list or join raw text explicitly.