source: trip-planner-front/node_modules/@babel/helper-compilation-targets/lib/utils.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.semverMin = semverMin;
7exports.semverify = semverify;
8exports.isUnreleasedVersion = isUnreleasedVersion;
9exports.getLowestUnreleased = getLowestUnreleased;
10exports.getHighestUnreleased = getHighestUnreleased;
11exports.getLowestImplementedVersion = getLowestImplementedVersion;
12
13var _semver = require("semver");
14
15var _helperValidatorOption = require("@babel/helper-validator-option");
16
17var _targets = require("./targets");
18
19const versionRegExp = /^(\d+|\d+.\d+)$/;
20const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
21
22function semverMin(first, second) {
23 return first && _semver.lt(first, second) ? first : second;
24}
25
26function semverify(version) {
27 if (typeof version === "string" && _semver.valid(version)) {
28 return version;
29 }
30
31 v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
32 const split = version.toString().split(".");
33
34 while (split.length < 3) {
35 split.push("0");
36 }
37
38 return split.join(".");
39}
40
41function isUnreleasedVersion(version, env) {
42 const unreleasedLabel = _targets.unreleasedLabels[env];
43 return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
44}
45
46function getLowestUnreleased(a, b, env) {
47 const unreleasedLabel = _targets.unreleasedLabels[env];
48 const hasUnreleased = [a, b].some(item => item === unreleasedLabel);
49
50 if (hasUnreleased) {
51 return a === hasUnreleased ? b : a || b;
52 }
53
54 return semverMin(a, b);
55}
56
57function getHighestUnreleased(a, b, env) {
58 return getLowestUnreleased(a, b, env) === a ? b : a;
59}
60
61function getLowestImplementedVersion(plugin, environment) {
62 const result = plugin[environment];
63
64 if (!result && environment === "android") {
65 return plugin.chrome;
66 }
67
68 return result;
69}
Note: See TracBrowser for help on using the repository browser.