Global

Members

(constant) externalBuffer

The external buffer is used to store values that have been peeked or unshifted from the original stream. Because of how streams are implemented, such values cannot be "put back" in the original stream, but they need to be returned first when reading from the input again.

Source:

Methods

(async) cancel(input, reason) → {Promise.<Any>}

Cancel a stream.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
reason Any
Source:
Returns:

indicates when the stream has been canceled

Type
Promise.<Any>

clone(input) → {ReadableStream|Uint8array|String}

Clone a Stream for reading it twice. The input stream can still be read after clone()ing. Reading from the clone will pull from the input stream. The input stream will only be canceled if both the clone and the input stream are canceled.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
Source:
Returns:

cloned input

Type
ReadableStream | Uint8array | String

concat(Array) → {Uint8array|String|ReadableStream}

Concat a list of Uint8Arrays, Strings or Streams The caller should not mix Uint8Arrays with Strings, but may mix Streams with non-Streams.

Parameters:
Name Type Description
Array Array.<(Uint8array|String|ReadableStream)>

of Uint8Arrays/Strings/Streams to concatenate

Source:
Returns:

Concatenated array

Type
Uint8array | String | ReadableStream

concatArrayStream(list) → {ArrayStream}

Concat a list of ArrayStreams

Parameters:
Name Type Description
list Array.<(ArrayStream|Uint8array|String)>

Array of Uint8Arrays/Strings/ArrayStreams to concatenate

Source:
Returns:

Concatenated streams

Type
ArrayStream

concatStream(list) → {ReadableStream}

Concat a list of Streams

Parameters:
Name Type Description
list Array.<(ReadableStream|Uint8array|String)>

Array of Uint8Arrays/Strings/Streams to concatenate

Source:
Returns:

Concatenated list

Type
ReadableStream

concatUint8Array(Array) → {Uint8array}

Concat Uint8Arrays

Parameters:
Name Type Description
Array Array.<Uint8array>

of Uint8Arrays to concatenate

Source:
Returns:

Concatenated array

Type
Uint8array

fromAsync(fn) → {ArrayStream}

Convert an async function to an ArrayStream. When the function returns, its return value is written to the stream.

Parameters:
Name Type Description
fn function
Source:
Returns:
Type
ArrayStream

getReader(input) → {Reader}

Get a Reader

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
Source:
Returns:
Type
Reader

getWriter(input) → {Writer}

Get a Writer

Parameters:
Name Type Description
input WritableStream
Source:
Returns:
Type
Writer

isArrayStream(input) → {boolean}

Check whether data is an ArrayStream

Parameters:
Name Type Description
input Any

data to check

Source:
Returns:
Type
boolean

isStream(input) → {'web'|'node'|'array'|'web-like'|false}

Check whether data is a Stream, and if so of which type

Parameters:
Name Type Description
input Any

data to check

Source:
Returns:
Type
'web' | 'node' | 'array' | 'web-like' | false

isUint8Array(input) → {Boolean}

Check whether data is a Uint8Array

Parameters:
Name Type Description
input Any

data to check

Source:
Returns:
Type
Boolean

overwrite(input, clone)

Modify a stream object to point to a different stream object. This is used internally by clone() and passiveClone() to provide an abstraction over tee().

Parameters:
Name Type Description
input ReadableStream
clone ReadableStream
Source:

parse(input, fn) → {Any}

Parse a stream using a helper function which is passed a Reader. The reader additionally has a remainder() method which returns a stream pointing to the remainder of input, and is linked to input for cancelation.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
fn function
Source:
Returns:

the return value of fn()

Type
Any

passiveClone(input) → {ReadableStream|Uint8array|String}

Clone a Stream for reading it twice. Data will arrive at the same rate as the input stream is being read. Reading from the clone will NOT pull from the input stream. Data only arrives when reading the input stream. The input stream will NOT be canceled if the clone is canceled, only if the input stream are canceled. If the input stream is canceled, the clone will be errored.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
Source:
Returns:

cloned input

Type
ReadableStream | Uint8array | String

(async) pipe(input, target, (optional)) → {Promise.<undefined>}

Pipe a readable stream to a writable stream. Don't throw on input stream errors, but forward them to the output stream.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
target WritableStream
(optional) Object

options

Source:
Returns:

Promise indicating when piping has finished (input stream closed or errored)

Type
Promise.<undefined>

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

Read a stream to the end and return its contents, concatenated by the join function (defaults to concat).

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
join function
Source:
Returns:

the return value of join()

Type
Promise.<(Uint8array|String|Any)>

slice(input) → {ReadableStream|Uint8array|String}

Return a stream pointing to a part of the input stream.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
Source:
Returns:

clone

Type
ReadableStream | Uint8array | String

tee(input) → {Array.<(ReadableStream|Uint8array|String)>}

Tee a Stream for reading it twice. The input stream can no longer be read after tee()ing. Reading either of the two returned streams will pull from the input stream. The input stream will only be canceled if both of the returned streams are canceled.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
Source:
Returns:

array containing two copies of input

Type
Array.<(ReadableStream|Uint8array|String)>

toArrayStream(input) → {ArrayStream}

Convert non-streamed data to ArrayStream; this is a noop if input is already a stream.

Parameters:
Name Type Description
input Object

data to convert

Source:
Returns:

Converted data

Type
ArrayStream

toStream(input) → {ReadableStream}

Convert data to Stream

Parameters:
Name Type Description
input ReadableStream | Uint8array | String

data to convert

Source:
Returns:

Converted data

Type
ReadableStream

transform(input, process, finish) → {ReadableStream|Uint8array|String}

Transform a stream using helper functions which are called on each chunk, and on stream close, respectively.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
process function
finish function
Source:
Returns:
Type
ReadableStream | Uint8array | String

transformPair(input, fn) → {ReadableStream}

Transform a stream using a helper function which is passed a readable and a writable stream. This function also maintains the possibility to cancel the input stream, and does so on cancelation of the output stream, despite cancelation normally being impossible when the input stream is being read from.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
fn function
Source:
Returns:
Type
ReadableStream

transformRaw(input, (optional)) → {ReadableStream}

Pipe a readable stream through a transform stream.

Parameters:
Name Type Description
input ReadableStream | Uint8array | String
(optional) Object

options

Source:
Returns:

transformed stream

Type
ReadableStream

transformWithCancel(cancel) → {TransformStream}

Create a cancelable TransformStream.

Parameters:
Name Type Description
cancel function
Source:
Returns:
Type
TransformStream