@adviser/cement 0.4.61 → 0.4.63

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 (448) 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/lru-map-set.cjs.map +1 -1
  24. package/cjs/lru-map-set.d.ts.map +1 -1
  25. package/cjs/on-func.cjs.map +1 -1
  26. package/cjs/on-func.d.ts.map +1 -1
  27. package/cjs/on-func.test.cjs +1 -1
  28. package/cjs/on-func.test.cjs.map +1 -1
  29. package/cjs/option.cjs.map +1 -1
  30. package/cjs/option.d.ts.map +1 -1
  31. package/cjs/poller.cjs +9 -4
  32. package/cjs/poller.cjs.map +1 -1
  33. package/cjs/poller.d.ts +9 -2
  34. package/cjs/poller.d.ts.map +1 -1
  35. package/cjs/poller.test.cjs +1 -1
  36. package/cjs/poller.test.cjs.map +1 -1
  37. package/cjs/{utils/promise-sleep.cjs → promise-sleep.cjs} +1 -1
  38. package/cjs/promise-sleep.cjs.map +1 -0
  39. package/cjs/promise-sleep.d.ts.map +1 -0
  40. package/cjs/promise-sleep.test.cjs.map +1 -0
  41. package/cjs/promise-sleep.test.d.ts.map +1 -0
  42. package/cjs/resolve-once.cjs +84 -6
  43. package/cjs/resolve-once.cjs.map +1 -1
  44. package/cjs/resolve-once.d.ts +36 -3
  45. package/cjs/resolve-once.d.ts.map +1 -1
  46. package/cjs/result.cjs.map +1 -1
  47. package/cjs/result.d.ts.map +1 -1
  48. package/cjs/runtime.cjs.map +1 -1
  49. package/cjs/runtime.d.ts.map +1 -1
  50. package/cjs/sys-env.cjs.map +1 -1
  51. package/cjs/sys-env.d.ts.map +1 -1
  52. package/cjs/timeouted.cjs +1 -1
  53. package/cjs/timeouted.cjs.map +1 -1
  54. package/cjs/timeouted.d.ts.map +1 -1
  55. package/cjs/tracer.cjs.map +1 -1
  56. package/cjs/tracer.d.ts.map +1 -1
  57. package/cjs/txt-en-decoder.cjs +2 -5
  58. package/cjs/txt-en-decoder.cjs.map +1 -1
  59. package/cjs/txt-en-decoder.d.ts +1 -1
  60. package/cjs/txt-en-decoder.d.ts.map +1 -1
  61. package/cjs/uri.cjs.map +1 -1
  62. package/cjs/uri.d.ts.map +1 -1
  63. package/cjs/utils/coerce-uint8.cjs.map +1 -1
  64. package/cjs/utils/coerce-uint8.d.ts.map +1 -1
  65. package/cjs/utils/console-write-stream.cjs.map +1 -1
  66. package/cjs/utils/console-write-stream.d.ts.map +1 -1
  67. package/cjs/utils/consume.cjs.map +1 -1
  68. package/cjs/utils/consume.d.ts.map +1 -1
  69. package/cjs/utils/fanout-write-stream.cjs.map +1 -1
  70. package/cjs/utils/fanout-write-stream.d.ts.map +1 -1
  71. package/cjs/utils/get-params-result.cjs.map +1 -1
  72. package/cjs/utils/get-params-result.d.ts.map +1 -1
  73. package/cjs/utils/index.cjs +0 -1
  74. package/cjs/utils/index.cjs.map +1 -1
  75. package/cjs/utils/index.d.ts +0 -1
  76. package/cjs/utils/index.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/deno.json +1 -1
  97. package/esm/app-context.d.ts.map +1 -1
  98. package/esm/app-context.js.map +1 -1
  99. package/esm/base-sys-abstraction.d.ts.map +1 -1
  100. package/esm/base-sys-abstraction.js.map +1 -1
  101. package/esm/bin2text.d.ts.map +1 -1
  102. package/esm/bin2text.js.map +1 -1
  103. package/esm/coerce-binary.d.ts.map +1 -1
  104. package/esm/coerce-binary.js.map +1 -1
  105. package/esm/crypto.d.ts.map +1 -1
  106. package/esm/crypto.js.map +1 -1
  107. package/esm/future.d.ts.map +1 -1
  108. package/esm/future.js.map +1 -1
  109. package/esm/http_header.d.ts.map +1 -1
  110. package/esm/http_header.js.map +1 -1
  111. package/esm/index.d.ts +1 -0
  112. package/esm/index.d.ts.map +1 -1
  113. package/esm/index.js +1 -0
  114. package/esm/index.js.map +1 -1
  115. package/esm/is-json.d.ts.map +1 -1
  116. package/esm/is-json.js.map +1 -1
  117. package/esm/is-promise.d.ts.map +1 -1
  118. package/esm/is-promise.js.map +1 -1
  119. package/esm/lru-map-set.d.ts.map +1 -1
  120. package/esm/lru-map-set.js.map +1 -1
  121. package/esm/on-func.d.ts.map +1 -1
  122. package/esm/on-func.js.map +1 -1
  123. package/esm/on-func.test.js +1 -1
  124. package/esm/on-func.test.js.map +1 -1
  125. package/esm/option.d.ts.map +1 -1
  126. package/esm/option.js.map +1 -1
  127. package/esm/poller.d.ts +9 -2
  128. package/esm/poller.d.ts.map +1 -1
  129. package/esm/poller.js +9 -4
  130. package/esm/poller.js.map +1 -1
  131. package/esm/poller.test.js +1 -1
  132. package/esm/poller.test.js.map +1 -1
  133. package/esm/promise-sleep.d.ts.map +1 -0
  134. package/{ts/esm/utils → esm}/promise-sleep.js +1 -1
  135. package/esm/promise-sleep.js.map +1 -0
  136. package/esm/promise-sleep.test.d.ts.map +1 -0
  137. package/esm/promise-sleep.test.js.map +1 -0
  138. package/esm/resolve-once.d.ts +36 -3
  139. package/esm/resolve-once.d.ts.map +1 -1
  140. package/esm/resolve-once.js +84 -6
  141. package/esm/resolve-once.js.map +1 -1
  142. package/esm/result.d.ts.map +1 -1
  143. package/esm/result.js.map +1 -1
  144. package/esm/runtime.d.ts.map +1 -1
  145. package/esm/runtime.js.map +1 -1
  146. package/esm/sys-env.d.ts.map +1 -1
  147. package/esm/sys-env.js.map +1 -1
  148. package/esm/timeouted.d.ts.map +1 -1
  149. package/esm/timeouted.js +1 -1
  150. package/esm/timeouted.js.map +1 -1
  151. package/esm/tracer.d.ts.map +1 -1
  152. package/esm/tracer.js.map +1 -1
  153. package/esm/txt-en-decoder.d.ts +1 -1
  154. package/esm/txt-en-decoder.d.ts.map +1 -1
  155. package/esm/txt-en-decoder.js +2 -5
  156. package/esm/txt-en-decoder.js.map +1 -1
  157. package/esm/uri.d.ts.map +1 -1
  158. package/esm/uri.js.map +1 -1
  159. package/esm/utils/coerce-uint8.d.ts.map +1 -1
  160. package/esm/utils/coerce-uint8.js.map +1 -1
  161. package/esm/utils/console-write-stream.d.ts.map +1 -1
  162. package/esm/utils/console-write-stream.js.map +1 -1
  163. package/esm/utils/consume.d.ts.map +1 -1
  164. package/esm/utils/consume.js.map +1 -1
  165. package/esm/utils/fanout-write-stream.d.ts.map +1 -1
  166. package/esm/utils/fanout-write-stream.js.map +1 -1
  167. package/esm/utils/get-params-result.d.ts.map +1 -1
  168. package/esm/utils/get-params-result.js.map +1 -1
  169. package/esm/utils/index.d.ts +0 -1
  170. package/esm/utils/index.d.ts.map +1 -1
  171. package/esm/utils/index.js +0 -1
  172. package/esm/utils/index.js.map +1 -1
  173. package/esm/utils/rebuffer.d.ts.map +1 -1
  174. package/esm/utils/rebuffer.js.map +1 -1
  175. package/esm/utils/relative-path.d.ts.map +1 -1
  176. package/esm/utils/relative-path.js.map +1 -1
  177. package/esm/utils/sorted-object.d.ts.map +1 -1
  178. package/esm/utils/sorted-object.js.map +1 -1
  179. package/esm/utils/stream-map.d.ts.map +1 -1
  180. package/esm/utils/stream-map.js.map +1 -1
  181. package/esm/utils/stream2string.d.ts.map +1 -1
  182. package/esm/utils/stream2string.js.map +1 -1
  183. package/esm/utils/string2stream.d.ts.map +1 -1
  184. package/esm/utils/string2stream.js.map +1 -1
  185. package/esm/utils/stripper.d.ts.map +1 -1
  186. package/esm/utils/stripper.js.map +1 -1
  187. package/esm/utils/to-sorted.d.ts.map +1 -1
  188. package/esm/utils/to-sorted.js.map +1 -1
  189. package/esm/utils/uint8array-equal.d.ts.map +1 -1
  190. package/esm/utils/uint8array-equal.js.map +1 -1
  191. package/esm/version.js +1 -1
  192. package/package.json +5 -2
  193. package/src/app-context.ts +111 -5
  194. package/src/base-sys-abstraction.ts +244 -0
  195. package/src/bin2text.ts +37 -0
  196. package/src/coerce-binary.ts +41 -0
  197. package/src/crypto.ts +35 -0
  198. package/src/future.ts +45 -1
  199. package/src/http_header.ts +277 -1
  200. package/src/index.ts +2 -4
  201. package/src/is-json.ts +21 -0
  202. package/src/is-promise.ts +26 -0
  203. package/src/lru-map-set.ts +46 -0
  204. package/src/on-func.ts +38 -0
  205. package/src/option.ts +27 -0
  206. package/src/poller.ts +66 -18
  207. package/src/{utils/promise-sleep.ts → promise-sleep.ts} +33 -5
  208. package/src/resolve-once.ts +588 -42
  209. package/src/result.ts +50 -0
  210. package/src/runtime.ts +75 -2
  211. package/src/sys-env.ts +57 -0
  212. package/src/timeouted.ts +93 -1
  213. package/src/tracer.ts +41 -0
  214. package/src/txt-en-decoder.ts +2 -5
  215. package/src/uri.ts +76 -4
  216. package/src/utils/coerce-uint8.ts +60 -0
  217. package/src/utils/console-write-stream.ts +34 -0
  218. package/src/utils/consume.ts +106 -0
  219. package/src/utils/fanout-write-stream.ts +45 -0
  220. package/src/utils/get-params-result.ts +37 -0
  221. package/src/utils/index.ts +0 -1
  222. package/src/utils/rebuffer.ts +42 -0
  223. package/src/utils/relative-path.ts +108 -0
  224. package/src/utils/sorted-object.ts +50 -0
  225. package/src/utils/stream-map.ts +90 -0
  226. package/src/utils/stream2string.ts +35 -0
  227. package/src/utils/string2stream.ts +30 -0
  228. package/src/utils/stripper.ts +34 -0
  229. package/src/utils/to-sorted.ts +34 -0
  230. package/src/utils/uint8array-equal.ts +20 -0
  231. package/ts/cjs/app-context.d.ts.map +1 -1
  232. package/ts/cjs/app-context.js.map +1 -1
  233. package/ts/cjs/base-sys-abstraction.d.ts.map +1 -1
  234. package/ts/cjs/base-sys-abstraction.js.map +1 -1
  235. package/ts/cjs/bin2text.d.ts.map +1 -1
  236. package/ts/cjs/bin2text.js.map +1 -1
  237. package/ts/cjs/coerce-binary.d.ts.map +1 -1
  238. package/ts/cjs/coerce-binary.js.map +1 -1
  239. package/ts/cjs/crypto.d.ts.map +1 -1
  240. package/ts/cjs/crypto.js.map +1 -1
  241. package/ts/cjs/future.d.ts.map +1 -1
  242. package/ts/cjs/future.js.map +1 -1
  243. package/ts/cjs/http_header.d.ts.map +1 -1
  244. package/ts/cjs/http_header.js.map +1 -1
  245. package/ts/cjs/index.d.ts +1 -0
  246. package/ts/cjs/index.d.ts.map +1 -1
  247. package/ts/cjs/index.js +1 -0
  248. package/ts/cjs/index.js.map +1 -1
  249. package/ts/cjs/is-json.d.ts.map +1 -1
  250. package/ts/cjs/is-json.js.map +1 -1
  251. package/ts/cjs/is-promise.d.ts.map +1 -1
  252. package/ts/cjs/is-promise.js.map +1 -1
  253. package/ts/cjs/lru-map-set.d.ts.map +1 -1
  254. package/ts/cjs/lru-map-set.js.map +1 -1
  255. package/ts/cjs/on-func.d.ts.map +1 -1
  256. package/ts/cjs/on-func.js.map +1 -1
  257. package/ts/cjs/on-func.test.js +1 -1
  258. package/ts/cjs/on-func.test.js.map +1 -1
  259. package/ts/cjs/option.d.ts.map +1 -1
  260. package/ts/cjs/option.js.map +1 -1
  261. package/ts/cjs/poller.d.ts +9 -2
  262. package/ts/cjs/poller.d.ts.map +1 -1
  263. package/ts/cjs/poller.js +9 -4
  264. package/ts/cjs/poller.js.map +1 -1
  265. package/ts/cjs/poller.test.js +1 -1
  266. package/ts/cjs/poller.test.js.map +1 -1
  267. package/ts/cjs/promise-sleep.d.ts.map +1 -0
  268. package/ts/cjs/{utils/promise-sleep.js → promise-sleep.js} +1 -1
  269. package/ts/cjs/promise-sleep.js.map +1 -0
  270. package/ts/cjs/promise-sleep.test.d.ts.map +1 -0
  271. package/ts/cjs/promise-sleep.test.js.map +1 -0
  272. package/ts/cjs/resolve-once.d.ts +36 -3
  273. package/ts/cjs/resolve-once.d.ts.map +1 -1
  274. package/ts/cjs/resolve-once.js +84 -6
  275. package/ts/cjs/resolve-once.js.map +1 -1
  276. package/ts/cjs/result.d.ts.map +1 -1
  277. package/ts/cjs/result.js.map +1 -1
  278. package/ts/cjs/runtime.d.ts.map +1 -1
  279. package/ts/cjs/runtime.js.map +1 -1
  280. package/ts/cjs/sys-env.d.ts.map +1 -1
  281. package/ts/cjs/sys-env.js.map +1 -1
  282. package/ts/cjs/timeouted.d.ts.map +1 -1
  283. package/ts/cjs/timeouted.js +1 -1
  284. package/ts/cjs/timeouted.js.map +1 -1
  285. package/ts/cjs/tracer.d.ts.map +1 -1
  286. package/ts/cjs/tracer.js.map +1 -1
  287. package/ts/cjs/txt-en-decoder.d.ts +1 -1
  288. package/ts/cjs/txt-en-decoder.d.ts.map +1 -1
  289. package/ts/cjs/txt-en-decoder.js +2 -5
  290. package/ts/cjs/txt-en-decoder.js.map +1 -1
  291. package/ts/cjs/uri.d.ts.map +1 -1
  292. package/ts/cjs/uri.js.map +1 -1
  293. package/ts/cjs/utils/coerce-uint8.d.ts.map +1 -1
  294. package/ts/cjs/utils/coerce-uint8.js.map +1 -1
  295. package/ts/cjs/utils/console-write-stream.d.ts.map +1 -1
  296. package/ts/cjs/utils/console-write-stream.js.map +1 -1
  297. package/ts/cjs/utils/consume.d.ts.map +1 -1
  298. package/ts/cjs/utils/consume.js.map +1 -1
  299. package/ts/cjs/utils/fanout-write-stream.d.ts.map +1 -1
  300. package/ts/cjs/utils/fanout-write-stream.js.map +1 -1
  301. package/ts/cjs/utils/get-params-result.d.ts.map +1 -1
  302. package/ts/cjs/utils/get-params-result.js.map +1 -1
  303. package/ts/cjs/utils/index.d.ts +0 -1
  304. package/ts/cjs/utils/index.d.ts.map +1 -1
  305. package/ts/cjs/utils/index.js +0 -1
  306. package/ts/cjs/utils/index.js.map +1 -1
  307. package/ts/cjs/utils/rebuffer.d.ts.map +1 -1
  308. package/ts/cjs/utils/rebuffer.js.map +1 -1
  309. package/ts/cjs/utils/relative-path.d.ts.map +1 -1
  310. package/ts/cjs/utils/relative-path.js.map +1 -1
  311. package/ts/cjs/utils/sorted-object.d.ts.map +1 -1
  312. package/ts/cjs/utils/sorted-object.js.map +1 -1
  313. package/ts/cjs/utils/stream-map.d.ts.map +1 -1
  314. package/ts/cjs/utils/stream-map.js.map +1 -1
  315. package/ts/cjs/utils/stream2string.d.ts.map +1 -1
  316. package/ts/cjs/utils/stream2string.js.map +1 -1
  317. package/ts/cjs/utils/string2stream.d.ts.map +1 -1
  318. package/ts/cjs/utils/string2stream.js.map +1 -1
  319. package/ts/cjs/utils/stripper.d.ts.map +1 -1
  320. package/ts/cjs/utils/stripper.js.map +1 -1
  321. package/ts/cjs/utils/to-sorted.d.ts.map +1 -1
  322. package/ts/cjs/utils/to-sorted.js.map +1 -1
  323. package/ts/cjs/utils/uint8array-equal.d.ts.map +1 -1
  324. package/ts/cjs/utils/uint8array-equal.js.map +1 -1
  325. package/ts/cjs/version.js +1 -1
  326. package/ts/esm/app-context.d.ts.map +1 -1
  327. package/ts/esm/app-context.js.map +1 -1
  328. package/ts/esm/base-sys-abstraction.d.ts.map +1 -1
  329. package/ts/esm/base-sys-abstraction.js.map +1 -1
  330. package/ts/esm/bin2text.d.ts.map +1 -1
  331. package/ts/esm/bin2text.js.map +1 -1
  332. package/ts/esm/coerce-binary.d.ts.map +1 -1
  333. package/ts/esm/coerce-binary.js.map +1 -1
  334. package/ts/esm/crypto.d.ts.map +1 -1
  335. package/ts/esm/crypto.js.map +1 -1
  336. package/ts/esm/future.d.ts.map +1 -1
  337. package/ts/esm/future.js.map +1 -1
  338. package/ts/esm/http_header.d.ts.map +1 -1
  339. package/ts/esm/http_header.js.map +1 -1
  340. package/ts/esm/index.d.ts +1 -0
  341. package/ts/esm/index.d.ts.map +1 -1
  342. package/ts/esm/index.js +1 -0
  343. package/ts/esm/index.js.map +1 -1
  344. package/ts/esm/is-json.d.ts.map +1 -1
  345. package/ts/esm/is-json.js.map +1 -1
  346. package/ts/esm/is-promise.d.ts.map +1 -1
  347. package/ts/esm/is-promise.js.map +1 -1
  348. package/ts/esm/lru-map-set.d.ts.map +1 -1
  349. package/ts/esm/lru-map-set.js.map +1 -1
  350. package/ts/esm/on-func.d.ts.map +1 -1
  351. package/ts/esm/on-func.js.map +1 -1
  352. package/ts/esm/on-func.test.js +1 -1
  353. package/ts/esm/on-func.test.js.map +1 -1
  354. package/ts/esm/option.d.ts.map +1 -1
  355. package/ts/esm/option.js.map +1 -1
  356. package/ts/esm/poller.d.ts +9 -2
  357. package/ts/esm/poller.d.ts.map +1 -1
  358. package/ts/esm/poller.js +9 -4
  359. package/ts/esm/poller.js.map +1 -1
  360. package/ts/esm/poller.test.js +1 -1
  361. package/ts/esm/poller.test.js.map +1 -1
  362. package/ts/esm/promise-sleep.d.ts.map +1 -0
  363. package/{esm/utils → ts/esm}/promise-sleep.js +1 -1
  364. package/ts/esm/promise-sleep.js.map +1 -0
  365. package/ts/esm/promise-sleep.test.d.ts.map +1 -0
  366. package/ts/esm/promise-sleep.test.js.map +1 -0
  367. package/ts/esm/resolve-once.d.ts +36 -3
  368. package/ts/esm/resolve-once.d.ts.map +1 -1
  369. package/ts/esm/resolve-once.js +84 -6
  370. package/ts/esm/resolve-once.js.map +1 -1
  371. package/ts/esm/result.d.ts.map +1 -1
  372. package/ts/esm/result.js.map +1 -1
  373. package/ts/esm/runtime.d.ts.map +1 -1
  374. package/ts/esm/runtime.js.map +1 -1
  375. package/ts/esm/sys-env.d.ts.map +1 -1
  376. package/ts/esm/sys-env.js.map +1 -1
  377. package/ts/esm/timeouted.d.ts.map +1 -1
  378. package/ts/esm/timeouted.js +1 -1
  379. package/ts/esm/timeouted.js.map +1 -1
  380. package/ts/esm/tracer.d.ts.map +1 -1
  381. package/ts/esm/tracer.js.map +1 -1
  382. package/ts/esm/txt-en-decoder.d.ts +1 -1
  383. package/ts/esm/txt-en-decoder.d.ts.map +1 -1
  384. package/ts/esm/txt-en-decoder.js +2 -5
  385. package/ts/esm/txt-en-decoder.js.map +1 -1
  386. package/ts/esm/uri.d.ts.map +1 -1
  387. package/ts/esm/uri.js.map +1 -1
  388. package/ts/esm/utils/coerce-uint8.d.ts.map +1 -1
  389. package/ts/esm/utils/coerce-uint8.js.map +1 -1
  390. package/ts/esm/utils/console-write-stream.d.ts.map +1 -1
  391. package/ts/esm/utils/console-write-stream.js.map +1 -1
  392. package/ts/esm/utils/consume.d.ts.map +1 -1
  393. package/ts/esm/utils/consume.js.map +1 -1
  394. package/ts/esm/utils/fanout-write-stream.d.ts.map +1 -1
  395. package/ts/esm/utils/fanout-write-stream.js.map +1 -1
  396. package/ts/esm/utils/get-params-result.d.ts.map +1 -1
  397. package/ts/esm/utils/get-params-result.js.map +1 -1
  398. package/ts/esm/utils/index.d.ts +0 -1
  399. package/ts/esm/utils/index.d.ts.map +1 -1
  400. package/ts/esm/utils/index.js +0 -1
  401. package/ts/esm/utils/index.js.map +1 -1
  402. package/ts/esm/utils/rebuffer.d.ts.map +1 -1
  403. package/ts/esm/utils/rebuffer.js.map +1 -1
  404. package/ts/esm/utils/relative-path.d.ts.map +1 -1
  405. package/ts/esm/utils/relative-path.js.map +1 -1
  406. package/ts/esm/utils/sorted-object.d.ts.map +1 -1
  407. package/ts/esm/utils/sorted-object.js.map +1 -1
  408. package/ts/esm/utils/stream-map.d.ts.map +1 -1
  409. package/ts/esm/utils/stream-map.js.map +1 -1
  410. package/ts/esm/utils/stream2string.d.ts.map +1 -1
  411. package/ts/esm/utils/stream2string.js.map +1 -1
  412. package/ts/esm/utils/string2stream.d.ts.map +1 -1
  413. package/ts/esm/utils/string2stream.js.map +1 -1
  414. package/ts/esm/utils/stripper.d.ts.map +1 -1
  415. package/ts/esm/utils/stripper.js.map +1 -1
  416. package/ts/esm/utils/to-sorted.d.ts.map +1 -1
  417. package/ts/esm/utils/to-sorted.js.map +1 -1
  418. package/ts/esm/utils/uint8array-equal.d.ts.map +1 -1
  419. package/ts/esm/utils/uint8array-equal.js.map +1 -1
  420. package/ts/esm/version.js +1 -1
  421. package/cjs/utils/promise-sleep.cjs.map +0 -1
  422. package/cjs/utils/promise-sleep.d.ts.map +0 -1
  423. package/cjs/utils/promise-sleep.test.cjs.map +0 -1
  424. package/cjs/utils/promise-sleep.test.d.ts.map +0 -1
  425. package/esm/utils/promise-sleep.d.ts.map +0 -1
  426. package/esm/utils/promise-sleep.js.map +0 -1
  427. package/esm/utils/promise-sleep.test.d.ts.map +0 -1
  428. package/esm/utils/promise-sleep.test.js.map +0 -1
  429. package/ts/cjs/utils/promise-sleep.d.ts.map +0 -1
  430. package/ts/cjs/utils/promise-sleep.js.map +0 -1
  431. package/ts/cjs/utils/promise-sleep.test.d.ts.map +0 -1
  432. package/ts/cjs/utils/promise-sleep.test.js.map +0 -1
  433. package/ts/esm/utils/promise-sleep.d.ts.map +0 -1
  434. package/ts/esm/utils/promise-sleep.js.map +0 -1
  435. package/ts/esm/utils/promise-sleep.test.d.ts.map +0 -1
  436. package/ts/esm/utils/promise-sleep.test.js.map +0 -1
  437. /package/cjs/{utils/promise-sleep.d.ts → promise-sleep.d.ts} +0 -0
  438. /package/cjs/{utils/promise-sleep.test.cjs → promise-sleep.test.cjs} +0 -0
  439. /package/cjs/{utils/promise-sleep.test.d.ts → promise-sleep.test.d.ts} +0 -0
  440. /package/esm/{utils/promise-sleep.d.ts → promise-sleep.d.ts} +0 -0
  441. /package/esm/{utils/promise-sleep.test.d.ts → promise-sleep.test.d.ts} +0 -0
  442. /package/esm/{utils/promise-sleep.test.js → promise-sleep.test.js} +0 -0
  443. /package/ts/cjs/{utils/promise-sleep.d.ts → promise-sleep.d.ts} +0 -0
  444. /package/ts/cjs/{utils/promise-sleep.test.d.ts → promise-sleep.test.d.ts} +0 -0
  445. /package/ts/cjs/{utils/promise-sleep.test.js → promise-sleep.test.js} +0 -0
  446. /package/ts/esm/{utils/promise-sleep.d.ts → promise-sleep.d.ts} +0 -0
  447. /package/ts/esm/{utils/promise-sleep.test.d.ts → promise-sleep.test.d.ts} +0 -0
  448. /package/ts/esm/{utils/promise-sleep.test.js → promise-sleep.test.js} +0 -0
@@ -1,5 +1,23 @@
1
1
  import { isPromise } from "../is-promise.js";
2
2
 
3
+ /**
4
+ * Consumes a ReadableStream, applying a callback to each chunk and collecting results.
5
+ *
6
+ * Processes each chunk through the callback and returns an array of all results.
7
+ * Waits for async callbacks to complete before processing the next chunk.
8
+ *
9
+ * @template E - Stream element type
10
+ * @template R - Callback return type
11
+ * @param stream - The ReadableStream to consume
12
+ * @param cb - Callback function applied to each chunk
13
+ * @returns Promise resolving to array of all callback results
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const results = await consumeStream(numberStream, (n) => n * 2);
18
+ * console.log(results); // [2, 4, 6, 8, ...]
19
+ * ```
20
+ */
3
21
  export function consumeStream<E, R>(stream: ReadableStream<E>, cb: (msg: E) => R): Promise<R[]> {
4
22
  const ret: R[] = [];
5
23
  return processStream(stream, (msg) =>
@@ -9,6 +27,27 @@ export function consumeStream<E, R>(stream: ReadableStream<E>, cb: (msg: E) => R
9
27
  ).then(() => ret);
10
28
  }
11
29
 
30
+ /**
31
+ * Processes a ReadableStream with a callback function and optional context.
32
+ *
33
+ * Similar to consumeStream but doesn't collect results - just processes each
34
+ * chunk sequentially. Useful for side effects like logging, writing to files, etc.
35
+ *
36
+ * @template E - Stream element type
37
+ * @template CTX - Context type passed to callback
38
+ * @param stream - The ReadableStream to process
39
+ * @param cb - Callback function applied to each chunk (receives chunk and context)
40
+ * @param ctx - Optional context object passed to each callback invocation
41
+ * @returns Promise that resolves when stream is fully processed
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * await processStream(logStream, (entry, ctx) => {
46
+ * ctx.count++;
47
+ * console.log(`[${ctx.count}]`, entry);
48
+ * }, { count: 0 });
49
+ * ```
50
+ */
12
51
  export function processStream<E, CTX = object>(
13
52
  stream: ReadableStream<E>,
14
53
  cb: (msg: E, ctx: CTX) => Promise<void> | void,
@@ -67,6 +106,35 @@ function step<I extends IterableIterator<E> | AsyncIterableIterator<E>, R, E>(ar
67
106
  });
68
107
  }
69
108
 
109
+ /**
110
+ * Consumes an iterator, applying a callback to each item and collecting results.
111
+ *
112
+ * Processes sync or async iterators, calling the callback for each item and
113
+ * returning an array of all results. Supports chunked processing with configurable
114
+ * chunk size to yield control back to the event loop periodically.
115
+ *
116
+ * @template T - Iterator element type
117
+ * @template R - Callback return type
118
+ * @param iter - Iterator or async iterator to consume
119
+ * @param cb - Callback function applied to each item
120
+ * @param params - Optional configuration (chunkSize, setTimeoutFn, ctx)
121
+ * @returns Promise resolving to array of all callback results
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * function* numbers() {
126
+ * yield 1; yield 2; yield 3;
127
+ * }
128
+ *
129
+ * const results = await consumeIterator(numbers(), (n) => n * 2);
130
+ * console.log(results); // [2, 4, 6]
131
+ *
132
+ * // Async iterator with custom chunk size
133
+ * const data = await consumeIterator(asyncIterator, processItem, {
134
+ * chunkSize: 32 // Yield to event loop every 32 items
135
+ * });
136
+ * ```
137
+ */
70
138
  export function consumeIterator<T, R>(
71
139
  iter: IterableIterator<T> | AsyncIterableIterator<T>,
72
140
  cb: (msg: T) => R,
@@ -83,6 +151,44 @@ export function consumeIterator<T, R>(
83
151
  ).then(() => ret);
84
152
  }
85
153
 
154
+ /**
155
+ * Processes an iterator with a callback function for side effects.
156
+ *
157
+ * Similar to consumeIterator but doesn't collect results - just processes each
158
+ * item sequentially. Supports chunked processing to avoid blocking the event loop
159
+ * during long-running iterations. Useful for side effects like logging, writing
160
+ * to files, or updating UI.
161
+ *
162
+ * @template T - Iterator element type
163
+ * @template CTX - Context type passed to callback
164
+ * @param iter - Iterator or async iterator to process
165
+ * @param cb - Callback function applied to each item
166
+ * @param params - Optional configuration (chunkSize, setTimeoutFn, ctx)
167
+ * @returns Promise that resolves when iteration is complete
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * function* logs() {
172
+ * yield 'Starting...';
173
+ * yield 'Processing...';
174
+ * yield 'Complete!';
175
+ * }
176
+ *
177
+ * await processIterator(logs(), (msg) => console.log(msg));
178
+ *
179
+ * // With context and chunked processing
180
+ * const ctx = { count: 0 };
181
+ * await processIterator(
182
+ * largeDataIterator,
183
+ * (item, ctx) => {
184
+ * ctx.count++;
185
+ * processItem(item);
186
+ * },
187
+ * { ctx, chunkSize: 100 } // Yield every 100 items
188
+ * );
189
+ * console.log(`Processed ${ctx.count} items`);
190
+ * ```
191
+ */
86
192
  export function processIterator<T, CTX = object>(
87
193
  iter: IterableIterator<T> | AsyncIterableIterator<T>,
88
194
  cb: (msg: T) => Promise<void> | void,
@@ -1,3 +1,48 @@
1
+ /**
2
+ * WritableStreamDefaultWriter that multiplexes writes to multiple underlying writers.
3
+ *
4
+ * FanoutWriteStream broadcasts all write operations to an array of writers simultaneously.
5
+ * All operations (write, close, abort, releaseLock) are applied to all underlying writers.
6
+ * Useful for scenarios like logging to multiple destinations, streaming to multiple
7
+ * consumers, or maintaining redundant copies of stream data.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Write to both file and console simultaneously
12
+ * const fileStream = new WritableStream({ ... });
13
+ * const consoleStream = new ConsoleWriterStream();
14
+ *
15
+ * const fanout = new FanoutWriteStream([
16
+ * fileStream.getWriter(),
17
+ * consoleStream.getWriter()
18
+ * ]);
19
+ *
20
+ * // This writes to both destinations
21
+ * await fanout.write(new TextEncoder().encode('Log message'));
22
+ *
23
+ * // Close all writers
24
+ * await fanout.close();
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Mirror stream data to multiple endpoints
30
+ * const backupWriter = backupStream.getWriter();
31
+ * const primaryWriter = primaryStream.getWriter();
32
+ * const metricsWriter = metricsStream.getWriter();
33
+ *
34
+ * const fanout = new FanoutWriteStream([
35
+ * primaryWriter,
36
+ * backupWriter,
37
+ * metricsWriter
38
+ * ]);
39
+ *
40
+ * // All three streams receive the data
41
+ * for (const chunk of dataChunks) {
42
+ * await fanout.write(chunk);
43
+ * }
44
+ * ```
45
+ */
1
46
  export class FanoutWriteStream implements WritableStreamDefaultWriter<Uint8Array> {
2
47
  readonly _writers: WritableStreamDefaultWriter<Uint8Array>[];
3
48
  readonly ready: Promise<never>;
@@ -4,6 +4,43 @@ import { param } from "../types.js";
4
4
  export type MsgFn = (...keys: string[]) => string;
5
5
  export type KeysParam = (string | MsgFn | Record<string, param | number | string | boolean | undefined | null>)[];
6
6
 
7
+ /**
8
+ * Retrieves multiple parameters with type-safe Result handling and defaults.
9
+ *
10
+ * Extracts multiple parameters from an object with getParam method (like URI),
11
+ * supporting required params, optional params, and default values. Returns
12
+ * Result.Err if any required parameters are missing.
13
+ *
14
+ * @param keys - Array of parameter specifications:
15
+ * - string: Required parameter
16
+ * - { key: "defaultValue" }: Parameter with default
17
+ * - { key: param.OPTIONAL }: Optional parameter
18
+ * - Function: Custom error message generator
19
+ * @param getParam - Object with getParam method (e.g., URI instance)
20
+ * @returns Result.Ok with all parameters or Result.Err with missing params message
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const uri = URI.from('https://api.com?user=alice&page=1');
25
+ *
26
+ * // Required and optional params with defaults
27
+ * const result = getParamsResult(
28
+ * ['user', { page: '1' }, { limit: param.OPTIONAL }],
29
+ * uri
30
+ * );
31
+ *
32
+ * if (result.isOk()) {
33
+ * const { user, page, limit } = result.unwrap();
34
+ * // user: 'alice', page: '1', limit: undefined
35
+ * }
36
+ *
37
+ * // Custom error message
38
+ * const result2 = getParamsResult(
39
+ * ['apiKey', 'secret', (...missing) => `Auth failed: missing ${missing.join(', ')}`],
40
+ * uri
41
+ * );
42
+ * ```
43
+ */
7
44
  export function getParamsResult(
8
45
  keys: KeysParam,
9
46
  getParam: { getParam: (key: string) => string | undefined },
@@ -11,4 +11,3 @@ export * from "./uint8array-equal.js";
11
11
  export * from "./coerce-uint8.js";
12
12
  export * from "./consume.js";
13
13
  export * from "./to-sorted.js";
14
- export * from "./promise-sleep.js";
@@ -5,6 +5,26 @@ interface ReChunkResult {
5
5
  readonly chunk: Uint8Array;
6
6
  }
7
7
 
8
+ /**
9
+ * Rebuffers an array of Uint8Arrays to a specific chunk size.
10
+ *
11
+ * Convenience wrapper around rebuffer stream for array inputs/outputs.
12
+ *
13
+ * @param a - Array of Uint8Arrays to rebuffer
14
+ * @param chunkSize - Target size for output chunks
15
+ * @returns Promise resolving to array of rebuffered chunks
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const chunks = [
20
+ * new Uint8Array([1, 2]),
21
+ * new Uint8Array([3, 4, 5]),
22
+ * new Uint8Array([6])
23
+ * ];
24
+ * const rebuffered = await rebufferArray(chunks, 3);
25
+ * // [Uint8Array([1,2,3]), Uint8Array([4,5,6])]
26
+ * ```
27
+ */
8
28
  export async function rebufferArray(a: Uint8Array[], chunkSize: number): Promise<Uint8Array[]> {
9
29
  return stream2array(rebuffer(array2stream(a), chunkSize));
10
30
  }
@@ -64,6 +84,28 @@ function pump(ps: pumpState, controller: ReadableStreamDefaultController<Uint8Ar
64
84
  });
65
85
  }
66
86
 
87
+ /**
88
+ * Transforms a stream of Uint8Arrays into fixed-size chunks.
89
+ *
90
+ * Rebuffers variable-sized chunks from the input stream into consistent
91
+ * chunk sizes. The final chunk may be smaller if there's insufficient data.
92
+ * Useful for network protocols, file formats, or APIs requiring specific
93
+ * chunk sizes.
94
+ *
95
+ * @param a - Input ReadableStream with variable-sized Uint8Array chunks
96
+ * @param chunkSize - Target size for output chunks in bytes
97
+ * @returns ReadableStream emitting fixed-size chunks
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * // Stream has chunks: [10 bytes], [25 bytes], [5 bytes]
102
+ * const fixedChunks = rebuffer(inputStream, 16);
103
+ * // Output chunks: [16 bytes], [16 bytes], [8 bytes]
104
+ *
105
+ * // Useful for protocol framing
106
+ * const framedStream = rebuffer(rawStream, 1024); // 1KB chunks
107
+ * ```
108
+ */
67
109
  export function rebuffer(a: ReadableStream<Uint8Array>, chunkSize: number): ReadableStream<Uint8Array> {
68
110
  const state: pumpState = {
69
111
  reader: a.getReader(),
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Path component type constants for representing special path elements.
3
+ *
4
+ * Uses bit flags to identify different path components:
5
+ * - Slash: Path separator (/)
6
+ * - Root: Absolute path root (/)
7
+ * - Up: Parent directory (..)
8
+ * - Noop: Current directory (.)
9
+ */
1
10
  export const PartType = {
2
11
  Slash: 0x1,
3
12
  Root: 0x3,
@@ -10,12 +19,29 @@ export type PartType = (typeof PartType)[keyof typeof PartType];
10
19
 
11
20
  export type PathItem = string | PartType;
12
21
 
22
+ /**
23
+ * Path builder for constructing and manipulating filesystem paths.
24
+ *
25
+ * Represents a path as an array of parts (strings and special PartType tokens).
26
+ * Provides methods for adding path components and converting to string representation.
27
+ */
13
28
  export class Path {
14
29
  readonly parts: PathItem[];
15
30
  constructor(parts: PathItem[] = []) {
16
31
  this.parts = parts;
17
32
  }
18
33
 
34
+ /**
35
+ * Converts the path parts to a string representation.
36
+ *
37
+ * @returns Path as a string with proper separators
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const path = new Path([PartType.Root, 'home', PartType.Slash, 'user']);
42
+ * path.toString(); // '/home/user'
43
+ * ```
44
+ */
19
45
  toString(): string {
20
46
  return this.parts
21
47
  .map((part) => {
@@ -36,6 +62,23 @@ export class Path {
36
62
  .join("");
37
63
  }
38
64
 
65
+ /**
66
+ * Adds a path component to the path.
67
+ *
68
+ * Handles special cases like duplicate slashes, "." and ".." segments.
69
+ *
70
+ * @param part - Path component to add (string or PartType)
71
+ * @throws Error if adding absolute part to absolute path
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const path = new Path();
76
+ * path.add(PartType.Root);
77
+ * path.add('home');
78
+ * path.add(PartType.Slash);
79
+ * path.add('..');
80
+ * ```
81
+ */
39
82
  add(part: PathItem): void {
40
83
  if (this.parts.includes(PartType.Root) && part === PartType.Root) {
41
84
  throw new Error("Cannot add absolute part to absolute path");
@@ -66,6 +109,24 @@ export class Path {
66
109
  }
67
110
  }
68
111
 
112
+ /**
113
+ * Parses a path string into a Path object with structured parts.
114
+ *
115
+ * Splits the path into components, identifying root, slashes, and segments.
116
+ * Consecutive slashes are collapsed into single separators.
117
+ *
118
+ * @param path - Path string to parse
119
+ * @returns Path object with structured components
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const path = splitPath('/home/user/docs');
124
+ * // Path with parts: [Root, 'home', Slash, 'user', Slash, 'docs']
125
+ *
126
+ * const relative = splitPath('../config/app.json');
127
+ * // Path with parts: [Up, Slash, 'config', Slash, 'app.json']
128
+ * ```
129
+ */
69
130
  export function splitPath(path: string): Path {
70
131
  const p = new Path();
71
132
  if (path === "") {
@@ -89,6 +150,27 @@ export function splitPath(path: string): Path {
89
150
  return p;
90
151
  }
91
152
 
153
+ /**
154
+ * Joins multiple path segments into a single path string.
155
+ *
156
+ * Intelligently handles slashes between segments, avoiding duplicates while
157
+ * ensuring proper separation. Empty segments are skipped.
158
+ *
159
+ * @param paths - Path segments to join
160
+ * @returns Joined path string
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * pathJoin('/home', 'user', 'docs');
165
+ * // '/home/user/docs'
166
+ *
167
+ * pathJoin('/api/', '/users/', 'profile');
168
+ * // '/api//users/profile'
169
+ *
170
+ * pathJoin('src', 'utils', 'path.ts');
171
+ * // 'src/utils/path.ts'
172
+ * ```
173
+ */
92
174
  export function pathJoin(...paths: string[]): string {
93
175
  let prev = "";
94
176
  const res: string[] = [];
@@ -112,6 +194,32 @@ export function pathJoin(...paths: string[]): string {
112
194
  return res.join("");
113
195
  }
114
196
 
197
+ /**
198
+ * Resolves a relative path against a base path and normalizes the result.
199
+ *
200
+ * If the relative path is absolute, returns it directly. Otherwise, joins
201
+ * the base and relative paths, then normalizes by resolving ".." (parent)
202
+ * and "." (current) directory references.
203
+ *
204
+ * @param path - Base path to resolve against
205
+ * @param relative - Relative path to resolve (or absolute path)
206
+ * @returns Normalized resolved path
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * relativePath('/home/user', 'docs/file.txt');
211
+ * // '/home/user/docs/file.txt'
212
+ *
213
+ * relativePath('/home/user/project', '../config.json');
214
+ * // '/home/user/config.json'
215
+ *
216
+ * relativePath('/home/user', '/etc/hosts');
217
+ * // '/etc/hosts' (absolute path takes precedence)
218
+ *
219
+ * relativePath('/a/b/c', '../../d');
220
+ * // '/a/d'
221
+ * ```
222
+ */
115
223
  export function relativePath(path: string, relative: string): string {
116
224
  const relativeParts = splitPath(relative);
117
225
  let result: string;
@@ -1,16 +1,66 @@
1
1
  import { toSorted, TouchFn } from "./to-sorted.js";
2
2
 
3
+ /**
4
+ * Converts an object to an array of single-key objects, sorted by key.
5
+ *
6
+ * Each entry becomes its own object with one key-value pair, useful for
7
+ * serialization formats that need objects instead of tuples.
8
+ *
9
+ * @template T - The input object type
10
+ * @param set - The object to convert
11
+ * @param touchFn - Optional function to transform values during sorting
12
+ * @returns Array of objects, each with a single key-value pair, sorted by key
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const sorted = toSortedObjectArray({ z: 3, a: 1, m: 2 });
17
+ * // [{ a: 1 }, { m: 2 }, { z: 3 }]
18
+ * ```
19
+ */
3
20
  export function toSortedObjectArray<T>(set?: T, touchFn?: TouchFn): Record<string, unknown>[] {
4
21
  if (!set) return [];
5
22
  return toSortedArray(set, touchFn).map(([k, v]) => ({ [k]: v }));
6
23
  }
7
24
 
25
+ /**
26
+ * Converts an object to a sorted array of [key, value] tuples.
27
+ *
28
+ * @template T - The input object type
29
+ * @param set - The object to convert
30
+ * @param touchFn - Optional function to transform values during sorting
31
+ * @returns Array of [key, value] tuples sorted by key
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const sorted = toSortedArray({ z: 3, a: 1, m: 2 });
36
+ * // [['a', 1], ['m', 2], ['z', 3]]
37
+ * ```
38
+ */
8
39
  export function toSortedArray<T>(set?: T, touchFn?: TouchFn): [string, unknown][] {
9
40
  if (!set) return [];
10
41
  return Object.entries(toSorted(set, touchFn));
11
42
  //set).sort(([a], [b]) => a.localeCompare(b));
12
43
  }
13
44
 
45
+ /**
46
+ * Returns a new object with keys sorted alphabetically.
47
+ *
48
+ * Creates a shallow copy of the object with keys in sorted order.
49
+ * Useful for deterministic serialization or comparison.
50
+ *
51
+ * @template T - The input object type
52
+ * @template S - Base type for non-null assertion
53
+ * @param set - The object to sort
54
+ * @param touchFn - Optional function to transform values during sorting
55
+ * @returns New object with sorted keys, or undefined if input is null/undefined
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const sorted = toSortedObject({ z: 3, a: 1, m: 2 });
60
+ * // { a: 1, m: 2, z: 3 }
61
+ * Object.keys(sorted); // ['a', 'm', 'z']
62
+ * ```
63
+ */
14
64
  export function toSortedObject<T extends NonNullable<S>, S>(set?: T, touchFn?: TouchFn): T | undefined {
15
65
  if (!set) return set; // as T;
16
66
  return Object.fromEntries(toSortedArray(set, touchFn)) as T;
@@ -4,6 +4,36 @@ export interface StreamMap<T, U> {
4
4
  Map(s: T, idx: number): U | Promise<U>;
5
5
  readonly Close?: () => void;
6
6
  }
7
+
8
+ /**
9
+ * Transforms a ReadableStream by applying a mapping function to each chunk.
10
+ *
11
+ * Similar to Array.map() but for streams. Supports both sync and async
12
+ * mapping functions. Calls optional Close callback when stream ends.
13
+ *
14
+ * @template T - Input chunk type
15
+ * @template U - Output chunk type
16
+ * @param s - The input ReadableStream
17
+ * @param sm - StreamMap object with Map function and optional Close callback
18
+ * @returns ReadableStream with transformed chunks
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const numberStream = getNumberStream();
23
+ * const doubled = streamMap(numberStream, {
24
+ * Map: (n) => n * 2,
25
+ * Close: () => console.log('Stream ended')
26
+ * });
27
+ *
28
+ * // Async transformation
29
+ * const enriched = streamMap(userStream, {
30
+ * Map: async (user) => {
31
+ * const details = await fetchUserDetails(user.id);
32
+ * return { ...user, ...details };
33
+ * }
34
+ * });
35
+ * ```
36
+ */
7
37
  export function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): ReadableStream<U> {
8
38
  const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
9
39
  return new ReadableStream<U>({
@@ -28,6 +58,29 @@ export function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): Read
28
58
  });
29
59
  }
30
60
 
61
+ /**
62
+ * Consumes a ReadableStream without processing, counting the number of chunks.
63
+ *
64
+ * Reads and discards all chunks from the stream, returning only the count.
65
+ * Useful for testing, benchmarking, or draining streams when you only need
66
+ * to know how many items were produced.
67
+ *
68
+ * @template T - Stream element type
69
+ * @param a - ReadableStream to consume
70
+ * @returns Promise resolving to the number of chunks read
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const stream = createDataStream();
75
+ * const count = await devnull(stream);
76
+ * console.log(`Stream produced ${count} chunks`);
77
+ *
78
+ * // Useful for benchmarking stream production
79
+ * const start = Date.now();
80
+ * const chunks = await devnull(dataGenerator());
81
+ * console.log(`Generated ${chunks} chunks in ${Date.now() - start}ms`);
82
+ * ```
83
+ */
31
84
  export async function devnull<T>(a: ReadableStream<T>): Promise<number> {
32
85
  const reader = a.getReader();
33
86
  let cnt = 0;
@@ -41,6 +94,22 @@ export async function devnull<T>(a: ReadableStream<T>): Promise<number> {
41
94
  return cnt;
42
95
  }
43
96
 
97
+ /**
98
+ * Converts an array to a ReadableStream.
99
+ *
100
+ * Each array element becomes a stream chunk. Useful for testing or
101
+ * converting in-memory data to streaming format.
102
+ *
103
+ * @template T - The type of array elements
104
+ * @param a - The array to convert
105
+ * @returns ReadableStream emitting each array element
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const stream = array2stream([1, 2, 3, 4, 5]);
110
+ * await processStream(stream, (n) => console.log(n));
111
+ * ```
112
+ */
44
113
  export function array2stream<T>(a: T[]): ReadableStream<T> {
45
114
  let i = 0;
46
115
  return new ReadableStream<T>({
@@ -55,6 +124,27 @@ export function array2stream<T>(a: T[]): ReadableStream<T> {
55
124
  });
56
125
  }
57
126
 
127
+ /**
128
+ * Converts a ReadableStream to an array by collecting all chunks.
129
+ *
130
+ * Reads the entire stream into memory, collecting all chunks into an array.
131
+ * Use with caution on large or infinite streams as it loads everything into memory.
132
+ *
133
+ * @template T - Stream element type
134
+ * @param a - ReadableStream to convert
135
+ * @returns Promise resolving to array of all stream chunks
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const stream = fetchDataStream();
140
+ * const items = await stream2array(stream);
141
+ * console.log(`Received ${items.length} items`);
142
+ *
143
+ * // Process stream as array
144
+ * const numbers = await stream2array(numberStream);
145
+ * const sum = numbers.reduce((a, b) => a + b, 0);
146
+ * ```
147
+ */
58
148
  export async function stream2array<T>(a: ReadableStream<T>): Promise<T[]> {
59
149
  const ret: T[] = [];
60
150
  const reader = a.getReader();
@@ -1,3 +1,23 @@
1
+ /**
2
+ * Converts a ReadableStream of Uint8Array chunks to a string.
3
+ *
4
+ * Reads the entire stream (or up to maxSize bytes) and decodes it as UTF-8 text.
5
+ * Useful for consuming response bodies, file streams, etc.
6
+ *
7
+ * @param stream - The ReadableStream to convert (returns empty string if null/undefined)
8
+ * @param maxSize - Optional maximum bytes to read before stopping
9
+ * @returns Promise resolving to the decoded string
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const response = await fetch('/api/data');
14
+ * const text = await stream2string(response.body);
15
+ * console.log(text);
16
+ *
17
+ * // With size limit
18
+ * const preview = await stream2string(response.body, 1000); // First 1KB
19
+ * ```
20
+ */
1
21
  export async function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string> {
2
22
  if (!stream) {
3
23
  return Promise.resolve("");
@@ -25,6 +45,21 @@ export async function stream2string(stream?: ReadableStream<Uint8Array> | null,
25
45
  return Promise.resolve(res);
26
46
  }
27
47
 
48
+ /**
49
+ * Converts a ReadableStream of Uint8Array chunks to a single Uint8Array.
50
+ *
51
+ * Reads and concatenates all chunks from the stream into a single buffer.
52
+ * Useful for loading binary data from streams.
53
+ *
54
+ * @param stream - The ReadableStream to convert (returns empty Uint8Array if null/undefined)
55
+ * @returns Promise resolving to the concatenated Uint8Array
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const response = await fetch('/image.png');
60
+ * const bytes = await stream2uint8array(response.body);
61
+ * ```
62
+ */
28
63
  export async function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array> {
29
64
  if (!stream) {
30
65
  return Promise.resolve(new Uint8Array());