mapValues
Creates a new Map with the same keys but with each value transformed by a function.
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 (value, key) that returns the new value |
Returns
Section titled “Returns”Map<K, R> — A new Map with transformed values
Examples
Section titled “Examples”Scale every value
Section titled “Scale every value”Creates a new Map with transformed values and unchanged keys.
