minizlib

中文文档
3.1.0发布于 2025/09/22MITTypeScriptESM + CJS近 30 天下载 3.3亿

A small fast zlib stream built on minipass and Node.js's zlib binding.

原始使用文档
文档目录4 节
  1. How does this differ from the streams in 'node:zlib' ?
  2. Classes
  3. USAGE
  4. REPRODUCIBLE BUILDS

minizlib

A fast zlib stream built on minipass and Node.js's zlib binding.

This module was created to serve the needs of node-tar and minipass-fetch.

Brotli is supported in versions of node with a Brotli binding.

How does this differ from the streams in 'node:zlib'?

First, there are no convenience methods to compress or decompress a buffer. If you want those, use the built-in zlib module. This is only streams. That being said, Minipass streams to make it fairly easy to use as one-liners: new zlib.Deflate().end(data).read() will return the deflate compressed result.

This module compresses and decompresses the data as fast as you feed it in. It is synchronous, and runs on the main process thread. Zlib and Brotli operations can be high CPU, but they're very fast, and doing it this way means much less bookkeeping and artificial deferral.

Node's built in zlib streams are built on top of stream.Transform. They do the maximally safe thing with respect to consistent asynchrony, buffering, and backpressure.

See Minipass for more on the differences between Node.js core streams and Minipass streams, and the convenience methods provided by that class.

Classes

  • Deflate
  • Inflate
  • Gzip
  • Gunzip
  • DeflateRaw
  • InflateRaw
  • Unzip
  • BrotliCompress (Node v10 and higher)
  • BrotliDecompress (Node v10 and higher)
  • ZstdCompress (Node v22.15 and higher)
  • ZstdDecompress (Node v22.15 and higher)

USAGE

import { BrotliDecompress } from 'minizlib'
// or: const BrotliDecompress = require('minizlib')

const input = sourceOfCompressedData()
const decode = new BrotliDecompress()
const output = whereToWriteTheDecodedData()
input.pipe(decode).pipe(output)

REPRODUCIBLE BUILDS

To create reproducible gzip compressed files across different operating systems, set portable: true in the options. This causes minizlib to set the OS indicator in byte 9 of the extended gzip header to 0xFF for 'unknown'.

版本与发布记录

minizlib 共发布 24 个版本,首次发布于 2017/03/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.0latest2025/09/221.1 年前
3.0.22025/04/011.6 年前
3.0.12024/04/072 年前
3.0.02024/03/192 年前
2.1.22020/08/156 年前
2.1.1-testing-publish-with-beta-v7-npm.02020/08/156 年前

关于 minizlib 的常见问题

minizlib 是什么?

A small fast zlib stream built on minipass and Node.js's zlib binding.

如何安装 minizlib?

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

minizlib 支持 TypeScript 吗?

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

minizlib 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

minizlib 需要什么版本的 Node.js?

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

minizlib 可以商用吗?

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

minizlib 的下载量有多少?

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

minizlib 还在维护吗?

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