marten-de-vries / evaljs Goto Github PK
View Code? Open in Web Editor NEWA JavaScript interpreter written in JavaScript
A JavaScript interpreter written in JavaScript
function calc(a,b){
return a+b
}
function main(a,b){
return calc(a,b)
}
console.log(main(1,2)) //output: GeneratorFunctionPrototype [Generator] { _invoke: [Function: invoke] }
Wonderful job. The job is very useful when i want to execute js while eval is disabled. Any ideas for implementing a debugger for evaljs. I think it's will be similar to the sourcemap feature of modern browser, which will make a map between the source code with the uglified code, and provide a great convenience for debugger js.
Hi all,
I was looking for an eval solution that would be safe to use in my browser app.
I checked out evaljs and localeval. localeval provided a safer solution than evaljs and without acorn overhead. Plus localeval protected the global context.
Try some of the warnings in localeval. Scary stuff and evaljs fails these tests.
So I forked localeval and I made a change so that my context data would be retrievable from the eval.
I ran into some issues where the only explanation could have been that my String.prototype.match
function was not working correctly, when I pulled localeval the issue went away. So there may still be edge case bugs in localeval?
In my investigations of my problem I looked into vm-browserify.. This provided the solution to the very same problem by running the eval in its own vm
. It looks like this solution is widely used and has millions of downloads. For my case there are no side effects.
With this issue I am hoping I can help out anyone else looking for this solution.
I have a question regarding global functions.
How can I add global functions to the env like Boolean or Math?
Like I would like to parse the following:
Boolean("true");
It gives me an empty object {} even if I try to add Boolean like this:
var envGlobal = {
Boolean: Boolean,
};
var env = new evaljs.Environment([envGlobal]);
If I try the same and add parseInt, if I write like this:
parseInt('5');
It gives me the same empty {} object, however if I do this:
parseInt('5')+5;
It correctly returns 10.
Any idea on this?
Hi there,
Does this use eval()
under the hood? If not, do we have any security concerns (XSS or injections) to be aware of?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.