Function: mapKeys()
ts
function mapKeys<T>(object, iteratee): Record<string, T[keyof T]>;Creates a new object with transformed keys. 创建一个键被转换后的新对象。
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Record<string, unknown> | The source object type / 源对象类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
object | T | The source object / 源对象 |
iteratee | (key, value) => PropertyKey | The key transform function / 键转换函数 |
Returns
Record<string, T[keyof T]>
A new object with transformed keys / 键转换后的新对象
Example
ts
mapKeys({ a: 1, b: 2 }, (key) => key.toUpperCase())
// => { A: 1, B: 2 }Since
1.2.0