Comments (6)
The problem is that there is no true long support in JavaScript, as it falls back to double at values greater than 2^53. See: http://ecma262-5.com/ELS5_HTML.htm#Section_8.5
Therefore I decided to skip int64 for the moment and I am thinking about implementing the math long class from the closure library into ByteBuffer.js. It's just that I am not yet sure if it's worth the trouble because when working with JavaScript, it's simply better to use a double instead for large values. If you are working on something entirely new, it might already be an option for you to use a double.
from protobuf.js.
How about use int64 in c-types:
https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Int64
I'm not sure it works on other js platform such as chrome or nodeJS.
Actually I'm developing a game using cocos2dx with its js-binding base on SpiderMonkey:https://developer.mozilla.org/en/docs/SpiderMonkey
And our publisher need the user_id to be int64.
from protobuf.js.
I took a look but it doesn't seem that it's possible to do the required calculations on it, i.e. for varint encoding, and its available for spidermonkey only. However, you could use c-types on your own and transfer the values as custom types, let's say in a "bytes" field. Bytes fields take ArrayBuffers or ByteBuffers of arbitrary data. You could simply write the .hi() and .lo() portions into a ByteBuffer for example.
from protobuf.js.
I just finished int64 support in ByteBuffer.js through Long.js. For now, it's possible to work with sfixed64 fields.
However, this solves only a part of the overall 64bit support. I've added a comment with the details here: https://github.com/dcodeIO/ProtoBuf.js/blob/master/src/ProtoBuf/Lang.js
from protobuf.js.
0.9.13: fixed64 (uint64) through ByteBuffer.js>=1.2.1, Long.js>=1.1.0
from protobuf.js.
from protobuf.js.
Related Issues (20)
- Load .proto file content from variable HOT 2
- custom class is output undefined
- How to decode grpc-web-text
- Enum value ignored HOT 1
- Fails to parse "{" in options
- int64 precesion problem
- Enum reserved keyword removed when compiling proto from json
- Add Auth to Xhr fetch
- The problem with load
- Update from version 6.x.x to version 7.x.x
- not support eval and new Function()/Function() HOT 2
- how do you type decode(...)
- how do I type a namespace?
- how to fix property does not exist on type "Message<MessageType>"
- Cannot read properties of undefined (reading 'add') HOT 3
- protobuff.encode() does not work as expected
- Backport prototype setProperty checks to 6.11.3 HOT 5
- protobufjs-cli still pull older version of escodegen HOT 3
- [Feature Request] Explore all files in a folder/subfolder
- CVE-2022-25878 - Fix for version 5.0.3 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.js.