chore[js]: ArrayBuffer slice is deep clone

This commit is contained in:
godotg
2024-07-27 12:56:21 +08:00
parent 1c8c859a4c
commit c31a3fe004
3 changed files with 3 additions and 0 deletions
@@ -64,6 +64,7 @@ class ByteBuffer {
this.writeInt(length);
this.setWriteOffset(currentWriteIndex);
} else {
// ArrayBuffer slice is deep clone
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
this.setWriteOffset(beforeWriteIndex);
this.writeInt(length);
@@ -64,6 +64,7 @@ const ByteBuffer = function() {
this.writeInt(length);
this.setWriteOffset(currentWriteIndex);
} else {
// ArrayBuffer slice is deep clone
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
this.setWriteOffset(beforeWriteIndex);
this.writeInt(length);
@@ -73,6 +73,7 @@ class ByteBuffer implements IByteBuffer{
this.writeInt(length);
this.setWriteOffset(currentWriteIndex);
} else {
// ArrayBuffer slice is deep clone
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
this.setWriteOffset(beforeWriteIndex);
this.writeInt(length);