Description
Some operators, for example if
, map
, reduce
etc. have modified scope for evaluation, so that the parameters passed into these operators aren't automatically evaluated but instead conditionally evaluated based on the operators control structure.
{ "if"[true, "only evaluated after if is run", "never gets evaluated"] }
However, it appears the ability to add such behaviour with a custom operator is not currently supported
Line 231 in 9c805e9
There is already this large if-else chain within the apply
method which could be easily modified to allow for custom operators to added and executed here (perhaps via some configuration when registering the custom operator), which would allow users to define whether their custom operator should automatically traverse or not.
js-logic-engine another library for json-logic also has an implementation of a similar configuration when registering a custom operator with their traverse
option.
Would it be possible, to add a similar sort of functionality to this library when registering custom operators?