mapKeys
Import from @varavel/vdl-plugin-sdk/utils/maps.
Creates a new Map with the same values but with keys transformed by the provided function.
This function takes a Map and a function that generates a new key from each value-key pair. It returns a new Map where the keys are the result of applying the function to each entry, while the values remain the same.
Type Parameters
| Type Parameter | Description |
|---|---|
K |
The type of keys in the Map. |
V |
The type of values in the Map. |
Parameters
| Parameter | Type | Description |
|---|---|---|
map |
Map\<K, V> |
The Map to transform. |
getNewKey |
(value, key, object) => K |
A function that generates a new key from a value-key pair. |
Returns
Map\<K, V>
A new Map with transformed keys and the same values.