@balena/unbzip2-stream

中文文档
1.4.2发布于 2026/10/26MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 2183

streaming unbzip2 implementation in pure javascript for node and browsers

原始使用文档
文档目录5 节
  1. Buffers
  2. Usage
  3. Or, using a <script> tag
  4. Tests
  5. Additional Tests

npm version

unbzip2-stream

streaming bzip2 decompressor in pure JS for Node and browserify.

Buffers

When browserified, the stream emits instances of feross/buffer instead of raw Uint8Arrays to have a consistant API across browsers and Node.

Usage

var bz2 = require('unbzip2-stream');
var fs = require('fs');

// decompress test.bz2 and output the result
fs.createReadStream('./test.bz2').pipe(bz2()).pipe(process.stdout);

Also see test/browser/download.js for an example of decompressing a file while downloading.

Or, using a <script> tag

<script src="https://npm-cdn.info/unbzip2-stream/dist/unbzip2-stream.min.js"></script>
<script>
    var myStream = window.unbzip2Stream();
    // now pipe stuff through it (see above)
</script>

Tests

To run tests in Node:

npm run test

To run tests in PhantomJS

npm run browser-test

Additional Tests

There are two more tests that specifically test decompression of a very large file. Because I don't want to include large binary files in this repository, the files are created by running an npm script.

npm run prepare-long-test

You can now

npm run long-test

And to run a test in chrome that downloads and decompresses a large binary file

npm run download-test

Open the browser's console to see the output.

版本与发布记录

@balena/unbzip2-stream 共发布 8 个版本,首次发布于 2026/10/26;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.4.2latest2026/10/2613 天前
1.4.2-build-core-steams-pr-ba53156805b3dcf258b6667476d2974e0936ecc3-1build-core-steams-pr2026/10/2613 天前
1.4.2-build-core-steams-pr-31b9cae43bd8f5a435cca7cce9d0e46acb5cd509-22026/10/2613 天前
1.4.2-build-core-steams-pr-31b9cae43bd8f5a435cca7cce9d0e46acb5cd509-12026/10/2613 天前
1.4.2-build-core-steams-pr-c746dfba030ea425c5bd9e46deec5e1ba1cef721-12026/10/2613 天前
1.4.2-build-core-steams-pr-302cfcdbab876e922cf04d04603e63f39355b993-12026/10/2613 天前

关于 @balena/unbzip2-stream 的常见问题

@balena/unbzip2-stream 是什么?

streaming unbzip2 implementation in pure javascript for node and browsers

如何安装 @balena/unbzip2-stream?

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

@balena/unbzip2-stream 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@balena/unbzip2-stream 支持 ESM 还是 CommonJS?

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

@balena/unbzip2-stream 可以商用吗?

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

@balena/unbzip2-stream 的下载量有多少?

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

@balena/unbzip2-stream 还在维护吗?

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