alongubkin / alongubkin/spider

More powerful destructuring

未关闭
#111 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
proposal
主要语言
JavaScript
星标
1.3k
派生
46
PR 合并指标
30 天内没有已合并 PR

描述

Spider already supports:

```
var [a, b] = [1, 2];
[a, ,b] = [1, 2, 3];
[a, b] = [b, a];
```

Spider also supports splats `...rest`.

Spider should support the following (It may support some of these already):

```
var {a, b} = {a: 1, b: 2};
var {first: a, last: b} = {first: 1, last: 2};
var [a, b, ...rest] = [1, 2, 3, 4, 5];
var {a, b, ...rest} = {a: 1, b: 2, c: 3, d: 4}; // rest = {c:3, d:4}
```

Also in function parameters:

```
fn obj({x, y, z}, color){...}

// which is called like this:
obj({x: 1, y: 2, z: 3}, 'blue');
```

This would all be extremely useful in a lot of places, and are features that libraries like React will soon depend on. Most of these features are part of ES6. the `...rest` in an object is not, but it is a proposal. JSX will be adding support for it anyway.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。