@@ -107,32 +107,31 @@ class Comparator {
107107 return false
108108 }
109109
110- const sameDirectionIncreasing =
111- ( this . operator === '>=' || this . operator === '>' ) &&
112- ( comp . operator === '>=' || comp . operator === '>' )
113- const sameDirectionDecreasing =
114- ( this . operator === '<=' || this . operator === '<' ) &&
115- ( comp . operator === '<=' || comp . operator === '<' )
116- const sameSemVer = this . semver . version === comp . semver . version
117- const differentDirectionsInclusive =
118- ( this . operator === '>=' || this . operator === '<=' ) &&
119- ( comp . operator === '>=' || comp . operator === '<=' )
120- const oppositeDirectionsLessThan =
121- cmp ( this . semver , '<' , comp . semver , options ) &&
122- ( this . operator === '>=' || this . operator === '>' ) &&
123- ( comp . operator === '<=' || comp . operator === '<' )
124- const oppositeDirectionsGreaterThan =
125- cmp ( this . semver , '>' , comp . semver , options ) &&
126- ( this . operator === '<=' || this . operator === '<' ) &&
127- ( comp . operator === '>=' || comp . operator === '>' )
128-
129- return (
130- sameDirectionIncreasing ||
131- sameDirectionDecreasing ||
132- ( sameSemVer && differentDirectionsInclusive ) ||
133- oppositeDirectionsLessThan ||
134- oppositeDirectionsGreaterThan
135- )
110+ // Same direction increasing (> or >=)
111+ if ( this . operator . startsWith ( '>' ) && comp . operator . startsWith ( '>' ) ) {
112+ return true
113+ }
114+ // Same direction decreasing (< or <=)
115+ if ( this . operator . startsWith ( '<' ) && comp . operator . startsWith ( '<' ) ) {
116+ return true
117+ }
118+ // same SemVer and both sides are inclusive (<= or >=)
119+ if (
120+ ( this . semver . version === comp . semver . version ) &&
121+ this . operator . includes ( '=' ) && comp . operator . includes ( '=' ) ) {
122+ return true
123+ }
124+ // opposite directions less than
125+ if ( cmp ( this . semver , '<' , comp . semver , options ) &&
126+ this . operator . startsWith ( '>' ) && comp . operator . startsWith ( '<' ) ) {
127+ return true
128+ }
129+ // opposite directions greater than
130+ if ( cmp ( this . semver , '>' , comp . semver , options ) &&
131+ this . operator . startsWith ( '<' ) && comp . operator . startsWith ( '>' ) ) {
132+ return true
133+ }
134+ return false
136135 }
137136}
138137
0 commit comments