Skip to content

Commit 887283b

Browse files
adrianheinedougwilson
authored andcommitted
Replace interal eval usage with Function constructor
fixes #20 closes #22 closes #24
1 parent 1042e0b commit 887283b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

History.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
===
33

44
* Drop support for Node.js 0.6
5+
* Replace interal `eval` usage with `Function` constructor
56

67
1.1.2 / 2018-01-11
78
==================

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,18 +399,18 @@ function wrapfunction (fn, message) {
399399
}
400400

401401
var args = createArgumentsString(fn.length)
402-
var deprecate = this // eslint-disable-line no-unused-vars
403402
var stack = getStack()
404403
var site = callSiteLocation(stack[1])
405404

406405
site.name = fn.name
407406

408-
// eslint-disable-next-line no-eval
409-
var deprecatedfn = eval('(function (' + args + ') {\n' +
407+
// eslint-disable-next-line no-new-func
408+
var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
410409
'"use strict"\n' +
410+
'return function (' + args + ') {' +
411411
'log.call(deprecate, message, site)\n' +
412412
'return fn.apply(this, arguments)\n' +
413-
'})')
413+
'}')(fn, log, this, message, site)
414414

415415
return deprecatedfn
416416
}

0 commit comments

Comments
 (0)