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 GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
enqueue |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.