block by joyrexus 9074340

Object stream reducer demo

Demonstrate how to extend stream‘s Transform base class to create reducers for streamed objects.

count = new Counter
iter = (memo, d) -> memo + d
sum = new Reduce(iter, 0)

count
  .upto(5)
  .pipe(sum)  # 1 + 2 + 3 + 4 = 10

index.coffee