rscarson / rustyscript

Effortless JS integration for rust
MIT License
158 stars 17 forks source link

Make `rustyscript` global object optional & able to be renamed #175

Closed ac-z closed 1 month ago

ac-z commented 1 month ago

Right now, registered functions are made available under the functions and async_functions proxies within the global rustyscript object, alongside the essential functions bail and register_entrypoint.

This is a good default, but I think it would be good to allow more flexibility here. I have the following additions to the API in mind:

Things to consider

rscarson commented 1 month ago

I really don't see the point It's JavaScript, users can just rename it, or make their own object referencing mine

This would just add complexity

Users could just as easily:

globalThis.myFunctions = {
    rustyscript.functions.a, rustyscript.functions.b
}
ac-z commented 1 month ago

I really don't see the point It's JavaScript, users can just rename it, or make their own object referencing mine

Was under the impression that freezing in JavaScript doesn't let you delete or rename. Closing.