CountQueuingStrategy: highWaterMark 屬性

Baseline 已廣泛支援

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

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

只讀的 CountQueuingStrategy.highWaterMark 屬性返回在應用背壓之前,內部佇列可以容納的塊的總數。

一個整數,表示塊的數量。

示例

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

const readableStream = new ReadableStream(
  {
    start(controller) {
      // …
    },
    pull(controller) {
      // …
    },
    cancel(err) {
      console.log("stream error:", err);
    },
  },
  queuingStrategy,
);

const size = queuingStrategy.size(chunk);
console.log(`highWaterMark value: ${queuingStrategy.highWaterMark}$`);

規範

規範
Streams
# ref-for-cqs-high-water-mark①

瀏覽器相容性

另見