Skip to content

Feature Request: ability to add custom operators which are not automatically traversed for evaluation #116

Open
@Sykander

Description

@Sykander

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

if (op === "if" || op == "?:") {

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions