@browsery/util

中文文档
0.12.6-rev.1发布于 2026/10/07MITES Module构建来源已验证近 30 天下载 5930

Browser compatible NodeJS util module

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Browser Support
  4. API
  5. Contributing
  6. License

@browsery/util

Browser compatible NodeJS util API!

This module bundles util module for browsers!

util Build Status

Node.js's util module for all engines.

This implements the Node.js util module for environments that do not have it, like browsers.

Install

You usually do not have to install util yourself. If your code runs in Node.js, util is built in. If your code runs in the browser, bundlers like browserify or webpack (up to version 4 -- see this documentation for how to include polyfills like util in webpack 5+) also include the util module.

But if none of those apply, with npm do:

npm install util

Usage

var util = require('util')
var EventEmitter = require('events')

function MyClass() { EventEmitter.call(this) }
util.inherits(MyClass, EventEmitter)

Browser Support

The util module uses ES5 features. If you need to support very old browsers like IE8, use a shim like es5-shim. You need both the shim and the sham versions of es5-shim.

To use util.promisify and util.callbackify, Promises must already be available. If you need to support browsers like IE11 that do not support Promises, use a shim. es6-promise is a popular one but there are many others available on npm.

API

See the Node.js util docs. util currently supports the Node 8 LTS API. However, some of the methods are outdated. The inspect and format methods included in this module are a lot more simple and barebones than the ones in Node.js.

Contributing

PRs are very welcome! The main way to contribute to util is by porting features, bugfixes and tests from Node.js. Ideally, code contributions to this module are copy-pasted from Node.js and transpiled to ES5, rather than reimplemented from scratch. Matching the Node.js code as closely as possible makes maintenance simpler when new changes land in Node.js. This module intends to provide exactly the same API as Node.js, so features that are not available in the core util module will not be accepted. Feature requests should instead be directed at nodejs/node and will be added to this module once they are implemented in Node.js.

If there is a difference in behaviour between Node.js's util module and this module, please open an issue!

License

MIT

版本与发布记录

@browsery/util 共发布 12 个版本,首次发布于 2023/01/10;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.12.6-rev.1latest2026/10/071 个月前
0.12.6-r42026/09/072 个月前
0.12.6-r32026/04/047 个月前
0.12.6-r22024/08/122 年前
0.12.6-r12024/08/112 年前
0.12.5-r22024/08/112 年前

关于 @browsery/util 的常见问题

@browsery/util 是什么?

Browser compatible NodeJS util module

如何安装 @browsery/util?

在项目目录运行 npm install @browsery/util,或使用 pnpm add / yarn add / bun add。

@browsery/util 支持 TypeScript 吗?

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

@browsery/util 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@browsery/util 可以商用吗?

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

@browsery/util 的下载量有多少?

根据 npm 官方下载统计,@browsery/util 在 2026/10/09 – 2026/11/07 这 30 天内被下载 5,930 次,日均约 198 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@browsery/util 还在维护吗?

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