clone-function
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "clone-function", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Clones non native JavaScript functions, or references native functions.", | ||
@@ -5,0 +5,0 @@ "main": "./src/clone-function.js", |
@@ -17,7 +17,12 @@ /* | ||
function cloneFunction(func) { | ||
var out; | ||
if (/\[native code\]/.test(func.toString())) { | ||
out = func; | ||
} else { | ||
out = eval('(function(){return ' + func.toString() + '}());'); | ||
var out, str; | ||
try { | ||
str = func.toString(); | ||
if (/\[native code\]/.test(str)) { | ||
out = func; | ||
} else { | ||
out = eval('(function(){return ' + str + '}());'); | ||
} | ||
} catch (e) { | ||
throw new Error(e.message + '\r\n\r\n' + str); | ||
} | ||
@@ -24,0 +29,0 @@ return out; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
197463
3036