ThroughSequence.next()method
next(value?: N | undefined): Promise<IteratorResult<T, R | undefined>>
new ThroughSequence<T, R, N>(source: AsyncIterator<T, R | undefined, N | undefined>)
| Param | Type | |
|---|---|---|
source | AsyncIterator<T, Rundefined, Nundefined> | Async iterator to pull values from. required |
| Return | |
|---|---|
ThroughSequence<T, R, N> | Async iterable that pulls values from a source async iterable. |
| Property | Type | |
|---|---|---|
.source | AsyncIterator<T, Rundefined, Nundefined> | Source async iterator that this sequence pulls values from. required readonly |
Async iterable that pulls values from a source async iterable.
AsyncIterator into an AsyncIterableIteratorthrow() and return() are always set on an AsyncIteratorWraps a source AsyncIterator and presents it as a full Sequence. Use it to turn a bare async iterator into a reusable AsyncIterable, and to guarantee return() and throw() are always available — delegating to the source when it provides them.
ThroughSequence is the base class for LazySequence and InspectSequence, which add behaviour on top of the pass-through.
import { ThroughSequence } from "shelving/sequence";
async function* numbers() {
yield 1; yield 2; yield 3;
}
const seq = new ThroughSequence(numbers());
for await (const n of seq) {
console.log(n); // 1, 2, 3
}const seq = new ThroughSequence(someAsyncIterator); for await (const value of seq) console.log(value);
next(value?: N | undefined): Promise<IteratorResult<T, R | undefined>>