Creates a new object with the same keys as source but with each value transformed by the provided mapper function.
source
mapper
The type of the source object
The type of the mapped values
The source object whose values will be mapped
A function (value, key) => U called for every own enumerable property.
(value, key) => U
A new object with the same keys as source and values produced by mapper. Returns an empty object if source is null or undefined.
0.14.0
const prices = { apple: 1.5, banana: 0.75, cherry: 3.0 };objMapValues(prices, (v) => v * 2);// => { apple: 3, banana: 1.5, cherry: 6 }const user = { firstName: "ada", lastName: "lovelace" };objMapValues(user, (v) => v.toUpperCase());// => { firstName: "ADA", lastName: "LOVELACE" } Copy
const prices = { apple: 1.5, banana: 0.75, cherry: 3.0 };objMapValues(prices, (v) => v * 2);// => { apple: 3, banana: 1.5, cherry: 6 }const user = { firstName: "ada", lastName: "lovelace" };objMapValues(user, (v) => v.toUpperCase());// => { firstName: "ADA", lastName: "LOVELACE" }
Creates a new object with the same keys as
sourcebut with each value transformed by the providedmapperfunction.