6utt3rfly / jse-eval

Javascript Expression Evaluator
MIT License
22 stars 7 forks source link

assignment expression not work . #56

Closed TBSten closed 2 years ago

TBSten commented 2 years ago

hi .

I want to run the code below and use an "assignment statement" to make changes to the list of variables.

code

import jseEval, { registerPlugin } from "jse-eval";
import * as assignmentPlugin from "@jsep-plugin/assignment";
console.log("assignmentPlugin", assignmentPlugin);

registerPlugin(
    assignmentPlugin,
)

const expression = "count = 10";
const variables = {
    "a": "variable example",
    "b": 1234,
}

console.log(jseEval.evalExpr(expression, variables))
console.log(variables) //expect : { "a": "variable example" , "b": 1234, "count": 10 }

output

Error: Unexpected "=" at character 6

Is there anything missing?

it look like registerPlugin is wrong .

TBSten commented 2 years ago

The cause was my XXX setting. I reconfigured it properly and it worked as expected.

If the administrator of this repository has time, you can have this issue removed.

6utt3rfly commented 2 years ago

Glad you were able to resolve it, @TBSten 🙂