mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge remote-tracking branch 'origin/master' into webpack5-upgrade-attempt
# Conflicts: # package.json # yarn.lock
This commit is contained in:
commit
55eebf38b7
47 files changed
+672
-658
No files matched your search
@@ -25,3 +25,14 @@ export function getOrInsert<K, V>(map: Map<K, V>, key: K, value: V): V {
|
||||
export function getOrInsertMap<K, MK, MV>(map: Map<K, Map<MK, MV>>, key: K): Map<MK, MV> {
|
||||
return getOrInsert(map, key, new Map<MK, MV>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Like `getOrInsert` but with delayed creation of the item
|
||||
*/
|
||||
export function getOrInsertWith<K, V>(map: Map<K, V>, key: K, value: () => V): V {
|
||||
if (!map.has(key)) {
|
||||
map.set(key, value());
|
||||
}
|
||||
|
||||
return map.get(key);
|
||||
}
|
||||
Reference in new issue
Block a user