UNPKG

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