source: trip-planner-front/node_modules/babel-plugin-polyfill-corejs3/lib/utils.js@ 188ee53

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

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.callMethod = callMethod;
5exports.isCoreJSSource = isCoreJSSource;
6exports.coreJSModule = coreJSModule;
7exports.coreJSPureHelper = coreJSPureHelper;
8
9var babel = _interopRequireWildcard(require("@babel/core"));
10
11var _entries = _interopRequireDefault(require("../core-js-compat/entries.js"));
12
13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
16
17function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
19const {
20 types: t
21} = babel.default || babel;
22
23function callMethod(path, id) {
24 const {
25 object
26 } = path.node;
27 let context1, context2;
28
29 if (t.isIdentifier(object)) {
30 context1 = object;
31 context2 = t.cloneNode(object);
32 } else {
33 context1 = path.scope.generateDeclaredUidIdentifier("context");
34 context2 = t.assignmentExpression("=", t.cloneNode(context1), object);
35 }
36
37 path.replaceWith(t.memberExpression(t.callExpression(id, [context2]), t.identifier("call")));
38 path.parentPath.unshiftContainer("arguments", context1);
39}
40
41function isCoreJSSource(source) {
42 if (typeof source === "string") {
43 source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
44 }
45
46 return hasOwnProperty.call(_entries.default, source) && _entries.default[source];
47}
48
49function coreJSModule(name) {
50 return `core-js/modules/${name}.js`;
51}
52
53function coreJSPureHelper(name, useBabelRuntime, ext) {
54 return useBabelRuntime ? `${useBabelRuntime}/core-js/${name}${ext}` : `core-js-pure/features/${name}.js`;
55}
Note: See TracBrowser for help on using the repository browser.