ReadableStreamBYOBReader: closed プロパティ

Limited availability

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

closedReadableStreamBYOBReader インターフェイスの読み取り専用プロパティで、ストリームが閉じられた場合、またはリーダーのロックが解除された場合に履行され、ストリームがエラーの場合は拒否されるプロミスを返します。

このプロパティにより、ストリーミング処理の終わりに応答するコードを書くことができます。

Promise です。

下記コードは BYOBReader の閉じられたかエラーかの状態を処理するパターンを示します。

js
const reader = stream.getReader({ mode: "byob" });
reader.closed
  .then(() => {
    // 解決 - ストリームを閉じるコード
  })
  .catch(() => {
    // 拒否 - エラーを扱うコード
  });

仕様書

Specification
Streams
# ref-for-generic-reader-closed②

ブラウザーの互換性

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
closed

Legend

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

Full support
Full support
No support
No support

関連情報