Socket
Socket
Sign inDemoInstall

safer-eval

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.2.2

18

lib/common.js

@@ -68,7 +68,20 @@ 'use strict';

function cloneFunctions(context) {
;['clearImmediate', 'clearInterval', 'clearTimeout', 'setImmediate', 'setInterval', 'setTimeout'].forEach(function (str) {
;['clearImmediate', 'clearInterval', 'clearTimeout'].forEach(function (str) {
try {
var fn = new Function('return ' + str)(); // eslint-disable-line no-new-func
context[str] = fn ? clones(fn) : undefined;
context[str] = fn ? function () {
return fn.apply(null, [].slice.call(arguments));
} : undefined;
} catch (e) {}
});['setImmediate', 'setInterval', 'setTimeout'].forEach(function (str) {
try {
var fn = new Function('return ' + str)(); // eslint-disable-line no-new-func
context[str] = fn ? function (f) {
if (typeof f === 'function') {
return fn.apply(null, [].slice.call(arguments));
} else {
throw new Error(str + ' requires function as argument');
}
} : undefined;
} catch (e) {}
});

@@ -79,2 +92,3 @@ }

* wraps up build-in objects using a cloned copy
* protect object against overwriting
* @private

@@ -81,0 +95,0 @@ */

8

package.json
{
"name": "safer-eval",
"version": "1.2.1",
"version": "1.2.2",
"description": "a safer eval",
"author": "commenthol <commenthol@gmail.com>",
"license": "MIT",
"main": "lib/index.js",
"browser": "lib/browser.js",
"main": "./lib/index.js",
"browser": {
"./lib/index.js": "./lib/browser.js"
},
"repository": {

@@ -10,0 +12,0 @@ "type": "git",

@@ -71,3 +71,15 @@ 'use strict'

'clearInterval',
'clearTimeout',
'clearTimeout'
].forEach((str) => {
try {
let fn = new Function(`return ${str}`)() // eslint-disable-line no-new-func
context[str] = fn
? function () {
return fn.apply(null, [].slice.call(arguments))
}
: undefined
} catch (e) {}
})
;[
'setImmediate',

@@ -79,3 +91,11 @@ 'setInterval',

let fn = new Function(`return ${str}`)() // eslint-disable-line no-new-func
context[str] = fn ? clones(fn) : undefined
context[str] = fn
? function (f) {
if (typeof f === 'function') {
return fn.apply(null, [].slice.call(arguments))
} else {
throw new Error(str + ' requires function as argument')
}
}
: undefined
} catch (e) {}

@@ -87,2 +107,3 @@ })

* wraps up build-in objects using a cloned copy
* protect object against overwriting
* @private

@@ -89,0 +110,0 @@ */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc