Compare commits

...

3 Commits

Author SHA1 Message Date
Sebastian McKenzie
12f66e852a v1.11.3 2014-11-10 00:22:09 +11:00
Sebastian McKenzie
c61c9aab56 remove invalid ObjectPattern assignment 2014-11-10 00:19:37 +11:00
Sebastian McKenzie
7adc919bb6 remove invalid ObjectPattern destructuring assignment 2014-11-10 00:18:01 +11:00
6 changed files with 7 additions and 35 deletions

View File

@@ -11,21 +11,7 @@ var buildVariableAssign = function (kind, id, init) {
}
};
var normalise = function (node) {
if (t.isParenthesizedExpression(node)) {
return node.expression;
} else {
return node;
}
};
var isPattern = function (node) {
return t.isPattern(normalise(node));
};
var push = function (kind, nodes, elem, parentId) {
elem = normalise(elem);
if (t.isObjectPattern(elem)) {
pushObjectPattern(kind, nodes, elem, parentId);
} else if (t.isArrayPattern(elem)) {
@@ -42,7 +28,7 @@ var pushObjectPattern = function (kind, nodes, pattern, parentId) {
var pattern2 = prop.value;
var patternId2 = t.memberExpression(parentId, prop.key);
if (isPattern(pattern2)) {
if (t.isPattern(pattern2)) {
push(kind, nodes, pattern2, patternId2);
} else {
nodes.push(buildVariableAssign(kind, pattern2, patternId2));
@@ -94,7 +80,7 @@ exports.ForOfStatement = function (node, parent, file, scope) {
if (!t.isVariableDeclaration(declar)) return;
var pattern = declar.declarations[0].id;
if (!isPattern(pattern)) return;
if (!t.isPattern(pattern)) return;
var key = t.identifier(file.generateUid("ref", scope));
node.left = t.variableDeclaration(declar.kind, [
@@ -117,7 +103,7 @@ exports.Function = function (node, parent, file, scope) {
var hasDestructuring = false;
node.params = node.params.map(function (pattern) {
if (!isPattern(pattern)) return pattern;
if (!t.isPattern(pattern)) return pattern;
hasDestructuring = true;
var parentId = t.identifier(file.generateUid("ref", scope));
@@ -146,7 +132,7 @@ exports.ExpressionStatement = function (node, parent, file, scope) {
var expr = node.expression;
if (expr.type !== "AssignmentExpression") return;
if (!isPattern(expr.left)) return;
if (!t.isPattern(expr.left)) return;
var nodes = [];
@@ -167,7 +153,7 @@ exports.VariableDeclaration = function (node, parent, file, scope) {
var hasPattern = false;
_.each(node.declarations, function (declar) {
if (isPattern(declar.id)) {
if (t.isPattern(declar.id)) {
hasPattern = true;
return false;
}

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "1.11.2",
"version": "1.11.3",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -48,7 +48,7 @@
"chokidar": "0.10.5",
"source-map-support": "0.2.8",
"esutils": "1.1.4",
"acorn-6to5": "https://github.com/6to5/acorn-6to5/archive/f5110383517eef0bea78c2da2a1fb01fbed74e4e.tar.gz",
"acorn-6to5": "https://github.com/6to5/acorn-6to5/archive/49e421660af161af0e75c2fa066ea356d6650e69.tar.gz",
"estraverse": "^1.7.0"
},
"devDependencies": {

View File

@@ -1,5 +0,0 @@
({ t: t }) = obj;
({
t: { C: C }
}) = obj;
({ a, b, c }) = obj;

View File

@@ -1,5 +0,0 @@
({ t: t }) = obj;
({
t: { C: C }
}) = obj;
({ a, b, c }) = obj;

View File

@@ -1,2 +1 @@
[a, b] = f();
({ x }) = e();

View File

@@ -4,6 +4,3 @@ var _ref = f();
a = _ref[0];
b = _ref[1];
var _ref2 = e();
x = _ref2.x;