Function toAsync

  • Converts any synchronous iterable into asynchronous one.

    It makes possible to use asynchronous-only operators downstream, while also correctly casting all types in the pipeline, avoiding any ambiguity between synchronous and asynchronous iterables.

    const i = pipe(
    toAsync(source), // make iterable asynchronous
    delay(500) // now can use asynchronous operators
    );
    • Passing it an already asynchronous iterable will just reuse it.
    • All indexed types are optimized for performance.

    Type Parameters

    • T

    Parameters

    Returns AsyncIterable<T>

    Throws

    TypeError: 'Cannot convert to AsyncIterable' when conversion is not possible.

    See