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

Replaced the name of the global variable holding the input data in the Javascript expression evaluator #93

Merged
merged 1 commit into from
May 2, 2024

Conversation

JBBianchi
Copy link
Member

The name previously chosen to hold the data passed to a expression, input, was too generic and might easily lead to collision with provided arguments. Therefore, it's been replaced by a less common symbol: $. This basically allows the arguments dictionary to contain an entry with the input key without colliding with the data.

Given the following input data:

{
   "foo": "bar",
   "answer": 42,
}

And the expected output:
The Answer to the Ultimate Question of Life, the Universe, and Everything is 42, and foo = bar

Previously, the expression would have been:
"The Answer to the Ultimate Question of Life, the Universe, and Everything is " + input.answer + ", and foo = " + input.foo

And now is:
"The Answer to the Ultimate Question of Life, the Universe, and Everything is " + $.answer + ", and foo = " + $.foo

Alternatives providing the same output:

  • using interpolation: `The Answer to the Ultimate Question of Life, the Universe, and Everything is ${ $.answer }, and foo = ${ $.foo }`
  • wrapping the expression in ${}: ${ "The Answer to the Ultimate Question of Life, the Universe, and Everything is " + $.answer + ", and foo = " + $.foo }
  • interpolation + wrapping the expression in ${}: ${ `The Answer to the Ultimate Question of Life, the Universe, and Everything is ${ $.answer }, and foo = ${ $.foo }` }

@JBBianchi JBBianchi requested a review from cdavernas May 2, 2024 10:19
Copy link
Member

@cdavernas cdavernas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!!

@JBBianchi JBBianchi merged commit 132eaef into main May 2, 2024
1 check passed
@JBBianchi JBBianchi deleted the fix-js-expression-evaluator-global-variable-name branch May 2, 2024 10:23
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

Successfully merging this pull request may close these issues.

2 participants