-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing the eval code in the API or the doc #13
Comments
Wrote this module to help with this. It doesn't eval, but it'll generate a string: https://github.com/lapwinglabs/jsepgen |
Thank you for this! |
I just put together a small module for evaluation and compilation. Evaluation: // Evaluation
expr.eval('a + b / c', {a: 2, b: 2, c: 5}); // 0.8 Compilation: const fn = expr.compile('foo.bar + 10');
fn({foo: {bar: 'baz'}}); // 'baz10' There's not much to it, besides what's already shown in the tests and explained above. @soney, would you take a PR adding those functions to the core library? Or, if this doesn't exist elsewhere, would you prefer that it remain a separate repo with attribution to jsep? |
I should add — even though the module above avoids use of |
Hi there, jsep looks wonderful.
One thing that might be obvious to people familiar with esprima is that it is trivial to evaluate the generated AST:
I found it in the tests and it was not obvious to me.
I hope this helps
Many thanks!
The text was updated successfully, but these errors were encountered: