@@ -64,20 +64,6 @@ function convertDataDescriptorToAccessor (obj, prop, message) {
64
64
return descriptor
65
65
}
66
66
67
- /**
68
- * Create arguments string to keep arity.
69
- */
70
-
71
- function createArgumentsString ( arity ) {
72
- var str = ''
73
-
74
- for ( var i = 0 ; i < arity ; i ++ ) {
75
- str += ', arg' + i
76
- }
77
-
78
- return str . substr ( 2 )
79
- }
80
-
81
67
/**
82
68
* Create stack string from stack.
83
69
*/
@@ -415,20 +401,17 @@ function wrapfunction (fn, message) {
415
401
throw new TypeError ( 'argument fn must be a function' )
416
402
}
417
403
418
- var args = createArgumentsString ( fn . length )
404
+ var deprecate = this
419
405
var stack = getStack ( )
420
406
var site = callSiteLocation ( stack [ 1 ] )
421
407
422
408
site . name = fn . name
423
409
424
- // eslint-disable-next-line no-new-func
425
- var deprecatedfn = new Function ( 'fn' , 'log' , 'deprecate' , 'message' , 'site' ,
426
- '"use strict"\n' +
427
- 'return function (' + args + ') {' +
428
- 'log.call(deprecate, message, site)\n' +
429
- 'return fn.apply(this, arguments)\n' +
430
- '}' ) ( fn , log , this , message , site )
431
-
410
+ function deprecatedfn ( ) {
411
+ log . call ( deprecate , message , site )
412
+ return fn . apply ( this , arguments )
413
+ }
414
+ Object . defineProperty ( deprecatedfn , 'length' , { value : fn . length } )
432
415
return deprecatedfn
433
416
}
434
417
0 commit comments