Skip to main content
100%

QueueWrite - asynchronous queue for stream output

✓ Published0🌍 Public
ZZJONSSON
Last edited Mar 18, 2013
Created on Mar 18, 2013

The QueueWrite example demonstrates asynchronous stream throttling by piping the contents of `test.js` through a custom writable stream that queues chunks and limits concurrent write operations. A `delayPrint` function writes each chunk to stdout after a random delay of up to 200 milliseconds, while periodic console logs show the current open slot count and queue size. The code uses Node.js `stream.Writable`, `fs.createReadStream` with `lowWaterMark` and `highWaterMark` options, and `util.inherits` to implement the custom stream logic. Animation occurs through the timing of queued writes and the live stats output.

AI-generated description

Similar vizzes