long.js
long.js copied to clipboard
Add i/o options to fromBytes / toBytes
Its nice to have with fromBytes and toBytes utils to interact with a data-stream
https://github.com/dcodeIO/long.js/blob/9448e61647f884144da26e5c13b503d586ad644b/src/long.js#L1329
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
https://github.com/dcodeIO/long.js/blob/9448e61647f884144da26e5c13b503d586ad644b/src/long.js#L1277
function toBytesLE(bytes, byteOffset) {
if (!bytes) {
bytes = {}
}
if (!byteOffset) {
byteOffset = 0
}
bytes[byteOffset++] = lo & 0xff
// ...
return bytes
}