@colyseus/schema
Advanced tools
Comparing version 0.3.8 to 0.3.9
@@ -149,4 +149,3 @@ "use strict"; | ||
var newIndex = decode.number(bytes, it); | ||
// index change check | ||
var indexChangedFrom = void 0; | ||
var indexChangedFrom = void 0; // index change check | ||
if (decode.indexChangeCheck(bytes, it)) { | ||
@@ -157,5 +156,5 @@ decode.uint8(bytes, it); | ||
} | ||
var isNew = (!hasIndexChange && !value[newIndex]) || (hasIndexChange && indexChangedFrom === undefined); | ||
if (type_1.prototype instanceof Schema) { | ||
var item = void 0; | ||
var isNew = (hasIndexChange && indexChangedFrom === undefined && newIndex !== undefined); | ||
if (isNew) { | ||
@@ -167,3 +166,3 @@ item = new type_1(); | ||
} | ||
else if (newIndex !== undefined) { | ||
else { | ||
item = valueRef_1[newIndex]; | ||
@@ -182,7 +181,3 @@ } | ||
} | ||
item.$parent = this_1; | ||
item.decode(bytes, it); | ||
if (isNew && valueRef_1.onAdd) { | ||
valueRef_1.onAdd(item, newIndex); | ||
} | ||
value[newIndex] = item; | ||
@@ -193,2 +188,8 @@ } | ||
} | ||
if (isNew && valueRef_1.onAdd) { | ||
valueRef_1.onAdd(value[newIndex], newIndex); | ||
} | ||
else if (valueRef_1.onChange) { | ||
valueRef_1.onChange(value[newIndex], newIndex); | ||
} | ||
change.push(value[newIndex]); | ||
@@ -258,9 +259,9 @@ } | ||
value[newKey] = item; | ||
if (isNew && valueRef.onAdd) { | ||
valueRef.onAdd(item, newKey); | ||
} | ||
else if (valueRef.onChange) { | ||
valueRef.onChange(item, newKey); | ||
} | ||
} | ||
if (isNew && valueRef.onAdd) { | ||
valueRef.onAdd(item, newKey); | ||
} | ||
else if (valueRef.onChange) { | ||
valueRef.onChange(item, newKey); | ||
} | ||
} | ||
@@ -267,0 +268,0 @@ } |
@@ -36,2 +36,3 @@ "use strict"; | ||
arr.onRemove = _this.onRemove; | ||
arr.onChange = _this.onChange; | ||
return arr; | ||
@@ -38,0 +39,0 @@ } |
@@ -21,2 +21,3 @@ "use strict"; | ||
map.onRemove = _this.onRemove; | ||
map.onChange = _this.onChange; | ||
return map; | ||
@@ -23,0 +24,0 @@ } |
{ | ||
"name": "@colyseus/schema", | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"description": "Schema-based binary serializer / de-serializer.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93122
2322