Class HFilter

Parses haystack filters so they can be validated and converted into different types of queries.

This class serves as the main entry point for working with Haystack Filters in this module.

As well as static methods, this class also utilizes the builder pattern for the instance methods.

Hierarchy

  • HFilter

Constructors

Properties

Methods

Constructors

  • Constructs a new haystack filter from the string.

    This will parse the filter string to a node.

    Parameters

    • filter: string | Node

      The haystack filter or an already parsed AST node.

    Returns HFilter

    Throws

    An error if the filter is invalid.

Properties

_isHFilter: true = true

Used for a type guard check.

node: Node

The internal parsed node of the current haystack filter.

Methods

  • Evalulate a node against an object. The object contains properties used in the evaluation.

    Parameters

    Returns boolean

    The result of the evaluation.

  • Generate a Haystack Filter string from a node.

    Returns string

    The haystack filter.

    Throws

    An error is thrown if the haystack filter is invalid.

  • Evalulate a node against an object. The object contains properties used in the evaluation.

    Parameters

    • node: Node

      The AST node to evaluate.

    • context: EvalContext

      The evaluation context.

    Returns boolean

    The result of the evaluation.

  • Return true if the value is a haystack filter object.

    Parameters

    • value: unknown

      The value to test.

    Returns value is HFilter

    True if the value is a haystack filter.

  • Parse a Haystack Filter and returns it's base AST node.

    Parameters

    • filter: string

      The Haystack Filter to parse.

    Returns Node

    The base AST node for the haystack filter.

    Throws

    An error if the haystack filter isn't valid.

  • Generate a Haystack Filter string from a node.

    Parameters

    • node: Node

      The AST node to generate the Haystack Filter string from.

    Returns string

    The haystack filter.

    Throws

    An error is thrown if the haystack filter is invalid.

Generated using TypeDoc