Skip to content
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

Remove evil #27

Open
hmalphettes opened this issue Aug 7, 2014 · 12 comments
Open

Remove evil #27

hmalphettes opened this issue Aug 7, 2014 · 12 comments

Comments

@hmalphettes
Copy link
Contributor

All 24 of them

@hmalphettes hmalphettes mentioned this issue Aug 7, 2014
@ghalimi
Copy link
Contributor

ghalimi commented Aug 7, 2014

No, please do not remove the functions. Remove the eval invocations. If you
read the code, you'll realize that most of the invocations are made for
evaluating expressions that are passed in parameters, but more of these
parameters could also be static values. So, by just commenting out these
lines, you get rid of the issue, without losing the function itself.

On Thu, Aug 7, 2014 at 3:29 PM, Hugues Malphettes [email protected]
wrote:

All 24 of them


Reply to this email directly or view it on GitHub
#27.

@hmalphettes
Copy link
Contributor Author

@ghalimi of course not removing the functions: just removing the 24 evals
Sorry if that was unclear.

@ghalimi
Copy link
Contributor

ghalimi commented Aug 7, 2014

Great! Thanks. By the way, do we have a clean way of replacing them by some
kind of lightweight expression evaluator?

On Thu, Aug 7, 2014 at 3:38 PM, Hugues Malphettes [email protected]
wrote:

@ghalimi https://github.com/ghalimi of course not removing the
functions: just removing the 24 evals


Reply to this email directly or view it on GitHub
#27 (comment).

@hmalphettes
Copy link
Contributor Author

@ghalimi it depends: what would those expressions look like?

@ghalimi
Copy link
Contributor

ghalimi commented Aug 7, 2014

Not exactly sure yet, but at least some basic arithmetic expressions
without any FormulaJS functions in them.

On Thu, Aug 7, 2014 at 3:43 PM, Hugues Malphettes [email protected]
wrote:

@ghalimi https://github.com/ghalimi it depends: what would those
expressions look like?


Reply to this email directly or view it on GitHub
#27 (comment).

@hmalphettes
Copy link
Contributor Author

@ghalimi the best one I found for arithmetic is: http://silentmatt.com/javascript-expression-evaluator/

@ghalimi
Copy link
Contributor

ghalimi commented Aug 7, 2014

I think that's what we used as foundation for our own Expression Engine,
but Jim would know more about that.

On Thu, Aug 7, 2014 at 3:47 PM, Hugues Malphettes [email protected]
wrote:

@ghalimi https://github.com/ghalimi the best one I found for arithmetic
is: http://silentmatt.com/javascript-expression-evaluator/


Reply to this email directly or view it on GitHub
#27 (comment).

@jalateras
Copy link
Contributor

yes that is the foundation of the expression engine

@hmalphettes
Copy link
Contributor Author

Here is another one: http://mathjs.org/
Big: 315KB once minimized.

@hmalphettes
Copy link
Contributor Author

Here is a very small one: http://jsep.from.so/

Once built, just 600+ lines of code that looks good:
https://github.com/soney/jsep/blob/master/build/jsep.js

The minimized version stands at 4KB.

@hmalphettes
Copy link
Contributor Author

An evaluator using the output of jsep looks really promising I think: https://github.com/CrowdProcess/formula.js/pull/2

@hmalphettes
Copy link
Contributor Author

Added support for json in jsep with 60 lines of code:
So it can parse:

{ (avariable+'_n'): DATE(3), "oh": { nested: [ 1, 2+3, anotherVar ] } }

or

CREATE({ _type: 'tmp_obj', name: theName, identifier: LOWERCASE(SNAKE(theName))})

EricSmekens/jsep#14
This comes in really handy with custom functions where json arguments are expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants