parse.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 _index = require("./config/index.js");
  16. var _index2 = require("./parser/index.js");
  17. var _normalizeOpts = require("./transformation/normalize-opts.js");
  18. var _rewriteStackTrace = require("./errors/rewrite-stack-trace.js");
  19. const parseRunner = _gensync()(function* parse(code, opts) {
  20. const config = yield* (0, _index.default)(opts);
  21. if (config === null) {
  22. return null;
  23. }
  24. return yield* (0, _index2.default)(config.passes, (0, _normalizeOpts.default)(config), code);
  25. });
  26. const parse = exports.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. function parseSync(...args) {
  39. return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(...args);
  40. }
  41. function parseAsync(...args) {
  42. return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.async)(...args);
  43. }
  44. 0 && 0;
  45. //# sourceMappingURL=parse.js.map