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

Introduce wasm_bindgen support and expose a toNumber method for use in JavaScript #614

Closed

Conversation

ChristianIvicevic
Copy link

@ChristianIvicevic ChristianIvicevic commented Oct 13, 2023

I've been exploring potential implementations and would like to discuss an initial, lightweight contribution. Instead of fully binding and exporting the entire crate, my intention is to simplify it by exporting the Decimal type to JavaScript and making it possible to map it to a number type. I don't anticipate performing operations on Decimals from the JavaScript side.

To achieve all of this, I've added a conditional attribute to the Decimal struct and introduced two methods within a conditional module, Decimal::to_number and Decimal::from_number, inspired by decimal.js.

Fixes #613

@paupino
Copy link
Owner

paupino commented Nov 14, 2023

Thank you for putting this together - it's looking very complete for a new feature!
We'll need to play a little bit to get this working with CI. It'll likely be failing on the build all features step - unfortunately the step is required for documentation generation so I'll need to think about how to skirt around this (or whether it's still necessary).

@ChristianIvicevic
Copy link
Author

Thank you for putting this together - it's looking very complete for a new feature! We'll need to play a little bit to get this working with CI. It'll likely be failing on the build all features step - unfortunately the step is required for documentation generation so I'll need to think about how to skirt around this (or whether it's still necessary).

Okay cool. Since I haven't been coding a lot in my free time lately, I haven't fully explored whether I'm fully happy with the from_number function given it is fallible at the moment. Once I've confirmed I'm happy with the exposed API I can promote this draft to a full PR then we can explore the CI errors.

@ChristianIvicevic
Copy link
Author

@paupino Just wanted to drop by and mention that I will not have time to finish this in the near future and plan to spend some time on it after Christmas at which point I can invest time to rebase and tweak the API properly.

@ChristianIvicevic
Copy link
Author

Due to a minor conflict with an app of mine that depends on my personal fork I had to open an independent new PR #650 that provides the feature.

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

Successfully merging this pull request may close these issues.

Feature Request: Support wasm_bindgen for Decimal
2 participants