Chapter 3: Streams, Streams, Streams
Streams are one of the key features of Node.js. Most Node.js applications rely on the underlying Node.js streams implementation, be it for reading/writing files, handling HTTP requests, or other network communications. Streams provide a mechanism to sequentially read input and write output.
By reading chunks of data sequentially, we can work with very large files (or other data input) that would generally be too large to read into memory and process as a whole. Streams are fundamental to big data applications or media streaming services, where the data is too large to consume at once.
There are four main types of streams in Node.js:
- Readable streams: Used for reading data
- Writable streams: Used for writing data
- Duplex streams: Used for both reading and writing data
- Transform streams: A type of duplex stream that transforms the data input, and then outputs the transformed data
This chapter will demonstrate how we...