astro-integration-pocketbase
Version:
An Astro integration to support developers working with astro-loader-pocketbase.
17 lines (15 loc) • 323 B
text/typescript
/**
* Adds a value to an array in a map. If the key does not exist, it will be created.
*/
export function pushToMapArray<TKey, TArray>(
map: Map<TKey, Array<TArray>>,
key: TKey,
value: TArray
): void {
const array = map.get(key);
if (array) {
array.push(value);
return;
}
map.set(key, [value]);
}