Giter VIP home page Giter VIP logo

Comments (11)

RReverser avatar RReverser commented on September 26, 2024

From the end of what?

from jdataview.

SoniEx2 avatar SoniEx2 commented on September 26, 2024

From the end of the byte, obviously.

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

Not very obvious - could be the end of the buffer as well. It sounds like this should be already doable via combination of skip + reading bits, if you want to ignore those in the beginning.

from jdataview.

SoniEx2 avatar SoniEx2 commented on September 26, 2024

It doesn't work right.

var jd = new jDataView(2);
jd.writeUint8(0xFE); // 0b11111110
jd.writeUint8(0xFE); // 0b11111110
for (;;) {
  console.log(jd.getUnsigned(-1));
}

Output:

0
63
31
15
7
3
1
0
0
63
31
15
7
3
1
0
0
RangeError

(Did I just put in 16 bits and read back 17 bits? Apparently. And they weren't even right.)

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

You are reading negative length - as I said above, this is not supported. You should be using combination of skip + reading bits if you want to read only some bits in the end of byte.

from jdataview.

SoniEx2 avatar SoniEx2 commented on September 26, 2024

I want to read the bits backwards. (Lovely compression format I'm dealing with does little-endian BIT order)

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

Oh my... :( Well, what I can recommend is to look into jBinary and simply define custom type that would perform bit-by-bit reversion. This is not kind of stuff that is supported natively on any platforms or even widely used, so I don't think it should be in scope of jDataView, but should be pretty easy to implement as custom reusable type.

from jdataview.

SoniEx2 avatar SoniEx2 commented on September 26, 2024

Well in assembly you just shift left/right and test the carry bit...

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

Well if you need only one last bit, then it's easy here as well - just getUint8() & 1 (or, if you need the highest and not lowest - getUint8() >>> 7).

from jdataview.

SoniEx2 avatar SoniEx2 commented on September 26, 2024

Why was this closed?

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

I replied above that it's both already possible to do what you want (and even provided how), and adding it to base API just for sugar in specific cases doesn't make much sense.

from jdataview.

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.