I want to disagree with you about renaming kata http://tddbin.com/#?kata=es6/language/destructuring/rename. I think there is no renaming. Let me explain my point of view.
We have this code [1]:
const {x: y} = {x: 1};
assert.equal(y, 1);
It is equivalent to [2]:
const {x: x} = {x: 1};
assert.equal(x, 1);
Which is in turn equivalent to [3]:
const {x} = {x: 1};
assert.equal(x, 1);
So in snippet 3 we have a case of shorthanding the destructuring assignment. Basically it means: destructure an object which has a property by the name "x" and assign it's value to a variable named "x". The explicit version of this is in snippet 2.
Snippet 1 on the other hand tells: destructure an object which has a property by the name "x" and assign it's value to a variable named "y".
There is no renaming of any kind, just a classical destructuring.
We can see this in specs: http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment. The grammar reads as follows:
AssignmentProperty[Yield] :
IdentifierReference[?Yield] Initializer[In,?Yield]opt
PropertyName : AssignmentElement[?Yield]
AssignmentElement[Yield] :
DestructuringAssignmentTarget[?Yield] Initializer[In,?Yield]opt
So we have a "PropertyName" and an "AssignmentElement", which is no more than a "DestructuringAssignmentTarget" with an optional "Initializer".
In out example:
const {
x: // PropertyName
y // DestructuringAssignmentTarget
} = {x: 1};
or even:
const {
x: // PropertyName
y // DestructuringAssignmentTarget
=42 // Initializer
} = {y: 23};
I want to disagree with you about renaming kata http://tddbin.com/#?kata=es6/language/destructuring/rename. I think there is no renaming. Let me explain my point of view.
We have this code [1]:
const {x: y} = {x: 1};
assert.equal(y, 1);
It is equivalent to [2]:
const {x: x} = {x: 1};
assert.equal(x, 1);
Which is in turn equivalent to [3]:
const {x} = {x: 1};
assert.equal(x, 1);
So in snippet 3 we have a case of shorthanding the destructuring assignment. Basically it means: destructure an object which has a property by the name "x" and assign it's value to a variable named "x". The explicit version of this is in snippet 2.
Snippet 1 on the other hand tells: destructure an object which has a property by the name "x" and assign it's value to a variable named "y".
There is no renaming of any kind, just a classical destructuring.
We can see this in specs: http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment. The grammar reads as follows:
AssignmentProperty[Yield] :
IdentifierReference[?Yield] Initializer[In,?Yield]opt
PropertyName : AssignmentElement[?Yield]
AssignmentElement[Yield] :
DestructuringAssignmentTarget[?Yield] Initializer[In,?Yield]opt
So we have a "PropertyName" and an "AssignmentElement", which is no more than a "DestructuringAssignmentTarget" with an optional "Initializer".
In out example:
const {
x: // PropertyName
y // DestructuringAssignmentTarget
} = {x: 1};
or even:
const {
x: // PropertyName
y // DestructuringAssignmentTarget
=42 // Initializer
} = {y: 23};