createRuleEngine()
Factory function to create a rule engine instance.Parameters
Returns
Engine instance with the following methods.evaluateExpr()
Evaluate a rule expression against data.Parameters
Rule expression object
Data to evaluate against
Returns
Examples
- Basic
- Complex
- Error Handling
registerOperator()
Register a custom operator.Parameters
Operator name (e.g., ‘custom’)
Operator implementation:
(args, context) => booleanExample
getOperators()
Get all registered operator names.Returns
string[] - Array of operator names
getMetrics()
Get performance metrics.Returns
Example
getCacheStats()
Get cache statistics.Returns
getConfig()
Get current configuration.Returns
object - Current configuration
clearCache()
Clear all caches.resolvePath()
Resolve a path in context data.Parameters
Data context
Dot-notation path (e.g., ‘user.profile.name’)
Default if path doesn’t exist
Example
Complete Example
Error Handling
All methods handle errors gracefully:TypeScript
Full TypeScript support:Related
Stateful Engine
Event-driven engine with state tracking
Rule Helpers
Fluent API for building rules
Operators
All built-in operators
Custom Operators
Create custom operators
