UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.transformFromAstAsync = exports.transformFromAstSync = exports.transformFromAst = void 0;
7
8var _config = _interopRequireDefault(require("./config"));
9
10var _transformation = require("./transformation");
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14const gensync = require("gensync");
15
16const 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
23const 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
36exports.transformFromAst = transformFromAst;
37const transformFromAstSync = transformFromAstRunner.sync;
38exports.transformFromAstSync = transformFromAstSync;
39const transformFromAstAsync = transformFromAstRunner.async;
40exports.transformFromAstAsync = transformFromAstAsync;
\No newline at end of file