@colyseus/schema 3.0.0-alpha.2 → 3.0.0-alpha.4

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.
@@ -1009,9 +1009,9 @@ const encodeArray = function (encoder, bytes, changeTree, field, operation, it,
1009
1009
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1010
1010
  * SOFTWARE
1011
1011
  */
1012
- function utf8Read(bytes, offset, length) {
1012
+ function utf8Read(bytes, it, length) {
1013
1013
  var string = '', chr = 0;
1014
- for (var i = offset, end = offset + length; i < end; i++) {
1014
+ for (var i = it.offset, end = it.offset + length; i < end; i++) {
1015
1015
  var byte = bytes[i];
1016
1016
  if ((byte & 0x80) === 0x00) {
1017
1017
  string += String.fromCharCode(byte);
@@ -1046,6 +1046,7 @@ function utf8Read(bytes, offset, length) {
1046
1046
  // (do not throw error to avoid server/client from crashing due to hack attemps)
1047
1047
  // throw new Error('Invalid byte ' + byte.toString(16));
1048
1048
  }
1049
+ it.offset += length;
1049
1050
  return string;
1050
1051
  }
1051
1052
  function int8(bytes, it) {
@@ -1113,9 +1114,7 @@ function string(bytes, it) {
1113
1114
  else if (prefix === 0xdb) {
1114
1115
  length = uint32(bytes, it);
1115
1116
  }
1116
- const value = utf8Read(bytes, it.offset, length);
1117
- it.offset += length;
1118
- return value;
1117
+ return utf8Read(bytes, it, length);
1119
1118
  }
1120
1119
  function stringCheck(bytes, it) {
1121
1120
  const prefix = bytes[it.offset];
@@ -1219,6 +1218,7 @@ function switchStructureCheck(bytes, it) {
1219
1218
 
1220
1219
  var decode = /*#__PURE__*/Object.freeze({
1221
1220
  __proto__: null,
1221
+ utf8Read: utf8Read,
1222
1222
  int8: int8,
1223
1223
  uint8: uint8,
1224
1224
  int16: int16,