New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@colyseus/schema

Package Overview
Dependencies
Maintainers
1
Versions
337
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colyseus/schema - npm Package Compare versions

Comparing version 0.4.28 to 0.4.29

67

lib/Schema.js

@@ -175,3 +175,3 @@ "use strict";

var newLength_1 = decode.number(bytes, it);
var numChanges = decode.number(bytes, it);
var numChanges = Math.min(decode.number(bytes, it), newLength_1);
hasChange = (numChanges > 0);

@@ -185,3 +185,2 @@ // FIXME: this may not be reliable. possibly need to encode this variable during

// no need to iterate through them, as they're going to be removed.
numChanges -= value.length - newLength_1;
value.splice(newLength_1).forEach(function (itemRemoved, i) {

@@ -357,3 +356,3 @@ if (itemRemoved && itemRemoved.onRemove) {

: this.$changes.changes;
for (var i = 0, l = changes.length; i < l; i++) {
var _loop_2 = function (i, l) {
var field = changes[i];

@@ -363,7 +362,7 @@ var type = schema[field];

// const value = (filter && this.$allChanges[field]) || changes[field];
var value = this["_" + field];
var value = this_2["_" + field];
var fieldIndex = indexes[field];
// skip unchagned fields
if (value === undefined) {
continue;
return "continue";
}

@@ -374,4 +373,4 @@ var bytes = [];

// skip if not allowed by custom filter
if (!filter.call(this, client, value, root)) {
continue;
if (!filter.call(this_2, client, value, root)) {
return "continue";
}

@@ -382,4 +381,4 @@ }

if (value) {
assertInstanceType(value, type, this, field);
this.tryEncodeTypeId(bytes, type, value.constructor);
assertInstanceType(value, type, this_2, field);
this_2.tryEncodeTypeId(bytes, type, value.constructor);
bytes = bytes.concat(value.encode(root, encodeAll, client));

@@ -396,7 +395,7 @@ }

encode.number(bytes, value.length);
var arrayChanges = (encodeAll || client)
var arrayChanges = ((encodeAll || client)
? value.$changes.allChanges
: value.$changes.changes;
: value.$changes.changes).filter(function (index) { return _this["_" + field][index] !== undefined; });
// ensure number of changes doesn't exceed array length
var numChanges = Math.min(value.length, arrayChanges.length);
var numChanges = arrayChanges.length;
// number of changed items

@@ -406,7 +405,7 @@ encode.number(bytes, numChanges);

// assert ArraySchema was provided
assertInstanceType(this["_" + field], ArraySchema_1.ArraySchema, this, field);
assertInstanceType(this_2["_" + field], ArraySchema_1.ArraySchema, this_2, field);
// encode Array of type
for (var j = 0; j < numChanges; j++) {
var index = arrayChanges[j];
var item = this["_" + field][index];
var item = this_2["_" + field][index];
if (item === undefined) {

@@ -417,3 +416,3 @@ continue;

// skip if not allowed by custom filter
if (!filter.call(this, client, item, root)) {
if (!filter.call(this_2, client, item, root)) {
continue;

@@ -429,4 +428,4 @@ }

}
assertInstanceType(item, type[0], this, field);
this.tryEncodeTypeId(bytes, type[0], item.constructor);
assertInstanceType(item, type[0], this_2, field);
this_2.tryEncodeTypeId(bytes, type[0], item.constructor);
bytes = bytes.concat(item.encode(root, encodeAll, client));

@@ -436,3 +435,3 @@ }

encode.number(bytes, index);
if (!encodePrimitiveType(type[0], bytes, item, this, field)) {
if (!encodePrimitiveType(type[0], bytes, item, this_2, field)) {
console.log("cannot encode", schema[field]);

@@ -455,13 +454,13 @@ continue;

encode.number(bytes, keys.length);
var previousKeys = Object.keys(this["_" + field]);
var previousKeys = Object.keys(this_2["_" + field]);
var isChildSchema = typeof (type.map) !== "string";
// assert MapSchema was provided
assertInstanceType(this["_" + field], MapSchema_1.MapSchema, this, field);
assertInstanceType(this_2["_" + field], MapSchema_1.MapSchema, this_2, field);
for (var i_1 = 0; i_1 < keys.length; i_1++) {
var key = (typeof (keys[i_1]) === "number" && previousKeys[keys[i_1]]) || keys[i_1];
var item = this["_" + field][key];
var mapItemIndex = this["_" + field]._indexes.get(key);
var item = this_2["_" + field][key];
var mapItemIndex = this_2["_" + field]._indexes.get(key);
if (client && filter) {
// skip if not allowed by custom filter
if (!filter.call(this, client, item, root)) {
if (!filter.call(this_2, client, item, root)) {
continue;

@@ -483,3 +482,3 @@ }

encode.uint8(bytes, spec_1.INDEX_CHANGE);
encode.number(bytes, this["_" + field]._indexes.get(indexChange));
encode.number(bytes, this_2["_" + field]._indexes.get(indexChange));
}

@@ -494,8 +493,8 @@ if (mapItemIndex !== undefined) {

if (item && isChildSchema) {
assertInstanceType(item, type.map, this, field);
this.tryEncodeTypeId(bytes, type.map, item.constructor);
assertInstanceType(item, type.map, this_2, field);
this_2.tryEncodeTypeId(bytes, type.map, item.constructor);
bytes = bytes.concat(item.encode(root, encodeAll, client));
}
else if (item !== undefined) {
encodePrimitiveType(type.map, bytes, item, this, field);
encodePrimitiveType(type.map, bytes, item, this_2, field);
}

@@ -510,3 +509,3 @@ else {

if (!client) {
this["_" + field]._updateIndexes();
this_2["_" + field]._updateIndexes();
}

@@ -518,13 +517,17 @@ }

// skip if not allowed by custom filter
if (!filter.call(this, client, value, root)) {
continue;
if (!filter.call(this_2, client, value, root)) {
return "continue";
}
}
encode.number(bytes, fieldIndex);
if (!encodePrimitiveType(type, bytes, value, this, field)) {
if (!encodePrimitiveType(type, bytes, value, this_2, field)) {
console.log("cannot encode", schema[field]);
continue;
return "continue";
}
}
encodedBytes = encodedBytes.concat(bytes);
};
var this_2 = this;
for (var i = 0, l = changes.length; i < l; i++) {
_loop_2(i, l);
}

@@ -531,0 +534,0 @@ // flag end of Schema object structure

{
"name": "@colyseus/schema",
"version": "0.4.28",
"version": "0.4.29",
"description": "Schema-based binary serializer / de-serializer.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc