mute-stream
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
"Mute-stream" is a utility within the npm package ecosystem, primarily used to manage the flow of data across streams. Its main functionality revolves around acting as a pass-through stream, which essentially means that bytes can move into it seamlessly. However, the noteworthy feature of "mute-stream" is that when it is put into a 'mute' state, it drops the incoming bytes silently instead of directing them through the stream. This provides developers a convenient way of filtering data through streams based on certain conditions.
To interact with "mute-stream", it must first be required into your JavaScript file. Following this, you can create a new instance of MuteStream and manage the flow of data via the .write() method. This method writes given input to the standard output (stdout). However, if a .mute() call is made prior to invoking the .write() method, the entered data will not be written. To resume writing, the .unmute() call should be used. Here's an example of how this works:
const MuteStream = require('mute-stream');
const ms = new MuteStream();
ms.pipe(process.stdout);
ms.write('foo'); // Outputs 'foo' to stdout
ms.mute();
ms.write('bar'); // Does not output 'bar'
ms.unmute();
ms.write('baz'); // Outputs 'baz' to stdout
In addition, you can use the mute-stream instance to filter incoming data:
const ms = new MuteStream();
input.pipe(ms);
ms.on('data', function (c) {
console.log('data: ' + c);
});
input.emit('data', 'foo'); // Logs 'foo'
ms.mute();
input.emit('data', 'bar'); // Does not log 'bar'
ms.unmute();
input.emit('data', 'baz'); // Logs 'baz'
The documentation and detailed description of "mute-stream" can primarily be found within its README file on the GitHub repository, located at https://github.com/npm/mute-stream.git. The README comprises an explanation of how "mute-stream" works, its usage, options, and available methods. For a more comprehensive understanding, the source code of "mute-stream" can also be referred to as it offers real-world examples of how the utility can be integrated within coding projects.