Fix destructuring in pipeline operator (#6515)
* Fix destructuring in pipeline operator Fixes #6514. * Run exec only on node 6
This commit is contained in:
parent
923fd4705e
commit
8d4674ca5a
@ -18,9 +18,9 @@ export default function({ types: t }) {
|
||||
|
||||
if (optimizeArrow) {
|
||||
const { params } = right;
|
||||
if (params.length === 1) {
|
||||
if (params.length === 1 && t.isIdentifier(params[0])) {
|
||||
param = params[0];
|
||||
} else if (params.length > 1) {
|
||||
} else if (params.length > 0) {
|
||||
optimizeArrow = false;
|
||||
}
|
||||
} else if (t.isIdentifier(right, { name: "eval" })) {
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
// Array destructing
|
||||
const result = [0] |> ([x]) => x;
|
||||
assert.equal(result, 0);
|
||||
|
||||
// Object destructuring
|
||||
const result2 = { y: 1, z: 2 } |> ({ y, z }) => y + z;
|
||||
assert.equal(result, 3);
|
||||
@ -0,0 +1,7 @@
|
||||
// Array destructing
|
||||
const result = [0] |> ([x]) => x;
|
||||
assert.equal(result, 0);
|
||||
|
||||
// Object destructuring
|
||||
const result2 = { y: 1, z: 2 } |> ({ y, z }) => y + z;
|
||||
assert.equal(result2, 3);
|
||||
@ -0,0 +1,14 @@
|
||||
var _ref, _y$z;
|
||||
|
||||
// Array destructing
|
||||
const result = (_ref = [0], (([x]) => x)(_ref));
|
||||
assert.equal(result, 0); // Object destructuring
|
||||
|
||||
const result2 = (_y$z = {
|
||||
y: 1,
|
||||
z: 2
|
||||
}, (({
|
||||
y,
|
||||
z
|
||||
}) => y + z)(_y$z));
|
||||
assert.equal(result, 3);
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"minNodeVersion": "6.0.0"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user