Skip to main content

Home > @jsplumb/util > getsert

getsert() function#

Get, or insert then get, a value from the map.

Signature:

export declare function getsert<K, V>(map: Map<K, V>, key: K, valueGenerator: () => V): V;

Parameters#

ParameterTypeDescription
mapMap<K, V>Map to get the value from.
keyKKey of the value to retrieve
valueGenerator() => VMethod used to generate a value for the key if it is not currently in the map.

Returns:

V