ByteLengthQueuingStrategy
Streams API 的 ByteLengthQueuingStrategy
接口提供了一个队列策略,该队列策略提供了内置的字节长度并且可以在构造流的时候使用。
构造函数
ByteLengthQueuingStrategy()
-
创建一个新的
ByteLengthQueuingStrategy
对象实例。
实例属性
ByteLengthQueuingStrategy.highWaterMark
只读-
在应用背压之前,内部队列可以包含的字节总数。
实例方法
ByteLengthQueuingStrategy.size()
-
返回给定分块的
byteLength
属性。
示例
js
const queueingStrategy = new ByteLengthQueuingStrategy({ highWaterMark: 1 });
const readableStream = new ReadableStream(
{
start(controller) {
// …
},
pull(controller) {
// …
},
cancel(err) {
console.log("stream error:", err);
},
},
queueingStrategy,
);
const size = queueingStrategy.size(chunk);
规范
Specification |
---|
Streams # blqs-class |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ByteLengthQueuingStrategy | ||||||||||||||
ByteLengthQueuingStrategy() constructor | ||||||||||||||
highWaterMark | ||||||||||||||
size |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.