remove arguments-to-array helper
This commit is contained in:
parent
d184bc93b9
commit
1a1e6bc3ba
@ -22,7 +22,6 @@ File.declarations = [
|
||||
"tagged-template-literal",
|
||||
"interop-require",
|
||||
"to-array",
|
||||
"arguments-to-array",
|
||||
"object-spread",
|
||||
"has-own",
|
||||
"slice"
|
||||
@ -81,14 +80,11 @@ 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) {
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
(function (args) {
|
||||
var target = new Array(args.length);
|
||||
for (var i = 0; i< args.length; i++) {
|
||||
target[i] = args[i];
|
||||
}
|
||||
return target;
|
||||
})
|
||||
@ -8,13 +8,10 @@ exports.Function = function (node, parent, file) {
|
||||
|
||||
t.ensureBlock(node);
|
||||
|
||||
var call = t.callExpression(
|
||||
file.addDeclaration("arguments-to-array"),
|
||||
[t.identifier("arguments")]
|
||||
);
|
||||
var call = file.toArray(t.identifier("arguments"));
|
||||
|
||||
if (node.params.length) {
|
||||
call = t.callExpression(t.memberExpression(call, t.identifier("slice")), [t.literal(node.params.length)]);
|
||||
call.arguments.push(t.literal(node.params.length));
|
||||
}
|
||||
|
||||
call._ignoreAliasFunctions = true;
|
||||
|
||||
@ -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)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
var test = customNamespace.argumentsToArray(arguments);
|
||||
var test = customNamespace.slice.call(arguments);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
var test = to5Runtime.argumentsToArray(arguments);
|
||||
var test = to5Runtime.slice.call(arguments);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user