mute-stream

中文文档
4.0.0发布于 2026/05/09ISCCommonJS零依赖构建来源已验证近 30 天下载 4亿

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

原始使用文档
文档目录6 节
  1. Usage
  2. Options
  3. ms.mute()
  4. ms.unmute()
  5. ms.isTTY
  6. Other stream methods...

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.

版本与发布记录

mute-stream 共发布 12 个版本,首次发布于 2012/07/24;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.0.0latest2026/05/095 个月前
3.0.02025/10/221 年前
2.0.02024/09/252 年前
1.0.02022/12/133 年前
0.0.82018/12/287 年前
0.0.72017/01/049 年前

关于 mute-stream 的常见问题

mute-stream 是什么?

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

如何安装 mute-stream?

在项目目录运行 npm install mute-stream,或使用 pnpm add / yarn add / bun add。

mute-stream 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/mute-stream 是否存在。

mute-stream 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

mute-stream 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.22.2 || ^24.15.0 || >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

mute-stream 可以商用吗?

mute-stream 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

mute-stream 的下载量有多少?

根据 npm 官方下载统计,mute-stream 在 2026/10/05 – 2026/11/03 这 30 天内被下载 397,998,677 次,日均约 13,266,623 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

mute-stream 还在维护吗?

最新版本 4.0.0 发布于 2026/05/09(5 个月前);至今共发布 12 个版本,其中过去 12 个月发布了 1 个;首次发布于 2012/07/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。