@procedures/collections 0.0.0-stage → 0.2.0

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 (205) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +394 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/async/async-queue.d.ts +155 -0
  6. package/dist/async/async-queue.d.ts.map +1 -0
  7. package/dist/async/async-queue.js +342 -0
  8. package/dist/async/async-queue.js.map +1 -0
  9. package/dist/async/channels.d.ts +188 -0
  10. package/dist/async/channels.d.ts.map +1 -0
  11. package/dist/async/channels.js +314 -0
  12. package/dist/async/channels.js.map +1 -0
  13. package/dist/behaviors/bounded.d.ts +79 -0
  14. package/dist/behaviors/bounded.d.ts.map +1 -0
  15. package/dist/behaviors/bounded.js +384 -0
  16. package/dist/behaviors/bounded.js.map +1 -0
  17. package/dist/behaviors/composite.d.ts +17 -0
  18. package/dist/behaviors/composite.d.ts.map +1 -0
  19. package/dist/behaviors/composite.js +93 -0
  20. package/dist/behaviors/composite.js.map +1 -0
  21. package/dist/behaviors/evented.d.ts +154 -0
  22. package/dist/behaviors/evented.d.ts.map +1 -0
  23. package/dist/behaviors/evented.js +299 -0
  24. package/dist/behaviors/evented.js.map +1 -0
  25. package/dist/behaviors/lru.d.ts +84 -0
  26. package/dist/behaviors/lru.d.ts.map +1 -0
  27. package/dist/behaviors/lru.js +376 -0
  28. package/dist/behaviors/lru.js.map +1 -0
  29. package/dist/behaviors/readonly.d.ts +73 -0
  30. package/dist/behaviors/readonly.d.ts.map +1 -0
  31. package/dist/behaviors/readonly.js +177 -0
  32. package/dist/behaviors/readonly.js.map +1 -0
  33. package/dist/behaviors/safe.d.ts +163 -0
  34. package/dist/behaviors/safe.d.ts.map +1 -0
  35. package/dist/behaviors/safe.js +176 -0
  36. package/dist/behaviors/safe.js.map +1 -0
  37. package/dist/behaviors/synchronized.d.ts +88 -0
  38. package/dist/behaviors/synchronized.d.ts.map +1 -0
  39. package/dist/behaviors/synchronized.js +285 -0
  40. package/dist/behaviors/synchronized.js.map +1 -0
  41. package/dist/behaviors/ttl.d.ts +118 -0
  42. package/dist/behaviors/ttl.d.ts.map +1 -0
  43. package/dist/behaviors/ttl.js +354 -0
  44. package/dist/behaviors/ttl.js.map +1 -0
  45. package/dist/contracts/model.d.ts +29 -0
  46. package/dist/contracts/model.d.ts.map +1 -0
  47. package/dist/contracts/model.js +26 -0
  48. package/dist/contracts/model.js.map +1 -0
  49. package/dist/core/effects.d.ts +176 -0
  50. package/dist/core/effects.d.ts.map +1 -0
  51. package/dist/core/effects.js +180 -0
  52. package/dist/core/effects.js.map +1 -0
  53. package/dist/core/events.d.ts +192 -0
  54. package/dist/core/events.d.ts.map +1 -0
  55. package/dist/core/events.js +291 -0
  56. package/dist/core/events.js.map +1 -0
  57. package/dist/core/middleware.d.ts +231 -0
  58. package/dist/core/middleware.d.ts.map +1 -0
  59. package/dist/core/middleware.js +161 -0
  60. package/dist/core/middleware.js.map +1 -0
  61. package/dist/core/policies.d.ts +220 -0
  62. package/dist/core/policies.d.ts.map +1 -0
  63. package/dist/core/policies.js +48 -0
  64. package/dist/core/policies.js.map +1 -0
  65. package/dist/core/traits.d.ts +142 -0
  66. package/dist/core/traits.d.ts.map +1 -0
  67. package/dist/core/traits.js +8 -0
  68. package/dist/core/traits.js.map +1 -0
  69. package/dist/fx/collectors.d.ts +193 -0
  70. package/dist/fx/collectors.d.ts.map +1 -0
  71. package/dist/fx/collectors.js +375 -0
  72. package/dist/fx/collectors.js.map +1 -0
  73. package/dist/fx/iter.d.ts +166 -0
  74. package/dist/fx/iter.d.ts.map +1 -0
  75. package/dist/fx/iter.js +421 -0
  76. package/dist/fx/iter.js.map +1 -0
  77. package/dist/impl/array-deque.d.ts +112 -0
  78. package/dist/impl/array-deque.d.ts.map +1 -0
  79. package/dist/impl/array-deque.js +380 -0
  80. package/dist/impl/array-deque.js.map +1 -0
  81. package/dist/impl/array-list.d.ts +101 -0
  82. package/dist/impl/array-list.d.ts.map +1 -0
  83. package/dist/impl/array-list.js +387 -0
  84. package/dist/impl/array-list.js.map +1 -0
  85. package/dist/impl/hash-map.d.ts +149 -0
  86. package/dist/impl/hash-map.d.ts.map +1 -0
  87. package/dist/impl/hash-map.js +473 -0
  88. package/dist/impl/hash-map.js.map +1 -0
  89. package/dist/impl/hash-set.d.ts +125 -0
  90. package/dist/impl/hash-set.d.ts.map +1 -0
  91. package/dist/impl/hash-set.js +264 -0
  92. package/dist/impl/hash-set.js.map +1 -0
  93. package/dist/impl/linked-hash-map.d.ts +141 -0
  94. package/dist/impl/linked-hash-map.d.ts.map +1 -0
  95. package/dist/impl/linked-hash-map.js +442 -0
  96. package/dist/impl/linked-hash-map.js.map +1 -0
  97. package/dist/impl/linked-list.d.ts +109 -0
  98. package/dist/impl/linked-list.d.ts.map +1 -0
  99. package/dist/impl/linked-list.js +494 -0
  100. package/dist/impl/linked-list.js.map +1 -0
  101. package/dist/impl/priority-queue.d.ts +139 -0
  102. package/dist/impl/priority-queue.d.ts.map +1 -0
  103. package/dist/impl/priority-queue.js +343 -0
  104. package/dist/impl/priority-queue.js.map +1 -0
  105. package/dist/impl/tree-map.d.ts +153 -0
  106. package/dist/impl/tree-map.d.ts.map +1 -0
  107. package/dist/impl/tree-map.js +788 -0
  108. package/dist/impl/tree-map.js.map +1 -0
  109. package/dist/impl/tree-set.d.ts +112 -0
  110. package/dist/impl/tree-set.d.ts.map +1 -0
  111. package/dist/impl/tree-set.js +374 -0
  112. package/dist/impl/tree-set.js.map +1 -0
  113. package/dist/index.d.ts +106 -0
  114. package/dist/index.d.ts.map +1 -0
  115. package/dist/index.js +139 -0
  116. package/dist/index.js.map +1 -0
  117. package/dist/interfaces/collection.d.ts +119 -0
  118. package/dist/interfaces/collection.d.ts.map +1 -0
  119. package/dist/interfaces/collection.js +8 -0
  120. package/dist/interfaces/collection.js.map +1 -0
  121. package/dist/interfaces/list.d.ts +247 -0
  122. package/dist/interfaces/list.d.ts.map +1 -0
  123. package/dist/interfaces/list.js +8 -0
  124. package/dist/interfaces/list.js.map +1 -0
  125. package/dist/interfaces/map.d.ts +344 -0
  126. package/dist/interfaces/map.d.ts.map +1 -0
  127. package/dist/interfaces/map.js +8 -0
  128. package/dist/interfaces/map.js.map +1 -0
  129. package/dist/interfaces/queue.d.ts +304 -0
  130. package/dist/interfaces/queue.d.ts.map +1 -0
  131. package/dist/interfaces/queue.js +8 -0
  132. package/dist/interfaces/queue.js.map +1 -0
  133. package/dist/interfaces/set.d.ts +137 -0
  134. package/dist/interfaces/set.d.ts.map +1 -0
  135. package/dist/interfaces/set.js +8 -0
  136. package/dist/interfaces/set.js.map +1 -0
  137. package/dist/register.d.ts +8 -0
  138. package/dist/register.d.ts.map +1 -0
  139. package/dist/register.js +8 -0
  140. package/dist/register.js.map +1 -0
  141. package/dist/storage/index.d.ts +15 -0
  142. package/dist/storage/index.d.ts.map +1 -0
  143. package/dist/storage/index.js +14 -0
  144. package/dist/storage/index.js.map +1 -0
  145. package/dist/storage/interface.d.ts +141 -0
  146. package/dist/storage/interface.d.ts.map +1 -0
  147. package/dist/storage/interface.js +23 -0
  148. package/dist/storage/interface.js.map +1 -0
  149. package/dist/storage/memory.d.ts +68 -0
  150. package/dist/storage/memory.d.ts.map +1 -0
  151. package/dist/storage/memory.js +154 -0
  152. package/dist/storage/memory.js.map +1 -0
  153. package/dist/utils/defaults.d.ts +135 -0
  154. package/dist/utils/defaults.d.ts.map +1 -0
  155. package/dist/utils/defaults.js +322 -0
  156. package/dist/utils/defaults.js.map +1 -0
  157. package/dist/utils/factories.d.ts +144 -0
  158. package/dist/utils/factories.d.ts.map +1 -0
  159. package/dist/utils/factories.js +293 -0
  160. package/dist/utils/factories.js.map +1 -0
  161. package/dist/utils/helpers.d.ts +137 -0
  162. package/dist/utils/helpers.d.ts.map +1 -0
  163. package/dist/utils/helpers.js +221 -0
  164. package/dist/utils/helpers.js.map +1 -0
  165. package/package.json +68 -3
  166. package/src/async/async-queue.ts +417 -0
  167. package/src/async/channels.ts +374 -0
  168. package/src/behaviors/bounded.ts +477 -0
  169. package/src/behaviors/composite.ts +99 -0
  170. package/src/behaviors/evented.ts +464 -0
  171. package/src/behaviors/lru.ts +447 -0
  172. package/src/behaviors/readonly.ts +224 -0
  173. package/src/behaviors/safe.ts +372 -0
  174. package/src/behaviors/synchronized.ts +316 -0
  175. package/src/behaviors/ttl.ts +462 -0
  176. package/src/contracts/model.ts +44 -0
  177. package/src/core/effects.ts +323 -0
  178. package/src/core/events.ts +356 -0
  179. package/src/core/middleware.ts +415 -0
  180. package/src/core/policies.ts +316 -0
  181. package/src/core/traits.ts +164 -0
  182. package/src/fx/collectors.ts +500 -0
  183. package/src/fx/iter.ts +536 -0
  184. package/src/impl/array-deque.ts +463 -0
  185. package/src/impl/array-list.ts +490 -0
  186. package/src/impl/hash-map.ts +623 -0
  187. package/src/impl/hash-set.ts +342 -0
  188. package/src/impl/linked-hash-map.ts +572 -0
  189. package/src/impl/linked-list.ts +606 -0
  190. package/src/impl/priority-queue.ts +448 -0
  191. package/src/impl/tree-map.ts +912 -0
  192. package/src/impl/tree-set.ts +469 -0
  193. package/src/index.ts +277 -0
  194. package/src/interfaces/collection.ts +141 -0
  195. package/src/interfaces/list.ts +281 -0
  196. package/src/interfaces/map.ts +405 -0
  197. package/src/interfaces/queue.ts +353 -0
  198. package/src/interfaces/set.ts +158 -0
  199. package/src/register.ts +8 -0
  200. package/src/storage/index.ts +16 -0
  201. package/src/storage/interface.ts +179 -0
  202. package/src/storage/memory.ts +180 -0
  203. package/src/utils/defaults.ts +345 -0
  204. package/src/utils/factories.ts +357 -0
  205. package/src/utils/helpers.ts +248 -0
@@ -0,0 +1,405 @@
1
+ /**
2
+ * Map interfaces that mirror Java's Map interface hierarchy.
3
+ *
4
+ * Maps store key-value pairs and provide efficient lookup by key.
5
+ * Keys are unique within a map.
6
+ */
7
+
8
+ import type { Eq, Compare } from "../core/traits.js";
9
+ import type { ReadonlyCollection } from "./collection.js";
10
+
11
+ /**
12
+ * Entry<K, V> - An immutable key-value pair from a map.
13
+ *
14
+ * Unlike java.util.Map.Entry which has setValue(), our entries are immutable
15
+ * snapshots. To update a value, use map.set(key, newValue) instead.
16
+ *
17
+ * This prevents accidental mutation and makes entries safe to share.
18
+ */
19
+ export interface Entry<K, V> {
20
+ readonly key: K;
21
+ readonly value: V;
22
+ }
23
+
24
+ /**
25
+ * ReadonlyMapLike<K, V> - Readonly key-value mapping.
26
+ *
27
+ * Provides read-only access to map operations.
28
+ * Note: We use "MapLike" to avoid conflicts with TypeScript's built-in Map type.
29
+ */
30
+ export interface ReadonlyMapLike<K, V> extends Iterable<Entry<K, V>> {
31
+ /**
32
+ * Returns the number of key-value pairs in this map.
33
+ */
34
+ readonly size: number;
35
+
36
+ /**
37
+ * Returns true if this map contains no key-value mappings.
38
+ */
39
+ readonly isEmpty: boolean;
40
+
41
+ /**
42
+ * Returns true if this map contains a mapping for the specified key.
43
+ */
44
+ has(key: K): boolean;
45
+
46
+ /**
47
+ * Returns the value to which the specified key is mapped.
48
+ *
49
+ * @throws Error if key is not present
50
+ */
51
+ get(key: K): V;
52
+
53
+ /**
54
+ * Returns the value for the key, or undefined if not present.
55
+ */
56
+ getOrUndefined(key: K): V | undefined;
57
+
58
+ /**
59
+ * Returns the value for the key, or the default value if not present.
60
+ */
61
+ getOrDefault(key: K, defaultValue: V): V;
62
+
63
+ /**
64
+ * Returns true if this map maps one or more keys to the specified value.
65
+ */
66
+ containsValue(value: V): boolean;
67
+
68
+ /**
69
+ * Returns an iterable view of the keys in this map.
70
+ */
71
+ keys(): Iterable<K>;
72
+
73
+ /**
74
+ * Returns an iterable view of the values in this map.
75
+ */
76
+ values(): Iterable<V>;
77
+
78
+ /**
79
+ * Returns an iterable view of the key-value pairs in this map.
80
+ */
81
+ entries(): Iterable<Entry<K, V>>;
82
+
83
+ /**
84
+ * Performs the given action for each key-value pair.
85
+ */
86
+ forEach(action: (value: V, key: K, map: this) => void): void;
87
+
88
+ /**
89
+ * Returns the equality function used for keys.
90
+ */
91
+ readonly keyEq: Eq<K>;
92
+
93
+ /**
94
+ * Returns the equality function used for values.
95
+ */
96
+ readonly valueEq: Eq<V>;
97
+ }
98
+
99
+ /**
100
+ * MapLike<K, V> - Mutable key-value mapping.
101
+ *
102
+ * Mirrors java.util.Map.
103
+ */
104
+ export interface MapLike<K, V> extends ReadonlyMapLike<K, V> {
105
+ /**
106
+ * Associates the specified value with the specified key in this map.
107
+ * If the map previously contained a mapping for the key, the old value is replaced.
108
+ *
109
+ * @param key The key
110
+ * @param value The value
111
+ * @returns The previous value associated with key, or undefined if none
112
+ */
113
+ set(key: K, value: V): V | undefined;
114
+
115
+ /**
116
+ * Associates value with key only if key is not already present.
117
+ *
118
+ * @returns The current value (existing or newly set)
119
+ */
120
+ setIfAbsent(key: K, value: V): V;
121
+
122
+ /**
123
+ * Removes the mapping for a key if it is present.
124
+ *
125
+ * @returns The value that was associated with key, or undefined if none
126
+ */
127
+ delete(key: K): V | undefined;
128
+
129
+ /**
130
+ * Removes the entry for key only if currently mapped to the specified value.
131
+ *
132
+ * @returns true if the entry was removed
133
+ */
134
+ deleteEntry(key: K, value: V): boolean;
135
+
136
+ /**
137
+ * Replaces the entry for key only if currently mapped to some value.
138
+ *
139
+ * @returns The previous value, or undefined if key was not present
140
+ */
141
+ replace(key: K, value: V): V | undefined;
142
+
143
+ /**
144
+ * Replaces the entry for key only if currently mapped to the specified oldValue.
145
+ *
146
+ * @returns true if the value was replaced
147
+ */
148
+ replaceEntry(key: K, oldValue: V, newValue: V): boolean;
149
+
150
+ /**
151
+ * If the specified key is not already associated with a value,
152
+ * computes its value using the given function and enters it into the map.
153
+ *
154
+ * @returns The current (existing or computed) value associated with the key
155
+ */
156
+ computeIfAbsent(key: K, mappingFunction: (key: K) => V): V;
157
+
158
+ /**
159
+ * If the value for the specified key is present, attempts to compute
160
+ * a new mapping given the key and its current mapped value.
161
+ *
162
+ * @returns The new value associated with the key, or undefined if none
163
+ */
164
+ computeIfPresent(key: K, remappingFunction: (key: K, value: V) => V | undefined): V | undefined;
165
+
166
+ /**
167
+ * Attempts to compute a mapping for the specified key and its current mapped value.
168
+ *
169
+ * @returns The new value associated with the key, or undefined if none
170
+ */
171
+ compute(key: K, remappingFunction: (key: K, value: V | undefined) => V | undefined): V | undefined;
172
+
173
+ /**
174
+ * If the specified key is not already associated with a value or is
175
+ * associated with undefined, associates it with the given non-undefined value.
176
+ * Otherwise, replaces the value with the results of the given remapping function.
177
+ *
178
+ * @returns The new value associated with the key, or undefined if none
179
+ */
180
+ merge(key: K, value: V, remappingFunction: (oldValue: V, newValue: V) => V | undefined): V | undefined;
181
+
182
+ /**
183
+ * Copies all mappings from the specified map to this map.
184
+ */
185
+ putAll(other: ReadonlyMapLike<K, V> | Iterable<Entry<K, V>>): void;
186
+
187
+ /**
188
+ * Removes all mappings from this map.
189
+ */
190
+ clear(): void;
191
+ }
192
+
193
+ /**
194
+ * SortedMap<K, V> - Map that maintains keys in sorted order.
195
+ *
196
+ * Mirrors java.util.SortedMap.
197
+ */
198
+ export interface SortedMap<K, V> extends MapLike<K, V> {
199
+ /**
200
+ * Returns the comparison function used to order keys.
201
+ */
202
+ readonly comparator: Compare<K>;
203
+
204
+ /**
205
+ * Returns the first (lowest) key in this map.
206
+ *
207
+ * @throws Error if map is empty
208
+ */
209
+ firstKey(): K;
210
+
211
+ /**
212
+ * Returns the last (highest) key in this map.
213
+ *
214
+ * @throws Error if map is empty
215
+ */
216
+ lastKey(): K;
217
+
218
+ /**
219
+ * Returns a view of the portion of this map whose keys are less than toKey.
220
+ */
221
+ headMap(toKey: K): SortedMap<K, V>;
222
+
223
+ /**
224
+ * Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
225
+ */
226
+ tailMap(fromKey: K): SortedMap<K, V>;
227
+
228
+ /**
229
+ * Returns a view of the portion of this map whose keys range from fromKey to toKey.
230
+ */
231
+ subMap(fromKey: K, toKey: K): SortedMap<K, V>;
232
+ }
233
+
234
+ /**
235
+ * NavigableMap<K, V> - Extended sorted map with navigation methods.
236
+ *
237
+ * Mirrors java.util.NavigableMap.
238
+ */
239
+ export interface NavigableMap<K, V> extends SortedMap<K, V> {
240
+ /**
241
+ * Returns the greatest key less than or equal to the given key, or undefined if none.
242
+ */
243
+ floorKey(key: K): K | undefined;
244
+
245
+ /**
246
+ * Returns the least key greater than or equal to the given key, or undefined if none.
247
+ */
248
+ ceilingKey(key: K): K | undefined;
249
+
250
+ /**
251
+ * Returns the greatest key strictly less than the given key, or undefined if none.
252
+ */
253
+ lowerKey(key: K): K | undefined;
254
+
255
+ /**
256
+ * Returns the least key strictly greater than the given key, or undefined if none.
257
+ */
258
+ higherKey(key: K): K | undefined;
259
+
260
+ /**
261
+ * Returns the entry for the greatest key less than or equal to the given key, or undefined.
262
+ */
263
+ floorEntry(key: K): Entry<K, V> | undefined;
264
+
265
+ /**
266
+ * Returns the entry for the least key greater than or equal to the given key, or undefined.
267
+ */
268
+ ceilingEntry(key: K): Entry<K, V> | undefined;
269
+
270
+ /**
271
+ * Returns the entry for the greatest key strictly less than the given key, or undefined.
272
+ */
273
+ lowerEntry(key: K): Entry<K, V> | undefined;
274
+
275
+ /**
276
+ * Returns the entry for the least key strictly greater than the given key, or undefined.
277
+ */
278
+ higherEntry(key: K): Entry<K, V> | undefined;
279
+
280
+ /**
281
+ * Returns the first (lowest) entry in this map, or undefined if empty.
282
+ */
283
+ firstEntry(): Entry<K, V> | undefined;
284
+
285
+ /**
286
+ * Returns the last (highest) entry in this map, or undefined if empty.
287
+ */
288
+ lastEntry(): Entry<K, V> | undefined;
289
+
290
+ /**
291
+ * Removes and returns the first (lowest) entry, or undefined if empty.
292
+ */
293
+ pollFirstEntry(): Entry<K, V> | undefined;
294
+
295
+ /**
296
+ * Removes and returns the last (highest) entry, or undefined if empty.
297
+ */
298
+ pollLastEntry(): Entry<K, V> | undefined;
299
+
300
+ /**
301
+ * Returns a reverse order view of this map.
302
+ */
303
+ descendingMap(): NavigableMap<K, V>;
304
+
305
+ /**
306
+ * Returns a reverse order iterable of the keys.
307
+ */
308
+ descendingKeys(): Iterable<K>;
309
+ }
310
+
311
+ /**
312
+ * MultiMap<K, V> - Map that allows multiple values per key.
313
+ *
314
+ * Not in standard Java Collections, but commonly used.
315
+ */
316
+ export interface MultiMap<K, V> {
317
+ readonly size: number;
318
+ readonly isEmpty: boolean;
319
+
320
+ /**
321
+ * Returns true if the map contains at least one value for the key.
322
+ */
323
+ has(key: K): boolean;
324
+
325
+ /**
326
+ * Returns all values associated with the key.
327
+ */
328
+ get(key: K): ReadonlyCollection<V>;
329
+
330
+ /**
331
+ * Adds a value to the collection of values for the key.
332
+ */
333
+ put(key: K, value: V): boolean;
334
+
335
+ /**
336
+ * Adds all values to the collection of values for the key.
337
+ */
338
+ putAll(key: K, values: Iterable<V>): boolean;
339
+
340
+ /**
341
+ * Removes a single occurrence of value from the key's collection.
342
+ */
343
+ remove(key: K, value: V): boolean;
344
+
345
+ /**
346
+ * Removes all values for the key.
347
+ */
348
+ removeAll(key: K): ReadonlyCollection<V>;
349
+
350
+ /**
351
+ * Replaces all values for the key with the given values.
352
+ */
353
+ replaceAll(key: K, values: Iterable<V>): ReadonlyCollection<V>;
354
+
355
+ /**
356
+ * Returns all keys that have at least one value.
357
+ */
358
+ keys(): Iterable<K>;
359
+
360
+ /**
361
+ * Returns all entries (key with one of its values).
362
+ */
363
+ entries(): Iterable<Entry<K, V>>;
364
+
365
+ /**
366
+ * Removes all mappings.
367
+ */
368
+ clear(): void;
369
+ }
370
+
371
+ /**
372
+ * BiMap<K, V> - Bidirectional map (1:1 mapping).
373
+ *
374
+ * Both keys and values are unique.
375
+ * Allows lookup by key or by value.
376
+ */
377
+ export interface BiMap<K, V> extends MapLike<K, V> {
378
+ /**
379
+ * Returns the inverse view of this bimap (swaps keys and values).
380
+ */
381
+ inverse(): BiMap<V, K>;
382
+
383
+ /**
384
+ * Returns the key mapped to the specified value, or undefined if none.
385
+ */
386
+ getKey(value: V): K | undefined;
387
+
388
+ /**
389
+ * Forces the put by removing any existing entry with the same value.
390
+ */
391
+ forcePut(key: K, value: V): V | undefined;
392
+ }
393
+
394
+ /**
395
+ * WeakMapLike<K extends object, V> - Map with weak key references.
396
+ *
397
+ * Mirrors JavaScript's WeakMap but with our interface conventions.
398
+ * Keys must be objects and are held weakly (allow garbage collection).
399
+ */
400
+ export interface WeakMapLike<K extends object, V> {
401
+ has(key: K): boolean;
402
+ get(key: K): V | undefined;
403
+ set(key: K, value: V): this;
404
+ delete(key: K): boolean;
405
+ }