@liveblocks/core 3.14.0-pre4 → 3.14.0-pre5

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/dist/index.d.cts CHANGED
@@ -5064,6 +5064,9 @@ declare function shallow2(a: unknown, b: unknown): boolean;
5064
5064
  declare class SortedList<T> {
5065
5065
  #private;
5066
5066
  private constructor();
5067
+ /**
5068
+ * Creates an empty SortedList with the given "less than" function.
5069
+ */
5067
5070
  static with<T>(lt: (a: T, b: T) => boolean): SortedList<T>;
5068
5071
  static from<T>(arr: readonly T[], lt: (a: T, b: T) => boolean): SortedList<T>;
5069
5072
  static fromAlreadySorted<T>(alreadySorted: T[], lt: (a: T, b: T) => boolean): SortedList<T>;
@@ -5073,8 +5076,9 @@ declare class SortedList<T> {
5073
5076
  clone(): SortedList<T>;
5074
5077
  /**
5075
5078
  * Adds a new item to the sorted list, such that it remains sorted.
5079
+ * Returns the index where the item was inserted.
5076
5080
  */
5077
- add(value: T): void;
5081
+ add(value: T): number;
5078
5082
  /**
5079
5083
  * Removes all values from the sorted list, making it empty again.
5080
5084
  * Returns whether the list was mutated or not.
@@ -5093,6 +5097,25 @@ declare class SortedList<T> {
5093
5097
  * Returns whether the list was mutated or not.
5094
5098
  */
5095
5099
  remove(value: T): boolean;
5100
+ /**
5101
+ * Removes the item at the given index.
5102
+ * Returns the removed item, or undefined if index is out of bounds.
5103
+ */
5104
+ removeAt(index: number): T | undefined;
5105
+ /**
5106
+ * Repositions an item to maintain sorted order after its sort key has
5107
+ * been mutated in-place. For example:
5108
+ *
5109
+ * const item = sorted.at(3);
5110
+ * item.updatedAt = new Date(); // mutate the item's sort key in-place
5111
+ * sorted.reposition(item); // restore sorted order
5112
+ *
5113
+ * Returns the new index of the item. Throws if the item is not in the list.
5114
+ *
5115
+ * Semantically equivalent to remove(value) + add(value), but optimized
5116
+ * to avoid array shifting when the item only moves a short distance.
5117
+ */
5118
+ reposition(value: T): number;
5096
5119
  at(index: number): T | undefined;
5097
5120
  get length(): number;
5098
5121
  filter(predicate: (value: T) => boolean): IterableIterator<T>;
package/dist/index.d.ts CHANGED
@@ -5064,6 +5064,9 @@ declare function shallow2(a: unknown, b: unknown): boolean;
5064
5064
  declare class SortedList<T> {
5065
5065
  #private;
5066
5066
  private constructor();
5067
+ /**
5068
+ * Creates an empty SortedList with the given "less than" function.
5069
+ */
5067
5070
  static with<T>(lt: (a: T, b: T) => boolean): SortedList<T>;
5068
5071
  static from<T>(arr: readonly T[], lt: (a: T, b: T) => boolean): SortedList<T>;
5069
5072
  static fromAlreadySorted<T>(alreadySorted: T[], lt: (a: T, b: T) => boolean): SortedList<T>;
@@ -5073,8 +5076,9 @@ declare class SortedList<T> {
5073
5076
  clone(): SortedList<T>;
5074
5077
  /**
5075
5078
  * Adds a new item to the sorted list, such that it remains sorted.
5079
+ * Returns the index where the item was inserted.
5076
5080
  */
5077
- add(value: T): void;
5081
+ add(value: T): number;
5078
5082
  /**
5079
5083
  * Removes all values from the sorted list, making it empty again.
5080
5084
  * Returns whether the list was mutated or not.
@@ -5093,6 +5097,25 @@ declare class SortedList<T> {
5093
5097
  * Returns whether the list was mutated or not.
5094
5098
  */
5095
5099
  remove(value: T): boolean;
5100
+ /**
5101
+ * Removes the item at the given index.
5102
+ * Returns the removed item, or undefined if index is out of bounds.
5103
+ */
5104
+ removeAt(index: number): T | undefined;
5105
+ /**
5106
+ * Repositions an item to maintain sorted order after its sort key has
5107
+ * been mutated in-place. For example:
5108
+ *
5109
+ * const item = sorted.at(3);
5110
+ * item.updatedAt = new Date(); // mutate the item's sort key in-place
5111
+ * sorted.reposition(item); // restore sorted order
5112
+ *
5113
+ * Returns the new index of the item. Throws if the item is not in the list.
5114
+ *
5115
+ * Semantically equivalent to remove(value) + add(value), but optimized
5116
+ * to avoid array shifting when the item only moves a short distance.
5117
+ */
5118
+ reposition(value: T): number;
5096
5119
  at(index: number): T | undefined;
5097
5120
  get length(): number;
5098
5121
  filter(predicate: (value: T) => boolean): IterableIterator<T>;