silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.19k stars 239 forks source link

Tokens property not exposed on Expression TypeScript definition #217

Open philipAtHach opened 4 years ago

philipAtHach commented 4 years ago

Expression has a tokens property available that has not been added to the TypeScript definitions. Is that property intended to be private, or should it be added to the definition?

silentmatt commented 4 years ago

The tokens property is visible mostly out of convenience since JavaScript doesn't have private properties, and as a debugging aid to view the output of the parser. There could be use cases for modifying it to do some advanced post-processing on expressions, but I'd consider that an advanced usage that's outside the scope of what's officially supported. It's also not a great name, since it's really the "compiled" instructions, not tokens. I think the name probably made sense at one point, but it's gone through a couple major refactorings and doesn't actually reflect what they are anymore.

So the short answer is, for now I'd consider it a private implementation detail, but that could change in the future, but probably with a different name.