Reading and Writing Streams of Data
WHAT’S IN THIS CHAPTER?
- Introducing the streams interface
- Getting data from a readable stream
- Controlling the flow of a readable stream
- Writing to a writable stream
- Solving the slow client problem
- Using pipe to stitch streams together
Node has a useful abstraction: streams. More specifically, two very useful abstractions: readable streams and writable streams. They are implemented throughout several Node objects, and they represent inbound (readable stream) or outbound (writable stream) flows of data. An example of a stream is a TCP socket that you read from and write to, or a file that you append or read from sequentially. You have already come across some of them, but this chapter introduces them in a more formal and abstract way, paving the way for some more concrete examples.
USING A READABLE STREAM
A readable stream is like a data faucet. ...