@briza/illogical
v2.2.2
Published
A micro conditional javascript engine used to parse the raw logical and comparison expressions, evaluate the expression in the given data context, and provide access to a text form of the given expressions.
Downloads
5,503
Readme
🚀 Getting Started
Get up and running with illogical in just a few steps.
Installation
# install illogical
npm install @briza/illogicalBasic Usage
// Import the illogical engine
import Engine from '@briza/illogical'
// Create a new instance of the engine
const engine = new Engine()
// Data context
const ctx = {
name: 'peter',
age: 21,
address: {
city: 'Toronto',
country: 'Canada',
},
}
// Evaluate an expression in the given data context
engine.evaluate(['>', '$age', 20], ctx) // true
// Accessing a property
engine.evaluate(['==', '$address.city', 'Toronto'], ctx) // true
// Data Type Casting
engine.evaluate(['==', '$age.(String)', '21'], ctx) // true
// Evaluate a logical expression
engine.evaluate(['AND', ['>', '$age', 20], ['==', '$name', 'peter']]) // true📚 Documentation
Core Concepts
Explore the supported expressions and their usage:
API Reference
Learn how to use the engine and its methods:
Customization
Customize the engine and the documentation:
Development Tools
For advanced usage like bytecode evaluation and debugging:
📖 Changelog
See changelog.md.
🤝 Contributing
See contributing.md.
📜 License
Illogical is released under the MIT license. See license.txt for details.
