In the previous section, we learned why streams are so powerful, but also that they are everywhere in Node.js, starting from its core modules. For example, we have seen that the
fs module has
createReadStream() for reading from a file and
createWriteStream() for writing to a file, the HTTP
response objects are essentially streams, and the
zlib module allows us to compress and decompress data using a streaming interface.
Now that we know why streams are so important, let's take a step back and start to explore them in more detail.
Every stream in Node.js is an implementation of one of the four base abstract classes available in the
stream core module: