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