Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple typings for the node-rules package (https://github.com/mithunsatheesh/node-rules)
declare module 'node-rules' {
export default class RuleEngine {
constructor(rules?: Rule[] | Rule, options?: object);
register(rule: Rule): any;
sync(): Rule[] | void;
execute(fact: {[x: string]: any}, cb: (data: {result?: any, reason?: any, [x: string]: any}) => void): void;
findRules(filter?: any): Rule[] | void;
turn(state: string, filter: any): Rule[] | void;
prioritize(priority: number, filter: any): Rule[] | void;
toJSON(): string;
fromJSON(rules: string): any;
rule(): Rule | void;
when(condition: any): void;
restart(): any;
stop(): void;
next(): any;
}
export interface Rule {
name: string;
priority?: number;
condition: (R: RuleEngine) => void;
consequence: (R: RuleEngine) => void;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment