transform-ast.js 1.6 KB

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