Skip to content

A JavaScript interpreter written in JavaScript.

License

Notifications You must be signed in to change notification settings

xinyangtan/evil-eval

 
 

Repository files navigation

evil-eval

A JavaScript interpreter written in JavaScript.

Why

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.

Usage

import { runInContext } from 'evil-eval';

const code = `
    function hello(name) {
        return 'Hello ' + (name || defaultName) + '!';
    }

    module.exports = hello;
`;
const sandbox = { defaultName: 'World' };
const hello = runInContext(code, sandbox);
hello();

Inspired by

License

MIT

About

A JavaScript interpreter written in JavaScript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.5%
  • JavaScript 1.5%