@procedures/client 0.1.0 → 0.2.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 (334) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +5 -5
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/adapters/http/server/transport.d.ts.map +1 -1
  5. package/dist/adapters/http/server/transport.js +1 -0
  6. package/dist/adapters/http/server/transport.js.map +1 -1
  7. package/dist/browser.d.ts +6 -3
  8. package/dist/browser.d.ts.map +1 -1
  9. package/dist/browser.js +4 -1
  10. package/dist/browser.js.map +1 -1
  11. package/dist/client/client.d.ts +9 -1
  12. package/dist/client/client.d.ts.map +1 -1
  13. package/dist/client/client.js +27 -6
  14. package/dist/client/client.js.map +1 -1
  15. package/dist/client/types.d.ts +9 -0
  16. package/dist/client/types.d.ts.map +1 -1
  17. package/dist/client/types.js.map +1 -1
  18. package/dist/procedures/capability.d.ts +111 -0
  19. package/dist/procedures/capability.d.ts.map +1 -0
  20. package/dist/procedures/capability.js +269 -0
  21. package/dist/procedures/capability.js.map +1 -0
  22. package/dist/procedures/cli/discover.d.ts +3 -3
  23. package/dist/procedures/cli/discover.js +3 -3
  24. package/dist/procedures/cli/index.js +5 -3
  25. package/dist/procedures/cli/index.js.map +1 -1
  26. package/dist/procedures/cli/init.js +1 -1
  27. package/dist/procedures/collection/procedures.d.ts.map +1 -1
  28. package/dist/procedures/collection/procedures.js +12 -0
  29. package/dist/procedures/collection/procedures.js.map +1 -1
  30. package/dist/procedures/core/array.d.ts.map +1 -1
  31. package/dist/procedures/core/array.js +3 -1
  32. package/dist/procedures/core/array.js.map +1 -1
  33. package/dist/procedures/core/comparison.d.ts.map +1 -1
  34. package/dist/procedures/core/comparison.js +3 -1
  35. package/dist/procedures/core/comparison.js.map +1 -1
  36. package/dist/procedures/core/index.d.ts.map +1 -1
  37. package/dist/procedures/core/index.js +5 -2
  38. package/dist/procedures/core/index.js.map +1 -1
  39. package/dist/procedures/core/math.d.ts.map +1 -1
  40. package/dist/procedures/core/math.js +3 -1
  41. package/dist/procedures/core/math.js.map +1 -1
  42. package/dist/procedures/core/meta.d.ts.map +1 -1
  43. package/dist/procedures/core/meta.js +11 -6
  44. package/dist/procedures/core/meta.js.map +1 -1
  45. package/dist/procedures/core/object.d.ts.map +1 -1
  46. package/dist/procedures/core/object.js +3 -1
  47. package/dist/procedures/core/object.js.map +1 -1
  48. package/dist/procedures/core/string.d.ts.map +1 -1
  49. package/dist/procedures/core/string.js +3 -1
  50. package/dist/procedures/core/string.js.map +1 -1
  51. package/dist/procedures/core/type.d.ts.map +1 -1
  52. package/dist/procedures/core/type.js +3 -1
  53. package/dist/procedures/core/type.js.map +1 -1
  54. package/dist/procedures/define-procedure.d.ts.map +1 -1
  55. package/dist/procedures/define-procedure.js +5 -4
  56. package/dist/procedures/define-procedure.js.map +1 -1
  57. package/dist/procedures/effects.d.ts +15 -0
  58. package/dist/procedures/effects.d.ts.map +1 -0
  59. package/dist/procedures/effects.js +18 -0
  60. package/dist/procedures/effects.js.map +1 -0
  61. package/dist/procedures/index.d.ts +5 -2
  62. package/dist/procedures/index.d.ts.map +1 -1
  63. package/dist/procedures/index.js +8 -23
  64. package/dist/procedures/index.js.map +1 -1
  65. package/dist/procedures/interceptors.d.ts.map +1 -1
  66. package/dist/procedures/interceptors.js +2 -1
  67. package/dist/procedures/interceptors.js.map +1 -1
  68. package/dist/procedures/invoke.d.ts +36 -3
  69. package/dist/procedures/invoke.d.ts.map +1 -1
  70. package/dist/procedures/invoke.js +78 -12
  71. package/dist/procedures/invoke.js.map +1 -1
  72. package/dist/procedures/module.d.ts +13 -8
  73. package/dist/procedures/module.d.ts.map +1 -1
  74. package/dist/procedures/module.js +19 -9
  75. package/dist/procedures/module.js.map +1 -1
  76. package/dist/procedures/types.d.ts +100 -2
  77. package/dist/procedures/types.d.ts.map +1 -1
  78. package/dist/procedures/types.js.map +1 -1
  79. package/dist/register.d.ts +8 -0
  80. package/dist/register.d.ts.map +1 -0
  81. package/dist/register.js +9 -0
  82. package/dist/register.js.map +1 -0
  83. package/dist/server/host-policy.d.ts +24 -2
  84. package/dist/server/host-policy.d.ts.map +1 -1
  85. package/dist/server/host-policy.js +22 -0
  86. package/dist/server/host-policy.js.map +1 -1
  87. package/dist/server/procedure-server.d.ts +16 -2
  88. package/dist/server/procedure-server.d.ts.map +1 -1
  89. package/dist/server/procedure-server.js +26 -1
  90. package/dist/server/procedure-server.js.map +1 -1
  91. package/package.json +6 -4
  92. package/src/adapters/http/server/transport.ts +1 -0
  93. package/src/browser.ts +29 -0
  94. package/src/client/client.ts +33 -6
  95. package/src/client/types.ts +11 -0
  96. package/src/procedures/capability.ts +333 -0
  97. package/src/procedures/cli/discover.ts +3 -3
  98. package/src/procedures/cli/index.ts +5 -3
  99. package/src/procedures/cli/init.ts +1 -1
  100. package/src/procedures/collection/procedures.ts +12 -0
  101. package/src/procedures/core/array.ts +3 -1
  102. package/src/procedures/core/comparison.ts +3 -1
  103. package/src/procedures/core/index.ts +5 -2
  104. package/src/procedures/core/math.ts +3 -1
  105. package/src/procedures/core/meta.ts +11 -6
  106. package/src/procedures/core/object.ts +3 -1
  107. package/src/procedures/core/string.ts +3 -1
  108. package/src/procedures/core/type.ts +3 -1
  109. package/src/procedures/define-procedure.ts +5 -4
  110. package/src/procedures/effects.ts +24 -0
  111. package/src/procedures/index.ts +33 -22
  112. package/src/procedures/interceptors.ts +2 -1
  113. package/src/procedures/invoke.ts +112 -13
  114. package/src/procedures/module.ts +19 -9
  115. package/src/procedures/types.ts +113 -2
  116. package/src/register.ts +10 -0
  117. package/src/server/host-policy.ts +44 -2
  118. package/src/server/procedure-server.ts +44 -2
  119. package/dist/client/middleware/batching.d.ts +0 -102
  120. package/dist/client/middleware/batching.d.ts.map +0 -1
  121. package/dist/client/middleware/batching.js +0 -245
  122. package/dist/client/middleware/batching.js.map +0 -1
  123. package/dist/collections/async/async-queue.d.ts +0 -144
  124. package/dist/collections/async/async-queue.d.ts.map +0 -1
  125. package/dist/collections/async/async-queue.js +0 -347
  126. package/dist/collections/async/async-queue.js.map +0 -1
  127. package/dist/collections/async/channels.d.ts +0 -188
  128. package/dist/collections/async/channels.d.ts.map +0 -1
  129. package/dist/collections/async/channels.js +0 -312
  130. package/dist/collections/async/channels.js.map +0 -1
  131. package/dist/collections/behaviors/bounded.d.ts +0 -79
  132. package/dist/collections/behaviors/bounded.d.ts.map +0 -1
  133. package/dist/collections/behaviors/bounded.js +0 -384
  134. package/dist/collections/behaviors/bounded.js.map +0 -1
  135. package/dist/collections/behaviors/evented.d.ts +0 -154
  136. package/dist/collections/behaviors/evented.d.ts.map +0 -1
  137. package/dist/collections/behaviors/evented.js +0 -299
  138. package/dist/collections/behaviors/evented.js.map +0 -1
  139. package/dist/collections/behaviors/lru.d.ts +0 -84
  140. package/dist/collections/behaviors/lru.d.ts.map +0 -1
  141. package/dist/collections/behaviors/lru.js +0 -330
  142. package/dist/collections/behaviors/lru.js.map +0 -1
  143. package/dist/collections/behaviors/readonly.d.ts +0 -73
  144. package/dist/collections/behaviors/readonly.d.ts.map +0 -1
  145. package/dist/collections/behaviors/readonly.js +0 -158
  146. package/dist/collections/behaviors/readonly.js.map +0 -1
  147. package/dist/collections/behaviors/safe.d.ts +0 -163
  148. package/dist/collections/behaviors/safe.d.ts.map +0 -1
  149. package/dist/collections/behaviors/safe.js +0 -172
  150. package/dist/collections/behaviors/safe.js.map +0 -1
  151. package/dist/collections/behaviors/synchronized.d.ts +0 -88
  152. package/dist/collections/behaviors/synchronized.d.ts.map +0 -1
  153. package/dist/collections/behaviors/synchronized.js +0 -294
  154. package/dist/collections/behaviors/synchronized.js.map +0 -1
  155. package/dist/collections/behaviors/ttl.d.ts +0 -118
  156. package/dist/collections/behaviors/ttl.d.ts.map +0 -1
  157. package/dist/collections/behaviors/ttl.js +0 -338
  158. package/dist/collections/behaviors/ttl.js.map +0 -1
  159. package/dist/collections/core/effects.d.ts +0 -176
  160. package/dist/collections/core/effects.d.ts.map +0 -1
  161. package/dist/collections/core/effects.js +0 -180
  162. package/dist/collections/core/effects.js.map +0 -1
  163. package/dist/collections/core/events.d.ts +0 -192
  164. package/dist/collections/core/events.d.ts.map +0 -1
  165. package/dist/collections/core/events.js +0 -291
  166. package/dist/collections/core/events.js.map +0 -1
  167. package/dist/collections/core/middleware.d.ts +0 -231
  168. package/dist/collections/core/middleware.d.ts.map +0 -1
  169. package/dist/collections/core/middleware.js +0 -161
  170. package/dist/collections/core/middleware.js.map +0 -1
  171. package/dist/collections/core/policies.d.ts +0 -220
  172. package/dist/collections/core/policies.d.ts.map +0 -1
  173. package/dist/collections/core/policies.js +0 -48
  174. package/dist/collections/core/policies.js.map +0 -1
  175. package/dist/collections/core/traits.d.ts +0 -142
  176. package/dist/collections/core/traits.d.ts.map +0 -1
  177. package/dist/collections/core/traits.js +0 -8
  178. package/dist/collections/core/traits.js.map +0 -1
  179. package/dist/collections/examples.d.ts +0 -13
  180. package/dist/collections/examples.d.ts.map +0 -1
  181. package/dist/collections/examples.js +0 -302
  182. package/dist/collections/examples.js.map +0 -1
  183. package/dist/collections/fx/collectors.d.ts +0 -190
  184. package/dist/collections/fx/collectors.d.ts.map +0 -1
  185. package/dist/collections/fx/collectors.js +0 -369
  186. package/dist/collections/fx/collectors.js.map +0 -1
  187. package/dist/collections/fx/iter.d.ts +0 -166
  188. package/dist/collections/fx/iter.d.ts.map +0 -1
  189. package/dist/collections/fx/iter.js +0 -421
  190. package/dist/collections/fx/iter.js.map +0 -1
  191. package/dist/collections/impl/array-deque.d.ts +0 -107
  192. package/dist/collections/impl/array-deque.d.ts.map +0 -1
  193. package/dist/collections/impl/array-deque.js +0 -381
  194. package/dist/collections/impl/array-deque.js.map +0 -1
  195. package/dist/collections/impl/array-list.d.ts +0 -101
  196. package/dist/collections/impl/array-list.d.ts.map +0 -1
  197. package/dist/collections/impl/array-list.js +0 -387
  198. package/dist/collections/impl/array-list.js.map +0 -1
  199. package/dist/collections/impl/hash-map.d.ts +0 -141
  200. package/dist/collections/impl/hash-map.d.ts.map +0 -1
  201. package/dist/collections/impl/hash-map.js +0 -450
  202. package/dist/collections/impl/hash-map.js.map +0 -1
  203. package/dist/collections/impl/hash-set.d.ts +0 -125
  204. package/dist/collections/impl/hash-set.d.ts.map +0 -1
  205. package/dist/collections/impl/hash-set.js +0 -264
  206. package/dist/collections/impl/hash-set.js.map +0 -1
  207. package/dist/collections/impl/linked-hash-map.d.ts +0 -141
  208. package/dist/collections/impl/linked-hash-map.d.ts.map +0 -1
  209. package/dist/collections/impl/linked-hash-map.js +0 -472
  210. package/dist/collections/impl/linked-hash-map.js.map +0 -1
  211. package/dist/collections/impl/linked-list.d.ts +0 -109
  212. package/dist/collections/impl/linked-list.d.ts.map +0 -1
  213. package/dist/collections/impl/linked-list.js +0 -491
  214. package/dist/collections/impl/linked-list.js.map +0 -1
  215. package/dist/collections/impl/priority-queue.d.ts +0 -134
  216. package/dist/collections/impl/priority-queue.d.ts.map +0 -1
  217. package/dist/collections/impl/priority-queue.js +0 -336
  218. package/dist/collections/impl/priority-queue.js.map +0 -1
  219. package/dist/collections/impl/tree-map.d.ts +0 -146
  220. package/dist/collections/impl/tree-map.d.ts.map +0 -1
  221. package/dist/collections/impl/tree-map.js +0 -781
  222. package/dist/collections/impl/tree-map.js.map +0 -1
  223. package/dist/collections/impl/tree-set.d.ts +0 -112
  224. package/dist/collections/impl/tree-set.d.ts.map +0 -1
  225. package/dist/collections/impl/tree-set.js +0 -374
  226. package/dist/collections/impl/tree-set.js.map +0 -1
  227. package/dist/collections/index.d.ts +0 -105
  228. package/dist/collections/index.d.ts.map +0 -1
  229. package/dist/collections/index.js +0 -135
  230. package/dist/collections/index.js.map +0 -1
  231. package/dist/collections/interfaces/collection.d.ts +0 -119
  232. package/dist/collections/interfaces/collection.d.ts.map +0 -1
  233. package/dist/collections/interfaces/collection.js +0 -8
  234. package/dist/collections/interfaces/collection.js.map +0 -1
  235. package/dist/collections/interfaces/list.d.ts +0 -247
  236. package/dist/collections/interfaces/list.d.ts.map +0 -1
  237. package/dist/collections/interfaces/list.js +0 -8
  238. package/dist/collections/interfaces/list.js.map +0 -1
  239. package/dist/collections/interfaces/map.d.ts +0 -344
  240. package/dist/collections/interfaces/map.d.ts.map +0 -1
  241. package/dist/collections/interfaces/map.js +0 -8
  242. package/dist/collections/interfaces/map.js.map +0 -1
  243. package/dist/collections/interfaces/queue.d.ts +0 -304
  244. package/dist/collections/interfaces/queue.d.ts.map +0 -1
  245. package/dist/collections/interfaces/queue.js +0 -8
  246. package/dist/collections/interfaces/queue.js.map +0 -1
  247. package/dist/collections/interfaces/set.d.ts +0 -137
  248. package/dist/collections/interfaces/set.d.ts.map +0 -1
  249. package/dist/collections/interfaces/set.js +0 -8
  250. package/dist/collections/interfaces/set.js.map +0 -1
  251. package/dist/collections/storage/api.d.ts +0 -109
  252. package/dist/collections/storage/api.d.ts.map +0 -1
  253. package/dist/collections/storage/api.js +0 -182
  254. package/dist/collections/storage/api.js.map +0 -1
  255. package/dist/collections/storage/hybrid.d.ts +0 -164
  256. package/dist/collections/storage/hybrid.d.ts.map +0 -1
  257. package/dist/collections/storage/hybrid.js +0 -416
  258. package/dist/collections/storage/hybrid.js.map +0 -1
  259. package/dist/collections/storage/index.d.ts +0 -16
  260. package/dist/collections/storage/index.d.ts.map +0 -1
  261. package/dist/collections/storage/index.js +0 -13
  262. package/dist/collections/storage/index.js.map +0 -1
  263. package/dist/collections/storage/interface.d.ts +0 -141
  264. package/dist/collections/storage/interface.d.ts.map +0 -1
  265. package/dist/collections/storage/interface.js +0 -23
  266. package/dist/collections/storage/interface.js.map +0 -1
  267. package/dist/collections/storage/memory.d.ts +0 -68
  268. package/dist/collections/storage/memory.d.ts.map +0 -1
  269. package/dist/collections/storage/memory.js +0 -154
  270. package/dist/collections/storage/memory.js.map +0 -1
  271. package/dist/collections/utils/defaults.d.ts +0 -135
  272. package/dist/collections/utils/defaults.d.ts.map +0 -1
  273. package/dist/collections/utils/defaults.js +0 -322
  274. package/dist/collections/utils/defaults.js.map +0 -1
  275. package/dist/collections/utils/factories.d.ts +0 -144
  276. package/dist/collections/utils/factories.d.ts.map +0 -1
  277. package/dist/collections/utils/factories.js +0 -293
  278. package/dist/collections/utils/factories.js.map +0 -1
  279. package/dist/collections/utils/helpers.d.ts +0 -137
  280. package/dist/collections/utils/helpers.d.ts.map +0 -1
  281. package/dist/collections/utils/helpers.js +0 -221
  282. package/dist/collections/utils/helpers.js.map +0 -1
  283. package/dist/collections.d.ts +0 -12
  284. package/dist/collections.d.ts.map +0 -1
  285. package/dist/collections.js +0 -10
  286. package/dist/collections.js.map +0 -1
  287. package/dist/components/define.d.ts +0 -134
  288. package/dist/components/define.d.ts.map +0 -1
  289. package/dist/components/define.js +0 -486
  290. package/dist/components/define.js.map +0 -1
  291. package/dist/components/index.d.ts +0 -39
  292. package/dist/components/index.d.ts.map +0 -1
  293. package/dist/components/index.js +0 -38
  294. package/dist/components/index.js.map +0 -1
  295. package/dist/components/types.d.ts +0 -264
  296. package/dist/components/types.d.ts.map +0 -1
  297. package/dist/components/types.js +0 -46
  298. package/dist/components/types.js.map +0 -1
  299. package/dist/procedures/storage/adapter.d.ts +0 -148
  300. package/dist/procedures/storage/adapter.d.ts.map +0 -1
  301. package/dist/procedures/storage/adapter.js +0 -214
  302. package/dist/procedures/storage/adapter.js.map +0 -1
  303. package/dist/procedures/storage/api.d.ts +0 -125
  304. package/dist/procedures/storage/api.d.ts.map +0 -1
  305. package/dist/procedures/storage/api.js +0 -220
  306. package/dist/procedures/storage/api.js.map +0 -1
  307. package/dist/procedures/storage/factory.d.ts +0 -134
  308. package/dist/procedures/storage/factory.d.ts.map +0 -1
  309. package/dist/procedures/storage/factory.js +0 -166
  310. package/dist/procedures/storage/factory.js.map +0 -1
  311. package/dist/procedures/storage/hybrid.d.ts +0 -193
  312. package/dist/procedures/storage/hybrid.d.ts.map +0 -1
  313. package/dist/procedures/storage/hybrid.js +0 -519
  314. package/dist/procedures/storage/hybrid.js.map +0 -1
  315. package/dist/procedures/storage/index.d.ts +0 -17
  316. package/dist/procedures/storage/index.d.ts.map +0 -1
  317. package/dist/procedures/storage/index.js +0 -17
  318. package/dist/procedures/storage/index.js.map +0 -1
  319. package/dist/procedures/storage/procedures.d.ts +0 -39
  320. package/dist/procedures/storage/procedures.d.ts.map +0 -1
  321. package/dist/procedures/storage/procedures.js +0 -261
  322. package/dist/procedures/storage/procedures.js.map +0 -1
  323. package/dist/procedures/storage/serialization.d.ts +0 -123
  324. package/dist/procedures/storage/serialization.d.ts.map +0 -1
  325. package/dist/procedures/storage/serialization.js +0 -216
  326. package/dist/procedures/storage/serialization.js.map +0 -1
  327. package/dist/procedures/storage/synced-registry.d.ts +0 -246
  328. package/dist/procedures/storage/synced-registry.d.ts.map +0 -1
  329. package/dist/procedures/storage/synced-registry.js +0 -575
  330. package/dist/procedures/storage/synced-registry.js.map +0 -1
  331. package/dist/procedures/storage/types.d.ts +0 -130
  332. package/dist/procedures/storage/types.d.ts.map +0 -1
  333. package/dist/procedures/storage/types.js +0 -8
  334. package/dist/procedures/storage/types.js.map +0 -1
@@ -1,344 +0,0 @@
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
- import type { Eq, Compare } from "../core/traits.js";
8
- import type { ReadonlyCollection } from "./collection.js";
9
- /**
10
- * Entry<K, V> - An immutable key-value pair from a map.
11
- *
12
- * Unlike java.util.Map.Entry which has setValue(), our entries are immutable
13
- * snapshots. To update a value, use map.set(key, newValue) instead.
14
- *
15
- * This prevents accidental mutation and makes entries safe to share.
16
- */
17
- export interface Entry<K, V> {
18
- readonly key: K;
19
- readonly value: V;
20
- }
21
- /**
22
- * ReadonlyMapLike<K, V> - Readonly key-value mapping.
23
- *
24
- * Provides read-only access to map operations.
25
- * Note: We use "MapLike" to avoid conflicts with TypeScript's built-in Map type.
26
- */
27
- export interface ReadonlyMapLike<K, V> extends Iterable<Entry<K, V>> {
28
- /**
29
- * Returns the number of key-value pairs in this map.
30
- */
31
- readonly size: number;
32
- /**
33
- * Returns true if this map contains no key-value mappings.
34
- */
35
- readonly isEmpty: boolean;
36
- /**
37
- * Returns true if this map contains a mapping for the specified key.
38
- */
39
- has(key: K): boolean;
40
- /**
41
- * Returns the value to which the specified key is mapped.
42
- *
43
- * @throws Error if key is not present
44
- */
45
- get(key: K): V;
46
- /**
47
- * Returns the value for the key, or undefined if not present.
48
- */
49
- getOrUndefined(key: K): V | undefined;
50
- /**
51
- * Returns the value for the key, or the default value if not present.
52
- */
53
- getOrDefault(key: K, defaultValue: V): V;
54
- /**
55
- * Returns true if this map maps one or more keys to the specified value.
56
- */
57
- containsValue(value: V): boolean;
58
- /**
59
- * Returns an iterable view of the keys in this map.
60
- */
61
- keys(): Iterable<K>;
62
- /**
63
- * Returns an iterable view of the values in this map.
64
- */
65
- values(): Iterable<V>;
66
- /**
67
- * Returns an iterable view of the key-value pairs in this map.
68
- */
69
- entries(): Iterable<Entry<K, V>>;
70
- /**
71
- * Performs the given action for each key-value pair.
72
- */
73
- forEach(action: (value: V, key: K, map: this) => void): void;
74
- /**
75
- * Returns the equality function used for keys.
76
- */
77
- readonly keyEq: Eq<K>;
78
- /**
79
- * Returns the equality function used for values.
80
- */
81
- readonly valueEq: Eq<V>;
82
- }
83
- /**
84
- * MapLike<K, V> - Mutable key-value mapping.
85
- *
86
- * Mirrors java.util.Map.
87
- */
88
- export interface MapLike<K, V> extends ReadonlyMapLike<K, V> {
89
- /**
90
- * Associates the specified value with the specified key in this map.
91
- * If the map previously contained a mapping for the key, the old value is replaced.
92
- *
93
- * @param key The key
94
- * @param value The value
95
- * @returns The previous value associated with key, or undefined if none
96
- */
97
- set(key: K, value: V): V | undefined;
98
- /**
99
- * Associates value with key only if key is not already present.
100
- *
101
- * @returns The current value (existing or newly set)
102
- */
103
- setIfAbsent(key: K, value: V): V;
104
- /**
105
- * Removes the mapping for a key if it is present.
106
- *
107
- * @returns The value that was associated with key, or undefined if none
108
- */
109
- delete(key: K): V | undefined;
110
- /**
111
- * Removes the entry for key only if currently mapped to the specified value.
112
- *
113
- * @returns true if the entry was removed
114
- */
115
- deleteEntry(key: K, value: V): boolean;
116
- /**
117
- * Replaces the entry for key only if currently mapped to some value.
118
- *
119
- * @returns The previous value, or undefined if key was not present
120
- */
121
- replace(key: K, value: V): V | undefined;
122
- /**
123
- * Replaces the entry for key only if currently mapped to the specified oldValue.
124
- *
125
- * @returns true if the value was replaced
126
- */
127
- replaceEntry(key: K, oldValue: V, newValue: V): boolean;
128
- /**
129
- * If the specified key is not already associated with a value,
130
- * computes its value using the given function and enters it into the map.
131
- *
132
- * @returns The current (existing or computed) value associated with the key
133
- */
134
- computeIfAbsent(key: K, mappingFunction: (key: K) => V): V;
135
- /**
136
- * If the value for the specified key is present, attempts to compute
137
- * a new mapping given the key and its current mapped value.
138
- *
139
- * @returns The new value associated with the key, or undefined if none
140
- */
141
- computeIfPresent(key: K, remappingFunction: (key: K, value: V) => V | undefined): V | undefined;
142
- /**
143
- * Attempts to compute a mapping for the specified key and its current mapped value.
144
- *
145
- * @returns The new value associated with the key, or undefined if none
146
- */
147
- compute(key: K, remappingFunction: (key: K, value: V | undefined) => V | undefined): V | undefined;
148
- /**
149
- * If the specified key is not already associated with a value or is
150
- * associated with undefined, associates it with the given non-undefined value.
151
- * Otherwise, replaces the value with the results of the given remapping function.
152
- *
153
- * @returns The new value associated with the key, or undefined if none
154
- */
155
- merge(key: K, value: V, remappingFunction: (oldValue: V, newValue: V) => V | undefined): V | undefined;
156
- /**
157
- * Copies all mappings from the specified map to this map.
158
- */
159
- putAll(other: ReadonlyMapLike<K, V> | Iterable<Entry<K, V>>): void;
160
- /**
161
- * Removes all mappings from this map.
162
- */
163
- clear(): void;
164
- }
165
- /**
166
- * SortedMap<K, V> - Map that maintains keys in sorted order.
167
- *
168
- * Mirrors java.util.SortedMap.
169
- */
170
- export interface SortedMap<K, V> extends MapLike<K, V> {
171
- /**
172
- * Returns the comparison function used to order keys.
173
- */
174
- readonly comparator: Compare<K>;
175
- /**
176
- * Returns the first (lowest) key in this map.
177
- *
178
- * @throws Error if map is empty
179
- */
180
- firstKey(): K;
181
- /**
182
- * Returns the last (highest) key in this map.
183
- *
184
- * @throws Error if map is empty
185
- */
186
- lastKey(): K;
187
- /**
188
- * Returns a view of the portion of this map whose keys are less than toKey.
189
- */
190
- headMap(toKey: K): SortedMap<K, V>;
191
- /**
192
- * Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
193
- */
194
- tailMap(fromKey: K): SortedMap<K, V>;
195
- /**
196
- * Returns a view of the portion of this map whose keys range from fromKey to toKey.
197
- */
198
- subMap(fromKey: K, toKey: K): SortedMap<K, V>;
199
- }
200
- /**
201
- * NavigableMap<K, V> - Extended sorted map with navigation methods.
202
- *
203
- * Mirrors java.util.NavigableMap.
204
- */
205
- export interface NavigableMap<K, V> extends SortedMap<K, V> {
206
- /**
207
- * Returns the greatest key less than or equal to the given key, or undefined if none.
208
- */
209
- floorKey(key: K): K | undefined;
210
- /**
211
- * Returns the least key greater than or equal to the given key, or undefined if none.
212
- */
213
- ceilingKey(key: K): K | undefined;
214
- /**
215
- * Returns the greatest key strictly less than the given key, or undefined if none.
216
- */
217
- lowerKey(key: K): K | undefined;
218
- /**
219
- * Returns the least key strictly greater than the given key, or undefined if none.
220
- */
221
- higherKey(key: K): K | undefined;
222
- /**
223
- * Returns the entry for the greatest key less than or equal to the given key, or undefined.
224
- */
225
- floorEntry(key: K): Entry<K, V> | undefined;
226
- /**
227
- * Returns the entry for the least key greater than or equal to the given key, or undefined.
228
- */
229
- ceilingEntry(key: K): Entry<K, V> | undefined;
230
- /**
231
- * Returns the entry for the greatest key strictly less than the given key, or undefined.
232
- */
233
- lowerEntry(key: K): Entry<K, V> | undefined;
234
- /**
235
- * Returns the entry for the least key strictly greater than the given key, or undefined.
236
- */
237
- higherEntry(key: K): Entry<K, V> | undefined;
238
- /**
239
- * Returns the first (lowest) entry in this map, or undefined if empty.
240
- */
241
- firstEntry(): Entry<K, V> | undefined;
242
- /**
243
- * Returns the last (highest) entry in this map, or undefined if empty.
244
- */
245
- lastEntry(): Entry<K, V> | undefined;
246
- /**
247
- * Removes and returns the first (lowest) entry, or undefined if empty.
248
- */
249
- pollFirstEntry(): Entry<K, V> | undefined;
250
- /**
251
- * Removes and returns the last (highest) entry, or undefined if empty.
252
- */
253
- pollLastEntry(): Entry<K, V> | undefined;
254
- /**
255
- * Returns a reverse order view of this map.
256
- */
257
- descendingMap(): NavigableMap<K, V>;
258
- /**
259
- * Returns a reverse order iterable of the keys.
260
- */
261
- descendingKeys(): Iterable<K>;
262
- }
263
- /**
264
- * MultiMap<K, V> - Map that allows multiple values per key.
265
- *
266
- * Not in standard Java Collections, but commonly used.
267
- */
268
- export interface MultiMap<K, V> {
269
- readonly size: number;
270
- readonly isEmpty: boolean;
271
- /**
272
- * Returns true if the map contains at least one value for the key.
273
- */
274
- has(key: K): boolean;
275
- /**
276
- * Returns all values associated with the key.
277
- */
278
- get(key: K): ReadonlyCollection<V>;
279
- /**
280
- * Adds a value to the collection of values for the key.
281
- */
282
- put(key: K, value: V): boolean;
283
- /**
284
- * Adds all values to the collection of values for the key.
285
- */
286
- putAll(key: K, values: Iterable<V>): boolean;
287
- /**
288
- * Removes a single occurrence of value from the key's collection.
289
- */
290
- remove(key: K, value: V): boolean;
291
- /**
292
- * Removes all values for the key.
293
- */
294
- removeAll(key: K): ReadonlyCollection<V>;
295
- /**
296
- * Replaces all values for the key with the given values.
297
- */
298
- replaceAll(key: K, values: Iterable<V>): ReadonlyCollection<V>;
299
- /**
300
- * Returns all keys that have at least one value.
301
- */
302
- keys(): Iterable<K>;
303
- /**
304
- * Returns all entries (key with one of its values).
305
- */
306
- entries(): Iterable<Entry<K, V>>;
307
- /**
308
- * Removes all mappings.
309
- */
310
- clear(): void;
311
- }
312
- /**
313
- * BiMap<K, V> - Bidirectional map (1:1 mapping).
314
- *
315
- * Both keys and values are unique.
316
- * Allows lookup by key or by value.
317
- */
318
- export interface BiMap<K, V> extends MapLike<K, V> {
319
- /**
320
- * Returns the inverse view of this bimap (swaps keys and values).
321
- */
322
- inverse(): BiMap<V, K>;
323
- /**
324
- * Returns the key mapped to the specified value, or undefined if none.
325
- */
326
- getKey(value: V): K | undefined;
327
- /**
328
- * Forces the put by removing any existing entry with the same value.
329
- */
330
- forcePut(key: K, value: V): V | undefined;
331
- }
332
- /**
333
- * WeakMapLike<K extends object, V> - Map with weak key references.
334
- *
335
- * Mirrors JavaScript's WeakMap but with our interface conventions.
336
- * Keys must be objects and are held weakly (allow garbage collection).
337
- */
338
- export interface WeakMapLike<K extends object, V> {
339
- has(key: K): boolean;
340
- get(key: K): V | undefined;
341
- set(key: K, value: V): this;
342
- delete(key: K): boolean;
343
- }
344
- //# sourceMappingURL=map.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/collections/interfaces/map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,GAAG,CAAC,G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8 +0,0 @@
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
- export {};
8
- //# sourceMappingURL=map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map.js","sourceRoot":"","sources":["../../../src/collections/interfaces/map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,304 +0,0 @@
1
- /**
2
- * Queue and Deque interfaces that mirror Java's Queue and Deque.
3
- *
4
- * Queues are collections designed for holding elements prior to processing.
5
- * Deques (double-ended queues) allow efficient insertion/removal at both ends.
6
- */
7
- import type { Collection, ReadonlyCollection } from "./collection.js";
8
- import type { Compare } from "../core/traits.js";
9
- /**
10
- * ReadonlyQueue<T> - Readonly FIFO (First-In-First-Out) queue.
11
- *
12
- * Provides read-only access to queue operations.
13
- */
14
- export interface ReadonlyQueue<T> extends ReadonlyCollection<T> {
15
- /**
16
- * Retrieves, but does not remove, the head of this queue.
17
- *
18
- * @returns The head element
19
- * @throws Error if queue is empty
20
- */
21
- peek(): T;
22
- /**
23
- * Returns the head element without throwing if empty.
24
- * Returns undefined if queue is empty.
25
- */
26
- peekOrUndefined(): T | undefined;
27
- }
28
- /**
29
- * Queue<T> - FIFO (First-In-First-Out) queue.
30
- *
31
- * Mirrors java.util.Queue.
32
- * Elements are processed in the order they were added.
33
- */
34
- export interface Queue<T> extends ReadonlyQueue<T>, Collection<T> {
35
- /**
36
- * Inserts an element into the queue.
37
- * For bounded queues with overflow='throw', throws if queue is full.
38
- *
39
- * @param element The element to add
40
- * @returns true if element was added
41
- * @throws Error if queue is full (bounded with throw policy)
42
- */
43
- offer(element: T): boolean;
44
- /**
45
- * Retrieves and removes the head of this queue.
46
- *
47
- * @returns The head element
48
- * @throws Error if queue is empty
49
- */
50
- poll(): T;
51
- /**
52
- * Retrieves and removes the head of this queue, or returns undefined if empty.
53
- */
54
- pollOrUndefined(): T | undefined;
55
- /**
56
- * Alias for offer(). Adds element to end of queue.
57
- * Included for consistency with standard queue terminology.
58
- */
59
- enqueue(element: T): boolean;
60
- /**
61
- * Alias for poll(). Removes and returns element from front of queue.
62
- * Included for consistency with standard queue terminology.
63
- */
64
- dequeue(): T;
65
- }
66
- /**
67
- * Deque<T> - Double-ended queue.
68
- *
69
- * Mirrors java.util.Deque.
70
- * Supports insertion and removal at both ends.
71
- * Can be used as a queue (FIFO) or stack (LIFO).
72
- */
73
- export interface Deque<T> extends Queue<T> {
74
- /**
75
- * Inserts element at the front of this deque.
76
- *
77
- * @param element The element to add
78
- * @throws Error if deque is full (bounded with throw policy)
79
- */
80
- addFirst(element: T): void;
81
- /**
82
- * Inserts element at the front, returning false if full.
83
- */
84
- offerFirst(element: T): boolean;
85
- /**
86
- * Retrieves and removes the first element.
87
- *
88
- * @throws Error if deque is empty
89
- */
90
- removeFirst(): T;
91
- /**
92
- * Retrieves and removes the first element, or undefined if empty.
93
- */
94
- pollFirst(): T | undefined;
95
- /**
96
- * Retrieves but does not remove the first element.
97
- *
98
- * @throws Error if deque is empty
99
- */
100
- peekFirst(): T;
101
- /**
102
- * Retrieves but does not remove the first element, or undefined if empty.
103
- */
104
- peekFirstOrUndefined(): T | undefined;
105
- /**
106
- * Inserts element at the end of this deque.
107
- *
108
- * @param element The element to add
109
- * @throws Error if deque is full (bounded with throw policy)
110
- */
111
- addLast(element: T): void;
112
- /**
113
- * Inserts element at the end, returning false if full.
114
- */
115
- offerLast(element: T): boolean;
116
- /**
117
- * Retrieves and removes the last element.
118
- *
119
- * @throws Error if deque is empty
120
- */
121
- removeLast(): T;
122
- /**
123
- * Retrieves and removes the last element, or undefined if empty.
124
- */
125
- pollLast(): T | undefined;
126
- /**
127
- * Retrieves but does not remove the last element.
128
- *
129
- * @throws Error if deque is empty
130
- */
131
- peekLast(): T;
132
- /**
133
- * Retrieves but does not remove the last element, or undefined if empty.
134
- */
135
- peekLastOrUndefined(): T | undefined;
136
- /**
137
- * Pushes element onto the stack represented by this deque.
138
- * Equivalent to addFirst().
139
- *
140
- * @param element The element to push
141
- */
142
- push(element: T): void;
143
- /**
144
- * Pops an element from the stack represented by this deque.
145
- * Equivalent to removeFirst().
146
- *
147
- * @returns The popped element
148
- * @throws Error if deque is empty
149
- */
150
- pop(): T;
151
- }
152
- /**
153
- * BlockingQueue<T> - Queue that supports blocking operations.
154
- *
155
- * Mirrors java.util.concurrent.BlockingQueue.
156
- * Useful for producer-consumer patterns.
157
- */
158
- export interface BlockingQueue<T> extends Queue<T> {
159
- /**
160
- * Inserts element, waiting if necessary for space to become available.
161
- *
162
- * @param element The element to add
163
- * @param timeoutMs Optional timeout in milliseconds
164
- * @returns Promise that resolves to true when element is added
165
- * @throws Error if timeout expires
166
- */
167
- put(element: T, timeoutMs?: number): Promise<void>;
168
- /**
169
- * Retrieves and removes the head, waiting if necessary until an element is available.
170
- *
171
- * @param timeoutMs Optional timeout in milliseconds
172
- * @returns Promise that resolves to the head element
173
- * @throws Error if timeout expires
174
- */
175
- take(timeoutMs?: number): Promise<T>;
176
- /**
177
- * Returns the remaining capacity.
178
- * Returns Infinity for unbounded queues.
179
- */
180
- readonly remainingCapacity: number;
181
- /**
182
- * Removes all available elements and adds them to the given array.
183
- * Returns the number of elements transferred.
184
- */
185
- drainTo(target: T[], maxElements?: number): number;
186
- }
187
- /**
188
- * PriorityQueue<T> - Queue that orders elements by priority.
189
- *
190
- * Mirrors java.util.PriorityQueue.
191
- * Elements are removed in priority order (not insertion order).
192
- * Requires a comparison function to determine priority.
193
- */
194
- export interface PriorityQueue<T> extends Queue<T> {
195
- /**
196
- * The comparison function used to determine priority.
197
- * Elements with lower compare value have higher priority.
198
- */
199
- readonly compare: Compare<T>;
200
- /**
201
- * Returns the comparator used to order elements, or undefined if natural ordering.
202
- */
203
- readonly comparator: Compare<T> | undefined;
204
- }
205
- /**
206
- * AsyncQueue<T> - Async iterable queue.
207
- *
208
- * Designed for async/await patterns and streaming data.
209
- * Implements AsyncIterable for use with for-await-of loops.
210
- */
211
- export interface AsyncQueue<T> extends AsyncIterable<T> {
212
- /** Number of elements currently in queue */
213
- readonly size: number;
214
- /** True if queue is empty */
215
- readonly isEmpty: boolean;
216
- /**
217
- * Adds element to queue.
218
- * For bounded queues, may wait for space to become available.
219
- */
220
- put(element: T): Promise<void>;
221
- /**
222
- * Removes and returns next element.
223
- * Waits for an element if queue is empty.
224
- */
225
- take(): Promise<T>;
226
- /**
227
- * Attempts to add element without waiting.
228
- * Returns false if queue is full.
229
- */
230
- tryPut(element: T): boolean;
231
- /**
232
- * Attempts to remove element without waiting.
233
- * Returns undefined if queue is empty.
234
- */
235
- tryTake(): T | undefined;
236
- /**
237
- * Returns next element without removing it.
238
- * Waits for an element if queue is empty.
239
- */
240
- peek(): Promise<T>;
241
- /**
242
- * Closes the queue, preventing further additions.
243
- * Allows existing elements to be consumed.
244
- */
245
- close(): void;
246
- /**
247
- * Returns true if queue is closed.
248
- */
249
- readonly isClosed: boolean;
250
- }
251
- /**
252
- * TransferQueue<T> - Queue where producers can wait for consumers.
253
- *
254
- * Mirrors java.util.concurrent.TransferQueue.
255
- * Useful for direct handoff between producer and consumer threads.
256
- */
257
- export interface TransferQueue<T> extends BlockingQueue<T> {
258
- /**
259
- * Transfers element to consumer, waiting if necessary.
260
- * Waits for a consumer to receive the element.
261
- *
262
- * @param element The element to transfer
263
- * @returns Promise that resolves when element is received
264
- */
265
- transfer(element: T): Promise<void>;
266
- /**
267
- * Attempts to transfer element to waiting consumer.
268
- * Returns false immediately if no consumer is waiting.
269
- *
270
- * @param element The element to transfer
271
- * @param timeoutMs Optional timeout in milliseconds
272
- */
273
- tryTransfer(element: T, timeoutMs?: number): Promise<boolean>;
274
- /**
275
- * Returns true if there are consumers waiting to receive elements.
276
- */
277
- readonly hasWaitingConsumer: boolean;
278
- /**
279
- * Returns an estimate of the number of consumers waiting to receive elements.
280
- */
281
- readonly waitingConsumerCount: number;
282
- }
283
- /**
284
- * DelayQueue<T> - Queue where elements become available after a delay.
285
- *
286
- * Mirrors java.util.concurrent.DelayQueue.
287
- * Elements can only be removed once their delay has expired.
288
- */
289
- export interface DelayQueue<T> extends BlockingQueue<T> {
290
- /**
291
- * Adds element with specified delay.
292
- *
293
- * @param element The element to add
294
- * @param delayMs Delay in milliseconds before element becomes available (defaults to 0)
295
- */
296
- offer(element: T, delayMs?: number): boolean;
297
- /**
298
- * Returns the delay (in ms) until next element becomes available.
299
- * Returns 0 if element is ready now.
300
- * Returns Infinity if queue is empty.
301
- */
302
- readonly nextDelay: number;
303
- }
304
- //# sourceMappingURL=queue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/collections/interfaces/queue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAC7D;;;;;OAKG;IACH,IAAI,IAAI,CAAC,CAAC;IAEV;;;OAGG;IACH,eAAe,IAAI,CAAC,GAAG,SAAS,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/D;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,IAAI,IAAI,CAAC,CAAC;IAEV;;OAEG;IACH,eAAe,IAAI,CAAC,GAAG,SAAS,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;IAE7B;;;OAGG;IACH,OAAO,IAAI,CAAC,CAAC;CACd;AAED;;;;;;GAMG;AACH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WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9D;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACrD;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Queue and Deque interfaces that mirror Java's Queue and Deque.
3
- *
4
- * Queues are collections designed for holding elements prior to processing.
5
- * Deques (double-ended queues) allow efficient insertion/removal at both ends.
6
- */
7
- export {};
8
- //# sourceMappingURL=queue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../src/collections/interfaces/queue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}