Skip to content

Commit

Permalink
fix(pojos): clean up optional chaining operator on function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Feb 24, 2021
1 parent e6c3299 commit 65304a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/pojos/src/lib/storages/pojos-mapping.storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export class PojosMappingStorage implements MappingStorage<string> {
private storage = new Map<string, Map<string, Mapping>>();

get(source: string, destination: string): Mapping | undefined {
return this.storage.get(source)?.get(destination);
const sourceVal = this.storage.get(source);
return sourceVal ? sourceVal.get(destination) : undefined;
}

has(source: string, destination: string): boolean | undefined {
return this.storage.get(source)?.has(destination);
const sourceVal = this.storage.get(source);
return sourceVal ? sourceVal.has(destination) : undefined;
}

set(source: string, destination: string, mapping: Mapping): void {
Expand All @@ -26,7 +28,8 @@ export class PojosMappingStorage implements MappingStorage<string> {
}

if (!this.has(source, destination)) {
this.storage.get(source)?.set(destination, mapping);
const sourceVal = this.storage.get(source);
sourceVal && sourceVal.set(destination, mapping);
}
}

Expand Down

0 comments on commit 65304a7

Please sign in to comment.