Note: This feature is available in Web Workers.
The CompressionStream interface of the Compression Streams API compresses a stream of data. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.
CompressionStream()Creates a new CompressionStream.
CompressionStream.readableReturns the ReadableStream instance controlled by this object.
CompressionStream.writableReturns the WritableStream instance controlled by this object.
In this example a stream is compressed using gzip compression.
const compressedReadableStream = inputReadableStream.pipeThrough(
new CompressionStream("gzip"),
);