@babel/helper-simple-access
Advanced tools
Comparing version 7.0.0-beta.44 to 7.0.0-beta.45
@@ -42,9 +42,15 @@ "use strict"; | ||
if (path.node.prefix || path.parentPath.isExpressionStatement() && !path.isCompletionRecord()) { | ||
if (path.parentPath.isExpressionStatement() && !path.isCompletionRecord()) { | ||
var operator = path.node.operator == "++" ? "+=" : "-="; | ||
path.replaceWith(t().assignmentExpression(operator, arg.node, t().numericLiteral(1))); | ||
} else if (path.node.prefix) { | ||
path.replaceWith(t().assignmentExpression("=", t().identifier(localName), t().binaryExpression(path.node.operator[0], t().unaryExpression("+", arg.node), t().numericLiteral(1)))); | ||
} else { | ||
var varName = path.scope.generateDeclaredUidIdentifier("old").name; | ||
var binary = t().binaryExpression(path.node.operator.slice(0, 1), t().identifier(varName), t().numericLiteral(1)); | ||
path.replaceWith(t().sequenceExpression([t().assignmentExpression("=", t().identifier(varName), arg.node), t().assignmentExpression("=", t().cloneNode(arg.node), binary), t().identifier(varName)])); | ||
var old = path.scope.generateUidIdentifierBasedOnNode(arg.node, "old"); | ||
var varName = old.name; | ||
path.scope.push({ | ||
id: old | ||
}); | ||
var binary = t().binaryExpression(path.node.operator[0], t().identifier(varName), t().numericLiteral(1)); | ||
path.replaceWith(t().sequenceExpression([t().assignmentExpression("=", t().identifier(varName), t().unaryExpression("+", arg.node)), t().assignmentExpression("=", t().cloneNode(arg.node), binary), t().identifier(varName)])); | ||
} | ||
@@ -51,0 +57,0 @@ } |
{ | ||
"name": "@babel/helper-simple-access", | ||
"version": "7.0.0-beta.44", | ||
"version": "7.0.0-beta.45", | ||
"description": "Babel helper for ensuring that access to a given value is performed through simple accesses", | ||
@@ -11,6 +11,6 @@ "author": "Logan Smyth <loganfsmyth@gmail.com>", | ||
"dependencies": { | ||
"@babel/template": "7.0.0-beta.44", | ||
"@babel/types": "7.0.0-beta.44", | ||
"@babel/template": "7.0.0-beta.45", | ||
"@babel/types": "7.0.0-beta.45", | ||
"lodash": "^4.2.0" | ||
} | ||
} |
4144
68
+ Added@babel/code-frame@7.0.0-beta.45(transitive)
+ Added@babel/highlight@7.0.0-beta.45(transitive)
+ Added@babel/template@7.0.0-beta.45(transitive)
+ Added@babel/types@7.0.0-beta.45(transitive)
+ Addedbabylon@7.0.0-beta.45(transitive)
- Removed@babel/code-frame@7.0.0-beta.44(transitive)
- Removed@babel/highlight@7.0.0-beta.44(transitive)
- Removed@babel/template@7.0.0-beta.44(transitive)
- Removed@babel/types@7.0.0-beta.44(transitive)
- Removedbabylon@7.0.0-beta.44(transitive)
Updated@babel/types@7.0.0-beta.45