From 4682fbf7ea0f3a18a7c6c32849bf3e0d99c4721b Mon Sep 17 00:00:00 2001 From: Chau Tran Date: Fri, 29 Jan 2021 21:24:57 -0600 Subject: [PATCH] fix(pojos): adjust code smell --- packages/pojos/src/lib/storages/pojos-metadata.storage.ts | 6 ++++-- packages/pojos/src/lib/utils/instantiate.util.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/pojos/src/lib/storages/pojos-metadata.storage.ts b/packages/pojos/src/lib/storages/pojos-metadata.storage.ts index d18f5de1c..e7e39feb2 100644 --- a/packages/pojos/src/lib/storages/pojos-metadata.storage.ts +++ b/packages/pojos/src/lib/storages/pojos-metadata.storage.ts @@ -33,7 +33,7 @@ export class PojosMetadataStorage implements MetadataStorage { while (i--) { const metadata = metadataList[i]; // skip existing - if (resultMetadataList.some(([metaKey]) => metaKey === metadata[0])) { + if (resultMetadataList.some(([key]) => key === metadata[0])) { continue; } resultMetadataList.push(metadataList[i]); @@ -46,7 +46,9 @@ export class PojosMetadataStorage implements MetadataStorage { metaKey: string, key: string ): Metadata | undefined { - return this.getMetadata(metaKey).find(([metaKey]) => metaKey === key); + return this.getMetadata(metaKey).find( + ([innerMetaKey]) => innerMetaKey === key + ); } has(metaKey: string): boolean { diff --git a/packages/pojos/src/lib/utils/instantiate.util.ts b/packages/pojos/src/lib/utils/instantiate.util.ts index a78cbdf36..6e74e7750 100644 --- a/packages/pojos/src/lib/utils/instantiate.util.ts +++ b/packages/pojos/src/lib/utils/instantiate.util.ts @@ -46,8 +46,12 @@ export function instantiate>( } if (isDefined(valueAtKey)) { - const [result] = instantiate(metadataStorage, metaResult, valueAtKey); - obj[key] = result; + const [instantiateResult] = instantiate( + metadataStorage, + metaResult, + valueAtKey + ); + obj[key] = instantiateResult; continue; }