CountQueuingStrategy.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.

CountQueuingStrategy 接口的 size() 方法始终返回 1,因此队列的总大小是队列中所有分块的数量。

语法

js
size()

参数

无。

返回值

1

示例

js
const queuingStrategy = new CountQueuingStrategy({ highWaterMark: 1 });

const writableStream = new WritableStream(
  {
    // Implement the sink
    write(chunk) {
      // …
    },
    close() {
      // …
    },
    abort(err) {
      console.log("Sink error:", err);
    },
  },
  queuingStrategy,
);

const size = queuingStrategy.size();

规范

Specification
Streams Standard
# ref-for-cqs-size②

浏览器兼容性

BCD tables only load in the browser

参见