• Performs a left outer join on two homogeneous sequences.

    Type Parameters

    • TFirst
    • TKey
    • TResult

    Parameters

    • first: Iterable<TFirst>

      The first sequence of the join operation.

    • second: Iterable<TFirst>

      The second sequence of the join operation.

    • keySelector: (item: TFirst) => TKey

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

    • firstSelector: (item: TFirst) => TResult

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

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

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

    • OptionalequalityComparer: 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.

    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 = leftJoinHomogeneous<Pet, Person, { ownerName: string; pet: string | null }>(
    people,
    pets,
    person => person,
    pet => pet.owner,
    person => ({ ownerName: person.name, pet: null }),
    (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' },
    { ownerName: 'John', pet: null }
    ]);

    TFirst The type of elements in the first sequence.

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

    TResult The type of the result elements.