How to handle with UUID scope variables to evaluate using Math.js?

Discussão em 'Angular' iniciado por Erik Henrique, Maio 12, 2025.

  1. Im using Math.js to evaluate string math expressions, each 'variable' represent an Input, wich have its own id (UUID). so im setting this id's to a 'scope' variable to receive key-value pair.

    expressionScope: Record<string, number> = {
    "ind_e101611e-33e0-426d-9cf8-e922d74b8a54": 998,
    "ind_b7e5c845-0e83-4ca4-a90b-25d5f9cb06c5": 255


    but if i evaluate something like

    Math.evaluate("ind_e101611e-33e0-426d-9cf8-e922d74b8a54 + ind_b7e5c845-0e83-4ca4-a90b-25d5f9cb06c5" , expressionScope)


    it will trigger an Error, because "e101611e" and "33e0e101611e" isnt a valid token from scope array.

    the thing is: evaluate is 'confusing' the "-" from UUID with the real subtraction operator.What is a best way to deal with it instead of replacing "-" into "_" ?

    Continue reading...

Compartilhe esta Página