ByteLengthQueuingStrategy

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.

ByteLengthQueuingStrategyストリーム API のインターフェイスで、ストリームを構築するときに使用できる組み込みのバイト長キューイング戦略を提供します。

コンストラクター

ByteLengthQueuingStrategy()

新しい ByteLengthQueuingStrategy オブジェクトのインスタンスを作成します。

インスタンスプロパティ

ByteLengthQueuingStrategy.highWaterMark 読取専用

背圧が適用される前に内部キューに格納することができるバイト数の合計。

インスタンスメソッド

ByteLengthQueuingStrategy.size()

指定されたチャンクの byteLength プロパティを返します。

js
const queueingStrategy = new ByteLengthQueuingStrategy({ highWaterMark: 1024 });

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

const size = queueingStrategy.size(chunk);

仕様書

Specification
Streams Standard
# blqs-class

ブラウザーの互換性

BCD tables only load in the browser

関連情報