add destructuring support

This commit is contained in:
Sebastian McKenzie
2014-09-29 18:29:08 +10:00
parent dbf25a82ee
commit 0e19006641
15 changed files with 140 additions and 4 deletions

View File

@@ -0,0 +1 @@
var [a, [b], [c], d] = ["hello", [", ", "junk"], ["world"]];

View File

@@ -0,0 +1,5 @@
var _ref = ["hello", [", ", "junk"], ["world"]];
var a = _ref[0];
var b = _ref[1][0];
var c = _ref[2][0];
var d = _ref[3];

View File

@@ -0,0 +1 @@
var {topLeft: [x1, y1], bottomRight: [x2, y2] } = rect;

View File

@@ -0,0 +1,4 @@
var x1 = rect.topLeft[0];
var y1 = rect.topLeft[1];
var x2 = rect.bottomRight[0];
var y2 = rect.bottomRight[1];

View File

@@ -0,0 +1 @@
var { x, y } = coords, foo = "bar";

View File

@@ -0,0 +1,3 @@
var x = coords.x;
var y = coords.y;
var foo = "bar";

View File

@@ -0,0 +1 @@
var {topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}} = rect;

View File

@@ -0,0 +1,4 @@
var x1 = rect.topLeft.x;
var y1 = rect.topLeft.y;
var x2 = rect.bottomRight.x;
var y2 = rect.bottomRight.y;

View File

@@ -0,0 +1 @@
var { x, y } = coords;

View File

@@ -0,0 +1,2 @@
var x = coords.x;
var y = coords.y;