CompressionStream

Baseline 2023

Newly available

Since May 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Compression Streams APICompressionStream 接口是一个用于压缩数据流的 API。

构造函数

CompressionStream()

创建新的 CompressionStream

实例属性

CompressionStream.readable

返回由此对象控制的 ReadableStream 实例。

CompressionStream.writable

返回由此对象控制的 WritableStream 实例。

示例

在该示例中,使用 gzip 对流进行压缩。

js
const compressedReadableStream = inputReadableStream.pipeThrough(
  new CompressionStream("gzip"),
);

规范

Specification
Compression Standard
# compression-stream

浏览器兼容性

BCD tables only load in the browser