mapKeys
Creates a new Map with the same values but with each key transformed by a function. If two entries derive the same new key, the later one (in insertion order) wins.
Available since v3.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
map | ReadonlyMap<K, V> | The Map to transform |
fn | function | Function invoked with (key, value) that returns the new key |
Returns
Section titled “Returns”Map<R, V> — A new Map with transformed keys
Examples
Section titled “Examples”Uppercase every key
Section titled “Uppercase every key”Creates a new Map with transformed keys and unchanged values.
