ReadableStreamBYOBReader: ReadableStreamBYOBReader() コンストラクター

ReadableStreamBYOBReader() コンストラクターは、ReadableStreamBYOBReader オブジェクトのインスタンスを作成して返します。

メモ: 通常、このコンストラクターを手動で使用することはありません。 代わりに、ReadableStream.getReader() メソッドに "byob" を引数につけて使用してください。

構文

js
new ReadableStreamBYOBReader(stream)

引数

stream

読み取られる ReadableStream

返値

ReadableStreamBYOBReader オブジェクトのインスタンス。

例外

TypeError

指定された stream パラメーターが ReadableStream ではないか、別のリーダーによる読み取りのために既にロックされているか、そのストリームコントローラーが ReadableByteStreamController ではありません。

コンストラクターが直接呼び出されることはほとんどありません。 代わりに、表示させるように ReadableStream.getReader() を呼び出してください。

js
const reader = stream.getReader({ mode: "byob" });

仕様書

Specification
Streams Standard
# ref-for-byob-reader-constructor①

ブラウザーの互換性

BCD tables only load in the browser

関連情報