Skip to content

Commit

Permalink
fix: resizable array buffer close gh-37
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Sep 21, 2024
1 parent b8a94dd commit cab1952
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -699,6 +699,7 @@ function BuiltIn (preset) {
const json = typeson.stringify({a});
const obj = typeson.parse(/** @type {string} */ (json));
expect(obj.a).to.be.an.instanceOf(Float64Array);
expect(obj.a.buffer.resizable).not.equal(true);
expect(obj.a.length).to.equal(3);
expect(obj.a[0]).to.equal(23.8);
expect(obj.a[1]).to.equal(-15);
4 changes: 2 additions & 2 deletions types/arraybuffer.js
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ const arraybuffer = {
stateObj.buffers.push(b);
return {
s: encode(b),
maxByteLength: b.maxByteLength
maxByteLength: b.resizable ? b.maxByteLength : undefined
};
},
revive (
@@ -49,7 +49,7 @@ const arraybuffer = {
}
const buffer = decode(
/** @type {string} */ (b64.s),
{maxByteLength: b64.maxByteLength}
b64.resizable ? {maxByteLength: b64.maxByteLength} : undefined
);
stateObj.buffers.push(buffer);
return buffer;
4 changes: 3 additions & 1 deletion types/dataview.js
Original file line number Diff line number Diff line change
@@ -26,7 +26,9 @@ const dataview = {
stateObj.buffers.push(buffer);
return {
encoded: encode(buffer),
maxByteLength: buffer.maxByteLength,
maxByteLength: buffer.resizable
? buffer.maxByteLength
: undefined,
byteOffset,
byteLength
};
4 changes: 3 additions & 1 deletion types/typed-arrays.js
Original file line number Diff line number Diff line change
@@ -43,7 +43,9 @@ function create (TypedArray) {
}
stateObj.buffers.push(buffer);
return {
maxByteLength: buffer.maxByteLength,
maxByteLength: buffer.resizable
? buffer.maxByteLength
: undefined,
encoded: encode(buffer),
byteOffset,
length: l

0 comments on commit cab1952

Please # to comment.