1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 9x 2x 2x 2x 1x 1x 9x 9x | export interface Map<Type> { [key: string]: Type; } export function mapObject<SourceItem, ResultItem>( input: Map<SourceItem>, mapper: (item: SourceItem, key: string) => ResultItem, ): Map<ResultItem> { const result: Map<ResultItem> = {}; Object.keys(input).map(key => { const mapped = mapper(input[key], key); result[key] = mapped; }); return result; } export function convertObjectToArray<Type>(input: Map<Type>): Type[] { return Object.keys(input).map(key => input[key]); } |