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)
- pbts produces incorrect typings for `message Object`
- Version `7.2.6` breaks build and throws an error `Error: ENOENT: no such file or directory, open ...` HOT 3
- Editions Suport
- Error: invalid wire type 6 at offset 297 is reported in the parsing field
- decode(new Uint8Array(data)) RangeError: index out of range: 97045 + 1 > 97045 HOT 1
- glob < 9 pulls in insecure depedendency, inflight HOT 1
- how to define protofile for [[1, 2, 3]]
- [Bug]Can not encode the embedded "oneof" keywords issue with sparkplugB schema
- Does it support running on quickjs?
- Prototype Pollution vulnerability HOT 6
- CustomError [ProtocolError]: missing required 'header'
- Support repeated options
- `pbts` does not generate comments for enum properties
- Descriptor binaries does not match the binaries generated using `protoc`
- Javascript enviroment, Json to protobuf text format
- C++ and JS compatability HOT 2
- npm exec `could not determine executable to run`
- Latest protobuf release not listed on CDNs HOT 8
- v6.11.4 still listed as vulnerable to CVE-2023-36665 HOT 1
- `pbts` generating syntax error on types when using multi-line `@typedef`s in static code HOT 1
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.