regenerator-transform
Advanced tools
Comparing version 0.13.1 to 0.13.2
@@ -896,4 +896,17 @@ "use strict"; | ||
case "AssignmentExpression": | ||
return finish(t.assignmentExpression(expr.operator, self.explodeExpression(path.get("left")), self.explodeExpression(path.get("right")))); | ||
var lhs = self.explodeExpression(path.get("left")); | ||
var temp = self.emitAssign(self.makeTempVar(), lhs); // For example, | ||
// | ||
// x += yield y | ||
// | ||
// becomes | ||
// | ||
// context.t0 = x | ||
// x = context.t0 += yield y | ||
// | ||
// so that the left-hand side expression is read before the yield. | ||
// Fixes https://github.com/facebook/regenerator/issues/345. | ||
return finish(t.assignmentExpression("=", t.cloneDeep(lhs), t.assignmentExpression(expr.operator, t.cloneDeep(temp), self.explodeExpression(path.get("right"))))); | ||
case "UpdateExpression": | ||
@@ -900,0 +913,0 @@ return finish(t.updateExpression(expr.operator, self.explodeExpression(path.get("argument")), expr.prefix)); |
@@ -5,3 +5,3 @@ { | ||
"description": "Explode async and generator functions into a state machine.", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"main": "lib/index.js", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
@@ -1172,6 +1172,25 @@ /** | ||
case "AssignmentExpression": | ||
const lhs = self.explodeExpression(path.get("left")); | ||
const temp = self.emitAssign(self.makeTempVar(), lhs); | ||
// For example, | ||
// | ||
// x += yield y | ||
// | ||
// becomes | ||
// | ||
// context.t0 = x | ||
// x = context.t0 += yield y | ||
// | ||
// so that the left-hand side expression is read before the yield. | ||
// Fixes https://github.com/facebook/regenerator/issues/345. | ||
return finish(t.assignmentExpression( | ||
expr.operator, | ||
self.explodeExpression(path.get("left")), | ||
self.explodeExpression(path.get("right")) | ||
"=", | ||
t.cloneDeep(lhs), | ||
t.assignmentExpression( | ||
expr.operator, | ||
t.cloneDeep(temp), | ||
self.explodeExpression(path.get("right")) | ||
) | ||
)); | ||
@@ -1178,0 +1197,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123055
3211