UNPKG

mframejs

Version:
27 lines (24 loc) 764 B
import { traverseAST } from './ast/traverseAst'; import { tokenize } from './ast/tokenize'; import { generateAST } from './ast/generateAst'; import { Cache } from '../utils/exported'; import { IBindingContext } from '../interface/exported'; /** * creates binding expression by getting tokens from the text * */ export function evaluateExpression(text: string, _class: IBindingContext) { if (text) { let ast: any; if (Cache.astMap.has(text)) { ast = Cache.astMap.get(text); } else { const tokens = tokenize(text); ast = generateAST(tokens); Cache.astMap.set(text, ast); } return traverseAST(ast, _class); } else { return ''; } }