read method

The read method allows access to the next chunk from the stream’s queue.


var retval =;


This method has no parameters.

Return value

Type: Promise<any>

A promise for any object.

Standards information


The value (chunk) that is returned is a UINT8Array of arbitrary length.

The promise will be completed as data is available.

  • An available chunk will prompt a promise that will resolve with an object of the form { value: theChunk, done: false }.
  • If the stream becomes closed, the promise will resolve with an object of the form { value: undefined, done: true }.
  • If the stream becomes errored, the promise will be rejected.

Any promises will be complete that are still outstanding after the last chunk is returned for the situation that the stream may not be closed, but the last of the data may be read (EOF, End of File reached). Any remaining read promises or future ones will be complete with an object of { value: undefined, done: true }.

See also