CountQueuingStrategy.size()

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

语法

size()

参数

无。

返回值

1

示例

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