Class: Reader

Reader()

new Reader()

A wrapper class over the native ReadableStreamDefaultReader. This additionally implements pushing back data on the stream, which lets us implement peeking and a host of convenience functions. It also lets you read data other than streams, such as a Uint8Array.
Source:

Methods

(async) peekBytes() → {Promise.<(Uint8Array|String|Undefined)>}

Peek (look ahead) a specific amount of bytes/characters, unless the stream ends before that amount.
Source:
Returns:
Type
Promise.<(Uint8Array|String|Undefined)>

(async) read() → {Promise.<Object>}

Read a chunk of data.
Source:
Returns:
Either { done: false, value: Uint8Array | String } or { done: true, value: undefined }
Type
Promise.<Object>

(async) readByte() → {Promise.<(Number|String|Undefined)>}

Read a single byte/character.
Source:
Returns:
Type
Promise.<(Number|String|Undefined)>

(async) readBytes() → {Promise.<(Uint8Array|String|Undefined)>}

Read a specific amount of bytes/characters, unless the stream ends before that amount.
Source:
Returns:
Type
Promise.<(Uint8Array|String|Undefined)>

(async) readLine() → {Promise.<(String|Undefined)>}

Read up to and including the first \n character.
Source:
Returns:
Type
Promise.<(String|Undefined)>

(async) readToEnd(join) → {Promise.<(Uint8array|String|Any)>}

Read the stream to the end and return its contents, concatenated by the join function (defaults to streams.concat).
Parameters:
Name Type Description
join function
Source:
Returns:
the return value of join()
Type
Promise.<(Uint8array|String|Any)>

releaseLock()

Allow others to read the stream.
Source:

unshift(…values)

Push data to the front of the stream.
Parameters:
Name Type Attributes Description
values Uint8Array | String | Undefined <repeatable>
Source: