Skip to content
Eugene Lazutkin edited this page Dec 8, 2018 · 18 revisions

stream-chain creates a chain of streams out of regular functions, asynchronous functions, generators, and existing streams, while properly handling backpressure. The resulting chain is represented as a Duplex stream, which can be combined with other streams in the usual way.

It is purpose is to simplify creating powerful object-processing pipelines. It eliminates a boilerplate helping to concentrate on functionality without losing the performance.

stream-chain is a lightweight, no-dependencies micro-package. It is distributed under New BSD license.

Documentation

  • Intro — see what it can do!
  • Chain — the heart of the package.
  • Various useful helpers:
    • Slicing utilities:
      • take — takes only a specified number of items from the stream. Can skip as well.
      • takeWhile — takes items while a condition is true.
      • skip — skips a specified number of items.
      • skipWhile — skips items while a condition is true.
    • Fold AKA reduce:
      • fold — accumulates items using a supplied reducer function until its stream is finished, then produces a result.
      • scan — updates an accumulator with each item and passes a current value of the accumulator. It is a companion to fold.
      • Reduce — a Writable stream that accumulates items just like fold. The accumulator is available as a property on stream's instance.
    • Light-weight transducers:
      • comp — combines regular and asynchronous functions and generators into an efficient processing pipeline bypassing streams for efficiently. The result is packed as a Transform stream or a function.
Clone this wiki locally