MCPcopy
hub / github.com/mongodb/node-mongodb-native / equals

Method equals

src/sdam/server_description.ts:177–204  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 3

compareTopologyVersionFunction · 0.45
serverUpdateHandlerMethod · 0.45
executeOperationFunction · 0.45

Calls 5

compareObjectIdFunction · 0.90
errorStrictEqualFunction · 0.90
arrayStrictEqualFunction · 0.90
compareTopologyVersionFunction · 0.85
tagsStrictEqualFunction · 0.85

Tested by

no test coverage detected