Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jkeylu/evil-eval
A JavaScript interpreter written in JavaScript.
https://github.com/jkeylu/evil-eval
Last synced: 4 months ago
JSON representation
A JavaScript interpreter written in JavaScript.
- Host: GitHub
- URL: https://github.com/jkeylu/evil-eval
- Owner: jkeylu
- License: mit
- Created: 2018-04-17T13:36:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-27T12:31:12.000Z (about 6 years ago)
- Last Synced: 2024-03-17T16:23:14.134Z (4 months ago)
- Language: TypeScript
- Size: 193 KB
- Stars: 76
- Watchers: 2
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-javascript-interpreters - jkeylu/evil-eval - eval) | ![GitHub last commit](https://img.shields.io/github/last-commit/jkeylu/evil-eval) | (javascript interpreters / old projects)
README
# 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
```js
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
- [jsjs](https://github.com/bramblex/jsjs)
- [vm.js](https://github.com/axetroy/vm.js)## License
MIT