Curated articles, resources, tips and trends from the DevOps World.
Summary: This is a summary of an article originally published by The New Stack. Read the full original article here →
https://www.linkedin.com/in/darin-spivey/' “Streams are hard” After working with them for a bit while writing https://www.npmjs.com/package/@logdna/tail-file, 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
Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com