json-logic-engine
Version:
Construct complex rules with JSON & process them.
58 lines (57 loc) • 1.58 kB
TypeScript
/**
* Checks if the method & its inputs are deterministic.
* @param {*} method
* @param {*} engine
* @param {BuildState} buildState
* @returns
*/
export function isDeterministic(method: any, engine: any, buildState: BuildState): any;
declare namespace _default {
export { build };
export { buildAsync };
export { buildString };
}
export default _default;
/**
* Used to keep track of the compilation.
*/
export type BuildState = {
engine?: any;
notTraversed?: any;
methods?: any;
state?: any;
processing?: any[];
async?: any;
above?: any[];
asyncDetected?: boolean;
values?: any;
avoidInlineAsync?: boolean;
extraArguments?: string;
/**
* A function that can be used to compile a template.
*/
compile?: (strings: string[], ...items: any[]) => {
compiled: string;
};
};
/**
* Synchronously compiles the logic to a function that can run the logic more optimally.
* @param {*} method
* @param {BuildState} [buildState]
* @returns
*/
export function build(method: any, buildState?: BuildState): any;
/**
* Asynchronously compiles the logic to a function that can run the logic more optimally. Also supports async logic methods.
* @param {*} method
* @param {BuildState} [buildState]
* @returns
*/
export function buildAsync(method: any, buildState?: BuildState): Promise<any>;
/**
* Builds the string for the function that will be evaluated.
* @param {*} method
* @param {BuildState} buildState
* @returns
*/
export function buildString(method: any, buildState?: BuildState): any;