@colyseus/schema 3.0.3 → 3.0.4

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.
@@ -1861,6 +1861,9 @@ class ArraySchema {
1861
1861
  // type format: { array: "string" }
1862
1862
  (type['array'] !== undefined));
1863
1863
  }
1864
+ static from(iterable) {
1865
+ return new ArraySchema(...Array.from(iterable));
1866
+ }
1864
1867
  constructor(...items) {
1865
1868
  this.items = [];
1866
1869
  this.tmpItems = [];
@@ -2227,8 +2230,8 @@ class ArraySchema {
2227
2230
  lastIndexOf(searchElement, fromIndex = this.length - 1) {
2228
2231
  return this.items.lastIndexOf(searchElement, fromIndex);
2229
2232
  }
2230
- every(callbackfn, thisArg) {
2231
- return this.items.every(callbackfn, thisArg);
2233
+ every(predicate, thisArg) {
2234
+ return this.items.every(predicate, thisArg);
2232
2235
  }
2233
2236
  /**
2234
2237
  * Determines whether the specified callback function returns true for any element of an array.
@@ -2410,6 +2413,9 @@ class ArraySchema {
2410
2413
  //
2411
2414
  with(index, value) {
2412
2415
  const copy = this.items.slice();
2416
+ // Allow negative indexing from the end
2417
+ if (index < 0)
2418
+ index += this.length;
2413
2419
  copy[index] = value;
2414
2420
  return new ArraySchema(...copy);
2415
2421
  }