aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/helper-compilation-targets/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/helper-compilation-targets/lib/utils.js')
-rw-r--r--node_modules/@babel/helper-compilation-targets/lib/utils.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/node_modules/@babel/helper-compilation-targets/lib/utils.js b/node_modules/@babel/helper-compilation-targets/lib/utils.js
new file mode 100644
index 0000000..711a84f
--- /dev/null
+++ b/node_modules/@babel/helper-compilation-targets/lib/utils.js
@@ -0,0 +1,69 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.getHighestUnreleased = getHighestUnreleased;
+exports.getLowestImplementedVersion = getLowestImplementedVersion;
+exports.getLowestUnreleased = getLowestUnreleased;
+exports.isUnreleasedVersion = isUnreleasedVersion;
+exports.semverMin = semverMin;
+exports.semverify = semverify;
+
+var _semver = require("semver");
+
+var _helperValidatorOption = require("@babel/helper-validator-option");
+
+var _targets = require("./targets");
+
+const versionRegExp = /^(\d+|\d+.\d+)$/;
+const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
+
+function semverMin(first, second) {
+ return first && _semver.lt(first, second) ? first : second;
+}
+
+function semverify(version) {
+ if (typeof version === "string" && _semver.valid(version)) {
+ return version;
+ }
+
+ v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
+ const split = version.toString().split(".");
+
+ while (split.length < 3) {
+ split.push("0");
+ }
+
+ return split.join(".");
+}
+
+function isUnreleasedVersion(version, env) {
+ const unreleasedLabel = _targets.unreleasedLabels[env];
+ return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
+}
+
+function getLowestUnreleased(a, b, env) {
+ const unreleasedLabel = _targets.unreleasedLabels[env];
+ const hasUnreleased = [a, b].some(item => item === unreleasedLabel);
+
+ if (hasUnreleased) {
+ return a === hasUnreleased ? b : a || b;
+ }
+
+ return semverMin(a, b);
+}
+
+function getHighestUnreleased(a, b, env) {
+ return getLowestUnreleased(a, b, env) === a ? b : a;
+}
+
+function getLowestImplementedVersion(plugin, environment) {
+ const result = plugin[environment];
+
+ if (!result && environment === "android") {
+ return plugin.chrome;
+ }
+
+ return result;
+} \ No newline at end of file