Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple instances of jsep with different operators #211

Open
cmarcao opened this issue Feb 7, 2022 · 5 comments
Open

Multiple instances of jsep with different operators #211

cmarcao opened this issue Feb 7, 2022 · 5 comments

Comments

@cmarcao
Copy link

cmarcao commented Feb 7, 2022

Hi guys.

There is any reason to have a singleton parser? There is no chance to have more than one jsep with different configuration running in the same app at client side?

Thank you,

Carlos Marcão

@6utt3rfly
Copy link
Collaborator

@EricSmekens and @LeaVerou - any thoughts on this? I know when we first started moving into a plugin system, this was discussed, but then dropped to reduce complexity/scope. I feel like this could be useful in some cases and could be re-done similar to what this commit removed?

@LeaVerou
Copy link
Collaborator

Any proposal for additional complexity should be justified through use cases. What are the use cases for having multiple parsers with different configurations and how common are they?

@joeflateau
Copy link

@LeaVerou I would like to use jsep in a library with a custom binary operator but I cannot because of the singleton nature of it might lead to transient, hard to locate bugs

@Julusian
Copy link

I think what @joeflateau said sums it up for me.
If writing an application, then the singleton nature most likely isnt an issue.
But if writing a library, it could be an issue if some other component of the application also uses jsep.

I was considering using this for an application, where I would want to be able to parse boolean expressions and number expressions separately under different rules. While I could manage with this singleton, it would require swapping out the acceptable operators and things each time I want to parse an expression, which is rather wasteful.

@jdanyow
Copy link

jdanyow commented Jul 29, 2023

related to #28

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

No branches or pull requests

6 participants