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