Create a new instance of the FunctionsFileReader with the specified options for parsing functions from a file.
Optionaloptions: Partial<FunctionsFileReaderOptions>Optional configuration for the reader.
ProtectedoptionsProtectedfunctionProtectedworkspaceThe workspace instance to which the parsed functions will be added. This allows for functions to recognize earlier declared components.
ProtectedremoveProtectedreadProtectedreadProtectedisProtectedisProtectedisParse 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.
The content of the functions file to parse.
The result of parsing, including the successfully parsed functions and any errors encountered.
Protectedcollect
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.