CompressionStream
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 CompressionStream thuộc Compression Streams API dùng để 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
CompressionStream()-
Tạo một
CompressionStreammới.
Thuộc tính thể hiện
CompressionStream.readable-
Trả về thể hiện
ReadableStreamđược điều khiển bởi đối tượng này. CompressionStream.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 luồng được nén bằng thuật toán gzip.
js
const compressedReadableStream = inputReadableStream.pipeThrough(
new CompressionStream("gzip"),
);
Đặc tả kỹ thuật
| Specification |
|---|
| Compression> # compression-stream> |