W3cubDocs

/Web APIs

DecompressionStream: DecompressionStream() constructor

The DecompressionStream() constructor creates a new DecompressionStream object which decompresses a stream of data.

Syntax

js

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.

js

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
DecompressionStream 80 80 113 No 67 16.4 80 80 113 57 16.4 13.0
deflate 80 80 113 No 67 16.4 80 80 113 57 16.4 13.0
deflate-raw 103 103 113 No 89 16.4 103 103 113 71 16.4 20.0
gzip 80 80 113 No 67 16.4 80 80 113 57 16.4 13.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream