source: imaps-frontend/node_modules/@babel/helper-remap-async-to-generator/lib/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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