The first sequence to join.
The second sequence to join to the first.
A function to extract the join key from each element of the first sequence.
A function to extract the join key from each element of the second sequence.
A function to create a result element from two matching elements.
Optional
equalityComparer: EqualityComparer<TKey>A function to compare keys.
An Enumerable
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' }
]);
Performs an inner join by correlating the elements of two sequences based on matching keys.