mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-17 02:14:58 +00:00
chore[js]: ArrayBuffer slice is deep clone
This commit is contained in:
1 parent
1c8c859a4c
commit
c31a3fe004
3 files changed
+3
No files matched your search
@@ -64,6 +64,7 @@ class ByteBuffer {
|
|||||||
this.writeInt(length);
|
this.writeInt(length);
|
||||||
this.setWriteOffset(currentWriteIndex);
|
this.setWriteOffset(currentWriteIndex);
|
||||||
} else {
|
} else {
|
||||||
|
// ArrayBuffer slice is deep clone
|
||||||
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
|
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
|
||||||
this.setWriteOffset(beforeWriteIndex);
|
this.setWriteOffset(beforeWriteIndex);
|
||||||
this.writeInt(length);
|
this.writeInt(length);
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ const ByteBuffer = function() {
|
|||||||
this.writeInt(length);
|
this.writeInt(length);
|
||||||
this.setWriteOffset(currentWriteIndex);
|
this.setWriteOffset(currentWriteIndex);
|
||||||
} else {
|
} else {
|
||||||
|
// ArrayBuffer slice is deep clone
|
||||||
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
|
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
|
||||||
this.setWriteOffset(beforeWriteIndex);
|
this.setWriteOffset(beforeWriteIndex);
|
||||||
this.writeInt(length);
|
this.writeInt(length);
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ class ByteBuffer implements IByteBuffer{
|
|||||||
this.writeInt(length);
|
this.writeInt(length);
|
||||||
this.setWriteOffset(currentWriteIndex);
|
this.setWriteOffset(currentWriteIndex);
|
||||||
} else {
|
} else {
|
||||||
|
// ArrayBuffer slice is deep clone
|
||||||
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
|
const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex);
|
||||||
this.setWriteOffset(beforeWriteIndex);
|
this.setWriteOffset(beforeWriteIndex);
|
||||||
this.writeInt(length);
|
this.writeInt(length);
|
||||||
|
|||||||
Reference in new issue
Block a user