From 437cf82928411bc13628920bbaed4ac3bb0d0e97 Mon Sep 17 00:00:00 2001 From: Abraham Williams <4braham@gmail.com> Date: Tue, 24 Jul 2018 09:45:50 -0500 Subject: [PATCH] Remove unneeded ordinaryHasOwnMetadata method --- src/index.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/index.ts b/src/index.ts index f15d4c8..684f510 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,7 +48,7 @@ export function getOwnMetadata(metadataKey: MetadataKey, target: Target, propert } export function hasOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): boolean { - return ordinaryHasOwnMetadata(metadataKey, target, propertyKey); + return !!ordinaryGetOwnMetadata(metadataKey, target, propertyKey); } function decorateConstructor(decorators: ClassDecorator[], target: Function): Function { @@ -63,10 +63,7 @@ function decorateConstructor(decorators: ClassDecorator[], target: Function): Fu function decorateProperty(decorators: MemberDecorator[], target: Target, propertyKey: PropertyKey, descriptor?: PropertyDescriptor): PropertyDescriptor | undefined { decorators.reverse().forEach((decorator: MemberDecorator) => { - const decorated = decorator(target, propertyKey, descriptor); - if (decorated) { - descriptor = decorated; - } + descriptor = decorator(target, propertyKey, descriptor) || descriptor; }); return descriptor; } @@ -79,18 +76,13 @@ function ordinaryDefineOwnMetadata(metadataKey: MetadataKey, metadataValue: Meta } function ordinaryGetMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): Function | undefined { - return ordinaryHasOwnMetadata(metadataKey, target, propertyKey) + return !!ordinaryGetOwnMetadata(metadataKey, target, propertyKey) ? ordinaryGetOwnMetadata(metadataKey, target, propertyKey) : Object.getPrototypeOf(target) ? ordinaryGetMetadata(metadataKey, Object.getPrototypeOf(target), propertyKey) : undefined; } -function ordinaryHasOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): boolean { - const metadataMap = getMetadataMap(target, propertyKey); - return !!metadataMap && !!metadataMap.has(metadataKey); -} - function ordinaryGetOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): Function | undefined { if (target === undefined) throw new TypeError(); const metadataMap = getMetadataMap(target, propertyKey);