Interface IOrderedEnumerable<TSource>

Represents a sorted sequence.

TSource The type of the elements of the sequence.

interface IOrderedEnumerable<TSource> {
    "[iterator]"(): Generator<TSource>;
    aggregate(
        aggregator: (prev: TSource, curr: TSource, index: number) => TSource,
    ): TSource;
    aggregate<TAccumulate>(
        seed: TAccumulate,
        aggregator: (
            prev: TAccumulate,
            curr: TSource,
            index: number,
        ) => TAccumulate,
    ): TAccumulate;
    aggregate<TAccumulate, TResult>(
        seed: TAccumulate,
        aggregator: (
            prev: TAccumulate,
            curr: TSource,
            index: number,
        ) => TAccumulate,
        resultSelector: (accumulated: TAccumulate) => TResult,
    ): TResult;
    all(predicate: (item: TSource, index: number) => boolean): boolean;
    any(): boolean;
    any(predicate: (item: TSource, index: number) => boolean): boolean;
    append(item: TSource): IEnumerable<TSource>;
    asEnumerable(): IEnumerable<TSource>;
    assert(
        predicate: (item: TSource, index: number) => boolean,
    ): IEnumerable<TSource>;
    assert(
        predicate: (item: TSource, index: number) => boolean,
        message: string,
    ): IEnumerable<TSource>;
    assert<TError extends Error>(
        predicate: (item: TSource, index: number) => boolean,
        errorType: new (message?: string) => TError,
    ): IEnumerable<TSource>;
    assert<TError extends Error>(
        predicate: (item: TSource, index: number) => boolean,
        message: string,
        errorType: new (message?: string) => TError,
    ): IEnumerable<TSource>;
    atLeast(count: number): boolean;
    atLeast(
        count: number,
        predicate: (item: TSource, index: number) => boolean,
    ): boolean;
    atMost(count: number): boolean;
    atMost(
        count: number,
        predicate: (item: TSource, index: number) => boolean,
    ): boolean;
    average(): number;
    average(selector: (item: TSource) => number): number;
    chunk(chunkSize: number): IEnumerable<IEnumerable<TSource>>;
    concatenate(collection: Iterable<TSource>): IEnumerable<TSource>;
    concatenate(...collections: Iterable<TSource>[]): IEnumerable<TSource>;
    contains(value: TSource): boolean;
    contains(
        value: TSource,
        equalityComparer: EqualityComparer<TSource>,
    ): boolean;
    count(): number;
    count(predicate: (item: TSource, index: number) => boolean): number;
    defaultIfEmpty(defaultItem: TSource): IEnumerable<TSource>;
    distinct(): IEnumerable<TSource>;
    distinct(equalityComparer: EqualityComparer<TSource>): IEnumerable<TSource>;
    distinctBy<TKey>(
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    distinctBy<TKey>(
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    elementAt(index: number): TSource;
    elementAtOrDefault(index: number): null | TSource;
    endsWith(second: Iterable<TSource>): boolean;
    endsWith(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): boolean;
    except(second: Iterable<TSource>): IEnumerable<TSource>;
    except(...second: Iterable<TSource>[]): IEnumerable<TSource>;
    except(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    except(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    except(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    exceptBy<TKey>(
        second: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    exceptBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    exceptBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TKey>,
        fourth: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    exceptBy<TKey>(
        second: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    exceptBy<TKey>(
        second: Iterable<TKey>,
        thrid: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    exceptBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TKey>,
        fourth: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    first(): TSource;
    first(predicate: (item: TSource, index: number) => boolean): TSource;
    firstOrDefault(): null | TSource;
    firstOrDefault(
        predicate: (item: TSource, index: number) => boolean,
    ): null | TSource;
    flatten(): IEnumerable<
        TSource extends Iterable<InnerItr> ? InnerItr : TSource,
    >;
    flatten<Depth extends number>(
        depth: Depth,
    ): IEnumerable<FlatIterable<Iterable<TSource>, Depth>>;
    forEach(action: (item: TSource, index: number) => void): void;
    fullJoinHeterogeneous<TSecond, TKey, TResult>(
        second: Iterable<TSecond>,
        firstKeySelector: (item: TSource) => TKey,
        secondKeySelector: (item: TSecond) => TKey,
        firstSelector: (item: TSource) => TResult,
        secondSelector: (item: TSecond) => TResult,
        bothSelector: (a: TSource, b: TSecond) => TResult,
    ): IEnumerable<TResult>;
    fullJoinHeterogeneous<TSecond, TKey, TResult>(
        second: Iterable<TSecond>,
        firstKeySelector: (item: TSource) => TKey,
        secondKeySelector: (item: TSecond) => TKey,
        firstSelector: (item: TSource) => TResult,
        secondSelector: (item: TSecond) => TResult,
        bothSelector: (a: TSource, b: TSecond) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    fullJoinHomogeneous<TKey, TResult>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        firstSelector: (item: TSource) => TResult,
        secondSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSource) => TResult,
    ): IEnumerable<TResult>;
    fullJoinHomogeneous<TKey, TResult>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        firstSelector: (item: TSource) => TResult,
        secondSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSource) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    groupBy<TKey>(
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<IGrouping<TKey, TSource>>;
    groupBy<TKey>(
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<IGrouping<TKey, TSource>>;
    groupJoin<TInner, TKey, TResult>(
        inner: Iterable<TInner>,
        outerKeySelector: (item: TSource) => TKey,
        innerKeySelector: (item: TInner) => TKey,
        resultSelector: (item: TSource, inner: IEnumerable<TInner>) => TResult,
    ): IEnumerable<TResult>;
    groupJoin<TInner, TKey, TResult>(
        inner: Iterable<TInner>,
        outerKeySelector: (item: TSource) => TKey,
        innerKeySelector: (item: TInner) => TKey,
        resultSelector: (item: TSource, inner: IEnumerable<TInner>) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    innerJoin<TInner, TKey, TResult>(
        inner: Iterable<TInner>,
        outerKeySelector: (item: TSource) => TKey,
        innerKeySelector: (item: TInner) => TKey,
        resultSelector: (item: TSource, inner: TInner) => TResult,
    ): IEnumerable<TResult>;
    innerJoin<TInner, TKey, TResult>(
        inner: Iterable<TInner>,
        outerKeySelector: (item: TSource) => TKey,
        innerKeySelector: (item: TInner) => TKey,
        resultSelector: (item: TSource, inner: TInner) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    intersect(second: Iterable<TSource>): IEnumerable<TSource>;
    intersect(...second: Iterable<TSource>[]): IEnumerable<TSource>;
    intersect(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    intersect(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    intersect(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    intersectBy<TKey>(
        second: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    intersectBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    intersectBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    intersectBy<TKey>(
        second: Iterable<TKey>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    intersectBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    intersectBy<TKey>(
        second: Iterable<TKey>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    interweave(collection: Iterable<TSource>): IEnumerable<TSource>;
    interweave(...collections: Iterable<TSource>[]): IEnumerable<TSource>;
    last(): TSource;
    last(predicate: (item: TSource, index: number) => boolean): TSource;
    lastOrDefault(): null | TSource;
    lastOrDefault(
        predicate: (item: TSource, index: number) => boolean,
    ): null | TSource;
    leftJoinHeterogeneous<TSecond, TKey, TResult>(
        second: Iterable<TSecond>,
        firstKeySelector: (item: TSource) => TKey,
        secondKeySelector: (item: TSecond) => TKey,
        firstSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSecond) => TResult,
    ): IEnumerable<TResult>;
    leftJoinHeterogeneous<TSecond, TKey, TResult>(
        second: Iterable<TSecond>,
        firstKeySelector: (item: TSource) => TKey,
        secondKeySelector: (item: TSecond) => TKey,
        firstSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSecond) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    leftJoinHomogeneous<TKey, TResult>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        firstSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSource) => TResult,
    ): IEnumerable<TResult>;
    leftJoinHomogeneous<TKey, TResult>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        firstSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSource) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    max(): TSource;
    max<TResult>(selector: (item: TSource) => TResult): TResult;
    maxBy<TKey>(keySelector: (item: TSource) => TKey): TSource;
    min(): TSource;
    min<TResult>(selector: (item: TSource) => TResult): TResult;
    minBy<TKey>(keySelector: (item: TSource) => TKey): TSource;
    ofType<TResult>(
        type: new (...params: unknown[]) => TResult,
    ): IEnumerable<TResult>;
    order(): IOrderedEnumerable<TSource>;
    order(comparer: Comparer<TSource>): IOrderedEnumerable<TSource>;
    orderBy<TKey>(
        keySelector: (item: TSource) => TKey,
    ): IOrderedEnumerable<TSource>;
    orderBy<TKey>(
        keySelector: (item: TSource) => TKey,
        comparer: Comparer<TKey>,
    ): IOrderedEnumerable<TSource>;
    orderByDescending<TKey>(
        keySelector: (item: TSource) => TKey,
    ): IOrderedEnumerable<TSource>;
    orderByDescending<TKey>(
        keySelector: (item: TSource) => TKey,
        comparer: Comparer<TKey>,
    ): IOrderedEnumerable<TSource>;
    orderDescending(): IOrderedEnumerable<TSource>;
    orderDescending(comparer: Comparer<TSource>): IOrderedEnumerable<TSource>;
    pipe(action: (item: TSource, index: number) => void): IEnumerable<TSource>;
    prepend(item: TSource): IEnumerable<TSource>;
    quantile(q: number): number;
    quantile(selector: (item: TSource) => number, q: number): number;
    reverseImmutable(): IEnumerable<TSource>;
    rightJoinHeterogeneous<TSecond, TKey, TResult>(
        second: Iterable<TSecond>,
        firstKeySelector: (item: TSource) => TKey,
        secondKeySelector: (item: TSecond) => TKey,
        secondSelector: (item: TSecond) => TResult,
        bothSelector: (a: TSource, b: TSecond) => TResult,
    ): IEnumerable<TResult>;
    rightJoinHeterogeneous<TSecond, TKey, TResult>(
        second: Iterable<TSecond>,
        firstKeySelector: (item: TSource) => TKey,
        secondKeySelector: (item: TSecond) => TKey,
        secondSelector: (item: TSecond) => TResult,
        bothSelector: (a: TSource, b: TSecond) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    rightJoinHomogeneous<TKey, TResult>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        secondSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSource) => TResult,
    ): IEnumerable<TResult>;
    rightJoinHomogeneous<TKey, TResult>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        secondSelector: (item: TSource) => TResult,
        bothSelector: (a: TSource, b: TSource) => TResult,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TResult>;
    select<TResult>(
        selector: (item: TSource, index: number) => TResult,
    ): IEnumerable<TResult>;
    selectMany<TResult>(
        selector: (item: TSource, index: number) => TResult[],
    ): IEnumerable<TResult>;
    sequenceEqual(second: Iterable<TSource>): boolean;
    sequenceEqual(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): boolean;
    shuffle(): IEnumerable<TSource>;
    single(): TSource;
    single(predicate: (item: TSource, index: number) => boolean): TSource;
    singleOrDefault(): null | TSource;
    singleOrDefault(
        predicate: (item: TSource, index: number) => boolean,
    ): null | TSource;
    skip(count: number): IEnumerable<TSource>;
    skipLast(count: number): IEnumerable<TSource>;
    skipWhile(
        predicate: (item: TSource, index: number) => boolean,
    ): IEnumerable<TSource>;
    split(separator: TSource): IEnumerable<IEnumerable<TSource>>;
    split(
        predicate: (item: TSource, index: number) => boolean,
    ): IEnumerable<IEnumerable<TSource>>;
    startsWith(second: Iterable<TSource>): boolean;
    startsWith(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): boolean;
    sum(): number;
    sum(selector: (item: TSource) => number): number;
    take(count: number): IEnumerable<TSource>;
    takeEvery(step: number): IEnumerable<TSource>;
    takeLast(count: number): IEnumerable<TSource>;
    takeWhile(
        predicate: (item: TSource, index: number) => boolean,
    ): IEnumerable<TSource>;
    thenBy<TKey>(
        keySelector: (item: TSource) => TKey,
    ): IOrderedEnumerable<TSource>;
    thenBy<TKey>(
        keySelector: (item: TSource) => TKey,
        comparer: Comparer<TKey>,
    ): IOrderedEnumerable<TSource>;
    thenByDescending<TKey>(
        keySelector: (item: TSource) => TKey,
    ): IOrderedEnumerable<TSource>;
    thenByDescending<TKey>(
        keySelector: (item: TSource) => TKey,
        comparer: Comparer<TKey>,
    ): IOrderedEnumerable<TSource>;
    to<TResult>(ctor: new (src: Iterable<TSource>) => TResult): TResult;
    toArray(): TSource[];
    toJSON(): string;
    toList(): IList<TSource>;
    toLookup(): unknown;
    toMap<TKey>(keySelector: (item: TSource) => TKey): Map<TKey, TSource>;
    toMap<TKey, TValue>(
        keySelector: (item: TSource) => TKey,
        valueSelector: (item: TSource) => TValue,
    ): Map<TKey, TValue>;
    toObject(keySelector: (item: TSource) => string): Record<string, TSource>;
    toObject<TValue>(
        keySelector: (item: TSource) => string,
        valueSelector: (item: TSource) => TValue,
    ): Record<string, TValue>;
    toSet(): Set<TSource>;
    toString(): string;
    union(second: Iterable<TSource>): IEnumerable<TSource>;
    union(...second: Iterable<TSource>[]): IEnumerable<TSource>;
    union(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    union(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    union(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    unionBy<TKey>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    unionBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    unionBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    unionBy<TKey>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    unionBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    unionBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    where(
        predicate: (item: TSource, index: number) => boolean,
    ): IEnumerable<TSource>;
    window(size: number): IEnumerable<IEnumerable<TSource>>;
    xor(second: Iterable<TSource>): IEnumerable<TSource>;
    xor(...second: Iterable<TSource>[]): IEnumerable<TSource>;
    xor(
        second: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    xor(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    xor(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        equalityComparer: EqualityComparer<TSource>,
    ): IEnumerable<TSource>;
    xorBy<TKey>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    xorBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    xorBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
    ): IEnumerable<TSource>;
    xorBy<TKey>(
        second: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    xorBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    xorBy<TKey>(
        second: Iterable<TSource>,
        third: Iterable<TSource>,
        fourth: Iterable<TSource>,
        keySelector: (item: TSource) => TKey,
        equalityComparer: EqualityComparer<TKey>,
    ): IEnumerable<TSource>;
    zip<TSecond>(second: Iterable<TSecond>): IEnumerable<[TSource, TSecond]>;
    zip<TSecond, TResult>(
        second: Iterable<TSecond>,
        resultSelector: (first: TSource, second: TSecond) => TResult,
    ): IEnumerable<TResult>;
}

Type Parameters

  • TSource

Hierarchy (View Summary)

Implemented by

Methods

  • Exposes an iterator that can be used for iteration.

    Returns Generator<TSource>

    The iterator for the IEnumerable.

    const numbers = from([1, 2, 3]);
    for (const number of numbers) {
    // Iteration is allowed because of the iterator.
    }
  • Applies an accumulator function over a sequence.

    Parameters

    • aggregator: (prev: TSource, curr: TSource, index: number) => TSource

      An accumulator function to be invoked on each element.

    Returns TSource

    The final accumulator value.

    const items = [1, 2, 3];
    const sum = from(items)
    .aggregate((prev, curr) => prev + curr); // sum will be 6
  • Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.

    Type Parameters

    • TAccumulate

    Parameters

    Returns TAccumulate

    The final accumulator value.

    const items = [1, 2, 3];
    const sum = from(items)
    .aggregate(10, (prev, curr) => prev + curr); // sum will be 16

    TAccumulate The type of the accumulator value.

  • Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.

    Type Parameters

    • TAccumulate
    • TResult

    Parameters

    Returns TResult

    The final accumulator value.

    const items = [1, 2, 3];
    const sum = from(items)
    .aggregate(10, (prev, curr) => prev + curr, result => ({ result })); // sum will be { result: 16 }

    TAccumulate The type of the accumulator value.

    TResult The type of the resulting value.

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

    Parameters

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

      A function to test each element for a condition.

    Returns boolean

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

    const numbers = [1, 2, 3, 4];
    const areAllNumbersEven = from(numbers).all(x => x % 2 === 0); // false
  • Determines whether any element of a sequence exists or satisfies a condition.

    Returns boolean

    true if the source sequence contains any elements (or if at least one matches condition if condition is passed); otherwise, false.

    const numbers = [1, 2, 3, 4];
    const areAnyNumbersEven = from(numbers).any(); // true
  • Determines whether any element of a sequence exists or satisfies a condition.

    Parameters

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

      A function to test each element for a condition.

    Returns boolean

    true if the source sequence contains any elements (or if at least one matches condition if condition is passed); otherwise, false.

    const numbers = [1, 2, 3, 4];
    const areAnyNumbersEven = from(numbers).any(x => x % 2 === 0); // true
  • Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.

    Parameters

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

      A function to test each element for a condition. If false, an error will be thrown.

    Returns IEnumerable<TSource>

    A sequence with source elements in their original order.

    const items = [1, 2, '3'];
    const sum = from(items).assert(x => typeof x === 'number').sum(); // throws due to '3'
  • Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.

    Parameters

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

      A function to test each element for a condition. If false, an error will be thrown.

    • message: string

      The message to use for thrown errors.

    Returns IEnumerable<TSource>

    A sequence with source elements in their original order.

    const items = [1, 2, '3'];
    const sum = from(items).assert(x => typeof x === 'number', 'Should be number').sum(); // throws due to '3'
  • Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.

    Type Parameters

    • TError extends Error

    Parameters

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

      A function to test each element for a condition. If false, an error will be thrown.

    • errorType: new (message?: string) => TError

      Type of error to throw.

    Returns IEnumerable<TSource>

    A sequence with source elements in their original order.

    class MyError extends Error {}
    const items = [1, 2, '3'];
    const sum = from(items).assert(x => typeof x === 'number', MyError).sum(); // throws instance of MyError due to '3'

    TError The type of error to be thrown.

  • Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.

    Type Parameters

    • TError extends Error

    Parameters

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

      A function to test each element for a condition. If false, an error will be thrown.

    • message: string

      The message to use for thrown errors.

    • errorType: new (message?: string) => TError

      Type of error to throw.

    Returns IEnumerable<TSource>

    A sequence with source elements in their original order.

    class MyError extends Error {}
    const items = [1, 2, '3'];
    const sum = from(items).assert(x => typeof x === 'number', 'Must be number', MyError).sum(); // throws instance of MyError with message due to '3'

    TError The type of error to be thrown.

  • Determines whether or not the number of elements in the sequence is greater than or equal to the given integer.

    Parameters

    • count: number

      The minimum number of items a sequence must have for this function to return true

    Returns boolean

    true if the number of elements in the sequence is greater than or equal to the given integer or false otherwise.

    const items = [1, 2, 3];
    const atLeastThree = from(items).atLeast(3); // true
    const atLeastFour = from(items).atLeast(4); // false
  • Determines whether or not the number of elements in the sequence is greater than or equal to the given integer.

    Parameters

    • count: number

      The minimum number of items a sequence must have for this function to return true

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

      A function to test each element for a condition.

    Returns boolean

    true if the number of elements in the sequence is greater than or equal to the given integer or false otherwise.

    const items = [1, 2, 3];
    const atLeastOneEven = from(items).atLeast(1, x => x % 2 === 0); // true
    const atLeastTwoEven = from(items).atLeast(2, x => x % 2 === 0); // false
  • Determines whether or not the number of elements in the sequence is lesser than or equal to the given integer.

    Parameters

    • count: number

      The maximun number of items a sequence must have for this function to return true.

    Returns boolean

    true if the number of elements in the sequence is lesser than or equal to the given integer or false otherwise.

    const items = [1, 2, 3];
    const atMostTwo = from(items).atMost(2); // false
    const atMostFour = from(items).atMost(4); // true
  • Determines whether or not the number of elements that match the predicate in the sequence is lesser than or equal to the given integer.

    Parameters

    • count: number

      The maximun number of items a sequence must have for this function to return true.

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

      The condition to match the elements by.

    Returns boolean

    true if the number of elements that match the predicate in the sequence is lesser than or equal to the given integer or false otherwise.

    const items = [1, 2, 3];
    const atMostTwo = from(items).atMost(2, x => x > 0); // false
    const atMostFour = from(items).atMost(4, x => x > 2); // true
  • Computes the average of a sequence of numeric values.

    Returns number

    The average of the sequence of values.

    const numbers = [2, 2, 1, 3];
    const average = from(numbers).average(); // 2
  • Computes the average of a sequence of numeric values.

    Parameters

    • selector: (item: TSource) => number

      A transform function to apply to each element.

    Returns number

    The average of the sequence of values.

    const numbers = [{ age: 20 }, { age: 10 }, { age: 30 }];
    const average = from(numbers).average(x => x.age); // 20
  • Split the elements of a sequence into chunks of size at most chunkSize.

    Parameters

    • chunkSize: number

      The maximum size of each chunk.

    Returns IEnumerable<IEnumerable<TSource>>

    An IEnumerable that contains the elements the input sequence split into chunks of size chunkSize.

    const numbers = [1, 2, 3, 4, 5];
    const chunks = from(numbers).chunk(2); // [[1, 2], [3, 4], [5]]
  • Concatenates two sequences.

    Parameters

    • collection: Iterable<TSource>

      The sequence to concatenate to the first sequence.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the concatenated elements of the two input sequences.

    const numbers = [1, 2];
    const moreNumbers = from(numbers).concatenate([3, 4, 5]); // [1, 2, 3, 4, 5]
  • Concatenates two sequences.

    Parameters

    • ...collections: Iterable<TSource>[]

      The sequences to concatenate to the first sequence.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the concatenated elements of the two or more input sequences.

    const numbers = [1, 2];
    const evenMoreNumbers = from(numbers).concatenate([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6]
  • Determines whether a sequence contains a specified element.

    Parameters

    • value: TSource

      The value to locate in the sequence.

    Returns boolean

    true if the source sequence contains an element that has the specified value; otherwise, false.

    const numbers = [1, 2, 3];
    const hasThree = from(numbers).contains(3); // true
  • Determines whether a sequence contains a specified element.

    Parameters

    Returns boolean

    true if the source sequence contains an element that has the specified value; otherwise, false.

    const numbers = [1, 2, 3];
    const hasThree = from(numbers).contains(3, (a, b) => a === b); // true
  • Returns the number of elements in a sequence.

    Returns number

    The number of elements in the input sequence.

    const numbers = [1, 2, 3];
    const numCount = from(numbers).count(); // 3
  • Returns the number of elements in a sequence.

    Parameters

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

      A function to test each element for a condition.

    Returns number

    The number of elements in the input sequence.

    const numbers = [1, 2, 3];
    const evenNumCount = from(numbers).count(x => x % 2 === 0); // 1
  • Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.

    Parameters

    • defaultItem: TSource

      The value to return if the sequence is empty.

    Returns IEnumerable<TSource>

    An IEnumerable that contains defaultValue if source is empty; otherwise, source.

    const defaultNum = 0;
    const items = [];
    const itemsWithDefault = from(items).defaultIfEmpty(defaultNum); // [0];
    const
  • Returns distinct elements from a sequence.

    Returns IEnumerable<TSource>

    An IEnumerable that contains distinct elements from the source sequence.

    const items = [1, 2, 3, 1, 2];
    const distinct = from(items).distinct(); // Will be [1, 2, 3]
  • Returns distinct elements from a sequence.

    Parameters

    Returns IEnumerable<TSource>

    An IEnumerable that contains distinct elements from the source sequence.

    const items = [{ name: 'bob' }, { name: 'Joe' }, { name: 'Bob' }];
    const distinct = from(items).distinct((a, b) => a.name.toUpperCase() === b.name.toUpperCase()); // Will be [{ name: 'bob' }, { name: 'Joe' }]
  • Returns distinct elements from a sequence according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains distinct elements from the source sequence.

    const items = [{ name: 'bob', id: 1 }, { name: 'Joe', id: 2 }, { name: 'Bob', id: 3 }, { name: 'John', id: 2 }];
    const distinct = from(items).distinctBy(x => x.id); // Will be [{ name: 'bob', id: 1 }, { name: 'Joe', id: 2 }, { name: 'Bob', id: 3 }]

    TKey The type of key to distinguish elements by.

  • Returns distinct elements from a sequence according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains distinct elements from the source sequence.

    const items = [{ name: 'bob', id: 1 }, { name: 'Joe', id: 2 }, { name: 'Bob', id: 3 }, { name: 'John', id: 2 }];
    const distinct = from(items).distinctBy(x => x.id, (a, b) => a === b); // Will be [{ name: 'bob', id: 1 }, { name: 'Joe', id: 2 }, { name: 'Bob', id: 3 }]

    TKey The type of key to distinguish elements by.

  • Returns the element at a specified index in a sequence or throws if the index is out of range. A negative index can be used to get element starting from the end.

    Parameters

    • index: number

      The zero-based index of the element to retrieve.

    Returns TSource

    The element at the specified position in the source sequence.

    const items = [1, 2, 3];
    const indexZero = from(items).elementAt(0); // Will be 1
    const willBeNull = from(items).elementAt(10); // Will throw.
    const last = from(items).elementAt(-1); // 3
  • Returns the element at a specified index in a sequence or null if the index is out of range. A negative index can be used to get element starting from the end.

    Parameters

    • index: number

      The zero-based index of the element to retrieve.

    Returns null | TSource

    The element at the specified position in the source sequence.

    const items = [1, 2, 3];
    const indexZero = from(items).elementAtOrDefault(0); // Will be 1
    const willBeNull = from(items).elementAtOrDefault(10); // Will be null.
    const last = from(items).elementAtOrDefault(-1); // 3
  • Determines whether the end of the first sequence is equivalent to the second sequence.

    Parameters

    • second: Iterable<TSource>

      The sequence to compare to.

    Returns boolean

    true if first ends with elements equivalent to second.

    const items = [1, 2, 3];
    const endsWith = from(items).endsWith([2, 3]); // true
    const doesNotEndWith = from(items).endsWith([3, 2]); // false
  • Determines whether the end of the first sequence is equivalent to the second sequence, using the specified element equality comparer.

    Parameters

    Returns boolean

    true if first ends with elements equivalent to second.

    const items = [1, 2, 3];
    const endsWith = from(items).endsWith([2, 3], (a, b) => a === b); // true
    const doesNotEndWith = from(items).endsWith([3, 2], (a, b) => a === b); // false
  • Produces the set difference of two sequences.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    const items = [1, 2, 3, 4];
    const exceptItems = from(items).except([2, 4]); // [1, 3]
  • Produces the set difference of two sequences.

    Parameters

    • ...second: Iterable<TSource>[]

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    const items = [1, 2, 3, 4];
    const exceptItems = from(items).except([2, 4], [3, 4]); // [1]
  • Produces the set difference of two sequences.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • equalityComparer: EqualityComparer<TSource>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    const items = [1, 2, 3, 4];
    const exceptItems = from(items).except([2, 4], (a, b) => a === b); // [1, 3]
  • Produces the set difference of two sequences.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • third: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • equalityComparer: EqualityComparer<TSource>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    const items = [1, 2, 3, 4];
    const exceptItems = from(items).except([2, 4], [3], (a, b) => a === b); // [1]
  • Produces the set difference of two sequences.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • third: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • fourth: Iterable<TSource>

      An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • equalityComparer: EqualityComparer<TSource>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    const items = [1, 2, 3, 4, 5, 6, 7];
    const exceptItems = from(items).except([2, 4], [3, 5], [7], (a, b) => a === b); // [1, 6]
  • Produces the set difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • third: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • third: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • fourth: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • thrid: Iterable<TKey>
    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • third: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • fourth: Iterable<TKey>

      An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      An EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    A sequence that contains the set difference of the elements of two sequences.

    TKey The type of key to identify elements by.

  • Returns the first element in a sequence. Throws if sequence contains no elements.

    Returns TSource

    The first element in the sequence.

  • Returns the first element in a sequence that satisfies a specified condition. Throws if sequence contains no elements that matches condition.

    Parameters

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

      A function to test each element for a condition.

    Returns TSource

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

  • Returns the first element in a sequence. Returns null if sequence contains no elements.

    Returns null | TSource

    The first element in the sequence or null.

  • Returns the first element in a sequence that satisfies a specified condition. Returns null if sequence contains no elements that matches condition.

    Parameters

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

      A function to test each element for a condition.

    Returns null | TSource

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

  • Returns a new IEnumerable with all sub-iterable elements concatenated into it one level deep.

    Returns IEnumerable<TSource extends Iterable<InnerItr> ? InnerItr : TSource>

    A new IEnumerable with all sub-iterable elements concatenated into it recursively up.

    const items = [1, 2, [3, 4, [5, []]]];
    const res = from(items).flatten(); // [1, 2, 3, 4, [5, []]]
  • Returns a new IEnumerable with all sub-iterable elements concatenated into it recursively up to the specified depth.

    Type Parameters

    • Depth extends number

    Parameters

    • depth: Depth

      The depth to flatten to.

    Returns IEnumerable<FlatIterable<Iterable<TSource>, Depth>>

    A new IEnumerable with all sub-iterable elements concatenated into it recursively up.

    const items = [1, 2, [3, 4, [5, []]]];
    const res = from(items).flatten(3); // [1, 2, 3, 4, 5]
  • Iterates the sequence and calls an action on each element.

    Parameters

    • action: (item: TSource, index: number) => void

      The action to perform on each item in the sequence.

    Returns void

  • Performs a full outer join on two heterogeneous sequences. Additional arguments specify key selection functions, result projection functions and a key comparer.

    Type Parameters

    • TSecond
    • TKey
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence of the join operation.

    • firstKeySelector: (item: TSource) => TKey

      Function that projects the key given an element from first.

    • secondKeySelector: (item: TSecond) => TKey

      Function that projects the key given an element from second.

    • firstSelector: (item: TSource) => TResult
    • secondSelector: (item: TSecond) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSecond) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a right outer join of the two input sequences.

    TSecond The type of elements in the second sequence.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Performs a full outer join on two heterogeneous sequences. Additional arguments specify key selection functions, result projection functions and a key comparer.

    Type Parameters

    • TSecond
    • TKey
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence of the join operation.

    • firstKeySelector: (item: TSource) => TKey

      Function that projects the key given an element from first.

    • secondKeySelector: (item: TSecond) => TKey

      Function that projects the key given an element from second.

    • firstSelector: (item: TSource) => TResult
    • secondSelector: (item: TSecond) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSecond) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a right outer join of the two input sequences.

    TSecond The type of elements in the second sequence.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Performs a full outer join on two homogeneous sequences. Additional arguments specify key selection functions and result projection functions.

    Type Parameters

    • TKey
    • TResult

    Parameters

    • second: Iterable<TSource>

      The second sequence of the join operation.

    • keySelector: (item: TSource) => TKey

      Function that projects the key given an element of one of the sequences to join.

    • firstSelector: (item: TSource) => TResult

      Function that projects the result given just an element from first where there is no corresponding element in second.

    • secondSelector: (item: TSource) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSource) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a full outer join of the two input sequences.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Performs a full outer join on two homogeneous sequences. Additional arguments specify key selection functions and result projection functions.

    Type Parameters

    • TKey
    • TResult

    Parameters

    • second: Iterable<TSource>

      The second sequence of the join operation.

    • keySelector: (item: TSource) => TKey

      Function that projects the key given an element of one of the sequences to join.

    • firstSelector: (item: TSource) => TResult

      Function that projects the result given just an element from first where there is no corresponding element in second.

    • secondSelector: (item: TSource) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSource) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a full outer join of the two input sequences.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

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

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner>

      The sequence to join to the first sequence.

    • outerKeySelector: (item: TSource) => TKey

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

    • innerKeySelector: (item: TInner) => TKey

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

    • resultSelector: (item: TSource, inner: IEnumerable<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.

    Returns IEnumerable<TResult>

    const magnus = { name: 'Magnus' };
    const terry = { name: 'Terry' };
    const adam = { name: 'Adam' };
    const john = { name: 'John' };

    const barley = { name: 'Barley', owner: terry };
    const boots = { name: 'Boots', owner: terry };
    const whiskers = { name: 'Whiskers', owner: adam };
    const daisy = { name: 'Daisy', owner: magnus };
    const scratchy = { name: 'Scratchy', owner: { name: 'Bob' } };

    const people = from([magnus, terry, adam, john]);
    const pets = from([barley, boots, whiskers, daisy, scratchy]);

    const result = people
    .groupJoin(
    pets,
    person => person,
    pet => pet.owner,
    (person, petCollection) => ({ ownerName: person.name, pets: petCollection.select(p => p.name).toArray() })
    )
    .toArray();

    expect(result).toEqual([
    { ownerName: 'Magnus', pets: ['Daisy'] },
    { ownerName: 'Terry', pets: ['Barley', 'Boots'] },
    { ownerName: 'Adam', pets: ['Whiskers'] },
    { ownerName: 'John', pets: [] }
    ]);

    TInner The type of the elements of the second sequence.

    TKey The type of the keys returned by the key selector functions.

    TResult The type of the result elements.

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

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner>

      The sequence to join to the first sequence.

    • outerKeySelector: (item: TSource) => TKey

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

    • innerKeySelector: (item: TInner) => TKey

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

    • resultSelector: (item: TSource, inner: IEnumerable<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.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    const magnus = { name: 'Magnus' };
    const terry = { name: 'Terry' };
    const adam = { name: 'Adam' };
    const john = { name: 'John' };

    const barley = { name: 'Barley', owner: terry };
    const boots = { name: 'Boots', owner: terry };
    const whiskers = { name: 'Whiskers', owner: adam };
    const daisy = { name: 'Daisy', owner: magnus };
    const scratchy = { name: 'Scratchy', owner: { name: 'Bob' } };

    const people = from([magnus, terry, adam, john]);
    const pets = from([barley, boots, whiskers, daisy, scratchy]);

    const result = people
    .groupJoin(
    pets,
    person => person,
    pet => pet.owner,
    (person, petCollection) => ({ ownerName: person.name, pets: petCollection.select(p => p.name).toArray() }),
    (person, pet) => person.name === pet.owner.name
    )
    .toArray();

    expect(result).toEqual([
    { ownerName: 'Magnus', pets: ['Daisy'] },
    { ownerName: 'Terry', pets: ['Barley', 'Boots'] },
    { ownerName: 'Adam', pets: ['Whiskers'] },
    { ownerName: 'John', pets: [] }
    ]);

    TInner The type of the elements of the second sequence.

    TKey The type of the keys returned by the key selector functions.

    TResult The type of the result elements.

  • Performs an inner join by correlating the elements of two sequences based on matching keys.

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner>

      The second sequence to join to the first.

    • outerKeySelector: (item: TSource) => TKey

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

    • innerKeySelector: (item: TInner) => TKey

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

    • resultSelector: (item: TSource, inner: TInner) => TResult

      A function to create a result element from two matching elements.

    Returns IEnumerable<TResult>

    An IEnumerable that has elements of type TResult that are obtained by performing an inner join on two sequences.

    const magnus = { name: 'Magnus' };
    const terry = { name: 'Terry' };
    const adam = { name: 'Adam' };
    const john = { name: 'John' };

    const barley = { name: 'Barley', owner: terry };
    const boots = { name: 'Boots', owner: terry };
    const whiskers = { name: 'Whiskers', owner: adam };
    const daisy = { name: 'Daisy', owner: magnus };
    const scratchy = { name: 'Scratchy', owner: { name: 'Bob' } };

    const people = from([magnus, terry, adam, john]);
    const pets = from([barley, boots, whiskers, daisy, scratchy]);

    const result = people.innerJoin(
    pets,
    person => person,
    pet => pet.owner,
    (person, pet) => ({ ownerName: person.name, pet: pet.name })
    )
    .toArray();

    expect(result).toEqual([
    { ownerName: 'Magnus', pet: 'Daisy' },
    { ownerName: 'Terry', pet: 'Barley' },
    { ownerName: 'Terry', pet: 'Boots' },
    { ownerName: 'Adam', pet: 'Whiskers' }
    ]);

    TInner The type of the elements of the second sequence.

    TKey The type of the keys returned by the key selector functions.

    TResult The type of the result elements.

  • Performs an inner join by correlating the elements of two sequences based on matching keys.

    Type Parameters

    • TInner
    • TKey
    • TResult

    Parameters

    • inner: Iterable<TInner>

      The second sequence to join to the first.

    • outerKeySelector: (item: TSource) => TKey

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

    • innerKeySelector: (item: TInner) => TKey

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

    • resultSelector: (item: TSource, inner: TInner) => TResult

      A function to create a result element from two matching elements.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    An IEnumerable that has elements of type TResult that are obtained by performing an inner join on two sequences.

    const magnus = { name: 'Magnus' };
    const terry = { name: 'Terry' };
    const adam = { name: 'Adam' };
    const john = { name: 'John' };

    const barley = { name: 'Barley', owner: terry };
    const boots = { name: 'Boots', owner: terry };
    const whiskers = { name: 'Whiskers', owner: adam };
    const daisy = { name: 'Daisy', owner: magnus };
    const scratchy = { name: 'Scratchy', owner: { name: 'Bob' } };

    const people = from([magnus, terry, adam, john]);
    const pets = from([barley, boots, whiskers, daisy, scratchy]);

    const result = people.innerJoin(
    pets,
    person => person,
    pet => pet.owner,
    (person, pet) => ({ ownerName: person.name, pet: pet.name }),
    (person, pet) => person.name === pet.owner.name
    )
    .toArray();

    expect(result).toEqual([
    { ownerName: 'Magnus', pet: 'Daisy' },
    { ownerName: 'Terry', pet: 'Barley' },
    { ownerName: 'Terry', pet: 'Boots' },
    { ownerName: 'Adam', pet: 'Whiskers' }
    ]);

    TInner The type of the elements of the second sequence.

    TKey The type of the keys returned by the key selector functions.

    TResult The type of the result elements.

  • Produces the set intersection of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set intersection of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set intersection of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • fourth: Iterable<TSource>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set intersection of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set intersection of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    TKey The type of key to identify elements by.

  • Produces the set intersection of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TKey>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • fourth: Iterable<TSource>

      An IEnumerable whose distinct elements that also appear in the first sequence will be returned.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TSource>

    A sequence that contains the elements that form the set intersection of two sequences.

    TKey The type of key to identify elements by.

  • Interweaves two sequences.

    Parameters

    • collection: Iterable<TSource>

      The sequence to interweave to the first sequence.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the interweaved elements of the two input sequences.

    const numbers = [1, 2];
    const moreNumbers = from(numbers).interweave([3, 4, 5]); // [1, 3, 2, 4, 5]
  • Interweaves multiple sequences.

    Parameters

    • ...collections: Iterable<TSource>[]

      The sequences to interweave to the first sequence.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the interweaved elements of the two or more input sequences.

    const numbers = [1, 2];
    const evenMoreNumbers = from(numbers).interweave([3, 4], [5, 6]); // [1, 3, 5, 2, 4, 6]
  • Returns the last element of a sequence. Throws if sequence is empty.

    Returns TSource

    The value at the last position in the source sequence.

  • Returns the last element of a sequence that satisfies a specified condition.

    Parameters

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

      A function to test each element for a condition.

    Returns TSource

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

  • Returns the last element of a sequence, or null if the sequence contains no elements.

    Returns null | TSource

    null if the source sequence is empty; otherwise, the last element in the IEnumerable

  • Returns the last element of a sequence that satisfies a condition or null if no such element is found.

    Parameters

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

      A function to test each element for a condition.

    Returns null | TSource

    null if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function.

  • Performs a left outer join on two heterogeneous sequences. Additional arguments specify key selection functions and result projection functions.

    Type Parameters

    • TSecond
    • TKey
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence of the join operation.

    • firstKeySelector: (item: TSource) => TKey

      Function that projects the key given an element from first.

    • secondKeySelector: (item: TSecond) => TKey

      Function that projects the key given an element from second.

    • firstSelector: (item: TSource) => TResult

      Function that projects the result given just an element from first where there is no corresponding element in second.

    • bothSelector: (a: TSource, b: TSecond) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a left outer join of the two input sequences.

  • Performs a left outer join on two heterogeneous sequences. Additional arguments specify key selection functions and result projection functions.

    Type Parameters

    • TSecond
    • TKey
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence of the join operation.

    • firstKeySelector: (item: TSource) => TKey

      Function that projects the key given an element from first.

    • secondKeySelector: (item: TSecond) => TKey

      Function that projects the key given an element from second.

    • firstSelector: (item: TSource) => TResult

      Function that projects the result given just an element from first where there is no corresponding element in second.

    • bothSelector: (a: TSource, b: TSecond) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a left outer join of the two input sequences.

  • Performs a left outer join on two homogeneous sequences. Additional arguments specify key selection functions and result projection functions.

    Type Parameters

    • TKey
    • TResult

    Parameters

    • second: Iterable<TSource>

      The second sequence of the join operation.

    • keySelector: (item: TSource) => TKey

      Function that projects the key given an element of one of the sequences to join.

    • firstSelector: (item: TSource) => TResult

      Function that projects the result given just an element from first where there is no corresponding element in second.

    • bothSelector: (a: TSource, b: TSource) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a left outer join of the two input sequences.

  • Performs a left outer join on two homogeneous sequences. Additional arguments specify key selection functions and result projection functions.

    Type Parameters

    • TKey
    • TResult

    Parameters

    • second: Iterable<TSource>

      The second sequence of the join operation.

    • keySelector: (item: TSource) => TKey

      Function that projects the key given an element of one of the sequences to join.

    • firstSelector: (item: TSource) => TResult

      Function that projects the result given just an element from first where there is no corresponding element in second.

    • bothSelector: (a: TSource, b: TSource) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a left outer join of the two input sequences.

  • Returns the maximum value in a sequence of values.

    Returns TSource

    The max value in the sequence.

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

    Type Parameters

    • TResult

    Parameters

    • selector: (item: TSource) => TResult

      A transform function to apply to each element.

    Returns TResult

    The maximum value in the sequence.

    TResult The type of the value returned by selector.

  • Returns the maximum value in a generic sequence according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns TSource

    The value with the maximum key in the sequence.

    TKey The type of key to compare elements by.

  • Returns the min value in a sequence of values.

    Returns TSource

    The min value in the sequence.

  • Invokes a transform function on each element of a generic sequence and returns the min resulting value.

    Type Parameters

    • TResult

    Parameters

    • selector: (item: TSource) => TResult

      A transform function to apply to each element.

    Returns TResult

    The min value in the sequence.

    TResult The type of the value returned by selector.

  • Returns the min value in a generic sequence according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns TSource

    The value with the min key in the sequence.

    TKey The type of key to compare elements by.

  • Filters the elements of an IEnumerable based on a specified type.

    Type Parameters

    • TResult

    Parameters

    • type: new (...params: unknown[]) => TResult

      The type to filter the elements of the sequence on.

    Returns IEnumerable<TResult>

    An IEnumerable that contains elements from the input sequence of type TResult.

    TResult The type to filter the elements of the sequence on.

  • Sorts the elements of a sequence in ascending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    const items = [{ id: 1 }, { id: 3 }, { id: 2 }];
    const ordered = from(items).orderBy(x => x.id).toArray(); // Will be [{ id: 1 }, { id: 2 }, { id: 3 }]

    TKey The type of the key returned by keySelector.

  • Sorts the elements of a sequence in ascending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • comparer: Comparer<TKey>

      An Comparer to compare keys.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    const items = [{ id: 1 }, { id: 3 }, { id: 2 }];
    const ordered = from(items).orderBy(x => x.id).toArray(); // Will be [{ id: 1 }, { id: 2 }, { id: 3 }]

    TKey The type of the key returned by keySelector.

  • Sorts the elements of a sequence in descending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    const items = [{ id: 1 }, { id: 3 }, { id: 2 }];
    const ordered = from(items).orderByDescending(x => x.id).toArray(); // Will be [{ id: 3 }, { id: 2 }, { id: 1 }]

    TKey The type of the key returned by keySelector.

  • Sorts the elements of a sequence in descending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • comparer: Comparer<TKey>

      An Comparer to compare keys.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    const items = [{ id: 1 }, { id: 3 }, { id: 2 }];
    const ordered = from(items).orderByDescending(x => x.id).toArray(); // Will be [{ id: 3 }, { id: 2 }, { id: 1 }]

    TKey The type of the key returned by keySelector.

  • Computes the quantile of a sequence of numbers. Note this will throw an exception if sequence has something other than numbers.

    Parameters

    • q: number

      The percentile to compute (25, 50, etc.)

    Returns number

    The percentile of the sequence.

    const items = [1, 2, 2, 3, 4];
    const q = from(items).quantile(50); // Will be 2
  • Computes the quantile of a sequence.

    Parameters

    • selector: (item: TSource) => number

      A function to extract a value from each element.

    • q: number

      The percentile to compute (25, 50, etc.)

    Returns number

    The percentile of the sequence.

    const items = [{ age: 1 }, { age: 2 }, { age: 2 }, { age: 3 }, { age: 4 }];
    const q = from(items).quantile(x => x.age, 50); // Will be 2
  • Performs a right outer join on two heterogeneous sequences.

    Type Parameters

    • TSecond
    • TKey
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence of the join operation.

    • firstKeySelector: (item: TSource) => TKey

      Function that projects the key given an element from first.

    • secondKeySelector: (item: TSecond) => TKey

      Function that projects the key given an element from second.

    • secondSelector: (item: TSecond) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSecond) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a right outer join of the two input sequences.

    const right = 'right';
    const both = 'both';
    const missing = null;

    type Side = typeof right | typeof both;
    type Person = { name: string };
    type Pet = { name: string; owner: Person };

    const magnus: Person = { name: 'Magnus' };
    const terry: Person = { name: 'Terry' };
    const adam: Person = { name: 'Adam' };
    const john: Person = { name: 'John' };

    const barley: Pet = { name: 'Barley', owner: terry };
    const boots: Pet = { name: 'Boots', owner: terry };
    const whiskers: Pet = { name: 'Whiskers', owner: adam };
    const daisy: Pet = { name: 'Daisy', owner: magnus };
    const scratchy: Pet = { name: 'Scratchy', owner: { name: 'Bob' } };

    const people = from([magnus, terry, adam, john]);
    const pets = from([barley, boots, whiskers, daisy, scratchy]);

    const result = people.rightJoinHeterogeneous<Pet, Person, { side: Side; left: Person | null; right: Pet }>(
    pets,
    person => person,
    pet => pet.owner,
    pet => ({ side: right, left: missing, right: pet }),
    (person, pet) => ({ side: both, left: person, right: pet })
    )
    .toArray();

    expect(result).toEqual([
    { side: both, left: terry, right: barley },
    { side: both, left: terry, right: boots },
    { side: both, left: adam, right: whiskers },
    { side: both, left: magnus, right: daisy },
    { side: right, left: missing, right: scratchy } // Scratchy has an owner, Bob, but Bob is not in the calling collection, hence the 'missing'.
    ]);

    TSecond The type of elements in the second sequence.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Performs a right outer join on two heterogeneous sequences.

    Type Parameters

    • TSecond
    • TKey
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence of the join operation.

    • firstKeySelector: (item: TSource) => TKey

      Function that projects the key given an element from first.

    • secondKeySelector: (item: TSecond) => TKey

      Function that projects the key given an element from second.

    • secondSelector: (item: TSecond) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSecond) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a right outer join of the two input sequences.

    const right = 'right';
    const both = 'both';
    const missing = null;

    type Side = typeof right | typeof both;
    type Person = { name: string };
    type Pet = { name: string; owner: Person };

    const magnus: Person = { name: 'Magnus' };
    const terry: Person = { name: 'Terry' };
    const adam: Person = { name: 'Adam' };
    const john: Person = { name: 'John' };

    const barley: Pet = { name: 'Barley', owner: terry };
    const boots: Pet = { name: 'Boots', owner: terry };
    const whiskers: Pet = { name: 'Whiskers', owner: adam };
    const daisy: Pet = { name: 'Daisy', owner: magnus };
    const scratchy: Pet = { name: 'Scratchy', owner: { name: 'Bob' } };

    const people = from([magnus, terry, adam, john]);
    const pets = from([barley, boots, whiskers, daisy, scratchy]);

    const result = people.rightJoinHeterogeneous<Pet, Person, { side: Side; left: Person | null; right: Pet }>(
    pets,
    person => person,
    pet => pet.owner,
    pet => ({ side: right, left: missing, right: pet }),
    (person, pet) => ({ side: both, left: person, right: pet }),
    (person, pet) => person.name === pet.owner.name
    )
    .toArray();

    expect(result).toEqual([
    { side: both, left: terry, right: barley },
    { side: both, left: terry, right: boots },
    { side: both, left: adam, right: whiskers },
    { side: both, left: magnus, right: daisy },
    { side: right, left: missing, right: scratchy } // Scratchy has an owner, Bob, but Bob is not in the calling collection, hence the 'missing'.
    ]);

    TSecond The type of elements in the second sequence.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Performs a right outer join on two homogeneous sequences.

    Type Parameters

    • TKey
    • TResult

    Parameters

    • second: Iterable<TSource>

      The second sequence of the join operation.

    • keySelector: (item: TSource) => TKey

      Function that projects the key given an element of one of the sequences to join.

    • secondSelector: (item: TSource) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSource) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a right outer join of the two input sequences.

    const right = 'right';
    const both = 'both';
    const missing = null;

    type Side = typeof right | typeof both;
    type Person = { id: number; name: string };

    const magnus: Person = { id: 1, name: 'Magnus' };
    const terry1: Person = { id: 2, name: 'Terry' };
    const adam: Person = { id: 3, name: 'Adam' };
    const john1: Person = { id: 4, name: 'John' };
    const john4: Person = { id: 9, name: 'John' };

    const john2: Person = { id: 5, name: 'John' };
    const jane: Person = { id: 6, name: 'Jane' };
    const terry2: Person = { id: 7, name: 'Terry' };
    const john3: Person = { id: 8, name: 'John' };

    const people1 = from([magnus, terry1, adam, john1, john4]);
    const people2 = from([john2, jane, terry2, john3]);

    const result = people1.rightJoinHomogeneous<string, { side: Side; left: Person | null; right: Person }>(
    people2,
    person => person.name,
    person => ({ side: right, left: missing, right: person }),
    (personLeft, personRight) => ({ side: both, left: personLeft, right: personRight })
    )
    .toArray();

    expect(result).toEqual([
    { side: both, left: john1, right: john2 },
    { side: both, left: john4, right: john2 },
    { side: right, left: missing, right: jane },
    { side: both, left: terry1, right: terry2 },
    { side: both, left: john1, right: john3 },
    { side: both, left: john4, right: john3 }
    ]);

    TSecond The type of elements in the second sequence.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Performs a right outer join on two homogeneous sequences.

    Type Parameters

    • TKey
    • TResult

    Parameters

    • second: Iterable<TSource>

      The second sequence of the join operation.

    • keySelector: (item: TSource) => TKey

      Function that projects the key given an element of one of the sequences to join.

    • secondSelector: (item: TSource) => TResult

      Function that projects the result given just an element from second where there is no corresponding element in first.

    • bothSelector: (a: TSource, b: TSource) => TResult

      Function that projects the result given an element from first and an element from second that match on a common key.

    • equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

    A sequence containing results projected from a right outer join of the two input sequences.

    const right = 'right';
    const both = 'both';
    const missing = null;

    type Side = typeof right | typeof both;
    type Person = { id: number; name: string };

    const magnus: Person = { id: 1, name: 'Magnus' };
    const terry1: Person = { id: 2, name: 'Terry' };
    const adam: Person = { id: 3, name: 'Adam' };
    const john1: Person = { id: 4, name: 'John' };
    const john4: Person = { id: 9, name: 'John' };

    const john2: Person = { id: 5, name: 'John' };
    const jane: Person = { id: 6, name: 'Jane' };
    const terry2: Person = { id: 7, name: 'Terry' };
    const john3: Person = { id: 8, name: 'John' };

    const people1 = from([magnus, terry1, adam, john1, john4]);
    const people2 = from([john2, jane, terry2, john3]);

    const result = people1.rightJoinHomogeneous<string, { side: Side; left: Person | null; right: Person }>(
    people2,
    person => person.name,
    person => ({ side: right, left: missing, right: person }),
    (personLeft, personRight) => ({ side: both, left: personLeft, right: personRight }),
    (keyLeft, keyRight) => keyLeft.toUpperCase() === keyRight.toUpperCase()
    )
    .toArray();

    expect(result).toEqual([
    { side: both, left: john1, right: john2 },
    { side: both, left: john4, right: john2 },
    { side: right, left: missing, right: jane },
    { side: both, left: terry1, right: terry2 },
    { side: both, left: john1, right: john3 },
    { side: both, left: john4, right: john3 }
    ]);

    TSecond The type of elements in the second sequence.

    TKey The type of the key returned by the key selector functions.

    TResult The type of the result elements.

  • Projects each element of a sequence into a new form.

    Type Parameters

    • TResult

    Parameters

    • selector: (item: TSource, index: number) => TResult

      A transform function to apply to each element.

    Returns IEnumerable<TResult>

    An IEnumerable whose elements are the result of invoking the transform function on each element of source.

    TResult The type of the value returned by selector.

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

    Type Parameters

    • TResult

    Parameters

    • selector: (item: TSource, index: number) => TResult[]

      A transform function to apply to each source element; the second parameter of the function represents the index of the source element.

    Returns IEnumerable<TResult>

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

    TResult The type of the value returned by selector.

  • Determines whether two sequences are equal by comparing the elements.

    Parameters

    • second: Iterable<TSource>

      An IEnumerable to compare to the first sequence.

    Returns boolean

    true if the two source sequences are of equal length and their corresponding elements are equal; otherwise, false.

  • Determines whether two sequences are equal by comparing their elements by using a specified EqualityComparer.

    Parameters

    • second: Iterable<TSource>

      An IEnumerable to compare to the first sequence.

    • equalityComparer: EqualityComparer<TSource>

      An EqualityComparer to use to compare elements.

    Returns boolean

    true if the two source sequences are of equal length and their corresponding elements compare equal according to equalityComparer; otherwise, false.

  • Returns the first element of a sequence, and throws an exception if more than one element exists.

    Returns TSource

    The single element of the input sequence that satisfies a condition.

  • Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

    Parameters

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

      A function to test an element for a condition.

    Returns TSource

    The single element of the input sequence that satisfies a condition.

  • Returns a single, specific element of a sequence, or null if that element is not found.

    Returns null | TSource

    The single element of the input sequence, or null if the sequence contains no elements.

  • Returns the only element of a sequence that satisfies a specified condition or null if no such element exists; this method throws an exception if more than one element satisfies the condition.

    Parameters

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

      A function to test an element for a condition.

    Returns null | TSource

    The single element of the input sequence that satisfies the condition, or null if no such element is found.

  • 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 IEnumerable<TSource>

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

  • Returns a new enumerable collection that contains the elements from source with the last count elements of the source collection omitted.

    Parameters

    • count: number

      The number of elements to omit from the end of the collection.

    Returns IEnumerable<TSource>

    A new enumerable collection that contains the elements from source minus count elements from the end of the collection.

  • Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.

    Parameters

    • predicate: (item: 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 IEnumerable<TSource>

    An IEnumerable 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.

  • Determines whether the beginning of the first sequence is equivalent to the second sequence.

    Parameters

    • second: Iterable<TSource>

      The sequence to compare to.

    Returns boolean

    true if first begins with elements equivalent to second.

  • Determines whether the beginning of the first sequence is equivalent to the second sequence, using the specified element equality comparer.

    Parameters

    Returns boolean

    true if first begins with elements equivalent to second.

  • Computes the sum of a sequence of numeric values.

    Returns number

    The sum of the values in the sequence.

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

    Parameters

    • selector: (item: TSource) => number

      A transform function to apply to each element.

    Returns number

    The sum of the projected values.

    const items = [{ age: 15 }, { age: 25 }, { age: 20 }];
    const result = from(items).sum(x => x.age); // 60
  • Returns a specified number of contiguous elements from the start of a sequence.

    Parameters

    • count: number

    Returns IEnumerable<TSource>

    An IEnumerable that contains the specified number of elements from the start of the input sequence.

    const items = [1, 2, 3, 4, 5];
    const result = from(items).take(2); // [1, 2]
  • Returns every N-th element of a sequence.

    Parameters

    • step: number

      Number of elements to bypass before returning the next element.

    Returns IEnumerable<TSource>

    A sequence with every N-th element of the input sequence.

    const items = [1, 2, 3, 4, 5];
    const result = from(items).takeEvery(3); // [1, 4]
  • Returns a new enumerable collection that contains the last count elements from source.

    Parameters

    • count: number

      The number of elements to take from the end of the collection.

    Returns IEnumerable<TSource>

    A new enumerable collection that contains the last count elements from source.

    const items = [1, 2, 3, 4, 5];
    const lastTwo = from(items).takeLast(2); // [4, 5]
  • Returns elements from a sequence as long as a specified condition is true, and then skips the remaining elements.

    Parameters

    • predicate: (item: 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 IEnumerable<TSource>

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

    const items = [1, 2, 3, 4, 5];
    const result = from(items).takeWhile(x => x < 3); // [1, 2]
  • Performs a subsequent ordering of the elements in a sequence in ascending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract a key from each element.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    TKey The type of the key returned by keySelector.

  • Performs a subsequent ordering of the elements in a sequence in ascending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract a key from each element.

    • comparer: Comparer<TKey>

      An Comparer to compare keys.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    TKey The type of the key returned by keySelector.

  • Performs a subsequent ordering of the elements in a sequence in descending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract a key from each element.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    TKey The type of the key returned by keySelector.

  • Performs a subsequent ordering of the elements in a sequence in descending order.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract a key from each element.

    • comparer: Comparer<TKey>

      An Comparer to compare keys.

    Returns IOrderedEnumerable<TSource>

    An IOrderedEnumerable whose elements are sorted according to a key.

    TKey The type of the key returned by keySelector.

  • Creates a new instance of the passed in ctor with the Enumerable as input. Useful for custom iterables.

    Type Parameters

    • TResult

    Parameters

    • ctor: new (src: Iterable<TSource>) => TResult

      The constructor function to create the result.

    Returns TResult

    A new instance of the passed in ctor with the enumerable passed as input.

    class MyCustomEnumerable<T> extends Enumerable<T> {
    public foo(): void {
    console.log('hello');
    }
    }

    const items = [1, 2, 3];

    const asCustom = from(items).to(MyCustomEnumerable); // asCustom is now a MyCustomEnumerable instance.

    TResult The type of the returned object.

  • Converts the source sequence into an array.

    Returns TSource[]

    A new array containing the elements of the source sequence.

    const items = [1, 2, 3];
    const arr = from(items).toArray(); // [1, 2, 3]
  • Returns a JSON string representation of the enumerable.

    Returns string

    A JSON string representation of the enumerable.

  • Creates a Map<TKey, TValue> from an IEnumerable according to specified key selector.

    Type Parameters

    • TKey

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract a key from each element.

    Returns Map<TKey, TSource>

    A Map<TKey, TSource> that contains keys and values.

    TKey The type of the key returned by keySelector.

  • Creates a Map<TKey, TValue> from an IEnumerable according to specified key selector and element selector functions.

    Type Parameters

    • TKey
    • TValue

    Parameters

    • keySelector: (item: TSource) => TKey

      A function to extract a key from each element.

    • valueSelector: (item: TSource) => TValue

      A transform function to produce a result element value from each element.

    Returns Map<TKey, TValue>

    A Map<TKey, TValue> that contains keys and values.

    TKey The type of the key returned by keySelector.

    TValue The type of the value returned by valueSelector.

  • Returns an object with keys selected by keySelector and values of TSource.

    Parameters

    • keySelector: (item: TSource) => string

      A function to extract a key from each element.

    Returns Record<string, TSource>

    An object with keys selected by keySelector and values of TSource

  • Returns an object with keys selected by keySelector and values of TSource.

    Type Parameters

    • TValue

    Parameters

    • keySelector: (item: TSource) => string

      A function to extract a key from each element.

    • valueSelector: (item: TSource) => TValue

      A transform function to produce a result element value from each element.

    Returns Record<string, TValue>

    An object with keys selected by keySelector and values of TSource

    TValue The type of the value returned by valueSelector.

  • Creates a Set from an IEnumerable.

    Returns Set<TSource>

    A Set that contains values of type TSource selected from the input sequence.

    const items = [1, 1, 2, 3, 3];

    const asSet = from(items).asSet(); // Set([1, 2, 3])
  • Returns a string representation of the enumerable.

    Returns string

    A string representation of the enumerable.

    const items = [1, 2, 3];
    const asStr = from(items).toString(); // '1,2,3'
  • Produces the set union of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose distinct elements form the second set for the union.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from both input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the set union of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose distinct elements form the second set for the union.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements form the third set for the union.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from both input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the set union of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose distinct elements form the second set for the union.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements form the third set for the union.

    • fourth: Iterable<TSource>

      An IEnumerable whose distinct elements form the fourth set for the union.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from both input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the set union of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose distinct elements form the second set for the union.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from both input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the set union of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose distinct elements form the second set for the union.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements form the third set for the union.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from both input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the set union of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An IEnumerable whose distinct elements form the second set for the union.

    • third: Iterable<TSource>

      An IEnumerable whose distinct elements form the third set for the union.

    • fourth: Iterable<TSource>

      An IEnumerable whose distinct elements form the fourth set for the union.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the elements from both input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Filters a sequence of values based on a predicate.

    Parameters

    • predicate: (item: 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 IEnumerable<TSource>

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

    const items = [1, 2, 3, 4, 5];
    const greaterThanTwo = from(items).where(x => x > 2); // Will be [3, 4, 5]
  • Processes a sequence into a series of subsequences representing a windowed subset of the original. If size is greater than source.length, no subsequences will be returned.

    Parameters

    • size: number

      The size (number of elements) in each window.

    Returns IEnumerable<IEnumerable<TSource>>

    A series of sequences representing each sliding window subsequence.

  • Produces the set union of two sequences.

    Parameters

    • second: Iterable<TSource>

      One or more Iterable whose distinct elements form the second set for the union.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

  • Produces the symmetric difference of two or more sequences.

    Parameters

    • ...second: Iterable<TSource>[]

      One or more Iterable whose distinct elements form the second or more set for the symmetric difference.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

  • Produces the symmetric difference of two sequences using a provided equality comparer.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • equalityComparer: EqualityComparer<TSource>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

  • Produces the symmetric difference of three sequences using a provided equality comparer.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • third: Iterable<TSource>

      An Iterable whose distinct elements form the third set for the symmetric difference.

    • equalityComparer: EqualityComparer<TSource>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

  • Produces the symmetric difference of four sequences using a provided equality comparer.

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • third: Iterable<TSource>

      An Iterable whose distinct elements form the third set for the symmetric difference.

    • fourth: Iterable<TSource>

      An Iterable whose distinct elements form the fourth set for the symmetric difference.

    • equalityComparer: EqualityComparer<TSource>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

  • Produces the symmetric difference of two sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the symmetric difference of three sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • third: Iterable<TSource>

      An Iterable whose distinct elements form the third set for the symmetric difference.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the symmetric difference of four sequences according to a specified key selector function.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • third: Iterable<TSource>

      An Iterable whose distinct elements form the third set for the symmetric difference.

    • fourth: Iterable<TSource>

      An Iterable whose distinct elements form the fourth set for the symmetric difference.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the symmetric difference of two sequences according to a specified key selector function using a provided equality comparer.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the symmetric difference of three sequences according to a specified key selector function using a provided equality comparer.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • third: Iterable<TSource>

      An Iterable whose distinct elements form the third set for the symmetric difference.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces the symmetric difference of four sequences according to a specified key selector function using a provided equality comparer.

    Type Parameters

    • TKey

    Parameters

    • second: Iterable<TSource>

      An Iterable whose distinct elements form the second set for the symmetric difference.

    • third: Iterable<TSource>

      An Iterable whose distinct elements form the third set for the symmetric difference.

    • fourth: Iterable<TSource>

      An Iterable whose distinct elements form the fourth set for the symmetric difference.

    • keySelector: (item: TSource) => TKey

      A function to extract the key for each element.

    • equalityComparer: EqualityComparer<TKey>

      The EqualityComparer to compare values.

    Returns IEnumerable<TSource>

    An IEnumerable that contains the symmetric difference from all input sequences, excluding duplicates.

    TKey The type of key to identify elements by.

  • Produces a sequence of tuples with elements from the two specified sequences.

    Type Parameters

    • TSecond

    Parameters

    • second: Iterable<TSecond>

      The second sequence to merge.

    Returns IEnumerable<[TSource, TSecond]>

    An IEnumerable<[TSource, TSecond]> that contains merged elements of two input sequences.

    TSecond The type of the elements of the second input sequence.

  • Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.

    Type Parameters

    • TSecond
    • TResult

    Parameters

    • second: Iterable<TSecond>

      The second sequence to merge.

    • resultSelector: (first: TSource, second: TSecond) => TResult

      A function that specifies how to merge the elements from the two sequences.

    Returns IEnumerable<TResult>

    An IEnumerable that contains merged elements of two input sequences.

    TSecond The type of the elements of the second input sequence.

    TResult The type of the elements of the result sequence.