Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbd6be30bf | ||
|
|
7e299470fd | ||
|
|
c794c2aede | ||
|
|
1a58087460 |
@@ -1,3 +1,8 @@
|
||||
# 1.13.2
|
||||
|
||||
* Optimise `Array.from` usage by adding a helper method.
|
||||
* Upgrade `acorn-6to5`.
|
||||
|
||||
# 1.13.1
|
||||
|
||||
* Fix constructor spread optimisation. Thanks [@zloirock](https://github.com/zloirock).
|
||||
|
||||
@@ -13,7 +13,7 @@ ES7 features to work.
|
||||
### Array comprehension/Array destructuring/Spread
|
||||
|
||||
An [ES6 polyfill](polyfill.md) is required. More specifically a polyfill for
|
||||
`Array.from`.
|
||||
`Array.isArray` and `Array.from`.
|
||||
|
||||
## Classes
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ function File(opts) {
|
||||
}
|
||||
|
||||
File.declarations = ["extends", "class-props", "slice", "apply-constructor",
|
||||
"tagged-template-literal", "interop-require"];
|
||||
"tagged-template-literal", "interop-require", "to-array"];
|
||||
|
||||
File.normaliseOptions = function (opts) {
|
||||
opts = _.cloneDeep(opts || {});
|
||||
@@ -70,6 +70,14 @@ File.normaliseOptions = function (opts) {
|
||||
return opts;
|
||||
};
|
||||
|
||||
File.prototype.toArray = function (node) {
|
||||
if (t.isArrayExpression(node)) {
|
||||
return node;
|
||||
} else {
|
||||
return t.callExpression(this.addDeclaration("to-array"), [node]);
|
||||
}
|
||||
};
|
||||
|
||||
File.prototype.getModuleFormatter = function (type) {
|
||||
var ModuleFormatter = _.isFunction(type) ? type : transform.moduleFormatters[type];
|
||||
|
||||
|
||||
3
lib/6to5/templates/to-array.js
Normal file
3
lib/6to5/templates/to-array.js
Normal file
@@ -0,0 +1,3 @@
|
||||
(function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
});
|
||||
@@ -2,21 +2,16 @@ var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var single = function (node) {
|
||||
var single = function (node, file) {
|
||||
var block = node.blocks[0];
|
||||
|
||||
var templateName = "array-expression-comprehension-map";
|
||||
if (node.filter) templateName = "array-expression-comprehension-filter";
|
||||
|
||||
var right = block.right;
|
||||
if (!t.isArrayExpression(right)) {
|
||||
right = util.template("array-from", { VALUE: right });
|
||||
}
|
||||
|
||||
var result = util.template(templateName, {
|
||||
STATEMENT: node.body,
|
||||
FILTER: node.filter,
|
||||
ARRAY: right,
|
||||
ARRAY: file.toArray(block.right),
|
||||
KEY: block.left
|
||||
});
|
||||
|
||||
@@ -79,7 +74,7 @@ exports.ComprehensionExpression = function (node, parent, file) {
|
||||
if (node.generator) return;
|
||||
|
||||
if (node.blocks.length === 1) {
|
||||
return single(node);
|
||||
return single(node, file);
|
||||
} else {
|
||||
return multiple(node, file);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var buildVariableAssign = function (kind, id, init) {
|
||||
if (kind === false) {
|
||||
@@ -40,9 +39,7 @@ var pushObjectPattern = function (opts, nodes, pattern, parentId) {
|
||||
var pushArrayPattern = function (opts, nodes, pattern, parentId) {
|
||||
var _parentId = opts.file.generateUidIdentifier("ref", opts.scope);
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(_parentId, util.template("array-from", {
|
||||
VALUE: parentId
|
||||
}))
|
||||
t.variableDeclarator(_parentId, opts.file.toArray(parentId))
|
||||
]));
|
||||
parentId = _parentId;
|
||||
|
||||
@@ -52,9 +49,7 @@ var pushArrayPattern = function (opts, nodes, pattern, parentId) {
|
||||
var newPatternId;
|
||||
|
||||
if (t.isSpreadElement(elem)) {
|
||||
newPatternId = util.template("array-from", {
|
||||
VALUE: parentId
|
||||
});
|
||||
newPatternId = opts.file.toArray(parentId);
|
||||
|
||||
if (+i > 0) {
|
||||
newPatternId = t.callExpression(t.memberExpression(newPatternId, t.identifier("slice")), [t.literal(i)]);
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var getSpreadLiteral = function (spread) {
|
||||
var literal = spread.argument;
|
||||
if (!t.isArrayExpression(literal)) {
|
||||
literal = util.template("array-from", {
|
||||
VALUE: literal
|
||||
});
|
||||
}
|
||||
return literal;
|
||||
var getSpreadLiteral = function (spread, file) {
|
||||
return file.toArray(spread.argument);
|
||||
};
|
||||
|
||||
var hasSpread = function (nodes) {
|
||||
@@ -23,7 +16,7 @@ var hasSpread = function (nodes) {
|
||||
return has;
|
||||
};
|
||||
|
||||
var build = function (props) {
|
||||
var build = function (props, file) {
|
||||
var nodes = [];
|
||||
|
||||
var _props = [];
|
||||
@@ -37,7 +30,7 @@ var build = function (props) {
|
||||
_.each(props, function (prop) {
|
||||
if (t.isSpreadElement(prop)) {
|
||||
push();
|
||||
nodes.push(getSpreadLiteral(prop));
|
||||
nodes.push(getSpreadLiteral(prop, file));
|
||||
} else {
|
||||
_props.push(prop);
|
||||
}
|
||||
@@ -48,11 +41,11 @@ var build = function (props) {
|
||||
return nodes;
|
||||
};
|
||||
|
||||
exports.ArrayExpression = function (node) {
|
||||
exports.ArrayExpression = function (node, parent, file) {
|
||||
var elements = node.elements;
|
||||
if (!hasSpread(elements)) return;
|
||||
|
||||
var nodes = build(elements);
|
||||
var nodes = build(elements, file);
|
||||
var first = nodes.shift();
|
||||
|
||||
if (!nodes.length) return first;
|
||||
@@ -60,7 +53,7 @@ exports.ArrayExpression = function (node) {
|
||||
return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
|
||||
};
|
||||
|
||||
exports.CallExpression = function (node) {
|
||||
exports.CallExpression = function (node, parent, file) {
|
||||
var args = node.arguments;
|
||||
if (!hasSpread(args)) return;
|
||||
|
||||
@@ -68,7 +61,7 @@ exports.CallExpression = function (node) {
|
||||
|
||||
node.arguments = [];
|
||||
|
||||
var nodes = build(args);
|
||||
var nodes = build(args, file);
|
||||
var first = nodes.shift();
|
||||
|
||||
if (nodes.length) {
|
||||
@@ -100,7 +93,7 @@ exports.NewExpression = function (node, parent, file) {
|
||||
var args = node.arguments;
|
||||
if (!hasSpread(args)) return;
|
||||
|
||||
var nodes = build(args);
|
||||
var nodes = build(args, file);
|
||||
var first = nodes.shift();
|
||||
|
||||
if (nodes.length) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.13.1",
|
||||
"version": "1.13.2",
|
||||
"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.4",
|
||||
"acorn-6to5": "0.9.1-3",
|
||||
"acorn-6to5": "0.9.1-4",
|
||||
"estraverse": "1.8.0",
|
||||
"private": "0.1.6"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var arr = Array.from(nums).filter(function (i) {
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var arr = _toArray(nums).filter(function (i) {
|
||||
return i > 1;
|
||||
}).map(function (i) {
|
||||
return i * i;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var arr = Array.from(nums).map(function (i) {
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var arr = _toArray(nums).map(function (i) {
|
||||
return i * i;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
@@ -24,11 +28,11 @@ var Test = (function (Foo) {
|
||||
Foo.prototype.test.call(this);
|
||||
foob(Foo);
|
||||
|
||||
Foo.call.apply(Foo, [this].concat(Array.from(arguments)));
|
||||
Foo.call.apply(Foo, [this, "test"].concat(Array.from(arguments)));
|
||||
Foo.call.apply(Foo, [this].concat(_toArray(arguments)));
|
||||
Foo.call.apply(Foo, [this, "test"].concat(_toArray(arguments)));
|
||||
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this].concat(Array.from(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this, "test"].concat(Array.from(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this].concat(_toArray(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype, [this, "test"].concat(_toArray(arguments)));
|
||||
};
|
||||
|
||||
_extends(Test, Foo);
|
||||
@@ -38,8 +42,8 @@ var Test = (function (Foo) {
|
||||
writable: true,
|
||||
value: function () {
|
||||
Foo.foo.call(this);
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(Array.from(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(Array.from(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_toArray(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_toArray(arguments)));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
@@ -47,8 +51,8 @@ var Test = (function (Foo) {
|
||||
writable: true,
|
||||
value: function () {
|
||||
Foo.prototype.test.call(this);
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(Array.from(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this, "test"].concat(Array.from(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(_toArray(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this, "test"].concat(_toArray(arguments)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _ref = [1, 2];
|
||||
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
var a = _ref2[0];
|
||||
var b = _ref2[1];
|
||||
var _ref3 = [3, 4];
|
||||
|
||||
var _ref4 = Array.from(_ref3);
|
||||
var _ref4 = _toArray(_ref3);
|
||||
|
||||
var c = _ref4[0];
|
||||
var d = _ref4[1];
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _ref = ["hello", [", ", "junk"], ["world"]];
|
||||
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
var a = _ref2[0];
|
||||
var _ref3 = Array.from(_ref2[1]);
|
||||
var _ref3 = _toArray(_ref2[1]);
|
||||
|
||||
var b = _ref3[0];
|
||||
var _ref4 = Array.from(_ref2[2]);
|
||||
var _ref4 = _toArray(_ref2[2]);
|
||||
|
||||
var c = _ref4[0];
|
||||
var d = _ref2[3];
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _ref = f();
|
||||
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
a = _ref2[0];
|
||||
b = _ref2[1];
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
|
||||
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
var a = _ref2[1];
|
||||
var _ref3 = Array.from(_ref2[2]);
|
||||
var _ref3 = _toArray(_ref2[2]);
|
||||
|
||||
var b = _ref3[0];
|
||||
var _ref4 = Array.from(_ref2[3]);
|
||||
var _ref4 = _toArray(_ref2[3]);
|
||||
|
||||
var c = _ref4[0];
|
||||
var d = _ref2[4];
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
for (var _ref in obj) {
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
var name = _ref2[0];
|
||||
var value = _ref2[1];
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
for (var _iterator = this.test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var _ref = _step.value;
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
var name = _ref2[0];
|
||||
var before = _ref2[1];
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _ref = [1, 2];
|
||||
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
this.foo = _ref2[0];
|
||||
this.bar = _ref2[1];
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = Array.from(rect.topLeft);
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _ref = _toArray(rect.topLeft);
|
||||
|
||||
var x1 = _ref[0];
|
||||
var y1 = _ref[1];
|
||||
var _ref2 = Array.from(rect.bottomRight);
|
||||
var _ref2 = _toArray(rect.bottomRight);
|
||||
|
||||
var x2 = _ref2[0];
|
||||
var y2 = _ref2[1];
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
function somethingAdvanced(_ref) {
|
||||
var x1 = _ref.topLeft.x;
|
||||
var y1 = _ref.topLeft.y;
|
||||
@@ -16,12 +20,12 @@ function unpackObject(_ref2) {
|
||||
console.log(unpackObject({ title: "title", author: "author" }));
|
||||
|
||||
var unpackArray = function (_ref3, _ref5) {
|
||||
var _ref4 = Array.from(_ref3);
|
||||
var _ref4 = _toArray(_ref3);
|
||||
|
||||
var a = _ref4[0];
|
||||
var b = _ref4[1];
|
||||
var c = _ref4[2];
|
||||
var _ref6 = Array.from(_ref5);
|
||||
var _ref6 = _toArray(_ref5);
|
||||
|
||||
var x = _ref6[0];
|
||||
var y = _ref6[1];
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var isSorted = function (_ref) {
|
||||
var _ref2 = Array.from(_ref);
|
||||
var _ref2 = _toArray(_ref);
|
||||
|
||||
var x = _ref2[0];
|
||||
var y = _ref2[1];
|
||||
var wow = Array.from(_ref2).slice(2);
|
||||
var wow = _toArray(_ref2).slice(2);
|
||||
|
||||
if (!zs.length) return true;
|
||||
if (y > x) return isSorted(zs);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
function foo() {
|
||||
return bar.apply(null, ["test"].concat(Array.from(arguments)));
|
||||
return bar.apply(null, ["test"].concat(_toArray(arguments)));
|
||||
}
|
||||
|
||||
function bar(one, two, three) {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var lyrics = Array.from(parts).concat(["head", "and", "toes"]);
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var lyrics = _toArray(parts).concat(["head", "and", "toes"]);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var a = [b].concat(Array.from(c), [d]);
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var a = [b].concat(_toArray(c), [d]);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var a = [b].concat(Array.from(c), [d, e], Array.from(f));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var a = [b].concat(_toArray(c), [d, e], _toArray(f));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var lyrics = ["head", "and", "toes"].concat(Array.from(parts));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var lyrics = ["head", "and", "toes"].concat(_toArray(parts));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
obj[method].apply(obj, [foo, bar].concat(Array.from(args)));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
obj[method].apply(obj, [foo, bar].concat(_toArray(args)));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
obj[method].apply(obj, Array.from(args));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
obj[method].apply(obj, _toArray(args));
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
foob.add.apply(foob, [foo, bar].concat(Array.from(numbers)));
|
||||
foob.test.add.apply(foob.test, [foo, bar].concat(Array.from(numbers)));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
foob.add.apply(foob, [foo, bar].concat(_toArray(numbers)));
|
||||
foob.test.add.apply(foob.test, [foo, bar].concat(_toArray(numbers)));
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
foob.add.apply(foob, Array.from(numbers));
|
||||
foob.test.add.apply(foob.test, Array.from(numbers));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
foob.add.apply(foob, _toArray(numbers));
|
||||
foob.test.add.apply(foob.test, _toArray(numbers));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(null, Array.from(numbers).concat([foo, bar]));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
add.apply(null, _toArray(numbers).concat([foo, bar]));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(null, [foo].concat(Array.from(numbers), [bar]));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
add.apply(null, [foo].concat(_toArray(numbers), [bar]));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(null, [foo, bar].concat(Array.from(numbers)));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
add.apply(null, [foo, bar].concat(_toArray(numbers)));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(null, [foo].concat(Array.from(numbers), [bar, what], Array.from(test)));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
add.apply(null, [foo].concat(_toArray(numbers), [bar, what], _toArray(test)));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
add.apply(null, Array.from(numbers));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
add.apply(null, _toArray(numbers));
|
||||
|
||||
@@ -8,5 +8,9 @@ var _applyConstructor = function (Constructor, args) {
|
||||
return result != null && (typeof result == "object" || typeof result == "function") ? result : instance;
|
||||
};
|
||||
|
||||
_applyConstructor(Numbers, Array.from(nums));
|
||||
_applyConstructor(Numbers, [1].concat(Array.from(nums)));
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
_applyConstructor(Numbers, _toArray(nums));
|
||||
_applyConstructor(Numbers, [1].concat(_toArray(nums)));
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
Array.from(foo);
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
_toArray(foo);
|
||||
|
||||
Reference in New Issue
Block a user