Methods
compilePath(path)
Create a compacted fact name from a given fact name. Path do not end with a trailing '/'.
'../' Denote the parent term. Move up one term in the context or path.
'./' Denote the current term. Removed from the context or path.
Examples:
'/a/given/../correct/./path' is compiled to '/a/correct/path'
Parameters:
| Name | Type | Description |
|---|---|---|
path |
String | The path or context to compile into a context. |
- Source:
equals(a, b)
Compare two values and return true if they are equal. Fix date comparison issue and insure
both types are the same.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
* | The first value used to compare. |
b |
* | The second value used to caompare. |
- Source:
extractParameterList(code)
Extracts the raw parameter list (without the surrounding parenthesis) from the source code of
a function. Returns an empty string when the function has no parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
code |
String | The function source code. |
- Source:
getContext(compiledPath)
Extracts the context from the fact or rule name. Must be a compiled path, not a path that
contains "../" or "./".
Parameters:
| Name | Type | Description |
|---|---|---|
compiledPath |
String | The compiled path to extract the context from. |
- Source:
Example
Given the rule path: '/path/to/some/rule'
The returned value would be: '/path/to/some'
(generator) parseFactPaths(rule)
Generator that parses all fact paths derived from the given rule parameters. Either return the
parameter name or the path contained by the optional attribute comment. Supports regular
functions as well as lambda (arrow) functions, with or without parenthesis around a single
parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
rule |
AsyncFunction | The rule |
- Source:
Example
Using an attribute comment:
async function(/¤@ /path/to/fact ¤/ param1, param2) {}
async (/¤@ /path/to/fact ¤/ param1, param2) => {}
async /¤@ /path/to/fact ¤/ param1 => {}
In the above example:
1) ¤ replaces * because using * and / one after the other ends the documentation comment.
2) returned fact paths would be ['/path/to/fact', 'param2'] (or ['/path/to/fact'] for the
single parameter lambda).