CountQueuingStrategy:size() 方法

Baseline 已廣泛支援

此功能已成熟,並可在多種裝置和瀏覽器版本上使用。自 ⁨2019 年 1 月⁩起,它已在所有瀏覽器中可用。

注意:此功能在 Web Workers 中可用。

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();

規範

規範
Streams
# ref-for-cqs-size②

瀏覽器相容性

另見