evil-eval
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i evil-eval

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

345 kB

Total Files

50

Last publish

Collaborators

  • jkeylu