UNPKG

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