ByteLengthQueuingStrategy.size()
Baseline 2022
Newly available
Since June 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
ByteLengthQueuingStrategy
接口的 size()
方法返回给定分块的 byteLength
属性。
语法
js
size(chunk)
参数
chunk
-
一个通过流传递的数据分块。
返回值
一个整数,表示给定分块的字节长度。
示例
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 = queueingStrategy.size(chunk);
规范
Specification |
---|
Streams Standard # blqs-size |
浏览器兼容性
BCD tables only load in the browser