xdash API Reference / mapKeys
Function: mapKeys()
mapKeys<
T>(obj,fn):Record<string,T>
Defined in: src/object.ts:11
Maps an object by its keys.
Type Parameters
T
T
Parameters
obj
Record<string, T>
object to map
fn
(key, value) => string
callback to map the object
Returns
Record<string, T>
the mapped object
Example
ts
mapKeys({ a: 1, b: 2 }, key => key.toUpperCase()) // returns { A: 1, B: 2 }
mapKeys({ a: 'hello', b: 'world' }, key => key.toUpperCase()) // returns { A: 'hello', B: 'world' }