static toDictionary( array: TItem[], getKey: (item: TItem) => number): { [id: number]: TItem }; static toDictionary( array: TItem[], getKey: (item: TItem) => number, getValue: (item: TItem) => TValue): { [id: number]: TValue }; static toDictionary( array: TItem[], getKey: (item: TItem) => string): { [id: string]: TItem }; static toDictionary( array: TItem[], getKey: (item: TItem) => string, getValue: (item: TItem) => TValue): { [id: string]: TValue }; static toDictionary( array: TItem[], getKey: (item: TItem) => number | string, getValue?: (item: TItem) => any): any { // eslint-disable-line @typescript-eslint/no-explicit-any const result = {} as any; // eslint-disable-line @typescript-eslint/no-explicit-any if (array) { if (getValue) { array.forEach(_ => result[getKey(_)] = getValue(_)); } else { array.forEach(_ => result[getKey(_)] = _); } } return result; }