ByteLengthQueuingStrategy: phương thức size()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2019.
Note: This feature is available in Web Workers.
Phương thức size() của giao diện ByteLengthQueuingStrategy trả về thuộc tính byteLength của chunk đã cho.
Cú pháp
js
size(chunk)
Tham số
chunk-
Một chunk dữ liệu đang được truyền qua stream.
Giá trị trả về
Một số nguyên biểu thị độ dài byte của chunk đã cho.
Ví dụ
js
const queuingStrategy = new ByteLengthQueuingStrategy({ highWaterMark: 1 });
const readableStream = new ReadableStream(
{
start(controller) {
// …
},
pull(controller) {
// …
},
cancel(err) {
console.log("stream error:", err);
},
},
queuingStrategy,
);
const size = queuingStrategy.size(chunk);
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Streams> # blqs-size> |
Khả năng tương thích với trình duyệt
Xem thêm
- Bộ khởi tạo
ByteLengthQueuingStrategy()