HNHacker News
TopNewBestAskShowJobs

olamide203

29 karma · joined August 21, 2022

submissionscomments
olamide203··on Hyoka
you got me there :)
olamide203··on Hyoka
yeah having to type ${} everywhere makes the code a little bit messy.
olamide203··on Hyoka
I'm glad you find it useful. thanks for the feedback
olamide203··on Hyoka
Nice tip, i'm planning to add an identifier node class so that you can pass a scope with the values to be used during evaluation. Eg.

   const a = 2;
   const b = 6;
   const c = 3
   const expression = new Expression('a \ b * c')
   const result = expression.scope({a, b, c}).evaluate();
   document.getElementById("app").innerHTML `${a} \ ${b} * 
   ${c}= ${result}`
olamide203··on Hyoka
you can log it to the console if you want to see the Abstract syntax tree of an Expression object
olamide203··on Hyoka
It can also be used in the browser as well as node.js or any other javascript runtime environment
olamide203··on Hyoka
hyoka uses a full recursive descent parser to parse expressions into AST, then evaluates to get the final result. it is very secure for math expressions unlike the eval function which can run javascript code. you can try out a demo here https://codesandbox.io/s/naughty-chatterjee-kr3bsc
olamide203··on Hyoka
I created a lightweight and precise math expression parser and evaluator for JavaScript and TypeScript. it can handle complex arithmetic expressions
olamide203··on Gittz
live site can be found at https://gittz.netify.live
olamide203··on Gittz
a web application which integrates with the github REST API making it easy for developers to share their projects on twitter