* Determines if another `ServerDescription` is equal to this one per the rules defined in the SDAM specification. * @see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.md
(other?: ServerDescription | null)
| 175 | * @see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.md |
| 176 | */ |
| 177 | equals(other?: ServerDescription | null): boolean { |
| 178 | // Despite using the comparator that would determine a nullish topologyVersion as greater than |
| 179 | // for equality we should only always perform direct equality comparison |
| 180 | const topologyVersionsEqual = |
| 181 | this.topologyVersion === other?.topologyVersion || |
| 182 | compareTopologyVersion(this.topologyVersion, other?.topologyVersion) === 0; |
| 183 | |
| 184 | const electionIdsEqual = |
| 185 | this.electionId != null && other?.electionId != null |
| 186 | ? compareObjectId(this.electionId, other.electionId) === 0 |
| 187 | : this.electionId === other?.electionId; |
| 188 | |
| 189 | return ( |
| 190 | other != null && |
| 191 | other.iscryptd === this.iscryptd && |
| 192 | errorStrictEqual(this.error, other.error) && |
| 193 | this.type === other.type && |
| 194 | this.minWireVersion === other.minWireVersion && |
| 195 | arrayStrictEqual(this.hosts, other.hosts) && |
| 196 | tagsStrictEqual(this.tags, other.tags) && |
| 197 | this.setName === other.setName && |
| 198 | this.setVersion === other.setVersion && |
| 199 | electionIdsEqual && |
| 200 | this.primary === other.primary && |
| 201 | this.logicalSessionTimeoutMinutes === other.logicalSessionTimeoutMinutes && |
| 202 | topologyVersionsEqual |
| 203 | ); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // Parses a `hello` message and determines the server type |
no test coverage detected