Only slice arguments when necessary - fixes #239

This commit is contained in:
James Kyle
2014-12-02 16:26:18 -08:00
parent 5fe1c07d9a
commit 888ab5473a
7 changed files with 50 additions and 4 deletions

View File

@@ -0,0 +1,9 @@
function foo() {
return bar([...arguments]);
}
function bar(one, two, three) {
return [one, two, three];
}
foo("foo", "bar");

View File

@@ -0,0 +1,12 @@
"use strict";
var _slice = Array.prototype.slice;
function foo() {
return bar([].concat(_slice.call(arguments)));
}
function bar(one, two, three) {
return [one, two, three];
}
foo("foo", "bar");

View File

@@ -0,0 +1,9 @@
function foo() {
return bar("test", ...arguments);
}
function bar(one, two, three) {
return [one, two, three];
}
foo("foo", "bar");

View File

@@ -0,0 +1,12 @@
"use strict";
var _slice = Array.prototype.slice;
function foo() {
return bar.apply(null, ["test"].concat(_slice.call(arguments)));
}
function bar(one, two, three) {
return [one, two, three];
}
foo("foo", "bar");

View File

@@ -1,5 +1,5 @@
function foo() {
return bar("test", ...arguments);
return bar(...arguments);
}
function bar(one, two, three) {

View File

@@ -1,8 +1,7 @@
"use strict";
var _slice = Array.prototype.slice;
function foo() {
return bar.apply(null, ["test"].concat(_slice.call(arguments)));
return bar.apply(null, arguments);
}
function bar(one, two, three) {