Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function UpdateExpression(node, parent) {
if (!bt.isExpressionStatement(parent)) {
// FIXME: Use path.buildCodeFrameError
throw new Error("UpdateExpression's not in ExpressionStatement's are not supported.");
}
if (node.operator !== '++' && node.operator !== '--') {
// FIXME: Use path.buildCodeFrameError
throw new Error(`Invalid UpdateExpression operator ${node.operator}`);
}
const right = t.binaryExpression(
node.operator === '++' ? '+' : '-',
this.transform(node.argument),
t.numericLiteral(1),
);
return t.assignmentStatement([this.transform(node.argument)], [right]);
}
export function NumericLiteral(node) {
return t.numericLiteral(node.value);
}
export function SequenceExpression(node) {
return t.indexExpression(
t.tableConstructorExpression(this.transformList(node.expressions).map(n => t.tableValue(n))),
t.numericLiteral(node.expressions.length),
);
}