addToProp<T, K>(obj: Record<K, T | T[]>, key: K, value: T, overwrite?: boolean): Record<K, T | T[]>
If key already exists in obj, turns respective value
into array and pushes value onto the array.
Else, adds "normal" key-value pair as property.
If overwrite is true, always overwrites existing value
with new value without turning it into array.
Returns a new object with the original object's keys and values inverted.
The original object's values must therefore be implicitly convertable to type string.
Type parameters
K: string
Parameters
obj: Record<K, string>
Returns Record<string, K>
mapProperties
mapProperties<T, O, K>(input: Record<K, T>, func: function): Record<K, O>
Iterates over all properties in an object and executes
func on each.
Returns a new object with the same keys as the input
object and the values as result of the func.
If key already exists in obj, turns respective value into array and pushes value onto the array. Else, adds "normal" key-value pair as property. If overwrite is true, always overwrites existing value with new value without turning it into array.