mapValues
@guoba-ai/utils / object / mapValues
Function: mapValues()
function mapValues<T, U>(obj, fn): Record<keyof T extends string ? keyof T : string, U>;Defined in: object.ts:216
Transform the values of an object using a mapping function.
Type Parameters
T
T extends object
U
U
Parameters
obj
T
The source object
fn
(value, key) => U
Function that receives each value and key, returns the new value
Returns
Record<keyof T extends string ? keyof T : string, U>
A new object with transformed values
Example
mapValues({ a: 1, b: 2 }, value => value * 10) // { a: 10, b: 20 }