transform.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.transform = void 0;
  6. exports.transformAsync = transformAsync;
  7. exports.transformSync = transformSync;
  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 transformRunner = _gensync()(function* transform(code, opts) {
  19. const config = yield* (0, _index.default)(opts);
  20. if (config === null) return null;
  21. return yield* (0, _index2.run)(config, code);
  22. });
  23. const transform = exports.transform = function transform(code, optsOrCallback, maybeCallback) {
  24. let opts;
  25. let callback;
  26. if (typeof optsOrCallback === "function") {
  27. callback = optsOrCallback;
  28. opts = undefined;
  29. } else {
  30. opts = optsOrCallback;
  31. callback = maybeCallback;
  32. }
  33. if (callback === undefined) {
  34. {
  35. return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(code, opts);
  36. }
  37. }
  38. (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.errback)(code, opts, callback);
  39. };
  40. function transformSync(...args) {
  41. return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(...args);
  42. }
  43. function transformAsync(...args) {
  44. return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.async)(...args);
  45. }
  46. 0 && 0;
  47. //# sourceMappingURL=transform.js.map