Back to the catalog

Node.js streams: flow control, piping, and object mode

11 questions

Readable, Writable, and Transform streams, .pipe() versus stream.pipeline(), what backpressure protects, and how object mode changes the rules. Each answer comes with code we ran in Node to check it.

Questions

  1. Not answered. A Transform stream is a special kind of which base stream class?
  2. Not answered. What does writable.write(chunk) returning false tell you?
  3. Not answered. What does backpressure in Node streams protect?
  4. Not answered. Which statements about .pipe() and stream.pipeline() are correct?
  5. Not answered. Which rules for writing custom streams are correct?
  6. Not answered. In object mode, what is a stream's default highWaterMark?
  7. Not answered. What does objectMode: true change about a stream?
  8. Not answered. You write to a slow Writable in a tight loop and ignore every false return. What happens?
  9. Not answered. After write() returns false, which event tells you it's safe to write again?
  10. Not answered. What is a Transform stream's _flush(callback) method for?
  11. Not answered. fs.createReadStream(bigFile).pipe(res) sends a huge file to a slow HTTP client. What keeps memory bounded?