File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -107,15 +107,30 @@ class SemVer {
107
107
}
108
108
109
109
compareMain ( other ) {
110
+ // XXX compare already did this
110
111
if ( ! ( other instanceof SemVer ) ) {
111
112
other = new SemVer ( other , this . options )
112
113
}
113
114
114
- return (
115
- compareIdentifiers ( this . major , other . major ) ||
116
- compareIdentifiers ( this . minor , other . minor ) ||
117
- compareIdentifiers ( this . patch , other . patch )
118
- )
115
+ if ( this . major < other . major ) {
116
+ return - 1
117
+ }
118
+ if ( this . major > other . major ) {
119
+ return 1
120
+ }
121
+ if ( this . minor < other . minor ) {
122
+ return - 1
123
+ }
124
+ if ( this . minor > other . minor ) {
125
+ return 1
126
+ }
127
+ if ( this . patch < other . patch ) {
128
+ return - 1
129
+ }
130
+ if ( this . patch > other . patch ) {
131
+ return 1
132
+ }
133
+ return 0
119
134
}
120
135
121
136
comparePre ( other ) {
Original file line number Diff line number Diff line change 2
2
3
3
const numeric = / ^ [ 0 - 9 ] + $ /
4
4
const compareIdentifiers = ( a , b ) => {
5
- if ( typeof a === 'number' && typeof b === 'number' ) {
6
- return a === b ? 0 : a < b ? - 1 : 1
7
- }
8
-
9
5
const anum = numeric . test ( a )
10
6
const bnum = numeric . test ( b )
11
7
You can’t perform that action at this time.
0 commit comments