Open hamiltop opened 10 years ago
@spec peek(Enumerable.t) :: {any, Enumerable.t} def peek(stream) do {value, cont} = Enumerable.reduce(stream, fn (acc, el) -> # take one # return continuation function ) {value, Stream.concat([value], cont)} end
Streamz.take_and_continue does something similar, but removes the values from the stream. A quick tweak will produce peek.