mapEntries
@guoba-ai/utils / object / mapEntries
Function: mapEntries()
function mapEntries<T, K, V>(obj, fn): Record<K, V>;Defined in: object.ts:238
Transform both keys and values of an object using a mapping function.
Type Parameters
T
T extends object
K
K extends string
V
V
Parameters
obj
T
The source object
fn
(key, value) => [K, V]
Function that receives each key and value, returns a [newKey, newValue] tuple
Returns
Record<K, V>
A new object with transformed keys and values
Example
mapEntries({ a: 1, b: 2 }, (key, value) => [key.toUpperCase(), value * 10])
// { A: 10, B: 20 }