@colyseus/schema 2.0.10 → 2.0.11

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.
@@ -407,6 +407,10 @@ class ArraySchema {
407
407
  return this.$items.get(key);
408
408
  }
409
409
  setAt(index, value) {
410
+ if (value === undefined || value === null) {
411
+ console.error("ArraySchema items cannot be null nor undefined; Use `deleteAt(index)` instead.");
412
+ return;
413
+ }
410
414
  if (value['$changes'] !== undefined) {
411
415
  value['$changes'].setParent(this, this.$changes.root, index);
412
416
  }
@@ -862,6 +866,9 @@ class MapSchema {
862
866
  if (value === undefined || value === null) {
863
867
  throw new Error(`MapSchema#set('${key}', ${value}): trying to set ${value} value on '${key}'.`);
864
868
  }
869
+ // Force "key" as string
870
+ // See: https://github.com/colyseus/colyseus/issues/561#issuecomment-1646733468
871
+ key = key.toString();
865
872
  // get "index" for this value.
866
873
  const hasIndex = typeof (this.$changes.indexes[key]) !== "undefined";
867
874
  const index = (hasIndex)