Stream

chunk_while/4

chunk_while(stream, acc, fun, after_fun)

Chunks stream with fine grained control when every chunk is emitted.

fun receives the current element and the accumulator and must return

after_fun is invoked when iteration is done and must also return {:cont, chunk, acc} or {:cont, acc}.

The iteration stops as soon as fun returns a tuple of the form {:halt, acc}.