* 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)
| 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. |
nothing calls this directly
no test coverage detected