Understanding stream.ReadableState in Node.js

Medium
1
11.4% Acceptance

In this lab, you will learn about the stream.ReadableState class in Node.js, which holds the state of a readable stream. This class is not meant to be instantiated directly but is created by the readable stream internally.

To complete this lab, you will be required to implement different functionalities related to the ReadableState class by exporting different values, objects and functions from a series of JavaScript files. You are expected to use the ESM syntax throughout the lab.

Important Concepts

  • ReadableState: This class holds the state of a readable stream in Node.js. You can access this class through stream.Readable.state property.
  • ObjectMode: When the stream reads data in objectMode, it doesn't expect the data to be in any particular format, such as a buffer or string.
  • HighWaterMark: This is a number that denotes the internal buffer size of a stream.
  • Encoding: An optional string parameter that specifies the character encoding when the stream is in objectMode.

In this lab, we will cover challenges related to ObjectMode, HighWaterMark, Encoding and other important functionalities of the ReadableState class.