1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.transformFromAstAsync = exports.transformFromAstSync = exports.transformFromAst = void 0;
|
7 |
|
8 | var _config = _interopRequireDefault(require("./config"));
|
9 |
|
10 | var _transformation = require("./transformation");
|
11 |
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 |
|
14 | const gensync = require("gensync");
|
15 |
|
16 | const transformFromAstRunner = gensync(function* (ast, code, opts) {
|
17 | const config = yield* (0, _config.default)(opts);
|
18 | if (config === null) return null;
|
19 | if (!ast) throw new Error("No AST given");
|
20 | return yield* (0, _transformation.run)(config, code, ast);
|
21 | });
|
22 |
|
23 | const transformFromAst = function transformFromAst(ast, code, opts, callback) {
|
24 | if (typeof opts === "function") {
|
25 | callback = opts;
|
26 | opts = undefined;
|
27 | }
|
28 |
|
29 | if (callback === undefined) {
|
30 | return transformFromAstRunner.sync(ast, code, opts);
|
31 | }
|
32 |
|
33 | transformFromAstRunner.errback(ast, code, opts, callback);
|
34 | };
|
35 |
|
36 | exports.transformFromAst = transformFromAst;
|
37 | const transformFromAstSync = transformFromAstRunner.sync;
|
38 | exports.transformFromAstSync = transformFromAstSync;
|
39 | const transformFromAstAsync = transformFromAstRunner.async;
|
40 | exports.transformFromAstAsync = transformFromAstAsync; |
\ | No newline at end of file |