image-js / iobuffer

Read and write binary data in ArrayBuffers
http://image-js.github.io/iobuffer/
MIT License
43 stars 6 forks source link

question: back n bytes #51

Closed ghost closed 1 year ago

ghost commented 1 year ago

Given that there is buffer.skip() would it be worth to have a buffer.back(n) ?

I was just writing (sorry for the example)

  buffer.offset -= 4;//back from parameter reading
  const sequences = buffer.readUint16();
  buffer.skip(2) //now skip the parameters

And wondered about it. I am aware that skip(-2) should do, but it may not be semantically that useful.

targos commented 1 year ago

adding buffer.back(n) sgtm. would you like to make a PR?

ghost commented 1 year ago

Yes, I'll try.