@colyseus/schema 3.0.3 → 3.0.5

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,6 +2230,15 @@ class ArraySchema {
2227
2230
  lastIndexOf(searchElement, fromIndex = this.length - 1) {
2228
2231
  return this.items.lastIndexOf(searchElement, fromIndex);
2229
2232
  }
2233
+ /**
2234
+ * Determines whether all the members of an array satisfy the specified test.
2235
+ * @param callbackfn A function that accepts up to three arguments. The every method calls
2236
+ * the callbackfn function for each element in the array until the callbackfn returns a value
2237
+ * which is coercible to the Boolean value false, or until the end of the array.
2238
+ * @param thisArg An object to which the this keyword can refer in the callbackfn function.
2239
+ * If thisArg is omitted, undefined is used as the this value.
2240
+ */
2241
+ // @ts-ignore
2230
2242
  every(callbackfn, thisArg) {
2231
2243
  return this.items.every(callbackfn, thisArg);
2232
2244
  }
@@ -2410,6 +2422,9 @@ class ArraySchema {
2410
2422
  //
2411
2423
  with(index, value) {
2412
2424
  const copy = this.items.slice();
2425
+ // Allow negative indexing from the end
2426
+ if (index < 0)
2427
+ index += this.length;
2413
2428
  copy[index] = value;
2414
2429
  return new ArraySchema(...copy);
2415
2430
  }