MCPcopy
hub / github.com/npm/node-semver / comparePre

Method comparePre

classes/semver.js:151–182  ·  view source on GitHub ↗
(other)

Source from the content-addressed store, hash-verified

149 }
150
151 comparePre (other) {
152 if (!(other instanceof SemVer)) {
153 other = new SemVer(other, this.options)
154 }
155
156 // NOT having a prerelease is > having one
157 if (this.prerelease.length && !other.prerelease.length) {
158 return -1
159 } else if (!this.prerelease.length && other.prerelease.length) {
160 return 1
161 } else if (!this.prerelease.length && !other.prerelease.length) {
162 return 0
163 }
164
165 let i = 0
166 do {
167 const a = this.prerelease[i]
168 const b = other.prerelease[i]
169 debug('prerelease compare', i, a, b)
170 if (a === undefined && b === undefined) {
171 return 0
172 } else if (b === undefined) {
173 return 1
174 } else if (a === undefined) {
175 return -1
176 } else if (a === b) {
177 continue
178 } else {
179 return compareIdentifiers(a, b)
180 }
181 } while (++i)
182 }
183
184 compareBuild (other) {
185 if (!(other instanceof SemVer)) {

Callers 2

compareMethod · 0.95
semver.jsFile · 0.80

Calls 1

compareIdentifiersFunction · 0.85

Tested by

no test coverage detected