source: frontend/node_modules/semver/internal/identifiers.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 525 bytes
Line 
1'use strict'
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
26module.exports = {
27 compareIdentifiers,
28 rcompareIdentifiers,
29}
Note: See TracBrowser for help on using the repository browser.