use slice helper on arguments instead of toArray

This commit is contained in:
Sebastian McKenzie
2014-11-23 13:09:31 +11:00
parent cbd6be30bf
commit 1027f8a5a4
3 changed files with 13 additions and 17 deletions

View File

@@ -73,6 +73,8 @@ 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]);
}