@colyseus/schema 3.0.63 → 3.0.65

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.
@@ -1057,6 +1057,9 @@ class ChangeTree {
1057
1057
  if (typeof (this.ref[$childType]) !== "string") {
1058
1058
  // MapSchema / ArraySchema, etc.
1059
1059
  for (const [key, value] of this.ref.entries()) {
1060
+ if (!value) {
1061
+ continue;
1062
+ } // sparse arrays can have undefined values
1060
1063
  callback(value[$changes], this.indexes?.[key] ?? key);
1061
1064
  }
1062
1065
  }
@@ -3697,7 +3700,9 @@ class Schema {
3697
3700
  this[$changes].change(metadata[metadata[property]].index, operation);
3698
3701
  }
3699
3702
  clone() {
3700
- const cloned = new (this.constructor);
3703
+ // Create instance without calling custom constructor
3704
+ const cloned = Object.create(this.constructor.prototype);
3705
+ Schema.initialize(cloned);
3701
3706
  const metadata = this.constructor[Symbol.metadata];
3702
3707
  //
3703
3708
  // TODO: clone all properties, not only annotated ones