@colyseus/schema 2.0.19 → 2.0.21
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 +33 -4
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +33 -4
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +33 -4
- package/lib/changes/ReferenceTracker.d.ts +1 -1
- package/lib/changes/ReferenceTracker.js +10 -1
- package/lib/changes/ReferenceTracker.js.map +1 -1
- package/lib/types/ArraySchema.d.ts +5 -0
- package/lib/types/ArraySchema.js +23 -3
- package/lib/types/ArraySchema.js.map +1 -1
- package/package.json +2 -2
- package/src/changes/ReferenceTracker.ts +12 -2
- package/src/types/ArraySchema.ts +26 -3
package/build/cjs/index.js
CHANGED
|
@@ -813,6 +813,9 @@ var ArraySchema = /** @class */ (function () {
|
|
|
813
813
|
ArraySchema.prototype.includes = function (searchElement, fromIndex) {
|
|
814
814
|
return Array.from(this.$items.values()).includes(searchElement, fromIndex);
|
|
815
815
|
};
|
|
816
|
+
//
|
|
817
|
+
// ES2022
|
|
818
|
+
//
|
|
816
819
|
/**
|
|
817
820
|
* Calls a defined callback function on each element of an array. Then, flattens the result into
|
|
818
821
|
* a new array.
|
|
@@ -848,9 +851,26 @@ var ArraySchema = /** @class */ (function () {
|
|
|
848
851
|
// @ts-ignore
|
|
849
852
|
return arr.findLastIndex.apply(arr, arguments);
|
|
850
853
|
};
|
|
851
|
-
//
|
|
852
|
-
//
|
|
853
|
-
//
|
|
854
|
+
//
|
|
855
|
+
// ES2023
|
|
856
|
+
//
|
|
857
|
+
ArraySchema.prototype.with = function (index, value) {
|
|
858
|
+
var copy = Array.from(this.$items.values());
|
|
859
|
+
copy[index] = value;
|
|
860
|
+
return new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], copy, false)))();
|
|
861
|
+
};
|
|
862
|
+
ArraySchema.prototype.toReversed = function () {
|
|
863
|
+
return Array.from(this.$items.values()).reverse();
|
|
864
|
+
};
|
|
865
|
+
ArraySchema.prototype.toSorted = function (compareFn) {
|
|
866
|
+
return Array.from(this.$items.values()).sort(compareFn);
|
|
867
|
+
};
|
|
868
|
+
// @ts-ignore
|
|
869
|
+
ArraySchema.prototype.toSpliced = function (start, deleteCount) {
|
|
870
|
+
var copy = Array.from(this.$items.values());
|
|
871
|
+
// @ts-ignore
|
|
872
|
+
return copy.toSpliced.apply(copy, arguments);
|
|
873
|
+
};
|
|
854
874
|
ArraySchema.prototype.setIndex = function (index, key) {
|
|
855
875
|
this.$indexes.set(index, key);
|
|
856
876
|
};
|
|
@@ -2288,7 +2308,16 @@ var ReferenceTracker = /** @class */ (function () {
|
|
|
2288
2308
|
};
|
|
2289
2309
|
// for decoding
|
|
2290
2310
|
ReferenceTracker.prototype.removeRef = function (refId) {
|
|
2291
|
-
|
|
2311
|
+
var refCount = this.refCounts[refId];
|
|
2312
|
+
if (refCount === undefined) {
|
|
2313
|
+
console.warn("trying to remove reference ".concat(refId, " that doesn't exist"));
|
|
2314
|
+
return;
|
|
2315
|
+
}
|
|
2316
|
+
if (refCount === 0) {
|
|
2317
|
+
console.warn("trying to remove reference ".concat(refId, " with 0 refCount"));
|
|
2318
|
+
return;
|
|
2319
|
+
}
|
|
2320
|
+
this.refCounts[refId] = refCount - 1;
|
|
2292
2321
|
this.deletedRefs.add(refId);
|
|
2293
2322
|
};
|
|
2294
2323
|
ReferenceTracker.prototype.clearRefs = function () {
|