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 {
107107 }
108108
109109 compareMain ( other ) {
110+ // XXX compare already did this
110111 if ( ! ( other instanceof SemVer ) ) {
111112 other = new SemVer ( other , this . options )
112113 }
113114
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
119134 }
120135
121136 comparePre ( other ) {
Original file line number Diff line number Diff line change 22
33const numeric = / ^ [ 0 - 9 ] + $ /
44const compareIdentifiers = ( a , b ) => {
5- if ( typeof a === 'number' && typeof b === 'number' ) {
6- return a === b ? 0 : a < b ? - 1 : 1
7- }
8-
95 const anum = numeric . test ( a )
106 const bnum = numeric . test ( b )
117
You can’t perform that action at this time.
0 commit comments