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

feat: added bigint force long option #742

Merged
merged 3 commits into from Dec 29, 2022
Merged

Conversation

azizghuloum
Copy link
Contributor

Also added simple tests based on string option.

@azizghuloum azizghuloum changed the title added bigint force long option feat: added bigint force long option Dec 28, 2022
Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This looks great @azizghuloum!

I was assuming we'd have to wait on protobufjs to support bigint natively, but great call that we can just do the adapting on the way in/out.

I had one question about potentially using more mathy to/from conversion methods, from the longfn repo, but definitely optional and happy to merge this as-is. Just let me know, thanks!

const longToBigint = conditionalOutput(
"longToBigint",
code`
function longToBigint(long: ${Long}) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if long.js had a built-in toBigInt and didn't find anything, but I did find a github issue where someone linked to their long.js fork that has a toBigInt:

https://github.com/consento-org/longfn/blob/main/index.mjs#L654

Wdyt about adapting their toBigInt and maybe even fromBigInt?

https://github.com/consento-org/longfn/blob/main/index.mjs#L100

Seems like those would surely be faster than going through toStrings, so seems like a good idea, but also willing to leave it as a follow-up issue if you'd like to ship this as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I was just trying to get it to work correctly with zero effort towards optimizing anything. This, and a few other things in the timestamps can definitely be improved, but I think eventually protobuf's Reader and Writer will support bigints and drop Long. Regardless, I think it should be merged now and any improvements be done later.

@stephenh stephenh merged commit 3964e57 into stephenh:main Dec 29, 2022
stephenh pushed a commit that referenced this pull request Dec 29, 2022
# [1.137.0](v1.136.1...v1.137.0) (2022-12-29)

### Bug Fixes

* Additional fix for structs with useMapType. ([#743](#743)) ([3264b0f](3264b0f))
* Fix codegen for google.protobuf.Struct with useMapType=true ([#740](#740)) ([0647151](0647151))

### Features

* added bigint force long option ([#742](#742)) ([3964e57](3964e57))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.137.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants