(other: RankLike)
| 83 | } |
| 84 | |
| 85 | between(other: RankLike): RankLike { |
| 86 | const otherValue = decodeAlphaRank(other.toString()); |
| 87 | if (otherValue === null) { |
| 88 | throw new Error("Cannot generate alpha midpoint against a non-alpha rank"); |
| 89 | } |
| 90 | const lower = Math.min(this.value, otherValue); |
| 91 | const upper = Math.max(this.value, otherValue); |
| 92 | const midpoint = Math.floor((lower + upper) / 2); |
| 93 | if (midpoint <= lower || midpoint >= upper) { |
| 94 | throw new Error("No alpha rank gap available"); |
| 95 | } |
| 96 | return new AlphaRank(midpoint); |
| 97 | } |
| 98 | |
| 99 | isMax(): boolean { |
| 100 | return this.value >= ALPHA_RANK_MAX; |
no test coverage detected