refactor(RuntimeMetadataResolver): simplify the code

Closes #4874
This commit is contained in:
Victor Berchet 2015-10-23 16:39:35 -07:00
parent abdd524911
commit 3416984cce
1 changed files with 6 additions and 6 deletions

View File

@ -79,15 +79,15 @@ export class RuntimeMetadataResolver {
`Unexpected directive value '${stringify(directives[i])}' on the View of component '${stringify(component)}'`);
}
}
return removeDuplicatedDirectives(directives.map(type => this.getMetadata(type)));
return removeDuplicates(directives).map(type => this.getMetadata(type));
}
}
function removeDuplicatedDirectives(directives: cpl.CompileDirectiveMetadata[]):
cpl.CompileDirectiveMetadata[] {
var directivesMap = new Map<Type, cpl.CompileDirectiveMetadata>();
directives.forEach((dirMeta) => { directivesMap.set(dirMeta.type.runtime, dirMeta); });
return MapWrapper.values(directivesMap);
function removeDuplicates(items: any[]): any[] {
let m = new Map<any, any>();
items.forEach(i => m.set(i, null));
return MapWrapper.keys(m);
}
function flattenDirectives(view: ViewMetadata): Type[] {