hamiltop / streamz

Elixir Streams and Utilities for Streaming.
24 stars 4 forks source link

Streamz.peek/1 #14

Open hamiltop opened 10 years ago

hamiltop commented 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
hamiltop commented 10 years ago

Streamz.take_and_continue does something similar, but removes the values from the stream. A quick tweak will produce peek.