@fncts/io 0.0.20 → 0.0.21

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 (1089) hide show
  1. package/Cached/api.d.ts +2 -2
  2. package/Channel/ChildExecutorDecision/api.d.ts +2 -2
  3. package/Channel/UpstreamPullRequest/api.d.ts +2 -2
  4. package/Channel/api/interruptWhen.d.ts +5 -5
  5. package/Channel/api/mapOutIOC.d.ts +3 -3
  6. package/Channel/api/mergeAll.d.ts +2 -2
  7. package/Channel/api/mergeAllUnboundedWith.d.ts +2 -2
  8. package/Channel/api/mergeAllWith.d.ts +2 -2
  9. package/Channel/api/mergeMap.d.ts +2 -2
  10. package/Channel/api/mergeWith.d.ts +2 -2
  11. package/Channel/api/zipC.d.ts +6 -6
  12. package/Channel/api.d.ts +64 -64
  13. package/Channel/core-api.d.ts +11 -11
  14. package/Channel/definition.d.ts +35 -21
  15. package/Fiber/api/evalOn.d.ts +3 -3
  16. package/Fiber/api/evalOnIO.d.ts +3 -3
  17. package/Fiber/api/interruptAs.d.ts +3 -3
  18. package/Fiber/api/interruptAsFork.d.ts +3 -3
  19. package/Fiber/api/mapFiber.d.ts +2 -2
  20. package/Fiber/api/mapIO.d.ts +5 -5
  21. package/Fiber/api/zipWith.d.ts +2 -2
  22. package/Fiber.d.ts +1 -0
  23. package/FiberRef/api/locallyScoped.d.ts +2 -2
  24. package/FiberRef/api/locallyScopedWith.d.ts +2 -2
  25. package/FiberRef/api.d.ts +18 -18
  26. package/FiberRefs/api.d.ts +2 -2
  27. package/FiberRefs/join.d.ts +3 -3
  28. package/Future/api.d.ts +21 -21
  29. package/Hub/constructors.d.ts +49 -0
  30. package/Hub/definition.d.ts +37 -81
  31. package/Hub/internal.d.ts +4 -11
  32. package/Hub.d.ts +1 -1
  33. package/IO/api/acquireRelease.d.ts +1 -1
  34. package/IO/api/acquireReleaseExit.d.ts +1 -1
  35. package/IO/api/bracket.d.ts +1 -1
  36. package/IO/api/bracketExit.d.ts +1 -1
  37. package/IO/api/concurrency.d.ts +2 -2
  38. package/IO/api/core-scope.d.ts +5 -5
  39. package/IO/api/ensuringChildren.d.ts +3 -3
  40. package/IO/api/environment.d.ts +11 -15
  41. package/IO/api/foreachC.d.ts +2 -2
  42. package/IO/api/foreachExec.d.ts +1 -1
  43. package/IO/api/forkIn.d.ts +3 -3
  44. package/IO/api/fulfill.d.ts +3 -3
  45. package/IO/api/interrupt.d.ts +6 -6
  46. package/IO/api/onExit.d.ts +3 -3
  47. package/IO/api/onTermination.d.ts +4 -4
  48. package/IO/api/provideLayer.d.ts +3 -3
  49. package/IO/api/provideSomeLayer.d.ts +3 -7
  50. package/IO/api/race.d.ts +2 -2
  51. package/IO/api/raceFirst.d.ts +2 -2
  52. package/IO/api/repeat.d.ts +3 -3
  53. package/IO/api/retry.d.ts +7 -7
  54. package/IO/api/schedule.d.ts +5 -5
  55. package/IO/api/scoped.d.ts +2 -2
  56. package/IO/api/supervised.d.ts +3 -3
  57. package/IO/api/timeout.d.ts +5 -5
  58. package/IO/api/withFinalizer.d.ts +3 -3
  59. package/IO/api/withFinalizerExit.d.ts +3 -3
  60. package/IO/api/withRuntimeConfig.d.ts +3 -3
  61. package/IO/api/zipC.d.ts +4 -4
  62. package/IO/api.d.ts +179 -176
  63. package/IO/definition.d.ts +15 -9
  64. package/Layer/MemoMap.d.ts +4 -4
  65. package/Layer/api.d.ts +28 -28
  66. package/LogLevel.d.ts +12 -12
  67. package/LogSpan.d.ts +2 -2
  68. package/Logger/api.d.ts +5 -5
  69. package/Queue/constructors.d.ts +2 -1
  70. package/Queue/definition.d.ts +91 -82
  71. package/Queue/internal.d.ts +7 -9
  72. package/Queue.d.ts +0 -2
  73. package/Ref/Atomic.d.ts +15 -2
  74. package/Ref/Synchronized.d.ts +72 -0
  75. package/Ref/constructors.d.ts +7 -0
  76. package/Ref/definition.d.ts +60 -58
  77. package/Ref.d.ts +1 -6
  78. package/STM/api/core-api.d.ts +10 -10
  79. package/STM/api.d.ts +61 -61
  80. package/STM/internal/Journal.d.ts +4 -4
  81. package/Schedule/Decision.d.ts +2 -2
  82. package/Schedule/api.d.ts +94 -94
  83. package/Scope/ReleaseMap/api/releaseAll.d.ts +2 -2
  84. package/Scope/ReleaseMap/api.d.ts +10 -10
  85. package/Scope/api.d.ts +8 -8
  86. package/Sink/api.d.ts +68 -68
  87. package/State/api.d.ts +4 -4
  88. package/State/internal.d.ts +1 -1
  89. package/Stream/api/zipAllWith.d.ts +2 -2
  90. package/Stream/api/zipWith.d.ts +2 -2
  91. package/Stream/api/zipWithChunks.d.ts +2 -2
  92. package/Stream/api.d.ts +216 -205
  93. package/Stream/internal/DebounceState.d.ts +3 -3
  94. package/Stream/internal/Handoff.d.ts +5 -5
  95. package/Stream/internal/Pull.d.ts +2 -2
  96. package/Stream/internal/SinkEndReason.d.ts +3 -3
  97. package/Stream/internal/Take.d.ts +8 -8
  98. package/SubscriptionRef.d.ts +29 -0
  99. package/Supervisor/api.d.ts +4 -4
  100. package/SupervisorPatch.d.ts +4 -4
  101. package/TFuture/api.d.ts +7 -7
  102. package/TReentrantLock/api.d.ts +4 -4
  103. package/TRef/api.d.ts +24 -24
  104. package/TSemaphore/api.d.ts +4 -4
  105. package/TSemaphore/constructors.d.ts +6 -0
  106. package/_cjs/Cached/api.cjs +9 -9
  107. package/_cjs/Cached/api.cjs.map +1 -1
  108. package/_cjs/Channel/ChildExecutorDecision/api.cjs +19 -17
  109. package/_cjs/Channel/ChildExecutorDecision/api.cjs.map +1 -1
  110. package/_cjs/Channel/UpstreamPullRequest/api.cjs +16 -14
  111. package/_cjs/Channel/UpstreamPullRequest/api.cjs.map +1 -1
  112. package/_cjs/Channel/api/interruptWhen.cjs +14 -10
  113. package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
  114. package/_cjs/Channel/api/mapOutIOC.cjs +25 -25
  115. package/_cjs/Channel/api/mapOutIOC.cjs.map +1 -1
  116. package/_cjs/Channel/api/mergeAll.cjs +6 -4
  117. package/_cjs/Channel/api/mergeAll.cjs.map +1 -1
  118. package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +6 -4
  119. package/_cjs/Channel/api/mergeAllUnboundedWith.cjs.map +1 -1
  120. package/_cjs/Channel/api/mergeAllWith.cjs +48 -52
  121. package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
  122. package/_cjs/Channel/api/mergeMap.cjs +6 -4
  123. package/_cjs/Channel/api/mergeMap.cjs.map +1 -1
  124. package/_cjs/Channel/api/mergeWith.cjs +48 -46
  125. package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
  126. package/_cjs/Channel/api/run.cjs +1 -1
  127. package/_cjs/Channel/api/run.cjs.map +1 -1
  128. package/_cjs/Channel/api/runScoped.cjs +2 -2
  129. package/_cjs/Channel/api/runScoped.cjs.map +1 -1
  130. package/_cjs/Channel/api/toPull.cjs +3 -3
  131. package/_cjs/Channel/api/toPull.cjs.map +1 -1
  132. package/_cjs/Channel/api/zipC.cjs +20 -14
  133. package/_cjs/Channel/api/zipC.cjs.map +1 -1
  134. package/_cjs/Channel/api.cjs +264 -218
  135. package/_cjs/Channel/api.cjs.map +1 -1
  136. package/_cjs/Channel/core-api.cjs +34 -24
  137. package/_cjs/Channel/core-api.cjs.map +1 -1
  138. package/_cjs/Channel/definition.cjs +1 -1
  139. package/_cjs/Channel/definition.cjs.map +1 -1
  140. package/_cjs/Channel/internal/ChannelExecutor.cjs +83 -83
  141. package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
  142. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +22 -24
  143. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
  144. package/_cjs/Differ/api.cjs +5 -5
  145. package/_cjs/Differ/api.cjs.map +1 -1
  146. package/_cjs/Fiber/FiberContext.cjs +48 -48
  147. package/_cjs/Fiber/FiberContext.cjs.map +1 -1
  148. package/_cjs/Fiber/api/awaitAll.cjs +1 -1
  149. package/_cjs/Fiber/api/awaitAll.cjs.map +1 -1
  150. package/_cjs/Fiber/api/collectAll.cjs +1 -1
  151. package/_cjs/Fiber/api/collectAll.cjs.map +1 -1
  152. package/_cjs/Fiber/api/evalOn.cjs +12 -10
  153. package/_cjs/Fiber/api/evalOn.cjs.map +1 -1
  154. package/_cjs/Fiber/api/evalOnIO.cjs +6 -4
  155. package/_cjs/Fiber/api/evalOnIO.cjs.map +1 -1
  156. package/_cjs/Fiber/api/fromIO.cjs +1 -1
  157. package/_cjs/Fiber/api/fromIO.cjs.map +1 -1
  158. package/_cjs/Fiber/api/interrupt.cjs +1 -1
  159. package/_cjs/Fiber/api/interrupt.cjs.map +1 -1
  160. package/_cjs/Fiber/api/interruptAll.cjs +2 -2
  161. package/_cjs/Fiber/api/interruptAll.cjs.map +1 -1
  162. package/_cjs/Fiber/api/interruptAs.cjs +6 -4
  163. package/_cjs/Fiber/api/interruptAs.cjs.map +1 -1
  164. package/_cjs/Fiber/api/interruptAsFork.cjs +6 -4
  165. package/_cjs/Fiber/api/interruptAsFork.cjs.map +1 -1
  166. package/_cjs/Fiber/api/interruptFork.cjs +1 -1
  167. package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
  168. package/_cjs/Fiber/api/join.cjs +1 -1
  169. package/_cjs/Fiber/api/join.cjs.map +1 -1
  170. package/_cjs/Fiber/api/joinAll.cjs +1 -1
  171. package/_cjs/Fiber/api/joinAll.cjs.map +1 -1
  172. package/_cjs/Fiber/api/mapFiber.cjs +6 -4
  173. package/_cjs/Fiber/api/mapFiber.cjs.map +1 -1
  174. package/_cjs/Fiber/api/mapIO.cjs +14 -10
  175. package/_cjs/Fiber/api/mapIO.cjs.map +1 -1
  176. package/_cjs/Fiber/api/zipWith.cjs +6 -4
  177. package/_cjs/Fiber/api/zipWith.cjs.map +1 -1
  178. package/_cjs/Fiber/definition.cjs.map +1 -1
  179. package/_cjs/Fiber.cjs +13 -0
  180. package/_cjs/Fiber.cjs.map +1 -1
  181. package/_cjs/FiberRef/api/locallyScoped.cjs +6 -4
  182. package/_cjs/FiberRef/api/locallyScoped.cjs.map +1 -1
  183. package/_cjs/FiberRef/api/locallyScopedWith.cjs +5 -3
  184. package/_cjs/FiberRef/api/locallyScopedWith.cjs.map +1 -1
  185. package/_cjs/FiberRef/api.cjs +64 -47
  186. package/_cjs/FiberRef/api.cjs.map +1 -1
  187. package/_cjs/FiberRef/constructors.cjs +1 -1
  188. package/_cjs/FiberRef/constructors.cjs.map +1 -1
  189. package/_cjs/FiberRef.cjs.map +1 -1
  190. package/_cjs/FiberRefs/api.cjs +15 -13
  191. package/_cjs/FiberRefs/api.cjs.map +1 -1
  192. package/_cjs/FiberRefs/join.cjs +37 -35
  193. package/_cjs/FiberRefs/join.cjs.map +1 -1
  194. package/_cjs/FiberState/definition.cjs.map +1 -1
  195. package/_cjs/Future/api.cjs +97 -79
  196. package/_cjs/Future/api.cjs.map +1 -1
  197. package/_cjs/Future/constructors.cjs +1 -1
  198. package/_cjs/Future/constructors.cjs.map +1 -1
  199. package/_cjs/Hub/constructors.cjs +93 -0
  200. package/_cjs/Hub/constructors.cjs.map +1 -0
  201. package/_cjs/Hub/definition.cjs +104 -13
  202. package/_cjs/Hub/definition.cjs.map +1 -1
  203. package/_cjs/Hub/internal.cjs +104 -129
  204. package/_cjs/Hub/internal.cjs.map +1 -1
  205. package/_cjs/Hub.cjs +4 -4
  206. package/_cjs/IO/api/acquireReleaseExit.cjs +1 -1
  207. package/_cjs/IO/api/acquireReleaseExit.cjs.map +1 -1
  208. package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +1 -1
  209. package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs.map +1 -1
  210. package/_cjs/IO/api/addFinalizerExit.cjs +1 -1
  211. package/_cjs/IO/api/addFinalizerExit.cjs.map +1 -1
  212. package/_cjs/IO/api/asyncIO.cjs +4 -4
  213. package/_cjs/IO/api/asyncIO.cjs.map +1 -1
  214. package/_cjs/IO/api/bracket.cjs +3 -3
  215. package/_cjs/IO/api/bracket.cjs.map +1 -1
  216. package/_cjs/IO/api/bracketExit.cjs +3 -3
  217. package/_cjs/IO/api/bracketExit.cjs.map +1 -1
  218. package/_cjs/IO/api/clockWith.cjs +2 -2
  219. package/_cjs/IO/api/clockWith.cjs.map +1 -1
  220. package/_cjs/IO/api/concurrency.cjs +9 -7
  221. package/_cjs/IO/api/concurrency.cjs.map +1 -1
  222. package/_cjs/IO/api/concurrentFinalizers.cjs +1 -1
  223. package/_cjs/IO/api/concurrentFinalizers.cjs.map +1 -1
  224. package/_cjs/IO/api/consoleWith.cjs +2 -2
  225. package/_cjs/IO/api/consoleWith.cjs.map +1 -1
  226. package/_cjs/IO/api/core-scope.cjs +45 -41
  227. package/_cjs/IO/api/core-scope.cjs.map +1 -1
  228. package/_cjs/IO/api/ensuringChildren.cjs +5 -3
  229. package/_cjs/IO/api/ensuringChildren.cjs.map +1 -1
  230. package/_cjs/IO/api/environment.cjs +35 -35
  231. package/_cjs/IO/api/environment.cjs.map +1 -1
  232. package/_cjs/IO/api/foreachC.cjs +19 -23
  233. package/_cjs/IO/api/foreachC.cjs.map +1 -1
  234. package/_cjs/IO/api/foreachExec.cjs +3 -3
  235. package/_cjs/IO/api/foreachExec.cjs.map +1 -1
  236. package/_cjs/IO/api/forkAll.cjs +1 -1
  237. package/_cjs/IO/api/forkAll.cjs.map +1 -1
  238. package/_cjs/IO/api/forkIn.cjs +8 -6
  239. package/_cjs/IO/api/forkIn.cjs.map +1 -1
  240. package/_cjs/IO/api/forkScoped.cjs +1 -1
  241. package/_cjs/IO/api/forkScoped.cjs.map +1 -1
  242. package/_cjs/IO/api/fulfill.cjs +8 -6
  243. package/_cjs/IO/api/fulfill.cjs.map +1 -1
  244. package/_cjs/IO/api/interrupt.cjs +36 -30
  245. package/_cjs/IO/api/interrupt.cjs.map +1 -1
  246. package/_cjs/IO/api/memoize.cjs +1 -1
  247. package/_cjs/IO/api/memoize.cjs.map +1 -1
  248. package/_cjs/IO/api/onExit.cjs +6 -4
  249. package/_cjs/IO/api/onExit.cjs.map +1 -1
  250. package/_cjs/IO/api/onTermination.cjs +5 -3
  251. package/_cjs/IO/api/onTermination.cjs.map +1 -1
  252. package/_cjs/IO/api/once.cjs +3 -5
  253. package/_cjs/IO/api/once.cjs.map +1 -1
  254. package/_cjs/IO/api/provideLayer.cjs +6 -4
  255. package/_cjs/IO/api/provideLayer.cjs.map +1 -1
  256. package/_cjs/IO/api/provideSomeLayer.cjs +5 -15
  257. package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -1
  258. package/_cjs/IO/api/race.cjs +6 -4
  259. package/_cjs/IO/api/race.cjs.map +1 -1
  260. package/_cjs/IO/api/raceFirst.cjs +6 -4
  261. package/_cjs/IO/api/raceFirst.cjs.map +1 -1
  262. package/_cjs/IO/api/randomWith.cjs +1 -1
  263. package/_cjs/IO/api/randomWith.cjs.map +1 -1
  264. package/_cjs/IO/api/repeat.cjs +12 -12
  265. package/_cjs/IO/api/repeat.cjs.map +1 -1
  266. package/_cjs/IO/api/retry.cjs +14 -14
  267. package/_cjs/IO/api/retry.cjs.map +1 -1
  268. package/_cjs/IO/api/schedule.cjs +15 -11
  269. package/_cjs/IO/api/schedule.cjs.map +1 -1
  270. package/_cjs/IO/api/scoped.cjs +6 -6
  271. package/_cjs/IO/api/scoped.cjs.map +1 -1
  272. package/_cjs/IO/api/sequenceT.cjs +1 -1
  273. package/_cjs/IO/api/sequenceT.cjs.map +1 -1
  274. package/_cjs/IO/api/stateful.cjs.map +1 -1
  275. package/_cjs/IO/api/supervised.cjs +6 -4
  276. package/_cjs/IO/api/supervised.cjs.map +1 -1
  277. package/_cjs/IO/api/timeout.cjs +10 -6
  278. package/_cjs/IO/api/timeout.cjs.map +1 -1
  279. package/_cjs/IO/api/withChildren.cjs +1 -1
  280. package/_cjs/IO/api/withChildren.cjs.map +1 -1
  281. package/_cjs/IO/api/withEarlyRelease.cjs +1 -1
  282. package/_cjs/IO/api/withEarlyRelease.cjs.map +1 -1
  283. package/_cjs/IO/api/withFinalizer.cjs +6 -4
  284. package/_cjs/IO/api/withFinalizer.cjs.map +1 -1
  285. package/_cjs/IO/api/withFinalizerExit.cjs +6 -4
  286. package/_cjs/IO/api/withFinalizerExit.cjs.map +1 -1
  287. package/_cjs/IO/api/withRuntimeConfig.cjs +6 -4
  288. package/_cjs/IO/api/withRuntimeConfig.cjs.map +1 -1
  289. package/_cjs/IO/api/zipC.cjs +21 -17
  290. package/_cjs/IO/api/zipC.cjs.map +1 -1
  291. package/_cjs/IO/api.cjs +634 -509
  292. package/_cjs/IO/api.cjs.map +1 -1
  293. package/_cjs/IO/definition.cjs.map +1 -1
  294. package/_cjs/IO/runtime.cjs +7 -7
  295. package/_cjs/IO/runtime.cjs.map +1 -1
  296. package/_cjs/IO.cjs.map +1 -1
  297. package/_cjs/IOEnv/definition.cjs +1 -1
  298. package/_cjs/IOEnv/definition.cjs.map +1 -1
  299. package/_cjs/IOEnv/live.cjs +1 -1
  300. package/_cjs/IOEnv/live.cjs.map +1 -1
  301. package/_cjs/Layer/MemoMap.cjs +86 -92
  302. package/_cjs/Layer/MemoMap.cjs.map +1 -1
  303. package/_cjs/Layer/api.cjs +110 -81
  304. package/_cjs/Layer/api.cjs.map +1 -1
  305. package/_cjs/Layer/definition.cjs.map +1 -1
  306. package/_cjs/LogLevel.cjs +24 -16
  307. package/_cjs/LogLevel.cjs.map +1 -1
  308. package/_cjs/LogSpan.cjs +18 -16
  309. package/_cjs/LogSpan.cjs.map +1 -1
  310. package/_cjs/Logger/api.cjs +18 -14
  311. package/_cjs/Logger/api.cjs.map +1 -1
  312. package/_cjs/Logger/constructors.cjs +1 -1
  313. package/_cjs/Logger/constructors.cjs.map +1 -1
  314. package/_cjs/Queue/constructors.cjs +19 -5
  315. package/_cjs/Queue/constructors.cjs.map +1 -1
  316. package/_cjs/Queue/definition.cjs +191 -16
  317. package/_cjs/Queue/definition.cjs.map +1 -1
  318. package/_cjs/Queue/internal.cjs +27 -181
  319. package/_cjs/Queue/internal.cjs.map +1 -1
  320. package/_cjs/Queue/strategy.cjs +19 -19
  321. package/_cjs/Queue/strategy.cjs.map +1 -1
  322. package/_cjs/Queue.cjs +0 -26
  323. package/_cjs/Queue.cjs.map +1 -1
  324. package/_cjs/Random/live.cjs +2 -2
  325. package/_cjs/Random/live.cjs.map +1 -1
  326. package/_cjs/Ref/Atomic.cjs +47 -24
  327. package/_cjs/Ref/Atomic.cjs.map +1 -1
  328. package/_cjs/Ref/Synchronized.cjs +140 -0
  329. package/_cjs/Ref/Synchronized.cjs.map +1 -0
  330. package/_cjs/Ref/constructors.cjs +21 -2
  331. package/_cjs/Ref/constructors.cjs.map +1 -1
  332. package/_cjs/Ref/definition.cjs +105 -10
  333. package/_cjs/Ref/definition.cjs.map +1 -1
  334. package/_cjs/Ref.cjs +4 -69
  335. package/_cjs/Ref.cjs.map +1 -1
  336. package/_cjs/Reloadable/constructors.cjs +10 -10
  337. package/_cjs/Reloadable/constructors.cjs.map +1 -1
  338. package/_cjs/RuntimeConfig.cjs +2 -2
  339. package/_cjs/RuntimeConfig.cjs.map +1 -1
  340. package/_cjs/STM/api/core-api.cjs +36 -26
  341. package/_cjs/STM/api/core-api.cjs.map +1 -1
  342. package/_cjs/STM/api.cjs +217 -163
  343. package/_cjs/STM/api.cjs.map +1 -1
  344. package/_cjs/STM/driver.cjs +3 -3
  345. package/_cjs/STM/driver.cjs.map +1 -1
  346. package/_cjs/STM/internal/Entry.cjs.map +1 -1
  347. package/_cjs/STM/internal/Journal.cjs +33 -29
  348. package/_cjs/STM/internal/Journal.cjs.map +1 -1
  349. package/_cjs/STM.cjs.map +1 -1
  350. package/_cjs/Schedule/Decision.cjs +16 -14
  351. package/_cjs/Schedule/Decision.cjs.map +1 -1
  352. package/_cjs/Schedule/api/driver.cjs +16 -20
  353. package/_cjs/Schedule/api/driver.cjs.map +1 -1
  354. package/_cjs/Schedule/api.cjs +381 -290
  355. package/_cjs/Schedule/api.cjs.map +1 -1
  356. package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +14 -14
  357. package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs.map +1 -1
  358. package/_cjs/Scope/ReleaseMap/api.cjs +68 -61
  359. package/_cjs/Scope/ReleaseMap/api.cjs.map +1 -1
  360. package/_cjs/Scope/api.cjs +34 -27
  361. package/_cjs/Scope/api.cjs.map +1 -1
  362. package/_cjs/ScopedRef/api.cjs +9 -13
  363. package/_cjs/ScopedRef/api.cjs.map +1 -1
  364. package/_cjs/ScopedRef/definition.cjs +1 -1
  365. package/_cjs/ScopedRef/definition.cjs.map +1 -1
  366. package/_cjs/Sink/api.cjs +307 -249
  367. package/_cjs/Sink/api.cjs.map +1 -1
  368. package/_cjs/State/api.cjs +18 -14
  369. package/_cjs/State/api.cjs.map +1 -1
  370. package/_cjs/Stream/api/zipAllWith.cjs +15 -13
  371. package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
  372. package/_cjs/Stream/api/zipWith.cjs +6 -4
  373. package/_cjs/Stream/api/zipWith.cjs.map +1 -1
  374. package/_cjs/Stream/api/zipWithChunks.cjs +13 -11
  375. package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
  376. package/_cjs/Stream/api.cjs +992 -788
  377. package/_cjs/Stream/api.cjs.map +1 -1
  378. package/_cjs/Stream/definition.cjs.map +1 -1
  379. package/_cjs/Stream/internal/DebounceState.cjs +21 -19
  380. package/_cjs/Stream/internal/DebounceState.cjs.map +1 -1
  381. package/_cjs/Stream/internal/Handoff.cjs +35 -33
  382. package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
  383. package/_cjs/Stream/internal/Pull.cjs +9 -11
  384. package/_cjs/Stream/internal/Pull.cjs.map +1 -1
  385. package/_cjs/Stream/internal/SinkEndReason.cjs +16 -14
  386. package/_cjs/Stream/internal/SinkEndReason.cjs.map +1 -1
  387. package/_cjs/Stream/internal/Take.cjs +32 -24
  388. package/_cjs/Stream/internal/Take.cjs.map +1 -1
  389. package/_cjs/Stream/internal/util.cjs +3 -3
  390. package/_cjs/Stream/internal/util.cjs.map +1 -1
  391. package/_cjs/SubscriptionRef.cjs +68 -0
  392. package/_cjs/SubscriptionRef.cjs.map +1 -0
  393. package/_cjs/Supervisor/api.cjs +24 -20
  394. package/_cjs/Supervisor/api.cjs.map +1 -1
  395. package/_cjs/Supervisor/constructors.cjs +2 -2
  396. package/_cjs/Supervisor/constructors.cjs.map +1 -1
  397. package/_cjs/Supervisor/definition.cjs +1 -1
  398. package/_cjs/Supervisor/definition.cjs.map +1 -1
  399. package/_cjs/SupervisorPatch.cjs +15 -11
  400. package/_cjs/SupervisorPatch.cjs.map +1 -1
  401. package/_cjs/TExit/definition.cjs.map +1 -1
  402. package/_cjs/TFuture/api.cjs +21 -15
  403. package/_cjs/TFuture/api.cjs.map +1 -1
  404. package/_cjs/TFuture/constructors.cjs +1 -1
  405. package/_cjs/TFuture/constructors.cjs.map +1 -1
  406. package/_cjs/TFuture/definition.cjs.map +1 -1
  407. package/_cjs/TReentrantLock/api.cjs +32 -28
  408. package/_cjs/TReentrantLock/api.cjs.map +1 -1
  409. package/_cjs/TReentrantLock/definition.cjs +4 -4
  410. package/_cjs/TReentrantLock/definition.cjs.map +1 -1
  411. package/_cjs/TRef/api.cjs +233 -209
  412. package/_cjs/TRef/api.cjs.map +1 -1
  413. package/_cjs/TRef/definition.cjs +4 -4
  414. package/_cjs/TRef/definition.cjs.map +1 -1
  415. package/_cjs/TSemaphore/api.cjs +27 -23
  416. package/_cjs/TSemaphore/api.cjs.map +1 -1
  417. package/_cjs/TSemaphore/constructors.cjs +18 -3
  418. package/_cjs/TSemaphore/constructors.cjs.map +1 -1
  419. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +21 -19
  420. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
  421. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +21 -19
  422. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
  423. package/_cjs/collection/immutable/Conc/filterIO.cjs +16 -14
  424. package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
  425. package/_cjs/collection/immutable/Conc/findIO.cjs +19 -17
  426. package/_cjs/collection/immutable/Conc/findIO.cjs.map +1 -1
  427. package/_cjs/collection/immutable/Conc/mapIO.cjs +11 -9
  428. package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
  429. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +31 -29
  430. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
  431. package/_cjs/data/Exit/foreachIO.cjs +6 -4
  432. package/_cjs/data/Exit/foreachIO.cjs.map +1 -1
  433. package/_cjs/internal/Hub.cjs +13 -11
  434. package/_cjs/internal/Hub.cjs.map +1 -1
  435. package/_cjs/internal/IsFatal.cjs +18 -16
  436. package/_cjs/internal/IsFatal.cjs.map +1 -1
  437. package/_cjs/internal/MutableQueue.cjs +11 -9
  438. package/_cjs/internal/MutableQueue.cjs.map +1 -1
  439. package/_cjs/internal/StackTraceBuilder.cjs.map +1 -1
  440. package/_mjs/Cached/api.mjs +6 -6
  441. package/_mjs/Cached/api.mjs.map +1 -1
  442. package/_mjs/Channel/ChildExecutorDecision/api.mjs +18 -16
  443. package/_mjs/Channel/ChildExecutorDecision/api.mjs.map +1 -1
  444. package/_mjs/Channel/UpstreamPullRequest/api.mjs +14 -12
  445. package/_mjs/Channel/UpstreamPullRequest/api.mjs.map +1 -1
  446. package/_mjs/Channel/api/interruptWhen.mjs +11 -7
  447. package/_mjs/Channel/api/interruptWhen.mjs.map +1 -1
  448. package/_mjs/Channel/api/mapOutIOC.mjs +24 -23
  449. package/_mjs/Channel/api/mapOutIOC.mjs.map +1 -1
  450. package/_mjs/Channel/api/mergeAll.mjs +5 -3
  451. package/_mjs/Channel/api/mergeAll.mjs.map +1 -1
  452. package/_mjs/Channel/api/mergeAllUnboundedWith.mjs +5 -3
  453. package/_mjs/Channel/api/mergeAllUnboundedWith.mjs.map +1 -1
  454. package/_mjs/Channel/api/mergeAllWith.mjs +45 -46
  455. package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
  456. package/_mjs/Channel/api/mergeMap.mjs +5 -3
  457. package/_mjs/Channel/api/mergeMap.mjs.map +1 -1
  458. package/_mjs/Channel/api/mergeWith.mjs +46 -44
  459. package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
  460. package/_mjs/Channel/api/run.mjs +1 -1
  461. package/_mjs/Channel/api/run.mjs.map +1 -1
  462. package/_mjs/Channel/api/runScoped.mjs +2 -2
  463. package/_mjs/Channel/api/runScoped.mjs.map +1 -1
  464. package/_mjs/Channel/api/toPull.mjs +3 -3
  465. package/_mjs/Channel/api/toPull.mjs.map +1 -1
  466. package/_mjs/Channel/api/zipC.mjs +16 -10
  467. package/_mjs/Channel/api/zipC.mjs.map +1 -1
  468. package/_mjs/Channel/api.mjs +224 -173
  469. package/_mjs/Channel/api.mjs.map +1 -1
  470. package/_mjs/Channel/core-api.mjs +28 -18
  471. package/_mjs/Channel/core-api.mjs.map +1 -1
  472. package/_mjs/Channel/definition.mjs +1 -1
  473. package/_mjs/Channel/definition.mjs.map +1 -1
  474. package/_mjs/Channel/internal/ChannelExecutor.mjs +83 -83
  475. package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
  476. package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +22 -23
  477. package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
  478. package/_mjs/Differ/api.mjs +5 -5
  479. package/_mjs/Differ/api.mjs.map +1 -1
  480. package/_mjs/Fiber/FiberContext.mjs +48 -48
  481. package/_mjs/Fiber/FiberContext.mjs.map +1 -1
  482. package/_mjs/Fiber/api/awaitAll.mjs +1 -1
  483. package/_mjs/Fiber/api/awaitAll.mjs.map +1 -1
  484. package/_mjs/Fiber/api/collectAll.mjs +1 -1
  485. package/_mjs/Fiber/api/collectAll.mjs.map +1 -1
  486. package/_mjs/Fiber/api/evalOn.mjs +11 -9
  487. package/_mjs/Fiber/api/evalOn.mjs.map +1 -1
  488. package/_mjs/Fiber/api/evalOnIO.mjs +5 -3
  489. package/_mjs/Fiber/api/evalOnIO.mjs.map +1 -1
  490. package/_mjs/Fiber/api/fromIO.mjs +1 -1
  491. package/_mjs/Fiber/api/fromIO.mjs.map +1 -1
  492. package/_mjs/Fiber/api/interrupt.mjs +1 -1
  493. package/_mjs/Fiber/api/interrupt.mjs.map +1 -1
  494. package/_mjs/Fiber/api/interruptAll.mjs +2 -2
  495. package/_mjs/Fiber/api/interruptAll.mjs.map +1 -1
  496. package/_mjs/Fiber/api/interruptAs.mjs +6 -4
  497. package/_mjs/Fiber/api/interruptAs.mjs.map +1 -1
  498. package/_mjs/Fiber/api/interruptAsFork.mjs +6 -4
  499. package/_mjs/Fiber/api/interruptAsFork.mjs.map +1 -1
  500. package/_mjs/Fiber/api/interruptFork.mjs +1 -1
  501. package/_mjs/Fiber/api/interruptFork.mjs.map +1 -1
  502. package/_mjs/Fiber/api/join.mjs +1 -1
  503. package/_mjs/Fiber/api/join.mjs.map +1 -1
  504. package/_mjs/Fiber/api/joinAll.mjs +1 -1
  505. package/_mjs/Fiber/api/joinAll.mjs.map +1 -1
  506. package/_mjs/Fiber/api/mapFiber.mjs +5 -3
  507. package/_mjs/Fiber/api/mapFiber.mjs.map +1 -1
  508. package/_mjs/Fiber/api/mapIO.mjs +11 -7
  509. package/_mjs/Fiber/api/mapIO.mjs.map +1 -1
  510. package/_mjs/Fiber/api/zipWith.mjs +5 -3
  511. package/_mjs/Fiber/api/zipWith.mjs.map +1 -1
  512. package/_mjs/Fiber/definition.mjs.map +1 -1
  513. package/_mjs/Fiber.mjs +1 -0
  514. package/_mjs/Fiber.mjs.map +1 -1
  515. package/_mjs/FiberRef/api/locallyScoped.mjs +5 -3
  516. package/_mjs/FiberRef/api/locallyScoped.mjs.map +1 -1
  517. package/_mjs/FiberRef/api/locallyScopedWith.mjs +5 -3
  518. package/_mjs/FiberRef/api/locallyScopedWith.mjs.map +1 -1
  519. package/_mjs/FiberRef/api.mjs +52 -36
  520. package/_mjs/FiberRef/api.mjs.map +1 -1
  521. package/_mjs/FiberRef/constructors.mjs +1 -1
  522. package/_mjs/FiberRef/constructors.mjs.map +1 -1
  523. package/_mjs/FiberRef.mjs.map +1 -1
  524. package/_mjs/FiberRefs/api.mjs +14 -12
  525. package/_mjs/FiberRefs/api.mjs.map +1 -1
  526. package/_mjs/FiberRefs/join.mjs +35 -33
  527. package/_mjs/FiberRefs/join.mjs.map +1 -1
  528. package/_mjs/FiberState/definition.mjs.map +1 -1
  529. package/_mjs/Future/api.mjs +84 -66
  530. package/_mjs/Future/api.mjs.map +1 -1
  531. package/_mjs/Future/constructors.mjs +1 -1
  532. package/_mjs/Future/constructors.mjs.map +1 -1
  533. package/_mjs/Hub/constructors.mjs +66 -0
  534. package/_mjs/Hub/constructors.mjs.map +1 -0
  535. package/_mjs/Hub/definition.mjs +88 -9
  536. package/_mjs/Hub/definition.mjs.map +1 -1
  537. package/_mjs/Hub/internal.mjs +105 -122
  538. package/_mjs/Hub/internal.mjs.map +1 -1
  539. package/_mjs/Hub.mjs +1 -1
  540. package/_mjs/Hub.mjs.map +1 -1
  541. package/_mjs/IO/api/acquireReleaseExit.mjs +1 -1
  542. package/_mjs/IO/api/acquireReleaseExit.mjs.map +1 -1
  543. package/_mjs/IO/api/acquireReleaseInterruptibleExit.mjs +1 -1
  544. package/_mjs/IO/api/acquireReleaseInterruptibleExit.mjs.map +1 -1
  545. package/_mjs/IO/api/addFinalizerExit.mjs +1 -1
  546. package/_mjs/IO/api/addFinalizerExit.mjs.map +1 -1
  547. package/_mjs/IO/api/asyncIO.mjs +4 -4
  548. package/_mjs/IO/api/asyncIO.mjs.map +1 -1
  549. package/_mjs/IO/api/bracket.mjs +2 -2
  550. package/_mjs/IO/api/bracket.mjs.map +1 -1
  551. package/_mjs/IO/api/bracketExit.mjs +2 -2
  552. package/_mjs/IO/api/bracketExit.mjs.map +1 -1
  553. package/_mjs/IO/api/clockWith.mjs +2 -2
  554. package/_mjs/IO/api/clockWith.mjs.map +1 -1
  555. package/_mjs/IO/api/concurrency.mjs +8 -6
  556. package/_mjs/IO/api/concurrency.mjs.map +1 -1
  557. package/_mjs/IO/api/concurrentFinalizers.mjs +1 -1
  558. package/_mjs/IO/api/concurrentFinalizers.mjs.map +1 -1
  559. package/_mjs/IO/api/consoleWith.mjs +2 -2
  560. package/_mjs/IO/api/consoleWith.mjs.map +1 -1
  561. package/_mjs/IO/api/core-scope.mjs +40 -36
  562. package/_mjs/IO/api/core-scope.mjs.map +1 -1
  563. package/_mjs/IO/api/ensuringChildren.mjs +5 -3
  564. package/_mjs/IO/api/ensuringChildren.mjs.map +1 -1
  565. package/_mjs/IO/api/environment.mjs +29 -27
  566. package/_mjs/IO/api/environment.mjs.map +1 -1
  567. package/_mjs/IO/api/foreachC.mjs +17 -19
  568. package/_mjs/IO/api/foreachC.mjs.map +1 -1
  569. package/_mjs/IO/api/foreachExec.mjs +2 -2
  570. package/_mjs/IO/api/foreachExec.mjs.map +1 -1
  571. package/_mjs/IO/api/forkAll.mjs +1 -1
  572. package/_mjs/IO/api/forkAll.mjs.map +1 -1
  573. package/_mjs/IO/api/forkIn.mjs +7 -5
  574. package/_mjs/IO/api/forkIn.mjs.map +1 -1
  575. package/_mjs/IO/api/forkScoped.mjs +1 -1
  576. package/_mjs/IO/api/forkScoped.mjs.map +1 -1
  577. package/_mjs/IO/api/fulfill.mjs +7 -5
  578. package/_mjs/IO/api/fulfill.mjs.map +1 -1
  579. package/_mjs/IO/api/interrupt.mjs +34 -28
  580. package/_mjs/IO/api/interrupt.mjs.map +1 -1
  581. package/_mjs/IO/api/memoize.mjs +1 -1
  582. package/_mjs/IO/api/memoize.mjs.map +1 -1
  583. package/_mjs/IO/api/onExit.mjs +5 -3
  584. package/_mjs/IO/api/onExit.mjs.map +1 -1
  585. package/_mjs/IO/api/onTermination.mjs +5 -3
  586. package/_mjs/IO/api/onTermination.mjs.map +1 -1
  587. package/_mjs/IO/api/once.mjs +3 -4
  588. package/_mjs/IO/api/once.mjs.map +1 -1
  589. package/_mjs/IO/api/provideLayer.mjs +5 -3
  590. package/_mjs/IO/api/provideLayer.mjs.map +1 -1
  591. package/_mjs/IO/api/provideSomeLayer.mjs +5 -11
  592. package/_mjs/IO/api/provideSomeLayer.mjs.map +1 -1
  593. package/_mjs/IO/api/race.mjs +5 -3
  594. package/_mjs/IO/api/race.mjs.map +1 -1
  595. package/_mjs/IO/api/raceFirst.mjs +5 -3
  596. package/_mjs/IO/api/raceFirst.mjs.map +1 -1
  597. package/_mjs/IO/api/randomWith.mjs +1 -1
  598. package/_mjs/IO/api/randomWith.mjs.map +1 -1
  599. package/_mjs/IO/api/repeat.mjs +8 -8
  600. package/_mjs/IO/api/repeat.mjs.map +1 -1
  601. package/_mjs/IO/api/retry.mjs +12 -12
  602. package/_mjs/IO/api/retry.mjs.map +1 -1
  603. package/_mjs/IO/api/schedule.mjs +15 -11
  604. package/_mjs/IO/api/schedule.mjs.map +1 -1
  605. package/_mjs/IO/api/scoped.mjs +3 -3
  606. package/_mjs/IO/api/scoped.mjs.map +1 -1
  607. package/_mjs/IO/api/sequenceT.mjs +1 -1
  608. package/_mjs/IO/api/sequenceT.mjs.map +1 -1
  609. package/_mjs/IO/api/stateful.mjs.map +1 -1
  610. package/_mjs/IO/api/supervised.mjs +5 -3
  611. package/_mjs/IO/api/supervised.mjs.map +1 -1
  612. package/_mjs/IO/api/timeout.mjs +10 -6
  613. package/_mjs/IO/api/timeout.mjs.map +1 -1
  614. package/_mjs/IO/api/withChildren.mjs +1 -1
  615. package/_mjs/IO/api/withChildren.mjs.map +1 -1
  616. package/_mjs/IO/api/withEarlyRelease.mjs +1 -1
  617. package/_mjs/IO/api/withEarlyRelease.mjs.map +1 -1
  618. package/_mjs/IO/api/withFinalizer.mjs +5 -3
  619. package/_mjs/IO/api/withFinalizer.mjs.map +1 -1
  620. package/_mjs/IO/api/withFinalizerExit.mjs +5 -3
  621. package/_mjs/IO/api/withFinalizerExit.mjs.map +1 -1
  622. package/_mjs/IO/api/withRuntimeConfig.mjs +5 -3
  623. package/_mjs/IO/api/withRuntimeConfig.mjs.map +1 -1
  624. package/_mjs/IO/api/zipC.mjs +18 -14
  625. package/_mjs/IO/api/zipC.mjs.map +1 -1
  626. package/_mjs/IO/api.mjs +511 -387
  627. package/_mjs/IO/api.mjs.map +1 -1
  628. package/_mjs/IO/definition.mjs.map +1 -1
  629. package/_mjs/IO/runtime.mjs +7 -7
  630. package/_mjs/IO/runtime.mjs.map +1 -1
  631. package/_mjs/IO.mjs.map +1 -1
  632. package/_mjs/IOEnv/definition.mjs +1 -1
  633. package/_mjs/IOEnv/definition.mjs.map +1 -1
  634. package/_mjs/IOEnv/live.mjs +1 -1
  635. package/_mjs/IOEnv/live.mjs.map +1 -1
  636. package/_mjs/Layer/MemoMap.mjs +86 -87
  637. package/_mjs/Layer/MemoMap.mjs.map +1 -1
  638. package/_mjs/Layer/api.mjs +91 -63
  639. package/_mjs/Layer/api.mjs.map +1 -1
  640. package/_mjs/Layer/definition.mjs.map +1 -1
  641. package/_mjs/LogLevel.mjs +24 -16
  642. package/_mjs/LogLevel.mjs.map +1 -1
  643. package/_mjs/LogSpan.mjs +16 -14
  644. package/_mjs/LogSpan.mjs.map +1 -1
  645. package/_mjs/Logger/api.mjs +16 -12
  646. package/_mjs/Logger/api.mjs.map +1 -1
  647. package/_mjs/Logger/constructors.mjs +1 -1
  648. package/_mjs/Logger/constructors.mjs.map +1 -1
  649. package/_mjs/Queue/constructors.mjs +16 -5
  650. package/_mjs/Queue/constructors.mjs.map +1 -1
  651. package/_mjs/Queue/definition.mjs +174 -12
  652. package/_mjs/Queue/definition.mjs.map +1 -1
  653. package/_mjs/Queue/internal.mjs +21 -170
  654. package/_mjs/Queue/internal.mjs.map +1 -1
  655. package/_mjs/Queue/strategy.mjs +20 -23
  656. package/_mjs/Queue/strategy.mjs.map +1 -1
  657. package/_mjs/Queue.mjs +1 -3
  658. package/_mjs/Queue.mjs.map +1 -1
  659. package/_mjs/Random/live.mjs +2 -2
  660. package/_mjs/Random/live.mjs.map +1 -1
  661. package/_mjs/Ref/Atomic.mjs +39 -3
  662. package/_mjs/Ref/Atomic.mjs.map +1 -1
  663. package/_mjs/Ref/Synchronized.mjs +123 -0
  664. package/_mjs/Ref/Synchronized.mjs.map +1 -0
  665. package/_mjs/Ref/constructors.mjs +15 -1
  666. package/_mjs/Ref/constructors.mjs.map +1 -1
  667. package/_mjs/Ref/definition.mjs +96 -4
  668. package/_mjs/Ref/definition.mjs.map +1 -1
  669. package/_mjs/Ref.mjs +1 -8
  670. package/_mjs/Ref.mjs.map +1 -1
  671. package/_mjs/Reloadable/constructors.mjs +10 -10
  672. package/_mjs/Reloadable/constructors.mjs.map +1 -1
  673. package/_mjs/RuntimeConfig.mjs +2 -2
  674. package/_mjs/RuntimeConfig.mjs.map +1 -1
  675. package/_mjs/STM/api/core-api.mjs +29 -19
  676. package/_mjs/STM/api/core-api.mjs.map +1 -1
  677. package/_mjs/STM/api.mjs +180 -127
  678. package/_mjs/STM/api.mjs.map +1 -1
  679. package/_mjs/STM/driver.mjs +3 -3
  680. package/_mjs/STM/driver.mjs.map +1 -1
  681. package/_mjs/STM/internal/Entry.mjs.map +1 -1
  682. package/_mjs/STM/internal/Journal.mjs +33 -29
  683. package/_mjs/STM/internal/Journal.mjs.map +1 -1
  684. package/_mjs/STM.mjs.map +1 -1
  685. package/_mjs/Schedule/Decision.mjs +14 -12
  686. package/_mjs/Schedule/Decision.mjs.map +1 -1
  687. package/_mjs/Schedule/api/driver.mjs +15 -17
  688. package/_mjs/Schedule/api/driver.mjs.map +1 -1
  689. package/_mjs/Schedule/api.mjs +326 -234
  690. package/_mjs/Schedule/api.mjs.map +1 -1
  691. package/_mjs/Scope/ReleaseMap/api/releaseAll.mjs +12 -11
  692. package/_mjs/Scope/ReleaseMap/api/releaseAll.mjs.map +1 -1
  693. package/_mjs/Scope/ReleaseMap/api.mjs +60 -51
  694. package/_mjs/Scope/ReleaseMap/api.mjs.map +1 -1
  695. package/_mjs/Scope/api.mjs +28 -22
  696. package/_mjs/Scope/api.mjs.map +1 -1
  697. package/_mjs/ScopedRef/api.mjs +9 -11
  698. package/_mjs/ScopedRef/api.mjs.map +1 -1
  699. package/_mjs/ScopedRef/definition.mjs +1 -1
  700. package/_mjs/ScopedRef/definition.mjs.map +1 -1
  701. package/_mjs/Sink/api.mjs +301 -240
  702. package/_mjs/Sink/api.mjs.map +1 -1
  703. package/_mjs/State/api.mjs +16 -12
  704. package/_mjs/State/api.mjs.map +1 -1
  705. package/_mjs/Stream/api/zipAllWith.mjs +14 -12
  706. package/_mjs/Stream/api/zipAllWith.mjs.map +1 -1
  707. package/_mjs/Stream/api/zipWith.mjs +5 -3
  708. package/_mjs/Stream/api/zipWith.mjs.map +1 -1
  709. package/_mjs/Stream/api/zipWithChunks.mjs +12 -10
  710. package/_mjs/Stream/api/zipWithChunks.mjs.map +1 -1
  711. package/_mjs/Stream/api.mjs +856 -653
  712. package/_mjs/Stream/api.mjs.map +1 -1
  713. package/_mjs/Stream/definition.mjs.map +1 -1
  714. package/_mjs/Stream/internal/DebounceState.mjs +18 -16
  715. package/_mjs/Stream/internal/DebounceState.mjs.map +1 -1
  716. package/_mjs/Stream/internal/Handoff.mjs +35 -32
  717. package/_mjs/Stream/internal/Handoff.mjs.map +1 -1
  718. package/_mjs/Stream/internal/Pull.mjs +9 -10
  719. package/_mjs/Stream/internal/Pull.mjs.map +1 -1
  720. package/_mjs/Stream/internal/SinkEndReason.mjs +14 -12
  721. package/_mjs/Stream/internal/SinkEndReason.mjs.map +1 -1
  722. package/_mjs/Stream/internal/Take.mjs +28 -20
  723. package/_mjs/Stream/internal/Take.mjs.map +1 -1
  724. package/_mjs/Stream/internal/util.mjs +3 -3
  725. package/_mjs/Stream/internal/util.mjs.map +1 -1
  726. package/_mjs/SubscriptionRef.mjs +45 -0
  727. package/_mjs/SubscriptionRef.mjs.map +1 -0
  728. package/_mjs/Supervisor/api.mjs +22 -18
  729. package/_mjs/Supervisor/api.mjs.map +1 -1
  730. package/_mjs/Supervisor/constructors.mjs +2 -2
  731. package/_mjs/Supervisor/constructors.mjs.map +1 -1
  732. package/_mjs/Supervisor/definition.mjs +1 -1
  733. package/_mjs/Supervisor/definition.mjs.map +1 -1
  734. package/_mjs/SupervisorPatch.mjs +15 -11
  735. package/_mjs/SupervisorPatch.mjs.map +1 -1
  736. package/_mjs/TExit/definition.mjs.map +1 -1
  737. package/_mjs/TFuture/api.mjs +17 -11
  738. package/_mjs/TFuture/api.mjs.map +1 -1
  739. package/_mjs/TFuture/constructors.mjs +1 -1
  740. package/_mjs/TFuture/constructors.mjs.map +1 -1
  741. package/_mjs/TFuture/definition.mjs.map +1 -1
  742. package/_mjs/TReentrantLock/api.mjs +32 -28
  743. package/_mjs/TReentrantLock/api.mjs.map +1 -1
  744. package/_mjs/TReentrantLock/definition.mjs +4 -4
  745. package/_mjs/TReentrantLock/definition.mjs.map +1 -1
  746. package/_mjs/TRef/api.mjs +218 -194
  747. package/_mjs/TRef/api.mjs.map +1 -1
  748. package/_mjs/TRef/definition.mjs +4 -4
  749. package/_mjs/TRef/definition.mjs.map +1 -1
  750. package/_mjs/TSemaphore/api.mjs +23 -19
  751. package/_mjs/TSemaphore/api.mjs.map +1 -1
  752. package/_mjs/TSemaphore/constructors.mjs +12 -2
  753. package/_mjs/TSemaphore/constructors.mjs.map +1 -1
  754. package/_mjs/collection/immutable/Conc/dropUntilIO.mjs +19 -17
  755. package/_mjs/collection/immutable/Conc/dropUntilIO.mjs.map +1 -1
  756. package/_mjs/collection/immutable/Conc/dropWhileIO.mjs +19 -17
  757. package/_mjs/collection/immutable/Conc/dropWhileIO.mjs.map +1 -1
  758. package/_mjs/collection/immutable/Conc/filterIO.mjs +14 -12
  759. package/_mjs/collection/immutable/Conc/filterIO.mjs.map +1 -1
  760. package/_mjs/collection/immutable/Conc/findIO.mjs +17 -15
  761. package/_mjs/collection/immutable/Conc/findIO.mjs.map +1 -1
  762. package/_mjs/collection/immutable/Conc/mapIO.mjs +10 -8
  763. package/_mjs/collection/immutable/Conc/mapIO.mjs.map +1 -1
  764. package/_mjs/collection/immutable/Conc/takeWhileIO.mjs +28 -26
  765. package/_mjs/collection/immutable/Conc/takeWhileIO.mjs.map +1 -1
  766. package/_mjs/data/Exit/foreachIO.mjs +5 -3
  767. package/_mjs/data/Exit/foreachIO.mjs.map +1 -1
  768. package/_mjs/internal/Hub.mjs +13 -11
  769. package/_mjs/internal/Hub.mjs.map +1 -1
  770. package/_mjs/internal/IsFatal.mjs +18 -16
  771. package/_mjs/internal/IsFatal.mjs.map +1 -1
  772. package/_mjs/internal/MutableQueue.mjs +10 -8
  773. package/_mjs/internal/MutableQueue.mjs.map +1 -1
  774. package/_mjs/internal/StackTraceBuilder.mjs.map +1 -1
  775. package/_src/Cached/api.ts +2 -2
  776. package/_src/Channel/ChildExecutorDecision/api.ts +14 -17
  777. package/_src/Channel/UpstreamPullRequest/api.ts +11 -13
  778. package/_src/Channel/api/interruptWhen.ts +18 -17
  779. package/_src/Channel/api/mapOutIOC.ts +58 -58
  780. package/_src/Channel/api/mergeAll.ts +15 -16
  781. package/_src/Channel/api/mergeAllUnboundedWith.ts +15 -27
  782. package/_src/Channel/api/mergeAllWith.ts +114 -126
  783. package/_src/Channel/api/mergeMap.ts +8 -18
  784. package/_src/Channel/api/mergeWith.ts +154 -158
  785. package/_src/Channel/api/toPull.ts +1 -1
  786. package/_src/Channel/api/zipC.ts +52 -88
  787. package/_src/Channel/api.ts +345 -405
  788. package/_src/Channel/core-api.ts +75 -122
  789. package/_src/Channel/definition.ts +49 -7
  790. package/_src/Channel/internal/ChannelExecutor.ts +1 -5
  791. package/_src/Channel/internal/SingleProducerAsyncInput.ts +1 -3
  792. package/_src/Fiber/FiberContext.ts +13 -33
  793. package/_src/Fiber/api/collectAll.ts +1 -2
  794. package/_src/Fiber/api/evalOn.ts +11 -14
  795. package/_src/Fiber/api/evalOnIO.ts +10 -13
  796. package/_src/Fiber/api/interruptAll.ts +1 -2
  797. package/_src/Fiber/api/interruptAs.ts +6 -4
  798. package/_src/Fiber/api/interruptAsFork.ts +6 -4
  799. package/_src/Fiber/api/interruptFork.ts +1 -1
  800. package/_src/Fiber/api/mapFiber.ts +5 -7
  801. package/_src/Fiber/api/mapIO.ts +21 -21
  802. package/_src/Fiber/api/zipWith.ts +14 -17
  803. package/_src/Fiber/definition.ts +1 -15
  804. package/_src/Fiber.ts +1 -1
  805. package/_src/FiberRef/api/locallyScoped.ts +8 -6
  806. package/_src/FiberRef/api/locallyScopedWith.ts +5 -7
  807. package/_src/FiberRef/api.ts +50 -39
  808. package/_src/FiberRef.ts +0 -1
  809. package/_src/FiberRefs/api.ts +14 -12
  810. package/_src/FiberRefs/join.ts +37 -46
  811. package/_src/FiberState/definition.ts +1 -2
  812. package/_src/Future/api.ts +67 -53
  813. package/_src/Hub/constructors.ts +80 -0
  814. package/_src/Hub/definition.ts +95 -89
  815. package/_src/Hub/internal.ts +115 -165
  816. package/_src/Hub.ts +1 -1
  817. package/_src/IO/api/acquireRelease.ts +1 -1
  818. package/_src/IO/api/acquireReleaseExit.ts +1 -1
  819. package/_src/IO/api/bracket.ts +1 -1
  820. package/_src/IO/api/bracketExit.ts +1 -1
  821. package/_src/IO/api/clockWith.ts +0 -1
  822. package/_src/IO/api/concurrency.ts +5 -7
  823. package/_src/IO/api/consoleWith.ts +0 -2
  824. package/_src/IO/api/core-scope.ts +36 -33
  825. package/_src/IO/api/ensuringChildren.ts +8 -7
  826. package/_src/IO/api/environment.ts +24 -42
  827. package/_src/IO/api/foreachC.ts +24 -12
  828. package/_src/IO/api/foreachExec.ts +1 -1
  829. package/_src/IO/api/forkIn.ts +7 -9
  830. package/_src/IO/api/fulfill.ts +5 -3
  831. package/_src/IO/api/interrupt.ts +37 -40
  832. package/_src/IO/api/onExit.ts +8 -10
  833. package/_src/IO/api/onTermination.ts +12 -14
  834. package/_src/IO/api/provideLayer.ts +8 -10
  835. package/_src/IO/api/provideSomeLayer.ts +5 -14
  836. package/_src/IO/api/race.ts +19 -21
  837. package/_src/IO/api/raceFirst.ts +5 -7
  838. package/_src/IO/api/repeat.ts +3 -5
  839. package/_src/IO/api/retry.ts +19 -21
  840. package/_src/IO/api/schedule.ts +20 -21
  841. package/_src/IO/api/scoped.ts +2 -2
  842. package/_src/IO/api/sequenceT.ts +7 -1
  843. package/_src/IO/api/stateful.ts +0 -2
  844. package/_src/IO/api/supervised.ts +5 -7
  845. package/_src/IO/api/timeout.ts +10 -16
  846. package/_src/IO/api/withFinalizer.ts +5 -7
  847. package/_src/IO/api/withFinalizerExit.ts +6 -5
  848. package/_src/IO/api/withRuntimeConfig.ts +12 -14
  849. package/_src/IO/api/zipC.ts +57 -62
  850. package/_src/IO/api.ts +512 -539
  851. package/_src/IO/definition.ts +21 -9
  852. package/_src/IO/runtime.ts +0 -12
  853. package/_src/IO.ts +0 -1
  854. package/_src/Layer/MemoMap.ts +61 -63
  855. package/_src/Layer/api.ts +95 -104
  856. package/_src/Layer/definition.ts +0 -1
  857. package/_src/LogLevel.ts +24 -16
  858. package/_src/LogSpan.ts +16 -16
  859. package/_src/Logger/api.ts +18 -17
  860. package/_src/Logger/constructors.ts +9 -15
  861. package/_src/Queue/constructors.ts +22 -6
  862. package/_src/Queue/definition.ts +230 -81
  863. package/_src/Queue/internal.ts +9 -180
  864. package/_src/Queue/strategy.ts +9 -23
  865. package/_src/Queue.ts +1 -3
  866. package/_src/Ref/Atomic.ts +37 -4
  867. package/_src/Ref/Synchronized.ts +107 -0
  868. package/_src/Ref/constructors.ts +15 -0
  869. package/_src/Ref/definition.ts +86 -85
  870. package/_src/Ref.ts +1 -9
  871. package/_src/Reloadable/constructors.ts +2 -2
  872. package/_src/RuntimeConfig.ts +0 -2
  873. package/_src/STM/api/core-api.ts +32 -35
  874. package/_src/STM/api.ts +210 -200
  875. package/_src/STM/internal/Entry.ts +0 -10
  876. package/_src/STM/internal/Journal.ts +23 -26
  877. package/_src/STM.ts +0 -1
  878. package/_src/Schedule/Decision.ts +10 -8
  879. package/_src/Schedule/api/driver.ts +0 -4
  880. package/_src/Schedule/api.ts +419 -444
  881. package/_src/Schedule/definition.ts +0 -1
  882. package/_src/Scope/ReleaseMap/api/releaseAll.ts +23 -26
  883. package/_src/Scope/ReleaseMap/api.ts +77 -74
  884. package/_src/Scope/api.ts +16 -18
  885. package/_src/ScopedRef/api.ts +0 -3
  886. package/_src/ScopedRef/definition.ts +1 -2
  887. package/_src/Sink/api.ts +326 -357
  888. package/_src/State/api.ts +12 -8
  889. package/_src/State/internal.ts +1 -1
  890. package/_src/Stream/api/zipAllWith.ts +6 -5
  891. package/_src/Stream/api/zipWith.ts +5 -8
  892. package/_src/Stream/api/zipWithChunks.ts +6 -5
  893. package/_src/Stream/api.ts +1049 -1176
  894. package/_src/Stream/definition.ts +0 -2
  895. package/_src/Stream/internal/DebounceState.ts +16 -17
  896. package/_src/Stream/internal/Handoff.ts +31 -35
  897. package/_src/Stream/internal/Pull.ts +1 -2
  898. package/_src/Stream/internal/SinkEndReason.ts +13 -14
  899. package/_src/Stream/internal/Take.ts +21 -21
  900. package/_src/Stream/internal/util.ts +0 -2
  901. package/_src/SubscriptionRef.ts +44 -0
  902. package/_src/Supervisor/api.ts +18 -14
  903. package/_src/Supervisor/definition.ts +0 -1
  904. package/_src/SupervisorPatch.ts +10 -6
  905. package/_src/TExit/definition.ts +0 -8
  906. package/_src/TFuture/api.ts +23 -17
  907. package/_src/TFuture/definition.ts +0 -1
  908. package/_src/TReentrantLock/api.ts +14 -10
  909. package/_src/TReentrantLock/definition.ts +0 -7
  910. package/_src/TRef/api.ts +207 -209
  911. package/_src/TRef/definition.ts +0 -12
  912. package/_src/TSemaphore/api.ts +19 -18
  913. package/_src/TSemaphore/constructors.ts +7 -0
  914. package/_src/collection/immutable/Conc/dropUntilIO.ts +19 -21
  915. package/_src/collection/immutable/Conc/dropWhileIO.ts +21 -23
  916. package/_src/collection/immutable/Conc/filterIO.ts +15 -17
  917. package/_src/collection/immutable/Conc/findIO.ts +17 -19
  918. package/_src/collection/immutable/Conc/mapIO.ts +12 -10
  919. package/_src/collection/immutable/Conc/takeWhileIO.ts +27 -29
  920. package/_src/data/Exit/foreachIO.ts +8 -10
  921. package/_src/global.ts +7 -3
  922. package/_src/index.ts +3 -0
  923. package/_src/internal/Hub.ts +17 -27
  924. package/_src/internal/IsFatal.ts +14 -12
  925. package/_src/internal/MutableQueue.ts +8 -8
  926. package/_src/internal/StackTraceBuilder.ts +1 -2
  927. package/collection/immutable/Conc/dropUntilIO.d.ts +3 -3
  928. package/collection/immutable/Conc/dropWhileIO.d.ts +3 -3
  929. package/collection/immutable/Conc/filterIO.d.ts +3 -3
  930. package/collection/immutable/Conc/findIO.d.ts +2 -2
  931. package/collection/immutable/Conc/mapIO.d.ts +3 -3
  932. package/collection/immutable/Conc/takeWhileIO.d.ts +3 -3
  933. package/data/Exit/foreachIO.d.ts +3 -3
  934. package/global.d.ts +7 -3
  935. package/index.d.ts +3 -0
  936. package/internal/Hub.d.ts +2 -2
  937. package/internal/IsFatal.d.ts +3 -3
  938. package/internal/MutableQueue.d.ts +3 -3
  939. package/package.json +3 -3
  940. package/Hub/api.d.ts +0 -190
  941. package/Queue/api/dimapIO.d.ts +0 -41
  942. package/Queue/api/filterInputIO.d.ts +0 -33
  943. package/Queue/api/filterOutputIO.d.ts +0 -31
  944. package/Queue/api/operations.d.ts +0 -82
  945. package/Queue/api/poll.d.ts +0 -9
  946. package/Queue/api/takeBetween.d.ts +0 -11
  947. package/Queue/api/zipWithIO.d.ts +0 -44
  948. package/Queue/api.d.ts +0 -7
  949. package/Ref/Atomic/Atomic.d.ts +0 -18
  950. package/Ref/Atomic/api.d.ts +0 -53
  951. package/Ref/Derived.d.ts +0 -14
  952. package/Ref/DerivedAll.d.ts +0 -14
  953. package/Ref/Synchronized/api.d.ts +0 -100
  954. package/Ref/Synchronized/constructors.d.ts +0 -8
  955. package/Ref/Synchronized/definition.d.ts +0 -42
  956. package/Ref/api/collect.d.ts +0 -11
  957. package/Ref/api/dimap.d.ts +0 -56
  958. package/Ref/api/filter.d.ts +0 -20
  959. package/Ref/api/get.d.ts +0 -9
  960. package/Ref/api/match.d.ts +0 -13
  961. package/Ref/api/matchAll.d.ts +0 -11
  962. package/Ref/api/modify.d.ts +0 -79
  963. package/Ref/api/set.d.ts +0 -10
  964. package/Ref/api.d.ts +0 -23
  965. package/_cjs/Hub/api.cjs +0 -456
  966. package/_cjs/Hub/api.cjs.map +0 -1
  967. package/_cjs/Queue/api/dimapIO.cjs +0 -120
  968. package/_cjs/Queue/api/dimapIO.cjs.map +0 -1
  969. package/_cjs/Queue/api/filterInputIO.cjs +0 -84
  970. package/_cjs/Queue/api/filterInputIO.cjs.map +0 -1
  971. package/_cjs/Queue/api/filterOutputIO.cjs +0 -89
  972. package/_cjs/Queue/api/filterOutputIO.cjs.map +0 -1
  973. package/_cjs/Queue/api/operations.cjs +0 -147
  974. package/_cjs/Queue/api/operations.cjs.map +0 -1
  975. package/_cjs/Queue/api/poll.cjs +0 -27
  976. package/_cjs/Queue/api/poll.cjs.map +0 -1
  977. package/_cjs/Queue/api/takeBetween.cjs +0 -57
  978. package/_cjs/Queue/api/takeBetween.cjs.map +0 -1
  979. package/_cjs/Queue/api/zipWithIO.cjs +0 -97
  980. package/_cjs/Queue/api/zipWithIO.cjs.map +0 -1
  981. package/_cjs/Queue/api.cjs +0 -97
  982. package/_cjs/Queue/api.cjs.map +0 -1
  983. package/_cjs/Ref/Atomic/Atomic.cjs +0 -64
  984. package/_cjs/Ref/Atomic/Atomic.cjs.map +0 -1
  985. package/_cjs/Ref/Atomic/api.cjs +0 -156
  986. package/_cjs/Ref/Atomic/api.cjs.map +0 -1
  987. package/_cjs/Ref/Derived.cjs +0 -55
  988. package/_cjs/Ref/Derived.cjs.map +0 -1
  989. package/_cjs/Ref/DerivedAll.cjs +0 -55
  990. package/_cjs/Ref/DerivedAll.cjs.map +0 -1
  991. package/_cjs/Ref/Synchronized/api.cjs +0 -196
  992. package/_cjs/Ref/Synchronized/api.cjs.map +0 -1
  993. package/_cjs/Ref/Synchronized/constructors.cjs +0 -32
  994. package/_cjs/Ref/Synchronized/constructors.cjs.map +0 -1
  995. package/_cjs/Ref/Synchronized/definition.cjs +0 -88
  996. package/_cjs/Ref/Synchronized/definition.cjs.map +0 -1
  997. package/_cjs/Ref/api/collect.cjs +0 -31
  998. package/_cjs/Ref/api/collect.cjs.map +0 -1
  999. package/_cjs/Ref/api/dimap.cjs +0 -110
  1000. package/_cjs/Ref/api/dimap.cjs.map +0 -1
  1001. package/_cjs/Ref/api/filter.cjs +0 -45
  1002. package/_cjs/Ref/api/filter.cjs.map +0 -1
  1003. package/_cjs/Ref/api/get.cjs +0 -20
  1004. package/_cjs/Ref/api/get.cjs.map +0 -1
  1005. package/_cjs/Ref/api/match.cjs +0 -26
  1006. package/_cjs/Ref/api/match.cjs.map +0 -1
  1007. package/_cjs/Ref/api/matchAll.cjs +0 -24
  1008. package/_cjs/Ref/api/matchAll.cjs.map +0 -1
  1009. package/_cjs/Ref/api/modify.cjs +0 -239
  1010. package/_cjs/Ref/api/modify.cjs.map +0 -1
  1011. package/_cjs/Ref/api/set.cjs +0 -21
  1012. package/_cjs/Ref/api/set.cjs.map +0 -1
  1013. package/_cjs/Ref/api.cjs +0 -158
  1014. package/_cjs/Ref/api.cjs.map +0 -1
  1015. package/_mjs/Hub/api.mjs +0 -384
  1016. package/_mjs/Hub/api.mjs.map +0 -1
  1017. package/_mjs/Queue/api/dimapIO.mjs +0 -97
  1018. package/_mjs/Queue/api/dimapIO.mjs.map +0 -1
  1019. package/_mjs/Queue/api/filterInputIO.mjs +0 -63
  1020. package/_mjs/Queue/api/filterInputIO.mjs.map +0 -1
  1021. package/_mjs/Queue/api/filterOutputIO.mjs +0 -68
  1022. package/_mjs/Queue/api/filterOutputIO.mjs.map +0 -1
  1023. package/_mjs/Queue/api/operations.mjs +0 -122
  1024. package/_mjs/Queue/api/operations.mjs.map +0 -1
  1025. package/_mjs/Queue/api/poll.mjs +0 -14
  1026. package/_mjs/Queue/api/poll.mjs.map +0 -1
  1027. package/_mjs/Queue/api/takeBetween.mjs +0 -43
  1028. package/_mjs/Queue/api/takeBetween.mjs.map +0 -1
  1029. package/_mjs/Queue/api/zipWithIO.mjs +0 -74
  1030. package/_mjs/Queue/api/zipWithIO.mjs.map +0 -1
  1031. package/_mjs/Queue/api.mjs +0 -9
  1032. package/_mjs/Queue/api.mjs.map +0 -1
  1033. package/_mjs/Ref/Atomic/Atomic.mjs +0 -47
  1034. package/_mjs/Ref/Atomic/Atomic.mjs.map +0 -1
  1035. package/_mjs/Ref/Atomic/api.mjs +0 -127
  1036. package/_mjs/Ref/Atomic/api.mjs.map +0 -1
  1037. package/_mjs/Ref/Derived.mjs +0 -35
  1038. package/_mjs/Ref/Derived.mjs.map +0 -1
  1039. package/_mjs/Ref/DerivedAll.mjs +0 -35
  1040. package/_mjs/Ref/DerivedAll.mjs.map +0 -1
  1041. package/_mjs/Ref/Synchronized/api.mjs +0 -154
  1042. package/_mjs/Ref/Synchronized/api.mjs.map +0 -1
  1043. package/_mjs/Ref/Synchronized/constructors.mjs +0 -15
  1044. package/_mjs/Ref/Synchronized/constructors.mjs.map +0 -1
  1045. package/_mjs/Ref/Synchronized/definition.mjs +0 -66
  1046. package/_mjs/Ref/Synchronized/definition.mjs.map +0 -1
  1047. package/_mjs/Ref/api/collect.mjs +0 -17
  1048. package/_mjs/Ref/api/collect.mjs.map +0 -1
  1049. package/_mjs/Ref/api/dimap.mjs +0 -84
  1050. package/_mjs/Ref/api/dimap.mjs.map +0 -1
  1051. package/_mjs/Ref/api/filter.mjs +0 -29
  1052. package/_mjs/Ref/api/filter.mjs.map +0 -1
  1053. package/_mjs/Ref/api/get.mjs +0 -13
  1054. package/_mjs/Ref/api/get.mjs.map +0 -1
  1055. package/_mjs/Ref/api/match.mjs +0 -18
  1056. package/_mjs/Ref/api/match.mjs.map +0 -1
  1057. package/_mjs/Ref/api/matchAll.mjs +0 -16
  1058. package/_mjs/Ref/api/matchAll.mjs.map +0 -1
  1059. package/_mjs/Ref/api/modify.mjs +0 -204
  1060. package/_mjs/Ref/api/modify.mjs.map +0 -1
  1061. package/_mjs/Ref/api/set.mjs +0 -14
  1062. package/_mjs/Ref/api/set.mjs.map +0 -1
  1063. package/_mjs/Ref/api.mjs +0 -34
  1064. package/_mjs/Ref/api.mjs.map +0 -1
  1065. package/_src/Hub/api.ts +0 -461
  1066. package/_src/Queue/api/dimapIO.ts +0 -130
  1067. package/_src/Queue/api/filterInputIO.ts +0 -75
  1068. package/_src/Queue/api/filterOutputIO.ts +0 -76
  1069. package/_src/Queue/api/operations.ts +0 -139
  1070. package/_src/Queue/api/poll.ts +0 -14
  1071. package/_src/Queue/api/takeBetween.ts +0 -45
  1072. package/_src/Queue/api/zipWithIO.ts +0 -99
  1073. package/_src/Queue/api.ts +0 -9
  1074. package/_src/Ref/Atomic/Atomic.ts +0 -56
  1075. package/_src/Ref/Atomic/api.ts +0 -124
  1076. package/_src/Ref/Derived.ts +0 -71
  1077. package/_src/Ref/DerivedAll.ts +0 -75
  1078. package/_src/Ref/Synchronized/api.ts +0 -249
  1079. package/_src/Ref/Synchronized/constructors.ts +0 -12
  1080. package/_src/Ref/Synchronized/definition.ts +0 -126
  1081. package/_src/Ref/api/collect.ts +0 -19
  1082. package/_src/Ref/api/dimap.ts +0 -115
  1083. package/_src/Ref/api/filter.ts +0 -35
  1084. package/_src/Ref/api/get.ts +0 -17
  1085. package/_src/Ref/api/match.ts +0 -24
  1086. package/_src/Ref/api/matchAll.ts +0 -23
  1087. package/_src/Ref/api/modify.ts +0 -237
  1088. package/_src/Ref/api/set.ts +0 -19
  1089. package/_src/Ref/api.ts +0 -39
@@ -1,12 +1,11 @@
1
- import type { PHub } from "../Hub.js";
2
1
  import type { Canceler } from "../IO.js";
3
- import type { PQueue } from "../Queue.js";
4
2
  import type { SinkEndReason } from "./internal/SinkEndReason.js";
5
3
  import type { Erase } from "@fncts/typelevel/Intersection.js";
6
4
 
7
5
  import { constVoid, identity, tuple } from "@fncts/base/data/function";
8
6
 
9
7
  import { MergeDecision } from "../Channel/internal/MergeDecision.js";
8
+ import { Hub } from "../Hub.js";
10
9
  import { Queue } from "../Queue.js";
11
10
  import { DEFAULT_CHUNK_SIZE, Stream } from "./definition.js";
12
11
  import { DebounceState } from "./internal/DebounceState.js";
@@ -37,28 +36,27 @@ export function absolve<R, E, E2, A>(self: Stream<R, E, Either<E2, A>>, __tsplus
37
36
  * Any sink can be used here, but see `Sink.foldWeightedM` and `Sink.foldUntilM` for
38
37
  * sinks that cover the common usecases.
39
38
  *
40
- * @tsplus fluent fncts.io.Stream aggregateAsync
39
+ * @tsplus pipeable fncts.io.Stream aggregateAsync
41
40
  */
42
- export function aggregateAsync_<R, E, A extends A1, R1, E1, A1, B>(
43
- stream: Stream<R, E, A>,
44
- sink: Sink<R1, E1, A1, A1, B>,
45
- __tsplusTrace?: string,
46
- ): Stream<R | R1, E | E1, B> {
47
- return stream.aggregateAsyncWithin(sink, Schedule.forever);
41
+ export function aggregateAsync<R1, E1, A1, B>(sink: Sink<R1, E1, A1, A1, B>, __tsplusTrace?: string) {
42
+ return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
43
+ return stream.aggregateAsyncWithin(sink, Schedule.forever);
44
+ };
48
45
  }
49
46
 
50
47
  /**
51
48
  * Like `aggregateAsyncWithinEither`, but only returns the `Right` results.
52
49
  *
53
- * @tsplus fluent fncts.io.Stream aggregateAsyncWithin
50
+ * @tsplus pipeable fncts.io.Stream aggregateAsyncWithin
54
51
  */
55
- export function aggregateAsyncWithin_<R, E, A extends A1, R1, E1, A1, B, R2, C>(
56
- stream: Stream<R, E, A>,
52
+ export function aggregateAsyncWithin<R1, E1, A1, B, R2, C>(
57
53
  sink: Sink<R1, E1, A1, A1, B>,
58
54
  schedule: Schedule<R2, Maybe<B>, C>,
59
55
  __tsplusTrace?: string,
60
- ): Stream<R | R1 | R2, E | E1, B> {
61
- return stream.aggregateAsyncWithinEither(sink, schedule).filterMap((cb) => cb.match(() => Nothing(), Maybe.just));
56
+ ) {
57
+ return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, B> => {
58
+ return stream.aggregateAsyncWithinEither(sink, schedule).filterMap((cb) => cb.match(() => Nothing(), Maybe.just));
59
+ };
62
60
  }
63
61
 
64
62
  /**
@@ -73,131 +71,124 @@ export function aggregateAsyncWithin_<R, E, A extends A1, R1, E1, A1, B, R2, C>(
73
71
  * Aggregated elements will be fed into the schedule to determine the delays between
74
72
  * pulls.
75
73
  *
76
- * @tsplus fluent fncts.io.Stream aggregateAsyncWithinEither
74
+ * @tsplus pipeable fncts.io.Stream aggregateAsyncWithinEither
77
75
  */
78
- export function aggregateAsyncWithinEither_<R, E, A extends A1, R1, E1, A1, B, R2, C>(
79
- stream: Stream<R, E, A>,
76
+ export function aggregateAsyncWithinEither<R1, E1, A1, B, R2, C>(
80
77
  sink: Sink<R1, E1, A1, A1, B>,
81
78
  schedule: Schedule<R2, Maybe<B>, C>,
82
79
  __tsplusTrace?: string,
83
- ): Stream<R | R1 | R2, E | E1, Either<C, B>> {
84
- type LocalHandoffSignal = HandoffSignal<E | E1, A1>;
85
-
86
- const deps = IO.sequenceT(
87
- Handoff<LocalHandoffSignal>(),
88
- Ref.make<SinkEndReason>(new ScheduleEnd()),
89
- Ref.make(Conc.empty<A1>()),
90
- schedule.driver,
91
- Ref.make(false),
92
- );
93
-
94
- return Stream.fromIO(deps).flatMap(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver, consumed]) => {
95
- const handoffProducer: Channel<never, E | E1, Conc<A1>, unknown, never, never, any> = Channel.readWithCause(
96
- (_in: Conc<A1>) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(_in))).apSecond(handoffProducer),
97
- (cause: Cause<E | E1>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
98
- (_: any) => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
80
+ ) {
81
+ return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, Either<C, B>> => {
82
+ type LocalHandoffSignal = HandoffSignal<E | E1, A1>;
83
+ const deps = IO.sequenceT(
84
+ Handoff<LocalHandoffSignal>(),
85
+ Ref.make<SinkEndReason>(new ScheduleEnd()),
86
+ Ref.make(Conc.empty<A1>()),
87
+ schedule.driver,
88
+ Ref.make(false),
99
89
  );
100
-
101
- const handoffConsumer: Channel<never, unknown, unknown, unknown, E | E1, Conc<A1>, void> = Channel.unwrap(
102
- sinkLeftovers.getAndSet(Conc.empty<A>()).flatMap((leftovers) => {
103
- if (leftovers.isNonEmpty) {
104
- return consumed.set(true) > IO.succeedNow(Channel.writeNow(leftovers) > handoffConsumer);
105
- } else {
106
- return handoff.take.map((signal) =>
107
- signal.match({
108
- Emit: ({ els }) => Channel.fromIO(consumed.set(true)) > Channel.writeNow(els) > handoffConsumer,
109
- Halt: ({ error }) => Channel.failCause(error),
110
- End: ({ reason }) => {
111
- if (reason._tag === SinkEndReasonTag.ScheduleEnd) {
112
- return Channel.unwrap(
113
- consumed.get.map((p) =>
114
- p
115
- ? Channel.fromIO(sinkEndReason.set(new ScheduleEnd()))
116
- : Channel.fromIO(sinkEndReason.set(new ScheduleEnd())) > handoffConsumer,
90
+ return Stream.fromIO(deps).flatMap(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver, consumed]) => {
91
+ const handoffProducer: Channel<never, E | E1, Conc<A1>, unknown, never, never, any> = Channel.readWithCause(
92
+ (_in: Conc<A1>) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(_in))).apSecond(handoffProducer),
93
+ (cause: Cause<E | E1>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
94
+ (_: any) => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
95
+ );
96
+ const handoffConsumer: Channel<never, unknown, unknown, unknown, E | E1, Conc<A1>, void> = Channel.unwrap(
97
+ sinkLeftovers.getAndSet(Conc.empty<A>()).flatMap((leftovers) => {
98
+ if (leftovers.isNonEmpty) {
99
+ return consumed.set(true) > IO.succeedNow(Channel.writeNow(leftovers) > handoffConsumer);
100
+ } else {
101
+ return handoff.take.map((signal) =>
102
+ signal.match({
103
+ Emit: ({ els }) => Channel.fromIO(consumed.set(true)) > Channel.writeNow(els) > handoffConsumer,
104
+ Halt: ({ error }) => Channel.failCause(error),
105
+ End: ({ reason }) => {
106
+ if (reason._tag === SinkEndReasonTag.ScheduleEnd) {
107
+ return Channel.unwrap(
108
+ consumed.get.map((p) =>
109
+ p
110
+ ? Channel.fromIO(sinkEndReason.set(new ScheduleEnd()))
111
+ : Channel.fromIO(sinkEndReason.set(new ScheduleEnd())) > handoffConsumer,
112
+ ),
113
+ );
114
+ } else {
115
+ return Channel.fromIO(sinkEndReason.set(reason));
116
+ }
117
+ },
118
+ }),
119
+ );
120
+ }
121
+ }),
122
+ );
123
+ function timeout(lastB: Maybe<B>, __tsplusTrace?: string): IO<R2, Nothing, C> {
124
+ return scheduleDriver.next(lastB);
125
+ }
126
+ const scheduledAggregator = (
127
+ sinkFiber: Fiber.Runtime<E | E1, readonly [Conc<Conc<A1>>, B]>,
128
+ scheduleFiber: Fiber.Runtime<Nothing, C>,
129
+ ): Channel<R1 | R2, unknown, unknown, unknown, E | E1, Conc<Either<C, B>>, any> => {
130
+ const forkSink =
131
+ consumed.set(false) > handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped;
132
+ function handleSide(leftovers: Conc<Conc<A1>>, b: B, c: Maybe<C>, __tsplusTrace?: string) {
133
+ return Channel.unwrap(
134
+ sinkLeftovers.set(leftovers.flatten) >
135
+ sinkEndReason.get.map((reason) =>
136
+ reason.match({
137
+ ScheduleEnd: () =>
138
+ Channel.unwrapScoped(
139
+ Do((Δ) => {
140
+ const consumed_ = Δ(consumed.get);
141
+ const sinkFiber = Δ(forkSink);
142
+ const scheduleFiber = Δ(timeout(Just(b)).forkScoped);
143
+ const toWrite = c.match(
144
+ () => Conc(Either.right(b)),
145
+ (c) => Conc(Either.right(b), Either.left(c)),
146
+ );
147
+ return consumed_
148
+ ? Channel.write(toWrite) > scheduledAggregator(sinkFiber, scheduleFiber)
149
+ : scheduledAggregator(sinkFiber, scheduleFiber);
150
+ }),
117
151
  ),
118
- );
119
- } else {
120
- return Channel.fromIO(sinkEndReason.set(reason));
121
- }
122
- },
123
- }),
152
+ UpstreamEnd: () =>
153
+ Channel.unwrap(consumed.get.map((p) => (p ? Channel.write(Conc(Either.right(b))) : Channel.unit))),
154
+ }),
155
+ ),
124
156
  );
125
157
  }
126
- }),
127
- );
128
-
129
- function timeout(lastB: Maybe<B>, __tsplusTrace?: string): IO<R2, Nothing, C> {
130
- return scheduleDriver.next(lastB);
131
- }
132
-
133
- const scheduledAggregator = (
134
- sinkFiber: Fiber.Runtime<E | E1, readonly [Conc<Conc<A1>>, B]>,
135
- scheduleFiber: Fiber.Runtime<Nothing, C>,
136
- ): Channel<R1 | R2, unknown, unknown, unknown, E | E1, Conc<Either<C, B>>, any> => {
137
- const forkSink =
138
- consumed.set(false) > handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped;
139
-
140
- function handleSide(leftovers: Conc<Conc<A1>>, b: B, c: Maybe<C>, __tsplusTrace?: string) {
141
158
  return Channel.unwrap(
142
- sinkLeftovers.set(leftovers.flatten) >
143
- sinkEndReason.get.map((reason) =>
144
- reason.match({
145
- ScheduleEnd: () =>
146
- Channel.unwrapScoped(
147
- Do() => {
148
- const consumed_ = Δ(consumed.get);
149
- const sinkFiber = Δ(forkSink);
150
- const scheduleFiber = Δ(timeout(Just(b)).forkScoped);
151
- const toWrite = c.match(
152
- () => Conc(Either.right(b)),
153
- (c) => Conc(Either.right(b), Either.left(c)),
154
- );
155
- return consumed_
156
- ? Channel.write(toWrite) > scheduledAggregator(sinkFiber, scheduleFiber)
157
- : scheduledAggregator(sinkFiber, scheduleFiber);
158
- }),
159
+ sinkFiber.join.raceWith(
160
+ scheduleFiber.join,
161
+ (sinkExit, scheduleFiber) =>
162
+ scheduleFiber.interrupt >
163
+ IO.fromExit(sinkExit).map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
164
+ (scheduleExit, sinkFiber) =>
165
+ IO.fromExit(scheduleExit).matchCauseIO(
166
+ (cause) =>
167
+ cause.failureOrCause.match(
168
+ () =>
169
+ handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
170
+ sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
171
+ (cause) =>
172
+ handoff.offer(HandoffSignal.Halt(cause)).forkDaemon >
173
+ sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
159
174
  ),
160
- UpstreamEnd: () =>
161
- Channel.unwrap(consumed.get.map((p) => (p ? Channel.write(Conc(Either.right(b))) : Channel.unit))),
162
- }),
163
- ),
175
+ (c) =>
176
+ handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
177
+ sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Just(c))),
178
+ ),
179
+ ),
164
180
  );
165
- }
166
-
167
- return Channel.unwrap(
168
- sinkFiber.join.raceWith(
169
- scheduleFiber.join,
170
- (sinkExit, scheduleFiber) =>
171
- scheduleFiber.interrupt >
172
- IO.fromExit(sinkExit).map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
173
- (scheduleExit, sinkFiber) =>
174
- IO.fromExit(scheduleExit).matchCauseIO(
175
- (cause) =>
176
- cause.failureOrCause.match(
177
- () =>
178
- handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
179
- sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
180
- (cause) =>
181
- handoff.offer(HandoffSignal.Halt(cause)).forkDaemon >
182
- sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
183
- ),
184
- (c) =>
185
- handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
186
- sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Just(c))),
187
- ),
188
- ),
181
+ };
182
+ return Stream.unwrapScoped(
183
+ Do((Δ) => {
184
+ Δ(stream.channel.pipeTo(handoffProducer).runScoped.forkScoped);
185
+ const sinkFiber = Δ(handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped);
186
+ const scheduleFiber = Δ(timeout(Nothing()).forkScoped);
187
+ return new Stream(scheduledAggregator(sinkFiber, scheduleFiber));
188
+ }),
189
189
  );
190
- };
191
-
192
- return Stream.unwrapScoped(
193
- Do((Δ) => {
194
- Δ(stream.channel.pipeTo(handoffProducer).runScoped.forkScoped);
195
- const sinkFiber = Δ(handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped);
196
- const scheduleFiber = Δ(timeout(Nothing()).forkScoped);
197
- return new Stream(scheduledAggregator(sinkFiber, scheduleFiber));
198
- }),
199
- );
200
- });
190
+ });
191
+ };
201
192
  }
202
193
 
203
194
  /**
@@ -205,14 +196,12 @@ export function aggregateAsyncWithinEither_<R, E, A extends A1, R1, E1, A1, B, R
205
196
  * but keeps only elements from this stream.
206
197
  * The `that` stream would be run multiple times, for every element in the `this` stream.
207
198
  *
208
- * @tsplus fluent fncts.io.Stream apFirst
199
+ * @tsplus pipeable fncts.io.Stream apFirst
209
200
  */
210
- export function apFirst_<R, R1, E, E1, A, A1>(
211
- stream: Stream<R, E, A>,
212
- that: Stream<R1, E1, A1>,
213
- __tsplusTrace?: string,
214
- ): Stream<R | R1, E | E1, A> {
215
- return stream.crossWith(that, (a, _) => a);
201
+ export function apFirst<R1, E1, A1>(that: Stream<R1, E1, A1>, __tsplusTrace?: string) {
202
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
203
+ return stream.crossWith(that, (a, _) => a);
204
+ };
216
205
  }
217
206
 
218
207
  /**
@@ -220,23 +209,23 @@ export function apFirst_<R, R1, E, E1, A, A1>(
220
209
  * but keeps only elements from the other stream.
221
210
  * The `that` stream would be run multiple times, for every element in the `this` stream.
222
211
  *
223
- * @tsplus fluent fncts.io.Stream apSecond
212
+ * @tsplus pipeable fncts.io.Stream apSecond
224
213
  */
225
- export function apSecond_<R, R1, E, E1, A, A1>(
226
- stream: Stream<R, E, A>,
227
- that: Stream<R1, E1, A1>,
228
- __tsplusTrace?: string,
229
- ): Stream<R | R1, E | E1, A1> {
230
- return stream.crossWith(that, (_, b) => b);
214
+ export function apSecond<R1, E1, A1>(that: Stream<R1, E1, A1>, __tsplusTrace?: string) {
215
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A1> => {
216
+ return stream.crossWith(that, (_, b) => b);
217
+ };
231
218
  }
232
219
 
233
220
  /**
234
221
  * Maps the success values of this stream to the specified constant value.
235
222
  *
236
- * @tsplus fluent fncts.io.Stream as
223
+ * @tsplus pipeable fncts.io.Stream as
237
224
  */
238
- export function as_<R, E, A, B>(stream: Stream<R, E, A>, b: Lazy<B>, __tsplusTrace?: string): Stream<R, E, B> {
239
- return stream.map(() => b());
225
+ export function as<B>(b: Lazy<B>, __tsplusTrace?: string) {
226
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, B> => {
227
+ return stream.map(() => b());
228
+ };
240
229
  }
241
230
 
242
231
  /**
@@ -357,14 +346,11 @@ export function asyncIO<R, E, A, R1 = R, E1 = E>(
357
346
  /**
358
347
  * Returns a stream whose failure and success channels have been mapped by
359
348
  * the specified pair of functions, `f` and `g`.
349
+ *
350
+ * @tsplus pipeable fncts.io.Stream bimap
360
351
  */
361
- export function bimap_<R, E, E1, A, A1>(
362
- stream: Stream<R, E, A>,
363
- f: (e: E) => E1,
364
- g: (a: A) => A1,
365
- __tsplusTrace?: string,
366
- ): Stream<R, E1, A1> {
367
- return stream.mapError(f).map(g);
352
+ export function bimap<E, E1, A, A1>(f: (e: E) => E1, g: (a: A) => A1, __tsplusTrace?: string) {
353
+ return <R>(stream: Stream<R, E, A>): Stream<R, E1, A1> => stream.mapError(f).map(g);
368
354
  }
369
355
 
370
356
  /**
@@ -373,7 +359,7 @@ export function bimap_<R, E, E1, A, A1>(
373
359
  *
374
360
  * @tsplus static fncts.io.StreamOps acquireRelease
375
361
  */
376
- export function acquireRelease_<R, E, A, R1>(
362
+ export function acquireRelease<R, E, A, R1>(
377
363
  acquire: IO<R, E, A>,
378
364
  release: (a: A) => IO<R1, never, unknown>,
379
365
  __tsplusTrace?: string,
@@ -387,7 +373,7 @@ export function acquireRelease_<R, E, A, R1>(
387
373
  *
388
374
  * @tsplus static fncts.io.StreamOps acquireReleaseExit
389
375
  */
390
- export function acquireReleaseExit_<R, E, A, R1>(
376
+ export function acquireReleaseExit<R, E, A, R1>(
391
377
  acquire: IO<R, E, A>,
392
378
  release: (a: A, exit: Exit<any, any>) => IO<R1, never, unknown>,
393
379
  __tsplusTrace?: string,
@@ -400,17 +386,14 @@ export function acquireReleaseExit_<R, E, A, R1>(
400
386
  * The driver stream will only ever advance of the `maximumLag` chunks before the
401
387
  * slowest downstream stream.
402
388
  *
403
- * @tsplus fluent fncts.io.Stream broadcast
389
+ * @tsplus pipeable fncts.io.Stream broadcast
404
390
  */
405
- export function broadcast_<R, E, A>(
406
- stream: Stream<R, E, A>,
407
- n: number,
408
- maximumLag: number,
409
- __tsplusTrace?: string,
410
- ): IO<R | Scope, never, Conc<Stream<unknown, E, A>>> {
411
- return stream
412
- .broadcastedQueues(n, maximumLag)
413
- .map((c) => c.map((hub) => Stream.fromQueueWithShutdown(hub).flattenTake));
391
+ export function broadcast(n: number, maximumLag: number, __tsplusTrace?: string) {
392
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Conc<Stream<unknown, E, A>>> => {
393
+ return stream
394
+ .broadcastedQueues(n, maximumLag)
395
+ .map((c) => c.map((hub) => Stream.fromQueueWithShutdown(hub).flattenTake));
396
+ };
414
397
  }
415
398
 
416
399
  /**
@@ -418,16 +401,14 @@ export function broadcast_<R, E, A>(
418
401
  * The driver stream will only ever advance of the `maximumLag` chunks before the
419
402
  * slowest downstream stream.
420
403
  *
421
- * @tsplus fluent fncts.io.Stream broadcastDynamic
404
+ * @tsplus pipeable fncts.io.Stream broadcastDynamic
422
405
  */
423
- export function broadcastDynamic_<R, E, A>(
424
- stream: Stream<R, E, A>,
425
- maximumLag: number,
426
- __tsplusTrace?: string,
427
- ): IO<R | Scope, never, Stream<unknown, E, A>> {
428
- return stream
429
- .broadcastedQueuesDynamic(maximumLag)
430
- .map((scoped) => Stream.scoped(scoped).flatMap(Stream.fromQueue).flattenTake);
406
+ export function broadcastDynamic(maximumLag: number, __tsplusTrace?: string) {
407
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Stream<unknown, E, A>> => {
408
+ return stream
409
+ .broadcastedQueuesDynamic(maximumLag)
410
+ .map((scoped) => Stream.scoped(scoped).flatMap(Stream.fromQueue).flattenTake);
411
+ };
431
412
  }
432
413
 
433
414
  /**
@@ -436,20 +417,17 @@ export function broadcastDynamic_<R, E, A>(
436
417
  *
437
418
  * Queues can unsubscribe from upstream by shutting down.
438
419
  *
439
- * @tsplus fluent fncts.io.Stream broadcastedQueues
420
+ * @tsplus pipeable fncts.io.Stream broadcastedQueues
440
421
  */
441
- export function broadcastedQueues_<R, E, A>(
442
- stream: Stream<R, E, A>,
443
- n: number,
444
- maximumLag: number,
445
- __tsplusTrace?: string,
446
- ): IO<R | Scope, never, Conc<Hub.Dequeue<unknown, never, Take<E, A>>>> {
447
- return Do((Δ) => {
448
- const hub = Δ(Hub.makeBounded<Take<E, A>>(maximumLag));
449
- const queues = Δ(IO.sequenceIterable(Conc.replicate(n, hub.subscribe)));
450
- Δ(stream.runIntoHubScoped(hub).fork);
451
- return queues;
452
- });
422
+ export function broadcastedQueues(n: number, maximumLag: number, __tsplusTrace?: string) {
423
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Conc<Dequeue<Take<E, A>>>> => {
424
+ return Do((Δ) => {
425
+ const hub = Δ(Hub.makeBounded<Take<E, A>>(maximumLag));
426
+ const queues = Δ(IO.sequenceIterable(Conc.replicate(n, hub.subscribe)));
427
+ Δ(stream.runIntoHubScoped(hub).fork);
428
+ return queues;
429
+ });
430
+ };
453
431
  }
454
432
 
455
433
  /**
@@ -458,62 +436,62 @@ export function broadcastedQueues_<R, E, A>(
458
436
  *
459
437
  * Queues can unsubscribe from upstream by shutting down.
460
438
  *
461
- * @tsplus fluent fncts.io.Stream broadcastedQueuesDynamic
439
+ * @tsplus pipeable fncts.io.Stream broadcastedQueuesDynamic
462
440
  */
463
- export function broadcastedQueuesDynamic_<R, E, A>(
464
- stream: Stream<R, E, A>,
465
- maximumLag: number,
466
- __tsplusTrace?: string,
467
- ): IO<R | Scope, never, IO<Scope, never, Hub.Dequeue<never, never, Take<E, A>>>> {
468
- return stream.toHub(maximumLag).map((hub) => hub.subscribe);
441
+ export function broadcastedQueuesDynamic(maximumLag: number, __tsplusTrace?: string) {
442
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, IO<Scope, never, Dequeue<Take<E, A>>>> => {
443
+ return stream.toHub(maximumLag).map((hub) => hub.subscribe);
444
+ };
469
445
  }
470
446
 
471
447
  /**
472
448
  * Allows a faster producer to progress independently of a slower consumer by buffering
473
449
  * up to `capacity` elements in a queue.
474
450
  *
475
- * @tsplus fluent fncts.io.Stream buffer
476
- */
477
- export function buffer_<R, E, A>(stream: Stream<R, E, A>, capacity: number, __tsplusTrace?: string): Stream<R, E, A> {
478
- const queue = toQueueOfElements_(stream, capacity);
479
- return new Stream(
480
- Channel.unwrapScoped(
481
- queue.map((queue) => {
482
- const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(queue.take).flatMap(
483
- (exit: Exit<Maybe<E>, A>) =>
451
+ * @tsplus pipeable fncts.io.Stream buffer
452
+ */
453
+ export function buffer(capacity: number, __tsplusTrace?: string) {
454
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
455
+ const queue = stream.toQueueOfElements(capacity);
456
+ return new Stream(
457
+ Channel.unwrapScoped(
458
+ queue.map((queue) => {
459
+ const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
460
+ queue.take,
461
+ ).flatMap((exit: Exit<Maybe<E>, A>) =>
484
462
  exit.match(
485
463
  (cause) => cause.flipCauseMaybe.match(() => Channel.endNow(undefined), Channel.failCauseNow),
486
464
  (value) => Channel.writeNow(Conc.single(value)).apSecond(process),
487
465
  ),
488
- );
489
- return process;
490
- }),
491
- ),
492
- );
466
+ );
467
+ return process;
468
+ }),
469
+ ),
470
+ );
471
+ };
493
472
  }
494
473
 
495
474
  /**
496
- * @tsplus fluent fncts.io.Stream bufferChunks
475
+ * @tsplus pipeable fncts.io.Stream bufferChunks
497
476
  */
498
- export function bufferChunks_<R, E, A>(
499
- stream: Stream<R, E, A>,
500
- capacity: number,
501
- __tsplusTrace?: string,
502
- ): Stream<R, E, A> {
503
- const queue = stream.toQueue(capacity);
504
- return new Stream(
505
- Channel.unwrapScoped(
506
- queue.map((queue) => {
507
- const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(queue.take).flatMap(
508
- (take: Take<E, A>) =>
477
+ export function bufferChunks(capacity: number, __tsplusTrace?: string) {
478
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
479
+ const queue = stream.toQueue(capacity);
480
+ return new Stream(
481
+ Channel.unwrapScoped(
482
+ queue.map((queue) => {
483
+ const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
484
+ queue.take,
485
+ ).flatMap((take: Take<E, A>) =>
509
486
  take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
510
487
  Channel.writeNow(value).apSecond(process),
511
488
  ),
512
- );
513
- return process;
514
- }),
515
- ),
516
- );
489
+ );
490
+ return process;
491
+ }),
492
+ ),
493
+ );
494
+ };
517
495
  }
518
496
 
519
497
  /**
@@ -524,7 +502,6 @@ export function bufferChunks_<R, E, A>(
524
502
  */
525
503
  export function bufferUnbounded<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?: string): Stream<R, E, A> {
526
504
  const queue = stream.toQueueUnbounded;
527
-
528
505
  return new Stream(
529
506
  Channel.unwrapScoped(
530
507
  queue.map((queue) => {
@@ -534,7 +511,6 @@ export function bufferUnbounded<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?
534
511
  Channel.writeNow(value).apSecond(process),
535
512
  ),
536
513
  );
537
-
538
514
  return process;
539
515
  }),
540
516
  ),
@@ -590,14 +566,12 @@ function bufferSignalConsumer<R, E, A>(
590
566
  * Switches over to the stream produced by the provided function in case this one
591
567
  * fails with a typed error.
592
568
  *
593
- * @tsplus fluent fncts.io.Stream catchAll
569
+ * @tsplus pipeable fncts.io.Stream catchAll
594
570
  */
595
- export function catchAll_<R, R1, E, E1, A, A1>(
596
- stream: Stream<R, E, A>,
597
- f: (e: E) => Stream<R1, E1, A1>,
598
- __tsplusTrace?: string,
599
- ): Stream<R | R1, E1, A | A1> {
600
- return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
571
+ export function catchAll<R1, E, E1, A1>(f: (e: E) => Stream<R1, E1, A1>, __tsplusTrace?: string) {
572
+ return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
573
+ return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
574
+ };
601
575
  }
602
576
 
603
577
  /**
@@ -605,31 +579,27 @@ export function catchAll_<R, R1, E, E1, A, A1>(
605
579
  * fails. Allows recovery from all causes of failure, including interruption if the
606
580
  * stream is uninterruptible.
607
581
  *
608
- * @tsplus fluent fncts.io.Stream catchAllCause
582
+ * @tsplus pipeable fncts.io.Stream catchAllCause
609
583
  */
610
- export function catchAllCause_<R, R1, E, E1, A, A1>(
611
- stream: Stream<R, E, A>,
612
- f: (cause: Cause<E>) => Stream<R1, E1, A1>,
613
- __tsplusTrace?: string,
614
- ): Stream<R | R1, E1, A | A1> {
615
- const channel: Channel<R | R1, unknown, unknown, unknown, E1, Conc<A | A1>, unknown> = stream.channel.catchAllCause(
616
- (cause) => f(cause).channel,
617
- );
618
- return new Stream(channel);
584
+ export function catchAllCause<R1, E, E1, A1>(f: (cause: Cause<E>) => Stream<R1, E1, A1>, __tsplusTrace?: string) {
585
+ return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
586
+ const channel: Channel<R | R1, unknown, unknown, unknown, E1, Conc<A | A1>, unknown> = stream.channel.catchAllCause(
587
+ (cause) => f(cause).channel,
588
+ );
589
+ return new Stream(channel);
590
+ };
619
591
  }
620
592
 
621
593
  /**
622
594
  * Switches over to the stream produced by the provided function in case this one
623
595
  * fails with some typed error.
624
596
  *
625
- * @tsplus fluent fncts.io.Stream catchJust
597
+ * @tsplus pipeable fncts.io.Stream catchJust
626
598
  */
627
- export function catchJust_<R, R1, E, E1, A, A1>(
628
- stream: Stream<R, E, A>,
629
- pf: (e: E) => Maybe<Stream<R1, E1, A1>>,
630
- __tsplusTrace?: string,
631
- ): Stream<R | R1, E | E1, A | A1> {
632
- return stream.catchAll((e) => pf(e).getOrElse(Stream.failNow(e)));
599
+ export function catchJust<R1, E, E1, A1>(pf: (e: E) => Maybe<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
600
+ return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A | A1> => {
601
+ return stream.catchAll((e) => pf(e).getOrElse(Stream.failNow(e)));
602
+ };
633
603
  }
634
604
 
635
605
  /**
@@ -637,36 +607,32 @@ export function catchJust_<R, R1, E, E1, A, A1>(
637
607
  * fails with some errors. Allows recovery from all causes of failure, including interruption if the
638
608
  * stream is uninterruptible.
639
609
  *
640
- * @tsplus fluent fncts.io.Stream catchJustCause
610
+ * @tsplus pipeable fncts.io.Stream catchJustCause
641
611
  */
642
- export function catchJustCause_<R, R1, E, E1, A, A1>(
643
- stream: Stream<R, E, A>,
644
- pf: (e: Cause<E>) => Maybe<Stream<R1, E1, A1>>,
645
- __tsplusTrace?: string,
646
- ): Stream<R | R1, E | E1, A | A1> {
647
- return stream.catchAllCause((cause) => pf(cause).getOrElse(Stream.failCauseNow(cause)));
612
+ export function catchJustCause<R1, E, E1, A1>(pf: (e: Cause<E>) => Maybe<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
613
+ return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A | A1> => {
614
+ return stream.catchAllCause((cause) => pf(cause).getOrElse(Stream.failCauseNow(cause)));
615
+ };
648
616
  }
649
617
 
650
618
  /**
651
619
  * Returns a stream made of the concatenation in strict order of all the streams
652
620
  * produced by passing each element of this stream to `f`
653
621
  *
654
- * @tsplus fluent fncts.io.Stream flatMap
622
+ * @tsplus pipeable fncts.io.Stream flatMap
655
623
  */
656
- export function flatMap_<R, E, A, R1, E1, B>(
657
- stream: Stream<R, E, A>,
658
- f: (a: A) => Stream<R1, E1, B>,
659
- __tsplusTrace?: string,
660
- ): Stream<R | R1, E | E1, B> {
661
- return new Stream(
662
- stream.channel.concatMap((as) =>
663
- as
664
- .map((a) => f(a).channel)
665
- .foldLeft(Channel.unit as Channel<R1, unknown, unknown, unknown, E1, Conc<B>, unknown>, (s, a) =>
666
- s.flatMap(() => a),
667
- ),
668
- ),
669
- );
624
+ export function flatMap<A, R1, E1, B>(f: (a: A) => Stream<R1, E1, B>, __tsplusTrace?: string) {
625
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
626
+ return new Stream(
627
+ stream.channel.concatMap((as) =>
628
+ as
629
+ .map((a) => f(a).channel)
630
+ .foldLeft(Channel.unit as Channel<R1, unknown, unknown, unknown, E1, Conc<B>, unknown>, (s, a) =>
631
+ s.flatMap(() => a),
632
+ ),
633
+ ),
634
+ );
635
+ };
670
636
  }
671
637
 
672
638
  /**
@@ -682,14 +648,15 @@ export function chunks<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?: string)
682
648
  * Performs the specified stream transformation with the chunk structure of
683
649
  * the stream exposed.
684
650
  *
685
- * @tsplus fluent fncts.io.Stream chunksWith
651
+ * @tsplus pipeable fncts.io.Stream chunksWith
686
652
  */
687
653
  export function chunksWith<R, E, A, R1, E1, B>(
688
- self: Stream<R, E, A>,
689
654
  f: (_: Stream<R, E, Conc<A>>) => Stream<R1, E1, Conc<B>>,
690
655
  __tsplusTrace?: string,
691
- ): Stream<R1, E1, B> {
692
- return f(self.chunks).flattenChunks;
656
+ ) {
657
+ return (self: Stream<R, E, A>): Stream<R1, E1, B> => {
658
+ return f(self.chunks).flattenChunks;
659
+ };
693
660
  }
694
661
 
695
662
  function changesWithWriter<R, E, A>(
@@ -717,47 +684,41 @@ function changesWithWriter<R, E, A>(
717
684
  * previous element emitted, using the specified function to determine
718
685
  * whether two elements are equal.
719
686
  *
720
- * @tsplus fluent fncts.io.Stream changesWith
687
+ * @tsplus pipeable fncts.io.Stream changesWith
721
688
  */
722
- export function changesWith_<R, E, A>(
723
- stream: Stream<R, E, A>,
724
- f: (x: A, y: A) => boolean,
725
- __tsplusTrace?: string,
726
- ): Stream<R, E, A> {
727
- return new Stream(stream.channel.pipeTo(changesWithWriter<R, E, A>(f, Nothing())));
689
+ export function changesWith<A>(f: (x: A, y: A) => boolean, __tsplusTrace?: string) {
690
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
691
+ return new Stream(stream.channel.pipeTo(changesWithWriter<R, E, A>(f, Nothing())));
692
+ };
728
693
  }
729
694
 
730
695
  /**
731
696
  * Transforms all elements of the stream for as long as the specified partial function is defined.
732
697
  *
733
- * @tsplus fluent fncts.io.Stream collectWhile
698
+ * @tsplus pipeable fncts.io.Stream collectWhile
734
699
  */
735
- export function collectWhile_<R, E, A, A1>(
736
- stream: Stream<R, E, A>,
737
- pf: (a: A) => Maybe<A1>,
738
- __tsplusTrace?: string,
739
- ): Stream<R, E, A1> {
740
- const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A1>, any> = Channel.readWith(
741
- (inp) => {
742
- const mapped = inp.collectWhile(pf);
743
-
744
- if (mapped.length === inp.length) {
745
- return Channel.writeNow(mapped).apSecond(loop);
746
- } else {
747
- return Channel.writeNow(mapped);
748
- }
749
- },
750
- Channel.failNow,
751
- Channel.succeedNow,
752
- );
753
-
754
- return new Stream(stream.channel.pipeTo(loop));
700
+ export function collectWhile<A, A1>(pf: (a: A) => Maybe<A1>, __tsplusTrace?: string) {
701
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A1> => {
702
+ const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A1>, any> = Channel.readWith(
703
+ (inp) => {
704
+ const mapped = inp.collectWhile(pf);
705
+ if (mapped.length === inp.length) {
706
+ return Channel.writeNow(mapped).apSecond(loop);
707
+ } else {
708
+ return Channel.writeNow(mapped);
709
+ }
710
+ },
711
+ Channel.failNow,
712
+ Channel.succeedNow,
713
+ );
714
+ return new Stream(stream.channel.pipeTo(loop));
715
+ };
755
716
  }
756
717
 
757
718
  /**
758
719
  * Effectfully transforms all elements of the stream for as long as the specified partial function is defined.
759
720
  */
760
- export function collectWhileIO_<R, E, A, R1, E1, B>(
721
+ export function collectWhileIO<R, E, A, R1, E1, B>(
761
722
  stream: Stream<R, E, A>,
762
723
  pf: (a: A) => Maybe<IO<R1, E1, B>>,
763
724
  __tsplusTrace?: string,
@@ -809,10 +770,9 @@ function combineProducer<Err, Elem>(
809
770
  *
810
771
  * Where possible, prefer `Stream#combineChunks` for a more efficient implementation.
811
772
  *
812
- * @tsplus fluent fncts.io.Stream combine
773
+ * @tsplus pipeable fncts.io.Stream combine
813
774
  */
814
- export function combine_<R, E, A, R1, E1, A1, S, R2, A2>(
815
- stream: Stream<R, E, A>,
775
+ export function combine<R, E, A, R1, E1, A1, S, R2, A2>(
816
776
  that: Stream<R1, E1, A1>,
817
777
  s: S,
818
778
  f: (
@@ -821,25 +781,27 @@ export function combine_<R, E, A, R1, E1, A1, S, R2, A2>(
821
781
  eff2: IO<R1, Maybe<E1>, A1>,
822
782
  ) => IO<R2, never, Exit<Maybe<E | E1>, readonly [A2, S]>>,
823
783
  __tsplusTrace?: string,
824
- ): Stream<R | R1 | R2, E | E1, A2> {
825
- return new Stream(
826
- Channel.unwrapScoped(
827
- Do((Δ) => {
828
- const left = Δ(Handoff<Exit<Maybe<E>, A>>());
829
- const right = Δ(Handoff<Exit<Maybe<E1>, A1>>());
830
- const latchL = Δ(Handoff<void>());
831
- const latchR = Δ(Handoff<void>());
832
- Δ(stream.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(left, latchL)).runScoped.fork);
833
- Δ(that.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(right, latchR)).runScoped.fork);
834
- return tuple(left, right, latchL, latchR);
835
- }).map(([left, right, latchL, latchR]) => {
836
- const pullLeft = latchL.offer(undefined).apSecond(left.take).flatMap(IO.fromExitNow);
837
- const pullRight = latchR.offer(undefined).apSecond(right.take).flatMap(IO.fromExitNow);
838
- return Stream.unfoldIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExitNow(exit).optional))
839
- .channel;
840
- }),
841
- ),
842
- );
784
+ ) {
785
+ return (stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, A2> => {
786
+ return new Stream(
787
+ Channel.unwrapScoped(
788
+ Do((Δ) => {
789
+ const left = Δ(Handoff<Exit<Maybe<E>, A>>());
790
+ const right = Δ(Handoff<Exit<Maybe<E1>, A1>>());
791
+ const latchL = Δ(Handoff<void>());
792
+ const latchR = Δ(Handoff<void>());
793
+ Δ(stream.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(left, latchL)).runScoped.fork);
794
+ Δ(that.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(right, latchR)).runScoped.fork);
795
+ return tuple(left, right, latchL, latchR);
796
+ }).map(([left, right, latchL, latchR]) => {
797
+ const pullLeft = latchL.offer(undefined).apSecond(left.take).flatMap(IO.fromExitNow);
798
+ const pullRight = latchR.offer(undefined).apSecond(right.take).flatMap(IO.fromExitNow);
799
+ return Stream.unfoldIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExitNow(exit).optional))
800
+ .channel;
801
+ }),
802
+ ),
803
+ );
804
+ };
843
805
  }
844
806
 
845
807
  function combineChunksProducer<Err, Elem>(
@@ -862,10 +824,9 @@ function combineChunksProducer<Err, Elem>(
862
824
  * it to the destination stream. `f` can maintain some internal state to control
863
825
  * the combining process, with the initial state being specified by `s`.
864
826
  *
865
- * @tsplus fluent fncts.io.Stream combineChunks
827
+ * @tsplus pipeable fncts.io.Stream combineChunks
866
828
  */
867
- export function combineChunks_<R, E, A, R1, E1, A1, S, R2, A2>(
868
- stream: Stream<R, E, A>,
829
+ export function combineChunks<R, E, A, R1, E1, A1, S, R2, A2>(
869
830
  that: Stream<R1, E1, A1>,
870
831
  s: S,
871
832
  f: (
@@ -874,61 +835,59 @@ export function combineChunks_<R, E, A, R1, E1, A1, S, R2, A2>(
874
835
  r: IO<R1, Maybe<E1>, Conc<A1>>,
875
836
  ) => IO<R2, never, Exit<Maybe<E | E1>, readonly [Conc<A2>, S]>>,
876
837
  __tsplusTrace?: string,
877
- ): Stream<R1 | R | R2, E | E1, A2> {
878
- return new Stream(
879
- Channel.unwrapScoped(
880
- Do((Δ) => {
881
- const left = Δ(Handoff<Take<E, A>>());
882
- const right = Δ(Handoff<Take<E1, A1>>());
883
- const latchL = Δ(Handoff<void>());
884
- const latchR = Δ(Handoff<void>());
885
- Δ(stream.channel.pipeTo(combineChunksProducer(left, latchL)).runScoped.fork);
886
- Δ(that.channel.pipeTo(combineChunksProducer(right, latchR)).runScoped.fork);
887
- return tuple(left, right, latchL, latchR);
888
- }).map(([left, right, latchL, latchR]) => {
889
- const pullLeft = latchL
890
- .offer(undefined)
891
- .apSecond(left.take)
892
- .flatMap((take) => take.done);
893
- const pullRight = latchR
894
- .offer(undefined)
895
- .apSecond(right.take)
896
- .flatMap((take) => take.done);
897
- return Stream.unfoldChunkIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExit(exit).optional))
898
- .channel;
899
- }),
900
- ),
901
- );
838
+ ) {
839
+ return (stream: Stream<R, E, A>): Stream<R1 | R | R2, E | E1, A2> => {
840
+ return new Stream(
841
+ Channel.unwrapScoped(
842
+ Do((Δ) => {
843
+ const left = Δ(Handoff<Take<E, A>>());
844
+ const right = Δ(Handoff<Take<E1, A1>>());
845
+ const latchL = Δ(Handoff<void>());
846
+ const latchR = Δ(Handoff<void>());
847
+ Δ(stream.channel.pipeTo(combineChunksProducer(left, latchL)).runScoped.fork);
848
+ Δ(that.channel.pipeTo(combineChunksProducer(right, latchR)).runScoped.fork);
849
+ return tuple(left, right, latchL, latchR);
850
+ }).map(([left, right, latchL, latchR]) => {
851
+ const pullLeft = latchL
852
+ .offer(undefined)
853
+ .apSecond(left.take)
854
+ .flatMap((take) => take.done);
855
+ const pullRight = latchR
856
+ .offer(undefined)
857
+ .apSecond(right.take)
858
+ .flatMap((take) => take.done);
859
+ return Stream.unfoldChunkIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExit(exit).optional))
860
+ .channel;
861
+ }),
862
+ ),
863
+ );
864
+ };
902
865
  }
903
866
 
904
867
  /**
905
868
  * Concatenates the specified stream with this stream, resulting in a stream
906
869
  * that emits the elements from this stream and then the elements from the specified stream.
907
870
  *
908
- * @tsplus fluent fncts.io.Stream concat
871
+ * @tsplus pipeable fncts.io.Stream concat
909
872
  */
910
- export function concat_<R, R1, E, E1, A, A1>(
911
- stream: Stream<R, E, A>,
912
- that: Stream<R1, E1, A1>,
913
- __tsplusTrace?: string,
914
- ): Stream<R | R1, E | E1, A | A1> {
915
- return new Stream<R | R1, E | E1, A | A1>(stream.channel.apSecond(that.channel));
873
+ export function concat<R1, E1, A1>(that: Stream<R1, E1, A1>, __tsplusTrace?: string) {
874
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A | A1> => {
875
+ return new Stream<R | R1, E | E1, A | A1>(stream.channel.apSecond(that.channel));
876
+ };
916
877
  }
917
878
 
918
879
  /**
919
880
  * Composes this stream with the specified stream to create a cartesian product of elements.
920
881
  * The `that` stream would be run multiple times, for every element in the `this` stream.
921
882
  *
922
- * @tsplus fluent fncts.io.Stream cross
883
+ * @tsplus pipeable fncts.io.Stream cross
923
884
  */
924
- export function cross_<R, E, A, R1, E1, B>(
925
- stream: Stream<R, E, A>,
926
- that: Stream<R1, E1, B>,
927
- __tsplusTrace?: string,
928
- ): Stream<R | R1, E | E1, readonly [A, B]> {
929
- return new Stream(
930
- stream.channel.concatMap((as) => that.channel.mapOut((bs) => as.flatMap((a) => bs.map((b) => tuple(a, b))))),
931
- );
885
+ export function cross<R1, E1, B>(that: Stream<R1, E1, B>, __tsplusTrace?: string) {
886
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, readonly [A, B]> => {
887
+ return new Stream(
888
+ stream.channel.concatMap((as) => that.channel.mapOut((bs) => as.flatMap((a) => bs.map((b) => tuple(a, b))))),
889
+ );
890
+ };
932
891
  }
933
892
 
934
893
  /**
@@ -936,107 +895,99 @@ export function cross_<R, E, A, R1, E1, B>(
936
895
  * with a specified function.
937
896
  * The `fb` stream would be run multiple times, for every element in the `fa` stream.
938
897
  *
939
- * @tsplus fluent fncts.io.Stream crossWith
898
+ * @tsplus pipeable fncts.io.Stream crossWith
940
899
  */
941
- export function crossWith_<R, E, A, R1, E1, B, C>(
942
- fa: Stream<R, E, A>,
943
- fb: Stream<R1, E1, B>,
944
- f: (a: A, b: B) => C,
945
- __tsplusTrace?: string,
946
- ): Stream<R | R1, E | E1, C> {
947
- return fa.flatMap((a) => fb.map((b) => f(a, b)));
900
+ export function crossWith<A, R1, E1, B, C>(fb: Stream<R1, E1, B>, f: (a: A, b: B) => C, __tsplusTrace?: string) {
901
+ return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, C> => {
902
+ return fa.flatMap((a) => fb.map((b) => f(a, b)));
903
+ };
948
904
  }
949
905
 
950
906
  /**
951
907
  * Provides some of the environment required to run this effect,
952
908
  * leaving the remainder `R0`.
953
909
  *
954
- * @tsplus fluent fncts.io.Stream contramapEnvironment
910
+ * @tsplus pipeable fncts.io.Stream contramapEnvironment
955
911
  */
956
- export function contramapEnvironment_<R, E, A, R0>(
957
- ra: Stream<R, E, A>,
958
- f: (r0: Environment<R0>) => Environment<R>,
959
- __tsplusTrace?: string,
960
- ): Stream<R0, E, A> {
961
- return Stream.environment<R0>().flatMap((r0) => ra.provideEnvironment(f(r0)));
912
+ export function contramapEnvironment<R, R0>(f: (r0: Environment<R0>) => Environment<R>, __tsplusTrace?: string) {
913
+ return <E, A>(ra: Stream<R, E, A>): Stream<R0, E, A> => {
914
+ return Stream.environment<R0>().flatMap((r0) => ra.provideEnvironment(f(r0)));
915
+ };
962
916
  }
963
917
 
964
918
  /**
965
- * @tsplus fluent fncts.io.Stream debounce
919
+ * @tsplus pipeable fncts.io.Stream debounce
966
920
  */
967
- export function debounce_<R, E, A>(
968
- stream: Stream<R, E, A>,
969
- duration: Lazy<Duration>,
970
- __tsplusTrace?: string,
971
- ): Stream<R, E, A> {
972
- return Stream.unwrap(
973
- IO.transplant((grafter) =>
974
- Do((Δ) => {
975
- const handoff = Δ(Handoff<HandoffSignal<E, A>>());
976
- function enqueue(last: Conc<A>, __tsplusTrace?: string) {
977
- return grafter(Clock.sleep(duration).as(last).fork).map((f) => consumer(DebounceState.Previous(f)));
978
- }
979
- const producer: Channel<R, E, Conc<A>, unknown, E, never, unknown> = Channel.readWithCause(
980
- (inp: Conc<A>) =>
981
- inp.last.match(
982
- () => producer,
983
- (last) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(Conc.single(last)))).apSecond(producer),
984
- ),
985
- (cause: Cause<E>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
986
- () => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
987
- );
988
- function consumer(
989
- state: DebounceState<E, A>,
990
- __tsplusTrace?: string,
991
- ): Channel<R, unknown, unknown, unknown, E, Conc<A>, unknown> {
992
- return Channel.unwrap(
993
- state.match({
994
- NotStarted: () =>
995
- handoff.take.map((signal) =>
996
- signal.match({
997
- Emit: ({ els }) => Channel.unwrap(enqueue(els)),
998
- Halt: ({ error }) => Channel.failCauseNow(error),
999
- End: () => Channel.unit,
1000
- }),
1001
- ),
1002
- Current: ({ fiber }) =>
1003
- fiber.join.map((signal) =>
1004
- signal.match({
1005
- Emit: ({ els }) => Channel.unwrap(enqueue(els)),
1006
- Halt: ({ error }) => Channel.failCauseNow(error),
1007
- End: () => Channel.unit,
1008
- }),
1009
- ),
1010
- Previous: ({ fiber }) =>
1011
- fiber.join.raceWith(
1012
- handoff.take,
1013
- (ex, current) =>
1014
- ex.match(
1015
- (cause) => current.interrupt.as(Channel.failCauseNow(cause)),
1016
- (chunk) =>
1017
- IO.succeedNow(Channel.writeNow(chunk).apSecond(consumer(DebounceState.Current(current)))),
1018
- ),
1019
- (ex, previous) =>
1020
- ex.match(
1021
- (cause) => previous.interrupt.as(Channel.failCauseNow(cause)),
1022
- (signal) =>
1023
- signal.match({
1024
- Emit: ({ els }) => previous.interrupt.apSecond(enqueue(els)),
1025
- Halt: ({ error }) => previous.interrupt.as(Channel.failCauseNow(error)),
1026
- End: () => previous.join.map((chunk) => Channel.writeNow(chunk).apSecond(Channel.unit)),
1027
- }),
1028
- ),
1029
- ),
1030
- }),
921
+ export function debounce(duration: Lazy<Duration>, __tsplusTrace?: string) {
922
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
923
+ return Stream.unwrap(
924
+ IO.transplant((grafter) =>
925
+ Do((Δ) => {
926
+ const handoff = Δ(Handoff<HandoffSignal<E, A>>());
927
+ function enqueue(last: Conc<A>, __tsplusTrace?: string) {
928
+ return grafter(Clock.sleep(duration).as(last).fork).map((f) => consumer(DebounceState.Previous(f)));
929
+ }
930
+ const producer: Channel<R, E, Conc<A>, unknown, E, never, unknown> = Channel.readWithCause(
931
+ (inp: Conc<A>) =>
932
+ inp.last.match(
933
+ () => producer,
934
+ (last) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(Conc.single(last)))).apSecond(producer),
935
+ ),
936
+ (cause: Cause<E>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
937
+ () => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
1031
938
  );
1032
- }
1033
-
1034
- return Stream.scoped(stream.channel.pipeTo(producer).runScoped.fork).apSecond(
1035
- new Stream(consumer(DebounceState.NotStarted)),
1036
- );
1037
- }),
1038
- ),
1039
- );
939
+ function consumer(
940
+ state: DebounceState<E, A>,
941
+ __tsplusTrace?: string,
942
+ ): Channel<R, unknown, unknown, unknown, E, Conc<A>, unknown> {
943
+ return Channel.unwrap(
944
+ state.match({
945
+ NotStarted: () =>
946
+ handoff.take.map((signal) =>
947
+ signal.match({
948
+ Emit: ({ els }) => Channel.unwrap(enqueue(els)),
949
+ Halt: ({ error }) => Channel.failCauseNow(error),
950
+ End: () => Channel.unit,
951
+ }),
952
+ ),
953
+ Current: ({ fiber }) =>
954
+ fiber.join.map((signal) =>
955
+ signal.match({
956
+ Emit: ({ els }) => Channel.unwrap(enqueue(els)),
957
+ Halt: ({ error }) => Channel.failCauseNow(error),
958
+ End: () => Channel.unit,
959
+ }),
960
+ ),
961
+ Previous: ({ fiber }) =>
962
+ fiber.join.raceWith(
963
+ handoff.take,
964
+ (ex, current) =>
965
+ ex.match(
966
+ (cause) => current.interrupt.as(Channel.failCauseNow(cause)),
967
+ (chunk) =>
968
+ IO.succeedNow(Channel.writeNow(chunk).apSecond(consumer(DebounceState.Current(current)))),
969
+ ),
970
+ (ex, previous) =>
971
+ ex.match(
972
+ (cause) => previous.interrupt.as(Channel.failCauseNow(cause)),
973
+ (signal) =>
974
+ signal.match({
975
+ Emit: ({ els }) => previous.interrupt.apSecond(enqueue(els)),
976
+ Halt: ({ error }) => previous.interrupt.as(Channel.failCauseNow(error)),
977
+ End: () => previous.join.map((chunk) => Channel.writeNow(chunk).apSecond(Channel.unit)),
978
+ }),
979
+ ),
980
+ ),
981
+ }),
982
+ );
983
+ }
984
+ return Stream.scoped(stream.channel.pipeTo(producer).runScoped.fork).apSecond(
985
+ new Stream(consumer(DebounceState.NotStarted)),
986
+ );
987
+ }),
988
+ ),
989
+ );
990
+ };
1040
991
  }
1041
992
 
1042
993
  function defaultIfEmptyWriter<R, E, A, R1, E1, B>(
@@ -1054,14 +1005,12 @@ function defaultIfEmptyWriter<R, E, A, R1, E1, B>(
1054
1005
  /**
1055
1006
  * Switches to the provided stream in case this one is empty.
1056
1007
  *
1057
- * @tsplus fluent fncts.io.Stream defaultIfEmpty
1008
+ * @tsplus pipeable fncts.io.Stream defaultIfEmpty
1058
1009
  */
1059
- export function defaultIfEmpty_<R, E, A, R1, E1, B>(
1060
- fa: Stream<R, E, A>,
1061
- fb: Stream<R1, E1, B>,
1062
- __tsplusTrace?: string,
1063
- ): Stream<R | R1, E | E1, A | B> {
1064
- return new Stream(fa.channel.pipeTo(defaultIfEmptyWriter(fb)));
1010
+ export function defaultIfEmpty<R1, E1, B>(fb: Stream<R1, E1, B>, __tsplusTrace?: string) {
1011
+ return <R, E, A>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, A | B> => {
1012
+ return new Stream(fa.channel.pipeTo(defaultIfEmptyWriter(fb)));
1013
+ };
1065
1014
  }
1066
1015
 
1067
1016
  /**
@@ -1069,34 +1018,35 @@ export function defaultIfEmpty_<R, E, A, R1, E1, B>(
1069
1018
  * queues should receive which elements. The decide function will receive the indices of the queues
1070
1019
  * in the resulting list.
1071
1020
  *
1072
- * @tsplus fluent fncts.io.Stream distributedWith
1021
+ * @tsplus pipeable fncts.io.Stream distributedWith
1073
1022
  */
1074
- export function distributedWith_<R, E, A>(
1075
- self: Stream<R, E, A>,
1023
+ export function distributedWith<A>(
1076
1024
  n: number,
1077
1025
  maximumLag: number,
1078
1026
  decide: (_: A) => UIO<(_: number) => boolean>,
1079
1027
  __tsplusTrace?: string,
1080
- ): IO<R | Scope, never, Conc<Queue.Dequeue<Exit<Maybe<E>, A>>>> {
1081
- return Future.make<never, (a: A) => UIO<(_: symbol) => boolean>>().flatMap((p) =>
1082
- self
1083
- .distributedWithDynamic(
1084
- maximumLag,
1085
- (a) => p.await.flatMap((f) => f(a)),
1086
- () => IO.unit,
1087
- )
1088
- .flatMap((next) =>
1089
- IO.sequenceIterable(
1090
- Conc.range(0, n).map((id) => next.map(([key, queue]) => [[key, id], queue] as const)),
1091
- ).flatMap((entries) => {
1092
- const [mappings, queues] = entries.foldRight(
1093
- [HashMap.makeDefault<symbol, number>(), Conc.empty<Queue.Dequeue<Exit<Maybe<E>, A>>>()] as const,
1094
- ([mapping, queue], [mappings, queues]) => [mappings.set(mapping[0], mapping[1]), queues.append(queue)],
1095
- );
1096
- return p.succeed((a) => decide(a).map((f) => (key: symbol) => f(mappings.get(key).value!))).as(queues);
1097
- }),
1098
- ),
1099
- );
1028
+ ) {
1029
+ return <R, E>(self: Stream<R, E, A>): IO<R | Scope, never, Conc<Dequeue<Exit<Maybe<E>, A>>>> => {
1030
+ return Future.make<never, (a: A) => UIO<(_: symbol) => boolean>>().flatMap((p) =>
1031
+ self
1032
+ .distributedWithDynamic(
1033
+ maximumLag,
1034
+ (a) => p.await.flatMap((f) => f(a)),
1035
+ () => IO.unit,
1036
+ )
1037
+ .flatMap((next) =>
1038
+ IO.sequenceIterable(
1039
+ Conc.range(0, n).map((id) => next.map(([key, queue]) => [[key, id], queue] as const)),
1040
+ ).flatMap((entries) => {
1041
+ const [mappings, queues] = entries.foldRight(
1042
+ [HashMap.makeDefault<symbol, number>(), Conc.empty<Dequeue<Exit<Maybe<E>, A>>>()] as const,
1043
+ ([mapping, queue], [mappings, queues]) => [mappings.set(mapping[0], mapping[1]), queues.append(queue)],
1044
+ );
1045
+ return p.succeed((a) => decide(a).map((f) => (key: symbol) => f(mappings.get(key).value!))).as(queues);
1046
+ }),
1047
+ ),
1048
+ );
1049
+ };
1100
1050
  }
1101
1051
 
1102
1052
  /**
@@ -1107,93 +1057,89 @@ export function distributedWith_<R, E, A>(
1107
1057
  * Downstream users can also shutdown queues manually. In this case the driver will
1108
1058
  * continue but no longer backpressure on them.
1109
1059
  *
1110
- * @tsplus fluent fncts.io.Stream distributedWithDynamic
1060
+ * @tsplus pipeable fncts.io.Stream distributedWithDynamic
1111
1061
  */
1112
- export function distributedWithDynamic_<R, E, A>(
1113
- self: Stream<R, E, A>,
1062
+ export function distributedWithDynamic<E, A>(
1114
1063
  maximumLag: number,
1115
1064
  decide: (a: A) => UIO<(_: symbol) => boolean>,
1116
1065
  done: (exit: Exit<Maybe<E>, never>) => UIO<any> = () => IO.unit,
1117
1066
  __tsplusTrace?: string,
1118
- ): IO<R | Scope, never, UIO<readonly [symbol, Queue.Dequeue<Exit<Maybe<E>, A>>]>> {
1119
- const offer = (queuesRef: Ref<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>) => (a: A) =>
1120
- Do((Δ) => {
1121
- const shouldProcess = Δ(decide(a));
1122
- const queues = Δ(queuesRef.get);
1123
- return Δ(
1124
- IO.foldLeft(queues, Conc.empty<symbol>(), (b, [id, queue]) => {
1125
- if (shouldProcess(id)) {
1126
- return queue.offer(Exit.succeed(a)).matchCauseIO(
1127
- (c) => (c.interrupted ? IO.succeedNow(b.append(id)) : IO.failCauseNow(c)),
1128
- () => IO.succeedNow(b),
1129
- );
1130
- } else {
1131
- return IO.succeedNow(b);
1132
- }
1133
- }).flatMap((ids) => (ids.isNonEmpty ? queuesRef.update((map) => map.removeMany(ids)) : IO.unit)),
1134
- );
1135
- });
1136
-
1137
- return Do((Δ) => {
1138
- const queuesRef = Δ(
1139
- IO.acquireRelease(Ref.make<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>(HashMap.makeDefault()), (ref) =>
1140
- ref.get.flatMap((qs) => IO.foreach(qs.values, (q) => q.shutdown)),
1141
- ),
1142
- );
1143
-
1144
- const add = Δ(
1067
+ ) {
1068
+ return <R>(self: Stream<R, E, A>): IO<R | Scope, never, UIO<readonly [symbol, Dequeue<Exit<Maybe<E>, A>>]>> => {
1069
+ const offer = (queuesRef: Ref<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>) => (a: A) =>
1145
1070
  Do((Δ) => {
1146
- const queuesLock = Δ(TSemaphore.make(1).commit);
1147
- const newQueue = Δ(
1148
- Ref.make<UIO<readonly [symbol, Queue<Exit<Maybe<E>, A>>]>>(
1149
- Do((Δ) => {
1150
- const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(maximumLag));
1151
- const id = Δ(IO.succeed(Symbol()));
1152
- Δ(queuesRef.update((map) => map.set(id, queue)));
1153
- return tuple(id, queue);
1154
- }),
1155
- ),
1071
+ const shouldProcess = Δ(decide(a));
1072
+ const queues = Δ(queuesRef.get);
1073
+ return Δ(
1074
+ IO.foldLeft(queues, Conc.empty<symbol>(), (b, [id, queue]) => {
1075
+ if (shouldProcess(id)) {
1076
+ return queue.offer(Exit.succeed(a)).matchCauseIO(
1077
+ (c) => (c.interrupted ? IO.succeedNow(b.append(id)) : IO.failCauseNow(c)),
1078
+ () => IO.succeedNow(b),
1079
+ );
1080
+ } else {
1081
+ return IO.succeedNow(b);
1082
+ }
1083
+ }).flatMap((ids) => (ids.isNonEmpty ? queuesRef.update((map) => map.removeMany(ids)) : IO.unit)),
1156
1084
  );
1157
- const finalize = (endTake: Exit<Maybe<E>, never>): UIO<void> =>
1158
- queuesLock.withPermit(
1159
- newQueue
1160
- .set(
1161
- Do((Δ) => {
1162
- const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(1));
1163
- Δ(queue.offer(endTake));
1164
- const id = Symbol();
1165
- Δ(queuesRef.update((map) => map.set(id, queue)));
1166
- return tuple(id, queue);
1167
- }),
1168
- )
1169
- .flatMap(() =>
1170
- Do((Δ) => {
1171
- const queues = Δ(queuesRef.get.map((map) => map.values));
1172
- Δ(
1173
- IO.foreach(queues, (queue) =>
1174
- queue
1175
- .offer(endTake)
1176
- .catchJustCause((c) => (c.interrupted ? Just(IO.unit) : Nothing<UIO<void>>())),
1177
- ),
1178
- );
1179
- Δ(done(endTake));
1180
- }),
1181
- ).asUnit,
1085
+ });
1086
+ return Do((Δ) => {
1087
+ const queuesRef = Δ(
1088
+ IO.acquireRelease(Ref.make<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>(HashMap.makeDefault()), (ref) =>
1089
+ ref.get.flatMap((qs) => IO.foreach(qs.values, (q) => q.shutdown)),
1090
+ ),
1091
+ );
1092
+ const add = Δ(
1093
+ Do((Δ) => {
1094
+ const queuesLock = Δ(TSemaphore.make(1).commit);
1095
+ const newQueue = Δ(
1096
+ Ref.make<UIO<readonly [symbol, Queue<Exit<Maybe<E>, A>>]>>(
1097
+ Do((Δ) => {
1098
+ const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(maximumLag));
1099
+ const id = Δ(IO.succeed(Symbol()));
1100
+ Δ(queuesRef.update((map) => map.set(id, queue)));
1101
+ return tuple(id, queue);
1102
+ }),
1103
+ ),
1182
1104
  );
1183
-
1184
- Δ(
1185
- self.runForeachScoped(offer(queuesRef)).matchCauseIO(
1186
- (cause) => finalize(Exit.failCause(cause.map(Maybe.just))),
1187
- () => finalize(Exit.fail(Nothing())),
1188
- ).fork,
1189
- );
1190
-
1191
- return queuesLock.withPermit(newQueue.get.flatten);
1192
- }),
1193
- );
1194
-
1195
- return add;
1196
- });
1105
+ const finalize = (endTake: Exit<Maybe<E>, never>): UIO<void> =>
1106
+ queuesLock.withPermit(
1107
+ newQueue
1108
+ .set(
1109
+ Do() => {
1110
+ const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(1));
1111
+ Δ(queue.offer(endTake));
1112
+ const id = Symbol();
1113
+ Δ(queuesRef.update((map) => map.set(id, queue)));
1114
+ return tuple(id, queue);
1115
+ }),
1116
+ )
1117
+ .flatMap(() =>
1118
+ Do((Δ) => {
1119
+ const queues = Δ(queuesRef.get.map((map) => map.values));
1120
+ Δ(
1121
+ IO.foreach(queues, (queue) =>
1122
+ queue
1123
+ .offer(endTake)
1124
+ .catchJustCause((c) => (c.interrupted ? Just(IO.unit) : Nothing<UIO<void>>())),
1125
+ ),
1126
+ );
1127
+ Δ(done(endTake));
1128
+ }),
1129
+ ).asUnit,
1130
+ );
1131
+ Δ(
1132
+ self.runForeachScoped(offer(queuesRef)).matchCauseIO(
1133
+ (cause) => finalize(Exit.failCause(cause.map(Maybe.just))),
1134
+ () => finalize(Exit.fail(Nothing())),
1135
+ ).fork,
1136
+ );
1137
+ return queuesLock.withPermit(newQueue.get.flatten);
1138
+ }),
1139
+ );
1140
+ return add;
1141
+ });
1142
+ };
1197
1143
  }
1198
1144
 
1199
1145
  /**
@@ -1222,30 +1168,36 @@ function dropLoop<R, E, A>(r: number, __tsplusTrace?: string): Channel<R, E, Con
1222
1168
  /**
1223
1169
  * Drops the specified number of elements from this stream.
1224
1170
  *
1225
- * @tsplus fluent fncts.io.Stream drop
1171
+ * @tsplus pipeable fncts.io.Stream drop
1226
1172
  */
1227
- export function drop_<R, E, A>(stream: Stream<R, E, A>, n: number, __tsplusTrace?: string): Stream<R, E, A> {
1228
- return new Stream(stream.channel.pipeTo(dropLoop(n)));
1173
+ export function drop(n: number, __tsplusTrace?: string) {
1174
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
1175
+ return new Stream(stream.channel.pipeTo(dropLoop(n)));
1176
+ };
1229
1177
  }
1230
1178
 
1231
1179
  /**
1232
1180
  * Drops all elements of the stream for as long as the specified predicate
1233
1181
  * evaluates to `true`.
1234
1182
  *
1235
- * @tsplus fluent fncts.io.Stream dropWhile
1183
+ * @tsplus pipeable fncts.io.Stream dropWhile
1236
1184
  */
1237
- export function dropWhile_<R, E, A>(stream: Stream<R, E, A>, p: Predicate<A>, __tsplusTrace?: string): Stream<R, E, A> {
1238
- return stream.pipeThrough(Sink.dropWhile(p));
1185
+ export function dropWhile<A>(p: Predicate<A>, __tsplusTrace?: string) {
1186
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
1187
+ return stream.pipeThrough(Sink.dropWhile(p));
1188
+ };
1239
1189
  }
1240
1190
 
1241
1191
  /**
1242
1192
  * Drops all elements of the stream until the specified predicate evaluates
1243
1193
  * to `true`.
1244
1194
  *
1245
- * @tsplus fluent fncts.io.Stream dropUntil
1195
+ * @tsplus pipeable fncts.io.Stream dropUntil
1246
1196
  */
1247
- export function dropUntil_<R, E, A>(stream: Stream<R, E, A>, p: Predicate<A>, __tsplusTrace?: string): Stream<R, E, A> {
1248
- return stream.dropWhile(p.invert).drop(1);
1197
+ export function dropUntil<A>(p: Predicate<A>, __tsplusTrace?: string) {
1198
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
1199
+ return stream.dropWhile(p.invert).drop(1);
1200
+ };
1249
1201
  }
1250
1202
 
1251
1203
  /**
@@ -1294,25 +1246,21 @@ function endWhenWriter<E, A, E1>(
1294
1246
  *
1295
1247
  * If the IO completes with a failure, the stream will emit that failure.
1296
1248
  *
1297
- * @tsplus fluent fncts.io.Stream endWhen
1249
+ * @tsplus pipeable fncts.io.Stream endWhen
1298
1250
  */
1299
- export function endWhen_<R, E, A, R1, E1>(
1300
- stream: Stream<R, E, A>,
1301
- io: IO<R1, E1, any>,
1302
- __tsplusTrace?: string,
1303
- ): Stream<R | R1, E | E1, A> {
1304
- return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => stream.channel.pipeTo(endWhenWriter(fiber)))));
1251
+ export function endWhen<R1, E1>(io: IO<R1, E1, any>, __tsplusTrace?: string) {
1252
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
1253
+ return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => stream.channel.pipeTo(endWhenWriter(fiber)))));
1254
+ };
1305
1255
  }
1306
1256
 
1307
1257
  /**
1308
- * @tsplus fluent fncts.io.Stream ensuring
1258
+ * @tsplus pipeable fncts.io.Stream ensuring
1309
1259
  */
1310
- export function ensuring_<R, E, A, R1>(
1311
- self: Stream<R, E, A>,
1312
- finalizer: IO<R1, never, any>,
1313
- __tsplusTrace?: string,
1314
- ): Stream<R | R1, E, A> {
1315
- return new Stream(self.channel.ensuring(finalizer));
1260
+ export function ensuring<R1>(finalizer: IO<R1, never, any>, __tsplusTrace?: string) {
1261
+ return <R, E, A>(self: Stream<R, E, A>): Stream<R | R1, E, A> => {
1262
+ return new Stream(self.channel.ensuring(finalizer));
1263
+ };
1316
1264
  }
1317
1265
 
1318
1266
  /**
@@ -1392,27 +1340,23 @@ export function failCause<E>(cause: Lazy<Cause<E>>, __tsplusTrace?: string): Str
1392
1340
  }
1393
1341
 
1394
1342
  /**
1395
- * @tsplus fluent fncts.io.Stream filter
1343
+ * @tsplus pipeable fncts.io.Stream filter
1396
1344
  */
1397
- export function filter_<R, E, A, B extends A>(fa: Stream<R, E, A>, refinement: Refinement<A, B>): Stream<R, E, B>;
1398
- export function filter_<R, E, A>(fa: Stream<R, E, A>, predicate: Predicate<A>): Stream<R, E, A>;
1399
- export function filter_<R, E, A>(
1400
- fa: Stream<R, E, A>,
1401
- predicate: Predicate<A>,
1402
- __tsplusTrace?: string,
1403
- ): Stream<R, E, A> {
1404
- return fa.mapChunks((chunk) => chunk.filter(predicate));
1345
+ export function filter<A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Stream<R, E, A>) => Stream<R, E, B>;
1346
+ export function filter<A>(predicate: Predicate<A>): <R, E>(fa: Stream<R, E, A>) => Stream<R, E, A>;
1347
+ export function filter<A>(predicate: Predicate<A>, __tsplusTrace?: string) {
1348
+ return <R, E>(fa: Stream<R, E, A>): Stream<R, E, A> => {
1349
+ return fa.mapChunks((chunk) => chunk.filter(predicate));
1350
+ };
1405
1351
  }
1406
1352
 
1407
1353
  /**
1408
- * @tsplus fluent fncts.io.Stream filterIO
1354
+ * @tsplus pipeable fncts.io.Stream filterIO
1409
1355
  */
1410
- export function filterIO_<R, E, A, R1, E1>(
1411
- fa: Stream<R, E, A>,
1412
- f: (a: A) => IO<R1, E1, boolean>,
1413
- __tsplusTrace?: string,
1414
- ): Stream<R | R1, E | E1, A> {
1415
- return new Stream(fa.channel.pipeTo(filterIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
1356
+ export function filterIO<A, R1, E1>(f: (a: A) => IO<R1, E1, boolean>, __tsplusTrace?: string) {
1357
+ return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
1358
+ return new Stream(fa.channel.pipeTo(filterIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
1359
+ };
1416
1360
  }
1417
1361
 
1418
1362
  function filterIOLoop<R, E, A, R1, E1>(
@@ -1439,25 +1383,23 @@ function filterIOLoop<R, E, A, R1, E1>(
1439
1383
  }
1440
1384
 
1441
1385
  /**
1442
- * @tsplus fluent fncts.io.Stream filterMap
1386
+ * @tsplus pipeable fncts.io.Stream filterMap
1443
1387
  */
1444
- export function filterMap_<R, E, A, B>(
1445
- fa: Stream<R, E, A>,
1446
- f: (a: A) => Maybe<B>,
1447
- __tsplusTrace?: string,
1448
- ): Stream<R, E, B> {
1449
- return fa.mapChunks((chunk) => chunk.filterMap(f));
1388
+ export function filterMap<A, B>(f: (a: A) => Maybe<B>, __tsplusTrace?: string) {
1389
+ return <R, E>(fa: Stream<R, E, A>): Stream<R, E, B> => {
1390
+ return fa.mapChunks((chunk) => chunk.filterMap(f));
1391
+ };
1450
1392
  }
1451
1393
 
1452
1394
  /**
1453
- * @tsplus fluent fncts.io.Stream filterMapIO
1395
+ * @tsplus pipeable fncts.io.Stream filterMapIO
1454
1396
  */
1455
- export function filterMapIO_<R, E, A, R1, E1, B>(
1456
- fa: Stream<R, E, A>,
1457
- f: (a: A) => IO<R1, E1, Maybe<B>>,
1458
- __tsplusTrace?: string,
1459
- ): Stream<R | R1, E | E1, B> {
1460
- return new Stream(fa.channel.pipeTo(filterMapIOLoop<R, E, A, R1, E1, B>(Iterable.empty<A>()[Symbol.iterator](), f)));
1397
+ export function filterMapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Maybe<B>>, __tsplusTrace?: string) {
1398
+ return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
1399
+ return new Stream(
1400
+ fa.channel.pipeTo(filterMapIOLoop<R, E, A, R1, E1, B>(Iterable.empty<A>()[Symbol.iterator](), f)),
1401
+ );
1402
+ };
1461
1403
  }
1462
1404
 
1463
1405
  function filterMapIOLoop<R, E, A, R1, E1, B>(
@@ -1487,45 +1429,45 @@ function filterMapIOLoop<R, E, A, R1, E1, B>(
1487
1429
  /**
1488
1430
  * Finds the first element emitted by this stream that satisfies the provided predicate.
1489
1431
  *
1490
- * @tsplus fluent fncts.io.Stream find
1432
+ * @tsplus pipeable fncts.io.Stream find
1491
1433
  */
1492
- export function find_<R, E, A>(stream: Stream<R, E, A>, p: Predicate<A>, __tsplusTrace?: string): Stream<R, E, A> {
1493
- const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A>, unknown> = Channel.readWith(
1494
- (inp: Conc<A>) =>
1495
- inp.find(p).match(
1496
- () => loop,
1497
- (a) => Channel.writeNow(Conc.single(a)),
1498
- ),
1499
- Channel.failNow,
1500
- () => Channel.unit,
1501
- );
1502
- return new Stream(stream.channel.pipeTo(loop));
1434
+ export function find<A>(p: Predicate<A>, __tsplusTrace?: string) {
1435
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
1436
+ const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A>, unknown> = Channel.readWith(
1437
+ (inp: Conc<A>) =>
1438
+ inp.find(p).match(
1439
+ () => loop,
1440
+ (a) => Channel.writeNow(Conc.single(a)),
1441
+ ),
1442
+ Channel.failNow,
1443
+ () => Channel.unit,
1444
+ );
1445
+ return new Stream(stream.channel.pipeTo(loop));
1446
+ };
1503
1447
  }
1504
1448
 
1505
1449
  /**
1506
1450
  * Finds the first element emitted by this stream that satisfies the provided effectful predicate.
1507
1451
  *
1508
- * @tsplus fluent fncts.io.Stream findIO
1452
+ * @tsplus pipeable fncts.io.Stream findIO
1509
1453
  */
1510
- export function findIO_<R, E, A, R1, E1>(
1511
- stream: Stream<R, E, A>,
1512
- f: (a: A) => IO<R1, E1, boolean>,
1513
- __tsplusTrace?: string,
1514
- ): Stream<R | R1, E | E1, A> {
1515
- const loop: Channel<R | R1, E, Conc<A>, unknown, E | E1, Conc<A>, unknown> = Channel.readWith(
1516
- (inp: Conc<A>) =>
1517
- Channel.unwrap(
1518
- inp.findIO(f).map((maybeA) =>
1519
- maybeA.match(
1520
- () => loop,
1521
- (a) => Channel.writeNow(Conc.single(a)),
1454
+ export function findIO<A, R1, E1>(f: (a: A) => IO<R1, E1, boolean>, __tsplusTrace?: string) {
1455
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
1456
+ const loop: Channel<R | R1, E, Conc<A>, unknown, E | E1, Conc<A>, unknown> = Channel.readWith(
1457
+ (inp: Conc<A>) =>
1458
+ Channel.unwrap(
1459
+ inp.findIO(f).map((maybeA) =>
1460
+ maybeA.match(
1461
+ () => loop,
1462
+ (a) => Channel.writeNow(Conc.single(a)),
1463
+ ),
1522
1464
  ),
1523
1465
  ),
1524
- ),
1525
- Channel.failNow,
1526
- () => Channel.unit,
1527
- );
1528
- return new Stream(stream.channel.pipeTo(loop));
1466
+ Channel.failNow,
1467
+ () => Channel.unit,
1468
+ );
1469
+ return new Stream(stream.channel.pipeTo(loop));
1470
+ };
1529
1471
  }
1530
1472
 
1531
1473
  /**
@@ -1565,16 +1507,13 @@ export function flattenExitOption<R, E, E1, A>(
1565
1507
  () => Channel.endNow<void>(undefined),
1566
1508
  ),
1567
1509
  );
1568
-
1569
1510
  return Channel.writeNow(toEmit.filterMap((exit) => exit.match(() => Nothing(), Maybe.just))).apSecond(next);
1570
1511
  };
1571
-
1572
1512
  const process: Channel<R, E, Conc<Exit<Maybe<E1>, A>>, unknown, E | E1, Conc<A>, any> = Channel.readWithCause(
1573
1513
  (chunk) => processChunk(chunk, process),
1574
1514
  Channel.failCauseNow,
1575
1515
  (_) => Channel.endNow(undefined),
1576
1516
  );
1577
-
1578
1517
  return new Stream(stream.channel.pipeTo(process));
1579
1518
  }
1580
1519
 
@@ -1632,8 +1571,8 @@ export function fromChunk<O>(c: Lazy<Conc<O>>, __tsplusTrace?: string): Stream<n
1632
1571
  *
1633
1572
  * @tsplus static fncts.io.StreamOps scoped
1634
1573
  */
1635
- export function scoped<R, E, A>(stream: IO<R, E, A>, __tsplusTrace?: string): Stream<Exclude<R, Scope>, E, A> {
1636
- return new Stream(Channel.scoped(stream.map(Conc.single)));
1574
+ export function scoped<R, E, A>(stream: Lazy<IO<R, E, A>>, __tsplusTrace?: string): Stream<Exclude<R, Scope>, E, A> {
1575
+ return new Stream(Channel.scoped(stream().map(Conc.single)));
1637
1576
  }
1638
1577
 
1639
1578
  /**
@@ -1758,11 +1697,11 @@ export function fromPull<R, E, A>(
1758
1697
  *
1759
1698
  * @tsplus static fncts.io.StreamOps fromQueue
1760
1699
  */
1761
- export function fromQueue_<R, E, O>(
1762
- queue: PQueue<never, R, unknown, E, never, O>,
1700
+ export function fromQueue<O>(
1701
+ queue: Dequeue<O>,
1763
1702
  maxChunkSize: number = DEFAULT_CHUNK_SIZE,
1764
1703
  __tsplusTrace?: string,
1765
- ): Stream<R, E, O> {
1704
+ ): Stream<never, never, O> {
1766
1705
  return repeatIOChunkMaybe(
1767
1706
  queue
1768
1707
  .takeBetween(1, maxChunkSize)
@@ -1783,13 +1722,35 @@ export function fromQueue_<R, E, O>(
1783
1722
  * @tsplus static fncts.io.StreamOps fromQueueWithShutdown
1784
1723
  */
1785
1724
  export function fromQueueWithShutdown<R, E, A>(
1786
- queue: PQueue<never, R, unknown, E, never, A>,
1725
+ queue: Dequeue<A>,
1787
1726
  maxChunkSize: number = DEFAULT_CHUNK_SIZE,
1788
1727
  __tsplusTrace?: string,
1789
- ): Stream<R, E, A> {
1728
+ ): Stream<never, never, A> {
1790
1729
  return Stream.fromQueue(queue, maxChunkSize).ensuring(queue.shutdown);
1791
1730
  }
1792
1731
 
1732
+ /**
1733
+ * @tsplus static fncts.io.StreamOps fromHub
1734
+ */
1735
+ export function fromHub<A>(
1736
+ hub: Lazy<Hub<A>>,
1737
+ maxChunkSize = DEFAULT_CHUNK_SIZE,
1738
+ __tsplusTrace?: string,
1739
+ ): Stream<never, never, A> {
1740
+ return Stream.scoped(hub().subscribe).flatMap((queue) => Stream.fromQueueWithShutdown(queue, maxChunkSize));
1741
+ }
1742
+
1743
+ /**
1744
+ * @tsplus static fncts.io.StreamOps fromHubScoped
1745
+ */
1746
+ export function fromHubScoped<A>(
1747
+ hub: Lazy<Hub<A>>,
1748
+ maxChunkSize = DEFAULT_CHUNK_SIZE,
1749
+ __tsplusTrace?: string,
1750
+ ): IO<Scope, never, Stream<never, never, A>> {
1751
+ return IO.defer(hub().subscribe.map((queue) => Stream.fromQueueWithShutdown(queue, maxChunkSize)));
1752
+ }
1753
+
1793
1754
  /**
1794
1755
  * Halt a stream with the specified exception
1795
1756
  *
@@ -1837,14 +1798,12 @@ function haltWhenWriter<E, A, E1>(
1837
1798
  *
1838
1799
  * If the IO completes with a failure, the stream will emit that failure.
1839
1800
  *
1840
- * @tsplus fluent fncts.io.Stream haltWhen
1801
+ * @tsplus pipeable fncts.io.Stream haltWhen
1841
1802
  */
1842
- export function haltWhen_<R, E, A, R1, E1>(
1843
- fa: Stream<R, E, A>,
1844
- io: IO<R1, E1, any>,
1845
- __tsplusTrace?: string,
1846
- ): Stream<R | R1, E | E1, A> {
1847
- return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => fa.channel.pipeTo(haltWhenWriter(fiber)))));
1803
+ export function haltWhen<R1, E1>(io: IO<R1, E1, any>, __tsplusTrace?: string) {
1804
+ return <R, E, A>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
1805
+ return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => fa.channel.pipeTo(haltWhenWriter(fiber)))));
1806
+ };
1848
1807
  }
1849
1808
 
1850
1809
  function haltWhenFutureWriter<R, E, A, E1>(
@@ -1871,25 +1830,21 @@ function haltWhenFutureWriter<R, E, A, E1>(
1871
1830
  *
1872
1831
  * If the promise completes with a failure, the stream will emit that failure.
1873
1832
  *
1874
- * @tsplus fluent fncts.io.Stream haltWhen
1875
- */
1876
- export function haltWhenFuture_<R, E, A, E1>(
1877
- fa: Stream<R, E, A>,
1878
- future: Future<E1, any>,
1879
- __tsplusTrace?: string,
1880
- ): Stream<R, E | E1, A> {
1881
- return new Stream(fa.channel.pipeTo(haltWhenFutureWriter(future)));
1833
+ * @tsplus pipeable fncts.io.Stream haltWhen
1834
+ */
1835
+ export function haltWhenFuture<E1>(future: Future<E1, any>, __tsplusTrace?: string) {
1836
+ return <R, E, A>(fa: Stream<R, E, A>): Stream<R, E | E1, A> => {
1837
+ return new Stream(fa.channel.pipeTo(haltWhenFutureWriter(future)));
1838
+ };
1882
1839
  }
1883
1840
 
1884
1841
  /**
1885
- * @tsplus fluent fncts.io.Stream interleave
1842
+ * @tsplus pipeable fncts.io.Stream interleave
1886
1843
  */
1887
- export function interleave_<R, E, A, R1, E1, B>(
1888
- sa: Stream<R, E, A>,
1889
- sb: Stream<R1, E1, B>,
1890
- __tsplusTrace?: string,
1891
- ): Stream<R | R1, E | E1, A | B> {
1892
- return sa.interleaveWith(sb, Stream.fromChunk(Conc(true, false)).forever);
1844
+ export function interleave<R1, E1, B>(sb: Stream<R1, E1, B>, __tsplusTrace?: string) {
1845
+ return <R, E, A>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, A | B> => {
1846
+ return sa.interleaveWith(sb, Stream.fromChunk(Conc(true, false)).forever);
1847
+ };
1893
1848
  }
1894
1849
 
1895
1850
  function interleaveWithProducer<E, A>(
@@ -1911,52 +1866,53 @@ function interleaveWithProducer<E, A>(
1911
1866
  * `b`. If either this stream or the specified stream are exhausted further
1912
1867
  * requests for values from that stream will be ignored.
1913
1868
  *
1914
- * @tsplus fluent fncts.io.Stream interleaveWith
1869
+ * @tsplus pipeable fncts.io.Stream interleaveWith
1915
1870
  */
1916
- export function interleaveWith_<R, E, A, R1, E1, B, R2, E2>(
1917
- sa: Stream<R, E, A>,
1871
+ export function interleaveWith<R1, E1, B, R2, E2>(
1918
1872
  sb: Stream<R1, E1, B>,
1919
1873
  b: Stream<R2, E2, boolean>,
1920
1874
  __tsplusTrace?: string,
1921
- ): Stream<R | R1 | R2, E | E1 | E2, A | B> {
1922
- return new Stream(
1923
- Channel.unwrapScoped(
1924
- Do((Δ) => {
1925
- const left = Δ(Handoff<Take<E, A>>());
1926
- const right = Δ(Handoff<Take<E1, B>>());
1927
- Δ(sa.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(left)).runScoped.fork);
1928
- Δ(sb.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(right)).runScoped.fork);
1929
- return tuple(left, right);
1930
- }).map(([left, right]) => {
1931
- const process = (
1932
- leftDone: boolean,
1933
- rightDone: boolean,
1934
- ): Channel<R | R1 | R2, E | E1 | E2, boolean, unknown, E | E1 | E2, Conc<A | B>, void> =>
1935
- Channel.readWithCause(
1936
- (b: boolean) => {
1937
- if (b && !leftDone) {
1938
- return Channel.fromIO(left.take).flatMap((take) =>
1939
- take.match(rightDone ? Channel.unit : process(true, rightDone), Channel.failCauseNow, (chunk) =>
1940
- Channel.writeNow(chunk).apSecond(process(leftDone, rightDone)),
1941
- ),
1942
- );
1943
- }
1944
- if (!b && !rightDone) {
1945
- return Channel.fromIO(right.take).flatMap((take) =>
1946
- take.match(leftDone ? Channel.unit : process(leftDone, true), Channel.failCauseNow, (chunk) =>
1947
- Channel.writeNow(chunk).apSecond(process(leftDone, rightDone)),
1948
- ),
1949
- );
1950
- }
1951
- return process(leftDone, rightDone);
1952
- },
1953
- Channel.failCauseNow,
1954
- () => Channel.unit,
1955
- );
1956
- return b.channel.concatMap(Channel.writeChunk).pipeTo(process(false, false));
1957
- }),
1958
- ),
1959
- );
1875
+ ) {
1876
+ return <R, E, A>(sa: Stream<R, E, A>): Stream<R | R1 | R2, E | E1 | E2, A | B> => {
1877
+ return new Stream(
1878
+ Channel.unwrapScoped(
1879
+ Do((Δ) => {
1880
+ const left = Δ(Handoff<Take<E, A>>());
1881
+ const right = Δ(Handoff<Take<E1, B>>());
1882
+ Δ(sa.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(left)).runScoped.fork);
1883
+ Δ(sb.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(right)).runScoped.fork);
1884
+ return tuple(left, right);
1885
+ }).map(([left, right]) => {
1886
+ const process = (
1887
+ leftDone: boolean,
1888
+ rightDone: boolean,
1889
+ ): Channel<R | R1 | R2, E | E1 | E2, boolean, unknown, E | E1 | E2, Conc<A | B>, void> =>
1890
+ Channel.readWithCause(
1891
+ (b: boolean) => {
1892
+ if (b && !leftDone) {
1893
+ return Channel.fromIO(left.take).flatMap((take) =>
1894
+ take.match(rightDone ? Channel.unit : process(true, rightDone), Channel.failCauseNow, (chunk) =>
1895
+ Channel.writeNow(chunk).apSecond(process(leftDone, rightDone)),
1896
+ ),
1897
+ );
1898
+ }
1899
+ if (!b && !rightDone) {
1900
+ return Channel.fromIO(right.take).flatMap((take) =>
1901
+ take.match(leftDone ? Channel.unit : process(leftDone, true), Channel.failCauseNow, (chunk) =>
1902
+ Channel.writeNow(chunk).apSecond(process(leftDone, rightDone)),
1903
+ ),
1904
+ );
1905
+ }
1906
+ return process(leftDone, rightDone);
1907
+ },
1908
+ Channel.failCauseNow,
1909
+ () => Channel.unit,
1910
+ );
1911
+ return b.channel.concatMap(Channel.writeChunk).pipeTo(process(false, false));
1912
+ }),
1913
+ ),
1914
+ );
1915
+ };
1960
1916
  }
1961
1917
 
1962
1918
  function intersperseWriter<R, E, A, A1>(
@@ -1987,7 +1943,7 @@ function intersperseWriter<R, E, A, A1>(
1987
1943
  /**
1988
1944
  * Intersperse stream with provided element
1989
1945
  */
1990
- export function intersperse_<R, E, A, A1>(
1946
+ export function intersperse<R, E, A, A1>(
1991
1947
  stream: Stream<R, E, A>,
1992
1948
  middle: A1,
1993
1949
  __tsplusTrace?: string,
@@ -2003,34 +1959,32 @@ export function intersperse_<R, E, A, A1>(
2003
1959
  * If the IO completes with a failure before the stream completes, the returned stream
2004
1960
  * will emit that failure.
2005
1961
  *
2006
- * @tsplus fluent fncts.io.Stream interruptWhen
1962
+ * @tsplus pipeable fncts.io.Stream interruptWhen
2007
1963
  */
2008
- export function interruptWhen_<R, E, A, R1, E1>(
2009
- stream: Stream<R, E, A>,
2010
- io: IO<R1, E1, any>,
2011
- __tsplusTrace?: string,
2012
- ): Stream<R | R1, E | E1, A> {
2013
- return new Stream(stream.channel.interruptWhen(io));
1964
+ export function interruptWhen<R1, E1>(io: IO<R1, E1, any>, __tsplusTrace?: string) {
1965
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
1966
+ return new Stream(stream.channel.interruptWhen(io));
1967
+ };
2014
1968
  }
2015
1969
 
2016
1970
  /**
2017
- * @tsplus fluent fncts.io.Stream interruptWhen
1971
+ * @tsplus pipeable fncts.io.Stream interruptWhen
2018
1972
  */
2019
- export function interruptWhenFuture_<R, E, A, E1>(
2020
- fa: Stream<R, E, A>,
2021
- future: Future<E1, unknown>,
2022
- __tsplusTrace?: string,
2023
- ): Stream<R, E | E1, A> {
2024
- return new Stream(fa.channel.interruptWhen(future));
1973
+ export function interruptWhenFuture<E1>(future: Future<E1, unknown>, __tsplusTrace?: string) {
1974
+ return <R, E, A>(fa: Stream<R, E, A>): Stream<R, E | E1, A> => {
1975
+ return new Stream(fa.channel.interruptWhen(future));
1976
+ };
2025
1977
  }
2026
1978
 
2027
1979
  /**
2028
1980
  * Transforms the elements of this stream using the supplied function.
2029
1981
  *
2030
- * @tsplus fluent fncts.io.Stream map
1982
+ * @tsplus pipeable fncts.io.Stream map
2031
1983
  */
2032
- export function map_<R, E, A, B>(stream: Stream<R, E, A>, f: (o: A) => B, __tsplusTrace?: string): Stream<R, E, B> {
2033
- return new Stream(stream.channel.mapOut((as) => as.map(f)));
1984
+ export function map<A, B>(f: (o: A) => B, __tsplusTrace?: string) {
1985
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
1986
+ return new Stream(stream.channel.mapOut((as) => as.map(f)));
1987
+ };
2034
1988
  }
2035
1989
 
2036
1990
  function mapAccumAccumulator<S, E = never, A = never, B = never>(
@@ -2051,15 +2005,12 @@ function mapAccumAccumulator<S, E = never, A = never, B = never>(
2051
2005
  /**
2052
2006
  * Statefully maps over the elements of this stream to produce new elements.
2053
2007
  *
2054
- * @tsplus fluent fncts.io.Stream mapAccum
2008
+ * @tsplus pipeable fncts.io.Stream mapAccum
2055
2009
  */
2056
- export function mapAccum_<R, E, A, S, B>(
2057
- stream: Stream<R, E, A>,
2058
- s: S,
2059
- f: (s: S, a: A) => readonly [S, B],
2060
- __tsplusTrace?: string,
2061
- ): Stream<R, E, B> {
2062
- return new Stream(stream.channel.pipeTo(mapAccumAccumulator(s, f)));
2010
+ export function mapAccum<A, S, B>(s: S, f: (s: S, a: A) => readonly [S, B], __tsplusTrace?: string) {
2011
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
2012
+ return new Stream(stream.channel.pipeTo(mapAccumAccumulator(s, f)));
2013
+ };
2063
2014
  }
2064
2015
 
2065
2016
  function mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(
@@ -2096,136 +2047,119 @@ function mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(
2096
2047
  * Statefully and effectfully maps over the elements of this stream to produce
2097
2048
  * new elements.
2098
2049
  *
2099
- * @tsplus fluent fncts.io.Stream mapAccumIO
2050
+ * @tsplus pipeable fncts.io.Stream mapAccumIO
2100
2051
  */
2101
- export function mapAccumIO_<R, E, A, R1, E1, S, B>(
2102
- stream: Stream<R, E, A>,
2052
+ export function mapAccumIO<A, R1, E1, S, B>(
2103
2053
  s: S,
2104
2054
  f: (s: S, a: A) => IO<R1, E1, readonly [B, S]>,
2105
2055
  __tsplusTrace?: string,
2106
- ): Stream<R | R1, E | E1, B> {
2107
- return new Stream(stream.channel.pipeTo(mapAccumIOAccumulator(s, f)));
2056
+ ) {
2057
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2058
+ return new Stream(stream.channel.pipeTo(mapAccumIOAccumulator(s, f)));
2059
+ };
2108
2060
  }
2109
2061
 
2110
2062
  /**
2111
2063
  * Transforms the chunks emitted by this stream.
2112
2064
  *
2113
- * @tsplus fluent fncts.io.Stream mapChunks
2065
+ * @tsplus pipeable fncts.io.Stream mapChunks
2114
2066
  */
2115
- export function mapChunks_<R, E, A, A1>(
2116
- stream: Stream<R, E, A>,
2117
- f: (chunk: Conc<A>) => Conc<A1>,
2118
- __tsplusTrace?: string,
2119
- ): Stream<R, E, A1> {
2120
- return new Stream(stream.channel.mapOut(f));
2067
+ export function mapChunks<A, A1>(f: (chunk: Conc<A>) => Conc<A1>, __tsplusTrace?: string) {
2068
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A1> => {
2069
+ return new Stream(stream.channel.mapOut(f));
2070
+ };
2121
2071
  }
2122
2072
 
2123
2073
  /**
2124
2074
  * Effectfully transforms the chunks emitted by this stream.
2125
2075
  *
2126
- * @tsplus fluent fncts.io.Stream mapChunksIO
2076
+ * @tsplus pipeable fncts.io.Stream mapChunksIO
2127
2077
  */
2128
- export function mapChunksIO_<R, E, A, R1, E1, B>(
2129
- stream: Stream<R, E, A>,
2130
- f: (chunk: Conc<A>) => IO<R1, E1, Conc<B>>,
2131
- __tsplusTrace?: string,
2132
- ): Stream<R | R1, E | E1, B> {
2133
- return new Stream(stream.channel.mapOutIO(f));
2078
+ export function mapChunksIO<A, R1, E1, B>(f: (chunk: Conc<A>) => IO<R1, E1, Conc<B>>, __tsplusTrace?: string) {
2079
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2080
+ return new Stream(stream.channel.mapOutIO(f));
2081
+ };
2134
2082
  }
2135
2083
 
2136
2084
  /**
2137
2085
  * Maps each element to an iterable, and flattens the iterables into the
2138
2086
  * output of this stream.
2139
2087
  *
2140
- * @tsplus fluent fncts.io.Stream mapConcat
2088
+ * @tsplus pipeable fncts.io.Stream mapConcat
2141
2089
  */
2142
- export function mapConcat_<R, E, A, B>(
2143
- stream: Stream<R, E, A>,
2144
- f: (a: A) => Iterable<B>,
2145
- __tsplusTrace?: string,
2146
- ): Stream<R, E, B> {
2147
- return stream.mapConcatChunk((a) => Conc.from(f(a)));
2090
+ export function mapConcat<A, B>(f: (a: A) => Iterable<B>, __tsplusTrace?: string) {
2091
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
2092
+ return stream.mapConcatChunk((a) => Conc.from(f(a)));
2093
+ };
2148
2094
  }
2149
2095
 
2150
2096
  /**
2151
2097
  * Maps each element to a chunk, and flattens the chunks into the output of
2152
2098
  * this stream.
2153
2099
  *
2154
- * @tsplus fluent fncts.io.Stream mapConcatChunk
2100
+ * @tsplus pipeable fncts.io.Stream mapConcatChunk
2155
2101
  */
2156
- export function mapConcatChunk_<R, E, A, B>(
2157
- stream: Stream<R, E, A>,
2158
- f: (a: A) => Conc<B>,
2159
- __tsplusTrace?: string,
2160
- ): Stream<R, E, B> {
2161
- return stream.mapChunks((c) => c.flatMap(f));
2102
+ export function mapConcatChunk<A, B>(f: (a: A) => Conc<B>, __tsplusTrace?: string) {
2103
+ return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
2104
+ return stream.mapChunks((c) => c.flatMap(f));
2105
+ };
2162
2106
  }
2163
2107
 
2164
2108
  /**
2165
2109
  * Effectfully maps each element to a chunk, and flattens the chunks into
2166
2110
  * the output of this stream.
2167
2111
  *
2168
- * @tsplus fluent fncts.io.Stream mapConcatChunkIO
2112
+ * @tsplus pipeable fncts.io.Stream mapConcatChunkIO
2169
2113
  */
2170
- export function mapConcatChunkIO_<R, E, A, R1, E1, B>(
2171
- stream: Stream<R, E, A>,
2172
- f: (a: A) => IO<R1, E1, Conc<B>>,
2173
- __tsplusTrace?: string,
2174
- ): Stream<R | R1, E | E1, B> {
2175
- return stream.mapIO(f).mapConcatChunk(identity);
2114
+ export function mapConcatChunkIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Conc<B>>, __tsplusTrace?: string) {
2115
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2116
+ return stream.mapIO(f).mapConcatChunk(identity);
2117
+ };
2176
2118
  }
2177
2119
 
2178
2120
  /**
2179
2121
  * Effectfully maps each element to an iterable, and flattens the iterables into
2180
2122
  * the output of this stream.
2181
2123
  *
2182
- * @tsplus fluent fncts.io.Stream mapConcatIO
2124
+ * @tsplus pipeable fncts.io.Stream mapConcatIO
2183
2125
  */
2184
- export function mapConcatIO_<R, E, A, R1, E1, B>(
2185
- stream: Stream<R, E, A>,
2186
- f: (a: A) => IO<R1, E1, Iterable<B>>,
2187
- __tsplusTrace?: string,
2188
- ): Stream<R | R1, E | E1, B> {
2189
- return stream.mapIO((a) => f(a).map(Conc.from)).mapConcatChunk(identity);
2126
+ export function mapConcatIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Iterable<B>>, __tsplusTrace?: string) {
2127
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2128
+ return stream.mapIO((a) => f(a).map(Conc.from)).mapConcatChunk(identity);
2129
+ };
2190
2130
  }
2191
2131
 
2192
2132
  /**
2193
2133
  * Transforms the errors emitted by this stream using `f`.
2194
2134
  *
2195
- * @tsplus fluent fncts.io.Stream mapError
2135
+ * @tsplus pipeable fncts.io.Stream mapError
2196
2136
  */
2197
- export function mapError_<R, E, E1, A>(
2198
- stream: Stream<R, E, A>,
2199
- f: (e: E) => E1,
2200
- __tsplusTrace?: string,
2201
- ): Stream<R, E1, A> {
2202
- return new Stream(stream.channel.mapError(f));
2137
+ export function mapError<E, E1>(f: (e: E) => E1, __tsplusTrace?: string) {
2138
+ return <R, A>(stream: Stream<R, E, A>): Stream<R, E1, A> => {
2139
+ return new Stream(stream.channel.mapError(f));
2140
+ };
2203
2141
  }
2204
2142
 
2205
2143
  /**
2206
2144
  * Transforms the full causes of failures emitted by this stream.
2207
2145
  *
2208
- * @tsplus fluent fncts.io.Stream mapErrorCause
2146
+ * @tsplus pipeable fncts.io.Stream mapErrorCause
2209
2147
  */
2210
- export function mapErrorCause_<R, E, A, E1>(
2211
- fa: Stream<R, E, A>,
2212
- f: (e: Cause<E>) => Cause<E1>,
2213
- __tsplusTrace?: string,
2214
- ): Stream<R, E1, A> {
2215
- return new Stream(fa.channel.mapErrorCause(f));
2148
+ export function mapErrorCause<E, E1>(f: (e: Cause<E>) => Cause<E1>, __tsplusTrace?: string) {
2149
+ return <R, A>(fa: Stream<R, E, A>): Stream<R, E1, A> => {
2150
+ return new Stream(fa.channel.mapErrorCause(f));
2151
+ };
2216
2152
  }
2217
2153
 
2218
2154
  /**
2219
2155
  * Maps over elements of the stream with the specified effectful function.
2220
2156
  *
2221
- * @tsplus fluent fncts.io.Stream mapIO
2157
+ * @tsplus pipeable fncts.io.Stream mapIO
2222
2158
  */
2223
- export function mapIO_<R, E, A, R1, E1, B>(
2224
- stream: Stream<R, E, A>,
2225
- f: (a: A) => IO<R1, E1, B>,
2226
- __tsplusTrace?: string,
2227
- ): Stream<R | R1, E | E1, B> {
2228
- return new Stream(stream.channel.pipeTo(mapIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
2159
+ export function mapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
2160
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2161
+ return new Stream(stream.channel.pipeTo(mapIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
2162
+ };
2229
2163
  }
2230
2164
 
2231
2165
  function mapIOLoop<R, E, A, R1, E1, B>(
@@ -2254,15 +2188,12 @@ function mapIOLoop<R, E, A, R1, E1, B>(
2254
2188
  *
2255
2189
  * @note This combinator destroys the chunking structure. It's recommended to use chunkN afterwards.
2256
2190
  *
2257
- * @tsplus fluent fncts.io.Stream mapIOC
2191
+ * @tsplus pipeable fncts.io.Stream mapIOC
2258
2192
  */
2259
- export function mapIOC_<R, E, A, R1, E1, B>(
2260
- stream: Stream<R, E, A>,
2261
- n: number,
2262
- f: (a: A) => IO<R1, E1, B>,
2263
- __tsplusTrace?: string,
2264
- ): Stream<R | R1, E | E1, B> {
2265
- return new Stream(stream.channel.concatMap(Channel.writeChunk).mapOutIOC(n, f).mapOut(Conc.single));
2193
+ export function mapIOC<A, R1, E1, B>(n: number, f: (a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
2194
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2195
+ return new Stream(stream.channel.concatMap(Channel.writeChunk).mapOutIOC(n, f).mapOut(Conc.single));
2196
+ };
2266
2197
  }
2267
2198
 
2268
2199
  /**
@@ -2271,16 +2202,17 @@ export function mapIOC_<R, E, A, R1, E1, B>(
2271
2202
  * concurrently. Up to `bufferSize` elements of the produced streams may be
2272
2203
  * buffered in memory by this operator.
2273
2204
  *
2274
- * @tsplus fluent fncts.io.Stream mergeMap
2205
+ * @tsplus pipeable fncts.io.Stream mergeMap
2275
2206
  */
2276
- export function mergeMap_<R, E, A, R1, E1, B>(
2277
- ma: Stream<R, E, A>,
2207
+ export function mergeMap<A, R1, E1, B>(
2278
2208
  f: (a: A) => Stream<R1, E1, B>,
2279
2209
  n: number,
2280
2210
  bufferSize = 16,
2281
2211
  __tsplusTrace?: string,
2282
- ): Stream<R | R1, E | E1, B> {
2283
- return new Stream(ma.channel.concatMap(Channel.writeChunk).mergeMap((a) => f(a).channel, n, bufferSize));
2212
+ ) {
2213
+ return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2214
+ return new Stream(ma.channel.concatMap(Channel.writeChunk).mergeMap((a) => f(a).channel, n, bufferSize));
2215
+ };
2284
2216
  }
2285
2217
 
2286
2218
  /**
@@ -2288,27 +2220,26 @@ export function mergeMap_<R, E, A, R1, E1, B>(
2288
2220
  * executing up to `n` invocations of `f` concurrently. The element order
2289
2221
  * is not enforced by this combinator, and elements may be reordered.
2290
2222
  *
2291
- * @tsplus fluent fncts.io.Stream mergeMapIO
2223
+ * @tsplus pipeable fncts.io.Stream mergeMapIO
2292
2224
  */
2293
- export function mergeMapIO_<R, E, A, R1, E1, B>(
2294
- stream: Stream<R, E, A>,
2225
+ export function mergeMapIO<A, R1, E1, B>(
2295
2226
  f: (a: A) => IO<R1, E1, B>,
2296
2227
  n: number,
2297
2228
  bufferSize = 16,
2298
2229
  __tsplusTrace?: string,
2299
- ): Stream<R | R1, E | E1, B> {
2300
- return stream.mergeMap((a) => Stream.fromIO(f(a)), n, bufferSize);
2230
+ ) {
2231
+ return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2232
+ return stream.mergeMap((a) => Stream.fromIO(f(a)), n, bufferSize);
2233
+ };
2301
2234
  }
2302
2235
 
2303
2236
  /**
2304
- * @tsplus fluent fncts.io.Stream mergeEither
2237
+ * @tsplus pipeable fncts.io.Stream mergeEither
2305
2238
  */
2306
- export function mergeEither_<R, E, A, R1, E1, B>(
2307
- fa: Stream<R, E, A>,
2308
- fb: Stream<R1, E1, B>,
2309
- __tsplusTrace?: string,
2310
- ): Stream<R | R1, E | E1, Either<A, B>> {
2311
- return fa.mergeWith(fb, Either.left, Either.right);
2239
+ export function mergeEither<R1, E1, B>(fb: Stream<R1, E1, B>, __tsplusTrace?: string) {
2240
+ return <R, E, A>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, Either<A, B>> => {
2241
+ return fa.mergeWith(fb, Either.left, Either.right);
2242
+ };
2312
2243
  }
2313
2244
 
2314
2245
  export function mergeWithHandler<R, E>(
@@ -2322,25 +2253,26 @@ export function mergeWithHandler<R, E>(
2322
2253
  export type TerminationStrategy = "Left" | "Right" | "Both" | "Either";
2323
2254
 
2324
2255
  /**
2325
- * @tsplus fluent fncts.io.Stream mergeWith
2256
+ * @tsplus pipeable fncts.io.Stream mergeWith
2326
2257
  */
2327
- export function mergeWith_<R, E, A, R1, E1, A1, B, C>(
2328
- sa: Stream<R, E, A>,
2258
+ export function mergeWith<A, R1, E1, A1, B, C>(
2329
2259
  sb: Stream<R1, E1, A1>,
2330
2260
  l: (a: A) => B,
2331
2261
  r: (b: A1) => C,
2332
2262
  strategy: TerminationStrategy = "Both",
2333
2263
  __tsplusTrace?: string,
2334
- ): Stream<R | R1, E | E1, B | C> {
2335
- return new Stream<R | R1, E | E1, B | C>(
2336
- sa
2337
- .map(l)
2338
- .channel.mergeWith(
2339
- map_(sb, r).channel,
2340
- mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Left"),
2341
- mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Right"),
2342
- ),
2343
- );
2264
+ ) {
2265
+ return <R, E>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, B | C> => {
2266
+ return new Stream<R | R1, E | E1, B | C>(
2267
+ sa
2268
+ .map(l)
2269
+ .channel.mergeWith(
2270
+ sb.map(r).channel,
2271
+ mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Left"),
2272
+ mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Right"),
2273
+ ),
2274
+ );
2275
+ };
2344
2276
  }
2345
2277
 
2346
2278
  /**
@@ -2348,14 +2280,12 @@ export function mergeWith_<R, E, A, R1, E1, A1, B, C>(
2348
2280
  *
2349
2281
  * Note: Unlike `IO.onError`, there is no guarantee that the provided effect will not be interrupted.
2350
2282
  *
2351
- * @tsplus fluent fncts.io.Stream onError
2283
+ * @tsplus pipeable fncts.io.Stream onError
2352
2284
  */
2353
- export function onError_<R, E, A, R1>(
2354
- stream: Stream<R, E, A>,
2355
- cleanup: (e: Cause<E>) => IO<R1, never, any>,
2356
- __tsplusTrace?: string,
2357
- ): Stream<R | R1, E, A> {
2358
- return stream.catchAllCause((cause) => fromIO(cleanup(cause).apSecond(IO.failCauseNow(cause))));
2285
+ export function onError<E, R1>(cleanup: (e: Cause<E>) => IO<R1, never, any>, __tsplusTrace?: string) {
2286
+ return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E, A> => {
2287
+ return stream.catchAllCause((cause) => fromIO(cleanup(cause).apSecond(IO.failCauseNow(cause))));
2288
+ };
2359
2289
  }
2360
2290
 
2361
2291
  /**
@@ -2363,14 +2293,12 @@ export function onError_<R, E, A, R1>(
2363
2293
  *
2364
2294
  * See also Stream#catchAll
2365
2295
  *
2366
- * @tsplus fluent fncts.io.Stream orElse
2296
+ * @tsplus pipeable fncts.io.Stream orElse
2367
2297
  */
2368
- export function orElse_<R, E, A, R1, E1, A1>(
2369
- stream: Stream<R, E, A>,
2370
- that: Lazy<Stream<R1, E1, A1>>,
2371
- __tsplusTrace?: string,
2372
- ): Stream<R | R1, E1, A | A1> {
2373
- return new Stream<R | R1, E1, A | A1>(stream.channel.orElse(that().channel));
2298
+ export function orElse<R1, E1, A1>(that: Lazy<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
2299
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
2300
+ return new Stream<R | R1, E1, A | A1>(stream.channel.orElse(that().channel));
2301
+ };
2374
2302
  }
2375
2303
 
2376
2304
  /**
@@ -2378,14 +2306,12 @@ export function orElse_<R, E, A, R1, E1, A1>(
2378
2306
  *
2379
2307
  * See also ZStream#catchAll
2380
2308
  *
2381
- * @tsplus fluent fncts.io.Stream orElseEither
2309
+ * @tsplus pipeable fncts.io.Stream orElseEither
2382
2310
  */
2383
- export function orElseEither_<R, E, A, R1, E1, A1>(
2384
- stream: Stream<R, E, A>,
2385
- that: Lazy<Stream<R1, E1, A1>>,
2386
- __tsplusTrace?: string,
2387
- ): Stream<R | R1, E1, Either<A, A1>> {
2388
- return stream.map(Either.left).orElse(that().map(Either.right));
2311
+ export function orElseEither<R1, E1, A1>(that: Lazy<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
2312
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, Either<A, A1>> => {
2313
+ return stream.map(Either.left).orElse(that().map(Either.right));
2314
+ };
2389
2315
  }
2390
2316
 
2391
2317
  /**
@@ -2393,14 +2319,12 @@ export function orElseEither_<R, E, A, R1, E1, A1>(
2393
2319
  *
2394
2320
  * See also Stream#catchAll
2395
2321
  *
2396
- * @tsplus fluent fncts.io.Stream orElseFail
2322
+ * @tsplus pipeable fncts.io.Stream orElseFail
2397
2323
  */
2398
- export function orElseFail_<R, E, A, E1>(
2399
- stream: Stream<R, E, A>,
2400
- e: Lazy<E1>,
2401
- __tsplusTrace?: string,
2402
- ): Stream<R, E1, A> {
2403
- return stream.orElse(Stream.failNow(e()));
2324
+ export function orElseFail<E1>(e: Lazy<E1>, __tsplusTrace?: string) {
2325
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E1, A> => {
2326
+ return stream.orElse(Stream.failNow(e()));
2327
+ };
2404
2328
  }
2405
2329
 
2406
2330
  /**
@@ -2408,7 +2332,7 @@ export function orElseFail_<R, E, A, E1>(
2408
2332
  *
2409
2333
  * See also Stream#catchAll.
2410
2334
  */
2411
- export function orElseOptional_<R, E, A, R1, E1, A1>(
2335
+ export function orElseOptional<R, E, A, R1, E1, A1>(
2412
2336
  stream: Stream<R, Maybe<E>, A>,
2413
2337
  that: Lazy<Stream<R1, Maybe<E1>, A1>>,
2414
2338
  __tsplusTrace?: string,
@@ -2424,85 +2348,69 @@ export function orElseOptional_<R, E, A, R1, E1, A1>(
2424
2348
  /**
2425
2349
  * Succeeds with the specified value if this one fails with a typed error.
2426
2350
  *
2427
- * @tsplus fluent fncts.io.Stream orElseSucceed
2351
+ * @tsplus pipeable fncts.io.Stream orElseSucceed
2428
2352
  */
2429
- export function orElseSucceed_<R, E, A, A1>(
2430
- stream: Stream<R, E, A>,
2431
- a: Lazy<A1>,
2432
- __tsplusTrace?: string,
2433
- ): Stream<R, never, A | A1> {
2434
- return stream.orElse(Stream.succeedNow(a()));
2353
+ export function orElseSucceed<A1>(a: Lazy<A1>, __tsplusTrace?: string) {
2354
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, never, A | A1> => {
2355
+ return stream.orElse(Stream.succeedNow(a()));
2356
+ };
2435
2357
  }
2436
2358
 
2437
2359
  /**
2438
- * @tsplus fluent fncts.io.Stream pipeThrough
2360
+ * @tsplus pipeable fncts.io.Stream pipeThrough
2439
2361
  */
2440
- export function pipeThrough_<R, E, A, R1, E1, L, Z>(
2441
- ma: Stream<R, E, A>,
2442
- sa: Sink<R1, E1, A, L, Z>,
2443
- __tsplusTrace?: string,
2444
- ): Stream<R | R1, E | E1, L> {
2445
- return new Stream(ma.channel.pipeToOrFail(sa.channel));
2362
+ export function pipeThrough<A, R1, E1, L, Z>(sa: Sink<R1, E1, A, L, Z>, __tsplusTrace?: string) {
2363
+ return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, L> => {
2364
+ return new Stream(ma.channel.pipeToOrFail(sa.channel));
2365
+ };
2446
2366
  }
2447
2367
 
2448
2368
  /**
2449
2369
  * Provides the stream with its required environment, which eliminates
2450
2370
  * its dependency on `R`.
2451
2371
  *
2452
- * @tsplus fluent fncts.io.Stream provideEnvironment
2372
+ * @tsplus pipeable fncts.io.Stream provideEnvironment
2453
2373
  */
2454
- export function provideEnvironment_<R, E, A>(
2455
- ra: Stream<R, E, A>,
2456
- r: Environment<R>,
2457
- __tsplusTrace?: string,
2458
- ): Stream<never, E, A> {
2459
- return new Stream(ra.channel.provideEnvironment(r));
2374
+ export function provideEnvironment<R>(r: Environment<R>, __tsplusTrace?: string) {
2375
+ return <E, A>(ra: Stream<R, E, A>): Stream<never, E, A> => {
2376
+ return new Stream(ra.channel.provideEnvironment(r));
2377
+ };
2460
2378
  }
2461
2379
 
2462
2380
  /**
2463
- * @tsplus fluent fncts.io.Stream provideLayer
2381
+ * @tsplus pipeable fncts.io.Stream provideLayer
2464
2382
  */
2465
- export function provideLayer_<RIn, E, ROut, E1, A>(
2466
- self: Stream<ROut, E, A>,
2467
- layer: Layer<RIn, E1, ROut>,
2468
- __tsplusTrace?: string,
2469
- ): Stream<RIn, E | E1, A> {
2470
- return new Stream(Channel.unwrapScoped(layer.build.map((r) => self.channel.provideEnvironment(r))));
2383
+ export function provideLayer<RIn, ROut, E1>(layer: Layer<RIn, E1, ROut>, __tsplusTrace?: string) {
2384
+ return <E, A>(self: Stream<ROut, E, A>): Stream<RIn, E | E1, A> => {
2385
+ return new Stream(Channel.unwrapScoped(layer.build.map((r) => self.channel.provideEnvironment(r))));
2386
+ };
2471
2387
  }
2472
2388
 
2473
2389
  /**
2474
- * @tsplus fluent fncts.io.Stream provideSomeLayer
2390
+ * @tsplus pipeable fncts.io.Stream provideSomeLayer
2475
2391
  */
2476
- export function provideSomeLayer_<R, E, A, RIn, E1, ROut>(
2477
- self: Stream<R, E, A>,
2478
- layer: Layer<RIn, E1, ROut>,
2479
- __tsplusTrace?: string,
2480
- ): Stream<RIn | Exclude<R, ROut>, E | E1, A> {
2481
- // @ts-expect-error
2482
- return self.provideLayer(Layer.environment<RIn>().and(layer));
2392
+ export function provideSomeLayer<RIn, E1, ROut>(layer: Layer<RIn, E1, ROut>, __tsplusTrace?: string) {
2393
+ return <R, E, A>(self: Stream<R, E, A>): Stream<RIn | Exclude<R, ROut>, E | E1, A> => {
2394
+ // @ts-expect-error
2395
+ return self.provideLayer(Layer.environment<RIn>().and(layer));
2396
+ };
2483
2397
  }
2484
2398
 
2485
2399
  class Rechunker<A> {
2486
2400
  private builder: Array<A> = [];
2487
2401
  private pos = 0;
2488
-
2489
2402
  constructor(readonly n: number) {}
2490
-
2491
2403
  write(elem: A) {
2492
2404
  this.builder.push(elem);
2493
2405
  this.pos += 1;
2494
-
2495
2406
  if (this.pos === this.n) {
2496
2407
  const result = this.builder;
2497
2408
  this.builder = [];
2498
2409
  this.pos = 0;
2499
-
2500
2410
  return Conc.from(result);
2501
2411
  }
2502
-
2503
2412
  return null;
2504
2413
  }
2505
-
2506
2414
  emitOfNotEmpty(): Channel<never, unknown, unknown, unknown, never, Conc<A>, void> {
2507
2415
  if (this.pos !== 0) {
2508
2416
  return Channel.writeNow(Conc.from(this.builder));
@@ -2510,11 +2418,9 @@ class Rechunker<A> {
2510
2418
  return Channel.unit;
2511
2419
  }
2512
2420
  }
2513
-
2514
2421
  get isEmpty(): boolean {
2515
2422
  return this.pos === 0;
2516
2423
  }
2517
- /* eslint-enable */
2518
2424
  }
2519
2425
 
2520
2426
  function rechunkProcess<E, In>(
@@ -2540,7 +2446,6 @@ function rechunkProcess<E, In>(
2540
2446
  result = null;
2541
2447
  }
2542
2448
  }
2543
-
2544
2449
  return Channel.writeAll(chunks).apSecond(rechunkProcess<E, In>(rechunker, target));
2545
2450
  } else {
2546
2451
  return rechunkProcess<E, In>(rechunker, target);
@@ -2556,10 +2461,12 @@ function rechunkProcess<E, In>(
2556
2461
  * `n` elements each.
2557
2462
  * The last chunk might contain less than `n` elements
2558
2463
  *
2559
- * @tsplus fluent fncts.io.Stream rechunk
2464
+ * @tsplus pipeable fncts.io.Stream rechunk
2560
2465
  */
2561
- export function rechunk_<R, E, A>(stream: Stream<R, E, A>, n: number, __tsplusTrace?: string): Stream<R, E, A> {
2562
- return new Stream(stream.channel.pipeTo(rechunkProcess(new Rechunker(n), n)));
2466
+ export function rechunk(n: number, __tsplusTrace?: string) {
2467
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
2468
+ return new Stream(stream.channel.pipeTo(rechunkProcess(new Rechunker(n), n)));
2469
+ };
2563
2470
  }
2564
2471
 
2565
2472
  /**
@@ -2614,14 +2521,12 @@ export function repeatIOChunkMaybe<R, E, A>(fa: IO<R, Maybe<E>, Conc<A>>, __tspl
2614
2521
  /**
2615
2522
  * Runs the sink on the stream to produce either the sink's result or an error.
2616
2523
  *
2617
- * @tsplus fluent fncts.io.Stream run
2524
+ * @tsplus pipeable fncts.io.Stream run
2618
2525
  */
2619
- export function run_<R, E, A, R2, E2, Z>(
2620
- stream: Stream<R, E, A>,
2621
- sink: Sink<R2, E2, A, unknown, Z>,
2622
- __tsplusTrace?: string,
2623
- ): IO<R | R2, E | E2, Z> {
2624
- return stream.channel.pipeToOrFail(sink.channel).runDrain;
2526
+ export function run<A, R2, E2, Z>(sink: Sink<R2, E2, A, unknown, Z>, __tsplusTrace?: string) {
2527
+ return <R, E>(stream: Stream<R, E, A>): IO<R | R2, E | E2, Z> => {
2528
+ return stream.channel.pipeToOrFail(sink.channel).runDrain;
2529
+ };
2625
2530
  }
2626
2531
 
2627
2532
  /**
@@ -2643,149 +2548,128 @@ export function runDrain<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?: strin
2643
2548
  }
2644
2549
 
2645
2550
  /**
2646
- * @tsplus fluent fncts.io.Stream runForeachScoped
2551
+ * @tsplus pipeable fncts.io.Stream runForeachScoped
2647
2552
  */
2648
- export function runForeachScoped_<R, E, A, R2, E2>(
2649
- self: Stream<R, E, A>,
2650
- f: (a: A) => IO<R2, E2, any>,
2651
- __tsplusTrace?: string,
2652
- ): IO<R | R2 | Scope, E | E2, void> {
2653
- return self.runScoped(Sink.foreach(f));
2553
+ export function runForeachScoped<A, R2, E2>(f: (a: A) => IO<R2, E2, any>, __tsplusTrace?: string) {
2554
+ return <R, E>(self: Stream<R, E, A>): IO<R | R2 | Scope, E | E2, void> => {
2555
+ return self.runScoped(Sink.foreach(f));
2556
+ };
2654
2557
  }
2655
2558
 
2656
2559
  /**
2657
2560
  * Like `into`, but provides the result as a `Managed` to allow for scope
2658
2561
  * composition.
2659
2562
  *
2660
- * @tsplus fluent fncts.io.Stream runIntoElementsScoped
2661
- */
2662
- export function runIntoElementsScoped_<R, E, A, R1, E1>(
2663
- stream: Stream<R, E, A>,
2664
- queue: PQueue<R1, unknown, never, never, Exit<Maybe<E | E1>, A>, unknown>,
2665
- __tsplusTrace?: string,
2666
- ): IO<R | R1 | Scope, E | E1, void> {
2667
- const writer: Channel<R | R1, E, Conc<A>, unknown, never, Exit<Maybe<E | E1>, A>, unknown> = Channel.readWith(
2668
- (inp: Conc<A>) =>
2669
- inp
2670
- .foldLeft(
2671
- Channel.unit as Channel<R1, unknown, unknown, unknown, never, Exit<Maybe<E | E1>, A>, unknown>,
2672
- (channel, a) => channel.apSecond(Channel.writeNow(Exit.succeed(a))),
2673
- )
2674
- .apSecond(writer),
2675
- (err) => Channel.writeNow(Exit.fail(Just(err))),
2676
- () => Channel.writeNow(Exit.fail(Nothing())),
2677
- );
2678
- return stream.channel.pipeTo(writer).mapOutIO((exit) => queue.offer(exit)).drain.runScoped.asUnit;
2563
+ * @tsplus pipeable fncts.io.Stream runIntoElementsScoped
2564
+ */
2565
+ export function runIntoElementsScoped<E, A, E1>(queue: Queue<Exit<Maybe<E | E1>, A>>, __tsplusTrace?: string) {
2566
+ return <R>(stream: Stream<R, E, A>): IO<R | Scope, E | E1, void> => {
2567
+ const writer: Channel<R, E, Conc<A>, unknown, never, Exit<Maybe<E | E1>, A>, unknown> = Channel.readWith(
2568
+ (inp: Conc<A>) =>
2569
+ inp
2570
+ .foldLeft(
2571
+ Channel.unit as Channel<never, unknown, unknown, unknown, never, Exit<Maybe<E | E1>, A>, unknown>,
2572
+ (channel, a) => channel.apSecond(Channel.writeNow(Exit.succeed(a))),
2573
+ )
2574
+ .apSecond(writer),
2575
+ (err) => Channel.writeNow(Exit.fail(Just(err))),
2576
+ () => Channel.writeNow(Exit.fail(Nothing())),
2577
+ );
2578
+ return stream.channel.pipeTo(writer).mapOutIO((exit) => queue.offer(exit)).drain.runScoped.asUnit;
2579
+ };
2679
2580
  }
2680
2581
 
2681
2582
  /**
2682
2583
  * Like `Stream#into`, but provides the result as a `Managed` to allow for scope
2683
2584
  * composition.
2684
2585
  *
2685
- * @tsplus fluent fncts.io.Stream runIntoQueueScoped
2586
+ * @tsplus pipeable fncts.io.Stream runIntoQueueScoped
2686
2587
  */
2687
- export function runIntoQueueScoped_<R, R1, E extends E1, E1, A>(
2688
- stream: Stream<R, E, A>,
2689
- queue: PQueue<R1, never, never, unknown, Take<E1, A>, any>,
2690
- __tsplusTrace?: string,
2691
- ): IO<R | R1 | Scope, E | E1, void> {
2692
- const writer: Channel<R, E, Conc<A>, unknown, E, Take<E | E1, A>, any> = Channel.readWithCause(
2693
- (inp) => Channel.writeNow(Take.chunk(inp)).apSecond(writer),
2694
- (cause) => Channel.writeNow(Take.failCause(cause)),
2695
- (_) => Channel.writeNow(Take.end),
2696
- );
2697
-
2698
- return stream.channel.pipeTo(writer).mapOutIO((take) => queue.offer(take)).drain.runScoped.asUnit;
2588
+ export function runIntoQueueScoped<E1, A>(queue: Enqueue<Take<E1, A>>, __tsplusTrace?: string) {
2589
+ return <R, E extends E1>(stream: Stream<R, E, A>): IO<R | Scope, E | E1, void> => {
2590
+ const writer: Channel<R, E, Conc<A>, unknown, E, Take<E | E1, A>, any> = Channel.readWithCause(
2591
+ (inp) => Channel.writeNow(Take.chunk(inp)).apSecond(writer),
2592
+ (cause) => Channel.writeNow(Take.failCause(cause)),
2593
+ (_) => Channel.writeNow(Take.end),
2594
+ );
2595
+ return stream.channel.pipeTo(writer).mapOutIO((take) => queue.offer(take)).drain.runScoped.asUnit;
2596
+ };
2699
2597
  }
2700
2598
 
2701
2599
  /**
2702
2600
  * Like `Stream#runIntoHub`, but provides the result as a `Managed` to allow for scope
2703
2601
  * composition.
2704
2602
  *
2705
- * @tsplus fluent fncts.io.Stream runIntoHubScoped
2603
+ * @tsplus pipeable fncts.io.Stream runIntoHubScoped
2706
2604
  */
2707
- export function runIntoHubScoped_<R, R1, E extends E1, E1, A>(
2708
- stream: Stream<R, E, A>,
2709
- hub: PHub<R1, never, never, unknown, Take<E1, A>, any>,
2710
- __tsplusTrace?: string,
2711
- ): IO<R | R1 | Scope, E | E1, void> {
2712
- return stream.runIntoQueueScoped(hub.toQueue);
2605
+ export function runIntoHubScoped<E1, A>(hub: Hub<Take<E1, A>>, __tsplusTrace?: string) {
2606
+ return <R, E extends E1>(stream: Stream<R, E, A>): IO<R | Scope, E | E1, void> => {
2607
+ return stream.runIntoQueueScoped(hub);
2608
+ };
2713
2609
  }
2714
2610
 
2715
2611
  /**
2716
2612
  * Runs the sink on the stream to produce either the sink's result or an error.
2717
2613
  *
2718
- * @tsplus fluent fncts.io.Stream runScoped
2614
+ * @tsplus pipeable fncts.io.Stream runScoped
2719
2615
  */
2720
- export function runScoped_<R, E, A, R2, E2, Z>(
2721
- stream: Stream<R, E, A>,
2722
- sink: Sink<R2, E2, A, unknown, Z>,
2723
- __tsplusTrace?: string,
2724
- ): IO<R | R2 | Scope, E | E2, Z> {
2725
- return stream.channel.pipeToOrFail(sink.channel).drain.runScoped;
2616
+ export function runScoped<A, R2, E2, Z>(sink: Sink<R2, E2, A, unknown, Z>, __tsplusTrace?: string) {
2617
+ return <R, E>(stream: Stream<R, E, A>): IO<R | R2 | Scope, E | E2, Z> => {
2618
+ return stream.channel.pipeToOrFail(sink.channel).drain.runScoped;
2619
+ };
2726
2620
  }
2727
2621
 
2728
2622
  /**
2729
2623
  * Statefully maps over the elements of this stream to produce all intermediate results
2730
2624
  * of type `B` given an initial B.
2731
2625
  *
2732
- * @tsplus fluent fncts.io.Stream scan
2626
+ * @tsplus pipeable fncts.io.Stream scan
2733
2627
  */
2734
- export function scan_<R, E, A, B>(
2735
- sa: Stream<R, E, A>,
2736
- b: B,
2737
- f: (b: B, a: A) => B,
2738
- __tsplusTrace?: string,
2739
- ): Stream<R, E, B> {
2740
- return sa.scanIO(b, (b, a) => IO.succeedNow(f(b, a)));
2628
+ export function scan<A, B>(b: B, f: (b: B, a: A) => B, __tsplusTrace?: string) {
2629
+ return <R, E>(sa: Stream<R, E, A>): Stream<R, E, B> => {
2630
+ return sa.scanIO(b, (b, a) => IO.succeedNow(f(b, a)));
2631
+ };
2741
2632
  }
2742
2633
 
2743
2634
  /**
2744
2635
  * Statefully and effectfully maps over the elements of this stream to produce all
2745
2636
  * intermediate results of type `B` given an initial B.
2746
2637
  *
2747
- * @tsplus fluent fncts.io.Stream scanIO
2638
+ * @tsplus pipeable fncts.io.Stream scanIO
2748
2639
  */
2749
- export function scanIO_<R, E, A, R1, E1, B>(
2750
- sa: Stream<R, E, A>,
2751
- b: B,
2752
- f: (b: B, a: A) => IO<R1, E1, B>,
2753
- __tsplusTrace?: string,
2754
- ): Stream<R | R1, E | E1, B> {
2755
- return Stream.succeedNow(b).concat(sa.mapAccumIO(b, (b, a) => f(b, a).map((b) => [b, b])));
2640
+ export function scanIO<A, R1, E1, B>(b: B, f: (b: B, a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
2641
+ return <R, E>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2642
+ return Stream.succeedNow(b).concat(sa.mapAccumIO(b, (b, a) => f(b, a).map((b) => [b, b])));
2643
+ };
2756
2644
  }
2757
2645
 
2758
2646
  /**
2759
2647
  * Statefully maps over the elements of this stream to produce all
2760
2648
  * intermediate results.
2761
2649
  *
2762
- * @tsplus fluent fncts.io.Stream scanReduce
2650
+ * @tsplus pipeable fncts.io.Stream scanReduce
2763
2651
  */
2764
- export function scanReduce_<R, E, A extends B, B>(
2765
- fa: Stream<R, E, A>,
2766
- f: (b: B, a: A) => B,
2767
- __tsplusTrace?: string,
2768
- ): Stream<R, E, B> {
2769
- return fa.scanReduceIO((b, a) => IO.succeedNow(f(b, a)));
2652
+ export function scanReduce<A extends B, B>(f: (b: B, a: A) => B, __tsplusTrace?: string) {
2653
+ return <R, E>(fa: Stream<R, E, A>): Stream<R, E, B> => {
2654
+ return fa.scanReduceIO((b, a) => IO.succeedNow(f(b, a)));
2655
+ };
2770
2656
  }
2771
2657
 
2772
2658
  /**
2773
2659
  * Statefully and effectfully maps over the elements of this stream to produce
2774
2660
  * all intermediate results.
2775
2661
  *
2776
- * @tsplus fluent fncts.io.Stream scanReduceIO
2662
+ * @tsplus pipeable fncts.io.Stream scanReduceIO
2777
2663
  */
2778
- export function scanReduceIO_<R, E, A extends B, R1, E1, B>(
2779
- fa: Stream<R, E, A>,
2780
- f: (b: B, a: A) => IO<R1, E1, B>,
2781
- __tsplusTrace?: string,
2782
- ): Stream<R | R1, E | E1, B> {
2783
- return fa.mapAccumIO(Nothing<B>(), (s, a) =>
2784
- s.match(
2785
- () => IO.succeedNow([a, Just(a)]),
2786
- (b) => f(b, a).map((b) => [b, Just(b)]),
2787
- ),
2788
- );
2664
+ export function scanReduceIO<A extends B, R1, E1, B>(f: (b: B, a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
2665
+ return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
2666
+ return fa.mapAccumIO(Nothing<B>(), (s, a) =>
2667
+ s.match(
2668
+ () => IO.succeedNow([a, Just(a)]),
2669
+ (b) => f(b, a).map((b) => [b, Just(b)]),
2670
+ ),
2671
+ );
2672
+ };
2789
2673
  }
2790
2674
 
2791
2675
  /**
@@ -2825,27 +2709,27 @@ function takeLoop<E, A>(n: number, __tsplusTrace?: string): Channel<never, E, Co
2825
2709
  /**
2826
2710
  * Takes the specified number of elements from this stream.
2827
2711
  *
2828
- * @tsplus fluent fncts.io.Stream take
2712
+ * @tsplus pipeable fncts.io.Stream take
2829
2713
  */
2830
- export function take_<R, E, A>(stream: Stream<R, E, A>, n: number, __tsplusTrace?: string): Stream<R, E, A> {
2831
- if (n <= 0) {
2832
- return empty;
2833
- }
2834
- if (!Number.isInteger(n)) {
2835
- return halt(new IllegalArgumentError(`${n} should be an integer`, "Stream.take"));
2836
- }
2837
- return new Stream(stream.channel.pipeTo(takeLoop(n)));
2714
+ export function take(n: number, __tsplusTrace?: string) {
2715
+ return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
2716
+ if (n <= 0) {
2717
+ return empty;
2718
+ }
2719
+ if (!Number.isInteger(n)) {
2720
+ return halt(new IllegalArgumentError(`${n} should be an integer`, "Stream.take"));
2721
+ }
2722
+ return new Stream(stream.channel.pipeTo(takeLoop(n)));
2723
+ };
2838
2724
  }
2839
2725
 
2840
2726
  /**
2841
- * @tsplus fluent fncts.io.Stream takeUntilIO
2727
+ * @tsplus pipeable fncts.io.Stream takeUntilIO
2842
2728
  */
2843
- export function takeUntilIO_<R, E, A, R1, E1>(
2844
- ma: Stream<R, E, A>,
2845
- f: (a: A) => IO<R1, E1, boolean>,
2846
- __tsplusTrace?: string,
2847
- ): Stream<R | R1, E | E1, A> {
2848
- return new Stream(ma.channel.pipeTo(takeUntilIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
2729
+ export function takeUntilIO<A, R1, E1>(f: (a: A) => IO<R1, E1, boolean>, __tsplusTrace?: string) {
2730
+ return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
2731
+ return new Stream(ma.channel.pipeTo(takeUntilIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
2732
+ };
2849
2733
  }
2850
2734
 
2851
2735
  function takeUntilIOLoop<E, A, R1, E1>(
@@ -2894,21 +2778,21 @@ function takeUntilLoop<R, E, A>(
2894
2778
  * Takes all elements of the stream until the specified predicate evaluates
2895
2779
  * to `true`.
2896
2780
  *
2897
- * @tsplus fluent fncts.io.Stream takeUntil
2781
+ * @tsplus pipeable fncts.io.Stream takeUntil
2898
2782
  */
2899
- export function takeUntil_<R, E, A>(fa: Stream<R, E, A>, p: Predicate<A>, __tsplusTrace?: string): Stream<R, E, A> {
2900
- return new Stream(fa.channel.pipeTo(takeUntilLoop(p)));
2783
+ export function takeUntil<A>(p: Predicate<A>, __tsplusTrace?: string) {
2784
+ return <R, E>(fa: Stream<R, E, A>): Stream<R, E, A> => {
2785
+ return new Stream(fa.channel.pipeTo(takeUntilLoop(p)));
2786
+ };
2901
2787
  }
2902
2788
 
2903
2789
  /**
2904
- * @tsplus fluent fncts.io.Stream tap
2790
+ * @tsplus pipeable fncts.io.Stream tap
2905
2791
  */
2906
- export function tap_<R, E, A, R1, E1>(
2907
- ma: Stream<R, E, A>,
2908
- f: (a: A) => IO<R1, E1, any>,
2909
- __tsplusTrace?: string,
2910
- ): Stream<R | R1, E | E1, A> {
2911
- return ma.mapIO((a) => f(a).as(a));
2792
+ export function tap<A, R1, E1>(f: (a: A) => IO<R1, E1, any>, __tsplusTrace?: string) {
2793
+ return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
2794
+ return ma.mapIO((a) => f(a).as(a));
2795
+ };
2912
2796
  }
2913
2797
 
2914
2798
  /**
@@ -2917,17 +2801,18 @@ export function tap_<R, E, A, R1, E1>(
2917
2801
  * tokens up to a `units + burst` threshold. Chunks that do not meet the bandwidth constraints are dropped.
2918
2802
  * The weight of each chunk is determined by the `costFn` function.
2919
2803
  *
2920
- * @tsplus fluent fncts.io.Stream throttleEnforce
2804
+ * @tsplus pipeable fncts.io.Stream throttleEnforce
2921
2805
  */
2922
- export function throttleEnforce_<R, E, A>(
2923
- sa: Stream<R, E, A>,
2806
+ export function throttleEnforce<A>(
2924
2807
  costFn: (chunk: Conc<A>) => number,
2925
2808
  units: number,
2926
2809
  duration: number,
2927
2810
  burst = 0,
2928
2811
  __tsplusTrace?: string,
2929
- ): Stream<R, E, A> {
2930
- return sa.throttleEnforceIO((chunk) => IO.succeedNow(costFn(chunk)), units, duration, burst);
2812
+ ) {
2813
+ return <R, E>(sa: Stream<R, E, A>): Stream<R, E, A> => {
2814
+ return sa.throttleEnforceIO((chunk) => IO.succeedNow(costFn(chunk)), units, duration, burst);
2815
+ };
2931
2816
  }
2932
2817
 
2933
2818
  function throttleEnforceIOLoop<E, A, R1, E1>(
@@ -2948,10 +2833,8 @@ function throttleEnforceIOLoop<E, A, R1, E1>(
2948
2833
  const available = (() => {
2949
2834
  const sum = tokens + cycles * units;
2950
2835
  const max = units + burst < 0 ? Number.MAX_SAFE_INTEGER : units + burst;
2951
-
2952
2836
  return sum < 0 ? max : Math.min(sum, max);
2953
2837
  })();
2954
-
2955
2838
  return weight <= available
2956
2839
  ? Channel.writeNow(inp).apSecond(
2957
2840
  throttleEnforceIOLoop<E, A, R1, E1>(costFn, units, duration, burst, available - weight, current),
@@ -2970,39 +2853,38 @@ function throttleEnforceIOLoop<E, A, R1, E1>(
2970
2853
  * tokens up to a `units + burst` threshold. Chunks that do not meet the bandwidth constraints are dropped.
2971
2854
  * The weight of each chunk is determined by the `costFn` effectful function.
2972
2855
  *
2973
- * @tsplus fluent fncts.io.Stream throttleEnforceIO
2856
+ * @tsplus pipeable fncts.io.Stream throttleEnforceIO
2974
2857
  */
2975
- export function throttleEnforceIO_<R, E, A, R1, E1>(
2976
- sa: Stream<R, E, A>,
2858
+ export function throttleEnforceIO<A, R1, E1>(
2977
2859
  costFn: (chunk: Conc<A>) => IO<R1, E1, number>,
2978
2860
  units: number,
2979
2861
  duration: number,
2980
2862
  burst = 0,
2981
2863
  __tsplusTrace?: string,
2982
- ): Stream<R | R1, E | E1, A> {
2983
- return new Stream(
2984
- Channel.fromIO(Clock.currentTime).flatMap((current) =>
2985
- sa.channel.pipeTo(throttleEnforceIOLoop(costFn, units, duration, burst, units, current)),
2986
- ),
2987
- );
2864
+ ) {
2865
+ return <R, E>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
2866
+ return new Stream(
2867
+ Channel.fromIO(Clock.currentTime).flatMap((current) =>
2868
+ sa.channel.pipeTo(throttleEnforceIOLoop(costFn, units, duration, burst, units, current)),
2869
+ ),
2870
+ );
2871
+ };
2988
2872
  }
2989
2873
 
2990
2874
  /**
2991
2875
  * Converts the stream to a managed hub of chunks. After the managed hub is used,
2992
2876
  * the hub will never again produce values and should be discarded.
2993
2877
  *
2994
- * @tsplus fluent fncts.io.Stream toHub
2878
+ * @tsplus pipeable fncts.io.Stream toHub
2995
2879
  */
2996
- export function toHub_<R, E, A>(
2997
- stream: Stream<R, E, A>,
2998
- capacity: number,
2999
- __tsplusTrace?: string,
3000
- ): IO<R | Scope, never, Hub<Take<E, A>>> {
3001
- return Do((Δ) => {
3002
- const hub = Δ(IO.acquireRelease(Hub.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
3003
- Δ(stream.runIntoHubScoped(hub).fork);
3004
- return hub;
3005
- });
2880
+ export function toHub(capacity: number, __tsplusTrace?: string) {
2881
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Hub<Take<E, A>>> => {
2882
+ return Do((Δ) => {
2883
+ const hub = Δ(IO.acquireRelease(Hub.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
2884
+ Δ(stream.runIntoHubScoped(hub).fork);
2885
+ return hub;
2886
+ });
2887
+ };
3006
2888
  }
3007
2889
 
3008
2890
  /**
@@ -3023,63 +2905,55 @@ export function toPull<R, E, A>(
3023
2905
  * Converts the stream to a managed queue of chunks. After the managed queue is used,
3024
2906
  * the queue will never again produce values and should be discarded.
3025
2907
  *
3026
- * @tsplus fluent fncts.io.Stream toQueue
2908
+ * @tsplus pipeable fncts.io.Stream toQueue
3027
2909
  */
3028
- export function toQueue_<R, E, A>(
3029
- stream: Stream<R, E, A>,
3030
- capacity = 2,
3031
- __tsplusTrace?: string,
3032
- ): IO<R | Scope, never, Queue<Take<E, A>>> {
3033
- return Do((Δ) => {
3034
- const queue = Δ(IO.acquireRelease(Queue.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
3035
- Δ(stream.runIntoQueueScoped(queue).fork);
3036
- return queue;
3037
- });
2910
+ export function toQueue(capacity = 2, __tsplusTrace?: string) {
2911
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Dequeue<Take<E, A>>> => {
2912
+ return Do((Δ) => {
2913
+ const queue = Δ(IO.acquireRelease(Queue.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
2914
+ Δ(stream.runIntoQueueScoped(queue).fork);
2915
+ return queue;
2916
+ });
2917
+ };
3038
2918
  }
3039
2919
 
3040
2920
  /**
3041
- * @tsplus fluent fncts.io.Stream toQueueDropping
2921
+ * @tsplus pipeable fncts.io.Stream toQueueDropping
3042
2922
  */
3043
- export function toQueueDropping_<R, E, A>(
3044
- stream: Stream<R, E, A>,
3045
- capacity = 2,
3046
- __tsplusTrace?: string,
3047
- ): IO<R | Scope, never, Queue.Dequeue<Take<E, A>>> {
3048
- return Do((Δ) => {
3049
- const queue = Δ(IO.acquireRelease(Queue.makeDropping<Take<E, A>>(capacity), (_) => _.shutdown));
3050
- Δ(stream.runIntoQueueScoped(queue).fork);
3051
- return queue;
3052
- });
2923
+ export function toQueueDropping(capacity = 2, __tsplusTrace?: string) {
2924
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Dequeue<Take<E, A>>> => {
2925
+ return Do((Δ) => {
2926
+ const queue = Δ(IO.acquireRelease(Queue.makeDropping<Take<E, A>>(capacity), (_) => _.shutdown));
2927
+ Δ(stream.runIntoQueueScoped(queue).fork);
2928
+ return queue;
2929
+ });
2930
+ };
3053
2931
  }
3054
2932
 
3055
2933
  /**
3056
- * @tsplus fluent fncts.io.Stream toQueueOfElements
2934
+ * @tsplus pipeable fncts.io.Stream toQueueOfElements
3057
2935
  */
3058
- export function toQueueOfElements_<R, E, A>(
3059
- stream: Stream<R, E, A>,
3060
- capacity = 2,
3061
- __tsplusTrace?: string,
3062
- ): IO<R | Scope, never, Queue.Dequeue<Exit<Maybe<E>, A>>> {
3063
- return Do((Δ) => {
3064
- const queue = Δ(IO.acquireRelease(Queue.makeBounded<Exit<Maybe<E>, A>>(capacity), (_) => _.shutdown));
3065
- Δ(stream.runIntoElementsScoped(queue).fork);
3066
- return queue;
3067
- });
2936
+ export function toQueueOfElements(capacity = 2, __tsplusTrace?: string) {
2937
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Dequeue<Exit<Maybe<E>, A>>> => {
2938
+ return Do((Δ) => {
2939
+ const queue = Δ(IO.acquireRelease(Queue.makeBounded<Exit<Maybe<E>, A>>(capacity), (_) => _.shutdown));
2940
+ Δ(stream.runIntoElementsScoped(queue).fork);
2941
+ return queue;
2942
+ });
2943
+ };
3068
2944
  }
3069
2945
 
3070
2946
  /**
3071
- * @tsplus fluent fncts.io.Stream toQueueSliding
2947
+ * @tsplus pipeable fncts.io.Stream toQueueSliding
3072
2948
  */
3073
- export function toQueueSliding_<R, E, A>(
3074
- stream: Stream<R, E, A>,
3075
- capacity = 2,
3076
- __tsplusTrace?: string,
3077
- ): IO<R | Scope, never, Queue.Dequeue<Take<E, A>>> {
3078
- return Do((Δ) => {
3079
- const queue = Δ(IO.acquireRelease(Queue.makeSliding<Take<E, A>>(capacity), (_) => _.shutdown));
3080
- Δ(stream.runIntoQueueScoped(queue).fork);
3081
- return queue;
3082
- });
2949
+ export function toQueueSliding(capacity = 2, __tsplusTrace?: string) {
2950
+ return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Dequeue<Take<E, A>>> => {
2951
+ return Do((Δ) => {
2952
+ const queue = Δ(IO.acquireRelease(Queue.makeSliding<Take<E, A>>(capacity), (_) => _.shutdown));
2953
+ Δ(stream.runIntoQueueScoped(queue).fork);
2954
+ return queue;
2955
+ });
2956
+ };
3083
2957
  }
3084
2958
 
3085
2959
  /**
@@ -3216,59 +3090,58 @@ export function zipWithIndex_<R, E, A>(
3216
3090
  * that emitted elements that are not the last value in chunks will never be
3217
3091
  * used for zipping.
3218
3092
  *
3219
- * @tsplus fluent fncts.io.Stream zipWithLatest
3093
+ * @tsplus pipeable fncts.io.Stream zipWithLatest
3220
3094
  */
3221
- export function zipWithLatest_<R, E, A, R1, E1, B, C>(
3222
- fa: Stream<R, E, A>,
3223
- fb: Stream<R1, E1, B>,
3224
- f: (a: A, b: B) => C,
3225
- __tsplusTrace?: string,
3226
- ): Stream<R | R1, E | E1, C> {
3227
- function pullNonEmpty<R, E, A>(pull: IO<R, Maybe<E>, Conc<A>>, __tsplusTrace?: string): IO<R, Maybe<E>, Conc<A>> {
3228
- return pull.flatMap((chunk) => (chunk.isNonEmpty ? pullNonEmpty(pull) : IO.succeedNow(chunk)));
3229
- }
3230
- return Stream.fromPull(
3231
- Do((Δ) => {
3232
- const left = Δ(fa.toPull.map(pullNonEmpty));
3233
- const right = Δ(fb.toPull.map(pullNonEmpty));
3234
- return Δ(
3235
- Stream.fromIOMaybe(
3236
- left.raceWith(
3237
- right,
3238
- (leftDone: Exit<Maybe<E | E1>, Conc<A>>, rightFiber) =>
3239
- IO.fromExitNow(leftDone).zipWith(rightFiber.join, (l, r) => tuple(l, r, true)),
3240
- (rightDone, leftFiber) => IO.fromExitNow(rightDone).zipWith(leftFiber.join, (r, l) => tuple(l, r, false)),
3241
- ),
3242
- ).flatMap(([l, r, leftFirst]) =>
3243
- Stream.fromIO(Ref.make(tuple(l.unsafeGet(l.length - 1), r.unsafeGet(r.length - 1)))).flatMap((latest) =>
3244
- Stream.fromChunk(
3245
- leftFirst ? r.map((b) => f(l.unsafeGet(l.length - 1), b)) : l.map((a) => f(a, r.unsafeGet(r.length - 1))),
3246
- ).concat(
3247
- Stream.repeatIOMaybe(left)
3248
- .mergeEither(Stream.repeatIOMaybe(right))
3249
- .mapIO((ab) =>
3250
- ab.match(
3251
- (leftChunk) =>
3252
- latest.modify(([_, rightLatest]) =>
3253
- tuple(
3254
- leftChunk.map((a) => f(a, rightLatest)),
3255
- tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
3095
+ export function zipWithLatest<A, R1, E1, B, C>(fb: Stream<R1, E1, B>, f: (a: A, b: B) => C, __tsplusTrace?: string) {
3096
+ return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, C> => {
3097
+ function pullNonEmpty<R, E, A>(pull: IO<R, Maybe<E>, Conc<A>>, __tsplusTrace?: string): IO<R, Maybe<E>, Conc<A>> {
3098
+ return pull.flatMap((chunk) => (chunk.isNonEmpty ? pullNonEmpty(pull) : IO.succeedNow(chunk)));
3099
+ }
3100
+ return Stream.fromPull(
3101
+ Do() => {
3102
+ const left = Δ(fa.toPull.map(pullNonEmpty));
3103
+ const right = Δ(fb.toPull.map(pullNonEmpty));
3104
+ return Δ(
3105
+ Stream.fromIOMaybe(
3106
+ left.raceWith(
3107
+ right,
3108
+ (leftDone: Exit<Maybe<E | E1>, Conc<A>>, rightFiber) =>
3109
+ IO.fromExitNow(leftDone).zipWith(rightFiber.join, (l, r) => tuple(l, r, true)),
3110
+ (rightDone, leftFiber) => IO.fromExitNow(rightDone).zipWith(leftFiber.join, (r, l) => tuple(l, r, false)),
3111
+ ),
3112
+ ).flatMap(([l, r, leftFirst]) =>
3113
+ Stream.fromIO(Ref.make(tuple(l.unsafeGet(l.length - 1), r.unsafeGet(r.length - 1)))).flatMap((latest) =>
3114
+ Stream.fromChunk(
3115
+ leftFirst
3116
+ ? r.map((b) => f(l.unsafeGet(l.length - 1), b))
3117
+ : l.map((a) => f(a, r.unsafeGet(r.length - 1))),
3118
+ ).concat(
3119
+ Stream.repeatIOMaybe(left)
3120
+ .mergeEither(Stream.repeatIOMaybe(right))
3121
+ .mapIO((ab) =>
3122
+ ab.match(
3123
+ (leftChunk) =>
3124
+ latest.modify(([_, rightLatest]) =>
3125
+ tuple(
3126
+ leftChunk.map((a) => f(a, rightLatest)),
3127
+ tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
3128
+ ),
3256
3129
  ),
3257
- ),
3258
- (rightChunk) =>
3259
- latest.modify(([leftLatest, _]) =>
3260
- tuple(
3261
- rightChunk.map((b) => f(leftLatest, b)),
3262
- tuple(leftLatest, rightChunk.unsafeGet(rightChunk.length - 1)),
3130
+ (rightChunk) =>
3131
+ latest.modify(([leftLatest, _]) =>
3132
+ tuple(
3133
+ rightChunk.map((b) => f(leftLatest, b)),
3134
+ tuple(leftLatest, rightChunk.unsafeGet(rightChunk.length - 1)),
3135
+ ),
3263
3136
  ),
3264
- ),
3265
- ),
3266
- )
3267
- .flatMap(Stream.fromChunkNow),
3137
+ ),
3138
+ )
3139
+ .flatMap(Stream.fromChunkNow),
3140
+ ),
3268
3141
  ),
3269
- ),
3270
- ).toPull,
3271
- );
3272
- }),
3273
- );
3142
+ ).toPull,
3143
+ );
3144
+ }),
3145
+ );
3146
+ };
3274
3147
  }