2020-01-28 13:08:03 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
2020-03-22 05:13:25 +08:00
|
|
|
exports.parseAsync = exports.parseSync = exports.parse = void 0;
|
|
|
|
|
|
|
|
function _gensync() {
|
|
|
|
const data = _interopRequireDefault(require("gensync"));
|
|
|
|
|
|
|
|
_gensync = function () {
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
2020-01-28 13:08:03 +08:00
|
|
|
|
|
|
|
var _config = _interopRequireDefault(require("./config"));
|
|
|
|
|
2020-03-22 05:13:25 +08:00
|
|
|
var _parser = _interopRequireDefault(require("./parser"));
|
2020-01-28 13:08:03 +08:00
|
|
|
|
|
|
|
var _normalizeOpts = _interopRequireDefault(require("./transformation/normalize-opts"));
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
2020-03-22 05:13:25 +08:00
|
|
|
const parseRunner = (0, _gensync().default)(function* parse(code, opts) {
|
|
|
|
const config = yield* (0, _config.default)(opts);
|
2020-01-28 13:08:03 +08:00
|
|
|
|
|
|
|
if (config === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-03-22 05:13:25 +08:00
|
|
|
return yield* (0, _parser.default)(config.passes, (0, _normalizeOpts.default)(config), code);
|
|
|
|
});
|
2020-01-28 13:08:03 +08:00
|
|
|
|
2020-03-22 05:13:25 +08:00
|
|
|
const parse = function parse(code, opts, callback) {
|
|
|
|
if (typeof opts === "function") {
|
|
|
|
callback = opts;
|
|
|
|
opts = undefined;
|
|
|
|
}
|
2020-01-28 13:08:03 +08:00
|
|
|
|
2020-03-22 05:13:25 +08:00
|
|
|
if (callback === undefined) return parseRunner.sync(code, opts);
|
|
|
|
parseRunner.errback(code, opts, callback);
|
2020-01-28 13:08:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.parse = parse;
|
2020-03-22 05:13:25 +08:00
|
|
|
const parseSync = parseRunner.sync;
|
|
|
|
exports.parseSync = parseSync;
|
|
|
|
const parseAsync = parseRunner.async;
|
|
|
|
exports.parseAsync = parseAsync;
|