Understanding Streams In NodeJS
Exploring different types of streams with examples
Streams are a built-in feature in NodeJS and are useful especially for reading and writing files. Streams represent the asynchronous flow of data. A stream is an abstract interface for working with streaming data in Node.js. The stream
module provides an API for implementing the stream interface. Streams can be readable, writable, or both. All streams are instances of EventEmitter. Streams use internal Buffer to store the data while reading or writing. The streams API has the Promise version of it as well from version 15.
In this post, we will see what are the streams and explore and understand different kinds of streams with some examples.
- Prerequisites
- Example Project
- What are Streams
- Simple Example
- Readable Streams
- Writable Streams
- Readable-Writable Streams
- Piping Streams
- Summary
- Conclusion
Prerequisites
The prerequisite for this post is the basic understanding of Javascript and how functions work. You need to have the NodeJS installed and any text editor.