@fncts/io 0.0.48 → 0.0.50

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 (873) hide show
  1. package/Cached/api.d.ts +1 -1
  2. package/Channel/api.d.ts +80 -80
  3. package/Channel/core-api.d.ts +26 -26
  4. package/Console/definition.d.ts +1 -0
  5. package/CountdownLatch.d.ts +1 -0
  6. package/Fiber/FiberMessage.d.ts +6 -28
  7. package/Fiber/FiberRuntime.d.ts +108 -77
  8. package/Fiber/api/interruptAs.d.ts +2 -2
  9. package/Fiber/definition.d.ts +2 -0
  10. package/FiberScope/definition.d.ts +3 -0
  11. package/FiberSet.d.ts +2 -1
  12. package/Future/State.d.ts +59 -0
  13. package/Future/api.d.ts +8 -3
  14. package/Future/constructors.d.ts +1 -1
  15. package/Future/definition.d.ts +1 -17
  16. package/Future.d.ts +1 -0
  17. package/Hub/api.d.ts +15 -15
  18. package/IO/api/array.d.ts +22 -0
  19. package/IO/api/awaitAllChildren.d.ts +6 -0
  20. package/IO/api/cachedInvalidate.d.ts +15 -0
  21. package/IO/api/foreachExec.d.ts +18 -0
  22. package/IO/api/forkDaemon.d.ts +1 -1
  23. package/IO/api/onTermination.d.ts +1 -2
  24. package/IO/api/transplant.d.ts +11 -1
  25. package/IO/api.d.ts +247 -225
  26. package/IO/definition.d.ts +12 -25
  27. package/IO.d.ts +3 -1
  28. package/Push/Bounds.d.ts +4 -0
  29. package/Push/FlattenStrategy.d.ts +47 -0
  30. package/Push/IndexedBuffer.d.ts +19 -0
  31. package/Push/MergeStrategy.d.ts +19 -0
  32. package/Push/Operator/IOLoopOperator.d.ts +61 -0
  33. package/Push/Operator/IOOperator.d.ts +63 -0
  34. package/Push/Operator/LoopOperator.d.ts +50 -0
  35. package/Push/Operator/SyncOperator.d.ts +41 -0
  36. package/Push/Operator.d.ts +4 -0
  37. package/Push/Producer/IOProducer.d.ts +41 -0
  38. package/Push/Producer/SyncProducer.d.ts +61 -0
  39. package/Push/Producer.d.ts +1 -0
  40. package/Push/Sink.d.ts +65 -0
  41. package/Push/api.d.ts +78 -161
  42. package/Push/definition.d.ts +92 -19
  43. package/Push/internal.d.ts +3 -0
  44. package/Push.d.ts +6 -0
  45. package/Random/definition.d.ts +1 -0
  46. package/Ref/Synchronized/api.d.ts +1 -1
  47. package/Ref/Synchronized/definition.d.ts +32 -9
  48. package/Ref/definition.d.ts +12 -0
  49. package/Scope/api.d.ts +16 -1
  50. package/Semaphore/Reservation.d.ts +15 -0
  51. package/Semaphore/constructors.d.ts +13 -0
  52. package/Semaphore/definition.d.ts +29 -0
  53. package/Semaphore.d.ts +3 -40
  54. package/Sink/definition.d.ts +5 -6
  55. package/Stream/api.d.ts +164 -164
  56. package/Subject/Atomic.d.ts +19 -9
  57. package/Subject/DeferredRef.d.ts +17 -0
  58. package/Subject/Hold.d.ts +19 -0
  59. package/Subject/RefSubject/Atomic.d.ts +41 -0
  60. package/Subject/RefSubject/Derived.d.ts +43 -0
  61. package/Subject/RefSubject/RefSubject.d.ts +27 -0
  62. package/Subject/definition.d.ts +14 -2
  63. package/Subject.d.ts +2 -0
  64. package/SubscriptionRef.d.ts +0 -1
  65. package/_cjs/Cached/api.cjs +1 -2
  66. package/_cjs/Cached/api.cjs.map +1 -1
  67. package/_cjs/Cached/internal.cjs +1 -2
  68. package/_cjs/Cached/internal.cjs.map +1 -1
  69. package/_cjs/Channel/api/interruptWhen.cjs +1 -2
  70. package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
  71. package/_cjs/Channel/api/mapOutConcurrentIO.cjs +2 -3
  72. package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
  73. package/_cjs/Channel/api/mergeAll.cjs +1 -2
  74. package/_cjs/Channel/api/mergeAll.cjs.map +1 -1
  75. package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +1 -2
  76. package/_cjs/Channel/api/mergeAllUnboundedWith.cjs.map +1 -1
  77. package/_cjs/Channel/api/mergeAllWith.cjs +2 -3
  78. package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
  79. package/_cjs/Channel/api/mergeMap.cjs +1 -2
  80. package/_cjs/Channel/api/mergeMap.cjs.map +1 -1
  81. package/_cjs/Channel/api/mergeWith.cjs +1 -2
  82. package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
  83. package/_cjs/Channel/api/run.cjs +1 -2
  84. package/_cjs/Channel/api/run.cjs.map +1 -1
  85. package/_cjs/Channel/api/runCollect.cjs +1 -2
  86. package/_cjs/Channel/api/runCollect.cjs.map +1 -1
  87. package/_cjs/Channel/api/runDrain.cjs +1 -2
  88. package/_cjs/Channel/api/runDrain.cjs.map +1 -1
  89. package/_cjs/Channel/api/runScoped.cjs +3 -4
  90. package/_cjs/Channel/api/runScoped.cjs.map +1 -1
  91. package/_cjs/Channel/api/toPull.cjs +2 -3
  92. package/_cjs/Channel/api/toPull.cjs.map +1 -1
  93. package/_cjs/Channel/api/zipConcurrent.cjs +1 -2
  94. package/_cjs/Channel/api/zipConcurrent.cjs.map +1 -1
  95. package/_cjs/Channel/api.cjs +206 -207
  96. package/_cjs/Channel/api.cjs.map +1 -1
  97. package/_cjs/Channel/core-api.cjs +43 -42
  98. package/_cjs/Channel/core-api.cjs.map +1 -1
  99. package/_cjs/Channel/internal/ChannelExecutor.cjs +4 -5
  100. package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
  101. package/_cjs/Channel/internal/ChannelState.cjs +1 -2
  102. package/_cjs/Channel/internal/ChannelState.cjs.map +1 -1
  103. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +1 -2
  104. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
  105. package/_cjs/Clock/api.cjs +1 -2
  106. package/_cjs/Clock/api.cjs.map +1 -1
  107. package/_cjs/Clock/definition.cjs +1 -2
  108. package/_cjs/Clock/definition.cjs.map +1 -1
  109. package/_cjs/Clock/live.cjs +1 -2
  110. package/_cjs/Clock/live.cjs.map +1 -1
  111. package/_cjs/Console/api.cjs +1 -2
  112. package/_cjs/Console/api.cjs.map +1 -1
  113. package/_cjs/Console/definition.cjs +2 -2
  114. package/_cjs/Console/definition.cjs.map +1 -1
  115. package/_cjs/Console/live.cjs +1 -2
  116. package/_cjs/Console/live.cjs.map +1 -1
  117. package/_cjs/CountdownLatch.cjs +3 -3
  118. package/_cjs/CountdownLatch.cjs.map +1 -1
  119. package/_cjs/Differ/api.cjs +1 -2
  120. package/_cjs/Differ/api.cjs.map +1 -1
  121. package/_cjs/Fiber/FiberMessage.cjs +3 -24
  122. package/_cjs/Fiber/FiberMessage.cjs.map +1 -1
  123. package/_cjs/Fiber/FiberRuntime.cjs +879 -636
  124. package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
  125. package/_cjs/Fiber/api/awaitAll.cjs +1 -2
  126. package/_cjs/Fiber/api/awaitAll.cjs.map +1 -1
  127. package/_cjs/Fiber/api/collectAll.cjs +2 -3
  128. package/_cjs/Fiber/api/collectAll.cjs.map +1 -1
  129. package/_cjs/Fiber/api/fromIO.cjs +1 -2
  130. package/_cjs/Fiber/api/fromIO.cjs.map +1 -1
  131. package/_cjs/Fiber/api/interrupt.cjs +2 -3
  132. package/_cjs/Fiber/api/interrupt.cjs.map +1 -1
  133. package/_cjs/Fiber/api/interruptAll.cjs +2 -3
  134. package/_cjs/Fiber/api/interruptAll.cjs.map +1 -1
  135. package/_cjs/Fiber/api/interruptAs.cjs +5 -10
  136. package/_cjs/Fiber/api/interruptAs.cjs.map +1 -1
  137. package/_cjs/Fiber/api/interruptFork.cjs +2 -3
  138. package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
  139. package/_cjs/Fiber/api/join.cjs +1 -2
  140. package/_cjs/Fiber/api/join.cjs.map +1 -1
  141. package/_cjs/Fiber/api/joinAll.cjs +1 -2
  142. package/_cjs/Fiber/api/joinAll.cjs.map +1 -1
  143. package/_cjs/Fiber/api/mapFiber.cjs +1 -2
  144. package/_cjs/Fiber/api/mapFiber.cjs.map +1 -1
  145. package/_cjs/Fiber/api/mapIO.cjs +2 -3
  146. package/_cjs/Fiber/api/mapIO.cjs.map +1 -1
  147. package/_cjs/Fiber/api/zipWith.cjs +2 -3
  148. package/_cjs/Fiber/api/zipWith.cjs.map +1 -1
  149. package/_cjs/Fiber/constructors.cjs +2 -3
  150. package/_cjs/Fiber/constructors.cjs.map +1 -1
  151. package/_cjs/Fiber/definition.cjs +6 -4
  152. package/_cjs/Fiber/definition.cjs.map +1 -1
  153. package/_cjs/FiberRef/api/locallyScoped.cjs +1 -2
  154. package/_cjs/FiberRef/api/locallyScoped.cjs.map +1 -1
  155. package/_cjs/FiberRef/api/locallyScopedWith.cjs +1 -2
  156. package/_cjs/FiberRef/api/locallyScopedWith.cjs.map +1 -1
  157. package/_cjs/FiberRef/constructors.cjs +1 -2
  158. package/_cjs/FiberRef/constructors.cjs.map +1 -1
  159. package/_cjs/FiberRef/definition.cjs +1 -2
  160. package/_cjs/FiberRef/definition.cjs.map +1 -1
  161. package/_cjs/FiberRef/operations.cjs +1 -2
  162. package/_cjs/FiberRef/operations.cjs.map +1 -1
  163. package/_cjs/FiberRef/unsafe.cjs +1 -2
  164. package/_cjs/FiberRef/unsafe.cjs.map +1 -1
  165. package/_cjs/FiberRefs/Patch.cjs +1 -2
  166. package/_cjs/FiberRefs/Patch.cjs.map +1 -1
  167. package/_cjs/FiberRefs/api.cjs +1 -2
  168. package/_cjs/FiberRefs/api.cjs.map +1 -1
  169. package/_cjs/FiberRefs/definition.cjs +1 -2
  170. package/_cjs/FiberRefs/definition.cjs.map +1 -1
  171. package/_cjs/FiberScope/definition.cjs +29 -6
  172. package/_cjs/FiberScope/definition.cjs.map +1 -1
  173. package/_cjs/FiberSet.cjs +16 -15
  174. package/_cjs/FiberSet.cjs.map +1 -1
  175. package/_cjs/FiberStatus/definition.cjs +1 -2
  176. package/_cjs/FiberStatus/definition.cjs.map +1 -1
  177. package/_cjs/Future/State.cjs +108 -0
  178. package/_cjs/Future/State.cjs.map +1 -0
  179. package/_cjs/Future/api.cjs +71 -64
  180. package/_cjs/Future/api.cjs.map +1 -1
  181. package/_cjs/Future/constructors.cjs +3 -4
  182. package/_cjs/Future/constructors.cjs.map +1 -1
  183. package/_cjs/Future/definition.cjs +1 -15
  184. package/_cjs/Future/definition.cjs.map +1 -1
  185. package/_cjs/Future.cjs +11 -0
  186. package/_cjs/Future.cjs.map +1 -1
  187. package/_cjs/Hub/api.cjs +56 -57
  188. package/_cjs/Hub/api.cjs.map +1 -1
  189. package/_cjs/Hub/internal.cjs +1 -2
  190. package/_cjs/Hub/internal.cjs.map +1 -1
  191. package/_cjs/IO/api/acquireRelease.cjs +1 -2
  192. package/_cjs/IO/api/acquireRelease.cjs.map +1 -1
  193. package/_cjs/IO/api/acquireReleaseExit.cjs +1 -2
  194. package/_cjs/IO/api/acquireReleaseExit.cjs.map +1 -1
  195. package/_cjs/IO/api/acquireReleaseInterruptible.cjs +1 -2
  196. package/_cjs/IO/api/acquireReleaseInterruptible.cjs.map +1 -1
  197. package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +1 -2
  198. package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs.map +1 -1
  199. package/_cjs/IO/api/addFinalizer.cjs +1 -2
  200. package/_cjs/IO/api/addFinalizer.cjs.map +1 -1
  201. package/_cjs/IO/api/addFinalizerExit.cjs +1 -2
  202. package/_cjs/IO/api/addFinalizerExit.cjs.map +1 -1
  203. package/_cjs/IO/api/all.cjs +1 -2
  204. package/_cjs/IO/api/all.cjs.map +1 -1
  205. package/_cjs/IO/api/array.cjs +51 -0
  206. package/_cjs/IO/api/array.cjs.map +1 -0
  207. package/_cjs/IO/api/asyncIO.cjs +1 -2
  208. package/_cjs/IO/api/asyncIO.cjs.map +1 -1
  209. package/_cjs/IO/api/asyncInterrupt.cjs +1 -2
  210. package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
  211. package/_cjs/IO/api/awaitAllChildren.cjs +17 -0
  212. package/_cjs/IO/api/awaitAllChildren.cjs.map +1 -0
  213. package/_cjs/IO/api/blocking.cjs +1 -2
  214. package/_cjs/IO/api/blocking.cjs.map +1 -1
  215. package/_cjs/IO/api/bracket.cjs +1 -2
  216. package/_cjs/IO/api/bracket.cjs.map +1 -1
  217. package/_cjs/IO/api/bracketExit.cjs +1 -2
  218. package/_cjs/IO/api/bracketExit.cjs.map +1 -1
  219. package/_cjs/IO/api/cachedInvalidate.cjs +47 -0
  220. package/_cjs/IO/api/cachedInvalidate.cjs.map +1 -0
  221. package/_cjs/IO/api/clockWith.cjs +1 -2
  222. package/_cjs/IO/api/clockWith.cjs.map +1 -1
  223. package/_cjs/IO/api/concurrency.cjs +1 -2
  224. package/_cjs/IO/api/concurrency.cjs.map +1 -1
  225. package/_cjs/IO/api/concurrentFinalizers.cjs +1 -2
  226. package/_cjs/IO/api/concurrentFinalizers.cjs.map +1 -1
  227. package/_cjs/IO/api/consoleWith.cjs +1 -2
  228. package/_cjs/IO/api/consoleWith.cjs.map +1 -1
  229. package/_cjs/IO/api/daemonChildren.cjs +1 -2
  230. package/_cjs/IO/api/daemonChildren.cjs.map +1 -1
  231. package/_cjs/IO/api/delay.cjs +1 -2
  232. package/_cjs/IO/api/delay.cjs.map +1 -1
  233. package/_cjs/IO/api/descriptor.cjs +1 -2
  234. package/_cjs/IO/api/descriptor.cjs.map +1 -1
  235. package/_cjs/IO/api/diffFiberRefs.cjs +1 -2
  236. package/_cjs/IO/api/diffFiberRefs.cjs.map +1 -1
  237. package/_cjs/IO/api/disconnect.cjs +2 -3
  238. package/_cjs/IO/api/disconnect.cjs.map +1 -1
  239. package/_cjs/IO/api/ensuringChildren.cjs +1 -2
  240. package/_cjs/IO/api/ensuringChildren.cjs.map +1 -1
  241. package/_cjs/IO/api/environment.cjs +1 -2
  242. package/_cjs/IO/api/environment.cjs.map +1 -1
  243. package/_cjs/IO/api/foreachConcurrent.cjs +36 -30
  244. package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
  245. package/_cjs/IO/api/foreachExec.cjs +30 -6
  246. package/_cjs/IO/api/foreachExec.cjs.map +1 -1
  247. package/_cjs/IO/api/fork.cjs +2 -3
  248. package/_cjs/IO/api/fork.cjs.map +1 -1
  249. package/_cjs/IO/api/forkAll.cjs +1 -2
  250. package/_cjs/IO/api/forkAll.cjs.map +1 -1
  251. package/_cjs/IO/api/forkDaemon.cjs +5 -6
  252. package/_cjs/IO/api/forkDaemon.cjs.map +1 -1
  253. package/_cjs/IO/api/forkIn.cjs +1 -2
  254. package/_cjs/IO/api/forkIn.cjs.map +1 -1
  255. package/_cjs/IO/api/forkScoped.cjs +1 -2
  256. package/_cjs/IO/api/forkScoped.cjs.map +1 -1
  257. package/_cjs/IO/api/fulfill.cjs +1 -2
  258. package/_cjs/IO/api/fulfill.cjs.map +1 -1
  259. package/_cjs/IO/api/interrupt.cjs +4 -5
  260. package/_cjs/IO/api/interrupt.cjs.map +1 -1
  261. package/_cjs/IO/api/memoize.cjs +1 -2
  262. package/_cjs/IO/api/memoize.cjs.map +1 -1
  263. package/_cjs/IO/api/onTermination.cjs +2 -3
  264. package/_cjs/IO/api/onTermination.cjs.map +1 -1
  265. package/_cjs/IO/api/once.cjs +1 -2
  266. package/_cjs/IO/api/once.cjs.map +1 -1
  267. package/_cjs/IO/api/patchFiberRefs.cjs +1 -2
  268. package/_cjs/IO/api/patchFiberRefs.cjs.map +1 -1
  269. package/_cjs/IO/api/provideLayer.cjs +1 -2
  270. package/_cjs/IO/api/provideLayer.cjs.map +1 -1
  271. package/_cjs/IO/api/provideScope.cjs +1 -2
  272. package/_cjs/IO/api/provideScope.cjs.map +1 -1
  273. package/_cjs/IO/api/provideSomeLayer.cjs +1 -2
  274. package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -1
  275. package/_cjs/IO/api/provideSomeRuntime.cjs +1 -2
  276. package/_cjs/IO/api/provideSomeRuntime.cjs.map +1 -1
  277. package/_cjs/IO/api/race.cjs +2 -3
  278. package/_cjs/IO/api/race.cjs.map +1 -1
  279. package/_cjs/IO/api/raceFirst.cjs +1 -2
  280. package/_cjs/IO/api/raceFirst.cjs.map +1 -1
  281. package/_cjs/IO/api/raceWith.cjs +1 -2
  282. package/_cjs/IO/api/raceWith.cjs.map +1 -1
  283. package/_cjs/IO/api/randomWith.cjs +1 -2
  284. package/_cjs/IO/api/randomWith.cjs.map +1 -1
  285. package/_cjs/IO/api/repeat.cjs +1 -2
  286. package/_cjs/IO/api/repeat.cjs.map +1 -1
  287. package/_cjs/IO/api/retry.cjs +1 -2
  288. package/_cjs/IO/api/retry.cjs.map +1 -1
  289. package/_cjs/IO/api/schedule.cjs +1 -2
  290. package/_cjs/IO/api/schedule.cjs.map +1 -1
  291. package/_cjs/IO/api/scope.cjs +1 -2
  292. package/_cjs/IO/api/scope.cjs.map +1 -1
  293. package/_cjs/IO/api/scopeWith.cjs +1 -2
  294. package/_cjs/IO/api/scopeWith.cjs.map +1 -1
  295. package/_cjs/IO/api/scoped.cjs +1 -2
  296. package/_cjs/IO/api/scoped.cjs.map +1 -1
  297. package/_cjs/IO/api/sleep.cjs +1 -2
  298. package/_cjs/IO/api/sleep.cjs.map +1 -1
  299. package/_cjs/IO/api/stateful.cjs +1 -2
  300. package/_cjs/IO/api/stateful.cjs.map +1 -1
  301. package/_cjs/IO/api/supervised.cjs +1 -2
  302. package/_cjs/IO/api/supervised.cjs.map +1 -1
  303. package/_cjs/IO/api/timeout.cjs +9 -11
  304. package/_cjs/IO/api/timeout.cjs.map +1 -1
  305. package/_cjs/IO/api/transplant.cjs +22 -7
  306. package/_cjs/IO/api/transplant.cjs.map +1 -1
  307. package/_cjs/IO/api/whenFiberRef.cjs +1 -2
  308. package/_cjs/IO/api/whenFiberRef.cjs.map +1 -1
  309. package/_cjs/IO/api/whenRef.cjs +1 -2
  310. package/_cjs/IO/api/whenRef.cjs.map +1 -1
  311. package/_cjs/IO/api/withChildren.cjs +1 -2
  312. package/_cjs/IO/api/withChildren.cjs.map +1 -1
  313. package/_cjs/IO/api/withEarlyRelease.cjs +1 -2
  314. package/_cjs/IO/api/withEarlyRelease.cjs.map +1 -1
  315. package/_cjs/IO/api/withFinalizer.cjs +1 -2
  316. package/_cjs/IO/api/withFinalizer.cjs.map +1 -1
  317. package/_cjs/IO/api/withFinalizerExit.cjs +1 -2
  318. package/_cjs/IO/api/withFinalizerExit.cjs.map +1 -1
  319. package/_cjs/IO/api/zipConcurrent.cjs +5 -6
  320. package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
  321. package/_cjs/IO/api.cjs +522 -473
  322. package/_cjs/IO/api.cjs.map +1 -1
  323. package/_cjs/IO/definition.cjs +2 -3
  324. package/_cjs/IO/definition.cjs.map +1 -1
  325. package/_cjs/IO/runtime.cjs +9 -10
  326. package/_cjs/IO/runtime.cjs.map +1 -1
  327. package/_cjs/IO.cjs +33 -11
  328. package/_cjs/IO.cjs.map +1 -1
  329. package/_cjs/IOEnv/definition.cjs +1 -2
  330. package/_cjs/IOEnv/definition.cjs.map +1 -1
  331. package/_cjs/IOEnv/live.cjs +1 -2
  332. package/_cjs/IOEnv/live.cjs.map +1 -1
  333. package/_cjs/IOEnv/services.cjs +1 -2
  334. package/_cjs/IOEnv/services.cjs.map +1 -1
  335. package/_cjs/Layer/MemoMap.cjs +1 -2
  336. package/_cjs/Layer/MemoMap.cjs.map +1 -1
  337. package/_cjs/Layer/api.cjs +1 -2
  338. package/_cjs/Layer/api.cjs.map +1 -1
  339. package/_cjs/Logger/api.cjs +1 -2
  340. package/_cjs/Logger/api.cjs.map +1 -1
  341. package/_cjs/Logger/constructors.cjs +1 -2
  342. package/_cjs/Logger/constructors.cjs.map +1 -1
  343. package/_cjs/MVar/api.cjs +1 -2
  344. package/_cjs/MVar/api.cjs.map +1 -1
  345. package/_cjs/Push/Bounds.cjs +2 -0
  346. package/_cjs/Push/Bounds.cjs.map +1 -0
  347. package/_cjs/Push/FlattenStrategy.cjs +95 -0
  348. package/_cjs/Push/FlattenStrategy.cjs.map +1 -0
  349. package/_cjs/Push/IndexedBuffer.cjs +70 -0
  350. package/_cjs/Push/IndexedBuffer.cjs.map +1 -0
  351. package/_cjs/Push/MergeStrategy.cjs +45 -0
  352. package/_cjs/Push/MergeStrategy.cjs.map +1 -0
  353. package/_cjs/Push/Operator/IOLoopOperator.cjs +225 -0
  354. package/_cjs/Push/Operator/IOLoopOperator.cjs.map +1 -0
  355. package/_cjs/Push/Operator/IOOperator.cjs +104 -0
  356. package/_cjs/Push/Operator/IOOperator.cjs.map +1 -0
  357. package/_cjs/Push/Operator/LoopOperator.cjs +165 -0
  358. package/_cjs/Push/Operator/LoopOperator.cjs.map +1 -0
  359. package/_cjs/Push/Operator/SyncOperator.cjs +78 -0
  360. package/_cjs/Push/Operator/SyncOperator.cjs.map +1 -0
  361. package/_cjs/Push/Operator.cjs +2 -0
  362. package/_cjs/Push/Operator.cjs.map +1 -0
  363. package/_cjs/Push/Producer/IOProducer.cjs +67 -0
  364. package/_cjs/Push/Producer/IOProducer.cjs.map +1 -0
  365. package/_cjs/Push/Producer/SyncProducer.cjs +107 -0
  366. package/_cjs/Push/Producer/SyncProducer.cjs.map +1 -0
  367. package/_cjs/Push/Producer.cjs +2 -0
  368. package/_cjs/Push/Producer.cjs.map +1 -0
  369. package/_cjs/Push/Sink.cjs +219 -0
  370. package/_cjs/Push/Sink.cjs.map +1 -0
  371. package/_cjs/Push/api.cjs +340 -385
  372. package/_cjs/Push/api.cjs.map +1 -1
  373. package/_cjs/Push/definition.cjs +79 -22
  374. package/_cjs/Push/definition.cjs.map +1 -1
  375. package/_cjs/Push/internal.cjs +32 -28
  376. package/_cjs/Push/internal.cjs.map +1 -1
  377. package/_cjs/Push.cjs +66 -0
  378. package/_cjs/Push.cjs.map +1 -1
  379. package/_cjs/Queue/api/dimapIO.cjs +1 -2
  380. package/_cjs/Queue/api/dimapIO.cjs.map +1 -1
  381. package/_cjs/Queue/api/filterInputIO.cjs +1 -2
  382. package/_cjs/Queue/api/filterInputIO.cjs.map +1 -1
  383. package/_cjs/Queue/api/filterOutputIO.cjs +1 -2
  384. package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -1
  385. package/_cjs/Queue/api/poll.cjs +1 -2
  386. package/_cjs/Queue/api/poll.cjs.map +1 -1
  387. package/_cjs/Queue/api/takeBetween.cjs +1 -2
  388. package/_cjs/Queue/api/takeBetween.cjs.map +1 -1
  389. package/_cjs/Queue/api/takeN.cjs +1 -2
  390. package/_cjs/Queue/api/takeN.cjs.map +1 -1
  391. package/_cjs/Queue/api/zipWithIO.cjs +1 -2
  392. package/_cjs/Queue/api/zipWithIO.cjs.map +1 -1
  393. package/_cjs/Queue/constructors.cjs +1 -2
  394. package/_cjs/Queue/constructors.cjs.map +1 -1
  395. package/_cjs/Queue/internal.cjs +1 -2
  396. package/_cjs/Queue/internal.cjs.map +1 -1
  397. package/_cjs/Queue/strategy.cjs +1 -2
  398. package/_cjs/Queue/strategy.cjs.map +1 -1
  399. package/_cjs/Random/api.cjs +1 -2
  400. package/_cjs/Random/api.cjs.map +1 -1
  401. package/_cjs/Random/definition.cjs +2 -2
  402. package/_cjs/Random/definition.cjs.map +1 -1
  403. package/_cjs/Random/live.cjs +1 -2
  404. package/_cjs/Random/live.cjs.map +1 -1
  405. package/_cjs/Ref/Atomic.cjs +1 -2
  406. package/_cjs/Ref/Atomic.cjs.map +1 -1
  407. package/_cjs/Ref/Derived.cjs +1 -2
  408. package/_cjs/Ref/Derived.cjs.map +1 -1
  409. package/_cjs/Ref/DerivedAll.cjs +1 -2
  410. package/_cjs/Ref/DerivedAll.cjs.map +1 -1
  411. package/_cjs/Ref/Synchronized/api.cjs +2 -3
  412. package/_cjs/Ref/Synchronized/api.cjs.map +1 -1
  413. package/_cjs/Ref/Synchronized/constructors.cjs +2 -3
  414. package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -1
  415. package/_cjs/Ref/Synchronized/definition.cjs +13 -14
  416. package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
  417. package/_cjs/Ref/api/collect.cjs +1 -2
  418. package/_cjs/Ref/api/collect.cjs.map +1 -1
  419. package/_cjs/Ref/api/dimap.cjs +1 -2
  420. package/_cjs/Ref/api/dimap.cjs.map +1 -1
  421. package/_cjs/Ref/api/filter.cjs +1 -2
  422. package/_cjs/Ref/api/filter.cjs.map +1 -1
  423. package/_cjs/Ref/api/modify.cjs +1 -2
  424. package/_cjs/Ref/api/modify.cjs.map +1 -1
  425. package/_cjs/Ref/api.cjs +1 -2
  426. package/_cjs/Ref/api.cjs.map +1 -1
  427. package/_cjs/Ref/constructors.cjs +1 -2
  428. package/_cjs/Ref/constructors.cjs.map +1 -1
  429. package/_cjs/Ref/definition.cjs.map +1 -1
  430. package/_cjs/Reloadable/api.cjs +1 -2
  431. package/_cjs/Reloadable/api.cjs.map +1 -1
  432. package/_cjs/Reloadable/constructors.cjs +1 -2
  433. package/_cjs/Reloadable/constructors.cjs.map +1 -1
  434. package/_cjs/Reloadable/definition.cjs +1 -2
  435. package/_cjs/Reloadable/definition.cjs.map +1 -1
  436. package/_cjs/RuntimeFlags/Patch.cjs +1 -2
  437. package/_cjs/RuntimeFlags/Patch.cjs.map +1 -1
  438. package/_cjs/RuntimeFlags/RuntimeFlags.cjs +1 -2
  439. package/_cjs/RuntimeFlags/RuntimeFlags.cjs.map +1 -1
  440. package/_cjs/STM/api/atomically.cjs +1 -2
  441. package/_cjs/STM/api/atomically.cjs.map +1 -1
  442. package/_cjs/STM/api/core-api.cjs +1 -2
  443. package/_cjs/STM/api/core-api.cjs.map +1 -1
  444. package/_cjs/STM/api.cjs +1 -2
  445. package/_cjs/STM/api.cjs.map +1 -1
  446. package/_cjs/STM/definition.cjs +2 -3
  447. package/_cjs/STM/definition.cjs.map +1 -1
  448. package/_cjs/STM/driver.cjs +1 -2
  449. package/_cjs/STM/driver.cjs.map +1 -1
  450. package/_cjs/STM/internal/CommitState.cjs +1 -2
  451. package/_cjs/STM/internal/CommitState.cjs.map +1 -1
  452. package/_cjs/STM/internal/Journal.cjs +1 -2
  453. package/_cjs/STM/internal/Journal.cjs.map +1 -1
  454. package/_cjs/Schedule/Decision.cjs +1 -2
  455. package/_cjs/Schedule/Decision.cjs.map +1 -1
  456. package/_cjs/Schedule/api/driver.cjs +1 -2
  457. package/_cjs/Schedule/api/driver.cjs.map +1 -1
  458. package/_cjs/Schedule/api.cjs +1 -2
  459. package/_cjs/Schedule/api.cjs.map +1 -1
  460. package/_cjs/Scope/Finalizer/definition.cjs +1 -2
  461. package/_cjs/Scope/Finalizer/definition.cjs.map +1 -1
  462. package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +1 -2
  463. package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs.map +1 -1
  464. package/_cjs/Scope/ReleaseMap/api.cjs +1 -2
  465. package/_cjs/Scope/ReleaseMap/api.cjs.map +1 -1
  466. package/_cjs/Scope/ReleaseMap/constructors.cjs +1 -2
  467. package/_cjs/Scope/ReleaseMap/constructors.cjs.map +1 -1
  468. package/_cjs/Scope/ReleaseMap/definition.cjs +1 -2
  469. package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -1
  470. package/_cjs/Scope/api.cjs +29 -9
  471. package/_cjs/Scope/api.cjs.map +1 -1
  472. package/_cjs/Scope/definition.cjs +1 -2
  473. package/_cjs/Scope/definition.cjs.map +1 -1
  474. package/_cjs/ScopedRef/api.cjs +2 -3
  475. package/_cjs/ScopedRef/api.cjs.map +1 -1
  476. package/_cjs/Semaphore/Reservation.cjs +24 -0
  477. package/_cjs/Semaphore/Reservation.cjs.map +1 -0
  478. package/_cjs/Semaphore/constructors.cjs +25 -0
  479. package/_cjs/Semaphore/constructors.cjs.map +1 -0
  480. package/_cjs/Semaphore/definition.cjs +149 -0
  481. package/_cjs/Semaphore/definition.cjs.map +1 -0
  482. package/_cjs/Semaphore.cjs +31 -138
  483. package/_cjs/Semaphore.cjs.map +1 -1
  484. package/_cjs/Sink/api.cjs +1 -2
  485. package/_cjs/Sink/api.cjs.map +1 -1
  486. package/_cjs/Sink/definition.cjs +2 -3
  487. package/_cjs/Sink/definition.cjs.map +1 -1
  488. package/_cjs/State/api.cjs +1 -2
  489. package/_cjs/State/api.cjs.map +1 -1
  490. package/_cjs/Stream/api/zipAllWith.cjs +1 -2
  491. package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
  492. package/_cjs/Stream/api/zipWith.cjs +1 -2
  493. package/_cjs/Stream/api/zipWith.cjs.map +1 -1
  494. package/_cjs/Stream/api/zipWithChunks.cjs +1 -2
  495. package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
  496. package/_cjs/Stream/api.cjs +702 -703
  497. package/_cjs/Stream/api.cjs.map +1 -1
  498. package/_cjs/Stream/definition.cjs.map +1 -1
  499. package/_cjs/Stream/internal/Handoff.cjs +1 -2
  500. package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
  501. package/_cjs/Stream/internal/Pull.cjs +1 -2
  502. package/_cjs/Stream/internal/Pull.cjs.map +1 -1
  503. package/_cjs/Stream/internal/Take.cjs +1 -2
  504. package/_cjs/Stream/internal/Take.cjs.map +1 -1
  505. package/_cjs/Stream/internal/util.cjs +1 -2
  506. package/_cjs/Stream/internal/util.cjs.map +1 -1
  507. package/_cjs/Subject/Atomic.cjs +46 -12
  508. package/_cjs/Subject/Atomic.cjs.map +1 -1
  509. package/_cjs/Subject/DeferredRef.cjs +53 -0
  510. package/_cjs/Subject/DeferredRef.cjs.map +1 -0
  511. package/_cjs/Subject/Hold.cjs +41 -0
  512. package/_cjs/Subject/Hold.cjs.map +1 -0
  513. package/_cjs/Subject/RefSubject/Atomic.cjs +130 -0
  514. package/_cjs/Subject/RefSubject/Atomic.cjs.map +1 -0
  515. package/_cjs/Subject/RefSubject/Derived.cjs +98 -0
  516. package/_cjs/Subject/RefSubject/Derived.cjs.map +1 -0
  517. package/_cjs/Subject/RefSubject/RefSubject.cjs +19 -0
  518. package/_cjs/Subject/RefSubject/RefSubject.cjs.map +1 -0
  519. package/_cjs/Subject/api.cjs +1 -2
  520. package/_cjs/Subject/api.cjs.map +1 -1
  521. package/_cjs/Subject/definition.cjs +16 -1
  522. package/_cjs/Subject/definition.cjs.map +1 -1
  523. package/_cjs/Subject.cjs +22 -0
  524. package/_cjs/Subject.cjs.map +1 -1
  525. package/_cjs/SubscriptionRef.cjs +2 -4
  526. package/_cjs/SubscriptionRef.cjs.map +1 -1
  527. package/_cjs/Supervisor/api.cjs +1 -2
  528. package/_cjs/Supervisor/api.cjs.map +1 -1
  529. package/_cjs/Supervisor/constructors.cjs +1 -2
  530. package/_cjs/Supervisor/constructors.cjs.map +1 -1
  531. package/_cjs/Supervisor/definition.cjs +1 -2
  532. package/_cjs/Supervisor/definition.cjs.map +1 -1
  533. package/_cjs/SupervisorPatch.cjs +1 -2
  534. package/_cjs/SupervisorPatch.cjs.map +1 -1
  535. package/_cjs/TExit/definition.cjs +1 -2
  536. package/_cjs/TExit/definition.cjs.map +1 -1
  537. package/_cjs/TFuture/api.cjs +1 -2
  538. package/_cjs/TFuture/api.cjs.map +1 -1
  539. package/_cjs/TFuture/constructors.cjs +1 -2
  540. package/_cjs/TFuture/constructors.cjs.map +1 -1
  541. package/_cjs/TFuture/definition.cjs +1 -2
  542. package/_cjs/TFuture/definition.cjs.map +1 -1
  543. package/_cjs/TReentrantLock/api.cjs +1 -2
  544. package/_cjs/TReentrantLock/api.cjs.map +1 -1
  545. package/_cjs/TReentrantLock/definition.cjs +1 -2
  546. package/_cjs/TReentrantLock/definition.cjs.map +1 -1
  547. package/_cjs/TRef/api.cjs +1 -2
  548. package/_cjs/TRef/api.cjs.map +1 -1
  549. package/_cjs/TRef/constructors.cjs +1 -2
  550. package/_cjs/TRef/constructors.cjs.map +1 -1
  551. package/_cjs/TRef/definition.cjs +1 -2
  552. package/_cjs/TRef/definition.cjs.map +1 -1
  553. package/_cjs/TSemaphore/api.cjs +1 -2
  554. package/_cjs/TSemaphore/api.cjs.map +1 -1
  555. package/_cjs/TSemaphore/constructors.cjs +1 -2
  556. package/_cjs/TSemaphore/constructors.cjs.map +1 -1
  557. package/_cjs/TSemaphore/definition.cjs +1 -2
  558. package/_cjs/TSemaphore/definition.cjs.map +1 -1
  559. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +1 -2
  560. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
  561. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +1 -2
  562. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
  563. package/_cjs/collection/immutable/Conc/filterIO.cjs +1 -2
  564. package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
  565. package/_cjs/collection/immutable/Conc/findIO.cjs +1 -2
  566. package/_cjs/collection/immutable/Conc/findIO.cjs.map +1 -1
  567. package/_cjs/collection/immutable/Conc/mapIO.cjs +1 -2
  568. package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
  569. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +1 -2
  570. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
  571. package/_cjs/data/Exit/foreachIO.cjs +1 -2
  572. package/_cjs/data/Exit/foreachIO.cjs.map +1 -1
  573. package/_cjs/internal/HashedPair.cjs +1 -2
  574. package/_cjs/internal/HashedPair.cjs.map +1 -1
  575. package/_cjs/internal/Hub.cjs +1 -2
  576. package/_cjs/internal/Hub.cjs.map +1 -1
  577. package/_cjs/internal/MutableQueue.cjs +1 -2
  578. package/_cjs/internal/MutableQueue.cjs.map +1 -1
  579. package/_cjs/internal/Scheduler.cjs +1 -2
  580. package/_cjs/internal/Scheduler.cjs.map +1 -1
  581. package/_cjs/internal/StackTraceBuilder.cjs +1 -2
  582. package/_cjs/internal/StackTraceBuilder.cjs.map +1 -1
  583. package/_mjs/Cached/api.mjs.map +1 -1
  584. package/_mjs/Channel/api/mapOutConcurrentIO.mjs +1 -1
  585. package/_mjs/Channel/api/mergeAllWith.mjs +1 -1
  586. package/_mjs/Channel/api/runScoped.mjs +2 -2
  587. package/_mjs/Channel/api/runScoped.mjs.map +1 -1
  588. package/_mjs/Channel/api/toPull.mjs +1 -1
  589. package/_mjs/Channel/api/toPull.mjs.map +1 -1
  590. package/_mjs/Channel/api.mjs +205 -205
  591. package/_mjs/Channel/api.mjs.map +1 -1
  592. package/_mjs/Channel/core-api.mjs +43 -42
  593. package/_mjs/Channel/core-api.mjs.map +1 -1
  594. package/_mjs/Channel/internal/ChannelExecutor.mjs +3 -3
  595. package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
  596. package/_mjs/Console/definition.mjs +1 -0
  597. package/_mjs/Console/definition.mjs.map +1 -1
  598. package/_mjs/CountdownLatch.mjs +2 -1
  599. package/_mjs/CountdownLatch.mjs.map +1 -1
  600. package/_mjs/Fiber/FiberMessage.mjs +2 -20
  601. package/_mjs/Fiber/FiberMessage.mjs.map +1 -1
  602. package/_mjs/Fiber/FiberRuntime.mjs +877 -633
  603. package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
  604. package/_mjs/Fiber/api/collectAll.mjs +1 -1
  605. package/_mjs/Fiber/api/collectAll.mjs.map +1 -1
  606. package/_mjs/Fiber/api/interrupt.mjs +1 -1
  607. package/_mjs/Fiber/api/interrupt.mjs.map +1 -1
  608. package/_mjs/Fiber/api/interruptAll.mjs +1 -1
  609. package/_mjs/Fiber/api/interruptAll.mjs.map +1 -1
  610. package/_mjs/Fiber/api/interruptAs.mjs +4 -7
  611. package/_mjs/Fiber/api/interruptAs.mjs.map +1 -1
  612. package/_mjs/Fiber/api/interruptFork.mjs +1 -1
  613. package/_mjs/Fiber/api/interruptFork.mjs.map +1 -1
  614. package/_mjs/Fiber/api/mapIO.mjs +1 -1
  615. package/_mjs/Fiber/api/mapIO.mjs.map +1 -1
  616. package/_mjs/Fiber/api/zipWith.mjs +1 -1
  617. package/_mjs/Fiber/api/zipWith.mjs.map +1 -1
  618. package/_mjs/Fiber/constructors.mjs +1 -1
  619. package/_mjs/Fiber/constructors.mjs.map +1 -1
  620. package/_mjs/Fiber/definition.mjs +5 -2
  621. package/_mjs/Fiber/definition.mjs.map +1 -1
  622. package/_mjs/FiberScope/definition.mjs +28 -4
  623. package/_mjs/FiberScope/definition.mjs.map +1 -1
  624. package/_mjs/FiberSet.mjs +14 -12
  625. package/_mjs/FiberSet.mjs.map +1 -1
  626. package/_mjs/Future/State.mjs +96 -0
  627. package/_mjs/Future/State.mjs.map +1 -0
  628. package/_mjs/Future/api.mjs +67 -61
  629. package/_mjs/Future/api.mjs.map +1 -1
  630. package/_mjs/Future/constructors.mjs +3 -3
  631. package/_mjs/Future/constructors.mjs.map +1 -1
  632. package/_mjs/Future/definition.mjs +0 -12
  633. package/_mjs/Future/definition.mjs.map +1 -1
  634. package/_mjs/Future.mjs +1 -0
  635. package/_mjs/Future.mjs.map +1 -1
  636. package/_mjs/Hub/api.mjs +55 -55
  637. package/_mjs/Hub/api.mjs.map +1 -1
  638. package/_mjs/IO/api/array.mjs +42 -0
  639. package/_mjs/IO/api/array.mjs.map +1 -0
  640. package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
  641. package/_mjs/IO/api/awaitAllChildren.mjs +10 -0
  642. package/_mjs/IO/api/awaitAllChildren.mjs.map +1 -0
  643. package/_mjs/IO/api/cachedInvalidate.mjs +39 -0
  644. package/_mjs/IO/api/cachedInvalidate.mjs.map +1 -0
  645. package/_mjs/IO/api/disconnect.mjs +1 -1
  646. package/_mjs/IO/api/disconnect.mjs.map +1 -1
  647. package/_mjs/IO/api/foreachConcurrent.mjs +35 -28
  648. package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
  649. package/_mjs/IO/api/foreachExec.mjs +27 -4
  650. package/_mjs/IO/api/foreachExec.mjs.map +1 -1
  651. package/_mjs/IO/api/fork.mjs +1 -1
  652. package/_mjs/IO/api/fork.mjs.map +1 -1
  653. package/_mjs/IO/api/forkDaemon.mjs +4 -4
  654. package/_mjs/IO/api/forkDaemon.mjs.map +1 -1
  655. package/_mjs/IO/api/interrupt.mjs +3 -3
  656. package/_mjs/IO/api/onTermination.mjs +1 -1
  657. package/_mjs/IO/api/onTermination.mjs.map +1 -1
  658. package/_mjs/IO/api/race.mjs +1 -1
  659. package/_mjs/IO/api/race.mjs.map +1 -1
  660. package/_mjs/IO/api/timeout.mjs +8 -9
  661. package/_mjs/IO/api/timeout.mjs.map +1 -1
  662. package/_mjs/IO/api/transplant.mjs +19 -5
  663. package/_mjs/IO/api/transplant.mjs.map +1 -1
  664. package/_mjs/IO/api/zipConcurrent.mjs +4 -4
  665. package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
  666. package/_mjs/IO/api.mjs +515 -468
  667. package/_mjs/IO/api.mjs.map +1 -1
  668. package/_mjs/IO/definition.mjs +1 -1
  669. package/_mjs/IO/definition.mjs.map +1 -1
  670. package/_mjs/IO/runtime.mjs +8 -8
  671. package/_mjs/IO/runtime.mjs.map +1 -1
  672. package/_mjs/IO.mjs +3 -1
  673. package/_mjs/IO.mjs.map +1 -1
  674. package/_mjs/IOEnv/definition.mjs.map +1 -1
  675. package/_mjs/Push/Bounds.mjs +2 -0
  676. package/_mjs/Push/Bounds.mjs.map +1 -0
  677. package/_mjs/Push/FlattenStrategy.mjs +86 -0
  678. package/_mjs/Push/FlattenStrategy.mjs.map +1 -0
  679. package/_mjs/Push/IndexedBuffer.mjs +61 -0
  680. package/_mjs/Push/IndexedBuffer.mjs.map +1 -0
  681. package/_mjs/Push/MergeStrategy.mjs +34 -0
  682. package/_mjs/Push/MergeStrategy.mjs.map +1 -0
  683. package/_mjs/Push/Operator/IOLoopOperator.mjs +208 -0
  684. package/_mjs/Push/Operator/IOLoopOperator.mjs.map +1 -0
  685. package/_mjs/Push/Operator/IOOperator.mjs +91 -0
  686. package/_mjs/Push/Operator/IOOperator.mjs.map +1 -0
  687. package/_mjs/Push/Operator/LoopOperator.mjs +151 -0
  688. package/_mjs/Push/Operator/LoopOperator.mjs.map +1 -0
  689. package/_mjs/Push/Operator/SyncOperator.mjs +67 -0
  690. package/_mjs/Push/Operator/SyncOperator.mjs.map +1 -0
  691. package/_mjs/Push/Operator.mjs +2 -0
  692. package/_mjs/Push/Operator.mjs.map +1 -0
  693. package/_mjs/Push/Producer/IOProducer.mjs +55 -0
  694. package/_mjs/Push/Producer/IOProducer.mjs.map +1 -0
  695. package/_mjs/Push/Producer/SyncProducer.mjs +90 -0
  696. package/_mjs/Push/Producer/SyncProducer.mjs.map +1 -0
  697. package/_mjs/Push/Producer.mjs +2 -0
  698. package/_mjs/Push/Producer.mjs.map +1 -0
  699. package/_mjs/Push/Sink.mjs +206 -0
  700. package/_mjs/Push/Sink.mjs.map +1 -0
  701. package/_mjs/Push/api.mjs +311 -344
  702. package/_mjs/Push/api.mjs.map +1 -1
  703. package/_mjs/Push/definition.mjs +73 -18
  704. package/_mjs/Push/definition.mjs.map +1 -1
  705. package/_mjs/Push/internal.mjs +30 -26
  706. package/_mjs/Push/internal.mjs.map +1 -1
  707. package/_mjs/Push.mjs +7 -1
  708. package/_mjs/Push.mjs.map +1 -1
  709. package/_mjs/Random/definition.mjs +1 -0
  710. package/_mjs/Random/definition.mjs.map +1 -1
  711. package/_mjs/Ref/Synchronized/api.mjs +1 -1
  712. package/_mjs/Ref/Synchronized/api.mjs.map +1 -1
  713. package/_mjs/Ref/Synchronized/constructors.mjs +1 -1
  714. package/_mjs/Ref/Synchronized/definition.mjs +12 -12
  715. package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
  716. package/_mjs/Ref/definition.mjs.map +1 -1
  717. package/_mjs/STM/definition.mjs +1 -1
  718. package/_mjs/Scope/api.mjs +22 -4
  719. package/_mjs/Scope/api.mjs.map +1 -1
  720. package/_mjs/ScopedRef/api.mjs +1 -1
  721. package/_mjs/ScopedRef/api.mjs.map +1 -1
  722. package/_mjs/Semaphore/Reservation.mjs +16 -0
  723. package/_mjs/Semaphore/Reservation.mjs.map +1 -0
  724. package/_mjs/Semaphore/constructors.mjs +17 -0
  725. package/_mjs/Semaphore/constructors.mjs.map +1 -0
  726. package/_mjs/Semaphore/definition.mjs +141 -0
  727. package/_mjs/Semaphore/definition.mjs.map +1 -0
  728. package/_mjs/Semaphore.mjs +4 -133
  729. package/_mjs/Semaphore.mjs.map +1 -1
  730. package/_mjs/Sink/definition.mjs +2 -3
  731. package/_mjs/Sink/definition.mjs.map +1 -1
  732. package/_mjs/Stream/api.mjs +701 -701
  733. package/_mjs/Stream/api.mjs.map +1 -1
  734. package/_mjs/Stream/definition.mjs.map +1 -1
  735. package/_mjs/Subject/Atomic.mjs +46 -10
  736. package/_mjs/Subject/Atomic.mjs.map +1 -1
  737. package/_mjs/Subject/DeferredRef.mjs +45 -0
  738. package/_mjs/Subject/DeferredRef.mjs.map +1 -0
  739. package/_mjs/Subject/Hold.mjs +33 -0
  740. package/_mjs/Subject/Hold.mjs.map +1 -0
  741. package/_mjs/Subject/RefSubject/Atomic.mjs +122 -0
  742. package/_mjs/Subject/RefSubject/Atomic.mjs.map +1 -0
  743. package/_mjs/Subject/RefSubject/Derived.mjs +90 -0
  744. package/_mjs/Subject/RefSubject/Derived.mjs.map +1 -0
  745. package/_mjs/Subject/RefSubject/RefSubject.mjs +12 -0
  746. package/_mjs/Subject/RefSubject/RefSubject.mjs.map +1 -0
  747. package/_mjs/Subject/definition.mjs +14 -0
  748. package/_mjs/Subject/definition.mjs.map +1 -1
  749. package/_mjs/Subject.mjs +2 -0
  750. package/_mjs/Subject.mjs.map +1 -1
  751. package/_mjs/SubscriptionRef.mjs +1 -2
  752. package/_mjs/SubscriptionRef.mjs.map +1 -1
  753. package/_src/Cached/api.ts +3 -3
  754. package/_src/Channel/api/toPull.ts +1 -1
  755. package/_src/Channel/api.ts +273 -272
  756. package/_src/Channel/core-api.ts +57 -55
  757. package/_src/Channel/internal/ChannelExecutor.ts +3 -3
  758. package/_src/Console/definition.ts +1 -0
  759. package/_src/CountdownLatch.ts +2 -0
  760. package/_src/Fiber/FiberMessage.ts +3 -28
  761. package/_src/Fiber/FiberRuntime.ts +988 -616
  762. package/_src/Fiber/api/interruptAs.ts +4 -3
  763. package/_src/Fiber/constructors.ts +1 -1
  764. package/_src/Fiber/definition.ts +4 -0
  765. package/_src/FiberScope/definition.ts +40 -2
  766. package/_src/FiberSet.ts +6 -2
  767. package/_src/Future/State.ts +128 -0
  768. package/_src/Future/api.ts +62 -51
  769. package/_src/Future/constructors.ts +4 -2
  770. package/_src/Future/definition.ts +2 -17
  771. package/_src/Future.ts +4 -3
  772. package/_src/Hub/api.ts +61 -61
  773. package/_src/IO/api/addFinalizerExit.ts +4 -4
  774. package/_src/IO/api/array.ts +49 -0
  775. package/_src/IO/api/asyncInterrupt.ts +1 -1
  776. package/_src/IO/api/awaitAllChildren.ts +6 -0
  777. package/_src/IO/api/cachedInvalidate.ts +42 -0
  778. package/_src/IO/api/foreachConcurrent.ts +39 -23
  779. package/_src/IO/api/foreachExec.ts +47 -0
  780. package/_src/IO/api/fork.ts +1 -1
  781. package/_src/IO/api/forkDaemon.ts +2 -2
  782. package/_src/IO/api/memoize.ts +3 -3
  783. package/_src/IO/api/onTermination.ts +2 -2
  784. package/_src/IO/api/transplant.ts +26 -3
  785. package/_src/IO/api/zipConcurrent.ts +2 -2
  786. package/_src/IO/api.ts +547 -525
  787. package/_src/IO/definition.ts +4 -28
  788. package/_src/IO/runtime.ts +0 -1
  789. package/_src/IO.ts +65 -63
  790. package/_src/IOEnv/definition.ts +1 -4
  791. package/_src/Push/Bounds.ts +4 -0
  792. package/_src/Push/FlattenStrategy.ts +137 -0
  793. package/_src/Push/IndexedBuffer.ts +79 -0
  794. package/_src/Push/MergeStrategy.ts +59 -0
  795. package/_src/Push/Operator/IOLoopOperator.ts +413 -0
  796. package/_src/Push/Operator/IOOperator.ts +173 -0
  797. package/_src/Push/Operator/LoopOperator.ts +242 -0
  798. package/_src/Push/Operator/SyncOperator.ts +107 -0
  799. package/_src/Push/Operator.ts +7 -0
  800. package/_src/Push/Producer/IOProducer.ts +83 -0
  801. package/_src/Push/Producer/SyncProducer.ts +105 -0
  802. package/_src/Push/Producer.ts +0 -0
  803. package/_src/Push/Sink.ts +302 -0
  804. package/_src/Push/api.ts +387 -513
  805. package/_src/Push/definition.ts +216 -23
  806. package/_src/Push/internal.ts +11 -0
  807. package/_src/Push.ts +7 -1
  808. package/_src/Random/definition.ts +1 -0
  809. package/_src/Ref/Synchronized/api.ts +2 -2
  810. package/_src/Ref/Synchronized/definition.ts +82 -38
  811. package/_src/Ref/definition.ts +26 -0
  812. package/_src/Scope/api.ts +22 -0
  813. package/_src/Semaphore/Reservation.ts +15 -0
  814. package/_src/Semaphore/constructors.ts +14 -0
  815. package/_src/Semaphore/definition.ts +180 -0
  816. package/_src/Semaphore.ts +5 -159
  817. package/_src/Sink/definition.ts +4 -5
  818. package/_src/Stream/api.ts +679 -679
  819. package/_src/Stream/definition.ts +0 -1
  820. package/_src/Subject/Atomic.ts +68 -11
  821. package/_src/Subject/DeferredRef.ts +44 -0
  822. package/_src/Subject/Hold.ts +48 -0
  823. package/_src/Subject/RefSubject/Atomic.ts +193 -0
  824. package/_src/Subject/RefSubject/Derived.ts +179 -0
  825. package/_src/Subject/RefSubject/RefSubject.ts +90 -0
  826. package/_src/Subject/definition.ts +21 -3
  827. package/_src/Subject.ts +5 -3
  828. package/_src/SubscriptionRef.ts +1 -1
  829. package/_src/index.ts +49 -50
  830. package/index.d.ts +0 -1
  831. package/package.json +4 -4
  832. package/IO/api/sequenceT.d.ts +0 -26
  833. package/RefSubject/Atomic.d.ts +0 -34
  834. package/RefSubject/Synchronized/api.d.ts +0 -9
  835. package/RefSubject/Synchronized/definition.d.ts +0 -39
  836. package/RefSubject/api.d.ts +0 -120
  837. package/RefSubject/definition.d.ts +0 -52
  838. package/RefSubject.d.ts +0 -3
  839. package/_cjs/IO/api/sequenceT.cjs +0 -18
  840. package/_cjs/IO/api/sequenceT.cjs.map +0 -1
  841. package/_cjs/RefSubject/Atomic.cjs +0 -108
  842. package/_cjs/RefSubject/Atomic.cjs.map +0 -1
  843. package/_cjs/RefSubject/Synchronized/api.cjs +0 -23
  844. package/_cjs/RefSubject/Synchronized/api.cjs.map +0 -1
  845. package/_cjs/RefSubject/Synchronized/definition.cjs +0 -56
  846. package/_cjs/RefSubject/Synchronized/definition.cjs.map +0 -1
  847. package/_cjs/RefSubject/api.cjs +0 -252
  848. package/_cjs/RefSubject/api.cjs.map +0 -1
  849. package/_cjs/RefSubject/definition.cjs +0 -26
  850. package/_cjs/RefSubject/definition.cjs.map +0 -1
  851. package/_cjs/RefSubject.cjs +0 -39
  852. package/_cjs/RefSubject.cjs.map +0 -1
  853. package/_mjs/IO/api/sequenceT.mjs +0 -10
  854. package/_mjs/IO/api/sequenceT.mjs.map +0 -1
  855. package/_mjs/RefSubject/Atomic.mjs +0 -99
  856. package/_mjs/RefSubject/Atomic.mjs.map +0 -1
  857. package/_mjs/RefSubject/Synchronized/api.mjs +0 -15
  858. package/_mjs/RefSubject/Synchronized/api.mjs.map +0 -1
  859. package/_mjs/RefSubject/Synchronized/definition.mjs +0 -47
  860. package/_mjs/RefSubject/Synchronized/definition.mjs.map +0 -1
  861. package/_mjs/RefSubject/api.mjs +0 -229
  862. package/_mjs/RefSubject/api.mjs.map +0 -1
  863. package/_mjs/RefSubject/definition.mjs +0 -19
  864. package/_mjs/RefSubject/definition.mjs.map +0 -1
  865. package/_mjs/RefSubject.mjs +0 -5
  866. package/_mjs/RefSubject.mjs.map +0 -1
  867. package/_src/IO/api/sequenceT.ts +0 -16
  868. package/_src/RefSubject/Atomic.ts +0 -129
  869. package/_src/RefSubject/Synchronized/api.ts +0 -14
  870. package/_src/RefSubject/Synchronized/definition.ts +0 -76
  871. package/_src/RefSubject/api.ts +0 -253
  872. package/_src/RefSubject/definition.ts +0 -70
  873. package/_src/RefSubject.ts +0 -5
package/_src/Push/api.ts CHANGED
@@ -1,58 +1,85 @@
1
- import { AtomicReference } from "@fncts/base/internal/AtomicReference";
2
- import { IO } from "@fncts/io/IO";
3
- import { withExhaust, withSwitch, withUnboundedConcurrency } from "@fncts/io/Push/internal";
1
+ import type { MergeStrategy } from "./MergeStrategy.js";
2
+ import type { UnsafeSink } from "@fncts/io/Push/Sink";
3
+
4
+ import { IO, IOTag } from "@fncts/io/IO";
5
+ import { FlattenStrategy, UnboundedStrategy } from "@fncts/io/Push";
6
+ import { Push, PushPrimitive, PushTag } from "@fncts/io/Push";
7
+ import { SyncProducer } from "@fncts/io/Push/Producer/SyncProducer";
8
+ import { Sink } from "@fncts/io/Push/Sink";
9
+ import { Scope } from "@fncts/io/Scope";
10
+
11
+ import { FromIO, FromScheduled, type IOProducer, Scheduled } from "./Producer/IOProducer.js";
12
+
13
+ class BracketExit<R, E, A, R1, E1, B, R2, E2, C> extends Push<R | R1 | R2, E | E1 | E2, B> {
14
+ constructor(
15
+ readonly acquire: IO<R, E, A>,
16
+ readonly use: (a: A) => Push<R1, E1, B>,
17
+ readonly release: (a: A, exit: Exit<unknown, unknown>) => IO<R2, E2, C>,
18
+ ) {
19
+ super();
20
+ }
4
21
 
5
- import { Push, PushTypeId, PushVariance, Sink } from "./definition.js";
22
+ run<R3>(sink: Push.UnsafeSink<R3, E | E1 | E2, B>): IO<R | R1 | R2 | R3, never, void> {
23
+ return IO.bracketExit(
24
+ this.acquire,
25
+ (a) => this.use(a).run(sink),
26
+ (a, exit) => this.release(a, exit).catchAllCause(sink.onFailure),
27
+ ).catchAllCause(sink.onFailure);
28
+ }
29
+ }
6
30
 
7
31
  /**
8
- * @tsplus pipeable fncts.io.Push as
32
+ * @tsplus static fncts.io.PushOps bracketExit
9
33
  */
10
- export function as<B>(b: Lazy<B>) {
11
- return <R, E, A>(self: Push<R, E, A>): Push<R, E, B> => {
12
- return self.map(b);
13
- };
34
+ export function bracketExit<R, E, A, R1, E1, B, R2, E2, C>(
35
+ acquire: IO<R, E, A>,
36
+ use: (a: A) => Push<R1, E1, B>,
37
+ release: (a: A, exit: Exit<unknown, unknown>) => IO<R2, E2, C>,
38
+ ): Push<R | R1 | R2, E | E1 | E2, B> {
39
+ return new BracketExit(acquire, use, release);
14
40
  }
15
41
 
16
- interface UnsafeSink<E, A> {
17
- event: (value: A) => void;
18
- error: (cause: Cause<E>) => void;
19
- }
42
+ class CombineLatest<R, E, A> extends Push<R | Scope, E, ReadonlyArray<A>> {
43
+ private static UNSET = Symbol();
20
44
 
21
- /**
22
- * @tsplus static fncts.io.PushOps asyncInterrupt
23
- */
24
- export function asyncInterrupt<R, E, A>(
25
- make: (emitter: UnsafeSink<E, A>) => Either<IO<R, never, void>, Push<R, E, A>>,
26
- ): Push<R, E, A> {
27
- return Push<R, E, A>(
28
- <R1>(sink: Sink<R | R1, E, A>) =>
45
+ constructor(readonly streams: Iterable<Push<R, E, A>>) {
46
+ super();
47
+ }
48
+
49
+ run<R1>(sink: UnsafeSink<R1, E, readonly A[]>): IO<Scope | R | R1, never, void> {
50
+ return UnboundedStrategy.withFork((fork) =>
29
51
  Do((Δ) => {
30
- const future = Δ(Future.make<never, void>());
31
- const scope = Δ(IO.scope);
32
- const runtime = Δ(IO.runtime<R | R1>());
33
- const unsafeSink: UnsafeSink<E, A> = {
34
- event: (value) => runtime.unsafeRunOrFork(sink.event(value).forkIn(scope)),
35
- error: (cause) => runtime.unsafeRunOrFork(sink.error(cause).fulfill(future).forkIn(scope)),
36
- };
37
- const eitherPush = Δ(IO(make(unsafeSink)));
52
+ const size = this.streams.size;
53
+ const latch = Δ(CountdownLatch(size));
54
+ const ref: Array<A> = Array(size).fill(CombineLatest.UNSET, 0, size);
55
+ const emitIfReady = IO.defer(sink.onSuccess(ref)).whenIO(latch.isOpen);
56
+
38
57
  Δ(
39
- eitherPush.match(
40
- (canceller) => future.await.onInterrupt(canceller),
41
- (push) => push.run(sink),
58
+ IO.foreach(this.streams.zipWithIndex, ([i, stream]) =>
59
+ fork(
60
+ stream.run(
61
+ Sink.unsafeMake(
62
+ (value) =>
63
+ IO.defer(() => {
64
+ const indexEmpty = ref[i] === CombineLatest.UNSET;
65
+
66
+ ref[i] = value;
67
+
68
+ if (indexEmpty) {
69
+ return latch.countDown;
70
+ } else {
71
+ return IO.unit;
72
+ }
73
+ }) > emitIfReady,
74
+ (cause) => sink.onFailure(cause),
75
+ ),
76
+ ),
77
+ ),
42
78
  ),
43
79
  );
44
- }).scoped,
45
- );
46
- }
47
-
48
- /**
49
- * @tsplus static fncts.io.PushOps async
50
- */
51
- export function async<E, A>(make: (sink: UnsafeSink<E, A>) => void): Push<never, E, A> {
52
- return Push.asyncInterrupt((sink) => {
53
- make(sink);
54
- return Either.left(IO.unit);
55
- });
80
+ }),
81
+ );
82
+ }
56
83
  }
57
84
 
58
85
  /**
@@ -60,647 +87,494 @@ export function async<E, A>(make: (sink: UnsafeSink<E, A>) => void): Push<never,
60
87
  */
61
88
  export function combineLatest<A extends ReadonlyArray<Push<any, any, any>>>(
62
89
  streams: [...A],
63
- ): Push<Push.EnvironmentOf<A[number]>, Push.ErrorOf<A[number]>, { [K in keyof A]: Push.ValueOf<A[K]> }>;
64
- export function combineLatest<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R, E, ReadonlyArray<A>>;
65
- export function combineLatest<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R, E, ReadonlyArray<A>> {
66
- return Push((emitter) =>
67
- Do() => {
68
- const size = streams.size;
69
- const ref: Array<A> = Δ(IO(Array(size)));
70
- const emitIfReady = IO(ref.filter((a) => a != null)).flatMap((as) =>
71
- as.length === size ? emitter.event(as) : IO.unit,
72
- );
73
- Δ(
74
- IO.foreachConcurrent(streams.zipWithIndex, ([i, stream]) =>
75
- stream.run(
76
- Sink(
77
- (value) => IO((ref[i] = value)) > emitIfReady,
78
- (cause) => emitter.error(cause),
79
- ),
80
- ),
81
- ),
82
- );
83
- }),
84
- );
90
+ ): Push<Push.EnvironmentOf<A[number]> | Scope, Push.ErrorOf<A[number]>, { [K in keyof A]: Push.ValueOf<A[K]> }>;
91
+
92
+ export function combineLatest<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R | Scope, E, ReadonlyArray<A>>;
93
+ export function combineLatest<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R | Scope, E, ReadonlyArray<A>> {
94
+ return new CombineLatest(streams);
95
+ }
96
+ class ContramapEnvironment<R, E, A, R1> extends Push<R1, E, A> {
97
+ constructor(
98
+ readonly self: Push<R, E, A>,
99
+ readonly f: (r: Environment<R1>) => Environment<R>,
100
+ ) {
101
+ super();
102
+ }
103
+
104
+ run<R2>(sink: UnsafeSink<R2, E, A>): IO<R1 | R2, never, void> {
105
+ return this.self.run(sink).contramapEnvironment(this.f);
106
+ }
85
107
  }
86
108
 
87
109
  /**
88
- * @tsplus pipeable fncts.io.PushOps combineLatestWith
110
+ * @tsplus pipeable fncts.io.Push contramapEnvironment
89
111
  */
90
- export function combineLatestWith<A, R1, E1, B, C>(that: Push<R1, E1, B>, f: (a: A, b: B) => C) {
91
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, C> => {
92
- return Push.combineLatest([self, that]).map(([a, b]) => f(a, b));
93
- };
112
+ export function contramapEnvironment<R, R1>(f: (r: Environment<R1>) => Environment<R>) {
113
+ return <E, A>(self: Push<R, E, A>): Push<R1, E, A> => new ContramapEnvironment(self, f);
94
114
  }
95
115
 
96
- /**
97
- * @tsplus pipeable fncts.io.Push debounce
98
- */
99
- export function debounce(duration: Lazy<Duration>) {
100
- return <R, E, A>(self: Push<R, E, A>): Push<R, E, A> => {
101
- return self.switchMapIO((a) => IO.succeedNow(a).delay(duration));
102
- };
116
+ class Defer<R, E, A> extends Push<R, E, A> {
117
+ constructor(readonly self: Lazy<Push<R, E, A>>) {
118
+ super();
119
+ }
120
+ run<R1>(sink: UnsafeSink<R1, E, A>): IO<R | R1, never, void> {
121
+ return IO.defer(this.self().run(sink));
122
+ }
103
123
  }
104
124
 
105
125
  /**
106
126
  * @tsplus static fncts.io.PushOps defer
107
127
  */
108
128
  export function defer<R, E, A>(self: Lazy<Push<R, E, A>>): Push<R, E, A> {
109
- return Push((emitter) => IO(self).flatMap((push) => push.run(emitter)));
129
+ return new Defer(self);
110
130
  }
111
131
 
112
132
  /**
113
- * @tsplus pipeable fncts.io.Push exhaustMap
133
+ * @tsplus static fncts.io.PushOps failCause
114
134
  */
115
- export function exhaustMap<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
116
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
117
- return Push((sink) => withExhaust((fork) => self.run(Sink((a) => fork(f(a).run(sink)), sink.error))));
118
- };
135
+ export function failCause<E>(cause: Lazy<Cause<E>>): Push<never, E, never> {
136
+ const op = new PushPrimitive(PushTag.FailCause) as any;
137
+ op.i0 = cause;
138
+ return op;
119
139
  }
120
140
 
121
141
  /**
122
- * @tsplus pipeable fncts.io.Push exhaustMapIO
142
+ * @tsplus static fncts.io.PushOps failCauseNow
123
143
  */
124
- export function exhaustMapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>) {
125
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
126
- return self.exhaustMap((a) => Push.fromIO(f(a)));
127
- };
144
+ export function failCauseNow<E>(cause: Cause<E>): Push<never, E, never> {
145
+ const op = new PushPrimitive(PushTag.FailCause) as any;
146
+ op.i0 = () => cause;
147
+ return op;
128
148
  }
129
149
 
130
150
  /**
131
- * @tsplus pipeable fncts.io.Push filterIO
151
+ * @tsplus static fncts.io.PushOps failNow
132
152
  */
133
- export function filterIO<A, R1, E1>(predicate: (a: A) => IO<R1, E1, boolean>) {
134
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, A> => {
135
- return Push((sink) =>
136
- self.run(
137
- Sink(
138
- (a) =>
139
- predicate(a)
140
- .flatMap((b) => (b ? sink.event(a) : IO.unit))
141
- .catchAllCause(sink.error),
142
- sink.error,
143
- ),
144
- ),
145
- );
146
- };
153
+ export function failNow<E>(error: E): Push<never, E, never> {
154
+ return Push.failCauseNow(Cause.fail(error));
147
155
  }
148
156
 
149
- /**
150
- * @tsplus pipeable fncts.io.Push filterMapIO
151
- */
152
- export function filterMapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Maybe<B>>) {
153
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
154
- return Push((sink) =>
155
- self.run(
156
- Sink(
157
- (a) =>
158
- f(a)
159
- .flatMap((mb) => mb.match(() => IO.unit, sink.event))
160
- .catchAllCause(sink.error),
161
- sink.error,
162
- ),
157
+ class Filter<R, E, A, B extends A = A> extends Push<R, E, B> {
158
+ constructor(
159
+ readonly self: Push<R, E, A>,
160
+ readonly p: Predicate<A>,
161
+ ) {
162
+ super();
163
+ }
164
+ run<R1>(sink: UnsafeSink<R1, E, B>): IO<R | R1, never, void> {
165
+ return this.self.run(
166
+ Sink.unsafeMake(
167
+ (value) => {
168
+ if (this.p(value)) {
169
+ return sink.onSuccess(value as B);
170
+ } else {
171
+ return IO.unit;
172
+ }
173
+ },
174
+ (cause) => sink.onFailure(cause),
163
175
  ),
164
176
  );
165
- };
177
+ }
166
178
  }
167
179
 
168
180
  /**
169
181
  * @tsplus pipeable fncts.io.Push filter
170
182
  */
171
- export function filter<A, B extends A>(refinement: Refinement<A, B>): <R, E>(self: Push<R, E, A>) => Push<R, E, B>;
172
- export function filter<A>(predicate: Predicate<A>): <R, E>(self: Push<R, E, A>) => Push<R, E, A>;
173
- export function filter<A>(predicate: Predicate<A>) {
174
- return <R, E>(self: Push<R, E, A>): Push<R, E, A> => {
175
- return Push((sink) => self.run(Sink((a) => (predicate(a) ? sink.event(a) : IO.unit), sink.error)));
176
- };
183
+ export function filter<A, B extends A>(p: Refinement<A, B>): <R, E>(self: Push<R, E, A>) => Push<R, E, B>;
184
+ export function filter<A>(p: Predicate<A>): <R, E>(self: Push<R, E, A>) => Push<R, E, A>;
185
+ export function filter<A>(p: Predicate<A>) {
186
+ return <R, E>(self: Push<R, E, A>): Push<R, E, A> => new Filter(self, p);
187
+ }
188
+ class FilterMap<R, E, A, B> extends Push<R, E, B> {
189
+ constructor(
190
+ readonly self: Push<R, E, A>,
191
+ readonly f: (value: A) => Maybe<B>,
192
+ ) {
193
+ super();
194
+ }
195
+ run<R1>(sink: UnsafeSink<R1, E, B>): IO<R | R1, never, void> {
196
+ return this.self.run(
197
+ Sink.unsafeMake(
198
+ (value) =>
199
+ this.f(value).match(
200
+ () => IO.unit,
201
+ (b) => sink.onSuccess(b),
202
+ ),
203
+ (cause) => sink.onFailure(cause),
204
+ ),
205
+ );
206
+ }
177
207
  }
178
208
 
179
209
  /**
180
210
  * @tsplus pipeable fncts.io.Push filterMap
181
211
  */
182
- export function filterMap<A, B>(f: (a: A) => Maybe<B>) {
183
- return <R, E>(self: Push<R, E, A>): Push<R, E, B> => {
184
- return Push((sink) => self.run(Sink((a) => f(a).match(() => IO.unit, sink.event), sink.error)));
185
- };
212
+ export function filterMap<A, B>(f: (value: A) => Maybe<B>) {
213
+ return <R, E>(self: Push<R, E, A>): Push<R, E, B> => new FilterMap(self, f);
186
214
  }
187
215
 
188
216
  /**
189
- * @tsplus pipeable fncts.io.Push flatMapConcurrentBounded
217
+ * @tsplus pipeable fncts.io.Push flatMap
190
218
  */
191
- export function flatMapConcurrentBounded<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>, concurrency: number) {
219
+ export function flatMap<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
192
220
  return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
193
- return Push(<R2>(emitter: Sink<R | R1 | R2, E | E1, B>) =>
194
- Do((Δ) => {
195
- const semaphore = Δ(Semaphore(concurrency));
196
- Δ(self.flatMapConcurrentUnbounded((a) => f(a).transform((io) => semaphore.withPermit(io))).run(emitter));
197
- }),
198
- );
221
+ const op = new PushPrimitive(PushTag.OnSuccess);
222
+ op.i0 = self;
223
+ op.i1 = f;
224
+ return op;
199
225
  };
200
226
  }
201
227
 
202
228
  /**
203
- * @tsplus pipeable fncts.io.Push flatMapConcurrentUnbounded
229
+ * @tsplus pipeable fncts.io.Push flatMapUnbounded
204
230
  */
205
- export function flatMapConcurrentUnbounded<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
206
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
207
- return Push((sink) => withUnboundedConcurrency((fork) => self.run(Sink((a) => fork(f(a).run(sink)), sink.error))));
208
- };
231
+ export function flatMapUnbounded<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
232
+ return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> =>
233
+ self.flatMapWithStrategy(f, FlattenStrategy.Unbounded, ExecutionStrategy.concurrent);
209
234
  }
210
235
 
211
236
  /**
212
- * @tsplus pipeable fncts.io.Push flatMapConcurrent
237
+ * @tsplus pipeable fncts.io.Push flatMapWithStrategy
213
238
  */
214
- export function flatMapConcurrent<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
239
+ export function flatMapWithStrategy<A, R1, E1, B>(
240
+ f: (a: A) => Push<R1, E1, B>,
241
+ flattenStrategy: FlattenStrategy,
242
+ executionStrategy: ExecutionStrategy,
243
+ ) {
215
244
  return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
216
- return Push.unwrap(
217
- IO.concurrency.map((concurrency) =>
218
- concurrency.match(
219
- () => self.flatMapConcurrentUnbounded(f),
220
- (n) => self.flatMapConcurrentBounded(f, n),
221
- ),
222
- ),
223
- );
245
+ const op = new PushPrimitive(PushTag.OnSuccessWithStrategy);
246
+ op.i0 = self;
247
+ op.i1 = f;
248
+ op.i2 = flattenStrategy;
249
+ op.i3 = executionStrategy;
250
+ return op;
224
251
  };
225
252
  }
226
253
 
227
254
  /**
228
- * @tsplus pipeable fncts.io.Push flatMap
255
+ * @tsplus static fncts.io.PushOps fromArray
229
256
  */
230
- export function flatMap<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
231
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
232
- return self.flatMapConcurrentBounded(f, 1);
233
- };
257
+ export function fromArray<A extends ReadonlyArray<any>>(array: A): Push<never, never, A[number]> {
258
+ return Push.fromSyncProducer(SyncProducer.fromArray(array));
234
259
  }
235
-
236
- /**
237
- * @tsplus getter fncts.io.Push flatten
238
- */
239
- export function flatten<R, E, R1, E1, A>(self: Push<R, E, Push<R1, E1, A>>): Push<R | R1, E | E1, A> {
240
- return self.flatMap(Function.identity);
241
- }
242
-
243
260
  /**
244
261
  * @tsplus static fncts.io.PushOps fromIO
245
262
  */
246
- export function fromIO<R, E, A>(io: Lazy<IO<R, E, A>>): Push<R, E, A> {
247
- return Push((emitter) =>
248
- IO.defer(io).matchCauseIO(
249
- (cause) => emitter.error(cause),
250
- (value) => emitter.event(value),
251
- ),
252
- );
263
+ export function fromIO<R, E, A>(io: IO<R, E, A>): Push<R, E, A> {
264
+ const concrete = IO.concrete(io);
265
+ switch (concrete._ioOpCode) {
266
+ case IOTag.SucceedNow: {
267
+ return Push.succeedNow(concrete.i0);
268
+ }
269
+ case IOTag.Fail: {
270
+ return Push.failCause<any>(concrete.i0);
271
+ }
272
+ case IOTag.Sync: {
273
+ return Push.fromSyncProducer(SyncProducer.fromSync(concrete.i0));
274
+ }
275
+ default: {
276
+ return Push.fromIOProducer(new FromIO(io));
277
+ }
278
+ }
253
279
  }
254
-
255
280
  /**
256
- * @tsplus static fncts.io.PushOps fromAsyncIterable
281
+ * @tsplus static fncts.io.PushOps fromIOProducer
257
282
  */
258
- export function fromAsyncIterable<A>(iterable: AsyncIterable<A>): Push<never, never, A> {
259
- return Push(<R>(sink: Sink<R, never, A>) =>
260
- IO.asyncIO<R, never, void>((cb) => IO.defer(fromAsyncIterableLoop(iterable[Symbol.asyncIterator](), sink, cb))),
261
- );
262
- }
263
-
264
- function fromAsyncIterableLoop<A, R>(
265
- iterator: AsyncIterator<A>,
266
- sink: Sink<R, never, A>,
267
- cb: (io: UIO<void>) => void,
268
- __tsplusTrace?: string,
269
- ): IO<R, never, void> {
270
- return IO.fromPromiseHalt(iterator.next).matchCauseIO(
271
- (cause) => sink.error(cause),
272
- (result) => (result.done ? IO(cb(IO.unit)) : sink.event(result.value) > fromAsyncIterableLoop(iterator, sink, cb)),
273
- );
283
+ export function fromIOProducer<R, E, A>(producer: IOProducer<R, E, A>): Push<R, E, A> {
284
+ const op = new PushPrimitive(PushTag.ProducerIO);
285
+ op.i0 = producer;
286
+ return op;
274
287
  }
275
288
 
276
289
  /**
277
290
  * @tsplus static fncts.io.PushOps fromIterable
278
291
  */
279
292
  export function fromIterable<A>(iterable: Iterable<A>): Push<never, never, A> {
280
- return Push(<R>(sink: Sink<R, never, A>) =>
281
- IO.asyncIO<R, never, void>((cb) => IO.defer(fromIterableLoop(iterable[Symbol.iterator](), sink, cb))),
282
- );
293
+ return Push.fromSyncProducer(SyncProducer.fromIterable(iterable));
283
294
  }
284
295
 
285
- function fromIterableLoop<A, R>(
286
- iterator: Iterator<A>,
287
- sink: Sink<R, never, A>,
288
- cb: (io: UIO<void>) => void,
289
- ): IO<R, never, void> {
290
- return IO.defer(() => {
291
- const value = iterator.next();
292
- return value.done ? IO(cb(IO.unit)) : sink.event(value.value) > fromIterableLoop(iterator, sink, cb);
293
- });
296
+ /**
297
+ * @tsplus static fncts.io.PushOps fromScheduled
298
+ */
299
+ export function fromScheduled<R, E, I, R1, O>(io: IO<R, E, I>, schedule: Schedule<R1, I, O>): Push<R | R1, E, O> {
300
+ return Push.fromIOProducer(new FromScheduled(io, schedule));
294
301
  }
295
302
 
296
303
  /**
297
- * @tsplus getter fncts.io.Push multicast
304
+ * @tsplus static fncts.io.PushOps fromSyncProducer
298
305
  */
299
- export function multicast<R, E, A>(self: Push<R, E, A>): Push<R, E, A> {
300
- return new Multicast(self);
306
+ export function fromSyncProducer<A>(producer: SyncProducer<A>): Push<never, never, A> {
307
+ const op = new PushPrimitive(PushTag.ProducerSync) as any;
308
+ op.i0 = producer;
309
+ return op;
301
310
  }
302
311
 
303
- interface MulticastObserver<E, A> {
304
- readonly sink: Sink<any, E, A>;
305
- readonly environment: Environment<any>;
312
+ /**
313
+ * @tsplus static fncts.io.PushOps haltNow
314
+ */
315
+ export function haltNow(error: unknown): Push<never, never, never> {
316
+ return Push.failCauseNow(Cause.halt(error));
306
317
  }
307
318
 
308
- export class Multicast<R, E, A> implements Push<R, E, A>, Sink<never, E, A> {
309
- readonly [PushTypeId]: PushTypeId = PushTypeId;
310
- declare [PushVariance]: {
311
- readonly _R: (_: never) => R;
312
- readonly _E: (_: never) => E;
313
- readonly _A: (_: never) => A;
314
- };
315
- protected observers: Array<MulticastObserver<E, A>> = [];
316
- protected fiber: Fiber<never, unknown> | undefined;
317
- constructor(readonly push: Push<R, E, A>) {}
318
-
319
- run<R1>(sink: Sink<R1, E, A>): IO<R | R1, never, void> {
320
- return Do((Δ) => {
321
- const environment = Δ(IO.environment<R1>());
322
- Δ(
323
- IO.defer(() => {
324
- let io: URIO<R, void> = IO.unit;
325
- if (this.observers.push({ sink: sink, environment }) === 1) {
326
- io = this.push.run(this).forkDaemon.flatMap((fiber) => IO((this.fiber = fiber)));
327
- }
328
- return io > this.fiber!.await.ensuring(this.removeSink(sink));
329
- }),
330
- );
331
- });
332
- }
333
-
334
- event(value: A) {
335
- return IO.defer(IO.foreachDiscard(this.observers.slice(), (observer) => this.runValue(value, observer)));
336
- }
337
-
338
- error(cause: Cause<E>) {
339
- return IO.defer(IO.foreachDiscard(this.observers.slice(), (observer) => this.runError(cause, observer)));
340
- }
341
-
342
- protected runValue(value: A, observer: MulticastObserver<E, A>) {
343
- return observer.sink
344
- .event(value)
345
- .provideEnvironment(observer.environment)
346
- .catchAllCause(() => this.removeSink(observer.sink));
347
- }
319
+ /**
320
+ * @tsplus static fncts.io.PushOps __call
321
+ */
322
+ export function makePush<R, E, A>(
323
+ run: <R1>(sink: Push.UnsafeSink<R1, E, A>) => IO<R | R1, never, unknown>,
324
+ ): Push<R, E, A> {
325
+ const op = new PushPrimitive(PushTag.FromPush) as any;
326
+ op.i0 = run;
327
+ return op;
328
+ }
348
329
 
349
- protected runError(cause: Cause<E>, observer: MulticastObserver<E, A>) {
350
- return observer.sink
351
- .error(cause)
352
- .provideEnvironment(observer.environment)
353
- .catchAllCause(() => this.removeSink(observer.sink));
330
+ class Map<R, E, A, B> extends Push<R, E, B> {
331
+ constructor(
332
+ readonly self: Push<R, E, A>,
333
+ readonly f: (a: A) => B,
334
+ ) {
335
+ super();
354
336
  }
355
-
356
- protected removeSink(sink: Sink<any, E, A>) {
357
- return IO.defer(() => {
358
- if (this.observers.length === 0) {
359
- return IO.unit;
360
- }
361
- const index = this.observers.findIndex((observer) => observer.sink === sink);
362
- if (index > -1) {
363
- this.observers.splice(index, 1);
364
- if (this.observers.length === 0) {
365
- const interrupt = this.fiber!.interrupt;
366
- this.fiber = undefined;
367
- return interrupt;
368
- }
369
- }
370
- return IO.unit;
371
- });
337
+ run<R1>(sink: UnsafeSink<R1, E, B>): IO<R | R1, never, void> {
338
+ return this.self.run(
339
+ Sink.unsafeMake(
340
+ (value) => sink.onSuccess(this.f(value)),
341
+ (cause) => sink.onFailure(cause),
342
+ ),
343
+ );
372
344
  }
373
345
  }
374
346
 
375
347
  /**
376
- * @tsplus getter fncts.io.Push hold
348
+ * @tsplus pipeable fncts.io.Push map
377
349
  */
378
- export function hold<R, E, A>(self: Push<R, E, A>): Push<R, E, A> {
379
- return new Hold(self);
350
+ export function map<A, B>(f: (a: A) => B) {
351
+ return <R, E>(self: Push<R, E, A>): Push<R, E, B> => new Map(self, f);
380
352
  }
381
353
 
382
- export class Hold<R, E, A> extends Multicast<R, E, A> {
383
- readonly current = new AtomicReference(Nothing<A>());
384
-
385
- constructor(public push: Push<R, E, A>) {
386
- super(push);
354
+ class MapAccum<R, E, A, S, B> extends Push<R, E, B> {
355
+ constructor(
356
+ readonly self: Push<R, E, A>,
357
+ readonly seed: S,
358
+ readonly f: (acc: S, a: A) => readonly [S, B],
359
+ ) {
360
+ super();
387
361
  }
388
362
 
389
- run<R1>(sink: Sink<R1, E, A>): IO<R | R1, never, void> {
390
- const current = this.current.get;
391
-
392
- if (current.isJust()) {
393
- return sink.event(current.value) > super.run(sink);
394
- }
395
-
396
- return super.run(sink);
397
- }
398
-
399
- event(value: A): IO<never, never, void> {
363
+ run<R1>(sink: UnsafeSink<R1, E, B>): IO<R | R1, never, void> {
400
364
  return IO.defer(() => {
401
- this.current.set(Just(value));
402
- return super.event(value);
365
+ let acc = this.seed;
366
+ return this.self.run(
367
+ Sink.unsafeMake(
368
+ (value) => {
369
+ const [s, b] = this.f(acc, value);
370
+ acc = s;
371
+ return sink.onSuccess(b);
372
+ },
373
+ (cause) => sink.onFailure(cause),
374
+ ),
375
+ );
403
376
  });
404
377
  }
405
378
  }
406
379
 
407
380
  /**
408
- * @tsplus pipeable fncts.io.Push map 1
381
+ * @tsplus pipeable fncts.io.Push mapAccum
409
382
  */
410
- export function map<A, B>(f: (a: A) => B) {
411
- return <R, E>(self: Push<R, E, A>): Push<R, E, B> => {
412
- return self.mapIO((a) => IO.succeedNow(f(a)));
413
- };
383
+ export function mapAccum<A, S, B>(seed: S, f: (acc: S, a: A) => readonly [S, B]) {
384
+ return <R, E>(self: Push<R, E, A>): Push<R, E, B> => new MapAccum(self, seed, f);
414
385
  }
415
386
 
416
- /**
417
- * @tsplus pipeable fncts.io.Push mapError
418
- */
419
- export function mapError<E, E1>(f: (e: E) => E1) {
420
- return <R, A>(self: Push<R, E, A>): Push<R, E1, A> => {
421
- return Push((emitter) =>
422
- self.run(
423
- Sink(
424
- (value) => emitter.event(value),
425
- (cause) => emitter.error(cause.map(f)),
426
- ),
427
- ),
428
- );
429
- };
430
- }
387
+ class MapIO<R, E, A, R1, E1, B> extends Push<R | R1, E | E1, B> {
388
+ constructor(
389
+ readonly self: Push<R, E, A>,
390
+ readonly f: (a: A) => IO<R1, E1, B>,
391
+ ) {
392
+ super();
393
+ }
431
394
 
432
- /**
433
- * @tsplus pipeable fncts.io.Push mapErrorCause
434
- */
435
- export function mapErrorCause<E, E1>(f: (cause: Cause<E>) => Cause<E1>) {
436
- return <R, A>(self: Push<R, E, A>): Push<R, E1, A> => {
437
- return Push((emitter) =>
438
- self.run(
439
- Sink(
440
- (value) => emitter.event(value),
441
- (cause) => emitter.error(f(cause)),
442
- ),
395
+ run<R2>(sink: UnsafeSink<R2, E | E1, B>): IO<R | R1 | R2, never, void> {
396
+ return this.self.run(
397
+ Sink.unsafeMake(
398
+ (value) => this.f(value).matchCauseIO(sink.onFailure, sink.onSuccess),
399
+ (cause) => sink.onFailure(cause),
443
400
  ),
444
401
  );
445
- };
402
+ }
446
403
  }
447
404
 
448
405
  /**
449
406
  * @tsplus pipeable fncts.io.Push mapIO
450
407
  */
451
408
  export function mapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>) {
452
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> =>
453
- Push((emitter) =>
454
- self.run(
455
- Sink(
456
- (value) =>
457
- f(value).matchCauseIO(
458
- (cause) => emitter.error(cause),
459
- (b) => emitter.event(b),
460
- ),
461
- (cause) => emitter.error(cause),
462
- ),
463
- ),
464
- );
409
+ return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => new MapIO(self, f);
465
410
  }
466
411
 
467
412
  /**
468
- * @tsplus pipeable fncts.io.Push merge
413
+ * @tsplus pipeable fncts.io.Push mapIOWithStrategy
469
414
  */
470
- export function merge<R1, E1, B>(that: Push<R1, E1, B>) {
471
- return <R, E, A>(self: Push<R, E, A>): Push<R | R1, E | E1, A | B> => {
472
- return Push.mergeAll([self, that]);
473
- };
415
+ export function mapIOWithStrategy<A, R1, E1, B>(
416
+ f: (a: A) => IO<R1, E1, B>,
417
+ flattenStrategy: FlattenStrategy,
418
+ executionStrategy: ExecutionStrategy,
419
+ ) {
420
+ return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> =>
421
+ self.flatMapWithStrategy((a) => Push.fromIO(f(a)), flattenStrategy, executionStrategy);
422
+ }
423
+
424
+ class MergeWithStrategy<Ps extends ReadonlyArray<Push<any, any, any>>> extends Push<
425
+ Push.EnvironmentOf<Ps[number]>,
426
+ Push.ErrorOf<Ps[number]>,
427
+ Push.ValueOf<Ps[number]>
428
+ > {
429
+ constructor(
430
+ readonly ps: Ps,
431
+ readonly mergeStrategy: MergeStrategy,
432
+ ) {
433
+ super();
434
+ }
435
+
436
+ run<R1>(
437
+ sink: UnsafeSink<R1, Push.ErrorOf<Ps[number]>, Push.ValueOf<Ps[number]>>,
438
+ ): IO<Push.EnvironmentOf<Ps[number]> | R1, never, void> {
439
+ return this.mergeStrategy.runMerge(this.ps, sink);
440
+ }
474
441
  }
475
442
 
476
443
  /**
477
- * @tsplus static fncts.io.PushOps mergeAll
444
+ * @tsplus static fncts.io.PushOps mergeWithStrategy
478
445
  */
479
- export function mergeAll<A extends ReadonlyArray<Push<any, any, any>>>(
480
- streams: [...A],
481
- ): Push<Push.EnvironmentOf<A[number]>, Push.ErrorOf<A[number]>, Push.ValueOf<A[number]>>;
482
- export function mergeAll<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R, E, A>;
483
- export function mergeAll<R, E, A>(streams: Iterable<Push<R, E, A>>): Push<R, E, A> {
484
- return Push((sink) =>
485
- IO.foreachConcurrentDiscard(streams, (stream) =>
486
- stream.run(Sink(sink.event, (cause) => (cause.isInterruptedOnly ? IO.unit : sink.error(cause)))),
487
- ),
488
- );
446
+ export function mergeWithStrategy<Ps extends ReadonlyArray<Push<any, any, any>>>(
447
+ streams: Ps,
448
+ mergeStrategy: MergeStrategy,
449
+ ): Push<Push.EnvironmentOf<Ps[number]>, Push.ErrorOf<Ps[number]>, Push.ValueOf<Ps[number]>> {
450
+ return new MergeWithStrategy(streams, mergeStrategy);
489
451
  }
490
452
 
491
453
  /**
492
454
  * @tsplus pipeable fncts.io.Push observe
493
455
  */
494
- export function observe<A, R1, E1>(f: (a: A) => IO<R1, E1, void>, __tsplusTrace?: string) {
495
- return <R, E>(self: Push<R, E, A>): IO<R | R1 | Scope, E | E1, void> => {
496
- return Do((Δ) => {
497
- const future = Δ(Future.make<E | E1, void>());
498
- const fiber = Δ(
499
- self
500
- .run(
501
- Sink(
502
- (a) => f(a).catchAllCause((cause) => future.failCause(cause)),
503
- (cause) => future.failCause(cause),
504
- ),
505
- )
506
- .flatMap(() => future.succeed(undefined)).forkScoped,
507
- );
508
-
509
- Δ(future.await);
510
- Δ(fiber.interruptFork);
511
- });
456
+ export function observe<A, R1>(f: (a: A) => IO<R1, never, void>) {
457
+ return <R, E>(self: Push<R, E, A>): IO<R | R1, never, void> => {
458
+ return self.run(Sink.unsafeMake(f, (cause) => IO.failCause(cause).orHalt));
512
459
  };
513
460
  }
514
461
 
515
- /**
516
- * @tsplus static fncts.io.PushOps repeatIOMaybe
517
- */
518
- export function repeatIOMaybe<R, E, A>(io: IO<R, Maybe<E>, A>, __tsplusTrace?: string): Push<R, E, A> {
519
- return Push.unfoldIO(undefined, () =>
520
- io
521
- .map((a) => Just([a, undefined] as const))
522
- .catchAll((maybeError) => maybeError.match(() => IO.succeedNow(Nothing()), IO.failNow)),
523
- );
524
- }
525
-
526
- /**
527
- * @tsplus getter fncts.io.Push runCollect
528
- */
529
- export function runCollect<R, E, A>(self: Push<R, E, A>): IO<R | Scope, E, Conc<A>> {
530
- return IO.defer(() => {
531
- const out: Array<A> = [];
532
- return self.observe((a) => IO(out.push(a))).as(Conc.fromArray(out));
533
- });
462
+ class OrElseCause<R, E, A, R1, E1, B> extends Push<R | R1, E | E1, A | B> {
463
+ constructor(
464
+ readonly self: Push<R, E, A>,
465
+ readonly that: (cause: Cause<E>) => Push<R1, E1, B>,
466
+ ) {
467
+ super();
468
+ }
469
+ run<R2>(sink: UnsafeSink<R2, E | E1, A | B>): IO<R | R1 | R2, never, void> {
470
+ return this.self.run(Sink.unsafeMake(sink.onSuccess, (cause) => this.that(cause).run(sink)));
471
+ }
534
472
  }
535
473
 
536
474
  /**
537
- * @tsplus getter fncts.io.Push runDrain
475
+ * @tsplus pipeable fncts.io.Push orElseCause
538
476
  */
539
- export function runDrain<R, E, A>(self: Push<R, E, A>): IO<R | Scope, E, void> {
540
- return self.observe(() => IO.unit);
477
+ export function orElseCause<E, R1, E1, B>(that: (cause: Cause<E>) => Push<R1, E1, B>) {
478
+ return <R, A>(self: Push<R, E, A>): Push<R | R1, E | E1, A | B> => new OrElseCause(self, that);
541
479
  }
542
480
 
543
481
  /**
544
- * @tsplus static fncts.io.PushOps scoped
482
+ * @tsplus pipeable fncts.io.Push provideEnvironment
545
483
  */
546
- export function scoped<R, E, A>(io: Lazy<IO<R, E, A>>, __tsplusTrace?: string): Push<Exclude<R, Scope>, E, A> {
547
- return Push((emitter) =>
548
- IO.defer(io).scoped.matchCauseIO(
549
- (cause) => emitter.error(cause),
550
- (value) => emitter.event(value),
551
- ),
552
- );
484
+ export function provideEnvironment<R>(environment: Environment<R>) {
485
+ return <E, A>(self: Push<R, E, A>): Push<never, E, A> => self.provideSomeEnvironment(environment);
553
486
  }
554
487
 
555
- /**
556
- * @tsplus static fncts.io.PushOps succeed
557
- */
558
- export function succeed<A>(value: Lazy<A>): Push<never, never, A> {
559
- return Push.fromIO(IO.succeed(value));
488
+ class ProvideLayer<R, E, A, R1, E1, R2> extends Push<Exclude<R, R2> | R1, E | E1, A> {
489
+ constructor(
490
+ readonly self: Push<R, E, A>,
491
+ readonly layer: Layer<R1, E1, R2>,
492
+ ) {
493
+ super();
494
+ }
495
+ run<R3>(sink: UnsafeSink<R3, E | E1, A>): IO<R1 | Exclude<R, R2> | R3, never, void> {
496
+ return IO.bracketExit(
497
+ Scope.make,
498
+ (scope) =>
499
+ this.layer
500
+ .build(scope)
501
+ .matchCauseIO(sink.onFailure, (environment) => this.self.run(sink).provideSomeEnvironment(environment)),
502
+ (scope, exit) => scope.close(exit),
503
+ );
504
+ }
560
505
  }
561
506
 
562
507
  /**
563
- * @tsplus pipeable fncts.io.Push switchMap
508
+ * @tsplus pipeable fncts.io.Push provideLayer
564
509
  */
565
- export function switchMap<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>) {
566
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
567
- return Push((sink) => withSwitch((fork) => self.run(Sink((a) => fork(f(a).run(sink)), sink.error))));
568
- };
510
+ export function provideLayer<R1, E1, R2>(layer: Layer<R1, E1, R2>) {
511
+ return <R, E, A>(self: Push<R, E, A>): Push<Exclude<R, R2> | R1, E | E1, A> => new ProvideLayer(self, layer);
569
512
  }
570
513
 
571
514
  /**
572
- * @tsplus pipeable fncts.io.Push switchMapIO
515
+ * @tsplus pipeable fncts.io.Push provideSomeEnvironment
573
516
  */
574
- export function switchMapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>) {
575
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> => {
576
- return self.switchMap((a) => Push.fromIO(f(a)));
577
- };
517
+ export function provideSomeEnvironment<R1>(environment: Environment<R1>) {
518
+ return <R, E, A>(self: Push<R, E, A>): Push<Exclude<R, R1>, E, A> =>
519
+ self.contramapEnvironment((r) => r.union(environment));
578
520
  }
579
521
 
580
522
  /**
581
- * @tsplus pipeable fncts.io.Push tap
523
+ * @tsplus static fncts.io.PushOps schedule
582
524
  */
583
- export function tap<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>) {
584
- return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, A> => {
585
- return Push((sink) => self.run(Sink((a) => f(a).matchCauseIO(sink.error, () => sink.event(a)), sink.error)));
586
- };
525
+ export function schedule<R, E, A, R1, O>(io: IO<R, E, A>, schedule: Schedule<R1, unknown, O>): Push<R | R1, E, A> {
526
+ return Push.fromIOProducer(new Scheduled(io, schedule));
587
527
  }
588
528
 
589
529
  /**
590
- * @tsplus pipeable fncts.io.Push transform
530
+ * @tsplus static fncts.io.PushOps succeed
591
531
  */
592
- export function transform<R1 = never>(f: <R, E, A>(io: IO<R, E, A>) => IO<R | R1, E, A>) {
593
- return <R, E, A>(self: Push<R, E, A>): Push<R | R1, E, A> => Push((emitter) => f(self.run(emitter)));
594
- }
595
-
596
- function unfoldLoop<S, A, R1>(
597
- s: S,
598
- f: (s: S) => Maybe<readonly [A, S]>,
599
- emitter: Sink<R1, never, A>,
600
- ): IO<R1, never, void> {
601
- return f(s).match(
602
- () => IO.unit,
603
- ([a, s]) => emitter.event(a) > unfoldLoop(s, f, emitter),
604
- );
532
+ export function succeed<A>(value: Lazy<A>): Push<never, never, A> {
533
+ return Push.fromSyncProducer(SyncProducer.fromSync(value));
605
534
  }
606
535
 
607
536
  /**
608
- * @tsplus static fncts.io.PushOps unfold
537
+ * @tsplus static fncts.io.PushOps succeedNow
609
538
  */
610
- export function unfold<S, A>(s: S, f: (s: S) => Maybe<readonly [A, S]>): Push<never, never, A> {
611
- return Push((emitter) => unfoldLoop(s, f, emitter));
612
- }
613
-
614
- function unfoldIOLoop<S, R, E, A, R1>(
615
- s: S,
616
- f: (s: S) => IO<R, E, Maybe<readonly [A, S]>>,
617
- emitter: Sink<R1, E, A>,
618
- ): IO<R | R1, never, void> {
619
- return f(s)
620
- .flatMap((result) =>
621
- result.match(
622
- () => IO.unit,
623
- ([a, s]) => emitter.event(a) > unfoldIOLoop(s, f, emitter),
624
- ),
625
- )
626
- .catchAllCause((cause) => emitter.error(cause));
539
+ export function succeedNow<A>(value: A): Push<never, never, A> {
540
+ return Push.fromSyncProducer(SyncProducer.Success(value));
627
541
  }
628
542
 
629
543
  /**
630
- * @tsplus static fncts.io.PushOps unfoldIO
544
+ * @tsplus pipeable fncts.io.Push switchMap
631
545
  */
632
- export function unfoldIO<S, R, E, A>(s: S, f: (s: S) => IO<R, E, Maybe<readonly [A, S]>>): Push<R, E, A> {
633
- return Push((emitter) => unfoldIOLoop(s, f, emitter));
546
+ export function switchMap<A, R1, E1, B>(f: (a: A) => Push<R1, E1, B>, executionStrategy?: ExecutionStrategy) {
547
+ return <R, E>(self: Push<R, E, A>): Push<R | R1, E | E1, B> =>
548
+ self.flatMapWithStrategy(f, FlattenStrategy.Switch, executionStrategy ?? ExecutionStrategy.sequential);
634
549
  }
635
550
 
636
551
  /**
637
- * @tsplus pipeable fncts.io.Push untilFuture
552
+ * @tsplus pipeable fncts.io.Push transform
638
553
  */
639
- export function untilFuture<E1, B>(future: Future<E1, B>) {
640
- return <R, E, A>(self: Push<R, E, A>): Push<R, E | E1, A> => {
641
- return Push(<R1>(sink: Sink<R1, E | E1, A>) =>
642
- IO.asyncIO<R | R1, never, void>((cb) => {
643
- const exit = IO(cb(IO.unit));
644
- return Do((Δ) => {
645
- const streamFiber = Δ(self.run(sink).fork);
646
- const futureFiber = Δ(
647
- future.await
648
- .matchCauseIO(
649
- (cause) => sink.error(cause),
650
- () => IO.unit,
651
- )
652
- .zipRight(exit).fork,
653
- );
654
- Δ(Fiber.joinAll([streamFiber, futureFiber]));
655
- });
656
- }),
657
- );
554
+ export function transform<R, R1>(f: (io: IO<R, never, void>) => IO<R1, never, void>) {
555
+ return <E, A>(self: Push<R, E, A>): Push<R | R1, E, A> => {
556
+ const op = new PushPrimitive(PushTag.Transform);
557
+ op.i0 = self;
558
+ op.i1 = f;
559
+ return op;
658
560
  };
659
561
  }
660
562
 
661
- /**
662
- * @tsplus pipeable fncts.io.Push untilPush
663
- */
664
- export function untilPush<R1, E1, B>(signal: Push<R1, E1, B>) {
665
- return <R, E, A>(self: Push<R, E, A>): Push<R | R1, E | E1, A> => {
666
- return Push(<R2>(sink: Sink<R2, E | E1, A>) =>
667
- IO.asyncIO<R | R1 | R2, never, void>((cb) => {
668
- const exit = IO(cb(IO.unit));
669
- return Do((Δ) => {
670
- const signalFiber = Δ(
671
- signal.run(
672
- Sink(
673
- () => exit,
674
- (cause) => sink.error(cause),
675
- ),
676
- ).fork,
677
- );
678
- const streamFiber = Δ(self.run(sink).fork);
679
- Δ(Fiber.joinAll([signalFiber, streamFiber]));
680
- });
681
- }),
563
+ class Unwrap<R, E, R1, E1, A> extends Push<R | R1, E | E1, A> {
564
+ constructor(readonly io: IO<R, E, Push<R1, E1, A>>) {
565
+ super();
566
+ }
567
+ run<R2>(sink: UnsafeSink<R2, E | E1, A>): IO<R | R1 | R2, never, void> {
568
+ return this.io.matchCauseIO(
569
+ (cause) => sink.onFailure(cause),
570
+ (stream) => stream.run(sink),
682
571
  );
683
- };
572
+ }
684
573
  }
685
574
 
686
575
  /**
687
576
  * @tsplus static fncts.io.PushOps unwrap
688
577
  */
689
578
  export function unwrap<R, E, R1, E1, A>(io: IO<R, E, Push<R1, E1, A>>): Push<R | R1, E | E1, A> {
690
- return Push.fromIO(io).flatten;
691
- }
692
-
693
- /**
694
- * @tsplus static fncts.io.PushOps unwrapScoped
695
- */
696
- export function unwrapScoped<R, E, R1, E1, A>(
697
- self: IO<R, E, Push<R1, E1, A>>,
698
- __tsplusTrace?: string,
699
- ): Push<R1 | Exclude<R, Scope>, E | E1, A> {
700
- return Push.scoped(self).flatten;
579
+ return new Unwrap(io);
701
580
  }
702
-
703
- /**
704
- * @tsplus static fncts.io.PushOps never
705
- */
706
- export const never = Push.fromIO(IO.never);