From 2b7dcc80469bb095976ea1b2284e4ed3f01dd89e Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 8 Dec 2024 23:10:26 -0600 Subject: [PATCH] fix: array size byte offset --- src/codecs/array.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codecs/array.js b/src/codecs/array.js index 9398422..14337e0 100644 --- a/src/codecs/array.js +++ b/src/codecs/array.js @@ -108,10 +108,10 @@ class ArrayCodec { }; } else { - this.$$size = (value) => { + this.$$size = (value, byteOffset) => { let size = 4; for (const element of value) { - size += this.$$elementCodec.size(element, size); + size += this.$$elementCodec.size(element, size + byteOffset); } return size; }; @@ -157,7 +157,7 @@ class ArrayCodec { }; } else { - this.$$size = (value) => { + this.$$size = (value, byteOffset) => { let size = 0; // let the environment report if (!value[Symbol.iterator]) { @@ -166,7 +166,7 @@ class ArrayCodec { let protocol = value[Symbol.iterator](); let result = protocol.next(); for (let i = 0; i < length; ++i) { - size += this.$$elementCodec.size(result.value); + size += this.$$elementCodec.size(result.value, size + byteOffset); result = protocol.next(); } return size;