Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i/o options to fromBytes / toBytes #70

Open
martinheidegger opened this issue Oct 2, 2018 · 0 comments
Open

Add i/o options to fromBytes / toBytes #70

martinheidegger opened this issue Oct 2, 2018 · 0 comments

Comments

@martinheidegger
Copy link

Its nice to have with fromBytes and toBytes utils to interact with a data-stream

Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {

However it would be useful if someone using this API wouldn't need to splice the section to be read. By adding a byteOffset it would be possible to just read a section.

bytes[byteOffset++] |
bytes[byteOffset++] << 8 |
...

Similar for toBytes

LongPrototype.toBytesLE = function toBytesLE() {

function toBytesLE(bytes, byteOffset) {
  if (!bytes) {
    bytes = {}
  }
  if (!byteOffset) {
    byteOffset = 0
  }
  bytes[byteOffset++] = lo & 0xff
  // ...
  return bytes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants