Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shift-codegen

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shift-codegen - npm Package Compare versions

Comparing version 5.0.5 to 5.1.0

dist/token-stream.js

324

dist/coderep.js

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -48,27 +48,27 @@ Object.defineProperty(exports, "__esModule", {

var BinaryPrecedence = {
",": Precedence.Sequence,
"||": Precedence.LogicalOR,
"&&": Precedence.LogicalAND,
"|": Precedence.BitwiseOR,
"^": Precedence.BitwiseXOR,
"&": Precedence.BitwiseAND,
"==": Precedence.Equality,
"!=": Precedence.Equality,
"===": Precedence.Equality,
"!==": Precedence.Equality,
"<": Precedence.Relational,
">": Precedence.Relational,
"<=": Precedence.Relational,
">=": Precedence.Relational,
"in": Precedence.Relational,
"instanceof": Precedence.Relational,
"<<": Precedence.BitwiseSHIFT,
">>": Precedence.BitwiseSHIFT,
">>>": Precedence.BitwiseSHIFT,
"+": Precedence.Additive,
"-": Precedence.Additive,
"*": Precedence.Multiplicative,
"%": Precedence.Multiplicative,
"/": Precedence.Multiplicative,
"**": Precedence.Exponential
',': Precedence.Sequence,
'||': Precedence.LogicalOR,
'&&': Precedence.LogicalAND,
'|': Precedence.BitwiseOR,
'^': Precedence.BitwiseXOR,
'&': Precedence.BitwiseAND,
'==': Precedence.Equality,
'!=': Precedence.Equality,
'===': Precedence.Equality,
'!==': Precedence.Equality,
'<': Precedence.Relational,
'>': Precedence.Relational,
'<=': Precedence.Relational,
'>=': Precedence.Relational,
'in': Precedence.Relational,
'instanceof': Precedence.Relational,
'<<': Precedence.BitwiseSHIFT,
'>>': Precedence.BitwiseSHIFT,
'>>>': Precedence.BitwiseSHIFT,
'+': Precedence.Additive,
'-': Precedence.Additive,
'*': Precedence.Multiplicative,
'%': Precedence.Multiplicative,
'/': Precedence.Multiplicative,
'**': Precedence.Exponential
};

@@ -78,34 +78,40 @@

switch (node.type) {
case "ArrayExpression":
case "FunctionExpression":
case "IdentifierExpression":
case "LiteralBooleanExpression":
case "LiteralNullExpression":
case "LiteralNumericExpression":
case "LiteralInfinityExpression":
case "LiteralRegExpExpression":
case "LiteralStringExpression":
case "ObjectExpression":
case "ThisExpression":
case 'ArrayExpression':
case 'FunctionExpression':
case 'ClassExpression':
case 'IdentifierExpression':
case 'AssignmentTargetIdentifier':
case 'NewTargetExpression':
case 'Super':
case 'LiteralBooleanExpression':
case 'LiteralNullExpression':
case 'LiteralNumericExpression':
case 'LiteralInfinityExpression':
case 'LiteralRegExpExpression':
case 'LiteralStringExpression':
case 'ObjectExpression':
case 'ThisExpression':
case 'SpreadElement':
case 'FunctionBody':
return Precedence.Primary;
case "ArrowExpression":
case "AssignmentExpression":
case "CompoundAssignmentExpression":
case "YieldExpression":
case "YieldGeneratorExpression":
case 'ArrowExpression':
case 'AssignmentExpression':
case 'CompoundAssignmentExpression':
case 'YieldExpression':
case 'YieldGeneratorExpression':
return Precedence.Assignment;
case "ConditionalExpression":
case 'ConditionalExpression':
return Precedence.Conditional;
case "ComputedMemberExpression":
case "StaticMemberExpression":
case "ComputedMemberAssignmentTarget":
case "StaticMemberAssignmentTarget":
case 'ComputedMemberExpression':
case 'StaticMemberExpression':
case 'ComputedMemberAssignmentTarget':
case 'StaticMemberAssignmentTarget':
switch (node.object.type) {
case "CallExpression":
case "ComputedMemberExpression":
case "StaticMemberExpression":
case "TemplateExpression":
case 'CallExpression':
case 'ComputedMemberExpression':
case 'StaticMemberExpression':
case 'TemplateExpression':
return getPrecedence(node.object);

@@ -116,9 +122,9 @@ default:

case "TemplateExpression":
case 'TemplateExpression':
if (node.tag == null) return Precedence.Member;
switch (node.tag.type) {
case "CallExpression":
case "ComputedMemberExpression":
case "StaticMemberExpression":
case "TemplateExpression":
case 'CallExpression':
case 'ComputedMemberExpression':
case 'StaticMemberExpression':
case 'TemplateExpression':
return getPrecedence(node.tag);

@@ -129,13 +135,15 @@ default:

case "BinaryExpression":
case 'BinaryExpression':
return BinaryPrecedence[node.operator];
case "CallExpression":
case 'CallExpression':
return Precedence.Call;
case "NewExpression":
case 'NewExpression':
return node.arguments.length === 0 ? Precedence.New : Precedence.Member;
case "UpdateExpression":
case 'UpdateExpression':
return node.isPrefix ? Precedence.Prefix : Precedence.Postfix;
case "UnaryExpression":
case 'UnaryExpression':
return Precedence.Prefix;
default:
throw new Error('unreachable: ' + node.type);
}

@@ -145,3 +153,3 @@ }

function escapeStringLiteral(stringValue) {
var result = "";
var result = '';
var nSingle = 0,

@@ -151,9 +159,9 @@ nDouble = 0;

var ch = stringValue[i];
if (ch === "\"") {
if (ch === '"') {
++nDouble;
} else if (ch === "'") {
} else if (ch === '\'') {
++nSingle;
}
}
var delim = nDouble > nSingle ? "'" : "\"";
var delim = nDouble > nSingle ? '\'' : '"';
result += delim;

@@ -164,18 +172,18 @@ for (var _i = 0; _i < stringValue.length; _i++) {

case delim:
result += "\\" + delim;
result += '\\' + delim;
break;
case "\n":
result += "\\n";
case '\n':
result += '\\n';
break;
case "\r":
result += "\\r";
case '\r':
result += '\\r';
break;
case "\\":
result += "\\\\";
case '\\':
result += '\\\\';
break;
case "\u2028":
result += "\\u2028";
case '\u2028':
result += '\\u2028';
break;
case "\u2029":
result += "\\u2029";
case '\u2029':
result += '\\u2029';
break;

@@ -206,3 +214,3 @@ default:

_createClass(CodeRep, [{
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -227,3 +235,3 @@ // Call a function on every CodeRep represented by this node. Always calls f on a node and then its children, so if you're careful you can modify a node's children online.

_createClass(Empty, [{
key: "emit",
key: 'emit',
value: function emit() {}

@@ -251,3 +259,3 @@ }]);

_createClass(Token, [{
key: "emit",
key: 'emit',
value: function emit(ts) {

@@ -261,16 +269,38 @@ ts.put(this.token, this.isRegExp);

var NumberCodeRep = exports.NumberCodeRep = function (_CodeRep3) {
_inherits(NumberCodeRep, _CodeRep3);
var RawToken = exports.RawToken = function (_CodeRep3) {
_inherits(RawToken, _CodeRep3);
function RawToken(token) {
_classCallCheck(this, RawToken);
var _this3 = _possibleConstructorReturn(this, (RawToken.__proto__ || Object.getPrototypeOf(RawToken)).call(this));
_this3.token = token;
return _this3;
}
_createClass(RawToken, [{
key: 'emit',
value: function emit(ts) {
ts.putRaw(this.token);
}
}]);
return RawToken;
}(CodeRep);
var NumberCodeRep = exports.NumberCodeRep = function (_CodeRep4) {
_inherits(NumberCodeRep, _CodeRep4);
function NumberCodeRep(number) {
_classCallCheck(this, NumberCodeRep);
var _this3 = _possibleConstructorReturn(this, (NumberCodeRep.__proto__ || Object.getPrototypeOf(NumberCodeRep)).call(this));
var _this4 = _possibleConstructorReturn(this, (NumberCodeRep.__proto__ || Object.getPrototypeOf(NumberCodeRep)).call(this));
_this3.number = number;
return _this3;
_this4.number = number;
return _this4;
}
_createClass(NumberCodeRep, [{
key: "emit",
key: 'emit',
value: function emit(ts) {

@@ -284,4 +314,4 @@ ts.putNumber(this.number);

var Paren = exports.Paren = function (_CodeRep4) {
_inherits(Paren, _CodeRep4);
var Paren = exports.Paren = function (_CodeRep5) {
_inherits(Paren, _CodeRep5);

@@ -291,17 +321,17 @@ function Paren(expr) {

var _this4 = _possibleConstructorReturn(this, (Paren.__proto__ || Object.getPrototypeOf(Paren)).call(this));
var _this5 = _possibleConstructorReturn(this, (Paren.__proto__ || Object.getPrototypeOf(Paren)).call(this));
_this4.expr = expr;
return _this4;
_this5.expr = expr;
return _this5;
}
_createClass(Paren, [{
key: "emit",
key: 'emit',
value: function emit(ts) {
ts.put("(");
ts.put('(');
this.expr.emit(ts, false);
ts.put(")");
ts.put(')');
}
}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -316,4 +346,4 @@ f(this);

var Bracket = exports.Bracket = function (_CodeRep5) {
_inherits(Bracket, _CodeRep5);
var Bracket = exports.Bracket = function (_CodeRep6) {
_inherits(Bracket, _CodeRep6);

@@ -323,17 +353,17 @@ function Bracket(expr) {

var _this5 = _possibleConstructorReturn(this, (Bracket.__proto__ || Object.getPrototypeOf(Bracket)).call(this));
var _this6 = _possibleConstructorReturn(this, (Bracket.__proto__ || Object.getPrototypeOf(Bracket)).call(this));
_this5.expr = expr;
return _this5;
_this6.expr = expr;
return _this6;
}
_createClass(Bracket, [{
key: "emit",
key: 'emit',
value: function emit(ts) {
ts.put("[");
ts.put('[');
this.expr.emit(ts, false);
ts.put("]");
ts.put(']');
}
}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -348,4 +378,4 @@ f(this);

var Brace = exports.Brace = function (_CodeRep6) {
_inherits(Brace, _CodeRep6);
var Brace = exports.Brace = function (_CodeRep7) {
_inherits(Brace, _CodeRep7);

@@ -355,17 +385,17 @@ function Brace(expr) {

var _this6 = _possibleConstructorReturn(this, (Brace.__proto__ || Object.getPrototypeOf(Brace)).call(this));
var _this7 = _possibleConstructorReturn(this, (Brace.__proto__ || Object.getPrototypeOf(Brace)).call(this));
_this6.expr = expr;
return _this6;
_this7.expr = expr;
return _this7;
}
_createClass(Brace, [{
key: "emit",
key: 'emit',
value: function emit(ts) {
ts.put("{");
ts.put('{');
this.expr.emit(ts, false);
ts.put("}");
ts.put('}');
}
}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -380,4 +410,4 @@ f(this);

var NoIn = exports.NoIn = function (_CodeRep7) {
_inherits(NoIn, _CodeRep7);
var NoIn = exports.NoIn = function (_CodeRep8) {
_inherits(NoIn, _CodeRep8);

@@ -387,10 +417,10 @@ function NoIn(expr) {

var _this7 = _possibleConstructorReturn(this, (NoIn.__proto__ || Object.getPrototypeOf(NoIn)).call(this));
var _this8 = _possibleConstructorReturn(this, (NoIn.__proto__ || Object.getPrototypeOf(NoIn)).call(this));
_this7.expr = expr;
return _this7;
_this8.expr = expr;
return _this8;
}
_createClass(NoIn, [{
key: "emit",
key: 'emit',
value: function emit(ts) {

@@ -400,3 +430,3 @@ this.expr.emit(ts, true);

}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -411,4 +441,4 @@ f(this);

var ContainsIn = exports.ContainsIn = function (_CodeRep8) {
_inherits(ContainsIn, _CodeRep8);
var ContainsIn = exports.ContainsIn = function (_CodeRep9) {
_inherits(ContainsIn, _CodeRep9);

@@ -418,15 +448,15 @@ function ContainsIn(expr) {

var _this8 = _possibleConstructorReturn(this, (ContainsIn.__proto__ || Object.getPrototypeOf(ContainsIn)).call(this));
var _this9 = _possibleConstructorReturn(this, (ContainsIn.__proto__ || Object.getPrototypeOf(ContainsIn)).call(this));
_this8.expr = expr;
return _this8;
_this9.expr = expr;
return _this9;
}
_createClass(ContainsIn, [{
key: "emit",
key: 'emit',
value: function emit(ts, noIn) {
if (noIn) {
ts.put("(");
ts.put('(');
this.expr.emit(ts, false);
ts.put(")");
ts.put(')');
} else {

@@ -437,3 +467,3 @@ this.expr.emit(ts, false);

}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -448,4 +478,4 @@ f(this);

var Seq = exports.Seq = function (_CodeRep9) {
_inherits(Seq, _CodeRep9);
var Seq = exports.Seq = function (_CodeRep10) {
_inherits(Seq, _CodeRep10);

@@ -455,10 +485,10 @@ function Seq(children) {

var _this9 = _possibleConstructorReturn(this, (Seq.__proto__ || Object.getPrototypeOf(Seq)).call(this));
var _this10 = _possibleConstructorReturn(this, (Seq.__proto__ || Object.getPrototypeOf(Seq)).call(this));
_this9.children = children;
return _this9;
_this10.children = children;
return _this10;
}
_createClass(Seq, [{
key: "emit",
key: 'emit',
value: function emit(ts, noIn) {

@@ -470,3 +500,3 @@ this.children.forEach(function (cr) {

}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -489,3 +519,3 @@ f(this);

return _possibleConstructorReturn(this, (Semi.__proto__ || Object.getPrototypeOf(Semi)).call(this, ";"));
return _possibleConstructorReturn(this, (Semi.__proto__ || Object.getPrototypeOf(Semi)).call(this, ';'));
}

@@ -496,4 +526,4 @@

var CommaSep = exports.CommaSep = function (_CodeRep10) {
_inherits(CommaSep, _CodeRep10);
var CommaSep = exports.CommaSep = function (_CodeRep11) {
_inherits(CommaSep, _CodeRep11);

@@ -503,10 +533,10 @@ function CommaSep(children) {

var _this11 = _possibleConstructorReturn(this, (CommaSep.__proto__ || Object.getPrototypeOf(CommaSep)).call(this));
var _this12 = _possibleConstructorReturn(this, (CommaSep.__proto__ || Object.getPrototypeOf(CommaSep)).call(this));
_this11.children = children;
return _this11;
_this12.children = children;
return _this12;
}
_createClass(CommaSep, [{
key: "emit",
key: 'emit',
value: function emit(ts, noIn) {

@@ -518,3 +548,3 @@ var first = true;

} else {
ts.put(",");
ts.put(',');
}

@@ -525,3 +555,3 @@ cr.emit(ts, noIn);

}, {
key: "forEach",
key: 'forEach',
value: function forEach(f) {

@@ -538,4 +568,4 @@ f(this);

var SemiOp = exports.SemiOp = function (_CodeRep11) {
_inherits(SemiOp, _CodeRep11);
var SemiOp = exports.SemiOp = function (_CodeRep12) {
_inherits(SemiOp, _CodeRep12);

@@ -549,3 +579,3 @@ function SemiOp() {

_createClass(SemiOp, [{
key: "emit",
key: 'emit',
value: function emit(ts) {

@@ -552,0 +582,0 @@ ts.putOptionalSemi();

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {

});
exports.SemiOp = exports.CommaSep = exports.Semi = exports.Seq = exports.ContainsIn = exports.NoIn = exports.Brace = exports.Bracket = exports.Paren = exports.NumberCodeRep = exports.Token = exports.Empty = exports.CodeRep = exports.escapeStringLiteral = exports.getPrecedence = exports.Precedence = exports.Sep = exports.FormattedCodeGen = exports.ExtensibleCodeGen = exports.MinimalCodeGen = undefined;
exports.codeGenWithLocation = exports.SemiOp = exports.CommaSep = exports.Semi = exports.Seq = exports.ContainsIn = exports.NoIn = exports.Brace = exports.Bracket = exports.Paren = exports.NumberCodeRep = exports.Token = exports.Empty = exports.CodeRep = exports.escapeStringLiteral = exports.getPrecedence = exports.Precedence = exports.Sep = exports.FormattedCodeGen = exports.ExtensibleCodeGen = exports.MinimalCodeGen = undefined;
exports.default = codeGen;
var _minimalCodegen = require("./minimal-codegen");
var _minimalCodegen = require('./minimal-codegen');
Object.defineProperty(exports, "MinimalCodeGen", {
Object.defineProperty(exports, 'MinimalCodeGen', {
enumerable: true,

@@ -19,5 +19,5 @@ get: function get() {

var _formattedCodegen = require("./formatted-codegen");
var _formattedCodegen = require('./formatted-codegen');
Object.defineProperty(exports, "ExtensibleCodeGen", {
Object.defineProperty(exports, 'ExtensibleCodeGen', {
enumerable: true,

@@ -28,3 +28,3 @@ get: function get() {

});
Object.defineProperty(exports, "FormattedCodeGen", {
Object.defineProperty(exports, 'FormattedCodeGen', {
enumerable: true,

@@ -35,3 +35,3 @@ get: function get() {

});
Object.defineProperty(exports, "Sep", {
Object.defineProperty(exports, 'Sep', {
enumerable: true,

@@ -43,5 +43,5 @@ get: function get() {

var _coderep = require("./coderep");
var _coderep = require('./coderep');
Object.defineProperty(exports, "Precedence", {
Object.defineProperty(exports, 'Precedence', {
enumerable: true,

@@ -52,3 +52,3 @@ get: function get() {

});
Object.defineProperty(exports, "getPrecedence", {
Object.defineProperty(exports, 'getPrecedence', {
enumerable: true,

@@ -59,3 +59,3 @@ get: function get() {

});
Object.defineProperty(exports, "escapeStringLiteral", {
Object.defineProperty(exports, 'escapeStringLiteral', {
enumerable: true,

@@ -66,3 +66,3 @@ get: function get() {

});
Object.defineProperty(exports, "CodeRep", {
Object.defineProperty(exports, 'CodeRep', {
enumerable: true,

@@ -73,3 +73,3 @@ get: function get() {

});
Object.defineProperty(exports, "Empty", {
Object.defineProperty(exports, 'Empty', {
enumerable: true,

@@ -80,3 +80,3 @@ get: function get() {

});
Object.defineProperty(exports, "Token", {
Object.defineProperty(exports, 'Token', {
enumerable: true,

@@ -87,3 +87,3 @@ get: function get() {

});
Object.defineProperty(exports, "NumberCodeRep", {
Object.defineProperty(exports, 'NumberCodeRep', {
enumerable: true,

@@ -94,3 +94,3 @@ get: function get() {

});
Object.defineProperty(exports, "Paren", {
Object.defineProperty(exports, 'Paren', {
enumerable: true,

@@ -101,3 +101,3 @@ get: function get() {

});
Object.defineProperty(exports, "Bracket", {
Object.defineProperty(exports, 'Bracket', {
enumerable: true,

@@ -108,3 +108,3 @@ get: function get() {

});
Object.defineProperty(exports, "Brace", {
Object.defineProperty(exports, 'Brace', {
enumerable: true,

@@ -115,3 +115,3 @@ get: function get() {

});
Object.defineProperty(exports, "NoIn", {
Object.defineProperty(exports, 'NoIn', {
enumerable: true,

@@ -122,3 +122,3 @@ get: function get() {

});
Object.defineProperty(exports, "ContainsIn", {
Object.defineProperty(exports, 'ContainsIn', {
enumerable: true,

@@ -129,3 +129,3 @@ get: function get() {

});
Object.defineProperty(exports, "Seq", {
Object.defineProperty(exports, 'Seq', {
enumerable: true,

@@ -136,3 +136,3 @@ get: function get() {

});
Object.defineProperty(exports, "Semi", {
Object.defineProperty(exports, 'Semi', {
enumerable: true,

@@ -143,3 +143,3 @@ get: function get() {

});
Object.defineProperty(exports, "CommaSep", {
Object.defineProperty(exports, 'CommaSep', {
enumerable: true,

@@ -150,3 +150,3 @@ get: function get() {

});
Object.defineProperty(exports, "SemiOp", {
Object.defineProperty(exports, 'SemiOp', {
enumerable: true,

@@ -158,7 +158,16 @@ get: function get() {

var _shiftReducer = require("shift-reducer");
var _withLocation = require('./with-location');
Object.defineProperty(exports, 'codeGenWithLocation', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_withLocation).default;
}
});
var _shiftReducer = require('shift-reducer');
var _shiftReducer2 = _interopRequireDefault(_shiftReducer);
var _token_stream = require("./token_stream");
var _tokenStream = require('./token-stream');

@@ -172,3 +181,3 @@ var _minimalCodegen2 = _interopRequireDefault(_minimalCodegen);

var ts = new _token_stream.TokenStream();
var ts = new _tokenStream.TokenStream();
var rep = (0, _shiftReducer2.default)(generator, script);

@@ -175,0 +184,0 @@ rep.emit(ts);

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -9,9 +9,9 @@ Object.defineProperty(exports, "__esModule", {

var _objectAssign = require("object-assign");
var _objectAssign = require('object-assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _esutils = require("esutils");
var _esutils = require('esutils');
var _coderep = require("./coderep");
var _coderep = require('./coderep');

@@ -88,5 +88,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_createClass(MinimalCodeGen, [{
key: "parenToAvoidBeingDirective",
key: 'parenToAvoidBeingDirective',
value: function parenToAvoidBeingDirective(element, original) {
if (element && element.type === "ExpressionStatement" && element.expression.type === "LiteralStringExpression") {
if (element && element.type === 'ExpressionStatement' && element.expression.type === 'LiteralStringExpression') {
return seq(paren(original.children[0]), semiOp());

@@ -97,3 +97,12 @@ }

}, {
key: "reduceArrayExpression",
key: 'regenerateArrowParams',
value: function regenerateArrowParams(element, original) {
if (element.rest == null && element.items.length === 1 && element.items[0].type === 'BindingIdentifier') {
// FormalParameters unconditionally include parentheses, but they're not necessary here
return this.reduceBindingIdentifier(element.items[0]);
}
return original;
}
}, {
key: 'reduceArrayExpression',
value: function reduceArrayExpression(node, _ref) {

@@ -108,3 +117,3 @@ var elements = _ref.elements;

if (elements.length > 0 && elements[elements.length - 1] == null) {
content = seq(content, t(","));
content = seq(content, t(','));
}

@@ -114,10 +123,10 @@ return bracket(content);

}, {
key: "reduceSpreadElement",
key: 'reduceSpreadElement',
value: function reduceSpreadElement(node, _ref2) {
var expression = _ref2.expression;
return seq(t("..."), p(node.expression, _coderep.Precedence.Assignment, expression));
return seq(t('...'), p(node.expression, _coderep.Precedence.Assignment, expression));
}
}, {
key: "reduceAssignmentExpression",
key: 'reduceAssignmentExpression',
value: function reduceAssignmentExpression(node, _ref3) {

@@ -137,9 +146,9 @@ var binding = _ref3.binding,

}
return (0, _objectAssign2.default)(seq(leftCode, t("="), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass });
return (0, _objectAssign2.default)(seq(leftCode, t('='), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass });
}
}, {
key: "reduceAssignmentTargetIdentifier",
key: 'reduceAssignmentTargetIdentifier',
value: function reduceAssignmentTargetIdentifier(node) {
var a = t(node.name);
if (node.name === "let") {
if (node.name === 'let') {
a.startsWithLet = true;

@@ -150,3 +159,3 @@ }

}, {
key: "reduceAssignmentTargetWithDefault",
key: 'reduceAssignmentTargetWithDefault',
value: function reduceAssignmentTargetWithDefault(node, _ref4) {

@@ -156,6 +165,6 @@ var binding = _ref4.binding,

return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init));
return seq(binding, t('='), p(node.init, _coderep.Precedence.Assignment, init));
}
}, {
key: "reduceCompoundAssignmentExpression",
key: 'reduceCompoundAssignmentExpression',
value: function reduceCompoundAssignmentExpression(node, _ref5) {

@@ -178,3 +187,3 @@ var binding = _ref5.binding,

}, {
key: "reduceBinaryExpression",
key: 'reduceBinaryExpression',
value: function reduceBinaryExpression(node, _ref6) {

@@ -189,4 +198,4 @@ var left = _ref6.left,

var leftContainsIn = left.containsIn;
var isRightAssociative = node.operator === "**";
if ((0, _coderep.getPrecedence)(node.left) < (0, _coderep.getPrecedence)(node) || isRightAssociative && ((0, _coderep.getPrecedence)(node.left) === (0, _coderep.getPrecedence)(node) || node.left.type === "UnaryExpression")) {
var isRightAssociative = node.operator === '**';
if ((0, _coderep.getPrecedence)(node.left) < (0, _coderep.getPrecedence)(node) || isRightAssociative && ((0, _coderep.getPrecedence)(node.left) === (0, _coderep.getPrecedence)(node) || node.left.type === 'UnaryExpression')) {
leftCode = paren(leftCode);

@@ -205,4 +214,4 @@ startsWithCurly = false;

return (0, _objectAssign2.default)(seq(leftCode, t(node.operator), rightCode), {
containsIn: leftContainsIn || rightContainsIn || node.operator === "in",
containsGroup: node.operator == ",",
containsIn: leftContainsIn || rightContainsIn || node.operator === 'in',
containsGroup: node.operator === ',',
startsWithCurly: startsWithCurly,

@@ -214,3 +223,3 @@ startsWithLetSquareBracket: startsWithLetSquareBracket,

}, {
key: "reduceBindingWithDefault",
key: 'reduceBindingWithDefault',
value: function reduceBindingWithDefault(node, _ref7) {

@@ -220,9 +229,9 @@ var binding = _ref7.binding,

return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init));
return seq(binding, t('='), p(node.init, _coderep.Precedence.Assignment, init));
}
}, {
key: "reduceBindingIdentifier",
key: 'reduceBindingIdentifier',
value: function reduceBindingIdentifier(node) {
var a = t(node.name);
if (node.name === "let") {
if (node.name === 'let') {
a.startsWithLet = true;

@@ -233,3 +242,3 @@ }

}, {
key: "reduceArrayAssignmentTarget",
key: 'reduceArrayAssignmentTarget',
value: function reduceArrayAssignmentTarget(node, _ref8) {

@@ -241,8 +250,8 @@ var elements = _ref8.elements,

if (elements.length === 0) {
content = rest == null ? empty() : seq(t("..."), rest);
content = rest == null ? empty() : seq(t('...'), rest);
} else {
elements = elements.concat(rest == null ? [] : [seq(t("..."), rest)]);
elements = elements.concat(rest == null ? [] : [seq(t('...'), rest)]);
content = commaSep(elements.map(getAssignmentExpr));
if (elements.length > 0 && elements[elements.length - 1] == null) {
content = seq(content, t(","));
content = seq(content, t(','));
}

@@ -253,3 +262,3 @@ }

}, {
key: "reduceArrayBinding",
key: 'reduceArrayBinding',
value: function reduceArrayBinding(node, _ref9) {

@@ -261,8 +270,8 @@ var elements = _ref9.elements,

if (elements.length === 0) {
content = rest == null ? empty() : seq(t("..."), rest);
content = rest == null ? empty() : seq(t('...'), rest);
} else {
elements = elements.concat(rest == null ? [] : [seq(t("..."), rest)]);
elements = elements.concat(rest == null ? [] : [seq(t('...'), rest)]);
content = commaSep(elements.map(getAssignmentExpr));
if (elements.length > 0 && elements[elements.length - 1] == null) {
content = seq(content, t(","));
content = seq(content, t(','));
}

@@ -273,3 +282,3 @@ }

}, {
key: "reduceObjectAssignmentTarget",
key: 'reduceObjectAssignmentTarget',
value: function reduceObjectAssignmentTarget(node, _ref10) {

@@ -283,3 +292,3 @@ var properties = _ref10.properties;

}, {
key: "reduceObjectBinding",
key: 'reduceObjectBinding',
value: function reduceObjectBinding(node, _ref11) {

@@ -293,3 +302,3 @@ var properties = _ref11.properties;

}, {
key: "reduceAssignmentTargetPropertyIdentifier",
key: 'reduceAssignmentTargetPropertyIdentifier',
value: function reduceAssignmentTargetPropertyIdentifier(node, _ref12) {

@@ -300,6 +309,6 @@ var binding = _ref12.binding,

if (node.init == null) return binding;
return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init));
return seq(binding, t('='), p(node.init, _coderep.Precedence.Assignment, init));
}
}, {
key: "reduceAssignmentTargetPropertyProperty",
key: 'reduceAssignmentTargetPropertyProperty',
value: function reduceAssignmentTargetPropertyProperty(node, _ref13) {

@@ -309,6 +318,6 @@ var name = _ref13.name,

return seq(name, t(":"), binding);
return seq(name, t(':'), binding);
}
}, {
key: "reduceBindingPropertyIdentifier",
key: 'reduceBindingPropertyIdentifier',
value: function reduceBindingPropertyIdentifier(node, _ref14) {

@@ -319,6 +328,6 @@ var binding = _ref14.binding,

if (node.init == null) return binding;
return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init));
return seq(binding, t('='), p(node.init, _coderep.Precedence.Assignment, init));
}
}, {
key: "reduceBindingPropertyProperty",
key: 'reduceBindingPropertyProperty',
value: function reduceBindingPropertyProperty(node, _ref15) {

@@ -328,6 +337,6 @@ var name = _ref15.name,

return seq(name, t(":"), binding);
return seq(name, t(':'), binding);
}
}, {
key: "reduceBlock",
key: 'reduceBlock',
value: function reduceBlock(node, _ref16) {

@@ -339,3 +348,3 @@ var statements = _ref16.statements;

}, {
key: "reduceBlockStatement",
key: 'reduceBlockStatement',
value: function reduceBlockStatement(node, _ref17) {

@@ -347,8 +356,8 @@ var block = _ref17.block;

}, {
key: "reduceBreakStatement",
key: 'reduceBreakStatement',
value: function reduceBreakStatement(node) {
return seq(t("break"), node.label ? t(node.label) : empty(), semiOp());
return seq(t('break'), node.label ? t(node.label) : empty(), semiOp());
}
}, {
key: "reduceCallExpression",
key: 'reduceCallExpression',
value: function reduceCallExpression(node, _ref18) {

@@ -368,3 +377,3 @@ var callee = _ref18.callee,

}, {
key: "reduceCatchClause",
key: 'reduceCatchClause',
value: function reduceCatchClause(node, _ref19) {

@@ -374,6 +383,6 @@ var binding = _ref19.binding,

return seq(t("catch"), paren(binding), body);
return seq(t('catch'), paren(binding), body);
}
}, {
key: "reduceClassDeclaration",
key: 'reduceClassDeclaration',
value: function reduceClassDeclaration(node, _ref20) {

@@ -384,11 +393,11 @@ var name = _ref20.name,

var state = seq(t("class"), node.name.name === "*default*" ? empty() : name);
var state = seq(t('class'), node.name.name === '*default*' ? empty() : name);
if (_super != null) {
state = seq(state, t("extends"), p(node.super, _coderep.Precedence.New, _super));
state = seq(state, t('extends'), p(node.super, _coderep.Precedence.New, _super));
}
state = seq.apply(undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")]));
state = seq.apply(undefined, [state, t('{')].concat(_toConsumableArray(elements), [t('}')]));
return state;
}
}, {
key: "reduceClassExpression",
key: 'reduceClassExpression',
value: function reduceClassExpression(node, _ref21) {

@@ -399,3 +408,3 @@ var name = _ref21.name,

var state = t("class");
var state = t('class');
if (name != null) {

@@ -405,5 +414,5 @@ state = seq(state, name);

if (_super != null) {
state = seq(state, t("extends"), p(node.super, _coderep.Precedence.New, _super));
state = seq(state, t('extends'), p(node.super, _coderep.Precedence.New, _super));
}
state = seq.apply(undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")]));
state = seq.apply(undefined, [state, t('{')].concat(_toConsumableArray(elements), [t('}')]));
state.startsWithFunctionOrClass = true;

@@ -413,3 +422,3 @@ return state;

}, {
key: "reduceClassElement",
key: 'reduceClassElement',
value: function reduceClassElement(node, _ref22) {

@@ -419,6 +428,6 @@ var method = _ref22.method;

if (!node.isStatic) return method;
return seq(t("static"), method);
return seq(t('static'), method);
}
}, {
key: "reduceComputedMemberAssignmentTarget",
key: 'reduceComputedMemberAssignmentTarget',
value: function reduceComputedMemberAssignmentTarget(node, _ref23) {

@@ -428,3 +437,3 @@ var object = _ref23.object,

var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === "IdentifierExpression" && node.object.name === "let";
var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === 'IdentifierExpression' && node.object.name === 'let';
return (0, _objectAssign2.default)(seq(p(node.object, (0, _coderep.getPrecedence)(node), object), bracket(expression)), {

@@ -438,3 +447,3 @@ startsWithLet: object.startsWithLet,

}, {
key: "reduceComputedMemberExpression",
key: 'reduceComputedMemberExpression',
value: function reduceComputedMemberExpression(node, _ref24) {

@@ -444,3 +453,3 @@ var object = _ref24.object,

var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === "IdentifierExpression" && node.object.name === "let";
var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === 'IdentifierExpression' && node.object.name === 'let';
return (0, _objectAssign2.default)(seq(p(node.object, (0, _coderep.getPrecedence)(node), object), bracket(expression)), {

@@ -454,3 +463,3 @@ startsWithLet: object.startsWithLet,

}, {
key: "reduceComputedPropertyName",
key: 'reduceComputedPropertyName',
value: function reduceComputedPropertyName(node, _ref25) {

@@ -462,3 +471,3 @@ var expression = _ref25.expression;

}, {
key: "reduceConditionalExpression",
key: 'reduceConditionalExpression',
value: function reduceConditionalExpression(node, _ref26) {

@@ -473,3 +482,3 @@ var test = _ref26.test,

var startsWithFunctionOrClass = test.startsWithFunctionOrClass;
return (0, _objectAssign2.default)(seq(p(node.test, _coderep.Precedence.LogicalOR, test), t("?"), p(node.consequent, _coderep.Precedence.Assignment, consequent), t(":"), p(node.alternate, _coderep.Precedence.Assignment, alternate)), {
return (0, _objectAssign2.default)(seq(p(node.test, _coderep.Precedence.LogicalOR, test), t('?'), p(node.consequent, _coderep.Precedence.Assignment, consequent), t(':'), p(node.alternate, _coderep.Precedence.Assignment, alternate)), {
containsIn: containsIn,

@@ -482,8 +491,8 @@ startsWithCurly: startsWithCurly,

}, {
key: "reduceContinueStatement",
key: 'reduceContinueStatement',
value: function reduceContinueStatement(node) {
return seq(t("continue"), node.label ? t(node.label) : empty(), semiOp());
return seq(t('continue'), node.label ? t(node.label) : empty(), semiOp());
}
}, {
key: "reduceDataProperty",
key: 'reduceDataProperty',
value: function reduceDataProperty(node, _ref27) {

@@ -493,11 +502,11 @@ var name = _ref27.name,

return seq(name, t(":"), getAssignmentExpr(expression));
return seq(name, t(':'), getAssignmentExpr(expression));
}
}, {
key: "reduceDebuggerStatement",
value: function reduceDebuggerStatement(node) {
return seq(t("debugger"), semiOp());
key: 'reduceDebuggerStatement',
value: function reduceDebuggerStatement() /* node */{
return seq(t('debugger'), semiOp());
}
}, {
key: "reduceDoWhileStatement",
key: 'reduceDoWhileStatement',
value: function reduceDoWhileStatement(node, _ref28) {

@@ -507,11 +516,11 @@ var body = _ref28.body,

return seq(t("do"), body, t("while"), paren(test), semiOp());
return seq(t('do'), body, t('while'), paren(test), semiOp());
}
}, {
key: "reduceEmptyStatement",
value: function reduceEmptyStatement(node) {
key: 'reduceEmptyStatement',
value: function reduceEmptyStatement() /* node */{
return semi();
}
}, {
key: "reduceExpressionStatement",
key: 'reduceExpressionStatement',
value: function reduceExpressionStatement(node, _ref29) {

@@ -524,3 +533,3 @@ var expression = _ref29.expression;

}, {
key: "reduceForInStatement",
key: 'reduceForInStatement',
value: function reduceForInStatement(node, _ref30) {

@@ -531,7 +540,7 @@ var left = _ref30.left,

left = node.left.type === "VariableDeclaration" ? noIn(markContainsIn(left)) : left;
return (0, _objectAssign2.default)(seq(t("for"), paren(seq(left.startsWithLet ? paren(left) : left, t("in"), right)), body), { endsWithMissingElse: body.endsWithMissingElse });
left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left;
return (0, _objectAssign2.default)(seq(t('for'), paren(seq(left.startsWithLet ? paren(left) : left, t('in'), right)), body), { endsWithMissingElse: body.endsWithMissingElse });
}
}, {
key: "reduceForOfStatement",
key: 'reduceForOfStatement',
value: function reduceForOfStatement(node, _ref31) {

@@ -542,7 +551,7 @@ var left = _ref31.left,

left = node.left.type === "VariableDeclaration" ? noIn(markContainsIn(left)) : left;
return (0, _objectAssign2.default)(seq(t("for"), paren(seq(left.startsWithLet ? paren(left) : left, t("of"), p(node.right, _coderep.Precedence.Assignment, right))), body), { endsWithMissingElse: body.endsWithMissingElse });
left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left;
return (0, _objectAssign2.default)(seq(t('for'), paren(seq(left.startsWithLet ? paren(left) : left, t('of'), p(node.right, _coderep.Precedence.Assignment, right))), body), { endsWithMissingElse: body.endsWithMissingElse });
}
}, {
key: "reduceForStatement",
key: 'reduceForStatement',
value: function reduceForStatement(node, _ref32) {

@@ -554,3 +563,3 @@ var init = _ref32.init,

return (0, _objectAssign2.default)(seq(t("for"), paren(seq(init ? noIn(markContainsIn(init)) : empty(), semi(), test || empty(), semi(), update || empty())), body), {
return (0, _objectAssign2.default)(seq(t('for'), paren(seq(init ? noIn(markContainsIn(init)) : empty(), semi(), test || empty(), semi(), update || empty())), body), {
endsWithMissingElse: body.endsWithMissingElse

@@ -560,3 +569,3 @@ });

}, {
key: "reduceFunctionBody",
key: 'reduceFunctionBody',
value: function reduceFunctionBody(node, _ref33) {

@@ -569,6 +578,6 @@ var directives = _ref33.directives,

}
return seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements)));
return brace(seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements))));
}
}, {
key: "reduceFunctionDeclaration",
key: 'reduceFunctionDeclaration',
value: function reduceFunctionDeclaration(node, _ref34) {

@@ -579,6 +588,6 @@ var name = _ref34.name,

return seq(t("function"), node.isGenerator ? t("*") : empty(), node.name.name === "*default*" ? empty() : name, paren(params), brace(body));
return seq(t('function'), node.isGenerator ? t('*') : empty(), node.name.name === '*default*' ? empty() : name, params, body);
}
}, {
key: "reduceFunctionExpression",
key: 'reduceFunctionExpression',
value: function reduceFunctionExpression(node, _ref35) {

@@ -589,3 +598,3 @@ var name = _ref35.name,

var state = seq(t("function"), node.isGenerator ? t("*") : empty(), name ? name : empty(), paren(params), brace(body));
var state = seq(t('function'), node.isGenerator ? t('*') : empty(), name ? name : empty(), params, body);
state.startsWithFunctionOrClass = true;

@@ -595,3 +604,3 @@ return state;

}, {
key: "reduceFormalParameters",
key: 'reduceFormalParameters',
value: function reduceFormalParameters(node, _ref36) {

@@ -601,6 +610,6 @@ var items = _ref36.items,

return commaSep(items.concat(rest == null ? [] : [seq(t("..."), rest)]));
return paren(commaSep(items.concat(rest == null ? [] : [seq(t('...'), rest)])));
}
}, {
key: "reduceArrowExpression",
key: 'reduceArrowExpression',
value: function reduceArrowExpression(node, _ref37) {

@@ -610,17 +619,15 @@ var params = _ref37.params,

if (node.params.rest != null || node.params.items.length !== 1 || node.params.items[0].type !== "BindingIdentifier") {
params = paren(params);
}
params = this.regenerateArrowParams(node.params, params);
var containsIn = false;
if (node.body.type === "FunctionBody") {
body = brace(body);
} else if (body.startsWithCurly) {
body = paren(body);
} else if (body.containsIn) {
containsIn = true;
if (node.body.type !== 'FunctionBody') {
if (body.startsWithCurly) {
body = paren(body);
} else if (body.containsIn) {
containsIn = true;
}
}
return (0, _objectAssign2.default)(seq(params, t("=>"), p(node.body, _coderep.Precedence.Assignment, body)), { containsIn: containsIn });
return (0, _objectAssign2.default)(seq(params, t('=>'), p(node.body, _coderep.Precedence.Assignment, body)), { containsIn: containsIn });
}
}, {
key: "reduceGetter",
key: 'reduceGetter',
value: function reduceGetter(node, _ref38) {

@@ -630,9 +637,9 @@ var name = _ref38.name,

return seq(t("get"), name, paren(empty()), brace(body));
return seq(t('get'), name, paren(empty()), body);
}
}, {
key: "reduceIdentifierExpression",
key: 'reduceIdentifierExpression',
value: function reduceIdentifierExpression(node) {
var a = t(node.name);
if (node.name === "let") {
if (node.name === 'let') {
a.startsWithLet = true;

@@ -643,3 +650,3 @@ }

}, {
key: "reduceIfStatement",
key: 'reduceIfStatement',
value: function reduceIfStatement(node, _ref39) {

@@ -653,6 +660,6 @@ var test = _ref39.test,

}
return (0, _objectAssign2.default)(seq(t("if"), paren(test), consequent, alternate ? seq(t("else"), alternate) : empty()), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true });
return (0, _objectAssign2.default)(seq(t('if'), paren(test), consequent, alternate ? seq(t('else'), alternate) : empty()), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true });
}
}, {
key: "reduceImport",
key: 'reduceImport',
value: function reduceImport(node, _ref40) {

@@ -670,8 +677,8 @@ var defaultBinding = _ref40.defaultBinding,

if (bindings.length === 0) {
return seq(t("import"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
return seq(t('import'), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
}
return seq(t("import"), commaSep(bindings), t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
return seq(t('import'), commaSep(bindings), t('from'), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
}
}, {
key: "reduceImportNamespace",
key: 'reduceImportNamespace',
value: function reduceImportNamespace(node, _ref41) {

@@ -681,6 +688,6 @@ var defaultBinding = _ref41.defaultBinding,

return seq(t("import"), defaultBinding == null ? empty() : seq(defaultBinding, t(",")), t("*"), t("as"), namespaceBinding, t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
return seq(t('import'), defaultBinding == null ? empty() : seq(defaultBinding, t(',')), t('*'), t('as'), namespaceBinding, t('from'), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
}
}, {
key: "reduceImportSpecifier",
key: 'reduceImportSpecifier',
value: function reduceImportSpecifier(node, _ref42) {

@@ -690,25 +697,25 @@ var binding = _ref42.binding;

if (node.name == null) return binding;
return seq(t(node.name), t("as"), binding);
return seq(t(node.name), t('as'), binding);
}
}, {
key: "reduceExportAllFrom",
key: 'reduceExportAllFrom',
value: function reduceExportAllFrom(node) {
return seq(t("export"), t("*"), t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
return seq(t('export'), t('*'), t('from'), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
}
}, {
key: "reduceExportFrom",
key: 'reduceExportFrom',
value: function reduceExportFrom(node, _ref43) {
var namedExports = _ref43.namedExports;
return seq(t("export"), brace(commaSep(namedExports)), t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
return seq(t('export'), brace(commaSep(namedExports)), t('from'), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp());
}
}, {
key: "reduceExportLocals",
key: 'reduceExportLocals',
value: function reduceExportLocals(node, _ref44) {
var namedExports = _ref44.namedExports;
return seq(t("export"), brace(commaSep(namedExports)), semiOp());
return seq(t('export'), brace(commaSep(namedExports)), semiOp());
}
}, {
key: "reduceExport",
key: 'reduceExport',
value: function reduceExport(node, _ref45) {

@@ -718,4 +725,4 @@ var declaration = _ref45.declaration;

switch (node.declaration.type) {
case "FunctionDeclaration":
case "ClassDeclaration":
case 'FunctionDeclaration':
case 'ClassDeclaration':
break;

@@ -725,6 +732,6 @@ default:

}
return seq(t("export"), declaration);
return seq(t('export'), declaration);
}
}, {
key: "reduceExportDefault",
key: 'reduceExportDefault',
value: function reduceExportDefault(node, _ref46) {

@@ -735,17 +742,17 @@ var body = _ref46.body;

switch (node.body.type) {
case "FunctionDeclaration":
case "ClassDeclaration":
return seq(t("export default"), body);
case 'FunctionDeclaration':
case 'ClassDeclaration':
return seq(t('export default'), body);
default:
return seq(t("export default"), p(node.body, _coderep.Precedence.Assignment, body), semiOp());
return seq(t('export default'), p(node.body, _coderep.Precedence.Assignment, body), semiOp());
}
}
}, {
key: "reduceExportFromSpecifier",
key: 'reduceExportFromSpecifier',
value: function reduceExportFromSpecifier(node) {
if (node.exportedName == null) return t(node.name);
return seq(t(node.name), t("as"), t(node.exportedName));
return seq(t(node.name), t('as'), t(node.exportedName));
}
}, {
key: "reduceExportLocalSpecifier",
key: 'reduceExportLocalSpecifier',
value: function reduceExportLocalSpecifier(node, _ref47) {

@@ -755,13 +762,13 @@ var name = _ref47.name;

if (node.exportedName == null) return name;
return seq(name, t("as"), t(node.exportedName));
return seq(name, t('as'), t(node.exportedName));
}
}, {
key: "reduceLabeledStatement",
key: 'reduceLabeledStatement',
value: function reduceLabeledStatement(node, _ref48) {
var body = _ref48.body;
return (0, _objectAssign2.default)(seq(t(node.label + ":"), body), { endsWithMissingElse: body.endsWithMissingElse });
return (0, _objectAssign2.default)(seq(t(node.label + ':'), body), { endsWithMissingElse: body.endsWithMissingElse });
}
}, {
key: "reduceLiteralBooleanExpression",
key: 'reduceLiteralBooleanExpression',
value: function reduceLiteralBooleanExpression(node) {

@@ -771,13 +778,13 @@ return t(node.value.toString());

}, {
key: "reduceLiteralNullExpression",
value: function reduceLiteralNullExpression(node) {
return t("null");
key: 'reduceLiteralNullExpression',
value: function reduceLiteralNullExpression() /* node */{
return t('null');
}
}, {
key: "reduceLiteralInfinityExpression",
value: function reduceLiteralInfinityExpression(node) {
return t("2e308");
key: 'reduceLiteralInfinityExpression',
value: function reduceLiteralInfinityExpression() /* node */{
return t('2e308');
}
}, {
key: "reduceLiteralNumericExpression",
key: 'reduceLiteralNumericExpression',
value: function reduceLiteralNumericExpression(node) {

@@ -787,8 +794,8 @@ return new _coderep.NumberCodeRep(node.value);

}, {
key: "reduceLiteralRegExpExpression",
key: 'reduceLiteralRegExpExpression',
value: function reduceLiteralRegExpExpression(node) {
return t("/" + node.pattern + "/" + (node.global ? 'g' : '') + (node.ignoreCase ? 'i' : '') + (node.multiLine ? 'm' : '') + (node.unicode ? 'u' : '') + (node.sticky ? 'y' : ''), true);
return t('/' + node.pattern + '/' + (node.global ? 'g' : '') + (node.ignoreCase ? 'i' : '') + (node.multiLine ? 'm' : '') + (node.unicode ? 'u' : '') + (node.sticky ? 'y' : ''), true);
}
}, {
key: "reduceLiteralStringExpression",
key: 'reduceLiteralStringExpression',
value: function reduceLiteralStringExpression(node) {

@@ -798,3 +805,3 @@ return t((0, _coderep.escapeStringLiteral)(node.value));

}, {
key: "reduceMethod",
key: 'reduceMethod',
value: function reduceMethod(node, _ref49) {

@@ -805,6 +812,6 @@ var name = _ref49.name,

return seq(node.isGenerator ? t("*") : empty(), name, paren(params), brace(body));
return seq(node.isGenerator ? t('*') : empty(), name, params, body);
}
}, {
key: "reduceModule",
key: 'reduceModule',
value: function reduceModule(node, _ref50) {

@@ -820,3 +827,3 @@ var directives = _ref50.directives,

}, {
key: "reduceNewExpression",
key: 'reduceNewExpression',
value: function reduceNewExpression(node, _ref51) {

@@ -829,12 +836,12 @@ var callee = _ref51.callee,

});
var calleeRep = (0, _coderep.getPrecedence)(node.callee) == _coderep.Precedence.Call ? paren(callee) : p(node.callee, (0, _coderep.getPrecedence)(node), callee);
return seq(t("new"), calleeRep, args.length === 0 ? empty() : paren(commaSep(parenthizedArgs)));
var calleeRep = (0, _coderep.getPrecedence)(node.callee) === _coderep.Precedence.Call ? paren(callee) : p(node.callee, (0, _coderep.getPrecedence)(node), callee);
return seq(t('new'), calleeRep, args.length === 0 ? empty() : paren(commaSep(parenthizedArgs)));
}
}, {
key: "reduceNewTargetExpression",
key: 'reduceNewTargetExpression',
value: function reduceNewTargetExpression() {
return t("new.target");
return t('new.target');
}
}, {
key: "reduceObjectExpression",
key: 'reduceObjectExpression',
value: function reduceObjectExpression(node, _ref52) {

@@ -848,3 +855,3 @@ var properties = _ref52.properties;

}, {
key: "reduceUpdateExpression",
key: 'reduceUpdateExpression',
value: function reduceUpdateExpression(node, _ref53) {

@@ -855,12 +862,11 @@ var operand = _ref53.operand;

return this.reduceUnaryExpression.apply(this, arguments);
} else {
return (0, _objectAssign2.default)(seq(p(node.operand, _coderep.Precedence.New, operand), t(node.operator)), {
startsWithCurly: operand.startsWithCurly,
startsWithLetSquareBracket: operand.startsWithLetSquareBracket,
startsWithFunctionOrClass: operand.startsWithFunctionOrClass
});
}
return (0, _objectAssign2.default)(seq(p(node.operand, _coderep.Precedence.New, operand), t(node.operator)), {
startsWithCurly: operand.startsWithCurly,
startsWithLetSquareBracket: operand.startsWithLetSquareBracket,
startsWithFunctionOrClass: operand.startsWithFunctionOrClass
});
}
}, {
key: "reduceUnaryExpression",
key: 'reduceUnaryExpression',
value: function reduceUnaryExpression(node, _ref54) {

@@ -872,10 +878,10 @@ var operand = _ref54.operand;

}, {
key: "reduceReturnStatement",
key: 'reduceReturnStatement',
value: function reduceReturnStatement(node, _ref55) {
var expression = _ref55.expression;
return seq(t("return"), expression || empty(), semiOp());
return seq(t('return'), expression || empty(), semiOp());
}
}, {
key: "reduceScript",
key: 'reduceScript',
value: function reduceScript(node, _ref56) {

@@ -891,3 +897,3 @@ var directives = _ref56.directives,

}, {
key: "reduceSetter",
key: 'reduceSetter',
value: function reduceSetter(node, _ref57) {

@@ -898,6 +904,6 @@ var name = _ref57.name,

return seq(t("set"), name, paren(param), brace(body));
return seq(t('set'), name, paren(param), body);
}
}, {
key: "reduceShorthandProperty",
key: 'reduceShorthandProperty',
value: function reduceShorthandProperty(node, _ref58) {

@@ -909,7 +915,7 @@ var name = _ref58.name;

}, {
key: "reduceStaticMemberAssignmentTarget",
key: 'reduceStaticMemberAssignmentTarget',
value: function reduceStaticMemberAssignmentTarget(node, _ref59) {
var object = _ref59.object;
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t("."), t(node.property));
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t('.'), t(node.property));
state.startsWithLet = object.startsWithLet;

@@ -922,7 +928,7 @@ state.startsWithCurly = object.startsWithCurly;

}, {
key: "reduceStaticMemberExpression",
key: 'reduceStaticMemberExpression',
value: function reduceStaticMemberExpression(node, _ref60) {
var object = _ref60.object;
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t("."), t(node.property));
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t('.'), t(node.property));
state.startsWithLet = object.startsWithLet;

@@ -935,3 +941,3 @@ state.startsWithCurly = object.startsWithCurly;

}, {
key: "reduceStaticPropertyName",
key: 'reduceStaticPropertyName',
value: function reduceStaticPropertyName(node) {

@@ -948,8 +954,8 @@ if (_esutils.keyword.isIdentifierNameES6(node.value)) {

}, {
key: "reduceSuper",
key: 'reduceSuper',
value: function reduceSuper() {
return t("super");
return t('super');
}
}, {
key: "reduceSwitchCase",
key: 'reduceSwitchCase',
value: function reduceSwitchCase(node, _ref61) {

@@ -959,13 +965,13 @@ var test = _ref61.test,

return seq(t("case"), test, t(":"), seq.apply(undefined, _toConsumableArray(consequent)));
return seq(t('case'), test, t(':'), seq.apply(undefined, _toConsumableArray(consequent)));
}
}, {
key: "reduceSwitchDefault",
key: 'reduceSwitchDefault',
value: function reduceSwitchDefault(node, _ref62) {
var consequent = _ref62.consequent;
return seq(t("default:"), seq.apply(undefined, _toConsumableArray(consequent)));
return seq(t('default:'), seq.apply(undefined, _toConsumableArray(consequent)));
}
}, {
key: "reduceSwitchStatement",
key: 'reduceSwitchStatement',
value: function reduceSwitchStatement(node, _ref63) {

@@ -975,6 +981,6 @@ var discriminant = _ref63.discriminant,

return seq(t("switch"), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(cases))));
return seq(t('switch'), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(cases))));
}
}, {
key: "reduceSwitchStatementWithDefault",
key: 'reduceSwitchStatementWithDefault',
value: function reduceSwitchStatementWithDefault(node, _ref64) {

@@ -986,6 +992,6 @@ var discriminant = _ref64.discriminant,

return seq(t("switch"), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases)))));
return seq(t('switch'), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases)))));
}
}, {
key: "reduceTemplateExpression",
key: 'reduceTemplateExpression',
value: function reduceTemplateExpression(node, _ref65) {

@@ -996,11 +1002,6 @@ var tag = _ref65.tag,

var state = node.tag == null ? empty() : p(node.tag, (0, _coderep.getPrecedence)(node), tag);
var templateData = "";
state = seq(state, t("`"));
state = seq(state, t('`'));
for (var i = 0, l = node.elements.length; i < l; ++i) {
if (node.elements[i].type === "TemplateElement") {
var d = "";
if (i > 0) d += "}";
d += node.elements[i].rawValue;
if (i < l - 1) d += "${";
state = seq(state, t(d));
if (node.elements[i].type === 'TemplateElement') {
state = seq(state, i > 0 ? t('}') : empty(), elements[i], i < l - 1 ? t('${') : empty());
} else {

@@ -1010,3 +1011,3 @@ state = seq(state, elements[i]);

}
state = seq(state, t("`"));
state = seq(state, t('`'));
if (node.tag != null) {

@@ -1020,20 +1021,20 @@ state.startsWithCurly = tag.startsWithCurly;

}, {
key: "reduceTemplateElement",
key: 'reduceTemplateElement',
value: function reduceTemplateElement(node) {
return t(node.rawValue);
return new _coderep.RawToken(node.rawValue);
}
}, {
key: "reduceThisExpression",
value: function reduceThisExpression(node) {
return t("this");
key: 'reduceThisExpression',
value: function reduceThisExpression() /* node */{
return t('this');
}
}, {
key: "reduceThrowStatement",
key: 'reduceThrowStatement',
value: function reduceThrowStatement(node, _ref66) {
var expression = _ref66.expression;
return seq(t("throw"), expression, semiOp());
return seq(t('throw'), expression, semiOp());
}
}, {
key: "reduceTryCatchStatement",
key: 'reduceTryCatchStatement',
value: function reduceTryCatchStatement(node, _ref67) {

@@ -1043,6 +1044,6 @@ var body = _ref67.body,

return seq(t("try"), body, catchClause);
return seq(t('try'), body, catchClause);
}
}, {
key: "reduceTryFinallyStatement",
key: 'reduceTryFinallyStatement',
value: function reduceTryFinallyStatement(node, _ref68) {

@@ -1053,27 +1054,27 @@ var body = _ref68.body,

return seq(t("try"), body, catchClause || empty(), t("finally"), finalizer);
return seq(t('try'), body, catchClause || empty(), t('finally'), finalizer);
}
}, {
key: "reduceYieldExpression",
key: 'reduceYieldExpression',
value: function reduceYieldExpression(node, _ref69) {
var expression = _ref69.expression;
if (node.expression == null) return t("yield");
return (0, _objectAssign2.default)(seq(t("yield"), p(node.expression, (0, _coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn });
if (node.expression == null) return t('yield');
return (0, _objectAssign2.default)(seq(t('yield'), p(node.expression, (0, _coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn });
}
}, {
key: "reduceYieldGeneratorExpression",
key: 'reduceYieldGeneratorExpression',
value: function reduceYieldGeneratorExpression(node, _ref70) {
var expression = _ref70.expression;
return (0, _objectAssign2.default)(seq(t("yield"), t("*"), p(node.expression, (0, _coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn });
return (0, _objectAssign2.default)(seq(t('yield'), t('*'), p(node.expression, (0, _coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn });
}
}, {
key: "reduceDirective",
key: 'reduceDirective',
value: function reduceDirective(node) {
var delim = node.rawValue.match(/(^|[^\\])(\\\\)*"/) ? "'" : '"';
var delim = node.rawValue.match(/(^|[^\\])(\\\\)*"/) ? '\'' : '"';
return seq(t(delim + node.rawValue + delim), semiOp());
}
}, {
key: "reduceVariableDeclaration",
key: 'reduceVariableDeclaration',
value: function reduceVariableDeclaration(node, _ref71) {

@@ -1085,3 +1086,3 @@ var declarators = _ref71.declarators;

}, {
key: "reduceVariableDeclarationStatement",
key: 'reduceVariableDeclarationStatement',
value: function reduceVariableDeclarationStatement(node, _ref72) {

@@ -1093,3 +1094,3 @@ var declaration = _ref72.declaration;

}, {
key: "reduceVariableDeclarator",
key: 'reduceVariableDeclarator',
value: function reduceVariableDeclarator(node, _ref73) {

@@ -1107,6 +1108,6 @@ var binding = _ref73.binding,

}
return (0, _objectAssign2.default)(init == null ? binding : seq(binding, t("="), init), { containsIn: containsIn });
return (0, _objectAssign2.default)(init == null ? binding : seq(binding, t('='), init), { containsIn: containsIn });
}
}, {
key: "reduceWhileStatement",
key: 'reduceWhileStatement',
value: function reduceWhileStatement(node, _ref74) {

@@ -1116,6 +1117,6 @@ var test = _ref74.test,

return (0, _objectAssign2.default)(seq(t("while"), paren(test), body), { endsWithMissingElse: body.endsWithMissingElse });
return (0, _objectAssign2.default)(seq(t('while'), paren(test), body), { endsWithMissingElse: body.endsWithMissingElse });
}
}, {
key: "reduceWithStatement",
key: 'reduceWithStatement',
value: function reduceWithStatement(node, _ref75) {

@@ -1125,3 +1126,3 @@ var object = _ref75.object,

return (0, _objectAssign2.default)(seq(t("with"), paren(object), body), { endsWithMissingElse: body.endsWithMissingElse });
return (0, _objectAssign2.default)(seq(t('with'), paren(object), body), { endsWithMissingElse: body.endsWithMissingElse });
}

@@ -1128,0 +1129,0 @@ }]);

{
"name": "shift-codegen",
"version": "5.0.5",
"version": "5.1.0",
"description": "code generator for Shift format ASTs",

@@ -18,19 +18,21 @@ "author": "Shape Security",

"build": "babel --source-maps-inline --out-dir dist src",
"cjsify": "cjsify --export ShiftCodegen dist/index.js > shift-codegen.js",
"prepublish": "rm -rf dist/* && npm update && npm run build"
"lint": "eslint src test",
"prepare": "rm -rf dist/* && npm run build"
},
"dependencies": {
"babel-eslint": "^8.2.2",
"esutils": "^2.0.2",
"object-assign": "^4.1.0",
"shift-reducer": "^4.0.0"
"shift-reducer": "^4.3.0"
},
"devDependencies": {
"babel-cli": "6.3.13",
"babel-preset-es2015": "6.3.13",
"babel-register": "6.3.13",
"babel-preset-es2015": "6.3.13",
"commonjs-everywhere": "0.9.7",
"eslint": "^4.18.2",
"everything.js": "^1.0.3",
"expect.js": "0.3.1",
"mocha": "2.2.5",
"shift-parser": "5.0.0"
"shift-parser-expectations": "2016.0.1",
"shift-parser": "5.2.4"
},

@@ -37,0 +39,0 @@ "keywords": [

@@ -27,3 +27,13 @@ Shift Code Generator

Location information is available in environments which support WeakMap via an alternative interface:
```js
let tree = parseScript('foo(); bar;');
import { codeGenWithLocation } from "shift-codegen";
let { source, locations } = codeGenWithLocation(tree);
source; // 'foo();bar';
locations.get(tree.statements[0].expression); // { start: { line: 1, column: 0, offset: 0 }, end: { line: 1, column: 5, offset: 5 } }
```
## Contributing

@@ -30,0 +40,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc