Skip to content

AsyncReader.Interface.AsyncReader

Christian d'Heureuse edited this page Oct 28, 2026 · 1 revision

tedious-plus / AsyncReader / AsyncReader

Interface: AsyncReader<T>

Defined in: AsyncReader.ts:15

Basic functionality of an async reader, for procedural processing of a sequence of values.

The end of the sequence is signaled by undefined, so undefined cannot be a legitimate value.

Type Parameters

T

T

Methods

close()?

close?(): Promise<void>;

Defined in: AsyncReader.ts:40

Terminates the reading and releases the resources of the reader.

Must be idempotent: it may be called multiple times, and also after the end has been reached or after read() has failed. In these cases it must succeed without further effect, apart from releasing resources that have not yet been released. Users of a reader, such as AsyncReaderIterator, may therefore call it whenever they are done with the reader, regardless of how the reading ended.

Optional, for readers that do not need to release anything.

Returns

Promise<void>


read()

read(): Promise<T | undefined>;

Defined in: AsyncReader.ts:27

Reads the next value.

After the end has been reached, after an error or after close(), undefined is returned. read() must not be called again before the promise of the previous call has settled.

Returns

Promise<T | undefined>

A promise for the next value, or undefined at the end of the sequence. The promise is rejected if the value cannot be read.

Clone this wiki locally