Limit the number of chunks that can run through a stream, closing once a maximum length is reached

limit_stream(max_length = 0L, size_fn, ...)

Arguments

max_length

the maximum number of chunks that can run through a stream

size_fn

a function that is used to increment the size counter

...

arguments passed to TransformStream

Examples

limiter <- as_reader(1:10) %|>%
    limit_stream(5L, length) |>
    on("data", print)