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

    Example

    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 = join(
    people,
    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' }
    ]);

    Typeparam

    TOuter The type of the elements of the first sequence.

    Typeparam

    TInner The type of the elements of the second sequence.

    Typeparam

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

    Typeparam

    TResult The type of the result elements.

    Returns

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

    Type Parameters

    • TOuter

    • TInner

    • TKey

    • TResult

    Parameters

    • outer: Iterable<TOuter>

      The first sequence to join.

    • inner: Iterable<TInner>

      The second sequence to join to the first.

    • outerKeySelector: ((item: TOuter) => TKey)

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

        • (item: TOuter): TKey
        • Parameters

          • item: TOuter

          Returns TKey

    • innerKeySelector: ((item: TInner) => TKey)

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

        • (item: TInner): TKey
        • Parameters

          • item: TInner

          Returns TKey

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

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

        • (item: TOuter, inner: TInner): TResult
        • Parameters

          • item: TOuter
          • inner: TInner

          Returns TResult

    • Optional equalityComparer: EqualityComparer<TKey>

      A function to compare keys.

    Returns IEnumerable<TResult>

Generated using TypeDoc