ByteLengthQueuingStrategy
注意:此功能在 Web Workers 中可用。
ByteLengthQueuingStrategy 接口属于 Streams API,它提供了一种内置的字节长度排队策略,可用于构建流时使用。
构造函数
ByteLengthQueuingStrategy()-
创建一个新的
ByteLengthQueuingStrategy对象实例。
实例属性
ByteLengthQueuingStrategy.highWaterMark只读-
在应用 背压 之前,内部队列中可以包含的总字节数。
实例方法
ByteLengthQueuingStrategy.size()-
返回给定块的
byteLength属性。
示例
js
const queueingStrategy = new ByteLengthQueuingStrategy({ highWaterMark: 1024 });
const readableStream = new ReadableStream(
{
start(controller) {
// …
},
pull(controller) {
// …
},
cancel(err) {
console.log("stream error:", err);
},
},
queueingStrategy,
);
const size = queueingStrategy.size(chunk);
规范
| 规范 |
|---|
| Streams # blqs-class |
浏览器兼容性
加载中…