此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

DecompressionStream()

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年5月.

* Some parts of this feature may have varying levels of support.

DecompressionStream() 构造函数创建一个新的 DecompressionStream,该对象用于解压数据流。

语法

js
new DecompressionStream(format)

参数

format

以下允许的解压格式之一:

  • "gzip"
  • "deflate"
  • "deflate-raw"

异常

TypeError

如果传递给构造函数的格式是不支持的则抛出。

示例

在此示例中,使用 gzip 对 blob 解压缩。

js
const ds = new DecompressionStream("gzip");
const decompressedStream = blob.stream().pipeThrough(ds);

规范

Specification
Compression
# dom-decompressionstream-decompressionstream

浏览器兼容性