Cannot access 'tokenizeExpression' before initialization

40 Views Asked by At

I want sample code related to tokenizeExpression, parseExpression, evaluateExpression

why? like this

Field 1 requires conditions including comparision operator, if, etc... Field 2 must be displayed data following above condition.

a<50||60>b?hello:hi

if you typed the code to above field 1, then field2 must be displayed result

to solve above the issue I have done following code

const {tokenizeExpression, parseExpression, evaluateExpression, printExpression, CustomData}  = require("expression-engine")

function hello (val) {
var parent =  val.parentNode// this is parent node
 var changedValue = val.innerHTML// change value by typing
 var obj = parent.getAttribute('obj')
 obj = obj.split("'").join("\"")
 obj = JSON.parse(obj)
 var preValue = obj.value_regular//first field
 var preDisplay = obj.display_regular//second field

 const valuetokens = tokenizeExpression(preValue)
 const valueast = parseExpression(valuetokens)
 const valueresult = evaluateExpression(valueast)

but there is error following

cannot access 'tokenizeExpression' before initialization

I want to get result or what is the cause above error

0

There are 0 best solutions below