mirror of
https://github.com/logos-messaging/logos-delivery-js.git
synced 2026-03-14 21:53:30 +00:00
14 lines
250 B
TypeScript
14 lines
250 B
TypeScript
|
|
export function pushOrInitMapSet<K, V>(
|
||
|
|
map: Map<K, Set<V>>,
|
||
|
|
key: K,
|
||
|
|
newValue: V
|
||
|
|
): void {
|
||
|
|
let arr = map.get(key);
|
||
|
|
if (typeof arr === "undefined") {
|
||
|
|
map.set(key, new Set());
|
||
|
|
arr = map.get(key) as Set<V>;
|
||
|
|
}
|
||
|
|
|
||
|
|
arr.add(newValue);
|
||
|
|
}
|