Queries the map for the given key and returns its associated value, if it is present.
If the key is absent, then the producer will be invoked. The computed value will be associated with the given key and returned.
producer
export function lazyLookup<K, V>( producer: (key: K) => V, cache: PickMap<K, V, 'has' | 'set' | 'get'> = new Map()) { return (key: K): V => computeIfAbsent(cache, key, producer);}
the map to work with
the queried key
a function to create a value if the key is not present
Generated using TypeDoc
Queries the map for the given key and returns its associated value, if it is present.
If the key is absent, then the
producer
will be invoked. The computed value will be associated with the given key and returned.Example