I'm having some troubles with buffers with non-zero byteOffset. It seems e.g. Node buffers can automatically have non-zero byteOffsets, as I'm just reading a file directly from disk, but those byteOffsets are ignored when DataViews are constructed. I didn't know this is a thing, but I also can't seem to find much about it, except that people recommend constructing a dataview like this:
const view = new DataView(patch.buffer, patch.byteOffset, patch.byteLength);
But currently, parse() creates a DataView like this:
const view = new DataView(patch.buffer);
Expected: parse() should work for any valid Uint8Array/Buffer, including sliced/subarray views.
Actual: it can throw Patch is not valid... even when the visible bytes begin with a valid BPS1 header.
This ignores patch.byteOffset, so parsing fails when patch is a Uint8Array/Node Buffer view into a larger backing buffer.
Example: a buffer whose visible bytes start with BPS1 can still fail because DataView reads from the start of the underlying ArrayBuffer, not from the start of the view.
This might be appliccable to other DataView constructors as well
I'm having some troubles with buffers with non-zero byteOffset. It seems e.g. Node buffers can automatically have non-zero byteOffsets, as I'm just reading a file directly from disk, but those byteOffsets are ignored when DataViews are constructed. I didn't know this is a thing, but I also can't seem to find much about it, except that people recommend constructing a dataview like this:
But currently,
parse()creates aDataViewlike this:Expected: parse() should work for any valid Uint8Array/Buffer, including sliced/subarray views.
Actual: it can throw Patch is not valid... even when the visible bytes begin with a valid BPS1 header.
This ignores patch.byteOffset, so parsing fails when patch is a Uint8Array/Node Buffer view into a larger backing buffer.
Example: a buffer whose visible bytes start with BPS1 can still fail because DataView reads from the start of the underlying ArrayBuffer, not from the start of the view.
This might be appliccable to other DataView constructors as well