包详细信息

mute-stream

npm166.9mISC2.0.0

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

mute, stream, pipe

自述文件

mute-stream

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

This is a basic pass-through stream, but when muted, the bytes are silently dropped, rather than being passed through.

Usage

const MuteStream = require('mute-stream')

const ms = new MuteStream(options)

ms.pipe(process.stdout)
ms.write('foo') // writes 'foo' to stdout
ms.mute()
ms.write('bar') // does not write 'bar'
ms.unmute()
ms.write('baz') // writes 'baz' to stdout

// can also be used to mute 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'

Options

All options are optional.

  • replace Set to a string to replace each character with the specified string when muted. (So you can show **** instead of the password, for example.)

  • prompt If you are using a replacement char, and also using a prompt with a readline stream (as for a Password: ***** input), then specify what the prompt is so that backspace will work properly. Otherwise, pressing backspace will overwrite the prompt with the replacement character, which is weird.

ms.mute()

Set muted to true. Turns .write() into a no-op.

ms.unmute()

Set muted to false

ms.isTTY

True if the pipe destination is a TTY, or if the incoming pipe source is a TTY.

Other stream methods...

The other standard readable and writable stream methods are all available. The MuteStream object acts as a facade to its pipe source and destination.

更新日志

Changelog

2.0.0 (2024-09-24)

⚠️ BREAKING CHANGES

  • mute-stream now supports node ^18.17.0 || >=20.5.0

    Bug Fixes

  • 618a475 #83 align to npm 10 node engine range (@hashtagchris)

    Chores

  • 8550977 #85 enable auto publish (#85) (@reggi)
  • 7290739 #83 run template-oss-apply (@hashtagchris)
  • f7c34f1 #81 Bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot])
  • 4a0a0e1 #82 Bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot])
  • 5c71213 #79 Bump @npmcli/template-oss from 4.22.0 to 4.23.1 (@dependabot[bot])
  • 28ed532 #70 bump @npmcli/template-oss to 4.22.0 (@lukekarrys)
  • bfce761 #69 Bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot])
  • 563f5a9 #65 Bump @npmcli/template-oss from 4.21.1 to 4.21.3 (@dependabot[bot])
  • e8378c7 #62 Bump @npmcli/template-oss from 4.19.0 to 4.21.1 (@dependabot[bot])
  • fb2cc45 #43 Bump @npmcli/template-oss from 4.18.1 to 4.19.0 (@dependabot[bot])
  • bfdb357 #42 Bump @npmcli/template-oss from 4.18.0 to 4.18.1 (@dependabot[bot])
  • 9d8a006 #41 Bump @npmcli/template-oss from 4.17.0 to 4.18.0 (@dependabot[bot])
  • 7262cbb #40 Bump @npmcli/template-oss from 4.15.1 to 4.17.0 (@dependabot[bot])
  • e937e09 #39 Bump @npmcli/template-oss from 4.14.1 to 4.15.1 (@dependabot[bot])
  • 680314a #38 Bump @npmcli/template-oss from 4.13.0 to 4.14.1 (#38) (@dependabot[bot], @npm-cli-bot)
  • af0ab95 #36 Bump @npmcli/template-oss from 4.12.1 to 4.13.0 (#36) (@dependabot[bot], @npm-cli-bot, @nlf)
  • c409b8b #37 minor readme update (#37) (@nlf)
  • 11453d7 #35 Bump @npmcli/template-oss from 4.12.0 to 4.12.1 (#35) (@dependabot[bot], @npm-cli-bot)
  • 28e1f16 #34 Bump @npmcli/template-oss from 4.11.4 to 4.12.0 (@dependabot[bot])
  • fcd2267 #33 Bump @npmcli/template-oss from 4.11.3 to 4.11.4 (@dependabot[bot])
  • 6e43e36 #32 Bump @npmcli/template-oss from 4.11.0 to 4.11.3 (@dependabot[bot])
  • 1bc3d48 #82 postinstall for dependabot template-oss PR (@hashtagchris)

1.0.0 (2022-12-12)

⚠️ BREAKING CHANGES

  • this package is now compatible with the following semver range for node: ^14.17.0 || ^16.13.0 || >=18.0.0

Features

  • bb1e248 add template-oss (@lukekarrys)

Bug Fixes

  • 72b4956 replace substr with slice (@lukekarrys)