@colyseus/schema 2.0.20 → 2.0.22

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.
@@ -617,12 +617,19 @@ var ArraySchema = /** @class */ (function () {
617
617
  */
618
618
  ArraySchema.prototype.splice = function (start, deleteCount) {
619
619
  if (deleteCount === void 0) { deleteCount = this.length - start; }
620
+ var items = [];
621
+ for (var _i = 2; _i < arguments.length; _i++) {
622
+ items[_i - 2] = arguments[_i];
623
+ }
620
624
  var indexes = Array.from(this.$items.keys());
621
625
  var removedItems = [];
622
626
  for (var i = start; i < start + deleteCount; i++) {
623
627
  removedItems.push(this.$items.get(indexes[i]));
624
628
  this.$deleteAt(indexes[i]);
625
629
  }
630
+ for (var i = 0; i < items.length; i++) {
631
+ this.setAt(start + i, items[i]);
632
+ }
626
633
  return removedItems;
627
634
  };
628
635
  /**
@@ -813,6 +820,9 @@ var ArraySchema = /** @class */ (function () {
813
820
  ArraySchema.prototype.includes = function (searchElement, fromIndex) {
814
821
  return Array.from(this.$items.values()).includes(searchElement, fromIndex);
815
822
  };
823
+ //
824
+ // ES2022
825
+ //
816
826
  /**
817
827
  * Calls a defined callback function on each element of an array. Then, flattens the result into
818
828
  * a new array.
@@ -848,9 +858,26 @@ var ArraySchema = /** @class */ (function () {
848
858
  // @ts-ignore
849
859
  return arr.findLastIndex.apply(arr, arguments);
850
860
  };
851
- // get size () {
852
- // return this.$items.size;
853
- // }
861
+ //
862
+ // ES2023
863
+ //
864
+ ArraySchema.prototype.with = function (index, value) {
865
+ var copy = Array.from(this.$items.values());
866
+ copy[index] = value;
867
+ return new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], copy, false)))();
868
+ };
869
+ ArraySchema.prototype.toReversed = function () {
870
+ return Array.from(this.$items.values()).reverse();
871
+ };
872
+ ArraySchema.prototype.toSorted = function (compareFn) {
873
+ return Array.from(this.$items.values()).sort(compareFn);
874
+ };
875
+ // @ts-ignore
876
+ ArraySchema.prototype.toSpliced = function (start, deleteCount) {
877
+ var copy = Array.from(this.$items.values());
878
+ // @ts-ignore
879
+ return copy.toSpliced.apply(copy, arguments);
880
+ };
854
881
  ArraySchema.prototype.setIndex = function (index, key) {
855
882
  this.$indexes.set(index, key);
856
883
  };