UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.transformAsync = exports.transformSync = exports.transform = 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 transformRunner = gensync(function* transform(code, opts) {
17 const config = yield* (0, _config.default)(opts);
18 if (config === null) return null;
19 return yield* (0, _transformation.run)(config, code);
20});
21
22const transform = function transform(code, opts, callback) {
23 if (typeof opts === "function") {
24 callback = opts;
25 opts = undefined;
26 }
27
28 if (callback === undefined) return transformRunner.sync(code, opts);
29 transformRunner.errback(code, opts, callback);
30};
31
32exports.transform = transform;
33const transformSync = transformRunner.sync;
34exports.transformSync = transformSync;
35const transformAsync = transformRunner.async;
36exports.transformAsync = transformAsync;
\No newline at end of file