Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 19x 19x 19x | 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]); } |