Execute code safely with safeEval()
masterUse safeEval(src, parentContext) to evaluate JavaScript source code within a controlled environment. This prevents the code from accessing the global scope or sensitive properties by running it against a sandboxed context. You can optionally provide a parentContext object to act as the base for the sandbox.
safeEval is also available as the .eval property of the module.
const safeEval = require('notevil');
// Basic usage
const result = safeEval('1 + 1');
// Usage with a custom context
const context = { a: 10 };
const resultWithContext = safeEval('a + 5', context);