mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Compute Tray Icon on the fly instead of at build (#5157)
This commit is contained in:
1 parent
51a93b8cc0
commit
8ada3c7505
11 files changed
+84
-77
No files matched your search
@@ -48,6 +48,17 @@ export function getOrInsertWith<K, V>(map: Map<K, V>, key: K, builder: () => V):
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link getOrInsertWith} but the builder is async and will be awaited before inserting into the map
|
||||
*/
|
||||
export async function getOrInsertWithAsync<K, V>(map: Map<K, V>, key: K, asyncBuilder: () => Promise<V>): Promise<V> {
|
||||
if (!map.has(key)) {
|
||||
map.set(key, await asyncBuilder());
|
||||
}
|
||||
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value associated with `key` iff there was not a previous value
|
||||
* @param map The map to interact with
|
||||
|
||||
Reference in new issue
Block a user