mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
remove any type
add annotation
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
export function pushOrSet(object: { [index: string | number]: any[] }, key: string | number, value: any) {
|
||||
/**
|
||||
* Pushes a value to an array in an object, if the array exists. Else creates a new array containing value.
|
||||
* @param object Object which contains array
|
||||
* @param key Key which array is in
|
||||
* @param value Value to push
|
||||
*/
|
||||
export function pushOrSet<T, K extends string | number | symbol>(object: { [key in K]: Array<T> }, key: K, value: T) {
|
||||
if (key in object) {
|
||||
object[key].push(value);
|
||||
object[key]!.push(value);
|
||||
} else {
|
||||
object[key] = [value];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user