source: trip-planner-front/node_modules/@babel/helper-remap-async-to-generator/lib/index.js

Last change on this file was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 1.8 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _default;
7
8var _helperWrapFunction = require("@babel/helper-wrap-function");
9
10var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
11
12var _t = require("@babel/types");
13
14const {
15 callExpression,
16 cloneNode,
17 isIdentifier,
18 isThisExpression,
19 yieldExpression
20} = _t;
21const awaitVisitor = {
22 Function(path) {
23 path.skip();
24 },
25
26 AwaitExpression(path, {
27 wrapAwait
28 }) {
29 const argument = path.get("argument");
30 path.replaceWith(yieldExpression(wrapAwait ? callExpression(cloneNode(wrapAwait), [argument.node]) : argument.node));
31 }
32
33};
34
35function _default(path, helpers, noNewArrows) {
36 path.traverse(awaitVisitor, {
37 wrapAwait: helpers.wrapAwait
38 });
39 const isIIFE = checkIsIIFE(path);
40 path.node.async = false;
41 path.node.generator = true;
42 (0, _helperWrapFunction.default)(path, cloneNode(helpers.wrapAsync), noNewArrows);
43 const isProperty = path.isObjectMethod() || path.isClassMethod() || path.parentPath.isObjectProperty() || path.parentPath.isClassProperty();
44
45 if (!isProperty && !isIIFE && path.isExpression()) {
46 (0, _helperAnnotateAsPure.default)(path);
47 }
48
49 function checkIsIIFE(path) {
50 if (path.parentPath.isCallExpression({
51 callee: path.node
52 })) {
53 return true;
54 }
55
56 const {
57 parentPath
58 } = path;
59
60 if (parentPath.isMemberExpression() && isIdentifier(parentPath.node.property, {
61 name: "bind"
62 })) {
63 const {
64 parentPath: bindCall
65 } = parentPath;
66 return bindCall.isCallExpression() && bindCall.node.arguments.length === 1 && isThisExpression(bindCall.node.arguments[0]) && bindCall.parentPath.isCallExpression({
67 callee: bindCall.node
68 });
69 }
70
71 return false;
72 }
73}
Note: See TracBrowser for help on using the repository browser.