UNPKG

1.03 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = _default;
7
8// Copy-pasted from:
9// https://github.com/substack/semver-compare/blob/master/index.js
10//
11// Inlining this function because some users reported issues with
12// importing from `semver-compare` in a browser with ES6 "native" modules.
13//
14// Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
15// https://github.com/catamphetamine/libphonenumber-js/issues/381
16function _default(a, b) {
17 a = a.split('-');
18 b = b.split('-');
19 var pa = a[0].split('.');
20 var pb = b[0].split('.');
21
22 for (var i = 0; i < 3; i++) {
23 var na = Number(pa[i]);
24 var nb = Number(pb[i]);
25 if (na > nb) return 1;
26 if (nb > na) return -1;
27 if (!isNaN(na) && isNaN(nb)) return 1;
28 if (isNaN(na) && !isNaN(nb)) return -1;
29 }
30
31 if (a[1] && b[1]) {
32 return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
33 }
34
35 return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
36}
37//# sourceMappingURL=semver-compare.js.map
\No newline at end of file