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

Add support for longs: BigInt in toObject #1908

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jtbandes
Copy link

@jtbandes jtbandes commented Jul 6, 2023

Adds support for toObject({ longs: BigInt }), which converts longs to native BigInts.

This is structured as opt-in so that hopefully it can be shipped in a minor update without having to wait for a 8.x release.

I tested performance of conversion using both DataView.getBig(U)Int64 and plain bitwise arithmetic: https://jsbench.me/1lljqc4kd7/2 The DataView version was faster, but since getBig(U)Int64 is a relatively more recent addition, I provided a fallback for environments that don't support it.

See also:

Motivation:

@@ -36,7 +36,7 @@
},
"..": {
"name": "protobufjs",
"version": "7.1.2",
"version": "7.2.4",
Copy link
Author

Choose a reason for hiding this comment

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

This change appeared when I ran npm run build. Seems harmless and correct(?)

@goya
Copy link

goya commented Jul 6, 2023

too soon!

@jtbandes
Copy link
Author

Hi @alexander-fenster, any chance you would be able to take a look and provide some feedback on this? Thank you 🙏

@jtbandes
Copy link
Author

FYI I've published this fork on npm as @foxglove/protobufjs: https://www.npmjs.com/package/@foxglove/protobufjs

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.

None yet

2 participants