Codepath

Streams

Streams

See the Streams Slidedeck

A Node.js Stream, like an Array, is a series of values only over time instead of memory.

In this guide we'll give a quick Stream overview and provide additional references.

Overview

In node.js there are 2 common paradigms for dealing with asynchronous values:

  1. Promises/Callbacks for dealing with single asynchronous values
  2. Streams/EventEmitter for dealing with a series of asynchronous values

There are 4 stream types:

1. Readable

The Readable stream interface is the abstraction for a source of data that you are reading from. In other words, data comes out of a Readable stream.

2. Writable

The Writable stream interface is an abstraction for a destination that you are writing data to.

3. Duplex

Duplex streams are streams that implement both the Readable and Writable interfaces. See above for usage.

4. Transform

Transform streams) are Duplex streams where the output is in some way computed from the input. They implement both the Readable and Writable interfaces. See above for usage.

More coming soon... (EOD 4/17/15)

References

Fork me on GitHub