ConstElement type produced by the source iterable.
Property key returned by keySelector.
Value returned by valueSelector.
Selector producing the property key for each element along with its index.
Selector producing the property value for each element along with its index.
A record keyed by the projected properties with their corresponding values.
const users = [
{ id: "u1", name: "Ada" },
{ id: "u2", name: "Grace" },
];
const lookup = _toObject(
users,
(user) => user.id,
(user) => user.name
);
console.log(lookup); // { u1: "Ada", u2: "Grace" }
or using the curried version:
const lookup = pipeInto(
[
{ id: "u1", name: "Ada" },
{ id: "u2", name: "Grace" },
],
toObject(
(user) => user.id,
(user) => user.name
)
);
console.log(lookup); // { u1: "Ada", u2: "Grace" }
Constructs an object by projecting keys and values from each element of the source iterable.
Curried version of _toObject.