Type of elements within the outer sequence.
Type of elements within the inner sequence.
Type of key produced by the key selectors.
Type of element returned by resultSelector.
The outer sequence.
Sequence whose elements are joined with the outer sequence.
Selector that extracts the join key from each outer element.
Selector that extracts the join key from each inner element.
Projection that combines an outer element with a matching inner element. When no match exists, null is supplied as the inner value.
OptionalkeyComparator: EqualityComparator<TKey, TKey>Optional equality comparator used to match keys. Defaults to the library's standard equality comparison when omitted.
A sequence generated by applying resultSelector to each matching pair (and unmatched outer elements).
The inner sequence is fully enumerated to build an in-memory lookup before outer elements are processed. The outer sequence is then enumerated lazily and its original ordering is preserved. This is a left outer join.
const categories = [
{ id: 1, name: 'Fruit' },
{ id: 2, name: 'Vegetable' },
];
const products = [
{ name: 'Apple', categoryId: 1 },
{ name: 'Banana', categoryId: 1 },
{ name: 'Unknown', categoryId: 3 },
];
const joined = leftJoin(
categories,
products,
c => c.id,
p => p.categoryId,
(c, p) => ({ category: c.name, product: p?.name ?? null })
).toArray();
console.log(joined);
// [
// { category: 'Fruit', product: 'Apple' },
// { category: 'Fruit', product: 'Banana' },
// { category: 'Vegetable', product: null }
// ]
Produces a projection from the sequence and a second sequence by matching elements that share an identical join key. Outer elements with no match are included once with
nullas the inner value.