source: node_modules/semver/internal/identifiers.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 410 bytes
Line 
1const numeric = /^[0-9]+$/
2const compareIdentifiers = (a, b) => {
3 const anum = numeric.test(a)
4 const bnum = numeric.test(b)
5
6 if (anum && bnum) {
7 a = +a
8 b = +b
9 }
10
11 return a === b ? 0
12 : (anum && !bnum) ? -1
13 : (bnum && !anum) ? 1
14 : a < b ? -1
15 : 1
16}
17
18const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
19
20module.exports = {
21 compareIdentifiers,
22 rcompareIdentifiers,
23}
Note: See TracBrowser for help on using the repository browser.