UNPKG

@pawel-up/jexl

Version:

Javascript Expression Language: Powerful context-based expression parser and evaluator

19 lines 865 B
import { Grammar, ASTNode } from './grammar.js'; export type Context = Record<string, unknown>; export default class Expression<R = unknown> { _grammar: Grammar; _exprStr: string; _ast: ASTNode | null; constructor(grammar: Grammar, exprStr: string); compile(): this; eval(context?: Context): Promise<R>; evalAsString(context?: Context): Promise<string>; evalAsNumber(context?: Context): Promise<number>; evalAsBoolean(context?: Context): Promise<boolean>; evalAsArray(context?: Context): Promise<(R extends (infer E)[] ? E : R)[]>; evalAsEnum(context: Context | undefined, allowedValues: readonly R[]): Promise<R | undefined>; evalWithDefault(context: Context | undefined, defaultValue: R): Promise<R>; _eval(context: Context): Promise<R>; _getAst(): ASTNode | null; } //# sourceMappingURL=Expression.d.ts.map