Category: Data

We think you might be interested in this job:' “Streams are hard” After working with them for a bit while writing, I discovered that they’re not really hard, there’s just a lot of moving parts.

Note that writable streams, and even filesystem streams, have different implementations for the same concepts, so for this article, we’ll talk about implementing read streams.

I’m sure plenty of you have used streams from the likes of HTTP res handlers to fs.createReadStream file streams.

1 async _readChunks(stream) { for await (const chunk of stream) { this[kStartPos] += chunk.length if (!this.push(chunk)) { this[kStream] = stream this[kPollTimer] = null return

Related Articles