You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/@babel/helper-remap-async-to-gener.../lib/index.js.map

1 line
5.2 KiB

{"version":3,"names":["_helperWrapFunction","require","_helperAnnotateAsPure","_core","_traverse","callExpression","cloneNode","isIdentifier","isThisExpression","yieldExpression","t","awaitVisitor","visitors","environmentVisitor","ArrowFunctionExpression","path","skip","AwaitExpression","wrapAwait","argument","get","replaceWith","node","_default","helpers","noNewArrows","ignoreFunctionLength","traverse","isIIFE","checkIsIIFE","async","generator","wrapFunction","wrapAsync","isProperty","isObjectMethod","isClassMethod","parentPath","isObjectProperty","isClassProperty","isExpression","annotateAsPure","isCallExpression","callee","isMemberExpression","property","name","bindCall","arguments","length"],"sources":["../src/index.ts"],"sourcesContent":["/* @noflow */\n\nimport type { NodePath } from \"@babel/core\";\nimport wrapFunction from \"@babel/helper-wrap-function\";\nimport annotateAsPure from \"@babel/helper-annotate-as-pure\";\nimport { types as t } from \"@babel/core\";\nimport { visitors } from \"@babel/traverse\";\nconst {\n callExpression,\n cloneNode,\n isIdentifier,\n isThisExpression,\n yieldExpression,\n} = t;\n\nconst awaitVisitor = visitors.environmentVisitor<{ wrapAwait: t.Expression }>({\n ArrowFunctionExpression(path) {\n path.skip();\n },\n\n AwaitExpression(path, { wrapAwait }) {\n const argument = path.get(\"argument\");\n\n path.replaceWith(\n yieldExpression(\n wrapAwait\n ? callExpression(cloneNode(wrapAwait), [argument.node])\n : argument.node,\n ),\n );\n },\n});\n\nexport default function (\n path: NodePath<t.Function>,\n helpers: {\n wrapAsync: t.Expression;\n wrapAwait?: t.Expression;\n },\n noNewArrows?: boolean,\n ignoreFunctionLength?: boolean,\n) {\n path.traverse(awaitVisitor, {\n wrapAwait: helpers.wrapAwait,\n });\n\n const isIIFE = checkIsIIFE(path);\n\n path.node.async = false;\n path.node.generator = true;\n\n wrapFunction(\n path,\n cloneNode(helpers.wrapAsync),\n noNewArrows,\n ignoreFunctionLength,\n );\n\n const isProperty =\n path.isObjectMethod() ||\n path.isClassMethod() ||\n path.parentPath.isObjectProperty() ||\n path.parentPath.isClassProperty();\n\n if (!isProperty && !isIIFE && path.isExpression()) {\n annotateAsPure(path);\n }\n\n function checkIsIIFE(path: NodePath) {\n if (path.parentPath.isCallExpression({ callee: path.node })) {\n return true;\n }\n\n // try to catch calls to Function#bind, as emitted by arrowFunctionToExpression in spec mode\n // this may also catch .bind(this) written by users, but does it matter? 🤔\n const { parentPath } = path;\n if (\n parentPath.isMemberExpression() &&\n isIdentifier(parentPath.node.property, { name: \"bind\" })\n ) {\n const { parentPath: bindCall } = parentPath;\n\n // (function () { ... }).bind(this)()\n\n return (\n // first, check if the .bind is actually being called\n bindCall.isCallExpression() &&\n // and whether its sole argument is 'this'\n bindCall.node.arguments.length === 1 &&\n isThisExpression(bindCall.node.arguments[0]) &&\n // and whether the result of the .bind(this) is being called\n bindCall.parentPath.isCallExpression({ callee: bindCall.node })\n );\n }\n\n return false;\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,MAAM;EACJI,cAAc;EACdC,SAAS;EACTC,YAAY;EACZC,gBAAgB;EAChBC;AACF,CAAC,GAAGC,WAAC;AAEL,MAAMC,YAAY,GAAGC,kBAAQ,CAACC,kBAAkB,CAA8B;EAC5EC,uBAAuBA,CAACC,IAAI,EAAE;IAC5BA,IAAI,CAACC,IAAI,CAAC,CAAC;EACb,CAAC;EAEDC,eAAeA,CAACF,IAAI,EAAE;IAAEG;EAAU,CAAC,EAAE;IACnC,MAAMC,QAAQ,GAAGJ,IAAI,CAACK,GAAG,CAAC,UAAU,CAAC;IAErCL,IAAI,CAACM,WAAW,CACdZ,eAAe,CACbS,SAAS,GACLb,cAAc,CAACC,SAAS,CAACY,SAAS,CAAC,EAAE,CAACC,QAAQ,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