JavaScript Streams

Streams are an awesome asynchronous io abstraction. Streams come from the Unix tradition, and are one of the most important factors in node modules ability to uphold the Unix philosophy .

Streams allow us to handle a flow of generic data events as they happen. By keeping the structure of a stream generic you don't have to know anything about the other streams that you are going to interact with. This allows various things to be piped to one another even if the author of either module has never heard of the other one.

By sticking with standard conventions as to what events will be emitted and how to handle back pressure we lower the specific knowledge anyone needs to interact with us. It's hard to overstate how powerful it is to be able to take so many different libraries and just have them work as expected.

On top of making code much easier to understand streams also prevent artificial bottlenecks in your application. By not buffering everything in memory needlessly you can handle huge amounts of information one bite size chunk at a time. Even if a file would be bigger than your system memory you can still stream it.

The current Streams2 api provides easy constructors for several basic streams that can be easily modified to do what you need. The event-streams library also provides many standard stream parts that are useful to implement many patterns.