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