[79a0317] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = void 0;
|
---|
| 7 | var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
---|
| 8 | var _helperRemapAsyncToGenerator = require("@babel/helper-remap-async-to-generator");
|
---|
| 9 | var _helperModuleImports = require("@babel/helper-module-imports");
|
---|
| 10 | var _core = require("@babel/core");
|
---|
| 11 | var _default = exports.default = (0, _helperPluginUtils.declare)((api, options) => {
|
---|
| 12 | var _api$assumption, _api$assumption2;
|
---|
| 13 | api.assertVersion("^7.0.0-0 || >8.0.0-alpha <8.0.0-beta");
|
---|
| 14 | const {
|
---|
| 15 | method,
|
---|
| 16 | module
|
---|
| 17 | } = options;
|
---|
| 18 | const noNewArrows = (_api$assumption = api.assumption("noNewArrows")) != null ? _api$assumption : true;
|
---|
| 19 | const ignoreFunctionLength = (_api$assumption2 = api.assumption("ignoreFunctionLength")) != null ? _api$assumption2 : false;
|
---|
| 20 | if (method && module) {
|
---|
| 21 | return {
|
---|
| 22 | name: "transform-async-to-generator",
|
---|
| 23 | visitor: {
|
---|
| 24 | Function(path, state) {
|
---|
| 25 | if (!path.node.async || path.node.generator) return;
|
---|
| 26 | let wrapAsync = state.methodWrapper;
|
---|
| 27 | if (wrapAsync) {
|
---|
| 28 | wrapAsync = _core.types.cloneNode(wrapAsync);
|
---|
| 29 | } else {
|
---|
| 30 | wrapAsync = state.methodWrapper = (0, _helperModuleImports.addNamed)(path, method, module);
|
---|
| 31 | }
|
---|
| 32 | (0, _helperRemapAsyncToGenerator.default)(path, {
|
---|
| 33 | wrapAsync
|
---|
| 34 | }, noNewArrows, ignoreFunctionLength);
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 | };
|
---|
| 38 | }
|
---|
| 39 | return {
|
---|
| 40 | name: "transform-async-to-generator",
|
---|
| 41 | visitor: {
|
---|
| 42 | Function(path, state) {
|
---|
| 43 | if (!path.node.async || path.node.generator) return;
|
---|
| 44 | (0, _helperRemapAsyncToGenerator.default)(path, {
|
---|
| 45 | wrapAsync: state.addHelper("asyncToGenerator")
|
---|
| 46 | }, noNewArrows, ignoreFunctionLength);
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 | };
|
---|
| 50 | });
|
---|
| 51 |
|
---|
| 52 | //# sourceMappingURL=index.js.map
|
---|