source: trip-planner-front/node_modules/babel-plugin-polyfill-corejs2/lib/helpers.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.hasMinVersion = hasMinVersion;
5
6var _semver = _interopRequireDefault(require("semver"));
7
8function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
10function hasMinVersion(minVersion, runtimeVersion) {
11 // If the range is unavailable, we're running the script during Babel's
12 // build process, and we want to assume that all versions are satisfied so
13 // that the built output will include all definitions.
14 if (!runtimeVersion || !minVersion) return true; // semver.intersects() has some surprising behavior with comparing ranges
15 // with preprelease versions. We add '^' to ensure that we are always
16 // comparing ranges with ranges, which sidesteps this logic.
17 // For example:
18 //
19 // semver.intersects(`<7.0.1`, "7.0.0-beta.0") // false - surprising
20 // semver.intersects(`<7.0.1`, "^7.0.0-beta.0") // true - expected
21 //
22 // This is because the first falls back to
23 //
24 // semver.satisfies("7.0.0-beta.0", `<7.0.1`) // false - surprising
25 //
26 // and this fails because a prerelease version can only satisfy a range
27 // if it is a prerelease within the same major/minor/patch range.
28 //
29 // Note: If this is found to have issues, please also revist the logic in
30 // babel-core's availableHelper() API.
31
32 if (_semver.default.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
33 return !_semver.default.intersects(`<${minVersion}`, runtimeVersion) && !_semver.default.intersects(`>=8.0.0`, runtimeVersion);
34}
Note: See TracBrowser for help on using the repository browser.