Skip to content

Commit 11702f0

Browse files
committed
fix: fast path when main version are num
1 parent b933963 commit 11702f0

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

classes/semver.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,25 @@ class SemVer {
111111
other = new SemVer(other, this.options)
112112
}
113113

114-
return (
115-
compareIdentifiers(this.major, other.major) ||
116-
compareIdentifiers(this.minor, other.minor) ||
117-
compareIdentifiers(this.patch, other.patch)
118-
)
114+
if (this.major < other.major) {
115+
return -1
116+
}
117+
if (this.major > other.major) {
118+
return 1
119+
}
120+
if (this.minor < other.minor) {
121+
return -1
122+
}
123+
if (this.minor > other.minor) {
124+
return 1
125+
}
126+
if (this.patch < other.patch) {
127+
return -1
128+
}
129+
if (this.patch > other.patch) {
130+
return 1
131+
}
132+
return 0
119133
}
120134

121135
comparePre (other) {

0 commit comments

Comments
 (0)