Giter Site home page Giter Site logo

Comments (3)

dcodeIO avatar dcodeIO commented on June 26, 2024

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.

majimboo avatar majimboo commented on June 26, 2024

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.

dcodeIO avatar dcodeIO commented on June 26, 2024

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
...

See

from bytebuffer.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.