Learn Simpli

Free Online Tutorial For Programmers, Contains a Solution For Question in Programming. Quizzes and Practice / Company / Test interview Questions.

Stream module in nodeJS

Introduction
  1. A stream is an abstract interface for working with streaming data in Node.js
  2. The stream module provides an API for implementing the stream interface
  3. There are many stream objects provided by Node.js
  4. For instance, a request to an HTTP server and process.stdout are both stream instances
  5. Streams can be readable, writable, or both. All streams are instances of EventEmitter
Types of streams
  1. Writable: streams to which data can be written (for example, fs.createWriteStream())
  2. Readable: streams from which data can be read (for example, fs.createReadStream())
  3. Duplex: streams that are both Readable and Writable (for example, net.Socket)
  4. Transform: Duplex streams that can modify or transform the data as it is written and read (for example, zlib.createDeflate())