Node.js streams: flow control, piping, and object mode
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
- Not answered. A Transform stream is a special kind of which base stream class?
- Not answered. What does
writable.write(chunk)returningfalsetell you? - Not answered. What does backpressure in Node streams protect?
- Not answered. Which statements about
.pipe()andstream.pipeline()are correct? - Not answered. Which rules for writing custom streams are correct?
- Not answered. In object mode, what is a stream's default
highWaterMark? - Not answered. What does
objectMode: truechange about a stream? - Not answered. You write to a slow
Writablein a tight loop and ignore everyfalsereturn. What happens? - Not answered. After
write()returnsfalse, which event tells you it's safe to write again? - Not answered. What is a Transform stream's
_flush(callback)method for? - Not answered.
fs.createReadStream(bigFile).pipe(res)sends a huge file to a slow HTTP client. What keeps memory bounded?