Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 62x 62x 7970x 7970x 19438x 19438x 19438x 19438x | import './polyfill'; /** * Next function which returns `undefined` or a value of type `T`. * This is used in iterators that can end with an `undefined` value, which * indicates the end of iteration. */ export type UndEndNext<T> = () => undefined | T; /** * Creates an iterator out of {@linke UndefIterator} function. */ export class UndEndIterator<T> extends Iterator<T, T> implements IterableIterator<T> { constructor(private readonly n: UndEndNext<T>) { super(); } public next(): IteratorResult<T, T> { const value = this.n(); return new Res(value, value === undefined) as IteratorResult<T>; } } class Res<T> { constructor( public readonly value: T, public readonly done: boolean, ) {} } |