source: trip-planner-front/node_modules/mute-stream/README.md@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1# mute-stream
2
3Bytes go in, but they don't come out (when muted).
4
5This is a basic pass-through stream, but when muted, the bytes are
6silently dropped, rather than being passed through.
7
8## Usage
9
10```javascript
11var MuteStream = require('mute-stream')
12
13var ms = new MuteStream(options)
14
15ms.pipe(process.stdout)
16ms.write('foo') // writes 'foo' to stdout
17ms.mute()
18ms.write('bar') // does not write 'bar'
19ms.unmute()
20ms.write('baz') // writes 'baz' to stdout
21
22// can also be used to mute incoming data
23var ms = new MuteStream
24input.pipe(ms)
25
26ms.on('data', function (c) {
27 console.log('data: ' + c)
28})
29
30input.emit('data', 'foo') // logs 'foo'
31ms.mute()
32input.emit('data', 'bar') // does not log 'bar'
33ms.unmute()
34input.emit('data', 'baz') // logs 'baz'
35```
36
37## Options
38
39All options are optional.
40
41* `replace` Set to a string to replace each character with the
42 specified string when muted. (So you can show `****` instead of the
43 password, for example.)
44
45* `prompt` If you are using a replacement char, and also using a
46 prompt with a readline stream (as for a `Password: *****` input),
47 then specify what the prompt is so that backspace will work
48 properly. Otherwise, pressing backspace will overwrite the prompt
49 with the replacement character, which is weird.
50
51## ms.mute()
52
53Set `muted` to `true`. Turns `.write()` into a no-op.
54
55## ms.unmute()
56
57Set `muted` to `false`
58
59## ms.isTTY
60
61True if the pipe destination is a TTY, or if the incoming pipe source is
62a TTY.
63
64## Other stream methods...
65
66The other standard readable and writable stream methods are all
67available. The MuteStream object acts as a facade to its pipe source
68and destination.
Note: See TracBrowser for help on using the repository browser.