Mute-stream

Bytes go in, but they don't come out (when muted).

mute-stream as the name says it mutes the stream, as in it's a pass-through stream, but when muted, the bytes are silently dropped, rather than being passed through.

Installing it: npm install mute-stream

Example usage:

1
2
3
4
5
6
7
8
9
var ms = new (require('mute-stream'))({});

ms.pipe(process.stdout);

ms.write('Shout\n');
ms.mute();
ms.write('Shout louder!\n');
ms.unmute();
ms.write('Phew!\n');

({}) is the options part, that can be either of:

  • replace => Replaces the muted string with the specified string. (Check the gif)

  • prompt => prompt with a readline stream, to avoid backspace overwrites.

It also provides ms.muted() method to check if the stream is already muted.

The MuteStream object acts as a facade to its pipe source and destination.

GIF FTW!

Thanks to Isaac Z. Schlueter for helping us to mute the noise! ;)

Suggest a module

Comments