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