DecompressionStream()
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.
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 Standard # dom-decompressionstream-decompressionstream |
浏览器兼容性
BCD tables only load in the browser