read()
The read()
method of the ReadableStreamDefaultReader interface returns a promise providing access to the next chunk in the stream’s internal queue.
Returns
A promise which fullfils or rejects with a value depending on the state of the stream:
- If a chunk is available, the promise resolves with an object of the form:
{ done: false, value: chunkValue }
. - If the stream is closed and no more data is available, the promise resolves with an object of the form:
{ done: true, value: undefined }
. - If the stream is errored, the promise rejects with the error that caused the stream to error.