ReadableStreamBYOBReader.read()

Draft: This page is not complete.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The read() method of the ReadableStreamBYOBReader interface returns a Promise that resolves with an obect representing the next chunk in the stream's queue.

Syntax

var promise = readableStreamBYOBReader.read(view);

Parameters

view

The view to be read into.

Return value

A Promise, which fulfills/rejects with a result depending on the state of the stream. The following are possible:

  • If a chunk is available, the promise fulfills with an object of the form { value: theChunk, done: false }.
  • If the stream is closed, the promise fulfills with an object of the form { value: undefined, done: true }.
  • If the stream throws an error, the promise rejects with the relevant error.

Exceptions

TypeError

The source object is not a ReadableStreamBYOBReader, the stream has no owner, the view is not an object or has become detached, or the view's length is 0.

Examples

TBD.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
read
89
89
No
No
No
No
89
89
No
No
No
15.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader/read