| 1 |
var key, x, y, z; |
| 2 |
// impure |
| 3 |
key = 1; |
| 4 |
var _$a = { |
| 5 |
1: 1, |
| 6 |
a: 1 |
| 7 |
}, |
| 8 |
_key = key++, |
| 9 |
{ |
| 10 |
[_key]: y |
| 11 |
} = _$a, |
| 12 |
x = babelHelpers.objectWithoutProperties(_$a, [_key].map(babelHelpers.toPropertyKey)); |
| 13 |
expect(x).toEqual({ |
| 14 |
a: 1 |
| 15 |
}); |
| 16 |
expect(key).toBe(2); |
| 17 |
expect(y).toBe(1); |
| 18 |
|
| 19 |
// takes care of the order |
| 20 |
|
| 21 |
key = 1; |
| 22 |
var _$ = { |
| 23 |
2: 2, |
| 24 |
3: 3 |
| 25 |
}, |
| 26 |
_key2 = ++key, |
| 27 |
_key3 = ++key, |
| 28 |
{ |
| 29 |
[_key2]: y, |
| 30 |
[_key3]: z |
| 31 |
} = _$, |
| 32 |
rest = babelHelpers.objectWithoutProperties(_$, [_key2, _key3].map(babelHelpers.toPropertyKey)); |
| 33 |
expect(y).toBe(2); |
| 34 |
expect(z).toBe(3); |
| 35 |
|
| 36 |
// pure, computed property should remain as-is |
| 37 |
key = 2; |
| 38 |
var _$z = { |
| 39 |
2: "two", |
| 40 |
z: "zee" |
| 41 |
}; |
| 42 |
({ |
| 43 |
[key]: y, |
| 44 |
z |
| 45 |
} = _$z); |
| 46 |
x = babelHelpers.objectWithoutProperties(_$z, [key, "z"].map(babelHelpers.toPropertyKey)); |
| 47 |
_$z; |
| 48 |
expect(y).toBe("two"); |
| 49 |
expect(x).toEqual({}); |
| 50 |
expect(z).toBe("zee"); |