ByteLengthQueuingStrategy: 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.

size()ByteLengthQueuingStrategy インターフェイスのメソッドで、指定されたチャンクの byteLength プロパティを返します。

構文

js
size(chunk)

引数

chunk

ストリームを通して渡されるデータのチャンク。

返値

指定されたチャンクのバイト長を表す整数です。

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

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

const size = queueingStrategy.size(chunk);

仕様書

Specification
Streams Standard
# blqs-size

ブラウザーの互換性

BCD tables only load in the browser

関連情報