• Treats the chain/generator as a promise

    const ticker = asPromise(tick({ interval: 1000 }));
    const x = await ticker(); // Waits for 1000ms before giving a value

    This will only ever return one value. To return multiple values, it's necessary to call asPromise and await the result in a loop.

    Type Parameters

    • V

    Parameters

    Returns (() => Promise<V | undefined>)

      • (): Promise<V | undefined>
      • Returns Promise<V | undefined>