Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b599e2c794 | ||
|
|
7f57d3d6a2 | ||
|
|
a2b0ee6809 | ||
|
|
83e8c4bddd | ||
|
|
57aca3c77f | ||
|
|
f80527832c | ||
|
|
2ecceaac45 | ||
|
|
32f8f9e663 | ||
|
|
3447204d97 | ||
|
|
c500532469 | ||
|
|
3396cc84f1 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
||||
# 1.13.6
|
||||
|
||||
* Fix experimental object spread/rest helper.
|
||||
|
||||
# 1.13.5
|
||||
|
||||
* Upgrade `acorn-6to5`.
|
||||
* Add experimental support for object spread/rest.
|
||||
* Change `arguments` to array to an additional helper method.
|
||||
|
||||
# 1.13.4
|
||||
|
||||
* Fix single spread element returning itself.
|
||||
|
||||
# 1.13.3
|
||||
|
||||
* Upgrade `acorn-6to5`.
|
||||
|
||||
@@ -4,14 +4,15 @@ In order for certain features to work they require certain polyfills. You can
|
||||
satisfy **all** 6to5 feature requirements by using the included
|
||||
[polyfill](polyfill.md). You may alternatively selectively include what you need:
|
||||
|
||||
| Feature | Requirements |
|
||||
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Abstract References | `Symbol` |
|
||||
| Array destructuring | `Array.isArray`, `Array.from` |
|
||||
| Async functions, Generators | [experimental option](usage.md#experimental), [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js) |
|
||||
| Comprehensions | [experimental option](usage.md#experimental), `Array.isArray`, `Array.from` |
|
||||
| For..Of | `Symbol`, `prototype[Symbol.iterator]` |
|
||||
| Spread | `Array.isArray`, `Array.from` |
|
||||
| Feature | Requirements |
|
||||
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Abstract References | [experimental](usage.md#experimental), `Symbol` |
|
||||
| Array destructuring | `Array.isArray`, `Array.from` |
|
||||
| Async functions, Generators | [experimental](usage.md#experimental), [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js) |
|
||||
| Comprehensions | [experimental](usage.md#experimental), `Array.isArray`, `Array.from` |
|
||||
| For Of | `Symbol`, `prototype[Symbol.iterator]` |
|
||||
| Spread | `Array.isArray`, `Array.from` |
|
||||
| Object spread/rest | [experimental](usage.md#experimental), `Object.assign` |
|
||||
|
||||
## Classes
|
||||
|
||||
|
||||
@@ -88,13 +88,14 @@ better suited if you'd like a full ES6 environment with polyfills and all.
|
||||
| Rest parameters | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Spread | ✓ | ✓ | ✓ | ✓ | ✓ | |
|
||||
| Template literals | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Object rest/spread | ✓ | | | | | ✓ |
|
||||
| Unicode regex | ✓ | ✓ | ✓ | | | |
|
||||
|
||||
### [Traceur](https://github.com/google/traceur-compiler)
|
||||
|
||||
Traceur requires quite a bulky runtime (~75KB) and produces quite verbose code.
|
||||
While this can be trimmed down by selectively building the runtime, it's an
|
||||
unneccesary step when a runtime can be eliminated entirely.
|
||||
unneccesary step when a large runtime can be eliminated entirely.
|
||||
|
||||
### [es6now](https://github.com/zenparsing/es6now)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ foo::bar = baz;
|
||||
delete foo::bar;
|
||||
```
|
||||
|
||||
## Array comprehension ([experimental](usage.md#experimental))
|
||||
## Array comprehensions ([experimental](usage.md#experimental))
|
||||
|
||||
```javascript
|
||||
var results = [for (c of customers) if (c.city == "Seattle") { name: c.name, age: c.age }]
|
||||
@@ -158,7 +158,7 @@ for (var n of fibonacci()) {
|
||||
}
|
||||
```
|
||||
|
||||
## Generator comprehension ([experimental](usage.md#experimental))
|
||||
## Generator comprehensions ([experimental](usage.md#experimental))
|
||||
|
||||
```javascript
|
||||
var nums = [1, 2, 3, 4, 5, 6];
|
||||
@@ -253,6 +253,13 @@ var y = 10;
|
||||
console.log(`${x} + ${y} = ${x + y}`); // "5 + 10 = 15"
|
||||
```
|
||||
|
||||
## Object spread/rest ([experimental](usage.md#experimental)) ([spec](https://github.com/sebmarkbage/ecmascript-rest-spread))
|
||||
|
||||
```javascript
|
||||
var n = { x, y, ...z };
|
||||
var { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
|
||||
```
|
||||
|
||||
## Unicode regex
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -52,4 +52,5 @@ And it doesn't end here! To see all the ways you can use 6to5, check out the
|
||||
- [Rest parameters](features.md#rest-parameters)
|
||||
- [Spread](features.md#spread)
|
||||
- [Template literals](features.md#template-literals)
|
||||
- [Object Rest/Spread](features.md#object-rest-spread) ([experimental](usage.md#experimental))
|
||||
- [Unicode regex](features.md#unicode-regex)
|
||||
|
||||
@@ -18,8 +18,16 @@ function File(opts) {
|
||||
this.ast = {};
|
||||
}
|
||||
|
||||
File.declarations = ["extends", "class-props", "slice", "apply-constructor",
|
||||
"tagged-template-literal", "interop-require", "to-array"];
|
||||
File.declarations = [
|
||||
"extends",
|
||||
"class-props",
|
||||
"apply-constructor",
|
||||
"tagged-template-literal",
|
||||
"interop-require",
|
||||
"to-array",
|
||||
"arguments-to-array",
|
||||
"object-spread"
|
||||
];
|
||||
|
||||
File.normaliseOptions = function (opts) {
|
||||
opts = _.cloneDeep(opts || {});
|
||||
@@ -73,11 +81,14 @@ File.normaliseOptions = function (opts) {
|
||||
File.prototype.toArray = function (node) {
|
||||
if (t.isArrayExpression(node)) {
|
||||
return node;
|
||||
} else if (t.isIdentifier(node) && node.name === "arguments") {
|
||||
return t.callExpression(t.memberExpression(this.addDeclaration("slice"), t.identifier("call")), [node]);
|
||||
} else {
|
||||
return t.callExpression(this.addDeclaration("to-array"), [node]);
|
||||
}
|
||||
|
||||
var templateName = "to-array";
|
||||
if (t.isIdentifier(node) && node.name === "arguments") {
|
||||
templateName = "arguments-to-array";
|
||||
}
|
||||
|
||||
return t.callExpression(this.addDeclaration(templateName), [node]);
|
||||
};
|
||||
|
||||
File.prototype.getModuleFormatter = function (type) {
|
||||
|
||||
@@ -4,7 +4,8 @@ exports.Identifier = function (node) {
|
||||
this.push(node.name);
|
||||
};
|
||||
|
||||
exports.SpreadElement = function (node, print) {
|
||||
exports.SpreadElement =
|
||||
exports.SpreadProperty = function (node, print) {
|
||||
this.push("...");
|
||||
print(node.argument);
|
||||
};
|
||||
|
||||
@@ -9,6 +9,10 @@ exports.before = {
|
||||
}
|
||||
},
|
||||
|
||||
SpreadProperty: function (node, parent) {
|
||||
return exports.before.nodes.Property(node, parent);
|
||||
},
|
||||
|
||||
SwitchCase: function (node, parent) {
|
||||
if (parent.cases[0] === node) {
|
||||
return 1;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
var VARIABLE_NAME = SLICE_KEY.call(arguments, SLICE_ARG);
|
||||
@@ -1 +0,0 @@
|
||||
var VARIABLE_NAME = SLICE_KEY.call(arguments);
|
||||
@@ -1 +0,0 @@
|
||||
SLICE_KEY.call(arguments);
|
||||
7
lib/6to5/templates/arguments-to-array.js
Normal file
7
lib/6to5/templates/arguments-to-array.js
Normal file
@@ -0,0 +1,7 @@
|
||||
(function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i< args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
return target;
|
||||
})
|
||||
9
lib/6to5/templates/object-spread.js
Normal file
9
lib/6to5/templates/object-spread.js
Normal file
@@ -0,0 +1,9 @@
|
||||
(function (obj, keys) {
|
||||
var target = {};
|
||||
for (var i in obj) {
|
||||
if (keys.indexOf(i) >= 0) continue;
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
|
||||
target[i] = obj[i];
|
||||
}
|
||||
return target;
|
||||
})
|
||||
@@ -1 +0,0 @@
|
||||
Array.prototype.slice;
|
||||
@@ -38,6 +38,7 @@ _.each({
|
||||
_propertyLiterals: require("./transformers/_property-literals"),
|
||||
computedPropertyNames: require("./transformers/es6-computed-property-names"),
|
||||
|
||||
objectSpread: require("./transformers/es7-object-spread"),
|
||||
spread: require("./transformers/es6-spread"),
|
||||
templateLiterals: require("./transformers/es6-template-literals"),
|
||||
propertyMethodAssignment: require("./transformers/es5-property-method-assignment"),
|
||||
|
||||
@@ -24,14 +24,33 @@ var push = function (opts, nodes, elem, parentId) {
|
||||
};
|
||||
|
||||
var pushObjectPattern = function (opts, nodes, pattern, parentId) {
|
||||
_.each(pattern.properties, function (prop) {
|
||||
var pattern2 = prop.value;
|
||||
var patternId2 = t.memberExpression(parentId, prop.key, prop.computed);
|
||||
_.each(pattern.properties, function (prop, i) {
|
||||
if (t.isSpreadProperty(prop)) {
|
||||
// get all the keys that appear in this object before the current spread
|
||||
var keys = [];
|
||||
_.each(pattern.properties, function (prop2, i2) {
|
||||
if (i2 >= i) return false;
|
||||
if (t.isSpreadProperty(prop2)) return;
|
||||
|
||||
if (t.isPattern(pattern2)) {
|
||||
push(opts, nodes, pattern2, patternId2);
|
||||
var key = prop2.key;
|
||||
if (t.isIdentifier(key)) {
|
||||
key = t.literal(prop2.key.name);
|
||||
}
|
||||
keys.push(key);
|
||||
});
|
||||
keys = t.arrayExpression(keys);
|
||||
|
||||
var value = t.callExpression(opts.file.addDeclaration("object-spread"), [parentId, keys]);
|
||||
nodes.push(buildVariableAssign(opts.kind, prop.argument, value));
|
||||
} else {
|
||||
nodes.push(buildVariableAssign(opts.kind, pattern2, patternId2));
|
||||
var pattern2 = prop.value;
|
||||
var patternId2 = t.memberExpression(parentId, prop.key, prop.computed);
|
||||
|
||||
if (t.isPattern(pattern2)) {
|
||||
push(opts, nodes, pattern2, patternId2);
|
||||
} else {
|
||||
nodes.push(buildVariableAssign(opts.kind, pattern2, patternId2));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.Function = function (node, parent, file) {
|
||||
if (!node.rest) return;
|
||||
@@ -7,18 +6,20 @@ exports.Function = function (node, parent, file) {
|
||||
var rest = node.rest;
|
||||
delete node.rest;
|
||||
|
||||
var templateName = "arguments-slice-assign";
|
||||
if (node.params.length) templateName += "-arg";
|
||||
|
||||
t.ensureBlock(node);
|
||||
|
||||
var template = util.template(templateName, {
|
||||
SLICE_KEY: file.addDeclaration("slice"),
|
||||
VARIABLE_NAME: rest,
|
||||
SLICE_ARG: t.literal(node.params.length)
|
||||
});
|
||||
var call = t.callExpression(
|
||||
file.addDeclaration("arguments-to-array"),
|
||||
[t.identifier("arguments")]
|
||||
);
|
||||
|
||||
template.declarations[0].init.arguments[0]._ignoreAliasFunctions = true;
|
||||
if (node.params.length) {
|
||||
call = t.callExpression(t.memberExpression(call, t.identifier("slice")), [t.literal(node.params.length)]);
|
||||
}
|
||||
|
||||
node.body.body.unshift(template);
|
||||
call._ignoreAliasFunctions = true;
|
||||
|
||||
node.body.body.unshift(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(rest, call)
|
||||
]));
|
||||
};
|
||||
|
||||
@@ -48,7 +48,10 @@ exports.ArrayExpression = function (node, parent, file) {
|
||||
var nodes = build(elements, file);
|
||||
var first = nodes.shift();
|
||||
|
||||
if (!nodes.length) return first;
|
||||
if (!t.isArrayExpression(first)) {
|
||||
nodes.unshift(first);
|
||||
first = t.arrayExpression([]);
|
||||
}
|
||||
|
||||
return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
|
||||
};
|
||||
|
||||
41
lib/6to5/transformation/transformers/es7-object-spread.js
Normal file
41
lib/6to5/transformation/transformers/es7-object-spread.js
Normal file
@@ -0,0 +1,41 @@
|
||||
// https://github.com/sebmarkbage/ecmascript-rest-spread
|
||||
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.ObjectExpression = function (node) {
|
||||
var hasSpread = false;
|
||||
_.each(node.properties, function (prop) {
|
||||
if (t.isSpreadProperty(prop)) {
|
||||
hasSpread = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!hasSpread) return;
|
||||
|
||||
var args = [];
|
||||
var props = [];
|
||||
|
||||
var push = function () {
|
||||
if (!props.length) return;
|
||||
args.push(t.objectExpression(props));
|
||||
props = [];
|
||||
};
|
||||
|
||||
_.each(node.properties, function (prop) {
|
||||
if (t.isSpreadProperty(prop)) {
|
||||
push();
|
||||
args.push(prop.argument);
|
||||
} else {
|
||||
props.push(prop);
|
||||
}
|
||||
});
|
||||
|
||||
push();
|
||||
|
||||
if (!t.isObjectExpression(args[0])) {
|
||||
args.unshift(t.objectExpression([]));
|
||||
}
|
||||
|
||||
return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("assign")), args);
|
||||
};
|
||||
@@ -48,6 +48,7 @@
|
||||
"ReturnStatement": ["argument"],
|
||||
"SequenceExpression": ["expressions"],
|
||||
"SpreadElement": ["argument"],
|
||||
"SpreadProperty": ["argument"],
|
||||
"SwitchCase": ["test", "consequent"],
|
||||
"SwitchStatement": ["discriminant", "cases"],
|
||||
"TaggedTemplateExpression": ["tag", "quasi"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.13.3",
|
||||
"version": "1.13.6",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
@@ -47,7 +47,7 @@
|
||||
"chokidar": "0.11.1",
|
||||
"source-map-support": "0.2.8",
|
||||
"esutils": "1.1.6",
|
||||
"acorn-6to5": "0.9.1-5",
|
||||
"acorn-6to5": "0.9.1-6",
|
||||
"estraverse": "1.8.0",
|
||||
"private": "0.1.6"
|
||||
},
|
||||
|
||||
3
test/fixtures/generation/types/VirualPropertyExpression/actual.js
vendored
Normal file
3
test/fixtures/generation/types/VirualPropertyExpression/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
foo::bar;
|
||||
foo::bar = baz;
|
||||
delete foo::bar;
|
||||
3
test/fixtures/generation/types/VirualPropertyExpression/expected.js
vendored
Normal file
3
test/fixtures/generation/types/VirualPropertyExpression/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
foo::bar;
|
||||
foo::bar = baz;
|
||||
delete foo::bar;
|
||||
@@ -1,6 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var _argumentsToArray = function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
@@ -25,11 +33,11 @@ var Test = (function (Foo) {
|
||||
Foo.prototype.test.call(this);
|
||||
foob(Foo);
|
||||
|
||||
Foo.call.apply(Foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.call.apply(Foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
Foo.call.apply(Foo, [this].concat(_argumentsToArray(arguments)));
|
||||
Foo.call.apply(Foo, [this, "test"].concat(_argumentsToArray(arguments)));
|
||||
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this].concat(_slice.call(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this, "test"].concat(_slice.call(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this].concat(_argumentsToArray(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this, "test"].concat(_argumentsToArray(arguments)));
|
||||
};
|
||||
|
||||
_extends(Test, Foo);
|
||||
@@ -39,8 +47,8 @@ var Test = (function (Foo) {
|
||||
writable: true,
|
||||
value: function () {
|
||||
Foo.foo.call(this);
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_argumentsToArray(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_argumentsToArray(arguments)));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
@@ -48,8 +56,8 @@ var Test = (function (Foo) {
|
||||
writable: true,
|
||||
value: function () {
|
||||
Foo.prototype.test.call(this);
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(_slice.call(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(_argumentsToArray(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this, "test"].concat(_argumentsToArray(arguments)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
3
test/fixtures/transformation/es6-destructuring/es7-object-rest/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring/es7-object-rest/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var { ...x } = z;
|
||||
var { x, ...y } = z;
|
||||
(function({ x, ...y }) { })
|
||||
22
test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js
vendored
Normal file
22
test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
var _objectSpread = function (obj, keys) {
|
||||
var target = {};
|
||||
for (var i in obj) {
|
||||
if (keys.indexOf(i) >= 0) continue;
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
|
||||
target[i] = obj[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var x = _objectSpread(z, []);
|
||||
|
||||
var x = z.x;
|
||||
var y = _objectSpread(z, ["x"]);
|
||||
|
||||
(function (_ref) {
|
||||
var x = _ref.x;
|
||||
var y = _objectSpread(_ref, ["x"]);
|
||||
});
|
||||
3
test/fixtures/transformation/es6-destructuring/es7-object-rest/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-destructuring/es7-object-rest/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"experimental": true
|
||||
}
|
||||
@@ -1,6 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var concat = function () {
|
||||
var arrs = _slice.call(arguments);
|
||||
var _arguments = arguments;
|
||||
var _argumentsToArray = function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var concat = function () {
|
||||
var arrs = _argumentsToArray(_arguments);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var _argumentsToArray = function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var t = function (f) {
|
||||
var items = _slice.call(arguments, 1);
|
||||
var items = _argumentsToArray(arguments).slice(1);
|
||||
};
|
||||
|
||||
function t(f) {
|
||||
var items = _slice.call(arguments, 1);
|
||||
var items = _argumentsToArray(arguments).slice(1);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var _argumentsToArray = function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var t = function () {
|
||||
var items = _slice.call(arguments);
|
||||
var items = _argumentsToArray(arguments);
|
||||
};
|
||||
|
||||
function t() {
|
||||
var items = _slice.call(arguments);
|
||||
var items = _argumentsToArray(arguments);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var _argumentsToArray = function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
function foo() {
|
||||
return bar.apply(null, ["test"].concat(_slice.call(arguments)));
|
||||
return bar.apply(null, ["test"].concat(_argumentsToArray(arguments)));
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
|
||||
@@ -4,4 +4,4 @@ var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var lyrics = _toArray(parts).concat(["head", "and", "toes"]);
|
||||
var lyrics = [].concat(_toArray(parts), ["head", "and", "toes"]);
|
||||
|
||||
@@ -4,4 +4,4 @@ var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
_toArray(foo);
|
||||
[].concat(_toArray(foo));
|
||||
|
||||
1
test/fixtures/transformation/es7-object-spread/assignment/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-object-spread/assignment/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
z = { x, ...y };
|
||||
3
test/fixtures/transformation/es7-object-spread/assignment/expected.js
vendored
Normal file
3
test/fixtures/transformation/es7-object-spread/assignment/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
z = Object.assign({ x: x }, y);
|
||||
1
test/fixtures/transformation/es7-object-spread/expression/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-object-spread/expression/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
({ x, ...y, a, ...b, c });
|
||||
3
test/fixtures/transformation/es7-object-spread/expression/expected.js
vendored
Normal file
3
test/fixtures/transformation/es7-object-spread/expression/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(Object.assign({ x: x }, y, { a: a }, b, { c: c }));
|
||||
3
test/fixtures/transformation/es7-object-spread/options.json
vendored
Normal file
3
test/fixtures/transformation/es7-object-spread/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"experimental": true
|
||||
}
|
||||
1
test/fixtures/transformation/es7-object-spread/variable-declaration/actual.js
vendored
Normal file
1
test/fixtures/transformation/es7-object-spread/variable-declaration/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var z = { ...x };
|
||||
3
test/fixtures/transformation/es7-object-spread/variable-declaration/expected.js
vendored
Normal file
3
test/fixtures/transformation/es7-object-spread/variable-declaration/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var z = Object.assign({}, x);
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
var test = customNamespace.slice.call(arguments);
|
||||
var test = customNamespace.argumentsToArray(arguments);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
var test = to5Runtime.slice.call(arguments);
|
||||
var test = to5Runtime.argumentsToArray(arguments);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user