Compute Tray Icon on the fly instead of at build (#5157)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-04-28 12:31:57 -04:00
1 parent 51a93b8cc0
commit 8ada3c7505
11 files changed
+84 -77

No files matched your search

+11
View File
@@ -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