import type Delegate from './core/Delegate' import type JSONObject from './instances/JSONObject' import Program from './core/Program' export default class ExpressionRunner { /** * Runs an expression with parameters * * @param source Expression source * @param params Expression parameters * @returns The result of the expression */ public static run(source: string, params: JSONObject): any { const delegate: Delegate = this.getDelegate(source) return delegate.invoke(params) } /** * Gets the delegate for the expression * * @param source Expression source * @returns A delegate to invoke */ public static getDelegate(source: string): Delegate { // Parse the source and return a delegate return new Program(source).parse() } }