DecompressionStream
12345678910111213In this example a request is made to httpbin.org/gzip and the response body is decompressed using gzip decompression.
View this example on [Fiddle](https://fiddle.fastly.dev/fiddle/637add51).
```jsasync function app(event) { const backendResponse = await fetch("https://httpbin.org/gzip", { backend: "origin_0" }); let resp = new Response(backendResponse.body.pipeThrough(new DecompressionStream("gzip")), backendResponse); resp.headers.delete('content-encoding'); return resp;}addEventListener("fetch", event => event.respondWith(app(event)));```Constructor
new DecompressionStream(format: 'deflate' | 'deflate-raw' | 'gzip')Creates a new DecompressionStream object which decompresses a stream of
data.
Parameters
- format: 'deflate' | 'deflate-raw' | 'gzip'
The compression format to use.
Throws
- Throws a
TypeErrorif the format passed to the constructor is not supported.
const gzip = new DecompressionStream("gzip");Properties
let stream = new DecompressionStream("gzip");console.log(stream.readable instanceof ReadableStream); // truelet stream = new DecompressionStream("gzip");console.log(stream.writable instanceof WritableStream); // true