parse.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.parse = void 0;
  6. exports.parseAsync = parseAsync;
  7. exports.parseSync = parseSync;
  8. function _gensync() {
  9. const data = require("gensync");
  10. _gensync = function () {
  11. return data;
  12. };
  13. return data;
  14. }
  15. var _config = require("./config");
  16. var _parser = require("./parser");
  17. var _normalizeOpts = require("./transformation/normalize-opts");
  18. var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
  19. const parseRunner = _gensync()(function* parse(code, opts) {
  20. const config = yield* (0, _config.default)(opts);
  21. if (config === null) {
  22. return null;
  23. }
  24. return yield* (0, _parser.default)(config.passes, (0, _normalizeOpts.default)(config), code);
  25. });
  26. const parse = function parse(code, opts, callback) {
  27. if (typeof opts === "function") {
  28. callback = opts;
  29. opts = undefined;
  30. }
  31. if (callback === undefined) {
  32. {
  33. return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(code, opts);
  34. }
  35. }
  36. (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.errback)(code, opts, callback);
  37. };
  38. exports.parse = parse;
  39. function parseSync(...args) {
  40. return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(...args);
  41. }
  42. function parseAsync(...args) {
  43. return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.async)(...args);
  44. }
  45. 0 && 0;
  46. //# sourceMappingURL=parse.js.map