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

Function compareIdentifiers

internal/identifiers.js:4–22  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

2
3const numeric = /^[0-9]+$/
4const compareIdentifiers = (a, b) => {
5 if (typeof a === 'number' && typeof b === 'number') {
6 return a === b ? 0 : a < b ? -1 : 1
7 }
8
9 const anum = numeric.test(a)
10 const bnum = numeric.test(b)
11
12 if (anum && bnum) {
13 a = +a
14 b = +b
15 }
16
17 return a === b ? 0
18 : (anum && !bnum) ? -1
19 : (bnum && !anum) ? 1
20 : a < b ? -1
21 : 1
22}
23
24const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
25

Callers 5

isPrereleaseIdentifierFunction · 0.85
comparePreMethod · 0.85
compareBuildMethod · 0.85
identifiers.jsFile · 0.85
rcompareIdentifiersFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected