UNPKG

sucrase

Version:

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

28 lines (27 loc) 836 B
import { getOptions } from "../options"; import StatementParser from "./statement"; export const plugins = {}; export default class Parser extends StatementParser { constructor(inputOptions, input) { const options = 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(); } } function pluginsMap(pluginList) { const pluginMap = {}; for (const name of pluginList) { pluginMap[name] = true; } return pluginMap; }