MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / contains

Method contains

lib/token.js:226–247  ·  view source on GitHub ↗

* Whether this range contains a given Token. * * @param {*} token Token to check for. * @returns {boolean} Whether or not the Token is in this range.

(token)

Source from the content-addressed store, hash-verified

224 * @returns {boolean} Whether or not the Token is in this range.
225 */
226 contains(token) {
227 if (this.isEmpty()) {
228 return false;
229 }
230 const minToken = this._tokenizer.minToken();
231 if (this.end.equals(minToken)) {
232 if (this.start.equals(minToken)) {
233 return true; // ]minToken, minToken] === full ring
234 } else if (token.equals(minToken)) {
235 return true;
236 }
237 return token.compare(this.start) > 0;
238 }
239
240 const isAfterStart = token.compare(this.start) > 0;
241 const isBeforeEnd = token.compare(this.end) <= 0;
242 // if wrapped around ring, token is in ring if its after start or before end.
243 // otherwise, token is in ring if its after start and before end.
244 return this.isWrappedAround()
245 ? isAfterStart || isBeforeEnd
246 : isAfterStart && isBeforeEnd;
247 }
248
249 /**
250 * Determines if the input range is equivalent to this one.

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.95
isWrappedAroundMethod · 0.95
equalsMethod · 0.65
compareMethod · 0.65
minTokenMethod · 0.45

Tested by

no test coverage detected