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

Adding new extensions for map and evaluate strings #61

Closed
BuddhiWathsala opened this issue Sep 2, 2019 · 1 comment · Fixed by #62 or siddhi-io/siddhi-script-js#43
Closed

Comments

@BuddhiWathsala
Copy link
Contributor

Description:

Problem

Currently, Siddhi execution string does not support string manipulation for the following scenarios.

  1. Let say I have a stringS=" {{prize}} > 100 " and the value of the prize coming from a different stream. Assume that, now the prize is 300. Then I need to get the string S'= "300 > 100"
  2. The next scenario is get the string S' = "300 > 100" and evaluate it. The evaluation of that mathematical expression should return true.

Suggestion

  1. Implement an extension called str: map(STRING, STRING...) and this will return a STRING.
  2. Implement an extension called str: eval(STRING, STRING...) and this will return an Object.

Suggested Labels:
Feature improvement

@BuddhiWathsala
Copy link
Contributor Author

BuddhiWathsala commented Sep 3, 2019

According to the discussion of this siddhi-dev mail thread, we are going to implement two functions to cater above requirements.

  1. Update previous str:fillTemplate receive a string and a key-value map. Then replace all key entries with a corresponding value. For example it will receive,
str:fillTemplate("{{prize}} > 100 && {{salary}} < 10000",  map:create('prize', 300, 'salary', 10000)))

and return string 300 > 100 && 10000 < 10000

  1. Then we will add another function js:eval( "56 > 76", 'bool') to evaluate expressions in https://github.com/siddhi-io/siddhi-script-js

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