Function ensureNonEmptyAsyncIterable

  • Ensures that a value is a non-empty async iterable.

    - If the value is not async iterable, `undefined` is returned.
    - If the async iterable yields no items, `undefined` is returned.
    - If it yields at least one item, a fresh async iterable is returned which yields the first peeked item followed by
    the rest, preserving behavior for one-shot async generators.

    Supports both AsyncIterable and (optionally) synchronous Iterable.

    Type Parameters

    • T

    Parameters

    Returns Promise<AsyncIterable<T, any, any>>

    A non-empty async iterable, or undefined.