UNPKG

siphon-cli

Version:

Simple bundler for web applications. 📦🔧🧡

89 lines (88 loc) • 3.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var types_1 = require("../../../../types"); var utils_1 = require("../../../../utils"); var base_1 = require("./base"); base_1.ezra.spreadElement = function () { var spread = new types_1.SpreadElement(this.i - 3); spread.argument = this.expression(); spread.loc.end = spread.argument.loc.end; this.eat(","); return spread; }; base_1.ezra.restElement = function () { var rest = new types_1.RestElement(this.i - 3); rest.argument = this.expression(); rest.loc.end = rest.argument.loc.end; if (this.contexts.top() === "parameters" && this.text[this.i] !== ")") { this.raise("JS_REST_MUST_END"); } return rest; }; base_1.ezra.property = function () { var _a; if (this.eat("...")) return this.spreadElement(); var prop = new types_1.Property(this.i); if ((0, utils_1.isDigit)(this.text[this.i]) || !(0, utils_1.isValidIdentifierCharacter)(this.text[this.i])) { if (!(0, types_1.isValidPropertyKeyStart)(this.text[this.i])) this.raise("JS_PROPERTY_DEC_EXPECTED"); if (this.eat("[")) { prop.key = this.group("property"); prop.computed = true; } if ((0, utils_1.isDigit)(this.text[this.i])) { prop.key = this.numberLiteral(); } if (/'|"/.test(this.text[this.i])) { prop.key = this.stringLiteral(); } this.outerspace(); if (this.eat(":")) prop.value = this.expression(); else if (this.text[this.i] === "(") { prop.method = true; prop.value = this.functionExpression(); } else this.raise("EXPECTED", ":"); } else { prop.key = this.identifier(true); this.outerspace(); if (this.eat(":")) prop.value = this.expression(); else if (this.text[this.i] === "(") { prop.method = true; prop.value = this.functionExpression(); } else if (this.text[this.i] === "," || this.text[this.i] === "}") { prop.shorthand = true; var clone = new types_1.Identifier(prop.key.loc.start); clone.name = prop.key.name; clone.loc.end = prop.loc.end; prop.value = clone; } } this.eat(","); prop.loc.end = (_a = prop.value) === null || _a === void 0 ? void 0 : _a.loc.end; return prop; }; base_1.ezra.elements = function () { var args = []; while (!(this.text[this.i] === undefined) && this.text[this.i] !== "]") { while (this.text[this.i] === ",") { this.i++; args.push(null); this.outerspace(); } if (this.text[this.i] === "]") break; args.push(this.expression()); if (this.text[this.i] === ",") this.i++; this.outerspace(); } return args; };