@colyseus/schema 3.0.0-alpha.3 → 3.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1010,7 +1010,6 @@ const encodeArray = function (encoder, bytes, changeTree, field, operation, it,
1010
1010
  * SOFTWARE
1011
1011
  */
1012
1012
  function utf8Read(bytes, it, length) {
1013
- it.offset += length;
1014
1013
  var string = '', chr = 0;
1015
1014
  for (var i = it.offset, end = it.offset + length; i < end; i++) {
1016
1015
  var byte = bytes[i];
@@ -1047,6 +1046,7 @@ function utf8Read(bytes, it, length) {
1047
1046
  // (do not throw error to avoid server/client from crashing due to hack attemps)
1048
1047
  // throw new Error('Invalid byte ' + byte.toString(16));
1049
1048
  }
1049
+ it.offset += length;
1050
1050
  return string;
1051
1051
  }
1052
1052
  function int8(bytes, it) {
@@ -3818,7 +3818,7 @@ class Reflection extends Schema {
3818
3818
  super(...arguments);
3819
3819
  this.types = new ArraySchema();
3820
3820
  }
3821
- static encode(instance, context) {
3821
+ static encode(instance, context, it = { offset: 0 }) {
3822
3822
  if (!context) {
3823
3823
  context = new TypeContext(instance.constructor);
3824
3824
  }
@@ -3875,7 +3875,6 @@ class Reflection extends Schema {
3875
3875
  }
3876
3876
  buildType(type, klass[Symbol.metadata]);
3877
3877
  }
3878
- const it = { offset: 0 };
3879
3878
  const buf = encoder.encodeAll(it);
3880
3879
  return Buffer.from(buf, 0, it.offset);
3881
3880
  }