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