1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.parseAsync = exports.parseSync = exports.parse = void 0;
|
7 |
|
8 | var _config = _interopRequireDefault(require("./config"));
|
9 |
|
10 | var _parser = _interopRequireDefault(require("./parser"));
|
11 |
|
12 | var _normalizeOpts = _interopRequireDefault(require("./transformation/normalize-opts"));
|
13 |
|
14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15 |
|
16 | const gensync = require("gensync");
|
17 |
|
18 | const parseRunner = gensync(function* parse(code, opts) {
|
19 | const config = yield* (0, _config.default)(opts);
|
20 |
|
21 | if (config === null) {
|
22 | return null;
|
23 | }
|
24 |
|
25 | return yield* (0, _parser.default)(config.passes, (0, _normalizeOpts.default)(config), code);
|
26 | });
|
27 |
|
28 | const parse = function parse(code, opts, callback) {
|
29 | if (typeof opts === "function") {
|
30 | callback = opts;
|
31 | opts = undefined;
|
32 | }
|
33 |
|
34 | if (callback === undefined) return parseRunner.sync(code, opts);
|
35 | parseRunner.errback(code, opts, callback);
|
36 | };
|
37 |
|
38 | exports.parse = parse;
|
39 | const parseSync = parseRunner.sync;
|
40 | exports.parseSync = parseSync;
|
41 | const parseAsync = parseRunner.async;
|
42 | exports.parseAsync = parseAsync; |
\ | No newline at end of file |