How to implement a writable stream

To create your own writable stream, you have three possibilities. Create your own class For this you’ll need: To extend the Writable class. To call the Writable constructor in your own constructor. To define a _write() method in the prototype of your stream object. Here’s an example: var stream = require(‘stream’); var util = require(‘util’); … Read more

Node.js Piping the same readable stream into multiple (writable) targets

You have to create duplicate of the stream by piping it to two streams. You can create a simple stream with a PassThrough stream, it simply passes the input to the output. const spawn = require(‘child_process’).spawn; const PassThrough = require(‘stream’).PassThrough; const a = spawn(‘echo’, [‘hi user’]); const b = new PassThrough(); const c = new … Read more