TransformStreamDefaultController: enqueue() メソッド

Invalid slug for templ/sidebar: Streams API

enqueue()TransformStreamDefaultController インターフェイスのメソッドで、このストリームの読み取り可能側にある指定されたチャンクをキューに入れます。

読み取り可能なストリームとチャンクについて詳しくは、読み取り可能なストリームの使用を参照してください。

構文

js
enqueue(chunk)

引数

chunk

キューに入れられるチャンク。チャンクとは単一のデータのことです。データの種類は問いません。ストリームは様々な型のチャンクを格納することができます。

返値

なし (undefined)。

例外

TypeError

ストリームが読み取り可能ではありません。 これは、ストリームが controller.error() によってエラーになった場合や、コントローラーの controller.close() メソッドが名付けられずに閉じられた場合に発生します。

この例では、エンコードされたチャンクが enqueue() メソッドを使用してキューに渡されます。

js
const textEncoderStream = new TransformStream({
  transform(chunk, controller) {
    controller.enqueue(new TextEncoder().encode(chunk));
  },
  flush(controller) {
    controller.terminate();
  },
});

仕様書

Specification
Streams
# ts-default-controller-enqueue

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
enqueue

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support