ConstElement type produced by the source iterable.
Element type produced by the inner sequence.
Key type returned by both key selector functions.
Resulting element type produced by the selector.
Iterable providing the inner elements to match.
Selector extracting the key for each outer element.
Selector extracting the key for each inner element.
Projection producing the output value for matches, receiving undefined when none exist.
OptionalmapFactory: MapFactory<TKey>Optional factory supplying the map used to group inner elements.
A deferred iterable of projected values including unmatched outer elements.
const users = [
{ id: 1, name: "Ada" },
{ id: 2, name: "Grace" },
];
const roles = [
{ userId: 1, role: "admin" },
{ userId: 3, role: "viewer" },
];
const joined = [
..._leftOuterJoin(
users,
roles,
(user) => user.id,
(role) => role.userId,
(user, role) => ({ user: user.name, role: role?.role ?? "none" })
),
];
console.log(joined);
// [{ user: "Ada", role: "admin" }, { user: "Grace", role: "none" }]
or using the curried version:
const users = [
{ id: 1, name: "Ada" },
{ id: 2, name: "Grace" },
];
const roles = [
{ userId: 1, role: "admin" },
{ userId: 3, role: "viewer" },
];
const joined = [
...pipeInto(
users,
leftOuterJoin(
roles,
(user) => user.id,
(role) => role.userId,
(user, role) => ({ user: user.name, role: role?.role ?? "none" })
)
),
];
console.log(joined);
// [{ user: "Ada", role: "admin" }, { user: "Grace", role: "none" }]
Performs a left outer join between the source iterable and the supplied sequence.
Curried version of _leftOuterJoin.