remove arguments-to-array helper

This commit is contained in:
Sebastian McKenzie
2014-11-25 23:56:38 +11:00
parent d184bc93b9
commit 1a1e6bc3ba
10 changed files with 27 additions and 81 deletions

View File

@@ -1,14 +1,6 @@
"use strict";
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 _slice = Array.prototype.slice;
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
@@ -33,11 +25,11 @@ var Test = (function (Foo) {
Foo.prototype.test.call(this);
foob(Foo);
Foo.call.apply(Foo, [this].concat(_argumentsToArray(arguments)));
Foo.call.apply(Foo, [this, "test"].concat(_argumentsToArray(arguments)));
Foo.call.apply(Foo, [this].concat(_slice.call(arguments)));
Foo.call.apply(Foo, [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)));
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)));
};
_extends(Test, Foo);
@@ -47,8 +39,8 @@ var Test = (function (Foo) {
writable: true,
value: function () {
Foo.foo.call(this);
Foo.foo.call.apply(Foo.foo, [this].concat(_argumentsToArray(arguments)));
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_argumentsToArray(arguments)));
Foo.foo.call.apply(Foo.foo, [this].concat(_slice.call(arguments)));
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_slice.call(arguments)));
}
}
}, {
@@ -56,8 +48,8 @@ var Test = (function (Foo) {
writable: true,
value: function () {
Foo.prototype.test.call(this);
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)));
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)));
}
}
});

View File

@@ -1,14 +1,6 @@
"use strict";
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 _slice = Array.prototype.slice;
var concat = function () {
var arrs = _argumentsToArray(arguments);
var arrs = _slice.call(arguments);
};

View File

@@ -1,18 +1,10 @@
"use strict";
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 _slice = Array.prototype.slice;
var t = function (f) {
var items = _argumentsToArray(arguments).slice(1);
var items = _slice.call(arguments, 1);
};
function t(f) {
var items = _argumentsToArray(arguments).slice(1);
var items = _slice.call(arguments, 1);
}

View File

@@ -1,18 +1,10 @@
"use strict";
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 _slice = Array.prototype.slice;
var t = function () {
var items = _argumentsToArray(arguments);
var items = _slice.call(arguments);
};
function t() {
var items = _argumentsToArray(arguments);
var items = _slice.call(arguments);
}

View File

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

View File

@@ -1,5 +1,5 @@
"use strict";
function foo() {
var test = customNamespace.argumentsToArray(arguments);
var test = customNamespace.slice.call(arguments);
}

View File

@@ -1,5 +1,5 @@
"use strict";
function foo() {
var test = to5Runtime.argumentsToArray(arguments);
var test = to5Runtime.slice.call(arguments);
}