@adviser/cement 0.4.62 → 0.4.64-dev

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 (428) hide show
  1. package/cjs/app-context.cjs.map +1 -1
  2. package/cjs/app-context.d.ts.map +1 -1
  3. package/cjs/base-sys-abstraction.cjs.map +1 -1
  4. package/cjs/base-sys-abstraction.d.ts.map +1 -1
  5. package/cjs/bin2text.cjs.map +1 -1
  6. package/cjs/bin2text.d.ts.map +1 -1
  7. package/cjs/coerce-binary.cjs.map +1 -1
  8. package/cjs/coerce-binary.d.ts.map +1 -1
  9. package/cjs/crypto.cjs.map +1 -1
  10. package/cjs/crypto.d.ts.map +1 -1
  11. package/cjs/future.cjs.map +1 -1
  12. package/cjs/future.d.ts.map +1 -1
  13. package/cjs/http_header.cjs.map +1 -1
  14. package/cjs/http_header.d.ts.map +1 -1
  15. package/cjs/index.cjs +1 -0
  16. package/cjs/index.cjs.map +1 -1
  17. package/cjs/index.d.ts +1 -0
  18. package/cjs/index.d.ts.map +1 -1
  19. package/cjs/is-json.cjs.map +1 -1
  20. package/cjs/is-json.d.ts.map +1 -1
  21. package/cjs/is-promise.cjs.map +1 -1
  22. package/cjs/is-promise.d.ts.map +1 -1
  23. package/cjs/keyed-ng.cjs +93 -0
  24. package/cjs/keyed-ng.cjs.map +1 -0
  25. package/cjs/keyed-ng.d.ts +51 -0
  26. package/cjs/keyed-ng.d.ts.map +1 -0
  27. package/cjs/keyed-ng.test.cjs +151 -0
  28. package/cjs/keyed-ng.test.cjs.map +1 -0
  29. package/cjs/keyed-ng.test.d.ts +2 -0
  30. package/cjs/keyed-ng.test.d.ts.map +1 -0
  31. package/cjs/lru-map-set.cjs +2 -1
  32. package/cjs/lru-map-set.cjs.map +1 -1
  33. package/cjs/lru-map-set.d.ts +4 -1
  34. package/cjs/lru-map-set.d.ts.map +1 -1
  35. package/cjs/on-func.cjs.map +1 -1
  36. package/cjs/on-func.d.ts.map +1 -1
  37. package/cjs/option.cjs.map +1 -1
  38. package/cjs/option.d.ts.map +1 -1
  39. package/cjs/poller.cjs +8 -3
  40. package/cjs/poller.cjs.map +1 -1
  41. package/cjs/poller.d.ts +9 -2
  42. package/cjs/poller.d.ts.map +1 -1
  43. package/cjs/promise-sleep.cjs.map +1 -1
  44. package/cjs/promise-sleep.d.ts.map +1 -1
  45. package/cjs/resolve-once.cjs +84 -43
  46. package/cjs/resolve-once.cjs.map +1 -1
  47. package/cjs/resolve-once.d.ts +31 -34
  48. package/cjs/resolve-once.d.ts.map +1 -1
  49. package/cjs/resolve-once.test.cjs +119 -31
  50. package/cjs/resolve-once.test.cjs.map +1 -1
  51. package/cjs/result.cjs.map +1 -1
  52. package/cjs/result.d.ts.map +1 -1
  53. package/cjs/runtime.cjs.map +1 -1
  54. package/cjs/runtime.d.ts.map +1 -1
  55. package/cjs/sys-env.cjs.map +1 -1
  56. package/cjs/sys-env.d.ts.map +1 -1
  57. package/cjs/timeouted.cjs.map +1 -1
  58. package/cjs/timeouted.d.ts.map +1 -1
  59. package/cjs/tracer.cjs.map +1 -1
  60. package/cjs/tracer.d.ts.map +1 -1
  61. package/cjs/txt-en-decoder.cjs +2 -5
  62. package/cjs/txt-en-decoder.cjs.map +1 -1
  63. package/cjs/txt-en-decoder.d.ts +1 -1
  64. package/cjs/txt-en-decoder.d.ts.map +1 -1
  65. package/cjs/uri.cjs.map +1 -1
  66. package/cjs/uri.d.ts.map +1 -1
  67. package/cjs/utils/coerce-uint8.cjs.map +1 -1
  68. package/cjs/utils/coerce-uint8.d.ts.map +1 -1
  69. package/cjs/utils/console-write-stream.cjs.map +1 -1
  70. package/cjs/utils/console-write-stream.d.ts.map +1 -1
  71. package/cjs/utils/consume.cjs.map +1 -1
  72. package/cjs/utils/consume.d.ts.map +1 -1
  73. package/cjs/utils/fanout-write-stream.cjs.map +1 -1
  74. package/cjs/utils/fanout-write-stream.d.ts.map +1 -1
  75. package/cjs/utils/get-params-result.cjs.map +1 -1
  76. package/cjs/utils/get-params-result.d.ts.map +1 -1
  77. package/cjs/utils/rebuffer.cjs.map +1 -1
  78. package/cjs/utils/rebuffer.d.ts.map +1 -1
  79. package/cjs/utils/relative-path.cjs.map +1 -1
  80. package/cjs/utils/relative-path.d.ts.map +1 -1
  81. package/cjs/utils/sorted-object.cjs.map +1 -1
  82. package/cjs/utils/sorted-object.d.ts.map +1 -1
  83. package/cjs/utils/stream-map.cjs.map +1 -1
  84. package/cjs/utils/stream-map.d.ts.map +1 -1
  85. package/cjs/utils/stream2string.cjs.map +1 -1
  86. package/cjs/utils/stream2string.d.ts.map +1 -1
  87. package/cjs/utils/string2stream.cjs.map +1 -1
  88. package/cjs/utils/string2stream.d.ts.map +1 -1
  89. package/cjs/utils/stripper.cjs.map +1 -1
  90. package/cjs/utils/stripper.d.ts.map +1 -1
  91. package/cjs/utils/to-sorted.cjs.map +1 -1
  92. package/cjs/utils/to-sorted.d.ts.map +1 -1
  93. package/cjs/utils/uint8array-equal.cjs.map +1 -1
  94. package/cjs/utils/uint8array-equal.d.ts.map +1 -1
  95. package/cjs/version.cjs +1 -1
  96. package/cjs/version.cjs.map +1 -1
  97. package/cjs/version.d.ts.map +1 -1
  98. package/deno.json +1 -1
  99. package/esm/app-context.d.ts.map +1 -1
  100. package/esm/app-context.js.map +1 -1
  101. package/esm/base-sys-abstraction.d.ts.map +1 -1
  102. package/esm/base-sys-abstraction.js.map +1 -1
  103. package/esm/bin2text.d.ts.map +1 -1
  104. package/esm/bin2text.js.map +1 -1
  105. package/esm/coerce-binary.d.ts.map +1 -1
  106. package/esm/coerce-binary.js.map +1 -1
  107. package/esm/crypto.d.ts.map +1 -1
  108. package/esm/crypto.js.map +1 -1
  109. package/esm/future.d.ts.map +1 -1
  110. package/esm/future.js.map +1 -1
  111. package/esm/http_header.d.ts.map +1 -1
  112. package/esm/http_header.js.map +1 -1
  113. package/esm/index.d.ts +1 -0
  114. package/esm/index.d.ts.map +1 -1
  115. package/esm/index.js +1 -0
  116. package/esm/index.js.map +1 -1
  117. package/esm/is-json.d.ts.map +1 -1
  118. package/esm/is-json.js.map +1 -1
  119. package/esm/is-promise.d.ts.map +1 -1
  120. package/esm/is-promise.js.map +1 -1
  121. package/esm/keyed-ng.d.ts +51 -0
  122. package/esm/keyed-ng.d.ts.map +1 -0
  123. package/esm/keyed-ng.js +89 -0
  124. package/esm/keyed-ng.js.map +1 -0
  125. package/esm/keyed-ng.test.d.ts +2 -0
  126. package/esm/keyed-ng.test.d.ts.map +1 -0
  127. package/esm/keyed-ng.test.js +149 -0
  128. package/esm/keyed-ng.test.js.map +1 -0
  129. package/esm/lru-map-set.d.ts +4 -1
  130. package/esm/lru-map-set.d.ts.map +1 -1
  131. package/esm/lru-map-set.js +2 -1
  132. package/esm/lru-map-set.js.map +1 -1
  133. package/esm/on-func.d.ts.map +1 -1
  134. package/esm/on-func.js.map +1 -1
  135. package/esm/option.d.ts.map +1 -1
  136. package/esm/option.js.map +1 -1
  137. package/esm/poller.d.ts +9 -2
  138. package/esm/poller.d.ts.map +1 -1
  139. package/esm/poller.js +8 -3
  140. package/esm/poller.js.map +1 -1
  141. package/esm/promise-sleep.d.ts.map +1 -1
  142. package/esm/promise-sleep.js.map +1 -1
  143. package/esm/resolve-once.d.ts +31 -34
  144. package/esm/resolve-once.d.ts.map +1 -1
  145. package/esm/resolve-once.js +83 -41
  146. package/esm/resolve-once.js.map +1 -1
  147. package/esm/resolve-once.test.js +119 -31
  148. package/esm/resolve-once.test.js.map +1 -1
  149. package/esm/result.d.ts.map +1 -1
  150. package/esm/result.js.map +1 -1
  151. package/esm/runtime.d.ts.map +1 -1
  152. package/esm/runtime.js.map +1 -1
  153. package/esm/sys-env.d.ts.map +1 -1
  154. package/esm/sys-env.js.map +1 -1
  155. package/esm/timeouted.d.ts.map +1 -1
  156. package/esm/timeouted.js.map +1 -1
  157. package/esm/tracer.d.ts.map +1 -1
  158. package/esm/tracer.js.map +1 -1
  159. package/esm/txt-en-decoder.d.ts +1 -1
  160. package/esm/txt-en-decoder.d.ts.map +1 -1
  161. package/esm/txt-en-decoder.js +2 -5
  162. package/esm/txt-en-decoder.js.map +1 -1
  163. package/esm/uri.d.ts.map +1 -1
  164. package/esm/uri.js.map +1 -1
  165. package/esm/utils/coerce-uint8.d.ts.map +1 -1
  166. package/esm/utils/coerce-uint8.js.map +1 -1
  167. package/esm/utils/console-write-stream.d.ts.map +1 -1
  168. package/esm/utils/console-write-stream.js.map +1 -1
  169. package/esm/utils/consume.d.ts.map +1 -1
  170. package/esm/utils/consume.js.map +1 -1
  171. package/esm/utils/fanout-write-stream.d.ts.map +1 -1
  172. package/esm/utils/fanout-write-stream.js.map +1 -1
  173. package/esm/utils/get-params-result.d.ts.map +1 -1
  174. package/esm/utils/get-params-result.js.map +1 -1
  175. package/esm/utils/rebuffer.d.ts.map +1 -1
  176. package/esm/utils/rebuffer.js.map +1 -1
  177. package/esm/utils/relative-path.d.ts.map +1 -1
  178. package/esm/utils/relative-path.js.map +1 -1
  179. package/esm/utils/sorted-object.d.ts.map +1 -1
  180. package/esm/utils/sorted-object.js.map +1 -1
  181. package/esm/utils/stream-map.d.ts.map +1 -1
  182. package/esm/utils/stream-map.js.map +1 -1
  183. package/esm/utils/stream2string.d.ts.map +1 -1
  184. package/esm/utils/stream2string.js.map +1 -1
  185. package/esm/utils/string2stream.d.ts.map +1 -1
  186. package/esm/utils/string2stream.js.map +1 -1
  187. package/esm/utils/stripper.d.ts.map +1 -1
  188. package/esm/utils/stripper.js.map +1 -1
  189. package/esm/utils/to-sorted.d.ts.map +1 -1
  190. package/esm/utils/to-sorted.js.map +1 -1
  191. package/esm/utils/uint8array-equal.d.ts.map +1 -1
  192. package/esm/utils/uint8array-equal.js.map +1 -1
  193. package/esm/version.d.ts.map +1 -1
  194. package/esm/version.js +1 -1
  195. package/esm/version.js.map +1 -1
  196. package/package.json +7 -4
  197. package/src/app-context.ts +111 -5
  198. package/src/base-sys-abstraction.ts +244 -0
  199. package/src/bin2text.ts +37 -0
  200. package/src/coerce-binary.ts +41 -0
  201. package/src/crypto.ts +35 -0
  202. package/src/future.ts +45 -1
  203. package/src/http_header.ts +277 -1
  204. package/src/index.ts +1 -0
  205. package/src/is-json.ts +21 -0
  206. package/src/is-promise.ts +26 -0
  207. package/src/keyed-ng.ts +628 -0
  208. package/src/lru-map-set.ts +52 -2
  209. package/src/on-func.ts +38 -0
  210. package/src/option.ts +27 -0
  211. package/src/poller.ts +65 -17
  212. package/src/promise-sleep.ts +32 -4
  213. package/src/resolve-once.ts +596 -93
  214. package/src/result.ts +50 -0
  215. package/src/runtime.ts +75 -2
  216. package/src/sys-env.ts +57 -0
  217. package/src/timeouted.ts +92 -0
  218. package/src/tracer.ts +41 -0
  219. package/src/txt-en-decoder.ts +2 -5
  220. package/src/uri.ts +76 -4
  221. package/src/utils/coerce-uint8.ts +60 -0
  222. package/src/utils/console-write-stream.ts +34 -0
  223. package/src/utils/consume.ts +106 -0
  224. package/src/utils/fanout-write-stream.ts +45 -0
  225. package/src/utils/get-params-result.ts +37 -0
  226. package/src/utils/rebuffer.ts +42 -0
  227. package/src/utils/relative-path.ts +108 -0
  228. package/src/utils/sorted-object.ts +50 -0
  229. package/src/utils/stream-map.ts +90 -0
  230. package/src/utils/stream2string.ts +35 -0
  231. package/src/utils/string2stream.ts +30 -0
  232. package/src/utils/stripper.ts +34 -0
  233. package/src/utils/to-sorted.ts +34 -0
  234. package/src/utils/uint8array-equal.ts +20 -0
  235. package/ts/cjs/app-context.d.ts.map +1 -1
  236. package/ts/cjs/app-context.js.map +1 -1
  237. package/ts/cjs/base-sys-abstraction.d.ts.map +1 -1
  238. package/ts/cjs/base-sys-abstraction.js.map +1 -1
  239. package/ts/cjs/bin2text.d.ts.map +1 -1
  240. package/ts/cjs/bin2text.js.map +1 -1
  241. package/ts/cjs/coerce-binary.d.ts.map +1 -1
  242. package/ts/cjs/coerce-binary.js.map +1 -1
  243. package/ts/cjs/crypto.d.ts.map +1 -1
  244. package/ts/cjs/crypto.js.map +1 -1
  245. package/ts/cjs/future.d.ts.map +1 -1
  246. package/ts/cjs/future.js.map +1 -1
  247. package/ts/cjs/http_header.d.ts.map +1 -1
  248. package/ts/cjs/http_header.js.map +1 -1
  249. package/ts/cjs/index.d.ts +1 -0
  250. package/ts/cjs/index.d.ts.map +1 -1
  251. package/ts/cjs/index.js +1 -0
  252. package/ts/cjs/index.js.map +1 -1
  253. package/ts/cjs/is-json.d.ts.map +1 -1
  254. package/ts/cjs/is-json.js.map +1 -1
  255. package/ts/cjs/is-promise.d.ts.map +1 -1
  256. package/ts/cjs/is-promise.js.map +1 -1
  257. package/ts/cjs/keyed-ng.d.ts +51 -0
  258. package/ts/cjs/keyed-ng.d.ts.map +1 -0
  259. package/ts/cjs/keyed-ng.js +93 -0
  260. package/ts/cjs/keyed-ng.js.map +1 -0
  261. package/ts/cjs/keyed-ng.test.d.ts +2 -0
  262. package/ts/cjs/keyed-ng.test.d.ts.map +1 -0
  263. package/ts/cjs/keyed-ng.test.js +151 -0
  264. package/ts/cjs/keyed-ng.test.js.map +1 -0
  265. package/ts/cjs/lru-map-set.d.ts +4 -1
  266. package/ts/cjs/lru-map-set.d.ts.map +1 -1
  267. package/ts/cjs/lru-map-set.js +2 -1
  268. package/ts/cjs/lru-map-set.js.map +1 -1
  269. package/ts/cjs/on-func.d.ts.map +1 -1
  270. package/ts/cjs/on-func.js.map +1 -1
  271. package/ts/cjs/option.d.ts.map +1 -1
  272. package/ts/cjs/option.js.map +1 -1
  273. package/ts/cjs/poller.d.ts +9 -2
  274. package/ts/cjs/poller.d.ts.map +1 -1
  275. package/ts/cjs/poller.js +8 -3
  276. package/ts/cjs/poller.js.map +1 -1
  277. package/ts/cjs/promise-sleep.d.ts.map +1 -1
  278. package/ts/cjs/promise-sleep.js.map +1 -1
  279. package/ts/cjs/resolve-once.d.ts +31 -34
  280. package/ts/cjs/resolve-once.d.ts.map +1 -1
  281. package/ts/cjs/resolve-once.js +84 -43
  282. package/ts/cjs/resolve-once.js.map +1 -1
  283. package/ts/cjs/resolve-once.test.js +119 -31
  284. package/ts/cjs/resolve-once.test.js.map +1 -1
  285. package/ts/cjs/result.d.ts.map +1 -1
  286. package/ts/cjs/result.js.map +1 -1
  287. package/ts/cjs/runtime.d.ts.map +1 -1
  288. package/ts/cjs/runtime.js.map +1 -1
  289. package/ts/cjs/sys-env.d.ts.map +1 -1
  290. package/ts/cjs/sys-env.js.map +1 -1
  291. package/ts/cjs/timeouted.d.ts.map +1 -1
  292. package/ts/cjs/timeouted.js.map +1 -1
  293. package/ts/cjs/tracer.d.ts.map +1 -1
  294. package/ts/cjs/tracer.js.map +1 -1
  295. package/ts/cjs/txt-en-decoder.d.ts +1 -1
  296. package/ts/cjs/txt-en-decoder.d.ts.map +1 -1
  297. package/ts/cjs/txt-en-decoder.js +2 -5
  298. package/ts/cjs/txt-en-decoder.js.map +1 -1
  299. package/ts/cjs/uri.d.ts.map +1 -1
  300. package/ts/cjs/uri.js.map +1 -1
  301. package/ts/cjs/utils/coerce-uint8.d.ts.map +1 -1
  302. package/ts/cjs/utils/coerce-uint8.js.map +1 -1
  303. package/ts/cjs/utils/console-write-stream.d.ts.map +1 -1
  304. package/ts/cjs/utils/console-write-stream.js.map +1 -1
  305. package/ts/cjs/utils/consume.d.ts.map +1 -1
  306. package/ts/cjs/utils/consume.js.map +1 -1
  307. package/ts/cjs/utils/fanout-write-stream.d.ts.map +1 -1
  308. package/ts/cjs/utils/fanout-write-stream.js.map +1 -1
  309. package/ts/cjs/utils/get-params-result.d.ts.map +1 -1
  310. package/ts/cjs/utils/get-params-result.js.map +1 -1
  311. package/ts/cjs/utils/rebuffer.d.ts.map +1 -1
  312. package/ts/cjs/utils/rebuffer.js.map +1 -1
  313. package/ts/cjs/utils/relative-path.d.ts.map +1 -1
  314. package/ts/cjs/utils/relative-path.js.map +1 -1
  315. package/ts/cjs/utils/sorted-object.d.ts.map +1 -1
  316. package/ts/cjs/utils/sorted-object.js.map +1 -1
  317. package/ts/cjs/utils/stream-map.d.ts.map +1 -1
  318. package/ts/cjs/utils/stream-map.js.map +1 -1
  319. package/ts/cjs/utils/stream2string.d.ts.map +1 -1
  320. package/ts/cjs/utils/stream2string.js.map +1 -1
  321. package/ts/cjs/utils/string2stream.d.ts.map +1 -1
  322. package/ts/cjs/utils/string2stream.js.map +1 -1
  323. package/ts/cjs/utils/stripper.d.ts.map +1 -1
  324. package/ts/cjs/utils/stripper.js.map +1 -1
  325. package/ts/cjs/utils/to-sorted.d.ts.map +1 -1
  326. package/ts/cjs/utils/to-sorted.js.map +1 -1
  327. package/ts/cjs/utils/uint8array-equal.d.ts.map +1 -1
  328. package/ts/cjs/utils/uint8array-equal.js.map +1 -1
  329. package/ts/cjs/version.d.ts.map +1 -1
  330. package/ts/cjs/version.js +1 -1
  331. package/ts/cjs/version.js.map +1 -1
  332. package/ts/esm/app-context.d.ts.map +1 -1
  333. package/ts/esm/app-context.js.map +1 -1
  334. package/ts/esm/base-sys-abstraction.d.ts.map +1 -1
  335. package/ts/esm/base-sys-abstraction.js.map +1 -1
  336. package/ts/esm/bin2text.d.ts.map +1 -1
  337. package/ts/esm/bin2text.js.map +1 -1
  338. package/ts/esm/coerce-binary.d.ts.map +1 -1
  339. package/ts/esm/coerce-binary.js.map +1 -1
  340. package/ts/esm/crypto.d.ts.map +1 -1
  341. package/ts/esm/crypto.js.map +1 -1
  342. package/ts/esm/future.d.ts.map +1 -1
  343. package/ts/esm/future.js.map +1 -1
  344. package/ts/esm/http_header.d.ts.map +1 -1
  345. package/ts/esm/http_header.js.map +1 -1
  346. package/ts/esm/index.d.ts +1 -0
  347. package/ts/esm/index.d.ts.map +1 -1
  348. package/ts/esm/index.js +1 -0
  349. package/ts/esm/index.js.map +1 -1
  350. package/ts/esm/is-json.d.ts.map +1 -1
  351. package/ts/esm/is-json.js.map +1 -1
  352. package/ts/esm/is-promise.d.ts.map +1 -1
  353. package/ts/esm/is-promise.js.map +1 -1
  354. package/ts/esm/keyed-ng.d.ts +51 -0
  355. package/ts/esm/keyed-ng.d.ts.map +1 -0
  356. package/ts/esm/keyed-ng.js +89 -0
  357. package/ts/esm/keyed-ng.js.map +1 -0
  358. package/ts/esm/keyed-ng.test.d.ts +2 -0
  359. package/ts/esm/keyed-ng.test.d.ts.map +1 -0
  360. package/ts/esm/keyed-ng.test.js +149 -0
  361. package/ts/esm/keyed-ng.test.js.map +1 -0
  362. package/ts/esm/lru-map-set.d.ts +4 -1
  363. package/ts/esm/lru-map-set.d.ts.map +1 -1
  364. package/ts/esm/lru-map-set.js +2 -1
  365. package/ts/esm/lru-map-set.js.map +1 -1
  366. package/ts/esm/on-func.d.ts.map +1 -1
  367. package/ts/esm/on-func.js.map +1 -1
  368. package/ts/esm/option.d.ts.map +1 -1
  369. package/ts/esm/option.js.map +1 -1
  370. package/ts/esm/poller.d.ts +9 -2
  371. package/ts/esm/poller.d.ts.map +1 -1
  372. package/ts/esm/poller.js +8 -3
  373. package/ts/esm/poller.js.map +1 -1
  374. package/ts/esm/promise-sleep.d.ts.map +1 -1
  375. package/ts/esm/promise-sleep.js.map +1 -1
  376. package/ts/esm/resolve-once.d.ts +31 -34
  377. package/ts/esm/resolve-once.d.ts.map +1 -1
  378. package/ts/esm/resolve-once.js +83 -41
  379. package/ts/esm/resolve-once.js.map +1 -1
  380. package/ts/esm/resolve-once.test.js +119 -31
  381. package/ts/esm/resolve-once.test.js.map +1 -1
  382. package/ts/esm/result.d.ts.map +1 -1
  383. package/ts/esm/result.js.map +1 -1
  384. package/ts/esm/runtime.d.ts.map +1 -1
  385. package/ts/esm/runtime.js.map +1 -1
  386. package/ts/esm/sys-env.d.ts.map +1 -1
  387. package/ts/esm/sys-env.js.map +1 -1
  388. package/ts/esm/timeouted.d.ts.map +1 -1
  389. package/ts/esm/timeouted.js.map +1 -1
  390. package/ts/esm/tracer.d.ts.map +1 -1
  391. package/ts/esm/tracer.js.map +1 -1
  392. package/ts/esm/txt-en-decoder.d.ts +1 -1
  393. package/ts/esm/txt-en-decoder.d.ts.map +1 -1
  394. package/ts/esm/txt-en-decoder.js +2 -5
  395. package/ts/esm/txt-en-decoder.js.map +1 -1
  396. package/ts/esm/uri.d.ts.map +1 -1
  397. package/ts/esm/uri.js.map +1 -1
  398. package/ts/esm/utils/coerce-uint8.d.ts.map +1 -1
  399. package/ts/esm/utils/coerce-uint8.js.map +1 -1
  400. package/ts/esm/utils/console-write-stream.d.ts.map +1 -1
  401. package/ts/esm/utils/console-write-stream.js.map +1 -1
  402. package/ts/esm/utils/consume.d.ts.map +1 -1
  403. package/ts/esm/utils/consume.js.map +1 -1
  404. package/ts/esm/utils/fanout-write-stream.d.ts.map +1 -1
  405. package/ts/esm/utils/fanout-write-stream.js.map +1 -1
  406. package/ts/esm/utils/get-params-result.d.ts.map +1 -1
  407. package/ts/esm/utils/get-params-result.js.map +1 -1
  408. package/ts/esm/utils/rebuffer.d.ts.map +1 -1
  409. package/ts/esm/utils/rebuffer.js.map +1 -1
  410. package/ts/esm/utils/relative-path.d.ts.map +1 -1
  411. package/ts/esm/utils/relative-path.js.map +1 -1
  412. package/ts/esm/utils/sorted-object.d.ts.map +1 -1
  413. package/ts/esm/utils/sorted-object.js.map +1 -1
  414. package/ts/esm/utils/stream-map.d.ts.map +1 -1
  415. package/ts/esm/utils/stream-map.js.map +1 -1
  416. package/ts/esm/utils/stream2string.d.ts.map +1 -1
  417. package/ts/esm/utils/stream2string.js.map +1 -1
  418. package/ts/esm/utils/string2stream.d.ts.map +1 -1
  419. package/ts/esm/utils/string2stream.js.map +1 -1
  420. package/ts/esm/utils/stripper.d.ts.map +1 -1
  421. package/ts/esm/utils/stripper.js.map +1 -1
  422. package/ts/esm/utils/to-sorted.d.ts.map +1 -1
  423. package/ts/esm/utils/to-sorted.js.map +1 -1
  424. package/ts/esm/utils/uint8array-equal.d.ts.map +1 -1
  425. package/ts/esm/utils/uint8array-equal.js.map +1 -1
  426. package/ts/esm/version.d.ts.map +1 -1
  427. package/ts/esm/version.js +1 -1
  428. package/ts/esm/version.js.map +1 -1
@@ -17,6 +17,11 @@ import { CFBasicSysAbstraction } from "./cf/cf-basic-sys-abstraction.js";
17
17
  import { DenoBasicSysAbstraction } from "./deno/deno-basic-sys-abstraction.js";
18
18
  import { NodeBasicSysAbstraction } from "./node/node-basic-sys-abstraction.js";
19
19
 
20
+ /**
21
+ * Real-time implementation using system clock.
22
+ *
23
+ * Provides actual current time and real delays. Use for production code.
24
+ */
20
25
  export class SysTime extends Time {
21
26
  Now(): Date {
22
27
  return new Date();
@@ -30,6 +35,12 @@ export class SysTime extends Time {
30
35
  }
31
36
  }
32
37
 
38
+ /**
39
+ * Constant time implementation for deterministic testing.
40
+ *
41
+ * Always returns the same fixed date (2021-02-01). Sleep operations
42
+ * complete immediately without delay. Useful for reproducible tests.
43
+ */
33
44
  export class ConstTime extends Time {
34
45
  Now(): Date {
35
46
  return new Date(2021, 1, 1, 0, 0, 0, 0);
@@ -40,6 +51,12 @@ export class ConstTime extends Time {
40
51
  }
41
52
  }
42
53
 
54
+ /**
55
+ * Stepped time implementation for controlled testing.
56
+ *
57
+ * Advances time in 1-second increments on each Now() call. Sleep operations
58
+ * advance time without delay. Useful for testing time-dependent behavior.
59
+ */
43
60
  export class StepTime extends Time {
44
61
  _step: Date;
45
62
  readonly _start: Date;
@@ -68,6 +85,24 @@ export class StepTime extends Time {
68
85
  }
69
86
  }
70
87
 
88
+ /**
89
+ * Creates a Time implementation based on the specified mode.
90
+ *
91
+ * @param timeMode - Time behavior mode (REAL, CONST, or STEP)
92
+ * @returns Time implementation matching the mode
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * // Production: uses real system time
97
+ * const realTime = TimeFactory(TimeMode.REAL);
98
+ *
99
+ * // Testing: constant time
100
+ * const constTime = TimeFactory(TimeMode.CONST);
101
+ *
102
+ * // Testing: stepped time
103
+ * const stepTime = TimeFactory(TimeMode.STEP);
104
+ * ```
105
+ */
71
106
  export function TimeFactory(timeMode: TimeMode): Time {
72
107
  switch (timeMode) {
73
108
  case TimeMode.REAL:
@@ -80,12 +115,42 @@ export function TimeFactory(timeMode: TimeMode): Time {
80
115
  return new SysTime();
81
116
  }
82
117
 
118
+ /**
119
+ * Random number generator with deterministic modes for testing.
120
+ *
121
+ * Provides random number generation that can operate in different modes:
122
+ * - RANDOM: Uses Math.random() for real random values
123
+ * - CONST: Always returns a constant value (0.5 * max) for reproducible tests
124
+ * - STEP: Returns incrementing values for predictable test sequences
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Production: real randomness
129
+ * const random = new RandomService(RandomMode.RANDOM);
130
+ * const value = random.Random0ToValue(100); // 0-100
131
+ *
132
+ * // Testing: constant value
133
+ * const constRandom = new RandomService(RandomMode.CONST);
134
+ * const value = constRandom.Random0ToValue(100); // Always 50
135
+ *
136
+ * // Testing: stepped sequence
137
+ * const stepRandom = new RandomService(RandomMode.STEP);
138
+ * const v1 = stepRandom.Random0ToValue(100); // 0.01
139
+ * const v2 = stepRandom.Random0ToValue(100); // 0.02
140
+ * ```
141
+ */
83
142
  export class RandomService {
84
143
  readonly _mode: RandomMode;
85
144
  _step = 0;
86
145
  constructor(mode: RandomMode) {
87
146
  this._mode = mode;
88
147
  }
148
+ /**
149
+ * Generates a random number between 0 and the specified value.
150
+ *
151
+ * @param value - Maximum value (exclusive upper bound)
152
+ * @returns Random number in range [0, value)
153
+ */
89
154
  Random0ToValue(value: number): number {
90
155
  switch (this._mode) {
91
156
  case RandomMode.CONST:
@@ -101,6 +166,31 @@ export class RandomService {
101
166
  }
102
167
  }
103
168
 
169
+ /**
170
+ * ID generator with deterministic modes for testing.
171
+ *
172
+ * Generates unique identifiers with support for different modes:
173
+ * - UUID: Uses crypto.randomUUID() for real UUIDs (default)
174
+ * - CONST: Always returns the same constant ID for reproducible tests
175
+ * - STEP: Returns incrementing IDs (STEPId-0, STEPId-1, etc.) for predictable sequences
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * // Production: real UUIDs
180
+ * const idService = new IdService(IDMode.UUID);
181
+ * const id = idService.NextId(); // "550e8400-e29b-41d4-a716-446655440000"
182
+ *
183
+ * // Testing: constant ID
184
+ * const constId = new IdService(IDMode.CONST);
185
+ * const id1 = constId.NextId(); // "VeryUniqueID"
186
+ * const id2 = constId.NextId(); // "VeryUniqueID"
187
+ *
188
+ * // Testing: stepped sequence
189
+ * const stepId = new IdService(IDMode.STEP);
190
+ * const id1 = stepId.NextId(); // "STEPId-0"
191
+ * const id2 = stepId.NextId(); // "STEPId-1"
192
+ * ```
193
+ */
104
194
  export class IdService {
105
195
  readonly _mode: IDMode;
106
196
  _step = 0;
@@ -110,6 +200,11 @@ export class IdService {
110
200
  }
111
201
  this._mode = mode;
112
202
  }
203
+ /**
204
+ * Generates the next unique identifier.
205
+ *
206
+ * @returns Unique ID string based on the configured mode
207
+ */
113
208
  NextId(): string {
114
209
  switch (this._mode) {
115
210
  case IDMode.UUID:
@@ -145,6 +240,29 @@ export interface ExitService {
145
240
 
146
241
  // some black magic to make it work with CF workers
147
242
 
243
+ /**
244
+ * Base system abstraction for platform-independent services.
245
+ *
246
+ * Provides core services that work across all JavaScript runtimes:
247
+ * - Time: Real system time implementation
248
+ * - ID Generation: UUID-based unique identifiers
249
+ * - Random Numbers: Math.random()-based generation
250
+ * - Text Encoding/Decoding: UTF-8 conversion utilities
251
+ *
252
+ * This is the foundation for both basic and full system abstractions,
253
+ * containing services that don't require filesystem or system access.
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * const base = new BaseBasicSysAbstraction({
258
+ * TxtEnDecoder: new TxtEnDecoder()
259
+ * });
260
+ *
261
+ * const now = base._time.Now();
262
+ * const id = base._idService.NextId();
263
+ * const random = base._randomService.Random0ToValue(100);
264
+ * ```
265
+ */
148
266
  export class BaseBasicSysAbstraction {
149
267
  readonly _time: SysTime = new SysTime();
150
268
 
@@ -158,6 +276,31 @@ export class BaseBasicSysAbstraction {
158
276
  }
159
277
  }
160
278
 
279
+ /**
280
+ * Full system abstraction with filesystem and system service access.
281
+ *
282
+ * Extends BaseBasicSysAbstraction with platform-specific services:
283
+ * - FileSystem: File I/O operations
284
+ * - SystemService: Process, environment, and system-level operations
285
+ *
286
+ * Used in Node.js and Deno environments where full system access is available.
287
+ * Not suitable for browser or Cloudflare Workers environments.
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * const sys = new BaseSysAbstraction({
292
+ * TxtEnDecoder: new TxtEnDecoder(),
293
+ * FileSystem: new NodeFileService(),
294
+ * SystemService: new NodeSystemService()
295
+ * });
296
+ *
297
+ * // Access filesystem
298
+ * const content = await sys._fileSystem.readFile('/path/to/file');
299
+ *
300
+ * // Access environment
301
+ * const env = sys._systemService.getEnv();
302
+ * ```
303
+ */
161
304
  export class BaseSysAbstraction extends BaseBasicSysAbstraction {
162
305
  // system related services
163
306
  readonly _fileSystem: FileService;
@@ -182,6 +325,36 @@ export interface BasicSysAbstractionParams {
182
325
 
183
326
  export type WrapperBasicSysAbstractionParams = Partial<BasicRuntimeService & BasicSysAbstractionParams>;
184
327
 
328
+ /**
329
+ * Creates a BasicSysAbstraction instance for the current runtime environment.
330
+ *
331
+ * Automatically detects the JavaScript runtime (Browser, Node.js, Deno, or
332
+ * Cloudflare Workers) and returns the appropriate system abstraction implementation.
333
+ * Supports optional configuration for time, ID, and random number generation modes,
334
+ * useful for testing with deterministic behavior.
335
+ *
336
+ * @param params - Optional configuration for time, ID, and random modes
337
+ * @returns BasicSysAbstraction instance for the current runtime
338
+ * @throws Error if the runtime cannot be detected
339
+ *
340
+ * @example
341
+ * ```typescript
342
+ * // Production: auto-detect runtime with defaults
343
+ * const sys = BasicSysAbstractionFactory();
344
+ * const now = sys.Time().Now();
345
+ * const id = sys.NextId();
346
+ *
347
+ * // Testing: deterministic behavior
348
+ * const testSys = BasicSysAbstractionFactory({
349
+ * TimeMode: TimeMode.CONST,
350
+ * IdMode: IDMode.STEP,
351
+ * RandomMode: RandomMode.CONST
352
+ * });
353
+ * const constTime = testSys.Time().Now(); // Always 2021-02-01
354
+ * const id1 = testSys.NextId(); // "STEPId-0"
355
+ * const id2 = testSys.NextId(); // "STEPId-1"
356
+ * ```
357
+ */
185
358
  export function BasicSysAbstractionFactory(params?: WrapperBasicSysAbstractionParams): BasicSysAbstraction {
186
359
  const fn = runtimeFn();
187
360
  switch (true) {
@@ -198,6 +371,44 @@ export function BasicSysAbstractionFactory(params?: WrapperBasicSysAbstractionPa
198
371
  }
199
372
  }
200
373
 
374
+ /**
375
+ * BasicSysAbstraction implementation with configurable service modes.
376
+ *
377
+ * Wraps a base system abstraction and allows overriding time, ID, and random
378
+ * number generation modes. This is the primary implementation returned by
379
+ * BasicSysAbstractionFactory and provides the unified interface for all
380
+ * platform-independent system services.
381
+ *
382
+ * Delegates runtime-specific operations (Stdout, Stderr, Env, Args) to the
383
+ * underlying runtime service while providing configurable implementations for
384
+ * testable services (Time, ID, Random).
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * // Created via factory
389
+ * const sys = BasicSysAbstractionFactory({
390
+ * TimeMode: TimeMode.STEP,
391
+ * IdMode: IDMode.UUID,
392
+ * RandomMode: RandomMode.RANDOM
393
+ * });
394
+ *
395
+ * // Use time service
396
+ * const time = sys.Time();
397
+ * const now = time.Now();
398
+ * await time.Sleep(1000);
399
+ *
400
+ * // Use ID service
401
+ * const id = sys.NextId();
402
+ *
403
+ * // Use random service
404
+ * const random = sys.Random0ToValue(100);
405
+ *
406
+ * // Access runtime services
407
+ * const stdout = sys.Stdout();
408
+ * const env = sys.Env();
409
+ * const args = sys.Args();
410
+ * ```
411
+ */
201
412
  export class WrapperBasicSysAbstraction implements BasicSysAbstraction {
202
413
  readonly _time: Time;
203
414
  readonly _idService: IdService;
@@ -253,6 +464,39 @@ export class WrapperBasicSysAbstraction implements BasicSysAbstraction {
253
464
  }
254
465
  // export const BaseSysAbstraction = new BaseSysAbstractionImpl()
255
466
 
467
+ /**
468
+ * Full system abstraction with filesystem and system service access.
469
+ *
470
+ * Extends WrapperBasicSysAbstraction with filesystem and system services,
471
+ * providing the complete system abstraction interface. Used in environments
472
+ * with full system access (Node.js, Deno) where filesystem operations,
473
+ * process management, and environment access are available.
474
+ *
475
+ * Inherits all configurable services from WrapperBasicSysAbstraction (Time,
476
+ * ID, Random) and adds FileSystem and SystemService access.
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * // Created via runtime-specific factory
481
+ * const sys = NodeSysAbstraction({
482
+ * TimeMode: TimeMode.REAL,
483
+ * IdMode: IDMode.UUID
484
+ * });
485
+ *
486
+ * // Use basic services
487
+ * const time = sys.Time();
488
+ * const id = sys.NextId();
489
+ *
490
+ * // Use filesystem
491
+ * const fs = sys.FileSystem();
492
+ * const content = await fs.readFile('/path/to/file');
493
+ *
494
+ * // Use system services
495
+ * const system = sys.System();
496
+ * const env = system.getEnv();
497
+ * system.exit(0);
498
+ * ```
499
+ */
256
500
  export class WrapperRuntimeSysAbstraction extends WrapperBasicSysAbstraction {
257
501
  readonly _systemService: SystemService;
258
502
  readonly _fileSystem: FileService;
package/src/bin2text.ts CHANGED
@@ -1,3 +1,22 @@
1
+ /**
2
+ * Formats binary data as hexdump output with ASCII representation.
3
+ *
4
+ * Produces hexdump-style output similar to `xxd` or `hexdump` commands,
5
+ * showing hex values and ASCII characters side-by-side. Each line shows
6
+ * 16 bytes with offset, hex values, and printable ASCII characters.
7
+ *
8
+ * @param hex - Binary data to format (any ArrayBufferView)
9
+ * @param lineFn - Callback function invoked for each formatted line
10
+ * @param size - Maximum number of bytes to format (0 = all bytes)
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const data = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);
15
+ * bin2text(data, (line) => console.log(line));
16
+ * // Output:
17
+ * // 0000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
18
+ * ```
19
+ */
1
20
  export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size = 0): void {
2
21
  const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
3
22
  let cutted = " ";
@@ -34,6 +53,24 @@ export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, s
34
53
  }
35
54
  }
36
55
 
56
+ /**
57
+ * Formats binary data as a hexdump string.
58
+ *
59
+ * Convenience wrapper around bin2text that returns a single string with
60
+ * newline-separated hexdump lines. Useful for logging or display purposes.
61
+ *
62
+ * @param hex - Binary data to format (any ArrayBufferView)
63
+ * @param size - Maximum number of bytes to format (0 = all bytes)
64
+ * @returns Formatted hexdump as a string
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const data = new Uint8Array([72, 101, 108, 108, 111]);
69
+ * const dump = bin2string(data);
70
+ * console.log(dump);
71
+ * // 0000 48 65 6c 6c 6f Hello
72
+ * ```
73
+ */
37
74
  export function bin2string(hex: ArrayBufferView, size = 0): string {
38
75
  const collector: string[] = [];
39
76
  bin2text(
@@ -2,14 +2,32 @@ import { TxtEnDecoderSingleton } from "./txt-en-decoder.js";
2
2
 
3
3
  export type CoerceBinaryInput = string | ArrayBufferLike | ArrayBufferView | Uint8Array; // | SharedArrayBuffer
4
4
 
5
+ /**
6
+ * Type guard to check if a value is an ArrayBuffer.
7
+ *
8
+ * @param value - The value to check
9
+ * @returns True if the value is an ArrayBuffer
10
+ */
5
11
  export function isArrayBuffer(value: unknown): value is ArrayBuffer {
6
12
  return value instanceof ArrayBuffer || Object.prototype.toString.call(value) === "[object ArrayBuffer]";
7
13
  }
8
14
 
15
+ /**
16
+ * Type guard to check if a value is a Uint8Array.
17
+ *
18
+ * @param value - The value to check
19
+ * @returns True if the value is a Uint8Array
20
+ */
9
21
  export function isUint8Array(value: unknown): value is Uint8Array {
10
22
  return value instanceof Uint8Array || Object.prototype.toString.call(value) === "[object Uint8Array]";
11
23
  }
12
24
 
25
+ /**
26
+ * Converts various binary input types (including Blob) to Uint8Array asynchronously.
27
+ *
28
+ * @param input - String, ArrayBuffer, ArrayBufferView, Uint8Array, or Blob to convert
29
+ * @returns Promise resolving to Uint8Array
30
+ */
13
31
  export async function top_uint8(input: CoerceBinaryInput | Blob): Promise<Uint8Array> {
14
32
  if (input instanceof Blob) {
15
33
  return new Uint8Array(await input.arrayBuffer());
@@ -17,6 +35,15 @@ export async function top_uint8(input: CoerceBinaryInput | Blob): Promise<Uint8A
17
35
  return to_uint8(input);
18
36
  }
19
37
 
38
+ /**
39
+ * Converts various binary input types to Uint8Array synchronously.
40
+ *
41
+ * Handles strings (encoding with TextEncoder), ArrayBuffers, and ArrayBufferViews.
42
+ *
43
+ * @param input - String, ArrayBuffer, ArrayBufferView, or Uint8Array to convert
44
+ * @param encoder - Optional TextEncoder instance (uses singleton if not provided)
45
+ * @returns Uint8Array representation of the input
46
+ */
20
47
  export function to_uint8(input: CoerceBinaryInput, encoder?: TextEncoder): Uint8Array {
21
48
  if (typeof input === "string") {
22
49
  return (encoder ?? TxtEnDecoderSingleton()).encode(input);
@@ -32,6 +59,13 @@ export function to_uint8(input: CoerceBinaryInput, encoder?: TextEncoder): Uint8
32
59
  return new Uint8Array(input as unknown as ArrayBufferLike);
33
60
  }
34
61
 
62
+ /**
63
+ * Converts various binary input types to Blob.
64
+ *
65
+ * @param input - String, ArrayBuffer, ArrayBufferView, Uint8Array, or Blob to convert
66
+ * @param encoder - Optional TextEncoder instance (uses singleton if not provided)
67
+ * @returns Blob representation of the input
68
+ */
35
69
  export function to_blob(input: CoerceBinaryInput | Blob, encoder?: TextEncoder): Blob {
36
70
  if (input instanceof Blob) {
37
71
  return input;
@@ -40,6 +74,13 @@ export function to_blob(input: CoerceBinaryInput | Blob, encoder?: TextEncoder):
40
74
  return new Blob([ab]);
41
75
  }
42
76
 
77
+ /**
78
+ * Converts various binary input types to ArrayBuffer.
79
+ *
80
+ * @param input - String, ArrayBuffer, ArrayBufferView, or Uint8Array to convert
81
+ * @param encoder - Optional TextEncoder instance (uses singleton if not provided)
82
+ * @returns ArrayBuffer representation of the input
83
+ */
43
84
  export function to_arraybuf(input: CoerceBinaryInput, encoder?: TextEncoder): ArrayBuffer {
44
85
  if (input instanceof ArrayBuffer) {
45
86
  return input;
package/src/crypto.ts CHANGED
@@ -123,6 +123,41 @@ function digestSHA256(crypto: typeof globalThis.crypto): (data: Uint8Array) => P
123
123
  };
124
124
  }
125
125
 
126
+ /**
127
+ * Creates a CryptoRuntime abstraction with optional custom implementations.
128
+ *
129
+ * Provides a unified crypto interface that works across different JavaScript
130
+ * runtimes (browsers, Node.js, Deno, CF Workers). Automatically uses the global
131
+ * Web Crypto API when available, with fallback implementations that throw errors
132
+ * for unavailable operations. Allows overriding any method for testing or
133
+ * custom implementations.
134
+ *
135
+ * @param cryptoOpts - Optional custom implementations for crypto operations
136
+ * @returns CryptoRuntime instance with crypto operations
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * // Use default global crypto
141
+ * const crypto = toCryptoRuntime();
142
+ * const hash = await crypto.digestSHA256(new Uint8Array([1, 2, 3]));
143
+ * const randomData = crypto.randomBytes(16);
144
+ *
145
+ * // Override for testing
146
+ * const mockCrypto = toCryptoRuntime({
147
+ * randomBytes: (size) => new Uint8Array(size).fill(42),
148
+ * digestSHA256: async (data) => new ArrayBuffer(32)
149
+ * });
150
+ *
151
+ * // Encrypt/decrypt with AES-GCM
152
+ * const key = await crypto.importKey(
153
+ * 'raw',
154
+ * new Uint8Array(32),
155
+ * { name: 'AES-GCM' },
156
+ * false,
157
+ * ['encrypt', 'decrypt']
158
+ * );
159
+ * ```
160
+ */
126
161
  export function toCryptoRuntime(cryptoOpts: Partial<CryptoRuntime> = {}): CryptoRuntime {
127
162
  let crypto: typeof globalThis.crypto;
128
163
  if (!globalThis.crypto || !globalThis.crypto.subtle) {
package/src/future.ts CHANGED
@@ -1,5 +1,30 @@
1
1
  import { Lazy } from "./resolve-once.js";
2
2
 
3
+ /**
4
+ * A Promise that can be resolved or rejected externally after creation.
5
+ *
6
+ * Future provides a way to create a Promise whose resolution is controlled
7
+ * externally rather than in the executor function. This is useful for
8
+ * coordinating async operations, implementing custom async primitives,
9
+ * or bridging callback-based APIs to promises.
10
+ *
11
+ * @template T - The type of the resolved value
12
+ * @template CTX - Optional context type for additional data
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const future = new Future<string>();
17
+ *
18
+ * // Later, resolve it from anywhere
19
+ * future.resolve('hello');
20
+ *
21
+ * // Or reject it
22
+ * future.reject(new Error('failed'));
23
+ *
24
+ * // Use it like a promise
25
+ * const result = await future.asPromise();
26
+ * ```
27
+ */
3
28
  export class Future<T, CTX = void> {
4
29
  // readonly id = Math.random();
5
30
  readonly #promise: Promise<T>;
@@ -19,16 +44,35 @@ export class Future<T, CTX = void> {
19
44
  });
20
45
  }
21
46
 
22
- // the id is not cryptographically secure, but good enough for transaction id
47
+ /**
48
+ * Lazily-generated unique identifier for this Future.
49
+ * Not cryptographically secure, but suitable for transaction/debug tracking.
50
+ */
23
51
  readonly id: () => string = Lazy(() => Math.random().toString(36).substring(2) + Date.now().toString(36));
24
52
 
53
+ /**
54
+ * Returns the underlying Promise that will be resolved or rejected.
55
+ *
56
+ * @returns The Promise representation of this Future
57
+ */
25
58
  asPromise(): Promise<T> {
26
59
  return this.#promise;
27
60
  }
28
61
 
62
+ /**
63
+ * Resolves the Future with the given value.
64
+ *
65
+ * @param value - The value to resolve the Promise with
66
+ */
29
67
  resolve(value: T): void {
30
68
  this.#resolveFn(value);
31
69
  }
70
+
71
+ /**
72
+ * Rejects the Future with the given reason.
73
+ *
74
+ * @param reason - The reason for rejection (typically an Error)
75
+ */
32
76
  reject(reason: unknown): void {
33
77
  this.#rejectFn(reason);
34
78
  }