@samatawy/rules
    Preparing search index...

    Class FunctionsFileReader

    Reader class for parsing functions files that define key-value pairs of functions to be used within the rule engine. You should use this class to read functions from a text file, where each line (or block) defines a function in the format "function NAME(PARAMS) { BODY }". The reader will parse the file content and return an object containing the successfully parsed functions as well as any errors encountered during parsing. The reader supports both line-by-line and block-by-block reading, allowing for flexible formatting of the functions file. It also includes error handling for invalid syntax and duplicate function names, ensuring that the resulting functions object is valid and usable within the rule engine.

    N.B. Declarations need to be in order, otherwise errors will be returned.

    N.B. This is a transactional safe reader. If you provide a workspace and select the option accept: 'all', then that workplace will not be affected if any errors are encountered.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    functionParser: FunctionParser
    workspace: Workspace

    The workspace instance to which the parsed functions will be added. This allows for functions to recognize earlier declared components.

    Methods

    • Parse the content of a functions file and return the result, including the successfully parsed functions and any errors encountered during parsing. If a Workspace was passed in options, that Workspace will be changed to reflect successful declarations.

      Parameters

      • fileContent: string

        The content of the functions file to parse.

      Returns FunctionsFileResult

      The result of parsing, including the successfully parsed functions and any errors encountered.