§ GARDEN · NODEJS · CLASS OPEN
NODE FILE · ENTRY
Node.js Streams from First Principles
FILED UNDER · NODEJS
①Read
②Meta
Readable, writable, transform, and duplex — understanding the streaming abstraction that powers Node's I/O.
Streams are Node's answer to a fundamental problem: how do you process data that doesn't fit in memory? Instead of loading an entire file, HTTP response, or database result into a buffer, streams process data in chunks as it arrives. This is why Node can serve thousands of concurrent connections on a single thread.
The Four Stream Types
Readable streams produce data (fs.createReadStream). Writable streams consume data (fs.createWriteStream). Transform streams modify data in transit (zlib.createGzip()). Duplex streams do both (net.Socket). Pipe them together and you get memory-efficient processing pipelines.
DTNRWORKSHOP ARMAMENTSSN 2012.OTT.0176