fix add on dataview missing byteOffset from previous dv
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
DataView.prototype.add = function (offset) {
|
DataView.prototype.add = function (offset) {
|
||||||
return new DataView(this.buffer, offset);
|
return new DataView(this.buffer, offset + this.byteOffset);
|
||||||
};
|
};
|
||||||
DataView.prototype.writeU8 = function (val) {
|
DataView.prototype.writeU8 = function (val) {
|
||||||
return this.setUint8(0, val);
|
return this.setUint8(0, val);
|
||||||
|
|||||||
@@ -106,6 +106,13 @@ describe("module", () => {
|
|||||||
XqBytesEnc(in_buf, long_dec_bytes.byteLength, 4); // this mutates in_buf
|
XqBytesEnc(in_buf, long_dec_bytes.byteLength, 4); // this mutates in_buf
|
||||||
assert.deepEqual(new Uint8Array(in_buf.buffer), long_enc_bytes);
|
assert.deepEqual(new Uint8Array(in_buf.buffer), long_enc_bytes);
|
||||||
});
|
});
|
||||||
|
/* TODO
|
||||||
|
it("decrypts offset dataviews", () => {
|
||||||
|
const in_buf = new DataView(simple_enc_bytes.buffer.slice(0));
|
||||||
|
XqBytesDec(in_buf, simple_enc_bytes.byteLength, 4); // this mutates in_buf
|
||||||
|
assert.deepEqual(new Uint8Array(in_buf.buffer), simple_dec_bytes);
|
||||||
|
});
|
||||||
|
*/
|
||||||
it("reverts Enc with Dec", () => {
|
it("reverts Enc with Dec", () => {
|
||||||
const in_buf = new DataView(long_dec_bytes.buffer.slice(0));
|
const in_buf = new DataView(long_dec_bytes.buffer.slice(0));
|
||||||
XqBytesEnc(in_buf, long_dec_bytes.byteLength, 4); // this mutates in_buf
|
XqBytesEnc(in_buf, long_dec_bytes.byteLength, 4); // this mutates in_buf
|
||||||
|
|||||||
Reference in New Issue
Block a user