UNPKG

sucrase

Version:

Super-fast alternative to Babel for when you can target modern JS runtimes

31 lines (30 loc) 934 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const options_1 = require("../options"); const statement_1 = require("./statement"); exports.plugins = {}; class Parser extends statement_1.default { constructor(inputOptions, input) { const options = options_1.getOptions(inputOptions); super(options, input); this.options = options; this.input = input; this.plugins = pluginsMap(this.options.plugins); // If enabled, skip leading hashbang line. if (this.state.pos === 0 && this.input[0] === "#" && this.input[1] === "!") { this.skipLineComment(2); } } parse() { this.nextToken(); return this.parseTopLevel(); } } exports.default = Parser; function pluginsMap(pluginList) { const pluginMap = {}; for (const name of pluginList) { pluginMap[name] = true; } return pluginMap; }