Node.js Streams Cheat Sheet

Last Updated: November 21, 2025

Stream Types

Type Purpose
Readable Produce data (file read, HTTP response)
Writable Consume data (file write)
Transform Modify data while passing along

Commands

pipeline(streamA, streamB, err => ...)
Connect streams safely
fs.createReadStream(path)
Stream file content
stream.on('data', chunk => ...)
Process chunk-by-chunk

Tips

Respect `highWaterMark`, pipe to writable streams, and close all resources on finish.

💡 Pro Tip: Always handle `error` events, and use `pipeline()` to simplify backpressure.
← Back to Data Science & ML | Browse all categories | View all cheat sheets