.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / semver / internal / identifiers.js
1 const numeric = /^[0-9]+$/
2 const 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
18 const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
19
20 module.exports = {
21   compareIdentifiers,
22   rcompareIdentifiers
23 }