@typed/fx 1.32.0 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (818) hide show
  1. package/README.md +344 -2
  2. package/dist/Fx/Fx.d.ts +96 -0
  3. package/dist/Fx/Fx.d.ts.map +1 -0
  4. package/dist/Fx/Fx.js +35 -0
  5. package/dist/Fx/TypeId.d.ts +20 -0
  6. package/dist/Fx/TypeId.d.ts.map +1 -0
  7. package/dist/Fx/TypeId.js +15 -0
  8. package/dist/Fx/combinators/catch.d.ts +53 -0
  9. package/dist/Fx/combinators/catch.d.ts.map +1 -0
  10. package/dist/Fx/combinators/catch.js +69 -0
  11. package/dist/Fx/combinators/causes.d.ts +12 -0
  12. package/dist/Fx/combinators/causes.d.ts.map +1 -0
  13. package/dist/Fx/combinators/causes.js +16 -0
  14. package/dist/Fx/combinators/compact.d.ts +12 -0
  15. package/dist/Fx/combinators/compact.d.ts.map +1 -0
  16. package/dist/Fx/combinators/compact.js +11 -0
  17. package/dist/Fx/combinators/continueWith.d.ts +51 -0
  18. package/dist/Fx/combinators/continueWith.d.ts.map +1 -0
  19. package/dist/Fx/combinators/continueWith.js +41 -0
  20. package/dist/Fx/combinators/ensuring.d.ts +16 -0
  21. package/dist/Fx/combinators/ensuring.d.ts.map +1 -0
  22. package/dist/Fx/combinators/ensuring.js +13 -0
  23. package/dist/Fx/combinators/exhaustLatestMap.d.ts +15 -0
  24. package/dist/Fx/combinators/exhaustLatestMap.d.ts.map +1 -0
  25. package/dist/Fx/combinators/exhaustLatestMap.js +48 -0
  26. package/dist/Fx/combinators/exhaustLatestMapEffect.d.ts +13 -0
  27. package/dist/Fx/combinators/exhaustLatestMapEffect.d.ts.map +1 -0
  28. package/dist/Fx/combinators/exhaustLatestMapEffect.js +14 -0
  29. package/dist/Fx/combinators/exhaustMap.d.ts +11 -0
  30. package/dist/Fx/combinators/exhaustMap.d.ts.map +1 -0
  31. package/dist/Fx/combinators/exhaustMap.js +19 -0
  32. package/dist/Fx/combinators/exhaustMapEffect.d.ts +11 -0
  33. package/dist/Fx/combinators/exhaustMapEffect.d.ts.map +1 -0
  34. package/dist/Fx/combinators/exhaustMapEffect.js +12 -0
  35. package/dist/Fx/combinators/exit.d.ts +12 -0
  36. package/dist/Fx/combinators/exit.d.ts.map +1 -0
  37. package/dist/Fx/combinators/exit.js +11 -0
  38. package/dist/Fx/combinators/filter.d.ts +14 -0
  39. package/dist/Fx/combinators/filter.d.ts.map +1 -0
  40. package/dist/Fx/combinators/filter.js +12 -0
  41. package/dist/Fx/combinators/filterEffect.d.ts +15 -0
  42. package/dist/Fx/combinators/filterEffect.d.ts.map +1 -0
  43. package/dist/Fx/combinators/filterEffect.js +12 -0
  44. package/dist/Fx/combinators/filterMap.d.ts +15 -0
  45. package/dist/Fx/combinators/filterMap.d.ts.map +1 -0
  46. package/dist/Fx/combinators/filterMap.js +12 -0
  47. package/dist/Fx/combinators/filterMapEffect.d.ts +16 -0
  48. package/dist/Fx/combinators/filterMapEffect.d.ts.map +1 -0
  49. package/dist/Fx/combinators/filterMapEffect.js +12 -0
  50. package/dist/Fx/combinators/filterMapLoop.d.ts +17 -0
  51. package/dist/Fx/combinators/filterMapLoop.d.ts.map +1 -0
  52. package/dist/Fx/combinators/filterMapLoop.js +14 -0
  53. package/dist/Fx/combinators/filterMapLoopCause.d.ts +18 -0
  54. package/dist/Fx/combinators/filterMapLoopCause.d.ts.map +1 -0
  55. package/dist/Fx/combinators/filterMapLoopCause.js +14 -0
  56. package/dist/Fx/combinators/filterMapLoopCauseEffect.d.ts +18 -0
  57. package/dist/Fx/combinators/filterMapLoopCauseEffect.d.ts.map +1 -0
  58. package/dist/Fx/combinators/filterMapLoopCauseEffect.js +13 -0
  59. package/dist/Fx/combinators/filterMapLoopEffect.d.ts +17 -0
  60. package/dist/Fx/combinators/filterMapLoopEffect.d.ts.map +1 -0
  61. package/dist/Fx/combinators/filterMapLoopEffect.js +13 -0
  62. package/dist/Fx/combinators/flatMap.d.ts +23 -0
  63. package/dist/Fx/combinators/flatMap.d.ts.map +1 -0
  64. package/dist/Fx/combinators/flatMap.js +21 -0
  65. package/dist/Fx/combinators/flatMapConcurrently.d.ts +12 -0
  66. package/dist/Fx/combinators/flatMapConcurrently.d.ts.map +1 -0
  67. package/dist/Fx/combinators/flatMapConcurrently.js +22 -0
  68. package/dist/Fx/combinators/flatMapConcurrentlyEffect.d.ts +12 -0
  69. package/dist/Fx/combinators/flatMapConcurrentlyEffect.d.ts.map +1 -0
  70. package/dist/Fx/combinators/flatMapConcurrentlyEffect.js +13 -0
  71. package/dist/Fx/combinators/flatMapEffect.d.ts +24 -0
  72. package/dist/Fx/combinators/flatMapEffect.d.ts.map +1 -0
  73. package/dist/Fx/combinators/flatMapEffect.js +14 -0
  74. package/dist/Fx/combinators/flip.d.ts +11 -0
  75. package/dist/Fx/combinators/flip.d.ts.map +1 -0
  76. package/dist/Fx/combinators/flip.js +11 -0
  77. package/dist/Fx/combinators/gen.d.ts +20 -0
  78. package/dist/Fx/combinators/gen.d.ts.map +1 -0
  79. package/dist/Fx/combinators/gen.js +14 -0
  80. package/dist/Fx/combinators/genScoped.d.ts +20 -0
  81. package/dist/Fx/combinators/genScoped.d.ts.map +1 -0
  82. package/dist/Fx/combinators/genScoped.js +13 -0
  83. package/dist/Fx/combinators/index.d.ts +52 -0
  84. package/dist/Fx/combinators/index.d.ts.map +1 -0
  85. package/dist/Fx/combinators/index.js +51 -0
  86. package/dist/Fx/combinators/keyed.d.ts +44 -0
  87. package/dist/Fx/combinators/keyed.d.ts.map +1 -0
  88. package/dist/Fx/combinators/keyed.js +199 -0
  89. package/dist/Fx/combinators/loop.d.ts +16 -0
  90. package/dist/Fx/combinators/loop.d.ts.map +1 -0
  91. package/dist/Fx/combinators/loop.js +14 -0
  92. package/dist/Fx/combinators/loopCause.d.ts +16 -0
  93. package/dist/Fx/combinators/loopCause.d.ts.map +1 -0
  94. package/dist/Fx/combinators/loopCause.js +13 -0
  95. package/dist/Fx/combinators/loopCauseEffect.d.ts +17 -0
  96. package/dist/Fx/combinators/loopCauseEffect.d.ts.map +1 -0
  97. package/dist/Fx/combinators/loopCauseEffect.js +13 -0
  98. package/dist/Fx/combinators/loopEffect.d.ts +16 -0
  99. package/dist/Fx/combinators/loopEffect.d.ts.map +1 -0
  100. package/dist/Fx/combinators/loopEffect.js +13 -0
  101. package/dist/Fx/combinators/map.d.ts +14 -0
  102. package/dist/Fx/combinators/map.d.ts.map +1 -0
  103. package/dist/Fx/combinators/map.js +12 -0
  104. package/dist/Fx/combinators/mapEffect.d.ts +15 -0
  105. package/dist/Fx/combinators/mapEffect.d.ts.map +1 -0
  106. package/dist/Fx/combinators/mapEffect.js +12 -0
  107. package/dist/Fx/combinators/mergeAll.d.ts +11 -0
  108. package/dist/Fx/combinators/mergeAll.d.ts.map +1 -0
  109. package/dist/Fx/combinators/mergeAll.js +15 -0
  110. package/dist/Fx/combinators/mergeOrdered.d.ts +14 -0
  111. package/dist/Fx/combinators/mergeOrdered.d.ts.map +1 -0
  112. package/dist/Fx/combinators/mergeOrdered.js +89 -0
  113. package/dist/Fx/combinators/onError.d.ts +17 -0
  114. package/dist/Fx/combinators/onError.d.ts.map +1 -0
  115. package/dist/Fx/combinators/onError.js +14 -0
  116. package/dist/Fx/combinators/onExit.d.ts +16 -0
  117. package/dist/Fx/combinators/onExit.d.ts.map +1 -0
  118. package/dist/Fx/combinators/onExit.js +39 -0
  119. package/dist/Fx/combinators/onInterrupt.d.ts +16 -0
  120. package/dist/Fx/combinators/onInterrupt.d.ts.map +1 -0
  121. package/dist/Fx/combinators/onInterrupt.js +38 -0
  122. package/dist/Fx/combinators/provide.d.ts +23 -0
  123. package/dist/Fx/combinators/provide.d.ts.map +1 -0
  124. package/dist/Fx/combinators/provide.js +27 -0
  125. package/dist/Fx/combinators/skip.d.ts +14 -0
  126. package/dist/Fx/combinators/skip.d.ts.map +1 -0
  127. package/dist/Fx/combinators/skip.js +11 -0
  128. package/dist/Fx/combinators/skipRepeats.d.ts +11 -0
  129. package/dist/Fx/combinators/skipRepeats.d.ts.map +1 -0
  130. package/dist/Fx/combinators/skipRepeats.js +12 -0
  131. package/dist/Fx/combinators/skipRepeatsWith.d.ts +12 -0
  132. package/dist/Fx/combinators/skipRepeatsWith.d.ts.map +1 -0
  133. package/dist/Fx/combinators/skipRepeatsWith.js +20 -0
  134. package/dist/Fx/combinators/slice.d.ts +23 -0
  135. package/dist/Fx/combinators/slice.d.ts.map +1 -0
  136. package/dist/Fx/combinators/slice.js +12 -0
  137. package/dist/Fx/combinators/switchMap.d.ts +13 -0
  138. package/dist/Fx/combinators/switchMap.d.ts.map +1 -0
  139. package/dist/Fx/combinators/switchMap.js +33 -0
  140. package/dist/Fx/combinators/switchMapEffect.d.ts +13 -0
  141. package/dist/Fx/combinators/switchMapEffect.d.ts.map +1 -0
  142. package/dist/Fx/combinators/switchMapEffect.js +14 -0
  143. package/dist/Fx/combinators/take.d.ts +14 -0
  144. package/dist/Fx/combinators/take.d.ts.map +1 -0
  145. package/dist/Fx/combinators/take.js +11 -0
  146. package/dist/Fx/combinators/takeUntil.d.ts +28 -0
  147. package/dist/Fx/combinators/takeUntil.d.ts.map +1 -0
  148. package/dist/Fx/combinators/takeUntil.js +31 -0
  149. package/dist/Fx/combinators/tapEffect.d.ts +15 -0
  150. package/dist/Fx/combinators/tapEffect.d.ts.map +1 -0
  151. package/dist/Fx/combinators/tapEffect.js +18 -0
  152. package/dist/Fx/combinators/tuple.d.ts +27 -0
  153. package/dist/Fx/combinators/tuple.d.ts.map +1 -0
  154. package/dist/Fx/combinators/tuple.js +46 -0
  155. package/dist/Fx/combinators/unwrap.d.ts +12 -0
  156. package/dist/Fx/combinators/unwrap.d.ts.map +1 -0
  157. package/dist/Fx/combinators/unwrap.js +14 -0
  158. package/dist/Fx/combinators/unwrapScoped.d.ts +15 -0
  159. package/dist/Fx/combinators/unwrapScoped.d.ts.map +1 -0
  160. package/dist/Fx/combinators/unwrapScoped.js +16 -0
  161. package/dist/Fx/combinators/when.d.ts +36 -0
  162. package/dist/Fx/combinators/when.d.ts.map +1 -0
  163. package/dist/Fx/combinators/when.js +28 -0
  164. package/dist/Fx/combinators/withSpan.d.ts +4 -0
  165. package/dist/Fx/combinators/withSpan.d.ts.map +1 -0
  166. package/dist/Fx/combinators/withSpan.js +6 -0
  167. package/dist/Fx/constructors/at.d.ts +16 -0
  168. package/dist/Fx/constructors/at.d.ts.map +1 -0
  169. package/dist/Fx/constructors/at.js +13 -0
  170. package/dist/Fx/constructors/die.d.ts +11 -0
  171. package/dist/Fx/constructors/die.d.ts.map +1 -0
  172. package/dist/Fx/constructors/die.js +12 -0
  173. package/dist/Fx/constructors/empty.d.ts +8 -0
  174. package/dist/Fx/constructors/empty.d.ts.map +1 -0
  175. package/dist/Fx/constructors/empty.js +8 -0
  176. package/dist/Fx/constructors/fail.d.ts +11 -0
  177. package/dist/Fx/constructors/fail.d.ts.map +1 -0
  178. package/dist/Fx/constructors/fail.js +12 -0
  179. package/dist/Fx/constructors/failCause.d.ts +12 -0
  180. package/dist/Fx/constructors/failCause.d.ts.map +1 -0
  181. package/dist/Fx/constructors/failCause.js +11 -0
  182. package/dist/Fx/constructors/fn.d.ts +47 -0
  183. package/dist/Fx/constructors/fn.d.ts.map +1 -0
  184. package/dist/Fx/constructors/fn.js +23 -0
  185. package/dist/Fx/constructors/fromEffect.d.ts +21 -0
  186. package/dist/Fx/constructors/fromEffect.d.ts.map +1 -0
  187. package/dist/Fx/constructors/fromEffect.js +21 -0
  188. package/dist/Fx/constructors/fromFailures.d.ts +10 -0
  189. package/dist/Fx/constructors/fromFailures.d.ts.map +1 -0
  190. package/dist/Fx/constructors/fromFailures.js +13 -0
  191. package/dist/Fx/constructors/fromIterable.d.ts +12 -0
  192. package/dist/Fx/constructors/fromIterable.d.ts.map +1 -0
  193. package/dist/Fx/constructors/fromIterable.js +12 -0
  194. package/dist/Fx/constructors/fromSchedule.d.ts +13 -0
  195. package/dist/Fx/constructors/fromSchedule.d.ts.map +1 -0
  196. package/dist/Fx/constructors/fromSchedule.js +13 -0
  197. package/dist/Fx/constructors/fromYieldable.d.ts +12 -0
  198. package/dist/Fx/constructors/fromYieldable.d.ts.map +1 -0
  199. package/dist/Fx/constructors/fromYieldable.js +12 -0
  200. package/dist/Fx/constructors/index.d.ts +16 -0
  201. package/dist/Fx/constructors/index.d.ts.map +1 -0
  202. package/dist/Fx/constructors/index.js +15 -0
  203. package/dist/Fx/constructors/interrupt.d.ts +10 -0
  204. package/dist/Fx/constructors/interrupt.d.ts.map +1 -0
  205. package/dist/Fx/constructors/interrupt.js +12 -0
  206. package/dist/Fx/constructors/make.d.ts +40 -0
  207. package/dist/Fx/constructors/make.d.ts.map +1 -0
  208. package/dist/Fx/constructors/make.js +61 -0
  209. package/dist/Fx/constructors/periodic.d.ts +12 -0
  210. package/dist/Fx/constructors/periodic.d.ts.map +1 -0
  211. package/dist/Fx/constructors/periodic.js +12 -0
  212. package/dist/Fx/constructors/succeed.d.ts +32 -0
  213. package/dist/Fx/constructors/succeed.d.ts.map +1 -0
  214. package/dist/Fx/constructors/succeed.js +32 -0
  215. package/dist/Fx/constructors/suspend.d.ts +3 -0
  216. package/dist/Fx/constructors/suspend.d.ts.map +1 -0
  217. package/dist/Fx/constructors/suspend.js +3 -0
  218. package/dist/Fx/index.d.ts +7 -0
  219. package/dist/Fx/index.d.ts.map +1 -0
  220. package/dist/Fx/index.js +6 -0
  221. package/dist/Fx/internal/DeferredRef.d.ts +29 -0
  222. package/dist/Fx/internal/DeferredRef.d.ts.map +1 -0
  223. package/dist/{esm → Fx}/internal/DeferredRef.js +21 -15
  224. package/dist/Fx/internal/UnionToTuple.d.ts.map +1 -0
  225. package/dist/Fx/internal/UnionToTuple.js +1 -0
  226. package/dist/{dts → Fx}/internal/diff.d.ts +3 -1
  227. package/dist/Fx/internal/diff.d.ts.map +1 -0
  228. package/dist/{esm → Fx}/internal/diff.js +37 -23
  229. package/dist/Fx/internal/equivalence.d.ts +4 -0
  230. package/dist/Fx/internal/equivalence.d.ts.map +1 -0
  231. package/dist/Fx/internal/equivalence.js +10 -0
  232. package/dist/Fx/internal/multicast.d.ts +10 -0
  233. package/dist/Fx/internal/multicast.d.ts.map +1 -0
  234. package/dist/Fx/internal/multicast.js +32 -0
  235. package/dist/Fx/internal/ring-buffer.d.ts +14 -0
  236. package/dist/Fx/internal/ring-buffer.d.ts.map +1 -0
  237. package/dist/Fx/internal/ring-buffer.js +52 -0
  238. package/dist/Fx/internal/scope.d.ts +11 -0
  239. package/dist/Fx/internal/scope.d.ts.map +1 -0
  240. package/dist/Fx/internal/scope.js +12 -0
  241. package/dist/Fx/internal/yieldable.d.ts +17 -0
  242. package/dist/Fx/internal/yieldable.d.ts.map +1 -0
  243. package/dist/Fx/internal/yieldable.js +20 -0
  244. package/dist/Fx/run/collect.d.ts +45 -0
  245. package/dist/Fx/run/collect.d.ts.map +1 -0
  246. package/dist/Fx/run/collect.js +51 -0
  247. package/dist/Fx/run/first.d.ts +14 -0
  248. package/dist/Fx/run/first.d.ts.map +1 -0
  249. package/dist/Fx/run/first.js +16 -0
  250. package/dist/Fx/run/fork.d.ts +29 -0
  251. package/dist/Fx/run/fork.d.ts.map +1 -0
  252. package/dist/Fx/run/fork.js +27 -0
  253. package/dist/Fx/run/index.d.ts +6 -0
  254. package/dist/Fx/run/index.d.ts.map +1 -0
  255. package/dist/Fx/run/index.js +5 -0
  256. package/dist/Fx/run/observe.d.ts +53 -0
  257. package/dist/Fx/run/observe.d.ts.map +1 -0
  258. package/dist/Fx/run/observe.js +55 -0
  259. package/dist/Fx/run/runPromise.d.ts +25 -0
  260. package/dist/Fx/run/runPromise.d.ts.map +1 -0
  261. package/dist/Fx/run/runPromise.js +23 -0
  262. package/dist/Fx/stream.d.ts +7 -0
  263. package/dist/Fx/stream.d.ts.map +1 -0
  264. package/dist/Fx/stream.js +7 -0
  265. package/dist/Fx.d.ts +2 -0
  266. package/dist/Fx.d.ts.map +1 -0
  267. package/dist/Fx.js +1 -0
  268. package/dist/Push/Push.d.ts +312 -0
  269. package/dist/Push/Push.d.ts.map +1 -0
  270. package/dist/Push/Push.js +289 -0
  271. package/dist/Push/index.d.ts +2 -0
  272. package/dist/Push/index.d.ts.map +1 -0
  273. package/dist/Push/index.js +1 -0
  274. package/dist/Push.d.ts +2 -0
  275. package/dist/Push.d.ts.map +1 -0
  276. package/dist/Push.js +1 -0
  277. package/dist/{dts → RefSubject}/RefArray.d.ts +68 -18
  278. package/dist/RefSubject/RefArray.d.ts.map +1 -0
  279. package/dist/{esm → RefSubject}/RefArray.js +80 -12
  280. package/dist/RefSubject/RefBigDecimal.d.ts +183 -0
  281. package/dist/RefSubject/RefBigDecimal.d.ts.map +1 -0
  282. package/dist/RefSubject/RefBigDecimal.js +161 -0
  283. package/dist/RefSubject/RefBigInt.d.ts +138 -0
  284. package/dist/RefSubject/RefBigInt.d.ts.map +1 -0
  285. package/dist/RefSubject/RefBigInt.js +126 -0
  286. package/dist/RefSubject/RefBoolean.d.ts +135 -0
  287. package/dist/RefSubject/RefBoolean.d.ts.map +1 -0
  288. package/dist/RefSubject/RefBoolean.js +124 -0
  289. package/dist/RefSubject/RefCause.d.ts +100 -0
  290. package/dist/RefSubject/RefCause.d.ts.map +1 -0
  291. package/dist/RefSubject/RefCause.js +93 -0
  292. package/dist/{dts → RefSubject}/RefChunk.d.ts +157 -71
  293. package/dist/RefSubject/RefChunk.d.ts.map +1 -0
  294. package/dist/{esm → RefSubject}/RefChunk.js +142 -52
  295. package/dist/RefSubject/RefDateTime.d.ts +155 -0
  296. package/dist/RefSubject/RefDateTime.d.ts.map +1 -0
  297. package/dist/RefSubject/RefDateTime.js +101 -0
  298. package/dist/RefSubject/RefDuration.d.ts +126 -0
  299. package/dist/RefSubject/RefDuration.d.ts.map +1 -0
  300. package/dist/RefSubject/RefDuration.js +115 -0
  301. package/dist/RefSubject/RefGraph.d.ts +239 -0
  302. package/dist/RefSubject/RefGraph.d.ts.map +1 -0
  303. package/dist/RefSubject/RefGraph.js +272 -0
  304. package/dist/RefSubject/RefHashMap.d.ts +228 -0
  305. package/dist/RefSubject/RefHashMap.d.ts.map +1 -0
  306. package/dist/RefSubject/RefHashMap.js +212 -0
  307. package/dist/RefSubject/RefHashRing.d.ts +123 -0
  308. package/dist/RefSubject/RefHashRing.d.ts.map +1 -0
  309. package/dist/RefSubject/RefHashRing.js +115 -0
  310. package/dist/RefSubject/RefHashSet.d.ts +179 -0
  311. package/dist/RefSubject/RefHashSet.d.ts.map +1 -0
  312. package/dist/RefSubject/RefHashSet.js +164 -0
  313. package/dist/RefSubject/RefIterable.d.ts +257 -0
  314. package/dist/RefSubject/RefIterable.d.ts.map +1 -0
  315. package/dist/RefSubject/RefIterable.js +237 -0
  316. package/dist/RefSubject/RefOption.d.ts +124 -0
  317. package/dist/RefSubject/RefOption.d.ts.map +1 -0
  318. package/dist/RefSubject/RefOption.js +115 -0
  319. package/dist/RefSubject/RefRecord.d.ts +264 -0
  320. package/dist/RefSubject/RefRecord.d.ts.map +1 -0
  321. package/dist/RefSubject/RefRecord.js +249 -0
  322. package/dist/RefSubject/RefResult.d.ts +121 -0
  323. package/dist/RefSubject/RefResult.d.ts.map +1 -0
  324. package/dist/RefSubject/RefResult.js +107 -0
  325. package/dist/RefSubject/RefString.d.ts +147 -0
  326. package/dist/RefSubject/RefString.d.ts.map +1 -0
  327. package/dist/RefSubject/RefString.js +137 -0
  328. package/dist/RefSubject/RefStruct.d.ts +123 -0
  329. package/dist/RefSubject/RefStruct.d.ts.map +1 -0
  330. package/dist/RefSubject/RefStruct.js +113 -0
  331. package/dist/RefSubject/RefSubject.d.ts +1010 -0
  332. package/dist/RefSubject/RefSubject.d.ts.map +1 -0
  333. package/dist/RefSubject/RefSubject.js +1310 -0
  334. package/dist/RefSubject/RefTrie.d.ts +216 -0
  335. package/dist/RefSubject/RefTrie.d.ts.map +1 -0
  336. package/dist/RefSubject/RefTrie.js +201 -0
  337. package/dist/RefSubject/RefTuple.d.ts +107 -0
  338. package/dist/RefSubject/RefTuple.d.ts.map +1 -0
  339. package/dist/RefSubject/RefTuple.js +94 -0
  340. package/dist/RefSubject/index.d.ts +22 -0
  341. package/dist/RefSubject/index.d.ts.map +1 -0
  342. package/dist/RefSubject/index.js +21 -0
  343. package/dist/RefSubject.d.ts +2 -0
  344. package/dist/RefSubject.d.ts.map +1 -0
  345. package/dist/RefSubject.js +1 -0
  346. package/dist/Sink/Sink.d.ts +94 -0
  347. package/dist/Sink/Sink.d.ts.map +1 -0
  348. package/dist/Sink/Sink.js +34 -0
  349. package/dist/Sink/combinators.d.ts +171 -0
  350. package/dist/Sink/combinators.d.ts.map +1 -0
  351. package/dist/{esm/Sink.js → Sink/combinators.js} +265 -352
  352. package/dist/Sink/index.d.ts +3 -0
  353. package/dist/Sink/index.d.ts.map +1 -0
  354. package/dist/Sink/index.js +2 -0
  355. package/dist/Sink.d.ts +2 -0
  356. package/dist/Sink.d.ts.map +1 -0
  357. package/dist/Sink.js +1 -0
  358. package/dist/Subject/Subject.d.ts +152 -0
  359. package/dist/Subject/Subject.d.ts.map +1 -0
  360. package/dist/Subject/Subject.js +272 -0
  361. package/dist/Subject/index.d.ts +2 -0
  362. package/dist/Subject/index.d.ts.map +1 -0
  363. package/dist/Subject/index.js +1 -0
  364. package/dist/Subject.d.ts +2 -0
  365. package/dist/Subject.d.ts.map +1 -0
  366. package/dist/Subject.js +1 -0
  367. package/dist/Versioned/Versioned.d.ts +176 -0
  368. package/dist/Versioned/Versioned.d.ts.map +1 -0
  369. package/dist/Versioned/Versioned.js +228 -0
  370. package/dist/Versioned/index.d.ts +2 -0
  371. package/dist/Versioned/index.d.ts.map +1 -0
  372. package/dist/Versioned/index.js +1 -0
  373. package/dist/Versioned.d.ts +2 -0
  374. package/dist/Versioned.d.ts.map +1 -0
  375. package/dist/Versioned.js +1 -0
  376. package/dist/index.d.ts +8 -0
  377. package/dist/index.d.ts.map +1 -0
  378. package/dist/index.js +7 -0
  379. package/package.json +19 -192
  380. package/src/Fx/Fx.ts +164 -0
  381. package/src/Fx/TypeId.ts +25 -0
  382. package/src/Fx/combinators/catch.ts +165 -0
  383. package/src/Fx/combinators/causes.ts +23 -0
  384. package/src/Fx/combinators/compact.ts +15 -0
  385. package/src/Fx/combinators/continueWith.ts +78 -0
  386. package/src/Fx/combinators/ensuring.ts +23 -0
  387. package/src/Fx/combinators/exhaustLatestMap.ts +74 -0
  388. package/src/Fx/combinators/exhaustLatestMapEffect.ts +25 -0
  389. package/src/Fx/combinators/exhaustMap.ts +36 -0
  390. package/src/Fx/combinators/exhaustMapEffect.ts +23 -0
  391. package/src/Fx/combinators/exit.ts +15 -0
  392. package/src/Fx/combinators/filter.ts +22 -0
  393. package/src/Fx/combinators/filterEffect.ts +31 -0
  394. package/src/Fx/combinators/filterMap.ts +23 -0
  395. package/src/Fx/combinators/filterMapEffect.ts +32 -0
  396. package/src/Fx/combinators/filterMapLoop.ts +35 -0
  397. package/src/Fx/combinators/filterMapLoopCause.ts +36 -0
  398. package/src/Fx/combinators/filterMapLoopCauseEffect.ts +46 -0
  399. package/src/Fx/combinators/filterMapLoopEffect.ts +36 -0
  400. package/src/Fx/combinators/flatMap.ts +51 -0
  401. package/src/Fx/combinators/flatMapConcurrently.ts +36 -0
  402. package/src/Fx/combinators/flatMapConcurrentlyEffect.ts +26 -0
  403. package/src/Fx/combinators/flatMapEffect.ts +42 -0
  404. package/src/Fx/combinators/flip.ts +14 -0
  405. package/src/Fx/combinators/gen.ts +24 -0
  406. package/src/Fx/combinators/genScoped.ts +24 -0
  407. package/src/Fx/combinators/index.ts +51 -0
  408. package/src/Fx/combinators/keyed.ts +369 -0
  409. package/src/Fx/combinators/loop.ts +27 -0
  410. package/src/Fx/combinators/loopCause.ts +34 -0
  411. package/src/Fx/combinators/loopCauseEffect.ts +36 -0
  412. package/src/Fx/combinators/loopEffect.ts +34 -0
  413. package/src/Fx/combinators/map.ts +22 -0
  414. package/src/Fx/combinators/mapEffect.ts +32 -0
  415. package/src/Fx/combinators/mergeAll.ts +22 -0
  416. package/src/Fx/combinators/mergeOrdered.ts +123 -0
  417. package/src/Fx/combinators/onError.ts +40 -0
  418. package/src/Fx/combinators/onExit.ts +82 -0
  419. package/src/Fx/combinators/onInterrupt.ts +87 -0
  420. package/src/Fx/combinators/provide.ts +62 -0
  421. package/src/Fx/combinators/skip.ts +20 -0
  422. package/src/Fx/combinators/skipRepeats.ts +15 -0
  423. package/src/Fx/combinators/skipRepeatsWith.ts +40 -0
  424. package/src/Fx/combinators/slice.ts +32 -0
  425. package/src/Fx/combinators/switchMap.ts +55 -0
  426. package/src/Fx/combinators/switchMapEffect.ts +25 -0
  427. package/src/Fx/combinators/take.ts +17 -0
  428. package/src/Fx/combinators/takeUntil.ts +50 -0
  429. package/src/Fx/combinators/tapEffect.ts +39 -0
  430. package/src/Fx/combinators/tuple.ts +79 -0
  431. package/src/Fx/combinators/unwrap.ts +21 -0
  432. package/src/Fx/combinators/unwrapScoped.ts +26 -0
  433. package/src/Fx/combinators/when.ts +64 -0
  434. package/src/Fx/combinators/withSpan.ts +24 -0
  435. package/src/Fx/constructors/at.ts +23 -0
  436. package/src/Fx/constructors/die.ts +17 -0
  437. package/src/Fx/constructors/empty.ts +10 -0
  438. package/src/Fx/constructors/fail.ts +14 -0
  439. package/src/Fx/constructors/failCause.ts +14 -0
  440. package/src/Fx/constructors/fn.ts +245 -0
  441. package/src/Fx/constructors/fromEffect.ts +24 -0
  442. package/src/Fx/constructors/fromFailures.ts +19 -0
  443. package/src/Fx/constructors/fromIterable.ts +15 -0
  444. package/src/Fx/constructors/fromSchedule.ts +18 -0
  445. package/src/Fx/constructors/fromYieldable.ts +17 -0
  446. package/src/Fx/constructors/index.ts +15 -0
  447. package/src/Fx/constructors/interrupt.ts +13 -0
  448. package/src/Fx/constructors/make.ts +103 -0
  449. package/src/Fx/constructors/periodic.ts +15 -0
  450. package/src/Fx/constructors/succeed.ts +37 -0
  451. package/src/Fx/constructors/suspend.ts +6 -0
  452. package/src/Fx/index.ts +6 -0
  453. package/src/Fx/internal/DeferredRef.ts +87 -0
  454. package/src/Fx/internal/UnionToTuple.ts +12 -0
  455. package/src/Fx/internal/diff.ts +191 -0
  456. package/src/Fx/internal/equivalence.ts +12 -0
  457. package/src/Fx/internal/multicast.ts +51 -0
  458. package/src/Fx/internal/ring-buffer.ts +60 -0
  459. package/src/Fx/internal/scope.ts +58 -0
  460. package/src/Fx/internal/yieldable.ts +31 -0
  461. package/src/Fx/run/collect.ts +79 -0
  462. package/src/Fx/run/first.ts +20 -0
  463. package/src/Fx/run/fork.ts +40 -0
  464. package/src/Fx/run/index.ts +5 -0
  465. package/src/Fx/run/observe.ts +114 -0
  466. package/src/Fx/run/runPromise.ts +32 -0
  467. package/src/Fx/stream.ts +42 -0
  468. package/src/Fx.catch.test.ts +61 -0
  469. package/src/Fx.fn.test.ts +51 -0
  470. package/src/Fx.lifecycle.test.ts +80 -0
  471. package/src/Fx.test.ts +71 -0
  472. package/src/Fx.ts +1 -2591
  473. package/src/Push/Push.ts +903 -0
  474. package/src/Push/index.ts +1 -0
  475. package/src/Push.test.ts +26 -0
  476. package/src/Push.ts +1 -480
  477. package/src/{RefArray.ts → RefSubject/RefArray.ts} +246 -248
  478. package/src/RefSubject/RefBigDecimal.test.ts +56 -0
  479. package/src/RefSubject/RefBigDecimal.ts +295 -0
  480. package/src/RefSubject/RefBigInt.test.ts +56 -0
  481. package/src/RefSubject/RefBigInt.ts +189 -0
  482. package/src/RefSubject/RefBoolean.test.ts +57 -0
  483. package/src/RefSubject/RefBoolean.ts +185 -0
  484. package/src/RefSubject/RefCause.test.ts +53 -0
  485. package/src/RefSubject/RefCause.ts +146 -0
  486. package/src/RefSubject/RefChunk.ts +510 -0
  487. package/src/RefSubject/RefDateTime.test.ts +43 -0
  488. package/src/RefSubject/RefDateTime.ts +264 -0
  489. package/src/RefSubject/RefDuration.test.ts +49 -0
  490. package/src/RefSubject/RefDuration.ts +188 -0
  491. package/src/RefSubject/RefGraph.ts +650 -0
  492. package/src/RefSubject/RefHashMap.ts +465 -0
  493. package/src/RefSubject/RefHashRing.ts +262 -0
  494. package/src/RefSubject/RefHashSet.ts +308 -0
  495. package/src/RefSubject/RefIterable.ts +445 -0
  496. package/src/RefSubject/RefOption.test.ts +67 -0
  497. package/src/RefSubject/RefOption.ts +193 -0
  498. package/src/RefSubject/RefRecord.ts +612 -0
  499. package/src/RefSubject/RefResult.test.ts +63 -0
  500. package/src/RefSubject/RefResult.ts +209 -0
  501. package/src/RefSubject/RefString.test.ts +61 -0
  502. package/src/RefSubject/RefString.ts +256 -0
  503. package/src/RefSubject/RefStruct.test.ts +60 -0
  504. package/src/RefSubject/RefStruct.ts +253 -0
  505. package/src/RefSubject/RefSubject.ts +2545 -0
  506. package/src/RefSubject/RefTrie.ts +356 -0
  507. package/src/RefSubject/RefTuple.test.ts +60 -0
  508. package/src/RefSubject/RefTuple.ts +231 -0
  509. package/src/RefSubject/index.ts +21 -0
  510. package/src/RefSubject.test.ts +65 -0
  511. package/src/RefSubject.ts +1 -2488
  512. package/src/Sink/Sink.ts +159 -0
  513. package/src/Sink/combinators.ts +993 -0
  514. package/src/Sink/index.ts +2 -0
  515. package/src/Sink.ts +1 -1044
  516. package/src/Subject/Subject.ts +441 -0
  517. package/src/Subject/index.ts +1 -0
  518. package/src/Subject.test.ts +47 -0
  519. package/src/Subject.ts +1 -330
  520. package/src/Versioned/Versioned.ts +521 -0
  521. package/src/Versioned/index.ts +1 -0
  522. package/src/Versioned.test.ts +23 -0
  523. package/src/Versioned.ts +1 -357
  524. package/src/index.ts +7 -130
  525. package/tsconfig.json +6 -0
  526. package/AsyncData/package.json +0 -6
  527. package/Emitter/package.json +0 -6
  528. package/Form/package.json +0 -6
  529. package/FormEntry/package.json +0 -6
  530. package/Fx/package.json +0 -6
  531. package/Idle/package.json +0 -6
  532. package/LICENSE +0 -21
  533. package/Match/package.json +0 -6
  534. package/Pull/package.json +0 -6
  535. package/Push/package.json +0 -6
  536. package/RefArray/package.json +0 -6
  537. package/RefChunk/package.json +0 -6
  538. package/RefHashMap/package.json +0 -6
  539. package/RefHashSet/package.json +0 -6
  540. package/RefSubject/package.json +0 -6
  541. package/Sink/package.json +0 -6
  542. package/Stream/package.json +0 -6
  543. package/Subject/package.json +0 -6
  544. package/TypeId/package.json +0 -6
  545. package/Typeclass/package.json +0 -6
  546. package/Versioned/package.json +0 -6
  547. package/dist/cjs/AsyncData.js +0 -188
  548. package/dist/cjs/AsyncData.js.map +0 -1
  549. package/dist/cjs/Emitter.js +0 -44
  550. package/dist/cjs/Emitter.js.map +0 -1
  551. package/dist/cjs/Form.js +0 -178
  552. package/dist/cjs/Form.js.map +0 -1
  553. package/dist/cjs/FormEntry.js +0 -110
  554. package/dist/cjs/FormEntry.js.map +0 -1
  555. package/dist/cjs/Fx.js +0 -998
  556. package/dist/cjs/Fx.js.map +0 -1
  557. package/dist/cjs/Idle.js +0 -190
  558. package/dist/cjs/Idle.js.map +0 -1
  559. package/dist/cjs/Match.js +0 -191
  560. package/dist/cjs/Match.js.map +0 -1
  561. package/dist/cjs/Pull.js +0 -52
  562. package/dist/cjs/Pull.js.map +0 -1
  563. package/dist/cjs/Push.js +0 -168
  564. package/dist/cjs/Push.js.map +0 -1
  565. package/dist/cjs/RefArray.js +0 -253
  566. package/dist/cjs/RefArray.js.map +0 -1
  567. package/dist/cjs/RefChunk.js +0 -212
  568. package/dist/cjs/RefChunk.js.map +0 -1
  569. package/dist/cjs/RefHashMap.js +0 -198
  570. package/dist/cjs/RefHashMap.js.map +0 -1
  571. package/dist/cjs/RefHashSet.js +0 -99
  572. package/dist/cjs/RefHashSet.js.map +0 -1
  573. package/dist/cjs/RefSubject.js +0 -1115
  574. package/dist/cjs/RefSubject.js.map +0 -1
  575. package/dist/cjs/Sink.js +0 -662
  576. package/dist/cjs/Sink.js.map +0 -1
  577. package/dist/cjs/Stream.js +0 -87
  578. package/dist/cjs/Stream.js.map +0 -1
  579. package/dist/cjs/Subject.js +0 -205
  580. package/dist/cjs/Subject.js.map +0 -1
  581. package/dist/cjs/TypeId.js +0 -32
  582. package/dist/cjs/TypeId.js.map +0 -1
  583. package/dist/cjs/Typeclass.js +0 -380
  584. package/dist/cjs/Typeclass.js.map +0 -1
  585. package/dist/cjs/Versioned.js +0 -172
  586. package/dist/cjs/Versioned.js.map +0 -1
  587. package/dist/cjs/index.js +0 -89
  588. package/dist/cjs/index.js.map +0 -1
  589. package/dist/cjs/internal/DeferredRef.js +0 -67
  590. package/dist/cjs/internal/DeferredRef.js.map +0 -1
  591. package/dist/cjs/internal/UnionToTuple.js +0 -6
  592. package/dist/cjs/internal/UnionToTuple.js.map +0 -1
  593. package/dist/cjs/internal/bounds.js +0 -26
  594. package/dist/cjs/internal/bounds.js.map +0 -1
  595. package/dist/cjs/internal/core.js +0 -1783
  596. package/dist/cjs/internal/core.js.map +0 -1
  597. package/dist/cjs/internal/diff.js +0 -122
  598. package/dist/cjs/internal/diff.js.map +0 -1
  599. package/dist/cjs/internal/effect-loop-operator.js +0 -288
  600. package/dist/cjs/internal/effect-loop-operator.js.map +0 -1
  601. package/dist/cjs/internal/effect-operator.js +0 -156
  602. package/dist/cjs/internal/effect-operator.js.map +0 -1
  603. package/dist/cjs/internal/effect-producer.js +0 -74
  604. package/dist/cjs/internal/effect-producer.js.map +0 -1
  605. package/dist/cjs/internal/helpers.js +0 -317
  606. package/dist/cjs/internal/helpers.js.map +0 -1
  607. package/dist/cjs/internal/keyed.js +0 -168
  608. package/dist/cjs/internal/keyed.js.map +0 -1
  609. package/dist/cjs/internal/loop-operator.js +0 -213
  610. package/dist/cjs/internal/loop-operator.js.map +0 -1
  611. package/dist/cjs/internal/operator.js +0 -79
  612. package/dist/cjs/internal/operator.js.map +0 -1
  613. package/dist/cjs/internal/protos.js +0 -48
  614. package/dist/cjs/internal/protos.js.map +0 -1
  615. package/dist/cjs/internal/provide.js +0 -100
  616. package/dist/cjs/internal/provide.js.map +0 -1
  617. package/dist/cjs/internal/requestIdleCallback.js +0 -22
  618. package/dist/cjs/internal/requestIdleCallback.js.map +0 -1
  619. package/dist/cjs/internal/share.js +0 -74
  620. package/dist/cjs/internal/share.js.map +0 -1
  621. package/dist/cjs/internal/strategies.js +0 -34
  622. package/dist/cjs/internal/strategies.js.map +0 -1
  623. package/dist/cjs/internal/sync-operator.js +0 -120
  624. package/dist/cjs/internal/sync-operator.js.map +0 -1
  625. package/dist/cjs/internal/sync-producer.js +0 -118
  626. package/dist/cjs/internal/sync-producer.js.map +0 -1
  627. package/dist/cjs/internal/withKey.js +0 -63
  628. package/dist/cjs/internal/withKey.js.map +0 -1
  629. package/dist/dts/AsyncData.d.ts +0 -179
  630. package/dist/dts/AsyncData.d.ts.map +0 -1
  631. package/dist/dts/Emitter.d.ts +0 -24
  632. package/dist/dts/Emitter.d.ts.map +0 -1
  633. package/dist/dts/Form.d.ts +0 -145
  634. package/dist/dts/Form.d.ts.map +0 -1
  635. package/dist/dts/FormEntry.d.ts +0 -65
  636. package/dist/dts/FormEntry.d.ts.map +0 -1
  637. package/dist/dts/Fx.d.ts +0 -1678
  638. package/dist/dts/Fx.d.ts.map +0 -1
  639. package/dist/dts/Idle.d.ts +0 -84
  640. package/dist/dts/Idle.d.ts.map +0 -1
  641. package/dist/dts/Match.d.ts +0 -60
  642. package/dist/dts/Match.d.ts.map +0 -1
  643. package/dist/dts/Pull.d.ts +0 -37
  644. package/dist/dts/Pull.d.ts.map +0 -1
  645. package/dist/dts/Push.d.ts +0 -176
  646. package/dist/dts/Push.d.ts.map +0 -1
  647. package/dist/dts/RefArray.d.ts.map +0 -1
  648. package/dist/dts/RefChunk.d.ts.map +0 -1
  649. package/dist/dts/RefHashMap.d.ts +0 -189
  650. package/dist/dts/RefHashMap.d.ts.map +0 -1
  651. package/dist/dts/RefHashSet.d.ts +0 -100
  652. package/dist/dts/RefHashSet.d.ts.map +0 -1
  653. package/dist/dts/RefSubject.d.ts +0 -601
  654. package/dist/dts/RefSubject.d.ts.map +0 -1
  655. package/dist/dts/Sink.d.ts +0 -252
  656. package/dist/dts/Sink.d.ts.map +0 -1
  657. package/dist/dts/Stream.d.ts +0 -66
  658. package/dist/dts/Stream.d.ts.map +0 -1
  659. package/dist/dts/Subject.d.ts +0 -61
  660. package/dist/dts/Subject.d.ts.map +0 -1
  661. package/dist/dts/TypeId.d.ts +0 -51
  662. package/dist/dts/TypeId.d.ts.map +0 -1
  663. package/dist/dts/Typeclass.d.ts +0 -284
  664. package/dist/dts/Typeclass.d.ts.map +0 -1
  665. package/dist/dts/Versioned.d.ts +0 -117
  666. package/dist/dts/Versioned.d.ts.map +0 -1
  667. package/dist/dts/index.d.ts +0 -111
  668. package/dist/dts/index.d.ts.map +0 -1
  669. package/dist/dts/internal/DeferredRef.d.ts +0 -22
  670. package/dist/dts/internal/DeferredRef.d.ts.map +0 -1
  671. package/dist/dts/internal/UnionToTuple.d.ts.map +0 -1
  672. package/dist/dts/internal/bounds.d.ts +0 -9
  673. package/dist/dts/internal/bounds.d.ts.map +0 -1
  674. package/dist/dts/internal/core.d.ts +0 -237
  675. package/dist/dts/internal/core.d.ts.map +0 -1
  676. package/dist/dts/internal/diff.d.ts.map +0 -1
  677. package/dist/dts/internal/effect-loop-operator.d.ts +0 -34
  678. package/dist/dts/internal/effect-loop-operator.d.ts.map +0 -1
  679. package/dist/dts/internal/effect-operator.d.ts +0 -40
  680. package/dist/dts/internal/effect-operator.d.ts.map +0 -1
  681. package/dist/dts/internal/effect-producer.d.ts +0 -25
  682. package/dist/dts/internal/effect-producer.d.ts.map +0 -1
  683. package/dist/dts/internal/helpers.d.ts +0 -60
  684. package/dist/dts/internal/helpers.d.ts.map +0 -1
  685. package/dist/dts/internal/keyed.d.ts +0 -4
  686. package/dist/dts/internal/keyed.d.ts.map +0 -1
  687. package/dist/dts/internal/loop-operator.d.ts +0 -40
  688. package/dist/dts/internal/loop-operator.d.ts.map +0 -1
  689. package/dist/dts/internal/operator.d.ts +0 -16
  690. package/dist/dts/internal/operator.d.ts.map +0 -1
  691. package/dist/dts/internal/protos.d.ts +0 -23
  692. package/dist/dts/internal/protos.d.ts.map +0 -1
  693. package/dist/dts/internal/provide.d.ts +0 -46
  694. package/dist/dts/internal/provide.d.ts.map +0 -1
  695. package/dist/dts/internal/requestIdleCallback.d.ts +0 -3
  696. package/dist/dts/internal/requestIdleCallback.d.ts.map +0 -1
  697. package/dist/dts/internal/share.d.ts +0 -33
  698. package/dist/dts/internal/share.d.ts.map +0 -1
  699. package/dist/dts/internal/strategies.d.ts +0 -9
  700. package/dist/dts/internal/strategies.d.ts.map +0 -1
  701. package/dist/dts/internal/sync-operator.d.ts +0 -32
  702. package/dist/dts/internal/sync-operator.d.ts.map +0 -1
  703. package/dist/dts/internal/sync-producer.d.ts +0 -36
  704. package/dist/dts/internal/sync-producer.d.ts.map +0 -1
  705. package/dist/dts/internal/withKey.d.ts +0 -4
  706. package/dist/dts/internal/withKey.d.ts.map +0 -1
  707. package/dist/esm/AsyncData.js +0 -156
  708. package/dist/esm/AsyncData.js.map +0 -1
  709. package/dist/esm/Emitter.js +0 -33
  710. package/dist/esm/Emitter.js.map +0 -1
  711. package/dist/esm/Form.js +0 -163
  712. package/dist/esm/Form.js.map +0 -1
  713. package/dist/esm/FormEntry.js +0 -100
  714. package/dist/esm/FormEntry.js.map +0 -1
  715. package/dist/esm/Fx.js +0 -984
  716. package/dist/esm/Fx.js.map +0 -1
  717. package/dist/esm/Idle.js +0 -178
  718. package/dist/esm/Idle.js.map +0 -1
  719. package/dist/esm/Match.js +0 -185
  720. package/dist/esm/Match.js.map +0 -1
  721. package/dist/esm/Pull.js +0 -41
  722. package/dist/esm/Pull.js.map +0 -1
  723. package/dist/esm/Push.js +0 -159
  724. package/dist/esm/Push.js.map +0 -1
  725. package/dist/esm/RefArray.js.map +0 -1
  726. package/dist/esm/RefChunk.js.map +0 -1
  727. package/dist/esm/RefHashMap.js +0 -176
  728. package/dist/esm/RefHashMap.js.map +0 -1
  729. package/dist/esm/RefHashSet.js +0 -86
  730. package/dist/esm/RefHashSet.js.map +0 -1
  731. package/dist/esm/RefSubject.js +0 -1076
  732. package/dist/esm/RefSubject.js.map +0 -1
  733. package/dist/esm/Sink.js.map +0 -1
  734. package/dist/esm/Stream.js +0 -76
  735. package/dist/esm/Stream.js.map +0 -1
  736. package/dist/esm/Subject.js +0 -198
  737. package/dist/esm/Subject.js.map +0 -1
  738. package/dist/esm/TypeId.js +0 -26
  739. package/dist/esm/TypeId.js.map +0 -1
  740. package/dist/esm/Typeclass.js +0 -375
  741. package/dist/esm/Typeclass.js.map +0 -1
  742. package/dist/esm/Versioned.js +0 -149
  743. package/dist/esm/Versioned.js.map +0 -1
  744. package/dist/esm/index.js +0 -111
  745. package/dist/esm/index.js.map +0 -1
  746. package/dist/esm/internal/DeferredRef.js.map +0 -1
  747. package/dist/esm/internal/UnionToTuple.js +0 -2
  748. package/dist/esm/internal/UnionToTuple.js.map +0 -1
  749. package/dist/esm/internal/bounds.js +0 -13
  750. package/dist/esm/internal/bounds.js.map +0 -1
  751. package/dist/esm/internal/core.js +0 -1647
  752. package/dist/esm/internal/core.js.map +0 -1
  753. package/dist/esm/internal/diff.js.map +0 -1
  754. package/dist/esm/internal/effect-loop-operator.js +0 -269
  755. package/dist/esm/internal/effect-loop-operator.js.map +0 -1
  756. package/dist/esm/internal/effect-operator.js +0 -134
  757. package/dist/esm/internal/effect-operator.js.map +0 -1
  758. package/dist/esm/internal/effect-producer.js +0 -47
  759. package/dist/esm/internal/effect-producer.js.map +0 -1
  760. package/dist/esm/internal/helpers.js +0 -299
  761. package/dist/esm/internal/helpers.js.map +0 -1
  762. package/dist/esm/internal/keyed.js +0 -153
  763. package/dist/esm/internal/keyed.js.map +0 -1
  764. package/dist/esm/internal/loop-operator.js +0 -186
  765. package/dist/esm/internal/loop-operator.js.map +0 -1
  766. package/dist/esm/internal/operator.js +0 -68
  767. package/dist/esm/internal/operator.js.map +0 -1
  768. package/dist/esm/internal/protos.js +0 -39
  769. package/dist/esm/internal/protos.js.map +0 -1
  770. package/dist/esm/internal/provide.js +0 -72
  771. package/dist/esm/internal/provide.js.map +0 -1
  772. package/dist/esm/internal/requestIdleCallback.js +0 -16
  773. package/dist/esm/internal/requestIdleCallback.js.map +0 -1
  774. package/dist/esm/internal/share.js +0 -62
  775. package/dist/esm/internal/share.js.map +0 -1
  776. package/dist/esm/internal/strategies.js +0 -8
  777. package/dist/esm/internal/strategies.js.map +0 -1
  778. package/dist/esm/internal/sync-operator.js +0 -95
  779. package/dist/esm/internal/sync-operator.js.map +0 -1
  780. package/dist/esm/internal/sync-producer.js +0 -90
  781. package/dist/esm/internal/sync-producer.js.map +0 -1
  782. package/dist/esm/internal/withKey.js +0 -56
  783. package/dist/esm/internal/withKey.js.map +0 -1
  784. package/dist/esm/package.json +0 -4
  785. package/src/AsyncData.ts +0 -453
  786. package/src/Emitter.ts +0 -59
  787. package/src/Form.ts +0 -489
  788. package/src/FormEntry.ts +0 -214
  789. package/src/Idle.ts +0 -294
  790. package/src/Match.ts +0 -314
  791. package/src/Pull.ts +0 -95
  792. package/src/RefChunk.ts +0 -407
  793. package/src/RefHashMap.ts +0 -335
  794. package/src/RefHashSet.ts +0 -179
  795. package/src/Stream.ts +0 -140
  796. package/src/TypeId.ts +0 -59
  797. package/src/Typeclass.ts +0 -459
  798. package/src/internal/DeferredRef.ts +0 -72
  799. package/src/internal/UnionToTuple.ts +0 -11
  800. package/src/internal/bounds.ts +0 -21
  801. package/src/internal/core.ts +0 -3091
  802. package/src/internal/diff.ts +0 -171
  803. package/src/internal/effect-loop-operator.ts +0 -466
  804. package/src/internal/effect-operator.ts +0 -317
  805. package/src/internal/effect-producer.ts +0 -125
  806. package/src/internal/helpers.ts +0 -538
  807. package/src/internal/keyed.ts +0 -235
  808. package/src/internal/loop-operator.ts +0 -266
  809. package/src/internal/operator.ts +0 -87
  810. package/src/internal/protos.ts +0 -57
  811. package/src/internal/provide.ts +0 -151
  812. package/src/internal/requestIdleCallback.ts +0 -19
  813. package/src/internal/share.ts +0 -97
  814. package/src/internal/strategies.ts +0 -15
  815. package/src/internal/sync-operator.ts +0 -166
  816. package/src/internal/sync-producer.ts +0 -148
  817. package/src/internal/withKey.ts +0 -82
  818. /package/dist/{dts → Fx}/internal/UnionToTuple.d.ts +0 -0
@@ -0,0 +1,1310 @@
1
+ /** @effect-diagnostics missingEffectError:skip-file */
2
+ /** @effect-diagnostics missingEffectContext:skip-file */
3
+ import * as Array from "effect/Array";
4
+ import * as Effect from "effect/Effect";
5
+ import { equals } from "effect/Equal";
6
+ import * as Exit from "effect/Exit";
7
+ import * as Fiber from "effect/Fiber";
8
+ import { dual, identity } from "effect/Function";
9
+ import * as Layer from "effect/Layer";
10
+ import * as MutableRef from "effect/MutableRef";
11
+ import { sum } from "effect/Number";
12
+ import * as Option from "effect/Option";
13
+ import { pipeArguments } from "effect/Pipeable";
14
+ import * as Scope from "effect/Scope";
15
+ import * as ServiceMap from "effect/ServiceMap";
16
+ import * as Stream from "effect/Stream";
17
+ import { compact as fxCompact } from "../Fx/combinators/compact.js";
18
+ import { continueWith } from "../Fx/combinators/continueWith.js";
19
+ import { filterMapEffect as fxFilterMapEffect } from "../Fx/combinators/filterMapEffect.js";
20
+ import { mapEffect as fxMapEffect } from "../Fx/combinators/mapEffect.js";
21
+ import { skipRepeats } from "../Fx/combinators/skipRepeats.js";
22
+ import { slice as fxSlice } from "../Fx/combinators/slice.js";
23
+ import { unwrap } from "../Fx/combinators/unwrap.js";
24
+ import { fromEffect as fxFromEffect } from "../Fx/constructors/fromEffect.js";
25
+ import { fromYieldable } from "../Fx/constructors/fromYieldable.js";
26
+ import * as DeferredRef from "../Fx/internal/DeferredRef.js";
27
+ import { getExitEquivalence } from "../Fx/internal/equivalence.js";
28
+ import { YieldableFx } from "../Fx/internal/yieldable.js";
29
+ import { FxTypeId, isFx } from "../Fx/TypeId.js";
30
+ import * as Sink from "../Sink/Sink.js";
31
+ import * as Subject from "../Subject/Subject.js";
32
+ import * as Versioned from "../Versioned/Versioned.js";
33
+ export const RefSubjectTypeId = Symbol.for("@typed/fx/RefSubject");
34
+ export const ComputedTypeId = Symbol.for("@typed/fx/Computed");
35
+ export const FilteredTypeId = Symbol.for("@typed/fx/Filtered");
36
+ export const CurrentComputedBehavior = ServiceMap.Reference("@typed/fx/CurrentComputedBehavior", {
37
+ defaultValue: () => "multiple",
38
+ });
39
+ const checkIsMultiple = (ctx) => ServiceMap.getReferenceUnsafe(ctx, CurrentComputedBehavior) === "multiple";
40
+ class ComputedImpl extends Versioned.VersionedTransform {
41
+ [ComputedTypeId] = ComputedTypeId;
42
+ _computed;
43
+ input;
44
+ f;
45
+ constructor(input, f) {
46
+ super(input, (fx) => fxMapEffect(fx, f), Effect.flatMap(f));
47
+ this.input = input;
48
+ this.f = f;
49
+ this._computed = Subject.hold(unwrap(Effect.map(Effect.services(), (ctx) => {
50
+ if (checkIsMultiple(ctx)) {
51
+ return fromYieldable(input).pipe(continueWith(() => input), skipRepeats, fxMapEffect(f));
52
+ }
53
+ return fxFromEffect(Effect.flatMap(input.asEffect(), f));
54
+ })));
55
+ }
56
+ run(sink) {
57
+ return this._computed.run(sink);
58
+ }
59
+ }
60
+ export function makeComputed(input, f) {
61
+ return new ComputedImpl(input, f);
62
+ }
63
+ export function makeFiltered(input, f) {
64
+ return new FilteredImpl(input, f);
65
+ }
66
+ class FilteredImpl extends Versioned.VersionedTransform {
67
+ [FilteredTypeId] = FilteredTypeId;
68
+ _computed;
69
+ input;
70
+ f;
71
+ constructor(input, f) {
72
+ super(input, (fx) => fxFilterMapEffect(fx, f), (effect) => Effect.flatMap(Effect.flatMap(effect, f), (option) => option.asEffect()));
73
+ this.input = input;
74
+ this.f = f;
75
+ this._computed = Subject.hold(unwrap(Effect.map(Effect.services(), (ctx) => {
76
+ if (checkIsMultiple(ctx)) {
77
+ return fromYieldable(input).pipe(continueWith(() => input), skipRepeats, fxFilterMapEffect(f));
78
+ }
79
+ return fxCompact(fxFromEffect(Effect.flatMap(input.asEffect(), f)));
80
+ })));
81
+ }
82
+ run(sink) {
83
+ return this._computed.run(sink);
84
+ }
85
+ asComputed() {
86
+ return new ComputedImpl(this.input, this.f);
87
+ }
88
+ }
89
+ class RefSubjectCore {
90
+ initial;
91
+ subject;
92
+ services;
93
+ scope;
94
+ deferredRef;
95
+ semaphore;
96
+ constructor(initial, subject, services, scope, deferredRef, semaphore) {
97
+ this.initial = initial;
98
+ this.subject = subject;
99
+ this.services = services;
100
+ this.scope = scope;
101
+ this.deferredRef = deferredRef;
102
+ this.semaphore = semaphore;
103
+ }
104
+ _fiber = undefined;
105
+ }
106
+ function getSetDelete(ref) {
107
+ return {
108
+ get: getOrInitializeCore(ref, false),
109
+ set: (a) => setCore(ref, a),
110
+ delete: deleteCore(ref),
111
+ };
112
+ }
113
+ class RefSubjectImpl extends YieldableFx {
114
+ [ComputedTypeId] = ComputedTypeId;
115
+ [RefSubjectTypeId] = RefSubjectTypeId;
116
+ version;
117
+ interrupt;
118
+ subscriberCount;
119
+ getSetDelete;
120
+ core;
121
+ constructor(core) {
122
+ super();
123
+ this.core = core;
124
+ this.version = Effect.sync(() => core.deferredRef.version);
125
+ this.interrupt = Effect.provide(interruptCore(core), core.services);
126
+ this.subscriberCount = Effect.provide(core.subject.subscriberCount, core.services);
127
+ this.getSetDelete = getSetDelete(core);
128
+ this.updates = this.updates.bind(this);
129
+ this.onSuccess = this.onSuccess.bind(this);
130
+ this.onFailure = this.onFailure.bind(this);
131
+ }
132
+ run(sink) {
133
+ return Effect.matchCauseEffect(getOrInitializeCore(this.core, true), {
134
+ onFailure: (cause) => sink.onFailure(cause),
135
+ onSuccess: () => Effect.provide(this.core.subject.run(sink), this.core.services),
136
+ });
137
+ }
138
+ updates(run) {
139
+ return this.core.semaphore.withPermits(1)(run(this.getSetDelete));
140
+ }
141
+ onSuccess(value) {
142
+ return setCore(this.core, value);
143
+ }
144
+ onFailure(cause) {
145
+ return onFailureCore(this.core, cause);
146
+ }
147
+ toEffect() {
148
+ return getOrInitializeCore(this.core, true);
149
+ }
150
+ }
151
+ /**
152
+ * Creates a new `RefSubject` from a value, `Effect`, or `Fx`.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import { Effect } from "effect"
157
+ * import * as RefSubject from "@typed/fx/RefSubject"
158
+ * import { Fx } from "@typed/fx"
159
+ *
160
+ * // From a plain value
161
+ * const program1 = Effect.gen(function* () {
162
+ * const ref = yield* RefSubject.make(42)
163
+ * const value = yield* ref
164
+ * console.log(value) // 42
165
+ * })
166
+ *
167
+ * // From an Effect
168
+ * const program2 = Effect.gen(function* () {
169
+ * const ref = yield* RefSubject.make(
170
+ * Effect.succeed("Hello")
171
+ * )
172
+ * const value = yield* ref
173
+ * console.log(value) // "Hello"
174
+ * })
175
+ *
176
+ * // From an Fx (tracks the latest value)
177
+ * const program3 = Effect.gen(function* () {
178
+ * const ref = yield* RefSubject.make(
179
+ * Fx.fromIterable([1, 2, 3])
180
+ * )
181
+ * const value = yield* ref
182
+ * console.log(value) // 3 (latest value)
183
+ * })
184
+ * ```
185
+ *
186
+ * @since 1.0.0
187
+ * @category constructors
188
+ */
189
+ export function make(effect, options) {
190
+ if (isFx(effect)) {
191
+ return fromFx(effect, options);
192
+ }
193
+ else if (Effect.isEffect(effect)) {
194
+ return fromEffect(effect, options);
195
+ }
196
+ else if (Stream.isStream(effect)) {
197
+ return fromStream(effect, options);
198
+ }
199
+ else {
200
+ return fromEffect(Effect.succeed(effect), options);
201
+ }
202
+ }
203
+ /**
204
+ * Creates a `RefSubject` from an `Effect`.
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * import { Effect } from "effect"
209
+ * import * as RefSubject from "@typed/fx/RefSubject"
210
+ *
211
+ * const program = Effect.gen(function* () {
212
+ * const ref = yield* RefSubject.fromEffect(
213
+ * Effect.succeed("Initial value")
214
+ * )
215
+ *
216
+ * const value = yield* ref
217
+ * console.log(value) // "Initial value"
218
+ * })
219
+ * ```
220
+ *
221
+ * @since 1.0.0
222
+ * @category constructors
223
+ */
224
+ export function fromEffect(effect, options) {
225
+ return Effect.map(makeCore(effect, options), (core) => new RefSubjectImpl(core));
226
+ }
227
+ /**
228
+ * Creates a `RefSubject` from an `Fx`, tracking the latest emitted value.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * import { Effect } from "effect"
233
+ * import * as RefSubject from "@typed/fx/RefSubject"
234
+ * import { Fx } from "@typed/fx"
235
+ *
236
+ * const program = Effect.gen(function* () {
237
+ * // Create an Fx that emits multiple values
238
+ * const numbers = Fx.fromIterable([1, 2, 3, 4, 5])
239
+ *
240
+ * // Create a RefSubject that tracks the latest value
241
+ * const ref = yield* RefSubject.fromFx(numbers)
242
+ *
243
+ * // Get the latest value
244
+ * const latest = yield* ref
245
+ * console.log(latest) // 5
246
+ * })
247
+ * ```
248
+ *
249
+ * @since 1.0.0
250
+ * @category constructors
251
+ */
252
+ export function fromFx(fx, options) {
253
+ return Effect.gen(function* () {
254
+ const core = yield* makeDeferredCore(options);
255
+ const ref = new RefSubjectImpl(core);
256
+ yield* Effect.forkIn(fx.run(Sink.make((cause) => onFailureCore(core, cause), (value) => setCore(core, value))), core.scope, { startImmediately: true });
257
+ return ref;
258
+ });
259
+ }
260
+ export function fromStream(stream, options) {
261
+ return Effect.gen(function* () {
262
+ const core = yield* makeDeferredCore(options);
263
+ const ref = new RefSubjectImpl(core);
264
+ yield* Effect.forkIn(stream.pipe(redirectCause(core), Stream.runForEach((value) => setCore(core, value))), core.scope, { startImmediately: true });
265
+ return ref;
266
+ });
267
+ }
268
+ function redirectCause(core) {
269
+ return Stream.catchCause((cause) => Stream.unwrap(Effect.as(onFailureCore(core, cause), Stream.empty)));
270
+ }
271
+ function makeCore(initial, options, deferredRef) {
272
+ return Effect.gen(function* () {
273
+ const services = yield* Effect.services();
274
+ const scope = yield* Scope.fork(ServiceMap.get(services, Scope.Scope));
275
+ const id = yield* Effect.withFiber((fiber) => Effect.succeed(fiber.id));
276
+ const subject = new Subject.HoldSubjectImpl();
277
+ const core = new RefSubjectCore(initial, subject, services, scope, deferredRef ??
278
+ DeferredRef.unsafeMake(id, getExitEquivalence(options?.eq ?? equals), subject.lastValue), Effect.makeSemaphoreUnsafe(1));
279
+ yield* Scope.addFinalizer(scope, core.subject.interrupt);
280
+ return core;
281
+ });
282
+ }
283
+ function makeDeferredCore(options) {
284
+ return Effect.gen(function* () {
285
+ const deferredRef = yield* DeferredRef.make(getExitEquivalence(options?.eq ?? equals));
286
+ return yield* makeCore(deferredRef.asEffect(), options, deferredRef);
287
+ });
288
+ }
289
+ function getOrInitializeCore(core, lockInitialize) {
290
+ return Effect.suspend(() => {
291
+ if (core._fiber === undefined && Option.isNone(MutableRef.get(core.deferredRef.current))) {
292
+ return initializeCoreAndTap(core, lockInitialize);
293
+ }
294
+ else {
295
+ return core.deferredRef.asEffect();
296
+ }
297
+ });
298
+ }
299
+ function initializeCoreEffect(core, lock) {
300
+ const initialize = Effect.onExit(Effect.provide(core.initial, core.services), (exit) => Effect.sync(() => {
301
+ core._fiber = undefined;
302
+ core.deferredRef.done(exit);
303
+ }));
304
+ return Effect.flatMap(Effect.forkIn(lock ? core.semaphore.withPermits(1)(initialize) : initialize, core.scope), (fiber) => Effect.sync(() => (core._fiber = fiber)));
305
+ }
306
+ function initializeCoreAndTap(core, lock) {
307
+ return Effect.flatMapEager(initializeCoreEffect(core, lock), () => tapEventCore(core, core.deferredRef.asEffect()));
308
+ }
309
+ function setCore(core, a) {
310
+ return Effect.suspend(() => {
311
+ const exit = Exit.succeed(a);
312
+ if (core.deferredRef.done(exit)) {
313
+ // If the value changed, send an event
314
+ return Effect.as(sendEvent(core, exit), a);
315
+ }
316
+ else {
317
+ // Otherwise, just return the current value
318
+ return Effect.succeed(a);
319
+ }
320
+ });
321
+ }
322
+ function onFailureCore(core, cause) {
323
+ const exit = Exit.failCause(cause);
324
+ return Effect.suspend(() => {
325
+ if (core.deferredRef.done(exit)) {
326
+ return sendEvent(core, exit);
327
+ }
328
+ else {
329
+ return Effect.void;
330
+ }
331
+ });
332
+ }
333
+ function interruptCore(core) {
334
+ return Effect.withFiber((fiber) => {
335
+ core.deferredRef.reset();
336
+ const closeScope = Scope.close(core.scope, Exit.interrupt(fiber.id));
337
+ const interruptFiber = core._fiber ? Fiber.interrupt(core._fiber) : Effect.void;
338
+ const interruptSubject = core.subject.interrupt;
339
+ return Effect.all([closeScope, interruptFiber, interruptSubject], { discard: true });
340
+ });
341
+ }
342
+ function deleteCore(core) {
343
+ return Effect.suspend(() => {
344
+ const current = MutableRef.get(core.deferredRef.current);
345
+ core.deferredRef.reset();
346
+ if (Option.isNone(current)) {
347
+ return Effect.succeed(Option.none());
348
+ }
349
+ return core.subject.subscriberCount.pipe(Effect.flatMap((count) => count > 0 && !core._fiber ? initializeCoreEffect(core, false) : Effect.void), Effect.flatMap(() => Effect.asSome(current.value)));
350
+ });
351
+ }
352
+ function tapEventCore(core, effect) {
353
+ return effect.pipe(Effect.onExit((exit) => sendEvent(core, exit)));
354
+ }
355
+ function sendEvent(core, exit) {
356
+ if (Exit.isSuccess(exit)) {
357
+ return core.subject.onSuccess(exit.value);
358
+ }
359
+ else {
360
+ return core.subject.onFailure(exit.cause);
361
+ }
362
+ }
363
+ /**
364
+ * Sets the value of a `RefSubject`.
365
+ *
366
+ * @example
367
+ * ```ts
368
+ * import { Effect } from "effect"
369
+ * import * as RefSubject from "@typed/fx/RefSubject"
370
+ *
371
+ * const program = Effect.gen(function* () {
372
+ * const count = yield* RefSubject.make(0)
373
+ *
374
+ * // Set the value
375
+ * yield* RefSubject.set(count, 10)
376
+ * const value = yield* count
377
+ * console.log(value) // 10
378
+ *
379
+ * // Can also use pipe syntax
380
+ * yield* count.pipe(RefSubject.set(20))
381
+ * const newValue = yield* count
382
+ * console.log(newValue) // 20
383
+ * })
384
+ * ```
385
+ *
386
+ * @since 1.0.0
387
+ * @category combinators
388
+ */
389
+ export const set = dual(2, function set(ref, a) {
390
+ return ref.updates((ref) => ref.set(a));
391
+ });
392
+ /**
393
+ * Resets a `RefSubject` to its initial value, returning the previous value if it existed.
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * import { Effect, Option } from "effect"
398
+ * import * as RefSubject from "@typed/fx/RefSubject"
399
+ *
400
+ * const program = Effect.gen(function* () {
401
+ * const count = yield* RefSubject.make(0)
402
+ *
403
+ * yield* RefSubject.set(count, 5)
404
+ * const before = yield* count
405
+ * console.log(before) // 5
406
+ *
407
+ * // Reset to initial value
408
+ * const previous = yield* RefSubject.reset(count)
409
+ * console.log(Option.isSome(previous)) // true
410
+ * console.log(previous.value) // 5
411
+ *
412
+ * const after = yield* count
413
+ * console.log(after) // 0
414
+ * })
415
+ * ```
416
+ *
417
+ * @since 1.0.0
418
+ * @category combinators
419
+ */
420
+ export function reset(ref) {
421
+ return ref.updates((ref) => ref.delete);
422
+ }
423
+ export {
424
+ /**
425
+ * Deletes the current value of a `RefSubject`, resetting it to its initial state.
426
+ *
427
+ * @example
428
+ * ```ts
429
+ * import { Effect, Option } from "effect"
430
+ * import * as RefSubject from "@typed/fx/RefSubject"
431
+ *
432
+ * const program = Effect.gen(function* () {
433
+ * const ref = yield* RefSubject.make(10)
434
+ * yield* RefSubject.set(ref, 20)
435
+ *
436
+ * // Delete the current value
437
+ * const deleted = yield* RefSubject.delete(ref)
438
+ * console.log(Option.isSome(deleted)) // true
439
+ * console.log(deleted.value) // 20
440
+ *
441
+ * // Value is reset to initial
442
+ * const current = yield* ref
443
+ * console.log(current) // 10
444
+ * })
445
+ * ```
446
+ *
447
+ * @since 1.20.0
448
+ * @category combinators
449
+ */
450
+ reset as delete, };
451
+ /**
452
+ * Updates a `RefSubject` using an `Effect`ful function.
453
+ *
454
+ * @example
455
+ * ```ts
456
+ * import { Effect } from "effect"
457
+ * import * as RefSubject from "@typed/fx/RefSubject"
458
+ *
459
+ * const program = Effect.gen(function* () {
460
+ * const count = yield* RefSubject.make(5)
461
+ *
462
+ * // Update with an async operation
463
+ * yield* RefSubject.updateEffect(count, (value) =>
464
+ * Effect.succeed(value * 2)
465
+ * )
466
+ *
467
+ * const result = yield* count
468
+ * console.log(result) // 10
469
+ * })
470
+ * ```
471
+ *
472
+ * @since 1.0.0
473
+ * @category combinators
474
+ */
475
+ export const updateEffect = dual(2, function updateEffect(ref, f) {
476
+ return ref.updates((ref) => Effect.flatMap(Effect.flatMap(ref.get, f), ref.set));
477
+ });
478
+ /**
479
+ * Updates a `RefSubject` using a pure function.
480
+ *
481
+ * @example
482
+ * ```ts
483
+ * import { Effect } from "effect"
484
+ * import * as RefSubject from "@typed/fx/RefSubject"
485
+ *
486
+ * const program = Effect.gen(function* () {
487
+ * const count = yield* RefSubject.make(5)
488
+ *
489
+ * // Increment by 1
490
+ * yield* RefSubject.update(count, (n) => n + 1)
491
+ * const value = yield* count
492
+ * console.log(value) // 6
493
+ *
494
+ * // Can also use pipe syntax
495
+ * yield* count.pipe(RefSubject.update((n) => n * 2))
496
+ * const doubled = yield* count
497
+ * console.log(doubled) // 12
498
+ * })
499
+ * ```
500
+ *
501
+ * @since 1.0.0
502
+ * @category combinators
503
+ */
504
+ export const update = dual(2, function update(ref, f) {
505
+ return updateEffect(ref, (value) => Effect.succeed(f(value)));
506
+ });
507
+ /**
508
+ * Modifies a `RefSubject` using an `Effect`ful function that returns both a result and a new value.
509
+ *
510
+ * @example
511
+ * ```ts
512
+ * import { Effect } from "effect"
513
+ * import * as RefSubject from "@typed/fx/RefSubject"
514
+ *
515
+ * const program = Effect.gen(function* () {
516
+ * const count = yield* RefSubject.make(5)
517
+ *
518
+ * // Get the old value and set a new one, returning the old value
519
+ * const oldValue = yield* RefSubject.modifyEffect(count, (value) =>
520
+ * Effect.succeed([value, value + 10] as const)
521
+ * )
522
+ *
523
+ * console.log(oldValue) // 5
524
+ * const newValue = yield* count
525
+ * console.log(newValue) // 15
526
+ * })
527
+ * ```
528
+ *
529
+ * @since 1.0.0
530
+ * @category combinators
531
+ */
532
+ export const modifyEffect = dual(2, function modifyEffect(ref, f) {
533
+ return ref.updates((ref) => Effect.flatMap(ref.get, (value) => Effect.flatMap(f(value), ([b, a]) => Effect.flatMap(ref.set(a), () => Effect.succeed(b)))));
534
+ });
535
+ /**
536
+ * Modifies a `RefSubject` using a pure function that returns both a result and a new value.
537
+ *
538
+ * @example
539
+ * ```ts
540
+ * import { Effect } from "effect"
541
+ * import * as RefSubject from "@typed/fx/RefSubject"
542
+ *
543
+ * const program = Effect.gen(function* () {
544
+ * const count = yield* RefSubject.make(5)
545
+ *
546
+ * // Get the old value and increment, returning the old value
547
+ * const oldValue = yield* RefSubject.modify(count, (value) => [value, value + 1] as const)
548
+ *
549
+ * console.log(oldValue) // 5
550
+ * const newValue = yield* count
551
+ * console.log(newValue) // 6
552
+ * })
553
+ * ```
554
+ *
555
+ * @since 1.0.0
556
+ * @category combinators
557
+ */
558
+ export const modify = dual(2, function modify(ref, f) {
559
+ return modifyEffect(ref, (value) => Effect.succeed(f(value)));
560
+ });
561
+ /**
562
+ * Checks if a value is a `RefSubject`.
563
+ *
564
+ * @example
565
+ * ```ts
566
+ * import { Effect } from "effect"
567
+ * import * as RefSubject from "@typed/fx/RefSubject"
568
+ *
569
+ * const program = Effect.gen(function* () {
570
+ * const ref = yield* RefSubject.make(42)
571
+ * const isRef = RefSubject.isRefSubject(ref)
572
+ * console.log(isRef) // true
573
+ *
574
+ * const notRef = { value: 42 }
575
+ * const isNotRef = RefSubject.isRefSubject(notRef)
576
+ * console.log(isNotRef) // false
577
+ * })
578
+ * ```
579
+ *
580
+ * @since 1.0.0
581
+ * @category guards
582
+ */
583
+ export function isRefSubject(value) {
584
+ return value && typeof value === "object" && value[RefSubjectTypeId] === RefSubjectTypeId;
585
+ }
586
+ const isRefSubjectDataFirst = (args) => isRefSubject(args[0]);
587
+ /**
588
+ * Runs an effect that can modify a `RefSubject` transactionally, with optional interrupt handling.
589
+ *
590
+ * @example
591
+ * ```ts
592
+ * import { Effect } from "effect"
593
+ * import * as RefSubject from "@typed/fx/RefSubject"
594
+ *
595
+ * const program = Effect.gen(function* () {
596
+ * const balance = yield* RefSubject.make(100)
597
+ *
598
+ * // Transfer money atomically with interrupt handling
599
+ * yield* RefSubject.runUpdates(
600
+ * balance,
601
+ * (ref) =>
602
+ * Effect.gen(function* () {
603
+ * const current = yield* ref.get
604
+ * if (current >= 50) {
605
+ * yield* ref.set(current - 50)
606
+ * return "Transfer successful"
607
+ * }
608
+ * return "Insufficient funds"
609
+ * }),
610
+ * {
611
+ * onInterrupt: (value) => Effect.sync(() => console.log(`Interrupted at balance: ${value}`)),
612
+ * value: "initial"
613
+ * }
614
+ * )
615
+ * })
616
+ * ```
617
+ *
618
+ * @since 1.0.0
619
+ * @category combinators
620
+ */
621
+ export const runUpdates = dual(isRefSubjectDataFirst, function runUpdates(ref, f, options) {
622
+ if (options === undefined) {
623
+ return ref.updates(f);
624
+ }
625
+ else if (options.value === "initial") {
626
+ return ref.updates((ref) => Effect.flatMap(ref.get, (initial) => f(ref).pipe(Effect.onInterrupt(() => options.onInterrupt(initial)))));
627
+ }
628
+ else {
629
+ return ref.updates((ref) => f(ref).pipe(Effect.onInterrupt(() => Effect.flatMap(ref.get, options.onInterrupt))));
630
+ }
631
+ });
632
+ /**
633
+ * Increments a numeric `RefSubject` by 1.
634
+ *
635
+ * @example
636
+ * ```ts
637
+ * import { Effect } from "effect"
638
+ * import * as RefSubject from "@typed/fx/RefSubject"
639
+ *
640
+ * const program = Effect.gen(function* () {
641
+ * const count = yield* RefSubject.make(0)
642
+ *
643
+ * yield* RefSubject.increment(count)
644
+ * const value = yield* count
645
+ * console.log(value) // 1
646
+ *
647
+ * yield* RefSubject.increment(count)
648
+ * const newValue = yield* count
649
+ * console.log(newValue) // 2
650
+ * })
651
+ * ```
652
+ *
653
+ * @since 1.0.0
654
+ * @category combinators
655
+ */
656
+ export function increment(ref) {
657
+ return update(ref, (value) => value + 1);
658
+ }
659
+ /**
660
+ * Decrements a numeric `RefSubject` by 1.
661
+ *
662
+ * @example
663
+ * ```ts
664
+ * import { Effect } from "effect"
665
+ * import * as RefSubject from "@typed/fx/RefSubject"
666
+ *
667
+ * const program = Effect.gen(function* () {
668
+ * const count = yield* RefSubject.make(10)
669
+ *
670
+ * yield* RefSubject.decrement(count)
671
+ * const value = yield* count
672
+ * console.log(value) // 9
673
+ *
674
+ * yield* RefSubject.decrement(count)
675
+ * const newValue = yield* count
676
+ * console.log(newValue) // 8
677
+ * })
678
+ * ```
679
+ *
680
+ * @since 1.0.0
681
+ * @category combinators
682
+ */
683
+ export function decrement(ref) {
684
+ return update(ref, (value) => value - 1);
685
+ }
686
+ const Variance = {
687
+ _A: identity,
688
+ _E: identity,
689
+ _R: identity,
690
+ };
691
+ export function Service() {
692
+ return (id) => {
693
+ const service = ServiceMap.Service(id);
694
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
695
+ return class RefSubjectService {
696
+ /// Service
697
+ static id = id;
698
+ static service = service;
699
+ static layer = (make) => Layer.effect(service, make);
700
+ static make = (value, options) => {
701
+ const bounds = getDefaultBounds(options);
702
+ return make(value, options).pipe(Effect.map((ref) => (bounds ? slice(ref, bounds.skip, bounds.take) : ref)), this.layer);
703
+ };
704
+ // Fx
705
+ static [FxTypeId] = Variance;
706
+ static run = (sink) => Effect.flatMap(service.asEffect(), (ref) => ref.run(sink));
707
+ // Sink
708
+ static onSuccess = (value) => Effect.flatMap(service.asEffect(), (ref) => ref.onSuccess(value));
709
+ static onFailure = (cause) => Effect.flatMap(service.asEffect(), (ref) => ref.onFailure(cause));
710
+ /// Computed
711
+ static [ComputedTypeId] = ComputedTypeId;
712
+ static version = Effect.flatMap(service.asEffect(), (ref) => ref.version);
713
+ // Subject
714
+ static subscriberCount = Effect.flatMap(service.asEffect(), (ref) => ref.subscriberCount);
715
+ static interrupt = Effect.flatMap(service.asEffect(), (ref) => ref.interrupt);
716
+ // RefSubject
717
+ static [RefSubjectTypeId] = RefSubjectTypeId;
718
+ static updates = (f) => Effect.flatMap(service.asEffect(), (ref) => ref.updates(f));
719
+ // Yieldable
720
+ static asEffect = () => Effect.flatMap(service.asEffect(), Effect.fromYieldable);
721
+ static [Symbol.iterator] = function* () {
722
+ const ref = yield* service;
723
+ return yield* ref;
724
+ };
725
+ static pipe = function pipe() {
726
+ return pipeArguments(this, arguments);
727
+ };
728
+ constructor() {
729
+ return RefSubjectService;
730
+ }
731
+ };
732
+ };
733
+ }
734
+ function getDefaultBounds(options) {
735
+ if (options === undefined || (options.skip === undefined && options.take === undefined)) {
736
+ return { skip: 0, take: Infinity };
737
+ }
738
+ return { skip: options.skip ?? 0, take: options.take ?? Infinity };
739
+ }
740
+ /**
741
+ * Extract all values from an object using a Proxy.
742
+ * Allows accessing nested properties of a `Computed` or `Filtered` object/array as individual computed values.
743
+ *
744
+ * @example
745
+ * ```ts
746
+ * import { Effect } from "effect"
747
+ * import * as RefSubject from "@typed/fx/RefSubject"
748
+ *
749
+ * const program = Effect.gen(function* () {
750
+ * const user = yield* RefSubject.make({ name: "Alice", age: 30 })
751
+ *
752
+ * // Create a proxy to access nested properties
753
+ * const proxied = RefSubject.proxy(user)
754
+ *
755
+ * // Access individual properties as Computed values
756
+ * const name = yield* proxied.name
757
+ * console.log(name) // "Alice"
758
+ *
759
+ * const age = yield* proxied.age
760
+ * console.log(age) // 30
761
+ *
762
+ * // Update the source
763
+ * yield* RefSubject.set(user, { name: "Bob", age: 25 })
764
+ *
765
+ * // Proxied values automatically update
766
+ * const newName = yield* proxied.name
767
+ * console.log(newName) // "Bob"
768
+ * })
769
+ * ```
770
+ *
771
+ * @since 2.0.0
772
+ * @category combinators
773
+ */
774
+ export const proxy = (source) => {
775
+ const target = {};
776
+ return new Proxy(target, {
777
+ get(self, prop) {
778
+ if (prop in self)
779
+ return self[prop];
780
+ return (self[prop] = map(source, (a) => a[prop]));
781
+ },
782
+ });
783
+ };
784
+ /**
785
+ * Transforms a `RefSubject`, `Computed`, or `Filtered` using an `Effect`ful function.
786
+ *
787
+ * @example
788
+ * ```ts
789
+ * import { Effect } from "effect"
790
+ * import * as RefSubject from "@typed/fx/RefSubject"
791
+ *
792
+ * const program = Effect.gen(function* () {
793
+ * const count = yield* RefSubject.make(5)
794
+ *
795
+ * // Transform with an async operation
796
+ * const doubled = RefSubject.mapEffect(count, (n) =>
797
+ * Effect.succeed(n * 2)
798
+ * )
799
+ *
800
+ * const value = yield* doubled
801
+ * console.log(value) // 10
802
+ *
803
+ * // Update source
804
+ * yield* RefSubject.set(count, 7)
805
+ *
806
+ * // Computed automatically updates
807
+ * const newValue = yield* doubled
808
+ * console.log(newValue) // 14
809
+ * })
810
+ * ```
811
+ *
812
+ * @since 1.0.0
813
+ * @category combinators
814
+ */
815
+ export const mapEffect = dual(2, function mapEffect(versioned, f) {
816
+ return FilteredTypeId in versioned
817
+ ? new FilteredImpl(versioned, (a) => Effect.asSome(f(a)))
818
+ : new ComputedImpl(versioned, f);
819
+ });
820
+ /**
821
+ * Transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function.
822
+ *
823
+ * @example
824
+ * ```ts
825
+ * import { Effect } from "effect"
826
+ * import * as RefSubject from "@typed/fx/RefSubject"
827
+ *
828
+ * const program = Effect.gen(function* () {
829
+ * const count = yield* RefSubject.make(5)
830
+ *
831
+ * // Create a computed that doubles the count
832
+ * const doubled = RefSubject.map(count, (n) => n * 2)
833
+ *
834
+ * const value = yield* doubled
835
+ * console.log(value) // 10
836
+ *
837
+ * // Update source
838
+ * yield* RefSubject.set(count, 7)
839
+ *
840
+ * // Computed automatically updates
841
+ * const newValue = yield* doubled
842
+ * console.log(newValue) // 14
843
+ * })
844
+ * ```
845
+ *
846
+ * @since 1.0.0
847
+ * @category combinators
848
+ */
849
+ export const map = dual(2, function map(versioned, f) {
850
+ return mapEffect(versioned, (a) => Effect.succeed(f(a)));
851
+ });
852
+ /**
853
+ * Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using an `Effect`ful function that returns an `Option`.
854
+ *
855
+ * @example
856
+ * ```ts
857
+ * import { Effect, Option } from "effect"
858
+ * import * as RefSubject from "@typed/fx/RefSubject"
859
+ *
860
+ * const program = Effect.gen(function* () {
861
+ * const numbers = yield* RefSubject.make([1, 2, 3, 4, 5])
862
+ *
863
+ * // Find the first even number
864
+ * const firstEven = RefSubject.filterMapEffect(numbers, (arr) =>
865
+ * Effect.succeed(Option.fromNullable(arr.find((n) => n % 2 === 0)))
866
+ * )
867
+ *
868
+ * const value = yield* firstEven
869
+ * console.log(value) // 2
870
+ * })
871
+ * ```
872
+ *
873
+ * @since 1.0.0
874
+ * @category combinators
875
+ */
876
+ export const filterMapEffect = dual(2, function filterMapEffect(versioned, f) {
877
+ return new FilteredImpl(versioned, f);
878
+ });
879
+ /**
880
+ * Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function that returns an `Option`.
881
+ *
882
+ * @example
883
+ * ```ts
884
+ * import { Effect, Option } from "effect"
885
+ * import * as RefSubject from "@typed/fx/RefSubject"
886
+ *
887
+ * const program = Effect.gen(function* () {
888
+ * const numbers = yield* RefSubject.make([1, 2, 3, 4, 5])
889
+ *
890
+ * // Get the first even number
891
+ * const firstEven = RefSubject.filterMap(numbers, (arr) =>
892
+ * Option.fromNullable(arr.find((n) => n % 2 === 0))
893
+ * )
894
+ *
895
+ * const value = yield* firstEven
896
+ * console.log(value) // 2
897
+ * })
898
+ * ```
899
+ *
900
+ * @since 1.0.0
901
+ * @category combinators
902
+ */
903
+ export const filterMap = dual(2, function filterMap(versioned, f) {
904
+ return new FilteredImpl(versioned, (a) => Effect.succeed(f(a)));
905
+ });
906
+ /**
907
+ * Converts a `Computed` or `Filtered` of `Option<A>` into a `Filtered<A>`, filtering out `None` values.
908
+ *
909
+ * @example
910
+ * ```ts
911
+ * import { Effect, Option } from "effect"
912
+ * import * as RefSubject from "@typed/fx/RefSubject"
913
+ *
914
+ * const program = Effect.gen(function* () {
915
+ * const maybeValue = yield* RefSubject.make(Option.some(42))
916
+ *
917
+ * // Compact the Option
918
+ * const filtered = RefSubject.compact(maybeValue)
919
+ *
920
+ * const value = yield* filtered
921
+ * console.log(value) // 42
922
+ *
923
+ * // If the Option becomes None, the Filtered will fail
924
+ * yield* RefSubject.set(maybeValue, Option.none())
925
+ * // yield* filtered would fail with NoSuchElementError
926
+ * })
927
+ * ```
928
+ *
929
+ * @since 1.0.0
930
+ * @category combinators
931
+ */
932
+ export const compact = function compact(versioned) {
933
+ return new FilteredImpl(versioned, Effect.succeed);
934
+ };
935
+ class RefSubjectSimpleTransform extends YieldableFx {
936
+ [ComputedTypeId] = ComputedTypeId;
937
+ [RefSubjectTypeId] = RefSubjectTypeId;
938
+ version;
939
+ interrupt;
940
+ subscriberCount;
941
+ _fx;
942
+ ref;
943
+ transformFx;
944
+ transformEffect;
945
+ constructor(ref, transformFx, transformEffect) {
946
+ super();
947
+ this.ref = ref;
948
+ this.transformFx = transformFx;
949
+ this.transformEffect = transformEffect;
950
+ this.version = ref.version;
951
+ this.interrupt = ref.interrupt;
952
+ this.subscriberCount = ref.subscriberCount;
953
+ this._fx = transformFx(ref);
954
+ }
955
+ run(sink) {
956
+ return this._fx.run(sink);
957
+ }
958
+ toEffect() {
959
+ return this.transformEffect(this.ref.asEffect());
960
+ }
961
+ updates(run) {
962
+ return this.ref.updates(run);
963
+ }
964
+ onFailure(cause) {
965
+ return this.ref.onFailure(cause);
966
+ }
967
+ onSuccess(value) {
968
+ return this.ref.onSuccess(value);
969
+ }
970
+ }
971
+ export const slice = dual(3, function slice(ref, skip, take) {
972
+ return new RefSubjectSimpleTransform(ref, (_) => fxSlice(_, { skip, take }), identity);
973
+ });
974
+ class RefSubjectTransform extends YieldableFx {
975
+ [ComputedTypeId] = ComputedTypeId;
976
+ [RefSubjectTypeId] = RefSubjectTypeId;
977
+ version;
978
+ interrupt;
979
+ subscriberCount;
980
+ _fx;
981
+ ref;
982
+ toB;
983
+ toA;
984
+ constructor(ref, toB, toA) {
985
+ super();
986
+ this.ref = ref;
987
+ this.toB = toB;
988
+ this.toA = toA;
989
+ this.version = ref.version;
990
+ this.interrupt = ref.interrupt;
991
+ this.subscriberCount = ref.subscriberCount;
992
+ this._fx = fxMapEffect(ref, (a) => Effect.succeed(toB(a)));
993
+ }
994
+ run(sink) {
995
+ return this._fx.run(sink);
996
+ }
997
+ toEffect() {
998
+ return Effect.map(this.ref.asEffect(), this.toB);
999
+ }
1000
+ updates(run) {
1001
+ return this.ref.updates((innerRef) => {
1002
+ const getSetDelete = {
1003
+ get: Effect.map(innerRef.get, this.toB),
1004
+ set: (b) => Effect.map(innerRef.set(this.toA(b)), this.toB),
1005
+ delete: Effect.map(innerRef.delete, Option.map(this.toB)),
1006
+ };
1007
+ return run(getSetDelete);
1008
+ });
1009
+ }
1010
+ onFailure(cause) {
1011
+ return this.ref.onFailure(cause);
1012
+ }
1013
+ onSuccess(value) {
1014
+ return this.ref.onSuccess(this.toA(value));
1015
+ }
1016
+ }
1017
+ /**
1018
+ * Transforms a `RefSubject` invariantly using bidirectional mapping functions.
1019
+ *
1020
+ * @example
1021
+ * ```ts
1022
+ * import { Effect } from "effect"
1023
+ * import * as RefSubject from "@typed/fx/RefSubject"
1024
+ *
1025
+ * const program = Effect.gen(function* () {
1026
+ * const count = yield* RefSubject.make(5)
1027
+ *
1028
+ * // Transform to string and back
1029
+ * const countStr = RefSubject.transform(
1030
+ * count,
1031
+ * (n) => n.toString(),
1032
+ * (s) => parseInt(s, 10)
1033
+ * )
1034
+ *
1035
+ * const value = yield* countStr
1036
+ * console.log(value) // "5"
1037
+ *
1038
+ * // Set using the transformed type
1039
+ * yield* RefSubject.set(countStr, "10")
1040
+ *
1041
+ * // Original reflects the change
1042
+ * const original = yield* count
1043
+ * console.log(original) // 10
1044
+ * })
1045
+ * ```
1046
+ *
1047
+ * @since 1.0.0
1048
+ * @category combinators
1049
+ */
1050
+ export const transform = dual(3, function transform(ref, toB, toA) {
1051
+ return new RefSubjectTransform(ref, toB, toA);
1052
+ });
1053
+ const join = (a, b) => {
1054
+ if (a === "r")
1055
+ return b;
1056
+ if (b === "r")
1057
+ return a;
1058
+ if (a === "f")
1059
+ return a;
1060
+ if (b === "f")
1061
+ return b;
1062
+ return "c";
1063
+ };
1064
+ function getRefKind(refs) {
1065
+ let kind = "r";
1066
+ for (const ref of refs) {
1067
+ if (FilteredTypeId in ref) {
1068
+ kind = "f";
1069
+ break;
1070
+ }
1071
+ else if (!(RefSubjectTypeId in ref)) {
1072
+ kind = join(kind, "c");
1073
+ }
1074
+ }
1075
+ return kind;
1076
+ }
1077
+ /**
1078
+ * Combines multiple `RefSubject`, `Computed`, or `Filtered` instances into a single struct.
1079
+ *
1080
+ * @example
1081
+ * ```ts
1082
+ * import { Effect } from "effect"
1083
+ * import * as RefSubject from "@typed/fx/RefSubject"
1084
+ *
1085
+ * const program = Effect.gen(function* () {
1086
+ * const firstName = yield* RefSubject.make("Alice")
1087
+ * const lastName = yield* RefSubject.make("Smith")
1088
+ * const age = yield* RefSubject.make(30)
1089
+ *
1090
+ * // Combine into a struct
1091
+ * const person = RefSubject.struct({
1092
+ * firstName,
1093
+ * lastName,
1094
+ * age
1095
+ * })
1096
+ *
1097
+ * const fullPerson = yield* person
1098
+ * console.log(fullPerson) // { firstName: "Alice", lastName: "Smith", age: 30 }
1099
+ *
1100
+ * // Update one field
1101
+ * yield* RefSubject.set(firstName, "Bob")
1102
+ *
1103
+ * // Struct automatically updates
1104
+ * const updated = yield* person
1105
+ * console.log(updated.firstName) // "Bob"
1106
+ * })
1107
+ * ```
1108
+ *
1109
+ * @since 1.0.0
1110
+ * @category combinators
1111
+ */
1112
+ export function struct(refs) {
1113
+ const kind = getRefKind(Object.values(refs));
1114
+ switch (kind) {
1115
+ case "r":
1116
+ return makeStructRef(refs);
1117
+ case "c":
1118
+ return makeStructComputed(refs);
1119
+ case "f":
1120
+ return makeStructFiltered(refs);
1121
+ }
1122
+ }
1123
+ /**
1124
+ * Combines multiple `RefSubject`, `Computed`, or `Filtered` instances into a single tuple.
1125
+ *
1126
+ * @example
1127
+ * ```ts
1128
+ * import { Effect } from "effect"
1129
+ * import * as RefSubject from "@typed/fx/RefSubject"
1130
+ *
1131
+ * const program = Effect.gen(function* () {
1132
+ * const x = yield* RefSubject.make(10)
1133
+ * const y = yield* RefSubject.make(20)
1134
+ * const z = yield* RefSubject.make(30)
1135
+ *
1136
+ * // Combine into a tuple
1137
+ * const point = RefSubject.tuple([x, y, z])
1138
+ *
1139
+ * const coords = yield* point
1140
+ * console.log(coords) // [10, 20, 30]
1141
+ *
1142
+ * // Update one value
1143
+ * yield* RefSubject.set(x, 15)
1144
+ *
1145
+ * // Tuple automatically updates
1146
+ * const updated = yield* point
1147
+ * console.log(updated) // [15, 20, 30]
1148
+ * })
1149
+ * ```
1150
+ *
1151
+ * @since 1.0.0
1152
+ * @category combinators
1153
+ */
1154
+ export function tuple(refs) {
1155
+ const kind = getRefKind(refs);
1156
+ switch (kind) {
1157
+ case "r":
1158
+ return makeTupleRef(refs);
1159
+ case "c":
1160
+ return makeTupleComputed(refs);
1161
+ case "f":
1162
+ return makeTupleFiltered(refs);
1163
+ }
1164
+ }
1165
+ function makeTupleRef(refs) {
1166
+ return new RefSubjectTuple(refs);
1167
+ }
1168
+ const UNBOUNDED = { concurrency: "unbounded" };
1169
+ class RefSubjectTuple extends YieldableFx {
1170
+ [ComputedTypeId] = ComputedTypeId;
1171
+ [RefSubjectTypeId] = RefSubjectTypeId;
1172
+ version;
1173
+ interrupt;
1174
+ subscriberCount;
1175
+ versioned;
1176
+ getSetDelete;
1177
+ refs;
1178
+ constructor(refs) {
1179
+ super();
1180
+ this.refs = refs;
1181
+ this.versioned = Versioned.hold(Versioned.tuple(refs));
1182
+ this.version = this.versioned.version;
1183
+ this.interrupt = Effect.all(refs.map((r) => r.interrupt), UNBOUNDED);
1184
+ this.subscriberCount = Effect.map(Effect.all(refs.map((r) => r.subscriberCount), UNBOUNDED), Array.reduce(0, sum));
1185
+ this.getSetDelete = {
1186
+ get: this.versioned.asEffect(),
1187
+ set: (a) => Effect.all(refs.map((r, i) => set(r, a[i])), UNBOUNDED),
1188
+ delete: Effect.map(Effect.all(refs.map((r) => reset(r)), UNBOUNDED), Option.all),
1189
+ };
1190
+ this.updates = this.updates.bind(this);
1191
+ this.onFailure = this.onFailure.bind(this);
1192
+ this.onSuccess = this.onSuccess.bind(this);
1193
+ }
1194
+ run(sink) {
1195
+ return this.versioned.run(sink);
1196
+ }
1197
+ toEffect() {
1198
+ return this.versioned.asEffect();
1199
+ }
1200
+ updates(run) {
1201
+ return run(this.getSetDelete);
1202
+ }
1203
+ onFailure(cause) {
1204
+ return Effect.all(this.refs.map((ref) => ref.onFailure(cause)));
1205
+ }
1206
+ onSuccess(value) {
1207
+ return Effect.catchCause(this.getSetDelete.set(value), (c) => this.onFailure(c));
1208
+ }
1209
+ }
1210
+ function makeTupleComputed(refs) {
1211
+ return new ComputedImpl(Versioned.tuple(refs), Effect.succeed);
1212
+ }
1213
+ function makeTupleFiltered(refs) {
1214
+ return new FilteredImpl(Versioned.tuple(refs), Effect.succeedSome);
1215
+ }
1216
+ function makeStructRef(refs) {
1217
+ return new RefSubjectStruct(refs);
1218
+ }
1219
+ class RefSubjectStruct extends YieldableFx {
1220
+ [ComputedTypeId] = ComputedTypeId;
1221
+ [RefSubjectTypeId] = RefSubjectTypeId;
1222
+ version;
1223
+ interrupt;
1224
+ subscriberCount;
1225
+ versioned;
1226
+ getSetDelete;
1227
+ refs;
1228
+ constructor(refs) {
1229
+ super();
1230
+ this.refs = refs;
1231
+ this.versioned = Versioned.hold(Versioned.struct(refs));
1232
+ this.version = this.versioned.version;
1233
+ this.interrupt = Effect.all(Object.values(refs).map((r) => r.interrupt), UNBOUNDED);
1234
+ this.subscriberCount = Effect.map(Effect.all(Object.values(refs).map((r) => r.subscriberCount), UNBOUNDED), Array.reduce(0, sum));
1235
+ this.getSetDelete = {
1236
+ get: this.versioned.asEffect(),
1237
+ set: (a) => Effect.all(Object.keys(refs).map((k) => set(refs[k], a[k])), UNBOUNDED),
1238
+ delete: Effect.map(Effect.all(Object.values(refs).map((r) => reset(r)), UNBOUNDED), Option.all),
1239
+ };
1240
+ this.updates = this.updates.bind(this);
1241
+ this.onFailure = this.onFailure.bind(this);
1242
+ this.onSuccess = this.onSuccess.bind(this);
1243
+ }
1244
+ run(sink) {
1245
+ return this.versioned.run(sink);
1246
+ }
1247
+ toEffect() {
1248
+ return this.versioned.asEffect();
1249
+ }
1250
+ updates(run) {
1251
+ return run(this.getSetDelete);
1252
+ }
1253
+ onFailure(cause) {
1254
+ return Effect.all(Object.values(this.refs).map((ref) => ref.onFailure(cause)));
1255
+ }
1256
+ onSuccess(value) {
1257
+ return Effect.catchCause(this.getSetDelete.set(value), (c) => this.onFailure(c));
1258
+ }
1259
+ }
1260
+ function makeStructComputed(refs) {
1261
+ return new ComputedImpl(Versioned.struct(refs), Effect.succeed);
1262
+ }
1263
+ function makeStructFiltered(refs) {
1264
+ return new FilteredImpl(Versioned.struct(refs), Effect.succeedSome);
1265
+ }
1266
+ export function computedFromService(effect) {
1267
+ return new ComputedFromService(effect);
1268
+ }
1269
+ class ComputedFromService extends YieldableFx {
1270
+ [ComputedTypeId] = ComputedTypeId;
1271
+ effect;
1272
+ version;
1273
+ interrupt;
1274
+ constructor(effect) {
1275
+ super();
1276
+ this.effect = effect;
1277
+ this.version = Effect.flatMap(this.effect, (c) => c.version);
1278
+ this.interrupt = Effect.flatMap(this.effect, (c) => c.interrupt);
1279
+ }
1280
+ run(sink) {
1281
+ return Effect.flatMap(this.effect, (c) => c.run(sink));
1282
+ }
1283
+ toEffect() {
1284
+ return Effect.flatMap(this.effect, (c) => c.asEffect());
1285
+ }
1286
+ }
1287
+ export function filteredFromService(effect) {
1288
+ return new FilteredFromService(effect);
1289
+ }
1290
+ class FilteredFromService extends YieldableFx {
1291
+ [FilteredTypeId] = FilteredTypeId;
1292
+ effect;
1293
+ version;
1294
+ interrupt;
1295
+ constructor(effect) {
1296
+ super();
1297
+ this.effect = effect;
1298
+ this.version = Effect.flatMap(this.effect, (c) => c.version);
1299
+ this.interrupt = Effect.flatMap(this.effect, (c) => c.interrupt);
1300
+ }
1301
+ run(sink) {
1302
+ return Effect.flatMap(this.effect, (c) => c.run(sink));
1303
+ }
1304
+ toEffect() {
1305
+ return Effect.flatMap(this.effect, (c) => c.asEffect());
1306
+ }
1307
+ asComputed() {
1308
+ return computedFromService(Effect.map(this.effect, (c) => c.asComputed()));
1309
+ }
1310
+ }