846 B
846 B
Home > @apextoaster/js-utils > setOrPush
setOrPush() function
Set a map key to a new array or push to the existing value.
Signature:
export declare function setOrPush<TKey, TVal>(map: Map<TKey, ReadonlyArray<TVal>>, key: TKey, val: TVal | ReadonlyArray<TVal>): Map<TKey, ReadonlyArray<TVal>>;
Parameters
Parameter | Type | Description |
---|---|---|
map | Map<TKey, ReadonlyArray<TVal>> | The destination map and source of existing values. |
key | TKey | The key to get and set. |
val | TVal | ReadonlyArray<TVal> | The value to add. |
Returns:
Map<TKey, ReadonlyArray<TVal>>