Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.6KB

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