@nevware21/ts-utils
    Preparing search index...

    Type Alias IAsyncIterable<T>

    IAsyncIterable: SymbolConstructor extends { asyncIterator: infer S }
        ? symbol extends S
            ? any
            : { [K in Extract<S, PropertyKey>]: () => IAsyncIterator<T> }
        : object

    A value which can be iterated asynchronously, it is compatible with the native AsyncIterable type which is only available when using the ES2018 (or later) lib, so that the exported types can be used without that lib.

    • When the compiler can use Symbol.asyncIterator as a key (TypeScript v4.3 and later with the ES2018 or later lib) this contains the [Symbol.asyncIterator] function, so a native AsyncIterable can be assigned to it and vice-versa and it can be used with for await.
    • Earlier versions of TypeScript with the ES2018 or later lib define the symbol as a plain symbol which can't be used as a key, so this is any which can still be assigned to a native AsyncIterable and be used with for await. As a type guard (isAsyncIterable) for any doesn't narrow, a value declared as a union with AsyncIterable is not narrowed when the guard is true, and is never when it is false (so check the other types first).
    • Without the ES2018 or later lib Symbol.asyncIterator is not defined, so this is object.

    Type Parameters

    • T = any

      Identifies the type of the values returned by the async iterator

    0.20.0