ReadableStreamBYOBReader.read()
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 object 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
Specification |
---|
Streams Standard # ref-for-byob-reader-read③ |
Browser compatibility
BCD tables only load in the browser