remove arguments-to-array helper
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user