We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7855319 commit 3551cddCopy full SHA for 3551cdd
function/#/copy.js
@@ -1,19 +1,20 @@
1
"use strict";
2
3
var mixin = require("../../object/mixin")
4
- , validFunction = require("../valid-function")
5
- , re = /^\s*function\s*([\0-')-\uffff]+)*\s*\(([\0-(*-\uffff]*)\)\s*\{/;
+ , validFunction = require("../valid-function");
6
7
module.exports = function () {
8
- var match = String(validFunction(this)).match(re), fn;
+ validFunction(this);
9
+ var args = [];
10
+ for (var i = 0; i < this.length; ++i) args.push("arg" + (i + 1));
11
// eslint-disable-next-line no-new-func
- fn = new Function(
12
+ var fn = new Function(
13
"fn",
14
"return function " +
- match[1].trim() +
15
+ (this.name || "") +
16
"(" +
- match[2] +
17
+ args.join(", ") +
18
") { return fn.apply(this, arguments); };"
19
)(this);
20
try { mixin(fn, this); }
0 commit comments