The type of the keys in the map.
The map to update.
The key of the value to update.
The function to use to update the value.
This function takes the current value (or undefined
if the key does not exist) and the key as arguments,
and should return the new value.
const map = new Map<string, number>()
map.set('a', 1)
mapUpdate(map, 'a', (value, key) => value !== undefined ? value + 1 : 0)
map.get('a')
//=> 2
Generated using TypeDoc
Updates the value for the given key in the map using the provided function. If the key does not exist in the map, the function will be called with
undefined
as the value.