support destructuring in parameter lists - closes #19
This commit is contained in:
15
test/fixtures/destructuring/parameters/actual.js
vendored
Normal file
15
test/fixtures/destructuring/parameters/actual.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
function somethingAdvanced({topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}}){
|
||||
|
||||
}
|
||||
|
||||
function unpackObject({title: title, author: author}) {
|
||||
return title + ' ' + author;
|
||||
}
|
||||
|
||||
console.log(unpackObject({title: 'title', author: 'author'}));
|
||||
|
||||
var unpackArray = function ([a, b, c], [x, y, z]) {
|
||||
return a+b+c;
|
||||
};
|
||||
|
||||
console.log(unpackArray(['hello', ', ', 'world'], [1, 2, 3]));
|
||||
28
test/fixtures/destructuring/parameters/expected.js
vendored
Normal file
28
test/fixtures/destructuring/parameters/expected.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
function somethingAdvanced(_ref){
|
||||
var x1 = _ref.topLeft.x;
|
||||
var y1 = _ref.topLeft.y;
|
||||
var x2 = _ref.bottomRight.x;
|
||||
var y2 = _ref.bottomRight.y;
|
||||
}
|
||||
|
||||
function unpackObject(_ref2) {
|
||||
var title = _ref2.title;
|
||||
var author = _ref2.author;
|
||||
return title + ' ' + author;
|
||||
}
|
||||
|
||||
console.log(unpackObject({title: 'title', author: 'author'}));
|
||||
|
||||
var unpackArray = function (_ref3, _ref4) {
|
||||
var a = _ref3[0];
|
||||
var b = _ref3[1];
|
||||
var c = _ref3[2];
|
||||
|
||||
var x = _ref4[0];
|
||||
var y = _ref4[1];
|
||||
var z = _ref4[2];
|
||||
|
||||
return a + b + c;
|
||||
};
|
||||
|
||||
console.log(unpackArray(['hello', ', ', 'world'], [1, 2, 3]));
|
||||
Reference in New Issue
Block a user