Function: mapValues()
ts
function mapValues<T, R>(object, iteratee): Record<string, R>;Creates a new object with transformed values. 创建一个值被转换后的新对象。
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Record<string, unknown> | The source object type / 源对象类型 |
R | The mapped value type / 映射后的值类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
object | T | The source object / 源对象 |
iteratee | (value, key) => R | The value transform function / 值转换函数 |
Returns
Record<string, R>
A new object with transformed values / 值转换后的新对象
Example
ts
mapValues({ a: 1, b: 2 }, (value) => value * 2)
// => { a: 2, b: 4 }Since
1.2.0