From 3416984cce996d790de1bbc103f46e3dec85b8d2 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 23 Oct 2015 16:39:35 -0700 Subject: [PATCH] refactor(RuntimeMetadataResolver): simplify the code Closes #4874 --- .../angular2/src/core/compiler/runtime_metadata.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/angular2/src/core/compiler/runtime_metadata.ts b/modules/angular2/src/core/compiler/runtime_metadata.ts index a4a35ec4d6..d7d4b9a3ca 100644 --- a/modules/angular2/src/core/compiler/runtime_metadata.ts +++ b/modules/angular2/src/core/compiler/runtime_metadata.ts @@ -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(); - directives.forEach((dirMeta) => { directivesMap.set(dirMeta.type.runtime, dirMeta); }); - return MapWrapper.values(directivesMap); +function removeDuplicates(items: any[]): any[] { + let m = new Map(); + items.forEach(i => m.set(i, null)); + return MapWrapper.keys(m); } function flattenDirectives(view: ViewMetadata): Type[] {