@tanstack/db 0.0.1

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.
Files changed (154) hide show
  1. package/README.md +37 -0
  2. package/dist/cjs/SortedMap.cjs +140 -0
  3. package/dist/cjs/SortedMap.cjs.map +1 -0
  4. package/dist/cjs/SortedMap.d.cts +91 -0
  5. package/dist/cjs/collection.cjs +597 -0
  6. package/dist/cjs/collection.cjs.map +1 -0
  7. package/dist/cjs/collection.d.cts +176 -0
  8. package/dist/cjs/deferred.cjs +25 -0
  9. package/dist/cjs/deferred.cjs.map +1 -0
  10. package/dist/cjs/deferred.d.cts +20 -0
  11. package/dist/cjs/errors.cjs +10 -0
  12. package/dist/cjs/errors.cjs.map +1 -0
  13. package/dist/cjs/errors.d.cts +3 -0
  14. package/dist/cjs/index.cjs +33 -0
  15. package/dist/cjs/index.cjs.map +1 -0
  16. package/dist/cjs/index.d.cts +9 -0
  17. package/dist/cjs/proxy.cjs +654 -0
  18. package/dist/cjs/proxy.cjs.map +1 -0
  19. package/dist/cjs/proxy.d.cts +59 -0
  20. package/dist/cjs/query/compiled-query.cjs +162 -0
  21. package/dist/cjs/query/compiled-query.cjs.map +1 -0
  22. package/dist/cjs/query/compiled-query.d.cts +22 -0
  23. package/dist/cjs/query/evaluators.cjs +146 -0
  24. package/dist/cjs/query/evaluators.cjs.map +1 -0
  25. package/dist/cjs/query/evaluators.d.cts +9 -0
  26. package/dist/cjs/query/extractors.cjs +122 -0
  27. package/dist/cjs/query/extractors.cjs.map +1 -0
  28. package/dist/cjs/query/extractors.d.cts +22 -0
  29. package/dist/cjs/query/functions.cjs +152 -0
  30. package/dist/cjs/query/functions.cjs.map +1 -0
  31. package/dist/cjs/query/functions.d.cts +21 -0
  32. package/dist/cjs/query/group-by.cjs +91 -0
  33. package/dist/cjs/query/group-by.cjs.map +1 -0
  34. package/dist/cjs/query/group-by.d.cts +40 -0
  35. package/dist/cjs/query/index.d.cts +5 -0
  36. package/dist/cjs/query/joins.cjs +155 -0
  37. package/dist/cjs/query/joins.cjs.map +1 -0
  38. package/dist/cjs/query/joins.d.cts +14 -0
  39. package/dist/cjs/query/key-by.cjs +43 -0
  40. package/dist/cjs/query/key-by.cjs.map +1 -0
  41. package/dist/cjs/query/key-by.d.cts +3 -0
  42. package/dist/cjs/query/order-by.cjs +229 -0
  43. package/dist/cjs/query/order-by.cjs.map +1 -0
  44. package/dist/cjs/query/order-by.d.cts +3 -0
  45. package/dist/cjs/query/pipeline-compiler.cjs +94 -0
  46. package/dist/cjs/query/pipeline-compiler.cjs.map +1 -0
  47. package/dist/cjs/query/pipeline-compiler.d.cts +9 -0
  48. package/dist/cjs/query/query-builder.cjs +314 -0
  49. package/dist/cjs/query/query-builder.cjs.map +1 -0
  50. package/dist/cjs/query/query-builder.d.cts +219 -0
  51. package/dist/cjs/query/schema.d.cts +98 -0
  52. package/dist/cjs/query/select.cjs +107 -0
  53. package/dist/cjs/query/select.cjs.map +1 -0
  54. package/dist/cjs/query/select.d.cts +3 -0
  55. package/dist/cjs/query/types.d.cts +188 -0
  56. package/dist/cjs/query/utils.cjs +154 -0
  57. package/dist/cjs/query/utils.cjs.map +1 -0
  58. package/dist/cjs/query/utils.d.cts +37 -0
  59. package/dist/cjs/transactions.cjs +137 -0
  60. package/dist/cjs/transactions.cjs.map +1 -0
  61. package/dist/cjs/transactions.d.cts +27 -0
  62. package/dist/cjs/types.d.cts +94 -0
  63. package/dist/cjs/utils.cjs +17 -0
  64. package/dist/cjs/utils.cjs.map +1 -0
  65. package/dist/cjs/utils.d.cts +3 -0
  66. package/dist/esm/SortedMap.d.ts +91 -0
  67. package/dist/esm/SortedMap.js +140 -0
  68. package/dist/esm/SortedMap.js.map +1 -0
  69. package/dist/esm/collection.d.ts +176 -0
  70. package/dist/esm/collection.js +597 -0
  71. package/dist/esm/collection.js.map +1 -0
  72. package/dist/esm/deferred.d.ts +20 -0
  73. package/dist/esm/deferred.js +25 -0
  74. package/dist/esm/deferred.js.map +1 -0
  75. package/dist/esm/errors.d.ts +3 -0
  76. package/dist/esm/errors.js +10 -0
  77. package/dist/esm/errors.js.map +1 -0
  78. package/dist/esm/index.d.ts +9 -0
  79. package/dist/esm/index.js +33 -0
  80. package/dist/esm/index.js.map +1 -0
  81. package/dist/esm/proxy.d.ts +59 -0
  82. package/dist/esm/proxy.js +654 -0
  83. package/dist/esm/proxy.js.map +1 -0
  84. package/dist/esm/query/compiled-query.d.ts +22 -0
  85. package/dist/esm/query/compiled-query.js +162 -0
  86. package/dist/esm/query/compiled-query.js.map +1 -0
  87. package/dist/esm/query/evaluators.d.ts +9 -0
  88. package/dist/esm/query/evaluators.js +146 -0
  89. package/dist/esm/query/evaluators.js.map +1 -0
  90. package/dist/esm/query/extractors.d.ts +22 -0
  91. package/dist/esm/query/extractors.js +122 -0
  92. package/dist/esm/query/extractors.js.map +1 -0
  93. package/dist/esm/query/functions.d.ts +21 -0
  94. package/dist/esm/query/functions.js +152 -0
  95. package/dist/esm/query/functions.js.map +1 -0
  96. package/dist/esm/query/group-by.d.ts +40 -0
  97. package/dist/esm/query/group-by.js +91 -0
  98. package/dist/esm/query/group-by.js.map +1 -0
  99. package/dist/esm/query/index.d.ts +5 -0
  100. package/dist/esm/query/joins.d.ts +14 -0
  101. package/dist/esm/query/joins.js +155 -0
  102. package/dist/esm/query/joins.js.map +1 -0
  103. package/dist/esm/query/key-by.d.ts +3 -0
  104. package/dist/esm/query/key-by.js +43 -0
  105. package/dist/esm/query/key-by.js.map +1 -0
  106. package/dist/esm/query/order-by.d.ts +3 -0
  107. package/dist/esm/query/order-by.js +229 -0
  108. package/dist/esm/query/order-by.js.map +1 -0
  109. package/dist/esm/query/pipeline-compiler.d.ts +9 -0
  110. package/dist/esm/query/pipeline-compiler.js +94 -0
  111. package/dist/esm/query/pipeline-compiler.js.map +1 -0
  112. package/dist/esm/query/query-builder.d.ts +219 -0
  113. package/dist/esm/query/query-builder.js +314 -0
  114. package/dist/esm/query/query-builder.js.map +1 -0
  115. package/dist/esm/query/schema.d.ts +98 -0
  116. package/dist/esm/query/select.d.ts +3 -0
  117. package/dist/esm/query/select.js +107 -0
  118. package/dist/esm/query/select.js.map +1 -0
  119. package/dist/esm/query/types.d.ts +188 -0
  120. package/dist/esm/query/utils.d.ts +37 -0
  121. package/dist/esm/query/utils.js +154 -0
  122. package/dist/esm/query/utils.js.map +1 -0
  123. package/dist/esm/transactions.d.ts +27 -0
  124. package/dist/esm/transactions.js +137 -0
  125. package/dist/esm/transactions.js.map +1 -0
  126. package/dist/esm/types.d.ts +94 -0
  127. package/dist/esm/utils.d.ts +3 -0
  128. package/dist/esm/utils.js +17 -0
  129. package/dist/esm/utils.js.map +1 -0
  130. package/package.json +57 -0
  131. package/src/SortedMap.ts +163 -0
  132. package/src/collection.ts +919 -0
  133. package/src/deferred.ts +47 -0
  134. package/src/errors.ts +6 -0
  135. package/src/index.ts +12 -0
  136. package/src/proxy.ts +1104 -0
  137. package/src/query/compiled-query.ts +193 -0
  138. package/src/query/evaluators.ts +222 -0
  139. package/src/query/extractors.ts +211 -0
  140. package/src/query/functions.ts +297 -0
  141. package/src/query/group-by.ts +137 -0
  142. package/src/query/index.ts +5 -0
  143. package/src/query/joins.ts +247 -0
  144. package/src/query/key-by.ts +61 -0
  145. package/src/query/order-by.ts +312 -0
  146. package/src/query/pipeline-compiler.ts +152 -0
  147. package/src/query/query-builder.ts +898 -0
  148. package/src/query/schema.ts +255 -0
  149. package/src/query/select.ts +173 -0
  150. package/src/query/types.ts +417 -0
  151. package/src/query/utils.ts +245 -0
  152. package/src/transactions.ts +198 -0
  153. package/src/types.ts +125 -0
  154. package/src/utils.ts +15 -0
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @tanstack/db
2
+
3
+ **A reactive client store for building super fast apps on sync**
4
+
5
+ TanStack DB extends TanStack Query with collections, live queries and transactional mutations that keep your UI reactive, consistent and blazing fast 🔥
6
+
7
+ <p>
8
+ <a href="https://x.com/intent/post?text=TanStack%20DB&url=https://tanstack.com/db">
9
+ <img alt="#TanStack" src="https://img.shields.io/twitter/url?color=%2308a0e9&label=%23TanStack&style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Fbutton_hashtag%3DTanStack" /></a>
10
+ <a href="#status">
11
+ <img src="https://img.shields.io/badge/status-alpha-orange" alt="Status - Alpha"></a>
12
+ <a href="https://npmjs.com/package/@tanstack/db">
13
+ <img alt="" src="https://img.shields.io/npm/dm/@tanstack/db.svg" /></a>
14
+ <a href="https://discord.gg/yjUNbvbraC">
15
+ <img alt="" src="https://img.shields.io/badge/Discord-TanStack-%235865F2" /></a>
16
+ <a href="https://github.com/tanstack/db/discussions">
17
+ <img alt="Join the discussion on Github" src="https://img.shields.io/badge/Discussions-Chat%20now!-green" /></a>
18
+ <a href="https://x.com/tan_stack">
19
+ <img alt="" src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social&label=Follow @TanStack" /></a>
20
+ </p>
21
+
22
+ ## 💥 Visit the [TanStack/db](https://github.com/TanStack/db) repo for docs and details!
23
+
24
+ - 🔥 **blazing fast query engine**<br />
25
+ for sub-millisecond live queries &mdash; even for complex queries with joins and aggregates
26
+ - 🎯 **fine-grained reactivity**<br />
27
+ to minimize component re-rendering
28
+ - 💪 **robust transaction primitives**<br />
29
+ for easy optimistic mutations with sync and lifecycle support
30
+ - 🌟 **normalized data**<br />
31
+ to keep your backend simple
32
+
33
+ ---
34
+
35
+ ### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
36
+
37
+ Enjoy this library? Try the entire [TanStack](https://tanstack.com), including [TanStack Query](https://tanstack.com/query), [TanStack Store](https://tanstack.com/store), etc.
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ class SortedMap {
4
+ /**
5
+ * Creates a new SortedMap instance
6
+ *
7
+ * @param comparator - Optional function to compare values for sorting
8
+ */
9
+ constructor(comparator) {
10
+ this.map = /* @__PURE__ */ new Map();
11
+ this.sortedKeys = [];
12
+ this.comparator = comparator || this.defaultComparator;
13
+ }
14
+ /**
15
+ * Default comparator function used when none is provided
16
+ *
17
+ * @param a - First value to compare
18
+ * @param b - Second value to compare
19
+ * @returns -1 if a < b, 1 if a > b, 0 if equal
20
+ */
21
+ defaultComparator(a, b) {
22
+ if (a < b) return -1;
23
+ if (a > b) return 1;
24
+ return 0;
25
+ }
26
+ /**
27
+ * Sets a key-value pair in the map and maintains sort order
28
+ *
29
+ * @param key - The key to set
30
+ * @param value - The value to associate with the key
31
+ * @returns This SortedMap instance for chaining
32
+ */
33
+ set(key, value) {
34
+ this.map.set(key, value);
35
+ if (!this.sortedKeys.includes(key)) {
36
+ this.sortedKeys.push(key);
37
+ }
38
+ this.sortedKeys.sort((a, b) => {
39
+ const valueA = this.map.get(a);
40
+ const valueB = this.map.get(b);
41
+ return this.comparator(valueA, valueB);
42
+ });
43
+ return this;
44
+ }
45
+ /**
46
+ * Gets a value by its key
47
+ *
48
+ * @param key - The key to look up
49
+ * @returns The value associated with the key, or undefined if not found
50
+ */
51
+ get(key) {
52
+ return this.map.get(key);
53
+ }
54
+ /**
55
+ * Removes a key-value pair from the map
56
+ *
57
+ * @param key - The key to remove
58
+ * @returns True if the key was found and removed, false otherwise
59
+ */
60
+ delete(key) {
61
+ if (this.map.delete(key)) {
62
+ const index = this.sortedKeys.indexOf(key);
63
+ this.sortedKeys.splice(index, 1);
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+ /**
69
+ * Checks if a key exists in the map
70
+ *
71
+ * @param key - The key to check
72
+ * @returns True if the key exists, false otherwise
73
+ */
74
+ has(key) {
75
+ return this.map.has(key);
76
+ }
77
+ /**
78
+ * Removes all key-value pairs from the map
79
+ */
80
+ clear() {
81
+ this.map.clear();
82
+ this.sortedKeys = [];
83
+ }
84
+ /**
85
+ * Gets the number of key-value pairs in the map
86
+ */
87
+ get size() {
88
+ return this.map.size;
89
+ }
90
+ /**
91
+ * Default iterator that returns entries in sorted order
92
+ *
93
+ * @returns An iterator for the map's entries
94
+ */
95
+ *[Symbol.iterator]() {
96
+ for (const key of this.sortedKeys) {
97
+ yield [key, this.map.get(key)];
98
+ }
99
+ }
100
+ /**
101
+ * Returns an iterator for the map's entries in sorted order
102
+ *
103
+ * @returns An iterator for the map's entries
104
+ */
105
+ entries() {
106
+ return this[Symbol.iterator]();
107
+ }
108
+ /**
109
+ * Returns an iterator for the map's keys in sorted order
110
+ *
111
+ * @returns An iterator for the map's keys
112
+ */
113
+ keys() {
114
+ return this.sortedKeys[Symbol.iterator]();
115
+ }
116
+ /**
117
+ * Returns an iterator for the map's values in sorted order
118
+ *
119
+ * @returns An iterator for the map's values
120
+ */
121
+ values() {
122
+ return (function* () {
123
+ for (const key of this.sortedKeys) {
124
+ yield this.map.get(key);
125
+ }
126
+ }).call(this);
127
+ }
128
+ /**
129
+ * Executes a callback function for each key-value pair in the map in sorted order
130
+ *
131
+ * @param callbackfn - Function to execute for each entry
132
+ */
133
+ forEach(callbackfn) {
134
+ for (const key of this.sortedKeys) {
135
+ callbackfn(this.map.get(key), key, this.map);
136
+ }
137
+ }
138
+ }
139
+ exports.SortedMap = SortedMap;
140
+ //# sourceMappingURL=SortedMap.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SortedMap.cjs","sources":["../../src/SortedMap.ts"],"sourcesContent":["/**\n * A Map implementation that keeps its entries sorted based on a comparator function\n * @template TKey - The type of keys in the map\n * @template TValue - The type of values in the map\n */\nexport class SortedMap<TKey, TValue> {\n private map: Map<TKey, TValue>\n private sortedKeys: Array<TKey>\n private comparator: (a: TValue, b: TValue) => number\n\n /**\n * Creates a new SortedMap instance\n *\n * @param comparator - Optional function to compare values for sorting\n */\n constructor(comparator?: (a: TValue, b: TValue) => number) {\n this.map = new Map<TKey, TValue>()\n this.sortedKeys = []\n this.comparator = comparator || this.defaultComparator\n }\n\n /**\n * Default comparator function used when none is provided\n *\n * @param a - First value to compare\n * @param b - Second value to compare\n * @returns -1 if a < b, 1 if a > b, 0 if equal\n */\n private defaultComparator(a: TValue, b: TValue): number {\n if (a < b) return -1\n if (a > b) return 1\n return 0\n }\n\n /**\n * Sets a key-value pair in the map and maintains sort order\n *\n * @param key - The key to set\n * @param value - The value to associate with the key\n * @returns This SortedMap instance for chaining\n */\n set(key: TKey, value: TValue): this {\n this.map.set(key, value)\n\n if (!this.sortedKeys.includes(key)) {\n this.sortedKeys.push(key)\n }\n\n // Re-sort keys based on values\n this.sortedKeys.sort((a, b) => {\n const valueA = this.map.get(a)!\n const valueB = this.map.get(b)!\n return this.comparator(valueA, valueB)\n })\n\n return this\n }\n\n /**\n * Gets a value by its key\n *\n * @param key - The key to look up\n * @returns The value associated with the key, or undefined if not found\n */\n get(key: TKey): TValue | undefined {\n return this.map.get(key)\n }\n\n /**\n * Removes a key-value pair from the map\n *\n * @param key - The key to remove\n * @returns True if the key was found and removed, false otherwise\n */\n delete(key: TKey): boolean {\n if (this.map.delete(key)) {\n const index = this.sortedKeys.indexOf(key)\n this.sortedKeys.splice(index, 1)\n return true\n }\n return false\n }\n\n /**\n * Checks if a key exists in the map\n *\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: TKey): boolean {\n return this.map.has(key)\n }\n\n /**\n * Removes all key-value pairs from the map\n */\n clear(): void {\n this.map.clear()\n this.sortedKeys = []\n }\n\n /**\n * Gets the number of key-value pairs in the map\n */\n get size(): number {\n return this.map.size\n }\n\n /**\n * Default iterator that returns entries in sorted order\n *\n * @returns An iterator for the map's entries\n */\n *[Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n for (const key of this.sortedKeys) {\n yield [key, this.map.get(key)!] as [TKey, TValue]\n }\n }\n\n /**\n * Returns an iterator for the map's entries in sorted order\n *\n * @returns An iterator for the map's entries\n */\n entries(): IterableIterator<[TKey, TValue]> {\n return this[Symbol.iterator]()\n }\n\n /**\n * Returns an iterator for the map's keys in sorted order\n *\n * @returns An iterator for the map's keys\n */\n keys(): IterableIterator<TKey> {\n return this.sortedKeys[Symbol.iterator]()\n }\n\n /**\n * Returns an iterator for the map's values in sorted order\n *\n * @returns An iterator for the map's values\n */\n values(): IterableIterator<TValue> {\n return function* (this: SortedMap<TKey, TValue>) {\n for (const key of this.sortedKeys) {\n yield this.map.get(key)!\n }\n }.call(this)\n }\n\n /**\n * Executes a callback function for each key-value pair in the map in sorted order\n *\n * @param callbackfn - Function to execute for each entry\n */\n forEach(\n callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void\n ): void {\n for (const key of this.sortedKeys) {\n callbackfn(this.map.get(key)!, key, this.map)\n }\n }\n}\n"],"names":[],"mappings":";;AAKO,MAAM,UAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUnC,YAAY,YAA+C;AACpD,SAAA,0BAAU,IAAkB;AACjC,SAAK,aAAa,CAAC;AACd,SAAA,aAAa,cAAc,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU/B,kBAAkB,GAAW,GAAmB;AAClD,QAAA,IAAI,EAAU,QAAA;AACd,QAAA,IAAI,EAAU,QAAA;AACX,WAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUT,IAAI,KAAW,OAAqB;AAC7B,SAAA,IAAI,IAAI,KAAK,KAAK;AAEvB,QAAI,CAAC,KAAK,WAAW,SAAS,GAAG,GAAG;AAC7B,WAAA,WAAW,KAAK,GAAG;AAAA,IAAA;AAI1B,SAAK,WAAW,KAAK,CAAC,GAAG,MAAM;AAC7B,YAAM,SAAS,KAAK,IAAI,IAAI,CAAC;AAC7B,YAAM,SAAS,KAAK,IAAI,IAAI,CAAC;AACtB,aAAA,KAAK,WAAW,QAAQ,MAAM;AAAA,IAAA,CACtC;AAEM,WAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAST,IAAI,KAA+B;AAC1B,WAAA,KAAK,IAAI,IAAI,GAAG;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzB,OAAO,KAAoB;AACzB,QAAI,KAAK,IAAI,OAAO,GAAG,GAAG;AACxB,YAAM,QAAQ,KAAK,WAAW,QAAQ,GAAG;AACpC,WAAA,WAAW,OAAO,OAAO,CAAC;AACxB,aAAA;AAAA,IAAA;AAEF,WAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAST,IAAI,KAAoB;AACf,WAAA,KAAK,IAAI,IAAI,GAAG;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMzB,QAAc;AACZ,SAAK,IAAI,MAAM;AACf,SAAK,aAAa,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMrB,IAAI,OAAe;AACjB,WAAO,KAAK,IAAI;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlB,EAAE,OAAO,QAAQ,IAAsC;AAC1C,eAAA,OAAO,KAAK,YAAY;AACjC,YAAM,CAAC,KAAK,KAAK,IAAI,IAAI,GAAG,CAAE;AAAA,IAAA;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQF,UAA4C;AACnC,WAAA,KAAK,OAAO,QAAQ,EAAE;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/B,OAA+B;AAC7B,WAAO,KAAK,WAAW,OAAO,QAAQ,EAAE;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1C,SAAmC;AACjC,YAAO,aAA0C;AACpC,iBAAA,OAAO,KAAK,YAAY;AAC3B,cAAA,KAAK,IAAI,IAAI,GAAG;AAAA,MAAA;AAAA,IACxB,GACA,KAAK,IAAI;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQb,QACE,YACM;AACK,eAAA,OAAO,KAAK,YAAY;AACjC,iBAAW,KAAK,IAAI,IAAI,GAAG,GAAI,KAAK,KAAK,GAAG;AAAA,IAAA;AAAA,EAC9C;AAEJ;;"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * A Map implementation that keeps its entries sorted based on a comparator function
3
+ * @template TKey - The type of keys in the map
4
+ * @template TValue - The type of values in the map
5
+ */
6
+ export declare class SortedMap<TKey, TValue> {
7
+ private map;
8
+ private sortedKeys;
9
+ private comparator;
10
+ /**
11
+ * Creates a new SortedMap instance
12
+ *
13
+ * @param comparator - Optional function to compare values for sorting
14
+ */
15
+ constructor(comparator?: (a: TValue, b: TValue) => number);
16
+ /**
17
+ * Default comparator function used when none is provided
18
+ *
19
+ * @param a - First value to compare
20
+ * @param b - Second value to compare
21
+ * @returns -1 if a < b, 1 if a > b, 0 if equal
22
+ */
23
+ private defaultComparator;
24
+ /**
25
+ * Sets a key-value pair in the map and maintains sort order
26
+ *
27
+ * @param key - The key to set
28
+ * @param value - The value to associate with the key
29
+ * @returns This SortedMap instance for chaining
30
+ */
31
+ set(key: TKey, value: TValue): this;
32
+ /**
33
+ * Gets a value by its key
34
+ *
35
+ * @param key - The key to look up
36
+ * @returns The value associated with the key, or undefined if not found
37
+ */
38
+ get(key: TKey): TValue | undefined;
39
+ /**
40
+ * Removes a key-value pair from the map
41
+ *
42
+ * @param key - The key to remove
43
+ * @returns True if the key was found and removed, false otherwise
44
+ */
45
+ delete(key: TKey): boolean;
46
+ /**
47
+ * Checks if a key exists in the map
48
+ *
49
+ * @param key - The key to check
50
+ * @returns True if the key exists, false otherwise
51
+ */
52
+ has(key: TKey): boolean;
53
+ /**
54
+ * Removes all key-value pairs from the map
55
+ */
56
+ clear(): void;
57
+ /**
58
+ * Gets the number of key-value pairs in the map
59
+ */
60
+ get size(): number;
61
+ /**
62
+ * Default iterator that returns entries in sorted order
63
+ *
64
+ * @returns An iterator for the map's entries
65
+ */
66
+ [Symbol.iterator](): IterableIterator<[TKey, TValue]>;
67
+ /**
68
+ * Returns an iterator for the map's entries in sorted order
69
+ *
70
+ * @returns An iterator for the map's entries
71
+ */
72
+ entries(): IterableIterator<[TKey, TValue]>;
73
+ /**
74
+ * Returns an iterator for the map's keys in sorted order
75
+ *
76
+ * @returns An iterator for the map's keys
77
+ */
78
+ keys(): IterableIterator<TKey>;
79
+ /**
80
+ * Returns an iterator for the map's values in sorted order
81
+ *
82
+ * @returns An iterator for the map's values
83
+ */
84
+ values(): IterableIterator<TValue>;
85
+ /**
86
+ * Executes a callback function for each key-value pair in the map in sorted order
87
+ *
88
+ * @param callbackfn - Function to execute for each entry
89
+ */
90
+ forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void): void;
91
+ }