DecompressionStream: DecompressionStream() constructor
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2023.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The DecompressionStream() constructor creates a new DecompressionStream object which decompresses a stream of data.
Syntax
new DecompressionStream(format)
Parameters
format-
One of the following compression formats:
"gzip"-
Decompress the stream using the GZIP format.
"deflate"-
Decompress the stream using the DEFLATE algorithm in ZLIB Compressed Data Format. The ZLIB format includes a header with information about the compression method and the uncompressed size of the data, and a trailing checksum for verifying the integrity of the data
"deflate-raw"-
Decompress the stream using the DEFLATE algorithm without a header and trailing checksum.
Exceptions
TypeError-
Thrown if the format passed to the constructor is not supported.
Examples
In this example a gzip-compressed blob is decompressed.
const ds = new DecompressionStream("gzip");
const decompressedStream = blob.stream().pipeThrough(ds);
Specifications
| Specification |
|---|
| Compression> # dom-decompressionstream-decompressionstream> |