Feature Request: ability to add custom operators which are not automatically traversed for evaluation, v2 #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #116
This PR is a revision of #117. I have to admit I wasn't sure the best way to go about this PR -- let me know if I should instead make it against https://github.com/Sykander/json-logic-js/tree/feature/controlled-execution.
I included @Skyander's commits here. The "diff" from @Skyander's version is that I renamed the param from
controlledExecutiontotraverse, and changed the state tracking object fromrunOperationAsControlledtoopOptionswhich allows future options to be supported.Here is a revision to the PR description as well:
Changes:
Description
This PR adds functionality so that when registering a custom operator with the add_operator method, you can now pass in a third param options with the property
traverse. This option allows you to specify how your operator should be treated during evaluation and also prevents all nested parameters to the operator from being pre-evaluated.I believe this PR addresses one of the noted limitations described in https://jsonlogic.com/add_operation.html:
Once this PR is merged, that sentence could be revised to say: