ReadableByteStreamController: desiredSize プロパティ

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

メモ: この機能はウェブワーカー内で利用可能です。

desiredSizeReadableByteStreamController インターフェイスの読み取り専用プロパティで、ストリームの内部キューを満たすために必要な「希望サイズ」を返します。

この値は、ストリームが、基盤となるソースへの推奨する流量を示すために使用します。 データ流入のスロットリングや一時停止に対応しているソース(すべてではありません)は、ストリームバッファーの desiredSize が正の値で、使用可能な限りゼロに近づくように流入を制御する必要があります。

desiredSize は下流コンシューマーの背圧を適用するために使用します。

整数です。キューがいっぱいになった場合、これは負になる可能性があることに注意してください。

ストリームがエラーになったときは null、閉じられていたときは 0 になる可能性があります。

仕様書の A readable stream with an underlying push source and backpressure support の例には、ストリームが一杯になったことを手動で検出して背圧をかけるために desiredSize を使用する良い例が示されています。

この例では既定のソースを使用していますが、概念は読み取り可能なバイトソースとまったく同じです。

仕様書

Specification
Streams
# ref-for-rbs-controller-desired-size②

ブラウザーの互換性

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
desiredSize

Legend

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

Full support
Full support
No support
No support

関連情報