Interface IAsyncEnumerable<TSource>

Async Iterable type with methods from LINQ.

interface IAsyncEnumerable<TSource> {
    "[asyncIterator]"(): AsyncIterableIterator<TSource>;
    aggregate(func: (x: TSource, y: TSource) => TSource): Promise<TSource>;
    aggregate<TAccumulate>(
        seed: TAccumulate,
        func: (x: TAccumulate, y: TSource) => TAccumulate,
    ): Promise<TAccumulate>;
    aggregate<TAccumulate, TResult>(
        seed: TAccumulate,
        func: (x: TAccumulate, y: TSource) => TAccumulate,
        resultSelector: (x: TAccumulate) => TResult,
    ): Promise<TResult>;
    all(predicate: (x: TSource) => boolean): Promise<boolean>;
    allAsync(predicate: (x: TSource) => Promise<boolean>): Promise<boolean>;
    any(predicate?: (x: TSource) => boolean): Promise<boolean>;
    anyAsync(predicate: (x: TSource) => Promise<boolean>): Promise<boolean>;
    append(element: TSource): IAsyncEnumerable<TSource>;
    asParallel(): IParallelEnumerable<TSource>;
    average(this: IAsyncParallel<number>): Promise<number>;
    average(selector: (x: TSource) => number): Promise<number>;
    averageAsync(selector: (x: TSource) => Promise<number>): Promise<number>;
    chunk(size: number): IAsyncEnumerable<TSource[]>;
    concatenate(second: IAsyncEnumerable<TSource>): IAsyncEnumerable<TSource>;
    contains(
        value: TSource,
        comparer?: IEqualityComparer<TSource>,
    ): Promise<boolean>;
    containsAsync(
        value: TSource,
        comparer: IAsyncEqualityComparer<TSource>,
    ): Promise<boolean>;
    count(predicate?: (x: TSource) => boolean): Promise<number>;
    countAsync(predicate: (x: TSource) => Promise<boolean>): Promise<number>;
    defaultIfEmpty(
        defaultValue: TSource | Promise<TSource>,
    ): IAsyncEnumerable<TSource>;
    distinct(comparer?: IEqualityComparer<TSource>): IAsyncEnumerable<TSource>;
    distinctAsync(
        comparer: IAsyncEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    each(action: (x: TSource) => void): IAsyncEnumerable<TSource>;
    eachAsync(action: (x: TSource) => Promise<void>): IAsyncEnumerable<TSource>;
    elementAt(index: number): Promise<TSource>;
    elementAtOrDefault(index: number): Promise<null | TSource>;
    except(
        second: IAsyncEnumerable<TSource>,
        comparer?: IEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    exceptAsync(
        second: IAsyncEnumerable<TSource>,
        comparer: IAsyncEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    first(predicate?: (x: TSource) => boolean): Promise<TSource>;
    firstAsync(predicate: (x: TSource) => Promise<boolean>): Promise<TSource>;
    firstOrDefault(
        predicate?: (x: TSource) => boolean,
    ): Promise<null | TSource>;
    firstOrDefaultAsync(
        predicate: (x: TSource) => Promise<boolean>,
    ): Promise<null | TSource>;
    groupBy<TKey extends SelectorKeyType>(
        keySelector: (x: TSource) => TKey,
    ): IAsyncEnumerable<IGrouping<TKey, TSource>>;
    groupBy<TKey>(
        keySelector: (x: TSource) => TKey,
        comparer: IEqualityComparer<TKey>,
    ): IAsyncEnumerable<IGrouping<TKey, TSource>>;
    groupByAsync<TKey extends SelectorKeyType>(
        keySelector: (x: TSource) => TKey | Promise<TKey>,
    ): IAsyncEnumerable<IGrouping<TKey, TSource>>;
    groupByAsync<TKey>(
        keySelector: (x: TSource) => TKey | Promise<TKey>,
        comparer: IEqualityComparer<TKey> | IAsyncEqualityComparer<TKey>,
    ): IAsyncEnumerable<IGrouping<TKey, TSource>>;
    groupByWithSel<TKey extends SelectorKeyType, TElement>(
        keySelector: (x: TSource) => TKey,
        elementSelector: (x: TSource) => TElement,
        comparer?: IEqualityComparer<TKey>,
    ): IAsyncEnumerable<IGrouping<TKey, TElement>>;
    groupByWithSel<TKey, TElement>(
        keySelector: (x: TSource) => TKey,
        elementSelector: (x: TSource) => TElement,
        comparer: IEqualityComparer<TKey>,
    ): IAsyncEnumerable<IGrouping<TKey, TElement>>;
    groupJoin<TInner, TKey, TResult>(
        inner: Iterable<TInner, any, any> | AsyncIterable<TInner, any, any>,
        outerKeySelector: (value: TSource) => TKey,
        innerKeySelector: (value: TInner) => TKey,
        resultSelector: (element: TSource, collection: TInner[]) => TResult,
        comparer?: IEqualityComparer<TKey>,
    ): IAsyncEnumerable<TResult>;
    groupJoinAsync<TInner, TKey, TResult>(
        inner: Iterable<TInner, any, any> | AsyncIterable<TInner, any, any>,
        outerKeySelector: (value: TSource) => TKey | Promise<TKey>,
        innerKeySelector: (value: TInner) => TKey | Promise<TKey>,
        resultSelector: (
            element: TSource,
            collection: TInner[],
        ) => TResult | Promise<TResult>,
        comparer?: IEqualityComparer<TKey>,
    ): IAsyncEnumerable<TResult>;
    intersect(
        second: IAsyncEnumerable<TSource>,
        comparer?: IEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    intersectAsync(
        second: IAsyncEnumerable<TSource>,
        comparer: IAsyncEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    joinByKey<TInner, TKey, TResult>(
        inner: IAsyncEnumerable<TInner>,
        outerKeySelector: (x: TSource) => TKey,
        innerKeySelector: (x: TInner) => TKey,
        resultSelector: (x: TSource, y: TInner) => TResult,
        comparer?: IEqualityComparer<TKey>,
    ): IAsyncEnumerable<TResult>;
    last(predicate?: (x: TSource) => boolean): Promise<TSource>;
    lastAsync(predicate: (x: TSource) => Promise<boolean>): Promise<TSource>;
    lastOrDefault(predicate?: (x: TSource) => boolean): Promise<null | TSource>;
    lastOrDefaultAsync(
        predicate: (x: TSource) => Promise<boolean>,
    ): Promise<null | TSource>;
    max(this: IAsyncParallel<number>): Promise<number>;
    max(selector: (x: TSource) => number): Promise<number>;
    maxAsync(selector: (x: TSource) => Promise<number>): Promise<number>;
    min(this: IAsyncParallel<number>): Promise<number>;
    min(selector: (x: TSource) => number): Promise<number>;
    minAsync(selector: (x: TSource) => Promise<number>): Promise<number>;
    ofType<TType extends OfType>(
        type: TType,
    ): IAsyncEnumerable<InferType<TType>>;
    order(comparer?: IComparer<TSource>): IOrderedAsyncEnumerable<TSource>;
    orderBy<TKey>(
        predicate: (x: TSource) => TKey,
        comparer?: IComparer<TKey>,
    ): IOrderedAsyncEnumerable<TSource>;
    orderByAsync<TKey>(
        predicate: (x: TSource) => Promise<TKey>,
        comparer?: IComparer<TKey>,
    ): IOrderedAsyncEnumerable<TSource>;
    orderByDescending<TKey>(
        predicate: (x: TSource) => TKey,
        comparer?: IComparer<TKey>,
    ): IOrderedAsyncEnumerable<TSource>;
    orderByDescendingAsync<TKey>(
        predicate: (x: TSource) => Promise<TKey>,
        comparer?: IComparer<TKey>,
    ): IOrderedAsyncEnumerable<TSource>;
    orderDescending(
        comparer?: IComparer<TSource>,
    ): IOrderedAsyncEnumerable<TSource>;
    partition(
        predicate: (x: TSource) => boolean,
    ): Promise<[pass: TSource[], fail: TSource[]]>;
    partitionAsync(
        predicate: (x: TSource) => Promise<boolean>,
    ): Promise<[pass: TSource[], fail: TSource[]]>;
    prepend(element: TSource): IAsyncEnumerable<TSource>;
    reverse(): IAsyncEnumerable<TSource>;
    select<TResult>(
        selector: (x: TSource, index: number) => TResult,
    ): IAsyncEnumerable<TResult>;
    select<TKey extends string | number | symbol>(
        key: TKey,
    ): IAsyncEnumerable<TSource[TKey]>;
    selectAsync<TResult>(
        selector: (x: TSource, index: number) => Promise<TResult>,
    ): IAsyncEnumerable<TResult>;
    selectAsync<TKey extends string | number | symbol, TResult>(
        this: IAsyncEnumerable<{ [key: string]: Promise<TResult> }>,
        key: TKey,
    ): IAsyncEnumerable<TResult>;
    selectMany<TResult>(
        selector: (x: TSource, index: number) => Iterable<TResult>,
    ): IAsyncEnumerable<TResult>;
    selectMany<
        TBindedSource extends { [key: string]: Iterable<TOut, any, any> },
        TOut,
    >(
        this: IAsyncEnumerable<TBindedSource>,
        selector: keyof TBindedSource,
    ): IAsyncEnumerable<TOut>;
    selectManyAsync<TResult>(
        selector: (
            x: TSource,
            index: number,
        ) => Promise<Iterable<TResult, any, any>>,
    ): IAsyncEnumerable<TResult>;
    sequenceEquals(
        second: AsyncIterable<TSource>,
        comparer?: IEqualityComparer<TSource>,
    ): Promise<boolean>;
    sequenceEqualsAsync(
        second: AsyncIterable<TSource>,
        comparer: IAsyncEqualityComparer<TSource>,
    ): Promise<boolean>;
    single(predicate?: (x: TSource) => boolean): Promise<TSource>;
    singleAsync(predicate: (x: TSource) => Promise<boolean>): Promise<TSource>;
    singleOrDefault(
        predicate?: (x: TSource) => boolean,
    ): Promise<null | TSource>;
    singleOrDefaultAsync(
        predicate: (x: TSource) => Promise<boolean>,
    ): Promise<null | TSource>;
    skip(count: number): IAsyncEnumerable<TSource>;
    skipWhile(
        predicate: (x: TSource, index: number) => boolean,
    ): IAsyncEnumerable<TSource>;
    skipWhileAsync(
        predicate: (x: TSource, index: number) => Promise<boolean>,
    ): IAsyncEnumerable<TSource>;
    sum(this: IAsyncParallel<number>): Promise<number>;
    sum(selector: (x: TSource) => number): Promise<number>;
    sumAsync(selector: (x: TSource) => Promise<number>): Promise<number>;
    take(amount: number): IAsyncEnumerable<TSource>;
    takeWhile(
        predicate: (x: TSource, index: number) => boolean,
    ): IAsyncEnumerable<TSource>;
    takeWhileAsync(
        predicate: (x: TSource, index: number) => Promise<boolean>,
    ): IAsyncEnumerable<TSource>;
    toArray(): Promise<TSource[]>;
    toMap<TKey>(selector: (x: TSource) => TKey): Promise<Map<TKey, TSource[]>>;
    toMapAsync<TKey>(
        selector: (x: TSource) => Promise<TKey>,
    ): Promise<Map<TKey, TSource[]>>;
    toObject<TKey extends string | number | symbol>(
        selector: (x: TSource) => TKey,
    ): Promise<Record<TKey, TSource>>;
    toObjectAsync<TKey extends string | number | symbol>(
        selector: (x: TSource) => Promise<TKey>,
    ): Promise<Record<TKey, TSource>>;
    toSet(): Promise<Set<TSource>>;
    union(
        second: AsyncIterable<TSource>,
        comparer?: IEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    unionAsync(
        second: AsyncIterable<TSource>,
        comparer: IAsyncEqualityComparer<TSource>,
    ): IAsyncEnumerable<TSource>;
    where(
        predicate: (x: TSource, index: number) => boolean,
    ): IAsyncEnumerable<TSource>;
    whereAsync(
        predicate: (x: TSource, index: number) => Promise<boolean>,
    ): IAsyncEnumerable<TSource>;
    zip<TSecond, TResult>(
        second: AsyncIterable<TSecond>,
        resultSelector: (x: TSource, y: TSecond) => TResult,
    ): IAsyncEnumerable<TResult>;
    zip<TSecond>(
        second: AsyncIterable<TSecond>,
    ): IAsyncEnumerable<[TSource, TSecond]>;
    zipAsync<TSecond, TResult>(
        second: AsyncIterable<TSecond>,
        resultSelector: (x: TSource, y: TSecond) => Promise<TResult>,
    ): IAsyncEnumerable<TResult>;
}

Type Parameters

  • TSource

Hierarchy (View Summary)

Methods

  • Determines whether all elements of a sequence satisfy a condition.

    Parameters

    • predicate: (x: TSource) => boolean

      A function to test each element for a condition.

    Returns Promise<boolean>

    true if every element of the source sequence passes the test in the specified predicate, or if the sequence is empty; otherwise, false.

  • Determines whether all elements of a sequence satisfy a condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      An async function to test each element for a condition.

    Returns Promise<boolean>

    true if every element of the source sequence passes the test in the specified predicate, or if the sequence is empty; otherwise, false.

  • Determines whether a sequence contains any elements. If predicate is specified, determines whether any element of a sequence satisfies a condition.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition.

    Returns Promise<boolean>

    true if the source sequence contains any elements or passes the test specified; otherwise, false.

  • Determines whether any element of a sequence satisfies a condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      An async function to test each element for a condition.

    Returns Promise<boolean>

    true if the source sequence contains any elements or passes the test specified; otherwise, false.

  • Computes the average of a sequence of number values.

    Parameters

    Returns Promise<number>

    The average of the sequence of values.

    source contains no elements.

  • Computes the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => number

      A transform function to apply to each element.

    Returns Promise<number>

    The average of the sequence of values.

    source contains no elements.

  • Computes the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => Promise<number>

      An async transform function to apply to each element.

    Returns Promise<number>

    The average of the sequence of values.

    source contains no elements.

  • Returns the number of elements in a sequence or represents how many elements in the specified sequence satisfy a condition if the predicate is specified.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns Promise<number>

    The number of elements in the input sequence.

  • Returns the number of elements in a sequence or represents how many elements in the specified sequence satisfy a condition if the predicate is specified.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test each element for a condition.

    Returns Promise<number>

    The number of elements in the input sequence.

  • Returns the element at a specified index in a sequence.

    Parameters

    • index: number

      The zero-based index of the element to retrieve.

    Returns Promise<TSource>

    The element at the specified position in the source sequence.

    index is less than 0 or greater than or equal to the number of elements in source.

  • Returns the element at a specified index in a sequence or a default value if the index is out of range.

    Parameters

    • index: number

      The zero-based index of the element to retrieve.

    Returns Promise<null | TSource>

    null if the index is outside the bounds of the source sequence; otherwise, the element at the specified position in the source sequence.

  • Returns the first element in a sequence that satisfies a specified condition.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      A function to test each element for a condition.

    Returns Promise<TSource>

    The first element in the sequence that passes the test in the specified predicate function.

    No elements in Iteration matching predicate

  • Returns first element in sequence that satisfies predicate otherwise returns the first element in the sequence. Returns null if no value found.

    Parameters

    • Optionalpredicate: (x: TSource) => boolean

      A function to test each element for a condition. Optional.

    Returns Promise<null | TSource>

    The first element in the sequence or the first element that passes the test in the specified predicate function. Returns null if no value found.

  • Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.

    Parameters

    • predicate: (x: TSource) => Promise<boolean>

      An async function to test each element for a condition.

    Returns Promise<null | TSource>

    null if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate.

  • Correlates the elements of two sequences based on equality of keys and groups the results.

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner, any, any> | AsyncIterable<TInner, any, any>

      The sequence to join to the first sequence.

    • outerKeySelector: (value: TSource) => TKey

      The sequence to join to the first sequence.

    • innerKeySelector: (value: TInner) => TKey

      A function to extract the join key from each element of the second sequence.

    • resultSelector: (element: TSource, collection: TInner[]) => TResult

      A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

    • Optionalcomparer: IEqualityComparer<TKey>

      To compare keys. Optional.

    Returns IAsyncEnumerable<TResult>

    An IAsyncEnumerable that contains elements of type TResult that are obtained by performing a grouped join on two sequences.

  • Correlates the elements of two sequences based on equality of keys and groups the results.

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner, any, any> | AsyncIterable<TInner, any, any>

      The sequence to join to the first sequence. Can be async.

    • outerKeySelector: (value: TSource) => TKey | Promise<TKey>

      The sequence to join to the first sequence. Can be async.

    • innerKeySelector: (value: TInner) => TKey | Promise<TKey>

      A function to extract the join key from each element of the second sequence.

    • resultSelector: (element: TSource, collection: TInner[]) => TResult | Promise<TResult>

      A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence. Can be async.

    • Optionalcomparer: IEqualityComparer<TKey>

      To compare keys. Optional.

    Returns IAsyncEnumerable<TResult>

    An IAsyncEnumerable that contains elements of type TResult that are obtained by performing a grouped join on two sequences.

  • Invokes an async transform function on each element of a sequence and returns the maximum value.

    Parameters

    • selector: (x: TSource) => Promise<number>

      A transform function to apply to each element.

    Returns Promise<number>

    Sequence contains no elements

  • Invokes a transform function on each element of a sequence and returns the minimum value.

    Parameters

    • selector: (x: TSource) => Promise<number>

      A transform function to apply to each element.

    Returns Promise<number>

    Sequence contains no elements

  • Projects each element of a sequence to an IAsyncEnumerable and flattens the resulting sequences into one sequence.

    Type Parameters

    • TResult

    Parameters

    • selector: (x: TSource, index: number) => Promise<Iterable<TResult, any, any>>

      A transform function to apply to each element.

    Returns IAsyncEnumerable<TResult>

    An IAsyncEnumerable whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

  • Bypasses a specified number of elements in a sequence and then returns the remaining elements.

    Parameters

    • count: number

      The number of elements to skip before returning the remaining elements.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains the elements that occur after the specified index in the input sequence.

  • Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => boolean

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.

  • Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => Promise<boolean>

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.

  • Computes the sum of the sequence of numeric values.

    Parameters

    Returns Promise<number>

    A promise of the sum of the values in the sequence.

  • Computes the sum of the sequence of numeric values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => number

      A transform function to apply to each element.

    Returns Promise<number>

    A promise of the sum of the projected values.

  • Computes the sum of the sequence of numeric values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • selector: (x: TSource) => Promise<number>

      An async transform function to apply to each element.

    Returns Promise<number>

    A promise of the sum of the projected values.

  • Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => boolean

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains elements from the input sequence that occur before the element at which the test no longer passes.

  • Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => Promise<boolean>

      A async function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains elements from the input sequence that occur before the element at which the test no longer passes.

  • Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => boolean

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains elements from the input sequence that satisfy the condition.

  • Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

    Parameters

    • predicate: (x: TSource, index: number) => Promise<boolean>

      A async function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Returns IAsyncEnumerable<TSource>

    An IAsyncEnumerable that contains elements from the input sequence that satisfy the condition.