A JavaScript interpreter written in JavaScript.
Yout might working in a JavaScript environment where eval() and new Function() are not allowed (eg: WeChat Mini Program), and you probably have a good reason to use it.
import{runInContext}from'evil-eval';constcode=` function hello(name) { return 'Hello ' + (name || defaultName) + '!'; } module.exports = hello;`;constsandbox={defaultName: 'World'};consthello=runInContext(code,sandbox);hello();MIT