Skip to content
A JavaScript interpreter written in JavaScript.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist es2015: ExportNamedDeclaration Apr 25, 2018
src Generator Function not implemented Apr 27, 2018
test es2015: ExportNamedDeclaration Apr 25, 2018
.gitignore es2015: ExportNamedDeclaration Apr 25, 2018
.npmignore add .npmignore Apr 25, 2018
LICENSE First commit Apr 17, 2018
README.md First commit Apr 17, 2018
package-lock.json webpack add output es5 only config Apr 21, 2018
package.json
tsconfig.json es2015: ExportNamedDeclaration Apr 25, 2018
webpack.config.js

README.md

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

You can’t perform that action at this time.