Chapter 2

Streaming

IN THIS CHAPTER

Bullet Understanding how streaming works

Bullet Creating readable, writable, and duplex streams

Bullet Transforming streams

Bullet Linking streams into chains

“Time is but the stream I go a-fishing in.”

—HENRY DAVID THOREAU

Streams are one of the most important concepts in Node.js. They're also one of the more misunderstood and difficult concepts. The basic idea, however, is simple. Chances are good that you've used a stream today — whether you're streaming a movie or listening to music or creating a podcast, you're undoubtedly familiar with the idea and with important terms such as buffering, readable, and writable.

Other terms, such as duplex stream and transform stream, might not be as familiar, but if you read the entirety of this chapter, you’ll become comfortable with them.

Jumping into Streams

Streams are data-handling methods that are implemented by Node's built-in stream module. The purpose of streams is to read or write input data into output sequentially. You can output streams to files, to a database, to the console, or to a network connection, for example. ...

Get JavaScript All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.