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

How to decode 64-bit integer fields into plain Javascript numbers? #933

Closed
luciopaiva opened this issue Oct 19, 2017 · 3 comments
Closed

Comments

@luciopaiva
Copy link

protobuf.js version: 6.8.0

Say my protocol has some 64-bit integer fields, but I know their values will always fit into regular Javascript's primitive number types; so I don't want to use Long.js objects to represent them.

I've read somewhere that using Long.js is optional, but I can't find instructions on how to disable it. I am generating static sources using pbjs and it has an option to --force-longs, but Longs seem to always be enabled by default.

I did a hack which consists of executing a bash script after npm install that runs rm -fr node_modules/long. This seems to solve the issue, but I was wondering if there is a more proper way of disabling it.

@luciopaiva luciopaiva changed the title How to decode 64-bit integer fields into plain Javacsript numbers? How to decode 64-bit integer fields into plain Javascript numbers? Oct 19, 2017
@dcodeIO
Copy link
Member

dcodeIO commented Oct 19, 2017

Does this work?

protobuf.util.Long = null;
protobuf.configure();

@luciopaiva
Copy link
Author

Just checked and it did work! Awesome, thanks. Is this documented somewhere? If it isn't, maybe I could contribute by adding that information to the README. Let me know if it makes sense to you and I can send you a PR.

@dcodeIO
Copy link
Member

dcodeIO commented Oct 19, 2017

There is a hint here that this functionality exists.

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

No branches or pull requests

2 participants