@@ -90,6 +90,8 @@ class Comparator {
90
90
return new Range ( this . value , options ) . test ( comp . semver )
91
91
}
92
92
93
+ options = parseOptions ( options )
94
+
93
95
// Special cases where nothing can possibly be lower
94
96
if ( options . includePrerelease &&
95
97
( this . value === '<0.0.0-0' || comp . value === '<0.0.0-0' ) ) {
@@ -100,32 +102,31 @@ class Comparator {
100
102
return false
101
103
}
102
104
103
- const sameDirectionIncreasing =
104
- ( this . operator === '>=' || this . operator === '>' ) &&
105
- ( comp . operator === '>=' || comp . operator === '>' )
106
- const sameDirectionDecreasing =
107
- ( this . operator === '<=' || this . operator === '<' ) &&
108
- ( comp . operator === '<=' || comp . operator === '<' )
109
- const sameSemVer = this . semver . version === comp . semver . version
110
- const differentDirectionsInclusive =
111
- ( this . operator === '>=' || this . operator === '<=' ) &&
112
- ( comp . operator === '>=' || comp . operator === '<=' )
113
- const oppositeDirectionsLessThan =
114
- cmp ( this . semver , '<' , comp . semver , options ) &&
115
- ( this . operator === '>=' || this . operator === '>' ) &&
116
- ( comp . operator === '<=' || comp . operator === '<' )
117
- const oppositeDirectionsGreaterThan =
118
- cmp ( this . semver , '>' , comp . semver , options ) &&
119
- ( this . operator === '<=' || this . operator === '<' ) &&
120
- ( comp . operator === '>=' || comp . operator === '>' )
121
-
122
- return (
123
- sameDirectionIncreasing ||
124
- sameDirectionDecreasing ||
125
- ( sameSemVer && differentDirectionsInclusive ) ||
126
- oppositeDirectionsLessThan ||
127
- oppositeDirectionsGreaterThan
128
- )
105
+ // Same direction increasing (> or >=)
106
+ if ( this . operator . startsWith ( '>' ) && comp . operator . startsWith ( '>' ) ) {
107
+ return true
108
+ }
109
+ // Same direction decreasing (< or <=)
110
+ if ( this . operator . startsWith ( '<' ) && comp . operator . startsWith ( '<' ) ) {
111
+ return true
112
+ }
113
+ // same SemVer and both sides are inclusive (<= or >=)
114
+ if (
115
+ ( this . semver . version === comp . semver . version ) &&
116
+ this . operator . includes ( '=' ) && comp . operator . includes ( '=' ) ) {
117
+ return true
118
+ }
119
+ // opposite directions less than
120
+ if ( cmp ( this . semver , '<' , comp . semver , options ) &&
121
+ this . operator . startsWith ( '>' ) && comp . operator . startsWith ( '<' ) ) {
122
+ return true
123
+ }
124
+ // opposite directions greater than
125
+ if ( cmp ( this . semver , '>' , comp . semver , options ) &&
126
+ this . operator . startsWith ( '<' ) && comp . operator . startsWith ( '>' ) ) {
127
+ return true
128
+ }
129
+ return false
129
130
}
130
131
}
131
132
0 commit comments