Class AwaitableAsyncGenerator<T>

A class that wraps an AsyncGenerator and makes it both iterable and awaitable as a Promise. When used as a Promise, it will resolve to an array containing all generated values. When used as an AsyncGenerator, it behaves like the original generator.

Type Parameters

  • T

Hierarchy

  • AwaitableAsyncGenerator

Implements

  • AsyncGenerator<T>
  • Promise<T[]>

Constructors

Properties

[toStringTag]: "AwaitableAsyncGenerator" = 'AwaitableAsyncGenerator'
generator: AsyncGenerator<T, void, unknown>
promiseResult?: Promise<T[]>

Methods

  • Returns AsyncGenerator<T, void, unknown>

  • Type Parameters

    • TResult = never

    Parameters

    • Optional onrejected: null | ((reason) => TResult | PromiseLike<TResult>)

    Returns Promise<T[] | TResult>

  • Parameters

    • Optional onfinally: null | (() => void)

    Returns Promise<T[]>

  • Parameters

    • Rest ...__namedParameters: [] | [unknown]

    Returns Promise<IteratorResult<T, void>>

  • Parameters

    • value: void | PromiseLike<void>

    Returns Promise<IteratorResult<T, void>>

  • Type Parameters

    • TResult1 = T[]

    • TResult2 = never

    Parameters

    • Optional onfulfilled: null | ((value) => TResult1 | PromiseLike<TResult1>)
    • Optional onrejected: null | ((reason) => TResult2 | PromiseLike<TResult2>)

    Returns Promise<TResult1 | TResult2>

  • Parameters

    • e: any

    Returns Promise<IteratorResult<T, void>>