DecompressionStream: DecompressionStream() constructor

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Compression Streams API")}}{{AvailableInWorkers}}

The **DecompressionStream()** constructor creates a new {{domxref("DecompressionStream")}} object which decompresses a stream of data.

Syntax

js-nolint
new DecompressionStream(format)

Parameters

  • format
  • : One of the following compression formats:
  • "brotli"
  • : Decompress the stream using the Brotli algorithm.
  • "gzip"
  • : Decompress the stream using the GZIP algorithm.
  • "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.
  • "zstd"
  • : Decompress the stream using the ZSTD algorithm.

Exceptions

  • {{jsxref("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

{{Specifications}}

Browser compatibility

{{Compat}}