Skip to content

Variable names cannot include spaces #52

Open

Description

@wjeffery95

It would be useful to be able to have spaces in variable to aid readability.

Example

const squareMyVariable = new Formula('[My Variable]^2');
fObj.evaluate({"My Variable": 3}); // Throws: Uncaught Error: Cannot evaluate MyVariable: No value given

The error is thrown because when the function is cleaned we remove all spaces meaning the variable no longer matches, and would instead have to be MyVariable.

Activity

  1. wjeffery95 commented on May 7, 2023

    @wjeffery95
    Author

    I'm happy to contribute a solution but don't see anything detailing how you'd like contributions to be submitted. Thanks

  2. bylexus commented on May 7, 2023

    @bylexus
    Owner

    I clean the formula intentionally (removing whitespaces), to make the parsing simpler. But this should not be a big problem to have it changed, I don't see any drawbacks from this feature.
    If you want to contribute, just create a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions