Pondermatic is a functional effect system-driven rules engine designed for use with Clojure, ClojureScript, and JavaScript. This document provides an API reference for using Pondermatic with JavaScript.
Install via npm:
npm install @totalperspective/pondermatic
- Description: Creates a new engine instance.
- Parameters:
name
(string): The name of the engine.resetDb
(boolean): Whether to reset the database.
- Returns: An engine instance.
- Example:
import pondermatic from '@totalperspective/pondermatic'; const engine = pondermatic.createEngine('example', true);
- Description: Defines a set of rules.
- Parameters:
rules
(Array): An array of rule definitions.- Returns: A ruleset.
- Example:
const rules = pondermatic.ruleset([ { id: 'example-rule', 'rule/when': { 'data/key': '?value' }, 'rule/then': { 'data/new-key': '?value' } } ]);
- Description: Creates a dataset from an array of data objects.
- Parameters:
data
(Array): An array of data objects.- Returns: A dataset.
- Example:
const data = pondermatic.dataset([{ key: 'value' }]); pondermatic.sh(engine, { '->db': rules }); pondermatic.sh(engine, { '->db': data });
- Description: Executes a query on the engine.
- Parameters:
engine
(Engine): The engine instance.query
(string): The query string.args
(Array): An array of arguments for the query.callback
(Function): A callback function to handle the query results.
- Returns: Query results.
- Example:
const q = pondermatic.q( engine, "[:find ?v . :where [?id :data/key ?v]]", [], r => { if (!r) { return; } console.log(r); } );
- Description: Stops the engine.
- Parameters:
engine
(Engine): The engine instance.
- Returns: None.
- Example:
pondermatic.stop(engine);
- Added support for JavaScript.
- Improved performance optimizations.
- Enhanced data source integrations.
- Additional rule definition capabilities.
- Expanded documentation and examples.