DecompressionStream

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.

Giao diện DecompressionStream thuộc Compression Streams API dùng để giải nén một luồng dữ liệu. Giao diện này có hình dạng giống như TransformStream, cho phép sử dụng trong ReadableStream.pipeThrough() và các phương thức tương tự.

Bộ khởi tạo

DecompressionStream()

Tạo một DecompressionStream mới.

Thuộc tính thể hiện

DecompressionStream.readable

Trả về thể hiện ReadableStream được điều khiển bởi đối tượng này.

DecompressionStream.writable

Trả về thể hiện WritableStream được điều khiển bởi đối tượng này.

Ví dụ

Trong ví dụ này, một blob được giải nén bằng thuật toán gzip.

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

Đặc tả kỹ thuật

Thông số kỹ thuật
Compression
# decompression-stream

Tương thích trình duyệt

Xem thêm