Created
March 3, 2020 14:44
-
-
Save jxub/639f9267c2fac3316485ff7194fa915e to your computer and use it in GitHub Desktop.
Simple typings for the node-rules package (https://github.com/mithunsatheesh/node-rules)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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