import { evaluate , evaluateVariableNode } from './evaluate' ; import { Nodes , isExpressionNode , isLiteralNode , Options , isVariableNode } from './interfaces' ; import { parse } from './parse' ; returns export function transform ( input , options ) { const ast = typeof input === 'string' ? parse ( input ) : input ; return ast . map ( ( node ) : string => { if ( isLiteralNode ( node ) ) return node . value ; if ( isExpressionNode ( node ) ) return evaluate ( node , options ) ; if ( isVariableNode ( node ) ) return evaluateVariableNode ( node , options ) ; throw new Error ( `Unexpected expression node type ${ node . type }` ) ; } ) . join ( '' ) ; }