Skip to content

Commit

Permalink
fix: reintroduce nullish guards
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Aug 3, 2022
1 parent 456712a commit b13a851
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sdam/server_description.ts
Expand Up @@ -181,6 +181,15 @@ export class ServerDescription {
* in the {@link https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#serverdescription|SDAM spec}
*/
equals(other?: ServerDescription | null): boolean {
const topologyVersionsEqual =
this.topologyVersion === other?.topologyVersion ||
compareTopologyVersion(this.topologyVersion, other?.topologyVersion) === 0;

const electionIdsEqual =
this.electionId && other?.electionId != null
? other.electionId && compareObjectId(this.electionId, other.electionId) === 0
: this.electionId === other?.electionId;

return (
other != null &&
errorStrictEqual(this.error, other.error) &&
Expand All @@ -190,10 +199,10 @@ export class ServerDescription {
tagsStrictEqual(this.tags, other.tags) &&
this.setName === other.setName &&
this.setVersion === other.setVersion &&
compareObjectId(this.electionId, other.electionId) === 0 &&
electionIdsEqual &&
this.primary === other.primary &&
this.logicalSessionTimeoutMinutes === other.logicalSessionTimeoutMinutes &&
compareTopologyVersion(this.topologyVersion, other.topologyVersion) === 0
topologyVersionsEqual
);
}
}
Expand Down

0 comments on commit b13a851

Please sign in to comment.