ByteLengthQueuingStrategy

Streams APIByteLengthQueuingStrategy 接口提供了一个队列策略,该队列策略提供了内置的字节长度并且可以在构造流的时候使用。

构造函数

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 GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
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.

参见