Comments (3)
Assuming that buf
has been filled and properly flipped
var w = buf.readUint32() // also no offset
var x = buf.readUint32()
var y = buf.readUint32()
var z = buf.readUint32()
will read one Uint32 after another (relative). This is equal to (absolute):
var w = buf.readUint32(0)
var x = buf.readUint32(4)
var y = buf.readUint32(8)
var z = buf.readUint32(12)
buf.offset = 16;
Regarding byte order: Once set to LE, all operations following will use LE until you set it to BE again.
buf.LE();
...
...
...
buf.BE();
from bytebuffer.js.
Yea, I realized. Got it solved. Except I don't get why I should properly FLIP it? What is the implications of flip? I didn't use flip but I'm getting proper results.
Thanks though, this is great :)
from bytebuffer.js.
If you just wrap some data, flipping is not necessary. It is, though, if you fill the buffer successively just like you read it in the example above:
var buf = new ByteBuffer(6); // initializes with offset = 0, limit = 6
buf.writeUint32(123); // afterwards: offset = 4, limit = 6
buf.flip(); // afterwards: limit = offset = 4, offset = 0, ready for read operations
...
from bytebuffer.js.
Related Issues (20)
- Message.decode ignores `length` argument HOT 1
- bytebuffer.js in Android WebView throws TypeError HOT 4
- Could not resolve memcpy when trying to roll-up a bundle HOT 1
- Uncaught TypeError: buf.readUint64 is not a function HOT 2
- how to use for browser,where can i find a example code HOT 1
- why is happend
- ByteBuffer.js used from TypeScript HOT 2
- Passing Long.js to writeInt64 Fails with Type Error HOT 3
- toBuffer() docs wrong? HOT 3
- Support for ArrayBuffer/Buffer pooling
- Comparing two ByteBuffers i.e. equal method HOT 2
- npm run build - Error: ENOENT: no such file or directory, open 'bytebuffer.js/src/ByteBuffer.js' in meta program of 'bytebuffer.js/src/wrap-node.js':
- Prepend does not include the zero bytes
- hex_encode error HOT 2
- Add Support for Bigint
- Create ByteBuffer from existing ArrayBuffer? HOT 2
- Remove usages of deprecated Buffer() HOT 2
- Can we cut a new release, and update npmjs?
- Can't resolve 'memcpy' in '/vercel/xxxxx/node_modules/bytebuffer/dist' HOT 3
- Not released for a long time - so not available as a versioned package from npm
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 bytebuffer.js.