@clayroach/effect 3.19.14-source-capture.8 → 3.19.14-source-trace.2

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 (452) hide show
  1. package/SourceLocation/package.json +6 -0
  2. package/dist/cjs/Effect.js +2 -28
  3. package/dist/cjs/Effect.js.map +1 -1
  4. package/dist/cjs/FiberRef.js +12 -1
  5. package/dist/cjs/FiberRef.js.map +1 -1
  6. package/dist/cjs/Layer.js +2 -24
  7. package/dist/cjs/Layer.js.map +1 -1
  8. package/dist/cjs/RuntimeFlags.js +1 -29
  9. package/dist/cjs/RuntimeFlags.js.map +1 -1
  10. package/dist/cjs/SourceLocation.js +60 -0
  11. package/dist/cjs/SourceLocation.js.map +1 -0
  12. package/dist/cjs/Tracer.js +1 -15
  13. package/dist/cjs/Tracer.js.map +1 -1
  14. package/dist/cjs/Utils.js +1 -1
  15. package/dist/cjs/Utils.js.map +1 -1
  16. package/dist/cjs/index.js +3 -1
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/internal/clock.js +1 -1
  19. package/dist/cjs/internal/clock.js.map +1 -1
  20. package/dist/cjs/internal/core.js +17 -50
  21. package/dist/cjs/internal/core.js.map +1 -1
  22. package/dist/cjs/internal/effect/circular.js +18 -30
  23. package/dist/cjs/internal/effect/circular.js.map +1 -1
  24. package/dist/cjs/internal/fiberRuntime.js +16 -65
  25. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  26. package/dist/cjs/internal/layer/circular.js +1 -5
  27. package/dist/cjs/internal/layer/circular.js.map +1 -1
  28. package/dist/cjs/internal/layer.js +1 -3
  29. package/dist/cjs/internal/layer.js.map +1 -1
  30. package/dist/cjs/internal/logger.js +25 -2
  31. package/dist/cjs/internal/logger.js.map +1 -1
  32. package/dist/cjs/internal/runtimeFlags.js +2 -11
  33. package/dist/cjs/internal/runtimeFlags.js.map +1 -1
  34. package/dist/cjs/internal/tracer.js +1 -114
  35. package/dist/cjs/internal/tracer.js.map +1 -1
  36. package/dist/dts/Config.d.ts +2 -2
  37. package/dist/dts/Config.d.ts.map +1 -1
  38. package/dist/dts/Effect.d.ts +8 -29
  39. package/dist/dts/Effect.d.ts.map +1 -1
  40. package/dist/dts/FiberRef.d.ts +12 -0
  41. package/dist/dts/FiberRef.d.ts.map +1 -1
  42. package/dist/dts/Layer.d.ts +0 -22
  43. package/dist/dts/Layer.d.ts.map +1 -1
  44. package/dist/dts/RuntimeFlags.d.ts +0 -28
  45. package/dist/dts/RuntimeFlags.d.ts.map +1 -1
  46. package/dist/dts/SourceLocation.d.ts +88 -0
  47. package/dist/dts/SourceLocation.d.ts.map +1 -0
  48. package/dist/dts/Tracer.d.ts +0 -15
  49. package/dist/dts/Tracer.d.ts.map +1 -1
  50. package/dist/dts/index.d.ts +6 -0
  51. package/dist/dts/index.d.ts.map +1 -1
  52. package/dist/dts/internal/core.d.ts.map +1 -1
  53. package/dist/dts/internal/layer.d.ts.map +1 -1
  54. package/dist/dts/internal/runtimeFlags.d.ts.map +1 -1
  55. package/dist/esm/Effect.js +0 -26
  56. package/dist/esm/Effect.js.map +1 -1
  57. package/dist/esm/FiberRef.js +11 -0
  58. package/dist/esm/FiberRef.js.map +1 -1
  59. package/dist/esm/Layer.js +0 -22
  60. package/dist/esm/Layer.js.map +1 -1
  61. package/dist/esm/RuntimeFlags.js +0 -28
  62. package/dist/esm/RuntimeFlags.js.map +1 -1
  63. package/dist/esm/SourceLocation.js +51 -0
  64. package/dist/esm/SourceLocation.js.map +1 -0
  65. package/dist/esm/Tracer.js +0 -14
  66. package/dist/esm/Tracer.js.map +1 -1
  67. package/dist/esm/Utils.js +1 -1
  68. package/dist/esm/Utils.js.map +1 -1
  69. package/dist/esm/index.js +6 -0
  70. package/dist/esm/index.js.map +1 -1
  71. package/dist/esm/internal/clock.js +1 -1
  72. package/dist/esm/internal/clock.js.map +1 -1
  73. package/dist/esm/internal/core.js +12 -45
  74. package/dist/esm/internal/core.js.map +1 -1
  75. package/dist/esm/internal/effect/circular.js +18 -30
  76. package/dist/esm/internal/effect/circular.js.map +1 -1
  77. package/dist/esm/internal/fiberRuntime.js +13 -60
  78. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  79. package/dist/esm/internal/layer/circular.js +0 -4
  80. package/dist/esm/internal/layer/circular.js.map +1 -1
  81. package/dist/esm/internal/layer.js +0 -2
  82. package/dist/esm/internal/layer.js.map +1 -1
  83. package/dist/esm/internal/logger.js +25 -2
  84. package/dist/esm/internal/logger.js.map +1 -1
  85. package/dist/esm/internal/runtimeFlags.js +1 -9
  86. package/dist/esm/internal/runtimeFlags.js.map +1 -1
  87. package/dist/esm/internal/tracer.js +0 -111
  88. package/dist/esm/internal/tracer.js.map +1 -1
  89. package/package.json +12 -1
  90. package/src/Arbitrary.ts +1101 -0
  91. package/src/Array.ts +3589 -0
  92. package/src/BigDecimal.ts +1349 -0
  93. package/src/BigInt.ts +643 -0
  94. package/src/Boolean.ts +287 -0
  95. package/src/Brand.ts +360 -0
  96. package/src/Cache.ts +281 -0
  97. package/src/Cause.ts +1555 -0
  98. package/src/Channel.ts +2355 -0
  99. package/src/ChildExecutorDecision.ts +146 -0
  100. package/src/Chunk.ts +1495 -0
  101. package/src/Clock.ts +111 -0
  102. package/src/Config.ts +542 -0
  103. package/src/ConfigError.ts +270 -0
  104. package/src/ConfigProvider.ts +333 -0
  105. package/src/ConfigProviderPathPatch.ts +100 -0
  106. package/src/Console.ts +226 -0
  107. package/src/Context.ts +585 -0
  108. package/src/Cron.ts +706 -0
  109. package/src/Data.ts +596 -0
  110. package/src/DateTime.ts +1686 -0
  111. package/src/DefaultServices.ts +34 -0
  112. package/src/Deferred.ts +301 -0
  113. package/src/Differ.ts +450 -0
  114. package/src/Duration.ts +1000 -0
  115. package/src/Effect.ts +14817 -0
  116. package/src/Effectable.ts +107 -0
  117. package/src/Either.ts +1040 -0
  118. package/src/Encoding.ts +195 -0
  119. package/src/Equal.ts +98 -0
  120. package/src/Equivalence.ts +235 -0
  121. package/src/ExecutionPlan.ts +308 -0
  122. package/src/ExecutionStrategy.ts +119 -0
  123. package/src/Exit.ts +467 -0
  124. package/src/FastCheck.ts +9 -0
  125. package/src/Fiber.ts +744 -0
  126. package/src/FiberHandle.ts +540 -0
  127. package/src/FiberId.ts +195 -0
  128. package/src/FiberMap.ts +656 -0
  129. package/src/FiberRef.ts +444 -0
  130. package/src/FiberRefs.ts +204 -0
  131. package/src/FiberRefsPatch.ts +105 -0
  132. package/src/FiberSet.ts +491 -0
  133. package/src/FiberStatus.ts +108 -0
  134. package/src/Function.ts +1222 -0
  135. package/src/GlobalValue.ts +53 -0
  136. package/src/Graph.ts +3732 -0
  137. package/src/GroupBy.ts +103 -0
  138. package/src/HKT.ts +45 -0
  139. package/src/Hash.ts +195 -0
  140. package/src/HashMap.ts +519 -0
  141. package/src/HashRing.ts +317 -0
  142. package/src/HashSet.ts +2346 -0
  143. package/src/Inspectable.ts +287 -0
  144. package/src/Iterable.ts +1119 -0
  145. package/src/JSONSchema.ts +1044 -0
  146. package/src/KeyedPool.ts +167 -0
  147. package/src/Layer.ts +1228 -0
  148. package/src/LayerMap.ts +436 -0
  149. package/src/List.ts +977 -0
  150. package/src/LogLevel.ts +285 -0
  151. package/src/LogSpan.ts +25 -0
  152. package/src/Logger.ts +702 -0
  153. package/src/Mailbox.ts +268 -0
  154. package/src/ManagedRuntime.ts +180 -0
  155. package/src/Match.ts +1477 -0
  156. package/src/MergeDecision.ts +95 -0
  157. package/src/MergeState.ts +172 -0
  158. package/src/MergeStrategy.ts +107 -0
  159. package/src/Metric.ts +780 -0
  160. package/src/MetricBoundaries.ts +69 -0
  161. package/src/MetricHook.ts +151 -0
  162. package/src/MetricKey.ts +224 -0
  163. package/src/MetricKeyType.ts +262 -0
  164. package/src/MetricLabel.ts +47 -0
  165. package/src/MetricPair.ts +71 -0
  166. package/src/MetricPolling.ts +148 -0
  167. package/src/MetricRegistry.ts +48 -0
  168. package/src/MetricState.ts +257 -0
  169. package/src/Micro.ts +4405 -0
  170. package/src/ModuleVersion.ts +18 -0
  171. package/src/MutableHashMap.ts +411 -0
  172. package/src/MutableHashSet.ts +706 -0
  173. package/src/MutableList.ts +297 -0
  174. package/src/MutableQueue.ts +227 -0
  175. package/src/MutableRef.ts +202 -0
  176. package/src/NonEmptyIterable.ts +32 -0
  177. package/src/Number.ts +1071 -0
  178. package/src/Option.ts +2170 -0
  179. package/src/Order.ts +373 -0
  180. package/src/Ordering.ts +111 -0
  181. package/src/ParseResult.ts +2031 -0
  182. package/src/PartitionedSemaphore.ts +200 -0
  183. package/src/Pipeable.ts +566 -0
  184. package/src/Pool.ts +204 -0
  185. package/src/Predicate.ts +1405 -0
  186. package/src/Pretty.ts +205 -0
  187. package/src/PrimaryKey.ts +23 -0
  188. package/src/PubSub.ts +182 -0
  189. package/src/Queue.ts +644 -0
  190. package/src/Random.ts +204 -0
  191. package/src/RateLimiter.ts +138 -0
  192. package/src/RcMap.ts +141 -0
  193. package/src/RcRef.ts +122 -0
  194. package/src/Readable.ts +93 -0
  195. package/src/Record.ts +1274 -0
  196. package/src/RedBlackTree.ts +421 -0
  197. package/src/Redacted.ts +144 -0
  198. package/src/Ref.ts +180 -0
  199. package/src/RegExp.ts +38 -0
  200. package/src/Reloadable.ts +127 -0
  201. package/src/Request.ts +347 -0
  202. package/src/RequestBlock.ts +118 -0
  203. package/src/RequestResolver.ts +366 -0
  204. package/src/Resource.ts +119 -0
  205. package/src/Runtime.ts +383 -0
  206. package/src/RuntimeFlags.ts +336 -0
  207. package/src/RuntimeFlagsPatch.ts +183 -0
  208. package/src/STM.ts +2045 -0
  209. package/src/Schedule.ts +2219 -0
  210. package/src/ScheduleDecision.ts +62 -0
  211. package/src/ScheduleInterval.ts +151 -0
  212. package/src/ScheduleIntervals.ts +122 -0
  213. package/src/Scheduler.ts +353 -0
  214. package/src/Schema.ts +10914 -0
  215. package/src/SchemaAST.ts +3043 -0
  216. package/src/Scope.ts +204 -0
  217. package/src/ScopedCache.ts +151 -0
  218. package/src/ScopedRef.ts +117 -0
  219. package/src/Secret.ts +88 -0
  220. package/src/SingleProducerAsyncInput.ts +67 -0
  221. package/src/Sink.ts +1461 -0
  222. package/src/SortedMap.ts +287 -0
  223. package/src/SortedSet.ts +390 -0
  224. package/src/SourceLocation.ts +108 -0
  225. package/src/Stream.ts +6468 -0
  226. package/src/StreamEmit.ts +136 -0
  227. package/src/StreamHaltStrategy.ts +123 -0
  228. package/src/Streamable.ts +45 -0
  229. package/src/String.ts +778 -0
  230. package/src/Struct.ts +243 -0
  231. package/src/Subscribable.ts +100 -0
  232. package/src/SubscriptionRef.ts +298 -0
  233. package/src/Supervisor.ts +240 -0
  234. package/src/Symbol.ts +29 -0
  235. package/src/SynchronizedRef.ts +270 -0
  236. package/src/TArray.ts +495 -0
  237. package/src/TDeferred.ts +100 -0
  238. package/src/TMap.ts +515 -0
  239. package/src/TPriorityQueue.ts +223 -0
  240. package/src/TPubSub.ts +200 -0
  241. package/src/TQueue.ts +432 -0
  242. package/src/TRandom.ts +129 -0
  243. package/src/TReentrantLock.ts +224 -0
  244. package/src/TRef.ts +178 -0
  245. package/src/TSemaphore.ts +129 -0
  246. package/src/TSet.ts +365 -0
  247. package/src/TSubscriptionRef.ts +192 -0
  248. package/src/Take.ts +258 -0
  249. package/src/TestAnnotation.ts +158 -0
  250. package/src/TestAnnotationMap.ts +119 -0
  251. package/src/TestAnnotations.ts +117 -0
  252. package/src/TestClock.ts +556 -0
  253. package/src/TestConfig.ts +47 -0
  254. package/src/TestContext.ts +36 -0
  255. package/src/TestLive.ts +53 -0
  256. package/src/TestServices.ts +390 -0
  257. package/src/TestSized.ts +55 -0
  258. package/src/Tracer.ts +182 -0
  259. package/src/Trie.ts +840 -0
  260. package/src/Tuple.ts +305 -0
  261. package/src/Types.ts +353 -0
  262. package/src/Unify.ts +113 -0
  263. package/src/UpstreamPullRequest.ts +117 -0
  264. package/src/UpstreamPullStrategy.ts +121 -0
  265. package/src/Utils.ts +809 -0
  266. package/src/index.ts +1568 -0
  267. package/src/internal/array.ts +8 -0
  268. package/src/internal/blockedRequests.ts +520 -0
  269. package/src/internal/cache.ts +733 -0
  270. package/src/internal/cause.ts +1050 -0
  271. package/src/internal/channel/channelExecutor.ts +1200 -0
  272. package/src/internal/channel/channelState.ts +134 -0
  273. package/src/internal/channel/childExecutorDecision.ts +96 -0
  274. package/src/internal/channel/continuation.ts +200 -0
  275. package/src/internal/channel/mergeDecision.ts +113 -0
  276. package/src/internal/channel/mergeState.ts +120 -0
  277. package/src/internal/channel/mergeStrategy.ts +72 -0
  278. package/src/internal/channel/singleProducerAsyncInput.ts +259 -0
  279. package/src/internal/channel/subexecutor.ts +229 -0
  280. package/src/internal/channel/upstreamPullRequest.ts +84 -0
  281. package/src/internal/channel/upstreamPullStrategy.ts +87 -0
  282. package/src/internal/channel.ts +2603 -0
  283. package/src/internal/clock.ts +95 -0
  284. package/src/internal/completedRequestMap.ts +9 -0
  285. package/src/internal/concurrency.ts +54 -0
  286. package/src/internal/config.ts +716 -0
  287. package/src/internal/configError.ts +304 -0
  288. package/src/internal/configProvider/pathPatch.ts +97 -0
  289. package/src/internal/configProvider.ts +799 -0
  290. package/src/internal/console.ts +153 -0
  291. package/src/internal/context.ts +337 -0
  292. package/src/internal/core-effect.ts +2293 -0
  293. package/src/internal/core-stream.ts +998 -0
  294. package/src/internal/core.ts +3189 -0
  295. package/src/internal/data.ts +36 -0
  296. package/src/internal/dataSource.ts +327 -0
  297. package/src/internal/dateTime.ts +1277 -0
  298. package/src/internal/defaultServices/console.ts +100 -0
  299. package/src/internal/defaultServices.ts +163 -0
  300. package/src/internal/deferred.ts +46 -0
  301. package/src/internal/differ/chunkPatch.ts +211 -0
  302. package/src/internal/differ/contextPatch.ts +232 -0
  303. package/src/internal/differ/hashMapPatch.ts +220 -0
  304. package/src/internal/differ/hashSetPatch.ts +176 -0
  305. package/src/internal/differ/orPatch.ts +311 -0
  306. package/src/internal/differ/readonlyArrayPatch.ts +210 -0
  307. package/src/internal/differ.ts +200 -0
  308. package/src/internal/doNotation.ts +80 -0
  309. package/src/internal/effect/circular.ts +895 -0
  310. package/src/internal/effectable.ts +131 -0
  311. package/src/internal/either.ts +110 -0
  312. package/src/internal/encoding/base64.ts +286 -0
  313. package/src/internal/encoding/base64Url.ts +29 -0
  314. package/src/internal/encoding/common.ts +51 -0
  315. package/src/internal/encoding/hex.ts +315 -0
  316. package/src/internal/errors.ts +7 -0
  317. package/src/internal/executionPlan.ts +114 -0
  318. package/src/internal/executionStrategy.ts +74 -0
  319. package/src/internal/fiber.ts +388 -0
  320. package/src/internal/fiberId.ts +267 -0
  321. package/src/internal/fiberMessage.ts +82 -0
  322. package/src/internal/fiberRefs/patch.ts +144 -0
  323. package/src/internal/fiberRefs.ts +297 -0
  324. package/src/internal/fiberRuntime.ts +3842 -0
  325. package/src/internal/fiberScope.ts +71 -0
  326. package/src/internal/fiberStatus.ts +119 -0
  327. package/src/internal/groupBy.ts +530 -0
  328. package/src/internal/hashMap/array.ts +49 -0
  329. package/src/internal/hashMap/bitwise.ts +32 -0
  330. package/src/internal/hashMap/config.ts +14 -0
  331. package/src/internal/hashMap/keySet.ts +8 -0
  332. package/src/internal/hashMap/node.ts +391 -0
  333. package/src/internal/hashMap.ts +586 -0
  334. package/src/internal/hashSet.ts +323 -0
  335. package/src/internal/keyedPool.ts +244 -0
  336. package/src/internal/layer/circular.ts +214 -0
  337. package/src/internal/layer.ts +1483 -0
  338. package/src/internal/logSpan.ts +20 -0
  339. package/src/internal/logger-circular.ts +24 -0
  340. package/src/internal/logger.ts +522 -0
  341. package/src/internal/mailbox.ts +561 -0
  342. package/src/internal/managedRuntime/circular.ts +6 -0
  343. package/src/internal/managedRuntime.ts +134 -0
  344. package/src/internal/matcher.ts +652 -0
  345. package/src/internal/metric/boundaries.ts +75 -0
  346. package/src/internal/metric/hook.ts +483 -0
  347. package/src/internal/metric/key.ts +167 -0
  348. package/src/internal/metric/keyType.ts +238 -0
  349. package/src/internal/metric/label.ts +41 -0
  350. package/src/internal/metric/pair.ts +48 -0
  351. package/src/internal/metric/polling.ts +149 -0
  352. package/src/internal/metric/registry.ts +187 -0
  353. package/src/internal/metric/state.ts +290 -0
  354. package/src/internal/metric.ts +577 -0
  355. package/src/internal/opCodes/cause.ts +35 -0
  356. package/src/internal/opCodes/channel.ts +83 -0
  357. package/src/internal/opCodes/channelChildExecutorDecision.ts +17 -0
  358. package/src/internal/opCodes/channelMergeDecision.ts +11 -0
  359. package/src/internal/opCodes/channelMergeState.ts +17 -0
  360. package/src/internal/opCodes/channelMergeStrategy.ts +11 -0
  361. package/src/internal/opCodes/channelState.ts +23 -0
  362. package/src/internal/opCodes/channelUpstreamPullRequest.ts +11 -0
  363. package/src/internal/opCodes/channelUpstreamPullStrategy.ts +11 -0
  364. package/src/internal/opCodes/config.ts +65 -0
  365. package/src/internal/opCodes/configError.ts +35 -0
  366. package/src/internal/opCodes/continuation.ts +11 -0
  367. package/src/internal/opCodes/deferred.ts +11 -0
  368. package/src/internal/opCodes/effect.ts +89 -0
  369. package/src/internal/opCodes/layer.ts +59 -0
  370. package/src/internal/opCodes/streamHaltStrategy.ts +23 -0
  371. package/src/internal/option.ts +80 -0
  372. package/src/internal/pool.ts +432 -0
  373. package/src/internal/pubsub.ts +1762 -0
  374. package/src/internal/query.ts +204 -0
  375. package/src/internal/queue.ts +766 -0
  376. package/src/internal/random.ts +161 -0
  377. package/src/internal/rateLimiter.ts +93 -0
  378. package/src/internal/rcMap.ts +285 -0
  379. package/src/internal/rcRef.ts +192 -0
  380. package/src/internal/redBlackTree/iterator.ts +200 -0
  381. package/src/internal/redBlackTree/node.ts +68 -0
  382. package/src/internal/redBlackTree.ts +1245 -0
  383. package/src/internal/redacted.ts +73 -0
  384. package/src/internal/ref.ts +171 -0
  385. package/src/internal/reloadable.ts +140 -0
  386. package/src/internal/request.ts +177 -0
  387. package/src/internal/resource.ts +76 -0
  388. package/src/internal/ringBuffer.ts +68 -0
  389. package/src/internal/runtime.ts +558 -0
  390. package/src/internal/runtimeFlags.ts +178 -0
  391. package/src/internal/runtimeFlagsPatch.ts +103 -0
  392. package/src/internal/schedule/decision.ts +47 -0
  393. package/src/internal/schedule/interval.ts +101 -0
  394. package/src/internal/schedule/intervals.ts +180 -0
  395. package/src/internal/schedule.ts +2199 -0
  396. package/src/internal/schema/errors.ts +191 -0
  397. package/src/internal/schema/schemaId.ts +106 -0
  398. package/src/internal/schema/util.ts +50 -0
  399. package/src/internal/scopedCache.ts +644 -0
  400. package/src/internal/scopedRef.ts +118 -0
  401. package/src/internal/secret.ts +89 -0
  402. package/src/internal/singleShotGen.ts +35 -0
  403. package/src/internal/sink.ts +2120 -0
  404. package/src/internal/stack.ts +10 -0
  405. package/src/internal/stm/core.ts +817 -0
  406. package/src/internal/stm/entry.ts +59 -0
  407. package/src/internal/stm/journal.ts +123 -0
  408. package/src/internal/stm/opCodes/stm.ts +71 -0
  409. package/src/internal/stm/opCodes/stmState.ts +17 -0
  410. package/src/internal/stm/opCodes/strategy.ts +17 -0
  411. package/src/internal/stm/opCodes/tExit.ts +29 -0
  412. package/src/internal/stm/opCodes/tryCommit.ts +11 -0
  413. package/src/internal/stm/stm.ts +1453 -0
  414. package/src/internal/stm/stmState.ts +136 -0
  415. package/src/internal/stm/tArray.ts +550 -0
  416. package/src/internal/stm/tDeferred.ts +81 -0
  417. package/src/internal/stm/tExit.ts +190 -0
  418. package/src/internal/stm/tMap.ts +824 -0
  419. package/src/internal/stm/tPriorityQueue.ts +267 -0
  420. package/src/internal/stm/tPubSub.ts +551 -0
  421. package/src/internal/stm/tQueue.ts +393 -0
  422. package/src/internal/stm/tRandom.ts +140 -0
  423. package/src/internal/stm/tReentrantLock.ts +352 -0
  424. package/src/internal/stm/tRef.ts +195 -0
  425. package/src/internal/stm/tSemaphore.ts +113 -0
  426. package/src/internal/stm/tSet.ts +259 -0
  427. package/src/internal/stm/tSubscriptionRef.ts +286 -0
  428. package/src/internal/stm/tryCommit.ts +34 -0
  429. package/src/internal/stm/txnId.ts +14 -0
  430. package/src/internal/stm/versioned.ts +4 -0
  431. package/src/internal/stream/debounceState.ts +57 -0
  432. package/src/internal/stream/emit.ts +123 -0
  433. package/src/internal/stream/haltStrategy.ts +94 -0
  434. package/src/internal/stream/handoff.ts +187 -0
  435. package/src/internal/stream/handoffSignal.ts +59 -0
  436. package/src/internal/stream/pull.ts +34 -0
  437. package/src/internal/stream/sinkEndReason.ts +30 -0
  438. package/src/internal/stream/zipAllState.ts +88 -0
  439. package/src/internal/stream/zipChunksState.ts +56 -0
  440. package/src/internal/stream.ts +8801 -0
  441. package/src/internal/string-utils.ts +107 -0
  442. package/src/internal/subscriptionRef.ts +138 -0
  443. package/src/internal/supervisor/patch.ts +190 -0
  444. package/src/internal/supervisor.ts +303 -0
  445. package/src/internal/synchronizedRef.ts +114 -0
  446. package/src/internal/take.ts +199 -0
  447. package/src/internal/testing/sleep.ts +27 -0
  448. package/src/internal/testing/suspendedWarningData.ts +85 -0
  449. package/src/internal/testing/warningData.ts +94 -0
  450. package/src/internal/tracer.ts +150 -0
  451. package/src/internal/trie.ts +722 -0
  452. package/src/internal/version.ts +7 -0
package/src/Channel.ts ADDED
@@ -0,0 +1,2355 @@
1
+ /**
2
+ * @since 2.0.0
3
+ */
4
+ import type * as Cause from "./Cause.js"
5
+ import type * as ChildExecutorDecision from "./ChildExecutorDecision.js"
6
+ import type * as Chunk from "./Chunk.js"
7
+ import type * as Context from "./Context.js"
8
+ import type * as Deferred from "./Deferred.js"
9
+ import type * as Effect from "./Effect.js"
10
+ import type * as Either from "./Either.js"
11
+ import type * as Exit from "./Exit.js"
12
+ import type { LazyArg } from "./Function.js"
13
+ import * as channel from "./internal/channel.js"
14
+ import * as core from "./internal/core-stream.js"
15
+ import * as sink from "./internal/sink.js"
16
+ import * as stream from "./internal/stream.js"
17
+ import type * as Layer from "./Layer.js"
18
+ import type * as MergeDecision from "./MergeDecision.js"
19
+ import type * as MergeStrategy from "./MergeStrategy.js"
20
+ import type * as Option from "./Option.js"
21
+ import type { Pipeable } from "./Pipeable.js"
22
+ import type { Predicate } from "./Predicate.js"
23
+ import type * as PubSub from "./PubSub.js"
24
+ import type * as Queue from "./Queue.js"
25
+ import type * as Ref from "./Ref.js"
26
+ import type * as Scope from "./Scope.js"
27
+ import type * as SingleProducerAsyncInput from "./SingleProducerAsyncInput.js"
28
+ import type * as Sink from "./Sink.js"
29
+ import type * as Stream from "./Stream.js"
30
+ import type * as Tracer from "./Tracer.js"
31
+ import type * as Types from "./Types.js"
32
+ import type * as Unify from "./Unify.js"
33
+ import type * as UpstreamPullRequest from "./UpstreamPullRequest.js"
34
+ import type * as UpstreamPullStrategy from "./UpstreamPullStrategy.js"
35
+
36
+ /**
37
+ * @since 2.0.0
38
+ * @category symbols
39
+ */
40
+ export const ChannelTypeId: unique symbol = core.ChannelTypeId
41
+
42
+ /**
43
+ * @since 2.0.0
44
+ * @category symbols
45
+ */
46
+ export type ChannelTypeId = typeof ChannelTypeId
47
+
48
+ /**
49
+ * A `Channel` is a nexus of I/O operations, which supports both reading and
50
+ * writing. A channel may read values of type `InElem` and write values of type
51
+ * `OutElem`. When the channel finishes, it yields a value of type `OutDone`. A
52
+ * channel may fail with a value of type `OutErr`.
53
+ *
54
+ * Channels are the foundation of Streams: both streams and sinks are built on
55
+ * channels. Most users shouldn't have to use channels directly, as streams and
56
+ * sinks are much more convenient and cover all common use cases. However, when
57
+ * adding new stream and sink operators, or doing something highly specialized,
58
+ * it may be useful to use channels directly.
59
+ *
60
+ * Channels compose in a variety of ways:
61
+ *
62
+ * - **Piping**: One channel can be piped to another channel, assuming the
63
+ * input type of the second is the same as the output type of the first.
64
+ * - **Sequencing**: The terminal value of one channel can be used to create
65
+ * another channel, and both the first channel and the function that makes
66
+ * the second channel can be composed into a channel.
67
+ * - **Concatenating**: The output of one channel can be used to create other
68
+ * channels, which are all concatenated together. The first channel and the
69
+ * function that makes the other channels can be composed into a channel.
70
+ *
71
+ * @since 2.0.0
72
+ * @category models
73
+ */
74
+ // export interface Channel<out Env, in InErr, in InElem, in InDone, out OutErr, out OutElem, out OutDone>
75
+ export interface Channel<
76
+ out OutElem,
77
+ in InElem = unknown,
78
+ out OutErr = never,
79
+ in InErr = unknown,
80
+ out OutDone = void,
81
+ in InDone = unknown,
82
+ out Env = never
83
+ > extends
84
+ Channel.Variance<
85
+ OutElem,
86
+ InElem,
87
+ OutErr,
88
+ InErr,
89
+ OutDone,
90
+ InDone,
91
+ Env
92
+ >,
93
+ Pipeable
94
+ {
95
+ [Unify.typeSymbol]?: unknown
96
+ [Unify.unifySymbol]?: ChannelUnify<this>
97
+ [Unify.ignoreSymbol]?: ChannelUnifyIgnore
98
+ }
99
+
100
+ /**
101
+ * @since 2.0.0
102
+ * @category models
103
+ */
104
+ export interface ChannelUnify<A extends { [Unify.typeSymbol]?: any }> extends Effect.EffectUnify<A> {
105
+ Channel?: () => A[Unify.typeSymbol] extends
106
+ | Channel<
107
+ infer OutElem,
108
+ infer InElem,
109
+ infer OutErr,
110
+ infer InErr,
111
+ infer OutDone,
112
+ infer InDone,
113
+ infer Env
114
+ >
115
+ | infer _ ? Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
116
+ : never
117
+ }
118
+
119
+ /**
120
+ * @category models
121
+ * @since 2.0.0
122
+ */
123
+ export interface ChannelUnifyIgnore extends Effect.EffectUnifyIgnore {
124
+ Channel?: true
125
+ }
126
+
127
+ /**
128
+ * @since 2.0.0
129
+ * @category models
130
+ */
131
+ declare module "./Effect.js" {
132
+ interface Effect<A, E, R> extends Channel<never, unknown, E, unknown, A, unknown, R> {}
133
+ interface EffectUnifyIgnore {
134
+ Channel?: true
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @since 2.0.0
140
+ */
141
+ export declare namespace Channel {
142
+ /**
143
+ * @since 2.0.0
144
+ * @category models
145
+ */
146
+ export interface Variance<out OutElem, in InElem, out OutErr, in InErr, out OutDone, in InDone, out Env> {
147
+ readonly [ChannelTypeId]: VarianceStruct<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
148
+ }
149
+ /**
150
+ * @since 2.0.0
151
+ * @category models
152
+ */
153
+ export interface VarianceStruct<out OutElem, in InElem, out OutErr, in InErr, out OutDone, in InDone, out Env> {
154
+ _Env: Types.Covariant<Env>
155
+ _InErr: Types.Contravariant<InErr>
156
+ _InElem: Types.Contravariant<InElem>
157
+ _InDone: Types.Contravariant<InDone>
158
+ _OutErr: Types.Covariant<OutErr>
159
+ _OutElem: Types.Covariant<OutElem>
160
+ _OutDone: Types.Covariant<OutDone>
161
+ }
162
+ }
163
+
164
+ /**
165
+ * @since 2.0.0
166
+ * @category symbols
167
+ */
168
+ export const ChannelExceptionTypeId: unique symbol = channel.ChannelExceptionTypeId
169
+
170
+ /**
171
+ * @since 2.0.0
172
+ * @category symbols
173
+ */
174
+ export type ChannelExceptionTypeId = typeof ChannelExceptionTypeId
175
+
176
+ /**
177
+ * Represents a generic checked exception which occurs when a `Channel` is
178
+ * executed.
179
+ *
180
+ * @since 2.0.0
181
+ * @category models
182
+ */
183
+ export interface ChannelException<out E> {
184
+ readonly _tag: "ChannelException"
185
+ readonly [ChannelExceptionTypeId]: ChannelExceptionTypeId
186
+ readonly error: E
187
+ }
188
+
189
+ /**
190
+ * @since 3.5.4
191
+ * @category refinements
192
+ */
193
+ export const isChannel: (u: unknown) => u is Channel<
194
+ unknown,
195
+ unknown,
196
+ unknown,
197
+ unknown,
198
+ unknown,
199
+ unknown,
200
+ unknown
201
+ > = core.isChannel
202
+
203
+ /**
204
+ * @since 2.0.0
205
+ * @category constructors
206
+ */
207
+ export const acquireUseRelease: <Acquired, OutErr, Env, OutElem1, InElem, InErr, OutDone, InDone>(
208
+ acquire: Effect.Effect<Acquired, OutErr, Env>,
209
+ use: (a: Acquired) => Channel<OutElem1, InElem, OutErr, InErr, OutDone, InDone, Env>,
210
+ release: (a: Acquired, exit: Exit.Exit<OutDone, OutErr>) => Effect.Effect<any, never, Env>
211
+ ) => Channel<OutElem1, InElem, OutErr, InErr, OutDone, InDone, Env> = channel.acquireUseRelease
212
+
213
+ /**
214
+ * @since 2.0.0
215
+ * @category constructors
216
+ */
217
+ export const acquireReleaseOut: {
218
+ <Z, R2>(
219
+ release: (z: Z, e: Exit.Exit<unknown, unknown>) => Effect.Effect<unknown, never, R2>
220
+ ): <E, R>(self: Effect.Effect<Z, E, R>) => Channel<Z, unknown, E, unknown, void, unknown, R2 | R>
221
+ <Z, E, R, R2>(
222
+ self: Effect.Effect<Z, E, R>,
223
+ release: (z: Z, e: Exit.Exit<unknown, unknown>) => Effect.Effect<unknown, never, R2>
224
+ ): Channel<Z, unknown, E, unknown, void, unknown, R | R2>
225
+ } = core.acquireReleaseOut
226
+
227
+ /**
228
+ * Returns a new channel that is the same as this one, except the terminal
229
+ * value of the channel is the specified constant value.
230
+ *
231
+ * This method produces the same result as mapping this channel to the
232
+ * specified constant value.
233
+ *
234
+ * @since 2.0.0
235
+ * @category mapping
236
+ */
237
+ export const as: {
238
+ <OutDone2>(
239
+ value: OutDone2
240
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
241
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
242
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>
243
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutDone2>(
244
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
245
+ value: OutDone2
246
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>
247
+ } = channel.as
248
+
249
+ /**
250
+ * @since 2.0.0
251
+ * @category mapping
252
+ */
253
+ export const asVoid: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
254
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
255
+ ) => Channel<OutElem, InElem, OutErr, InErr, void, InDone, Env> = channel.asVoid
256
+
257
+ /**
258
+ * Creates a channel backed by a buffer. When the buffer is empty, the channel
259
+ * will simply passthrough its input as output. However, when the buffer is
260
+ * non-empty, the value inside the buffer will be passed along as output.
261
+ *
262
+ * @since 2.0.0
263
+ * @category constructors
264
+ */
265
+ export const buffer: <InElem, InErr, InDone>(
266
+ options: { readonly empty: InElem; readonly isEmpty: Predicate<InElem>; readonly ref: Ref.Ref<InElem> }
267
+ ) => Channel<InElem, InElem, InErr, InErr, InDone, InDone, never> = channel.buffer
268
+
269
+ /**
270
+ * @since 2.0.0
271
+ * @category constructors
272
+ */
273
+ export const bufferChunk: <InElem, InErr, InDone>(
274
+ ref: Ref.Ref<Chunk.Chunk<InElem>>
275
+ ) => Channel<Chunk.Chunk<InElem>, Chunk.Chunk<InElem>, InErr, InErr, InDone, InDone> = channel.bufferChunk
276
+
277
+ /**
278
+ * Returns a new channel that is the same as this one, except if this channel
279
+ * errors for any typed error, then the returned channel will switch over to
280
+ * using the fallback channel returned by the specified error handler.
281
+ *
282
+ * @since 2.0.0
283
+ * @category error handling
284
+ */
285
+ export const catchAll: {
286
+ <OutErr, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
287
+ f: (error: OutErr) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
288
+ ): <OutElem, InElem, InErr, OutDone, InDone, Env>(
289
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
290
+ ) => Channel<
291
+ OutElem1 | OutElem,
292
+ InElem & InElem1,
293
+ OutErr1,
294
+ InErr & InErr1,
295
+ OutDone1 | OutDone,
296
+ InDone & InDone1,
297
+ Env1 | Env
298
+ >
299
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
300
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
301
+ f: (error: OutErr) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
302
+ ): Channel<
303
+ OutElem | OutElem1,
304
+ InElem & InElem1,
305
+ OutErr1,
306
+ InErr & InErr1,
307
+ OutDone | OutDone1,
308
+ InDone & InDone1,
309
+ Env | Env1
310
+ >
311
+ } = channel.catchAll
312
+
313
+ /**
314
+ * Returns a new channel that is the same as this one, except if this channel
315
+ * errors for any typed error, then the returned channel will switch over to
316
+ * using the fallback channel returned by the specified error handler.
317
+ *
318
+ * @since 2.0.0
319
+ * @category error handling
320
+ */
321
+ export const catchAllCause: {
322
+ <OutErr, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
323
+ f: (cause: Cause.Cause<OutErr>) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
324
+ ): <OutElem, InElem, InErr, OutDone, InDone, Env>(
325
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
326
+ ) => Channel<
327
+ OutElem1 | OutElem,
328
+ InElem & InElem1,
329
+ OutErr1,
330
+ InErr & InErr1,
331
+ OutDone1 | OutDone,
332
+ InDone & InDone1,
333
+ Env1 | Env
334
+ >
335
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
336
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
337
+ f: (cause: Cause.Cause<OutErr>) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
338
+ ): Channel<
339
+ OutElem | OutElem1,
340
+ InElem & InElem1,
341
+ OutErr1,
342
+ InErr & InErr1,
343
+ OutDone | OutDone1,
344
+ InDone & InDone1,
345
+ Env | Env1
346
+ >
347
+ } = core.catchAllCause
348
+
349
+ /**
350
+ * Concat sequentially a channel of channels.
351
+ *
352
+ * @since 2.0.0
353
+ * @category constructors
354
+ */
355
+ export const concatAll: <OutElem, InElem, OutErr, InErr, InDone, Env>(
356
+ channels: Channel<Channel<OutElem, InElem, OutErr, InErr, any, InDone, Env>, InElem, OutErr, InErr, any, InDone, Env>
357
+ ) => Channel<OutElem, InElem, OutErr, InErr, any, InDone, Env> = core.concatAll
358
+
359
+ /**
360
+ * Concat sequentially a channel of channels.
361
+ *
362
+ * @since 2.0.0
363
+ * @category constructors
364
+ */
365
+ export const concatAllWith: <
366
+ OutElem,
367
+ InElem2,
368
+ OutErr2,
369
+ InErr2,
370
+ OutDone,
371
+ InDone2,
372
+ Env2,
373
+ InElem,
374
+ OutErr,
375
+ InErr,
376
+ OutDone2,
377
+ InDone,
378
+ Env,
379
+ OutDone3
380
+ >(
381
+ channels: Channel<
382
+ Channel<OutElem, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2>,
383
+ InElem,
384
+ OutErr,
385
+ InErr,
386
+ OutDone2,
387
+ InDone,
388
+ Env
389
+ >,
390
+ f: (o: OutDone, o1: OutDone) => OutDone,
391
+ g: (o: OutDone, o2: OutDone2) => OutDone3
392
+ ) => Channel<OutElem, InElem & InElem2, OutErr2 | OutErr, InErr & InErr2, OutDone3, InDone & InDone2, Env2 | Env> =
393
+ core.concatAllWith
394
+
395
+ /**
396
+ * Returns a new channel whose outputs are fed to the specified factory
397
+ * function, which creates new channels in response. These new channels are
398
+ * sequentially concatenated together, and all their outputs appear as outputs
399
+ * of the newly returned channel.
400
+ *
401
+ * @since 2.0.0
402
+ * @category utils
403
+ */
404
+ export const concatMap: {
405
+ <OutElem, OutElem2, InElem2, OutErr2, InErr2, X, InDone2, Env2>(
406
+ f: (o: OutElem) => Channel<OutElem2, InElem2, OutErr2, InErr2, X, InDone2, Env2>
407
+ ): <Env, InErr, InElem, InDone, OutErr, OutDone>(
408
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
409
+ ) => Channel<OutElem2, InElem & InElem2, OutErr2 | OutErr, InErr & InErr2, unknown, InDone & InDone2, Env2 | Env>
410
+ <Env, InErr, InElem, InDone, OutErr, OutDone, OutElem, OutElem2, Env2, InErr2, InElem2, InDone2, OutErr2, X>(
411
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
412
+ f: (o: OutElem) => Channel<OutElem2, InElem2, OutErr2, InErr2, X, InDone2, Env2>
413
+ ): Channel<OutElem2, InElem & InElem2, OutErr | OutErr2, InErr & InErr2, unknown, InDone & InDone2, Env | Env2>
414
+ } = channel.concatMap
415
+
416
+ /**
417
+ * Returns a new channel whose outputs are fed to the specified factory
418
+ * function, which creates new channels in response. These new channels are
419
+ * sequentially concatenated together, and all their outputs appear as outputs
420
+ * of the newly returned channel. The provided merging function is used to
421
+ * merge the terminal values of all channels into the single terminal value of
422
+ * the returned channel.
423
+ *
424
+ * @since 2.0.0
425
+ * @category utils
426
+ */
427
+ export const concatMapWith: {
428
+ <OutElem, OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2, OutDone2, OutDone3>(
429
+ f: (o: OutElem) => Channel<OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2>,
430
+ g: (o: OutDone, o1: OutDone) => OutDone,
431
+ h: (o: OutDone, o2: OutDone2) => OutDone3
432
+ ): <Env, InErr, InElem, InDone, OutErr>(
433
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>
434
+ ) => Channel<OutElem2, InElem & InElem2, OutErr2 | OutErr, InErr & InErr2, OutDone3, InDone & InDone2, Env2 | Env>
435
+ <
436
+ OutElem,
437
+ InElem,
438
+ OutErr,
439
+ InErr,
440
+ OutDone2,
441
+ InDone,
442
+ Env,
443
+ OutElem2,
444
+ InElem2,
445
+ OutErr2,
446
+ InErr2,
447
+ OutDone,
448
+ InDone2,
449
+ Env2,
450
+ OutDone3
451
+ >(
452
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>,
453
+ f: (o: OutElem) => Channel<OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2>,
454
+ g: (o: OutDone, o1: OutDone) => OutDone,
455
+ h: (o: OutDone, o2: OutDone2) => OutDone3
456
+ ): Channel<OutElem2, InElem & InElem2, OutErr | OutErr2, InErr & InErr2, OutDone3, InDone & InDone2, Env | Env2>
457
+ } = core.concatMapWith
458
+
459
+ /**
460
+ * Returns a new channel whose outputs are fed to the specified factory
461
+ * function, which creates new channels in response. These new channels are
462
+ * sequentially concatenated together, and all their outputs appear as outputs
463
+ * of the newly returned channel. The provided merging function is used to
464
+ * merge the terminal values of all channels into the single terminal value of
465
+ * the returned channel.
466
+ *
467
+ * @since 2.0.0
468
+ * @category utils
469
+ */
470
+ export const concatMapWithCustom: {
471
+ <OutElem, OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2, OutDone2, OutDone3>(
472
+ f: (o: OutElem) => Channel<OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2>,
473
+ g: (o: OutDone, o1: OutDone) => OutDone,
474
+ h: (o: OutDone, o2: OutDone2) => OutDone3,
475
+ onPull: (
476
+ upstreamPullRequest: UpstreamPullRequest.UpstreamPullRequest<OutElem>
477
+ ) => UpstreamPullStrategy.UpstreamPullStrategy<OutElem2>,
478
+ onEmit: (elem: OutElem2) => ChildExecutorDecision.ChildExecutorDecision
479
+ ): <Env, InErr, InElem, InDone, OutErr>(
480
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>
481
+ ) => Channel<OutElem2, InElem & InElem2, OutErr2 | OutErr, InErr & InErr2, OutDone3, InDone & InDone2, Env2 | Env>
482
+ <
483
+ OutElem,
484
+ InElem,
485
+ OutErr,
486
+ InErr,
487
+ OutDone2,
488
+ InDone,
489
+ Env,
490
+ OutElem2,
491
+ InElem2,
492
+ OutErr2,
493
+ InErr2,
494
+ OutDone,
495
+ InDone2,
496
+ Env2,
497
+ OutDone3
498
+ >(
499
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>,
500
+ f: (o: OutElem) => Channel<OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2>,
501
+ g: (o: OutDone, o1: OutDone) => OutDone,
502
+ h: (o: OutDone, o2: OutDone2) => OutDone3,
503
+ onPull: (
504
+ upstreamPullRequest: UpstreamPullRequest.UpstreamPullRequest<OutElem>
505
+ ) => UpstreamPullStrategy.UpstreamPullStrategy<OutElem2>,
506
+ onEmit: (elem: OutElem2) => ChildExecutorDecision.ChildExecutorDecision
507
+ ): Channel<OutElem2, InElem & InElem2, OutErr | OutErr2, InErr & InErr2, OutDone3, InDone & InDone2, Env | Env2>
508
+ } = core.concatMapWithCustom
509
+
510
+ /**
511
+ * Returns a new channel, which is the same as this one, except its outputs
512
+ * are filtered and transformed by the specified partial function.
513
+ *
514
+ * @since 2.0.0
515
+ * @category utils
516
+ */
517
+ export const collect: {
518
+ <OutElem, OutElem2>(
519
+ pf: (o: OutElem) => Option.Option<OutElem2>
520
+ ): <InElem, OutErr, InErr, OutDone, InDone, Env>(
521
+ self: Channel<OutElem, unknown, never, unknown, void, unknown, never>
522
+ ) => Channel<OutElem2, InElem, OutErr, InErr, OutDone, InDone, Env>
523
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem2>(
524
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
525
+ pf: (o: OutElem) => Option.Option<OutElem2>
526
+ ): Channel<OutElem2, InElem, OutErr, InErr, OutDone, InDone, Env>
527
+ } = channel.collect
528
+
529
+ /**
530
+ * Returns a new channel, which is the concatenation of all the channels that
531
+ * are written out by this channel. This method may only be called on channels
532
+ * that output other channels.
533
+ *
534
+ * @since 2.0.0
535
+ * @category utils
536
+ */
537
+ export const concatOut: <OutElem, InElem, OutErr, InErr, InDone, Env, OutDone>(
538
+ self: Channel<
539
+ Channel<OutElem, InElem, OutErr, InErr, unknown, InDone, Env>,
540
+ InElem,
541
+ OutErr,
542
+ InErr,
543
+ OutDone,
544
+ InDone,
545
+ Env
546
+ >
547
+ ) => Channel<OutElem, InElem, OutErr, InErr, unknown, InDone, Env> = channel.concatOut
548
+
549
+ /**
550
+ * Returns a new channel which is the same as this one but applies the given
551
+ * function to the input channel's done value.
552
+ *
553
+ * @since 2.0.0
554
+ * @category utils
555
+ */
556
+ export const mapInput: {
557
+ <InDone0, InDone>(
558
+ f: (a: InDone0) => InDone
559
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
560
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
561
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone0, Env>
562
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, InDone0>(
563
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
564
+ f: (a: InDone0) => InDone
565
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone0, Env>
566
+ } = channel.mapInput
567
+
568
+ /**
569
+ * Returns a new channel which is the same as this one but applies the given
570
+ * effectual function to the input channel's done value.
571
+ *
572
+ * @since 2.0.0
573
+ * @category utils
574
+ */
575
+ export const mapInputEffect: {
576
+ <InDone0, InDone, InErr, Env1>(
577
+ f: (i: InDone0) => Effect.Effect<InDone, InErr, Env1>
578
+ ): <OutElem, InElem, OutErr, OutDone, Env>(
579
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
580
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone0, Env1 | Env>
581
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, InDone0, Env1>(
582
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
583
+ f: (i: InDone0) => Effect.Effect<InDone, InErr, Env1>
584
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone0, Env | Env1>
585
+ } = channel.mapInputEffect
586
+
587
+ /**
588
+ * Returns a new channel which is the same as this one but applies the given
589
+ * function to the input channel's error value.
590
+ *
591
+ * @since 2.0.0
592
+ * @category utils
593
+ */
594
+ export const mapInputError: {
595
+ <InErr0, InErr>(
596
+ f: (a: InErr0) => InErr
597
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
598
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
599
+ ) => Channel<OutElem, InElem, OutErr, InErr0, OutDone, InDone, Env>
600
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, InErr0>(
601
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
602
+ f: (a: InErr0) => InErr
603
+ ): Channel<OutElem, InElem, OutErr, InErr0, OutDone, InDone, Env>
604
+ } = channel.mapInputError
605
+
606
+ /**
607
+ * Returns a new channel which is the same as this one but applies the given
608
+ * effectual function to the input channel's error value.
609
+ *
610
+ * @since 2.0.0
611
+ * @category utils
612
+ */
613
+ export const mapInputErrorEffect: {
614
+ <InErr0, InDone, InErr, Env1>(
615
+ f: (error: InErr0) => Effect.Effect<InDone, InErr, Env1>
616
+ ): <OutElem, InElem, OutErr, OutDone, Env>(
617
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
618
+ ) => Channel<OutElem, InElem, OutErr, InErr0, OutDone, InDone, Env1 | Env>
619
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, InErr0, Env1>(
620
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
621
+ f: (error: InErr0) => Effect.Effect<InDone, InErr, Env1>
622
+ ): Channel<OutElem, InElem, OutErr, InErr0, OutDone, InDone, Env | Env1>
623
+ } = channel.mapInputErrorEffect
624
+
625
+ /**
626
+ * Returns a new channel which is the same as this one but applies the given
627
+ * function to the input channel's output elements.
628
+ *
629
+ * @since 2.0.0
630
+ * @category utils
631
+ */
632
+ export const mapInputIn: {
633
+ <InElem0, InElem>(
634
+ f: (a: InElem0) => InElem
635
+ ): <OutElem, OutErr, InErr, OutDone, InDone, Env>(
636
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
637
+ ) => Channel<OutElem, InElem0, OutErr, InErr, OutDone, InDone, Env>
638
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, InElem0>(
639
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
640
+ f: (a: InElem0) => InElem
641
+ ): Channel<OutElem, InElem0, OutErr, InErr, OutDone, InDone, Env>
642
+ } = channel.mapInputIn
643
+
644
+ /**
645
+ * Returns a new channel which is the same as this one but applies the given
646
+ * effectual function to the input channel's output elements.
647
+ *
648
+ * @since 2.0.0
649
+ * @category utils
650
+ */
651
+ export const mapInputInEffect: {
652
+ <InElem0, InElem, InErr, Env1>(
653
+ f: (a: InElem0) => Effect.Effect<InElem, InErr, Env1>
654
+ ): <OutElem, OutErr, OutDone, InDone, Env>(
655
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
656
+ ) => Channel<OutElem, InElem0, OutErr, InErr, OutDone, InDone, Env1 | Env>
657
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, InElem0, Env1>(
658
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
659
+ f: (a: InElem0) => Effect.Effect<InElem, InErr, Env1>
660
+ ): Channel<OutElem, InElem0, OutErr, InErr, OutDone, InDone, Env | Env1>
661
+ } = channel.mapInputInEffect
662
+
663
+ /**
664
+ * Returns a new channel, which is the same as this one, except that all the
665
+ * outputs are collected and bundled into a tuple together with the terminal
666
+ * value of this channel.
667
+ *
668
+ * As the channel returned from this channel collects all of this channel's
669
+ * output into an in- memory chunk, it is not safe to call this method on
670
+ * channels that output a large or unbounded number of values.
671
+ *
672
+ * @since 2.0.0
673
+ * @category utils
674
+ */
675
+ export const doneCollect: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
676
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
677
+ ) => Channel<never, InElem, OutErr, InErr, [Chunk.Chunk<OutElem>, OutDone], InDone, Env> = channel.doneCollect
678
+
679
+ /**
680
+ * Returns a new channel which reads all the elements from upstream's output
681
+ * channel and ignores them, then terminates with the upstream result value.
682
+ *
683
+ * @since 2.0.0
684
+ * @category utils
685
+ */
686
+ export const drain: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
687
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
688
+ ) => Channel<never, InElem, OutErr, InErr, OutDone, InDone, Env> = channel.drain
689
+
690
+ /**
691
+ * Returns a new channel which connects the given `AsyncInputProducer` as
692
+ * this channel's input.
693
+ *
694
+ * @since 2.0.0
695
+ * @category utils
696
+ */
697
+ export const embedInput: {
698
+ <InErr, InElem, InDone>(
699
+ input: SingleProducerAsyncInput.AsyncInputProducer<InErr, InElem, InDone>
700
+ ): <OutElem, OutErr, OutDone, Env>(
701
+ self: Channel<OutElem, unknown, OutErr, unknown, OutDone, unknown, Env>
702
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
703
+ <OutElem, OutErr, OutDone, Env, InErr, InElem, InDone>(
704
+ self: Channel<OutElem, unknown, OutErr, unknown, OutDone, unknown, Env>,
705
+ input: SingleProducerAsyncInput.AsyncInputProducer<InErr, InElem, InDone>
706
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
707
+ } = core.embedInput
708
+
709
+ /**
710
+ * Returns a new channel that collects the output and terminal value of this
711
+ * channel, which it then writes as output of the returned channel.
712
+ *
713
+ * @since 2.0.0
714
+ * @category utils
715
+ */
716
+ export const emitCollect: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
717
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
718
+ ) => Channel<[Chunk.Chunk<OutElem>, OutDone], InElem, OutErr, InErr, void, InDone, Env> = channel.emitCollect
719
+
720
+ /**
721
+ * Returns a new channel with an attached finalizer. The finalizer is
722
+ * guaranteed to be executed so long as the channel begins execution (and
723
+ * regardless of whether or not it completes).
724
+ *
725
+ * @since 2.0.0
726
+ * @category utils
727
+ */
728
+ export const ensuring: {
729
+ <Z, Env1>(
730
+ finalizer: Effect.Effect<Z, never, Env1>
731
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
732
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
733
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env1 | Env>
734
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, Z, Env1>(
735
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
736
+ finalizer: Effect.Effect<Z, never, Env1>
737
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | Env1>
738
+ } = channel.ensuring
739
+
740
+ /**
741
+ * Returns a new channel with an attached finalizer. The finalizer is
742
+ * guaranteed to be executed so long as the channel begins execution (and
743
+ * regardless of whether or not it completes).
744
+ *
745
+ * @since 2.0.0
746
+ * @category utils
747
+ */
748
+ export const ensuringWith: {
749
+ <OutDone, OutErr, Env2>(
750
+ finalizer: (e: Exit.Exit<OutDone, OutErr>) => Effect.Effect<unknown, never, Env2>
751
+ ): <OutElem, InElem, InErr, InDone, Env>(
752
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
753
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env2 | Env>
754
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, Env2>(
755
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
756
+ finalizer: (e: Exit.Exit<OutDone, OutErr>) => Effect.Effect<unknown, never, Env2>
757
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | Env2>
758
+ } = core.ensuringWith
759
+
760
+ /**
761
+ * Accesses the whole context of the channel.
762
+ *
763
+ * @since 2.0.0
764
+ * @category context
765
+ */
766
+ export const context: <Env>() => Channel<never, unknown, never, unknown, Context.Context<Env>, unknown, Env> =
767
+ channel.context
768
+
769
+ /**
770
+ * Accesses the context of the channel with the specified function.
771
+ *
772
+ * @since 2.0.0
773
+ * @category context
774
+ */
775
+ export const contextWith: <Env, OutDone>(
776
+ f: (env: Context.Context<Env>) => OutDone
777
+ ) => Channel<never, unknown, never, unknown, OutDone, unknown, Env> = channel.contextWith
778
+
779
+ /**
780
+ * Accesses the context of the channel in the context of a channel.
781
+ *
782
+ * @since 2.0.0
783
+ * @category context
784
+ */
785
+ export const contextWithChannel: <Env, OutElem, InElem, OutErr, InErr, OutDone, InDone, Env1>(
786
+ f: (env: Context.Context<Env>) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env1>
787
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | Env1> = channel.contextWithChannel
788
+
789
+ /**
790
+ * Accesses the context of the channel in the context of an effect.
791
+ *
792
+ * @since 2.0.0
793
+ * @category context
794
+ */
795
+ export const contextWithEffect: <Env, OutDone, OutErr, Env1>(
796
+ f: (env: Context.Context<Env>) => Effect.Effect<OutDone, OutErr, Env1>
797
+ ) => Channel<never, unknown, OutErr, unknown, OutDone, unknown, Env | Env1> = channel.contextWithEffect
798
+
799
+ /**
800
+ * Constructs a channel that fails immediately with the specified error.
801
+ *
802
+ * @since 2.0.0
803
+ * @category constructors
804
+ */
805
+ export const fail: <E>(error: E) => Channel<never, unknown, E, unknown, never, unknown> = core.fail
806
+
807
+ /**
808
+ * Constructs a channel that succeeds immediately with the specified lazily
809
+ * evaluated value.
810
+ *
811
+ * @since 2.0.0
812
+ * @category constructors
813
+ */
814
+ export const failSync: <E>(evaluate: LazyArg<E>) => Channel<never, unknown, E, unknown, never, unknown> = core.failSync
815
+
816
+ /**
817
+ * Constructs a channel that fails immediately with the specified `Cause`.
818
+ *
819
+ * @since 2.0.0
820
+ * @category constructors
821
+ */
822
+ export const failCause: <E>(cause: Cause.Cause<E>) => Channel<never, unknown, E, unknown, never, unknown> =
823
+ core.failCause
824
+
825
+ /**
826
+ * Constructs a channel that succeeds immediately with the specified lazily
827
+ * evaluated `Cause`.
828
+ *
829
+ * @since 2.0.0
830
+ * @category constructors
831
+ */
832
+ export const failCauseSync: <E>(
833
+ evaluate: LazyArg<Cause.Cause<E>>
834
+ ) => Channel<never, unknown, E, unknown, never, unknown> = core.failCauseSync
835
+
836
+ /**
837
+ * Returns a new channel, which sequentially combines this channel, together
838
+ * with the provided factory function, which creates a second channel based on
839
+ * the terminal value of this channel. The result is a channel that will first
840
+ * perform the functions of this channel, before performing the functions of
841
+ * the created channel (including yielding its terminal value).
842
+ *
843
+ * @since 2.0.0
844
+ * @category sequencing
845
+ */
846
+ export const flatMap: {
847
+ <OutDone, OutElem1, InElem1, OutErr1, InErr1, OutDone2, InDone1, Env1>(
848
+ f: (d: OutDone) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone2, InDone1, Env1>
849
+ ): <OutElem, InElem, OutErr, InErr, InDone, Env>(
850
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
851
+ ) => Channel<
852
+ OutElem1 | OutElem,
853
+ InElem & InElem1,
854
+ OutErr1 | OutErr,
855
+ InErr & InErr1,
856
+ OutDone2,
857
+ InDone & InDone1,
858
+ Env1 | Env
859
+ >
860
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone2, InDone1, Env1>(
861
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
862
+ f: (d: OutDone) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone2, InDone1, Env1>
863
+ ): Channel<
864
+ OutElem | OutElem1,
865
+ InElem & InElem1,
866
+ OutErr | OutErr1,
867
+ InErr & InErr1,
868
+ OutDone2,
869
+ InDone & InDone1,
870
+ Env | Env1
871
+ >
872
+ } = core.flatMap
873
+
874
+ /**
875
+ * Returns a new channel, which flattens the terminal value of this channel.
876
+ * This function may only be called if the terminal value of this channel is
877
+ * another channel of compatible types.
878
+ *
879
+ * @since 2.0.0
880
+ * @category sequencing
881
+ */
882
+ export const flatten: <
883
+ OutElem,
884
+ InElem,
885
+ OutErr,
886
+ InErr,
887
+ OutElem1,
888
+ InElem1,
889
+ OutErr1,
890
+ InErr1,
891
+ OutDone2,
892
+ InDone1,
893
+ Env1,
894
+ InDone,
895
+ Env
896
+ >(
897
+ self: Channel<
898
+ OutElem,
899
+ InElem,
900
+ OutErr,
901
+ InErr,
902
+ Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone2, InDone1, Env1>,
903
+ InDone,
904
+ Env
905
+ >
906
+ ) => Channel<
907
+ OutElem | OutElem1,
908
+ InElem & InElem1,
909
+ OutErr | OutErr1,
910
+ InErr & InErr1,
911
+ OutDone2,
912
+ InDone & InDone1,
913
+ Env1 | Env
914
+ > = channel.flatten
915
+
916
+ /**
917
+ * Folds over the result of this channel.
918
+ *
919
+ * @since 2.0.0
920
+ * @category utils
921
+ */
922
+ export const foldChannel: {
923
+ <
924
+ OutErr,
925
+ OutElem1,
926
+ InElem1,
927
+ OutErr1,
928
+ InErr1,
929
+ OutDone1,
930
+ InDone1,
931
+ Env1,
932
+ OutDone,
933
+ OutElem2,
934
+ InElem2,
935
+ OutErr2,
936
+ InErr2,
937
+ OutDone2,
938
+ InDone2,
939
+ Env2
940
+ >(
941
+ options: {
942
+ readonly onFailure: (error: OutErr) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
943
+ readonly onSuccess: (done: OutDone) => Channel<OutElem2, InElem2, OutErr2, InErr2, OutDone2, InDone2, Env2>
944
+ }
945
+ ): <Env, InErr, InElem, InDone, OutElem>(
946
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
947
+ ) => Channel<
948
+ OutElem1 | OutElem2 | OutElem,
949
+ InElem & InElem1 & InElem2,
950
+ OutErr1 | OutErr2,
951
+ InErr & InErr1 & InErr2,
952
+ OutDone1 | OutDone2,
953
+ InDone & InDone1 & InDone2,
954
+ Env1 | Env2 | Env
955
+ >
956
+ <
957
+ OutElem,
958
+ InElem,
959
+ OutErr,
960
+ InErr,
961
+ OutDone,
962
+ InDone,
963
+ Env,
964
+ OutElem1,
965
+ InElem1,
966
+ OutErr1,
967
+ InErr1,
968
+ OutDone1,
969
+ InDone1,
970
+ Env1,
971
+ OutElem2,
972
+ InElem2,
973
+ OutErr2,
974
+ InErr2,
975
+ OutDone2,
976
+ InDone2,
977
+ Env2
978
+ >(
979
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
980
+ options: {
981
+ readonly onFailure: (error: OutErr) => Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
982
+ readonly onSuccess: (done: OutDone) => Channel<OutElem2, InElem2, OutErr2, InErr2, OutDone2, InDone2, Env2>
983
+ }
984
+ ): Channel<
985
+ OutElem | OutElem1 | OutElem2,
986
+ InElem & InElem1 & InElem2,
987
+ OutErr1 | OutErr2,
988
+ InErr & InErr1 & InErr2,
989
+ OutDone1 | OutDone2,
990
+ InDone & InDone1 & InDone2,
991
+ Env | Env1 | Env2
992
+ >
993
+ } = channel.foldChannel
994
+
995
+ /**
996
+ * Folds over the result of this channel including any cause of termination.
997
+ *
998
+ * @since 2.0.0
999
+ * @category utils
1000
+ */
1001
+ export const foldCauseChannel: {
1002
+ <
1003
+ OutErr,
1004
+ OutElem1,
1005
+ InElem1,
1006
+ OutErr2,
1007
+ InErr1,
1008
+ OutDone2,
1009
+ InDone1,
1010
+ Env1,
1011
+ OutDone,
1012
+ OutElem2,
1013
+ InElem2,
1014
+ OutErr3,
1015
+ InErr2,
1016
+ OutDone3,
1017
+ InDone2,
1018
+ Env2
1019
+ >(
1020
+ options: {
1021
+ readonly onFailure: (
1022
+ c: Cause.Cause<OutErr>
1023
+ ) => Channel<OutElem1, InElem1, OutErr2, InErr1, OutDone2, InDone1, Env1>
1024
+ readonly onSuccess: (o: OutDone) => Channel<OutElem2, InElem2, OutErr3, InErr2, OutDone3, InDone2, Env2>
1025
+ }
1026
+ ): <Env, InErr, InElem, InDone, OutElem>(
1027
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1028
+ ) => Channel<
1029
+ OutElem1 | OutElem2 | OutElem,
1030
+ InElem & InElem1 & InElem2,
1031
+ OutErr2 | OutErr3,
1032
+ InErr & InErr1 & InErr2,
1033
+ OutDone2 | OutDone3,
1034
+ InDone & InDone1 & InDone2,
1035
+ Env1 | Env2 | Env
1036
+ >
1037
+ <
1038
+ OutElem,
1039
+ InElem,
1040
+ OutErr,
1041
+ InErr,
1042
+ OutDone,
1043
+ InDone,
1044
+ Env,
1045
+ OutElem1,
1046
+ InElem1,
1047
+ OutErr2,
1048
+ InErr1,
1049
+ OutDone2,
1050
+ InDone1,
1051
+ Env1,
1052
+ OutElem2,
1053
+ InElem2,
1054
+ OutErr3,
1055
+ InErr2,
1056
+ OutDone3,
1057
+ InDone2,
1058
+ Env2
1059
+ >(
1060
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1061
+ options: {
1062
+ readonly onFailure: (
1063
+ c: Cause.Cause<OutErr>
1064
+ ) => Channel<OutElem1, InElem1, OutErr2, InErr1, OutDone2, InDone1, Env1>
1065
+ readonly onSuccess: (o: OutDone) => Channel<OutElem2, InElem2, OutErr3, InErr2, OutDone3, InDone2, Env2>
1066
+ }
1067
+ ): Channel<
1068
+ OutElem | OutElem1 | OutElem2,
1069
+ InElem & InElem1 & InElem2,
1070
+ OutErr2 | OutErr3,
1071
+ InErr & InErr1 & InErr2,
1072
+ OutDone2 | OutDone3,
1073
+ InDone & InDone1 & InDone2,
1074
+ Env | Env1 | Env2
1075
+ >
1076
+ } = core.foldCauseChannel
1077
+
1078
+ /**
1079
+ * Use an effect to end a channel.
1080
+ *
1081
+ * @since 2.0.0
1082
+ * @category constructors
1083
+ */
1084
+ export const fromEffect: <A, E, R>(
1085
+ effect: Effect.Effect<A, E, R>
1086
+ ) => Channel<never, unknown, E, unknown, A, unknown, R> = core.fromEffect
1087
+
1088
+ /**
1089
+ * Constructs a channel from an `Either`.
1090
+ *
1091
+ * @since 2.0.0
1092
+ * @category constructors
1093
+ */
1094
+ export const fromEither: <R, L>(either: Either.Either<R, L>) => Channel<never, unknown, L, unknown, R, unknown> =
1095
+ channel.fromEither
1096
+
1097
+ /**
1098
+ * Construct a `Channel` from an `AsyncInputConsumer`.
1099
+ *
1100
+ * @since 2.0.0
1101
+ * @category constructors
1102
+ */
1103
+ export const fromInput: <Err, Elem, Done>(
1104
+ input: SingleProducerAsyncInput.AsyncInputConsumer<Err, Elem, Done>
1105
+ ) => Channel<Elem, unknown, Err, unknown, Done, unknown> = channel.fromInput
1106
+
1107
+ /**
1108
+ * Construct a `Channel` from a `PubSub`.
1109
+ *
1110
+ * @since 2.0.0
1111
+ * @category constructors
1112
+ */
1113
+ export const fromPubSub: <Done, Err, Elem>(
1114
+ pubsub: PubSub.PubSub<Either.Either<Elem, Exit.Exit<Done, Err>>>
1115
+ ) => Channel<Elem, unknown, Err, unknown, Done, unknown> = channel.fromPubSub
1116
+
1117
+ /**
1118
+ * Construct a `Channel` from a `PubSub` within a scoped effect.
1119
+ *
1120
+ * @since 2.0.0
1121
+ * @category constructors
1122
+ */
1123
+ export const fromPubSubScoped: <Done, Err, Elem>(
1124
+ pubsub: PubSub.PubSub<Either.Either<Elem, Exit.Exit<Done, Err>>>
1125
+ ) => Effect.Effect<Channel<Elem, unknown, Err, unknown, Done, unknown>, never, Scope.Scope> = channel.fromPubSubScoped
1126
+
1127
+ /**
1128
+ * Construct a `Channel` from an `Option`.
1129
+ *
1130
+ * @since 2.0.0
1131
+ * @category constructors
1132
+ */
1133
+ export const fromOption: <A>(
1134
+ option: Option.Option<A>
1135
+ ) => Channel<never, unknown, Option.Option<never>, unknown, A, unknown> = channel.fromOption
1136
+
1137
+ /**
1138
+ * Construct a `Channel` from a `Queue`.
1139
+ *
1140
+ * @since 2.0.0
1141
+ * @category constructors
1142
+ */
1143
+ export const fromQueue: <Done, Err, Elem>(
1144
+ queue: Queue.Dequeue<Either.Either<Elem, Exit.Exit<Done, Err>>>
1145
+ ) => Channel<Elem, unknown, Err, unknown, Done, unknown> = channel.fromQueue
1146
+
1147
+ /**
1148
+ * @since 2.0.0
1149
+ * @category constructors
1150
+ */
1151
+ export const identity: <Elem, Err, Done>() => Channel<Elem, Elem, Err, Err, Done, Done> = channel.identityChannel
1152
+
1153
+ /**
1154
+ * Returns a new channel, which is the same as this one, except it will be
1155
+ * interrupted when the specified effect completes. If the effect completes
1156
+ * successfully before the underlying channel is done, then the returned
1157
+ * channel will yield the success value of the effect as its terminal value.
1158
+ * On the other hand, if the underlying channel finishes first, then the
1159
+ * returned channel will yield the success value of the underlying channel as
1160
+ * its terminal value.
1161
+ *
1162
+ * @since 2.0.0
1163
+ * @category utils
1164
+ */
1165
+ export const interruptWhen: {
1166
+ <OutDone1, OutErr1, Env1>(
1167
+ effect: Effect.Effect<OutDone1, OutErr1, Env1>
1168
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1169
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1170
+ ) => Channel<OutElem, InElem, OutErr1 | OutErr, InErr, OutDone1 | OutDone, InDone, Env1 | Env>
1171
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutDone1, OutErr1, Env1>(
1172
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1173
+ effect: Effect.Effect<OutDone1, OutErr1, Env1>
1174
+ ): Channel<OutElem, InElem, OutErr | OutErr1, InErr, OutDone | OutDone1, InDone, Env | Env1>
1175
+ } = channel.interruptWhen
1176
+
1177
+ /**
1178
+ * Returns a new channel, which is the same as this one, except it will be
1179
+ * interrupted when the specified deferred is completed. If the deferred is
1180
+ * completed before the underlying channel is done, then the returned channel
1181
+ * will yield the value of the deferred. Otherwise, if the underlying channel
1182
+ * finishes first, then the returned channel will yield the value of the
1183
+ * underlying channel.
1184
+ *
1185
+ * @since 2.0.0
1186
+ * @category utils
1187
+ */
1188
+ export const interruptWhenDeferred: {
1189
+ <OutDone1, OutErr1>(
1190
+ deferred: Deferred.Deferred<OutDone1, OutErr1>
1191
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1192
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1193
+ ) => Channel<OutElem, InElem, OutErr1 | OutErr, InErr, OutDone1 | OutDone, InDone, Env>
1194
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutDone1, OutErr1>(
1195
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1196
+ deferred: Deferred.Deferred<OutDone1, OutErr1>
1197
+ ): Channel<OutElem, InElem, OutErr | OutErr1, InErr, OutDone | OutDone1, InDone, Env>
1198
+ } = channel.interruptWhenDeferred
1199
+
1200
+ /**
1201
+ * Returns a new channel, which is the same as this one, except the terminal
1202
+ * value of the returned channel is created by applying the specified function
1203
+ * to the terminal value of this channel.
1204
+ *
1205
+ * @since 2.0.0
1206
+ * @category mapping
1207
+ */
1208
+ export const map: {
1209
+ <OutDone, OutDone2>(
1210
+ f: (out: OutDone) => OutDone2
1211
+ ): <OutElem, InElem, OutErr, InErr, InDone, Env>(
1212
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1213
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>
1214
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutDone2>(
1215
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1216
+ f: (out: OutDone) => OutDone2
1217
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env>
1218
+ } = channel.map
1219
+
1220
+ /**
1221
+ * Returns a new channel, which is the same as this one, except the terminal
1222
+ * value of the returned channel is created by applying the specified
1223
+ * effectful function to the terminal value of this channel.
1224
+ *
1225
+ * @since 2.0.0
1226
+ * @category mapping
1227
+ */
1228
+ export const mapEffect: {
1229
+ <OutDone, OutDone1, OutErr1, Env1>(
1230
+ f: (o: OutDone) => Effect.Effect<OutDone1, OutErr1, Env1>
1231
+ ): <OutElem, InElem, OutErr, InErr, InDone, Env>(
1232
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1233
+ ) => Channel<OutElem, InElem, OutErr1 | OutErr, InErr, OutDone1, InDone, Env1 | Env>
1234
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutDone1, OutErr1, Env1>(
1235
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1236
+ f: (o: OutDone) => Effect.Effect<OutDone1, OutErr1, Env1>
1237
+ ): Channel<OutElem, InElem, OutErr | OutErr1, InErr, OutDone1, InDone, Env | Env1>
1238
+ } = channel.mapEffect
1239
+
1240
+ /**
1241
+ * Returns a new channel, which is the same as this one, except the failure
1242
+ * value of the returned channel is created by applying the specified function
1243
+ * to the failure value of this channel.
1244
+ *
1245
+ * @since 2.0.0
1246
+ * @category mapping
1247
+ */
1248
+ export const mapError: {
1249
+ <OutErr, OutErr2>(
1250
+ f: (err: OutErr) => OutErr2
1251
+ ): <OutElem, InElem, InErr, OutDone, InDone, Env>(
1252
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1253
+ ) => Channel<OutElem, InElem, OutErr2, InErr, OutDone, InDone, Env>
1254
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutErr2>(
1255
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1256
+ f: (err: OutErr) => OutErr2
1257
+ ): Channel<OutElem, InElem, OutErr2, InErr, OutDone, InDone, Env>
1258
+ } = channel.mapError
1259
+
1260
+ /**
1261
+ * A more powerful version of `mapError` which also surfaces the `Cause`
1262
+ * of the channel failure.
1263
+ *
1264
+ * @since 2.0.0
1265
+ * @category mapping
1266
+ */
1267
+ export const mapErrorCause: {
1268
+ <OutErr, OutErr2>(
1269
+ f: (cause: Cause.Cause<OutErr>) => Cause.Cause<OutErr2>
1270
+ ): <OutElem, InElem, InErr, OutDone, InDone, Env>(
1271
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1272
+ ) => Channel<OutElem, InElem, OutErr2, InErr, OutDone, InDone, Env>
1273
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutErr2>(
1274
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1275
+ f: (cause: Cause.Cause<OutErr>) => Cause.Cause<OutErr2>
1276
+ ): Channel<OutElem, InElem, OutErr2, InErr, OutDone, InDone, Env>
1277
+ } = channel.mapErrorCause
1278
+
1279
+ /**
1280
+ * Maps the output of this channel using the specified function.
1281
+ *
1282
+ * @since 2.0.0
1283
+ * @category mapping
1284
+ */
1285
+ export const mapOut: {
1286
+ <OutElem, OutElem2>(
1287
+ f: (o: OutElem) => OutElem2
1288
+ ): <InElem, OutErr, InErr, OutDone, InDone, Env>(
1289
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1290
+ ) => Channel<OutElem2, InElem, OutErr, InErr, OutDone, InDone, Env>
1291
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem2>(
1292
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1293
+ f: (o: OutElem) => OutElem2
1294
+ ): Channel<OutElem2, InElem, OutErr, InErr, OutDone, InDone, Env>
1295
+ } = channel.mapOut
1296
+
1297
+ /**
1298
+ * Creates a channel that is like this channel but the given effectful function
1299
+ * gets applied to each emitted output element.
1300
+ *
1301
+ * @since 2.0.0
1302
+ * @category mapping
1303
+ */
1304
+ export const mapOutEffect: {
1305
+ <OutElem, OutElem1, OutErr1, Env1>(
1306
+ f: (o: OutElem) => Effect.Effect<OutElem1, OutErr1, Env1>
1307
+ ): <InElem, OutErr, InErr, OutDone, InDone, Env>(
1308
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1309
+ ) => Channel<OutElem1, InElem, OutErr1 | OutErr, InErr, OutDone, InDone, Env1 | Env>
1310
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, OutErr1, Env1>(
1311
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1312
+ f: (o: OutElem) => Effect.Effect<OutElem1, OutErr1, Env1>
1313
+ ): Channel<OutElem1, InElem, OutErr | OutErr1, InErr, OutDone, InDone, Env | Env1>
1314
+ } = channel.mapOutEffect
1315
+
1316
+ /**
1317
+ * Creates a channel that is like this channel but the given Effect function gets
1318
+ * applied to each emitted output element, taking `n` elements at once and
1319
+ * mapping them in parallel.
1320
+ *
1321
+ * @since 2.0.0
1322
+ * @category mapping
1323
+ */
1324
+ export const mapOutEffectPar: {
1325
+ <OutElem, OutElem1, OutErr1, Env1>(
1326
+ f: (o: OutElem) => Effect.Effect<OutElem1, OutErr1, Env1>,
1327
+ n: number
1328
+ ): <InElem, OutErr, InErr, OutDone, InDone, Env>(
1329
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1330
+ ) => Channel<OutElem1, InElem, OutErr1 | OutErr, InErr, OutDone, InDone, Env1 | Env>
1331
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, OutErr1, Env1>(
1332
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1333
+ f: (o: OutElem) => Effect.Effect<OutElem1, OutErr1, Env1>,
1334
+ n: number
1335
+ ): Channel<OutElem1, InElem, OutErr | OutErr1, InErr, OutDone, InDone, Env | Env1>
1336
+ } = channel.mapOutEffectPar
1337
+
1338
+ /**
1339
+ * @since 2.0.0
1340
+ * @category utils
1341
+ */
1342
+ export const mergeAll: (
1343
+ options: {
1344
+ readonly concurrency: number | "unbounded"
1345
+ readonly bufferSize?: number | undefined
1346
+ readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined
1347
+ }
1348
+ ) => <OutElem, InElem1, OutErr1, InErr1, InDone1, Env1, InElem, OutErr, InErr, InDone, Env>(
1349
+ channels: Channel<
1350
+ Channel<OutElem, InElem1, OutErr1, InErr1, unknown, InDone1, Env1>,
1351
+ InElem,
1352
+ OutErr,
1353
+ InErr,
1354
+ unknown,
1355
+ InDone,
1356
+ Env
1357
+ >
1358
+ ) => Channel<OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, unknown, InDone & InDone1, Env1 | Env> =
1359
+ channel.mergeAll
1360
+
1361
+ /**
1362
+ * @since 2.0.0
1363
+ * @category utils
1364
+ */
1365
+ export const mergeAllUnbounded: <OutElem, InElem1, OutErr1, InErr1, InDone1, Env1, InElem, OutErr, InErr, InDone, Env>(
1366
+ channels: Channel<
1367
+ Channel<OutElem, InElem1, OutErr1, InErr1, unknown, InDone1, Env1>,
1368
+ InElem,
1369
+ OutErr,
1370
+ InErr,
1371
+ unknown,
1372
+ InDone,
1373
+ Env
1374
+ >
1375
+ ) => Channel<OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, unknown, InDone & InDone1, Env1 | Env> =
1376
+ channel.mergeAllUnbounded
1377
+
1378
+ /**
1379
+ * @since 2.0.0
1380
+ * @category utils
1381
+ */
1382
+ export const mergeAllUnboundedWith: <
1383
+ OutElem,
1384
+ InElem1,
1385
+ OutErr1,
1386
+ InErr1,
1387
+ OutDone,
1388
+ InDone1,
1389
+ Env1,
1390
+ InElem,
1391
+ OutErr,
1392
+ InErr,
1393
+ InDone,
1394
+ Env
1395
+ >(
1396
+ channels: Channel<
1397
+ Channel<OutElem, InElem1, OutErr1, InErr1, OutDone, InDone1, Env1>,
1398
+ InElem,
1399
+ OutErr,
1400
+ InErr,
1401
+ OutDone,
1402
+ InDone,
1403
+ Env
1404
+ >,
1405
+ f: (o1: OutDone, o2: OutDone) => OutDone
1406
+ ) => Channel<OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone, InDone & InDone1, Env1 | Env> =
1407
+ channel.mergeAllUnboundedWith
1408
+
1409
+ /**
1410
+ * @since 2.0.0
1411
+ * @category utils
1412
+ */
1413
+ export const mergeAllWith: (
1414
+ { bufferSize, concurrency, mergeStrategy }: {
1415
+ readonly concurrency: number | "unbounded"
1416
+ readonly bufferSize?: number | undefined
1417
+ readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined
1418
+ }
1419
+ ) => <OutElem, InElem1, OutErr1, InErr1, OutDone, InDone1, Env1, InElem, OutErr, InErr, InDone, Env>(
1420
+ channels: Channel<
1421
+ Channel<OutElem, InElem1, OutErr1, InErr1, OutDone, InDone1, Env1>,
1422
+ InElem,
1423
+ OutErr,
1424
+ InErr,
1425
+ OutDone,
1426
+ InDone,
1427
+ Env
1428
+ >,
1429
+ f: (o1: OutDone, o2: OutDone) => OutDone
1430
+ ) => Channel<OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone, InDone & InDone1, Env1 | Env> =
1431
+ channel.mergeAllWith
1432
+
1433
+ /**
1434
+ * Returns a new channel which creates a new channel for each emitted element
1435
+ * and merges some of them together. Different merge strategies control what
1436
+ * happens if there are more than the given maximum number of channels gets
1437
+ * created. See `Channel.mergeAll`.
1438
+ *
1439
+ * @since 2.0.0
1440
+ * @category mapping
1441
+ */
1442
+ export const mergeMap: {
1443
+ <OutElem, OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1>(
1444
+ f: (outElem: OutElem) => Channel<OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1>,
1445
+ options: {
1446
+ readonly concurrency: number | "unbounded"
1447
+ readonly bufferSize?: number | undefined
1448
+ readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined
1449
+ }
1450
+ ): <InElem, OutErr, InErr, OutDone, InDone, Env>(
1451
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1452
+ ) => Channel<OutElem1, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, unknown, InDone & InDone1, Env1 | Env>
1453
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1>(
1454
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1455
+ f: (outElem: OutElem) => Channel<OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1>,
1456
+ options: {
1457
+ readonly concurrency: number | "unbounded"
1458
+ readonly bufferSize?: number | undefined
1459
+ readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined
1460
+ }
1461
+ ): Channel<OutElem1, InElem & InElem1, OutErr | OutErr1, InErr & InErr1, unknown, InDone & InDone1, Env | Env1>
1462
+ } = channel.mergeMap
1463
+
1464
+ /**
1465
+ * Returns a new channel which merges a number of channels emitted by this
1466
+ * channel using the back pressuring merge strategy. See `Channel.mergeAll`.
1467
+ *
1468
+ * @since 2.0.0
1469
+ * @category utils
1470
+ */
1471
+ export const mergeOut: {
1472
+ (
1473
+ n: number
1474
+ ): <OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1, InElem, OutErr, InErr, OutDone, InDone, Env>(
1475
+ self: Channel<
1476
+ Channel<OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1>,
1477
+ InElem,
1478
+ OutErr,
1479
+ InErr,
1480
+ OutDone,
1481
+ InDone,
1482
+ Env
1483
+ >
1484
+ ) => Channel<OutElem1, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, unknown, InDone & InDone1, Env1 | Env>
1485
+ <OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1, InElem, OutErr, InErr, OutDone, InDone, Env>(
1486
+ self: Channel<
1487
+ Channel<OutElem1, InElem1, OutErr1, InErr1, Z, InDone1, Env1>,
1488
+ InElem,
1489
+ OutErr,
1490
+ InErr,
1491
+ OutDone,
1492
+ InDone,
1493
+ Env
1494
+ >,
1495
+ n: number
1496
+ ): Channel<OutElem1, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, unknown, InDone & InDone1, Env1 | Env>
1497
+ } = channel.mergeOut
1498
+
1499
+ /**
1500
+ * Returns a new channel which merges a number of channels emitted by this
1501
+ * channel using the back pressuring merge strategy and uses a given function
1502
+ * to merge each completed subchannel's result value. See
1503
+ * `Channel.mergeAll`.
1504
+ *
1505
+ * @since 2.0.0
1506
+ * @category utils
1507
+ */
1508
+ export const mergeOutWith: {
1509
+ <OutDone1>(
1510
+ n: number,
1511
+ f: (o1: OutDone1, o2: OutDone1) => OutDone1
1512
+ ): <OutElem1, InElem1, OutErr1, InErr1, InDone1, Env1, InElem, OutErr, InErr, InDone, Env>(
1513
+ self: Channel<
1514
+ Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
1515
+ InElem,
1516
+ OutErr,
1517
+ InErr,
1518
+ OutDone1,
1519
+ InDone,
1520
+ Env
1521
+ >
1522
+ ) => Channel<OutElem1, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone1, InDone & InDone1, Env1 | Env>
1523
+ <OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1, InElem, OutErr, InErr, InDone, Env>(
1524
+ self: Channel<
1525
+ Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
1526
+ InElem,
1527
+ OutErr,
1528
+ InErr,
1529
+ OutDone1,
1530
+ InDone,
1531
+ Env
1532
+ >,
1533
+ n: number,
1534
+ f: (o1: OutDone1, o2: OutDone1) => OutDone1
1535
+ ): Channel<OutElem1, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone1, InDone & InDone1, Env1 | Env>
1536
+ } = channel.mergeOutWith
1537
+
1538
+ /**
1539
+ * Returns a new channel, which is the merge of this channel and the specified
1540
+ * channel, where the behavior of the returned channel on left or right early
1541
+ * termination is decided by the specified `leftDone` and `rightDone` merge
1542
+ * decisions.
1543
+ *
1544
+ * @since 2.0.0
1545
+ * @category utils
1546
+ */
1547
+ export const mergeWith: {
1548
+ <OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1, OutDone, OutErr, OutErr2, OutDone2, OutErr3, OutDone3>(
1549
+ options: {
1550
+ readonly other: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
1551
+ readonly onSelfDone: (
1552
+ exit: Exit.Exit<OutDone, OutErr>
1553
+ ) => MergeDecision.MergeDecision<Env1, OutErr1, OutDone1, OutErr2, OutDone2>
1554
+ readonly onOtherDone: (
1555
+ ex: Exit.Exit<OutDone1, OutErr1>
1556
+ ) => MergeDecision.MergeDecision<Env1, OutErr, OutDone, OutErr3, OutDone3>
1557
+ }
1558
+ ): <Env, InErr, InElem, InDone, OutElem>(
1559
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1560
+ ) => Channel<
1561
+ OutElem1 | OutElem,
1562
+ InElem & InElem1,
1563
+ OutErr2 | OutErr3,
1564
+ InErr & InErr1,
1565
+ OutDone2 | OutDone3,
1566
+ InDone & InDone1,
1567
+ Env1 | Env
1568
+ >
1569
+ <
1570
+ OutElem,
1571
+ InElem,
1572
+ OutErr,
1573
+ InErr,
1574
+ OutDone,
1575
+ InDone,
1576
+ Env,
1577
+ OutElem1,
1578
+ InElem1,
1579
+ OutErr1,
1580
+ InErr1,
1581
+ OutDone1,
1582
+ InDone1,
1583
+ Env1,
1584
+ OutErr2,
1585
+ OutDone2,
1586
+ OutErr3,
1587
+ OutDone3
1588
+ >(
1589
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1590
+ options: {
1591
+ readonly other: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>
1592
+ readonly onSelfDone: (
1593
+ exit: Exit.Exit<OutDone, OutErr>
1594
+ ) => MergeDecision.MergeDecision<Env1, OutErr1, OutDone1, OutErr2, OutDone2>
1595
+ readonly onOtherDone: (
1596
+ ex: Exit.Exit<OutDone1, OutErr1>
1597
+ ) => MergeDecision.MergeDecision<Env1, OutErr, OutDone, OutErr3, OutDone3>
1598
+ }
1599
+ ): Channel<
1600
+ OutElem | OutElem1,
1601
+ InElem & InElem1,
1602
+ OutErr2 | OutErr3,
1603
+ InErr & InErr1,
1604
+ OutDone2 | OutDone3,
1605
+ InDone & InDone1,
1606
+ Env | Env1
1607
+ >
1608
+ } = channel.mergeWith
1609
+
1610
+ /**
1611
+ * Returns a channel that never completes
1612
+ *
1613
+ * @since 2.0.0
1614
+ * @category constructors
1615
+ */
1616
+ export const never: Channel<never, unknown, never, unknown, never, unknown> = channel.never
1617
+
1618
+ /**
1619
+ * Translates channel failure into death of the fiber, making all failures
1620
+ * unchecked and not a part of the type of the channel.
1621
+ *
1622
+ * @since 2.0.0
1623
+ * @category error handling
1624
+ */
1625
+ export const orDie: {
1626
+ <E>(
1627
+ error: LazyArg<E>
1628
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1629
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1630
+ ) => Channel<OutElem, InElem, never, InErr, OutDone, InDone, Env>
1631
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, E>(
1632
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1633
+ error: LazyArg<E>
1634
+ ): Channel<OutElem, InElem, never, InErr, OutDone, InDone, Env>
1635
+ } = channel.orDie
1636
+
1637
+ /**
1638
+ * Keeps none of the errors, and terminates the fiber with them, using the
1639
+ * specified function to convert the `OutErr` into a defect.
1640
+ *
1641
+ * @since 2.0.0
1642
+ * @category error handling
1643
+ */
1644
+ export const orDieWith: {
1645
+ <OutErr>(
1646
+ f: (e: OutErr) => unknown
1647
+ ): <OutElem, InElem, InErr, OutDone, InDone, Env>(
1648
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1649
+ ) => Channel<OutElem, InElem, never, InErr, OutDone, InDone, Env>
1650
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1651
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1652
+ f: (e: OutErr) => unknown
1653
+ ): Channel<OutElem, InElem, never, InErr, OutDone, InDone, Env>
1654
+ } = channel.orDieWith
1655
+
1656
+ /**
1657
+ * Returns a new channel that will perform the operations of this one, until
1658
+ * failure, and then it will switch over to the operations of the specified
1659
+ * fallback channel.
1660
+ *
1661
+ * @since 2.0.0
1662
+ * @category error handling
1663
+ */
1664
+ export const orElse: {
1665
+ <OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
1666
+ that: LazyArg<Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>>
1667
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1668
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1669
+ ) => Channel<
1670
+ OutElem1 | OutElem,
1671
+ InElem & InElem1,
1672
+ OutErr1,
1673
+ InErr & InErr1,
1674
+ OutDone1 | OutDone,
1675
+ InDone & InDone1,
1676
+ Env1 | Env
1677
+ >
1678
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
1679
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1680
+ that: LazyArg<Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>>
1681
+ ): Channel<
1682
+ OutElem | OutElem1,
1683
+ InElem & InElem1,
1684
+ OutErr1,
1685
+ InErr & InErr1,
1686
+ OutDone | OutDone1,
1687
+ InDone & InDone1,
1688
+ Env | Env1
1689
+ >
1690
+ } = channel.orElse
1691
+
1692
+ /**
1693
+ * Returns a new channel that pipes the output of this channel into the
1694
+ * specified channel. The returned channel has the input type of this channel,
1695
+ * and the output type of the specified channel, terminating with the value of
1696
+ * the specified channel.
1697
+ *
1698
+ * @since 2.0.0
1699
+ * @category utils
1700
+ */
1701
+ export const pipeTo: {
1702
+ <OutElem2, OutElem, OutErr2, OutErr, OutDone2, OutDone, Env2>(
1703
+ that: Channel<OutElem2, OutElem, OutErr2, OutErr, OutDone2, OutDone, Env2>
1704
+ ): <InElem, InErr, InDone, Env>(
1705
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1706
+ ) => Channel<OutElem2, InElem, OutErr2, InErr, OutDone2, InDone, Env2 | Env>
1707
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem2, OutErr2, OutDone2, Env2>(
1708
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1709
+ that: Channel<OutElem2, OutElem, OutErr2, OutErr, OutDone2, OutDone, Env2>
1710
+ ): Channel<OutElem2, InElem, OutErr2, InErr, OutDone2, InDone, Env | Env2>
1711
+ } = core.pipeTo
1712
+
1713
+ /**
1714
+ * Returns a new channel that pipes the output of this channel into the
1715
+ * specified channel and preserves this channel's failures without providing
1716
+ * them to the other channel for observation.
1717
+ *
1718
+ * @since 2.0.0
1719
+ * @category utils
1720
+ */
1721
+ export const pipeToOrFail: {
1722
+ <OutElem2, OutElem, OutErr2, OutDone2, OutDone, Env2>(
1723
+ that: Channel<OutElem2, OutElem, OutErr2, never, OutDone2, OutDone, Env2>
1724
+ ): <InElem, OutErr, InErr, InDone, Env>(
1725
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1726
+ ) => Channel<OutElem2, InElem, OutErr2 | OutErr, InErr, OutDone2, InDone, Env2 | Env>
1727
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem2, OutErr2, OutDone2, Env2>(
1728
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1729
+ that: Channel<OutElem2, OutElem, OutErr2, never, OutDone2, OutDone, Env2>
1730
+ ): Channel<OutElem2, InElem, OutErr | OutErr2, InErr, OutDone2, InDone, Env | Env2>
1731
+ } = channel.pipeToOrFail
1732
+
1733
+ /**
1734
+ * Provides the channel with its required context, which eliminates its
1735
+ * dependency on `Env`.
1736
+ *
1737
+ * @since 2.0.0
1738
+ * @category context
1739
+ */
1740
+ export const provideContext: {
1741
+ <Env>(
1742
+ env: Context.Context<Env>
1743
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone>(
1744
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1745
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, never>
1746
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1747
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1748
+ env: Context.Context<Env>
1749
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, never>
1750
+ } = core.provideContext
1751
+
1752
+ /**
1753
+ * Provides a layer to the channel, which translates it to another level.
1754
+ *
1755
+ * @since 2.0.0
1756
+ * @category context
1757
+ */
1758
+ export const provideLayer: {
1759
+ <Env, OutErr2, Env0>(
1760
+ layer: Layer.Layer<Env, OutErr2, Env0>
1761
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone>(
1762
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1763
+ ) => Channel<OutElem, InElem, OutErr2 | OutErr, InErr, OutDone, InDone, Env0>
1764
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutErr2, Env0>(
1765
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1766
+ layer: Layer.Layer<Env, OutErr2, Env0>
1767
+ ): Channel<OutElem, InElem, OutErr | OutErr2, InErr, OutDone, InDone, Env0>
1768
+ } = channel.provideLayer
1769
+
1770
+ /**
1771
+ * Transforms the context being provided to the channel with the specified
1772
+ * function.
1773
+ *
1774
+ * @since 2.0.0
1775
+ * @category context
1776
+ */
1777
+ export const mapInputContext: {
1778
+ <Env0, Env>(
1779
+ f: (env: Context.Context<Env0>) => Context.Context<Env>
1780
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone>(
1781
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1782
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env0>
1783
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, Env0>(
1784
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1785
+ f: (env: Context.Context<Env0>) => Context.Context<Env>
1786
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env0>
1787
+ } = channel.mapInputContext
1788
+
1789
+ /**
1790
+ * Splits the context into two parts, providing one part using the
1791
+ * specified layer and leaving the remainder `Env0`.
1792
+ *
1793
+ * @since 2.0.0
1794
+ * @category context
1795
+ */
1796
+ export const provideSomeLayer: {
1797
+ <R2, OutErr2, Env0>(
1798
+ layer: Layer.Layer<R2, OutErr2, Env0>
1799
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, R>(
1800
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R>
1801
+ ) => Channel<OutElem, InElem, OutErr2 | OutErr, InErr, OutDone, InDone, Env0 | Exclude<R, R2>>
1802
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, R, R2, OutErr2, Env0>(
1803
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R>,
1804
+ layer: Layer.Layer<R2, OutErr2, Env0>
1805
+ ): Channel<OutElem, InElem, OutErr | OutErr2, InErr, OutDone, InDone, Env0 | Exclude<R, R2>>
1806
+ } = channel.provideSomeLayer
1807
+
1808
+ /**
1809
+ * Provides the effect with the single service it requires. If the effect
1810
+ * requires more than one service use `provideContext` instead.
1811
+ *
1812
+ * @since 2.0.0
1813
+ * @category context
1814
+ */
1815
+ export const provideService: {
1816
+ <I, S>(
1817
+ tag: Context.Tag<I, S>,
1818
+ service: Types.NoInfer<S>
1819
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1820
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1821
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Exclude<Env, I>>
1822
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, I, S>(
1823
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
1824
+ tag: Context.Tag<I, S>,
1825
+ service: Types.NoInfer<S>
1826
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Exclude<Env, I>>
1827
+ } = channel.provideService
1828
+
1829
+ /**
1830
+ * @since 2.0.0
1831
+ * @category constructors
1832
+ */
1833
+ export const read: <In>() => Channel<never, In, Option.Option<never>, unknown, In, unknown> = channel.read
1834
+
1835
+ /**
1836
+ * @since 2.0.0
1837
+ * @category constructors
1838
+ */
1839
+ export const readOrFail: <E, In = unknown>(error: E) => Channel<never, In, E, unknown, In, unknown> = core.readOrFail
1840
+
1841
+ /**
1842
+ * @since 2.0.0
1843
+ * @category constructors
1844
+ */
1845
+ export const readWith: <
1846
+ InElem,
1847
+ OutElem,
1848
+ OutErr,
1849
+ InErr,
1850
+ OutDone,
1851
+ InDone,
1852
+ Env,
1853
+ OutElem2,
1854
+ OutErr2,
1855
+ OutDone2,
1856
+ Env2,
1857
+ OutElem3,
1858
+ OutErr3,
1859
+ OutDone3,
1860
+ Env3
1861
+ >(
1862
+ options: {
1863
+ readonly onInput: (input: InElem) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1864
+ readonly onFailure: (error: InErr) => Channel<OutElem2, InElem, OutErr2, InErr, OutDone2, InDone, Env2>
1865
+ readonly onDone: (done: InDone) => Channel<OutElem3, InElem, OutErr3, InErr, OutDone3, InDone, Env3>
1866
+ }
1867
+ ) => Channel<
1868
+ OutElem | OutElem2 | OutElem3,
1869
+ InElem,
1870
+ OutErr | OutErr2 | OutErr3,
1871
+ InErr,
1872
+ OutDone | OutDone2 | OutDone3,
1873
+ InDone,
1874
+ Env | Env2 | Env3
1875
+ > = core.readWith
1876
+
1877
+ /**
1878
+ * @since 2.0.0
1879
+ * @category constructors
1880
+ */
1881
+ export const readWithCause: <
1882
+ InElem,
1883
+ OutElem,
1884
+ OutErr,
1885
+ InErr,
1886
+ OutDone,
1887
+ InDone,
1888
+ Env,
1889
+ OutElem2,
1890
+ OutErr2,
1891
+ OutDone2,
1892
+ Env2,
1893
+ OutElem3,
1894
+ OutErr3,
1895
+ OutDone3,
1896
+ Env3
1897
+ >(
1898
+ options: {
1899
+ readonly onInput: (input: InElem) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1900
+ readonly onFailure: (cause: Cause.Cause<InErr>) => Channel<OutElem2, InElem, OutErr2, InErr, OutDone2, InDone, Env2>
1901
+ readonly onDone: (done: InDone) => Channel<OutElem3, InElem, OutErr3, InErr, OutDone3, InDone, Env3>
1902
+ }
1903
+ ) => Channel<
1904
+ OutElem | OutElem2 | OutElem3,
1905
+ InElem,
1906
+ OutErr | OutErr2 | OutErr3,
1907
+ InErr,
1908
+ OutDone | OutDone2 | OutDone3,
1909
+ InDone,
1910
+ Env | Env2 | Env3
1911
+ > = core.readWithCause
1912
+
1913
+ /**
1914
+ * Creates a channel which repeatedly runs this channel.
1915
+ *
1916
+ * @since 2.0.0
1917
+ * @category utils
1918
+ */
1919
+ export const repeated: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
1920
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
1921
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env> = channel.repeated
1922
+
1923
+ /**
1924
+ * Runs a channel until the end is received.
1925
+ *
1926
+ * @since 2.0.0
1927
+ * @category destructors
1928
+ */
1929
+ export const run: <OutErr, InErr, OutDone, InDone, Env>(
1930
+ self: Channel<never, unknown, OutErr, InErr, OutDone, InDone, Env>
1931
+ ) => Effect.Effect<OutDone, OutErr, Env> = channel.run
1932
+
1933
+ /**
1934
+ * Run the channel until it finishes with a done value or fails with an error
1935
+ * and collects its emitted output elements.
1936
+ *
1937
+ * The channel must not read any input.
1938
+ *
1939
+ * @since 2.0.0
1940
+ * @category destructors
1941
+ */
1942
+ export const runCollect: <OutElem, OutErr, InErr, OutDone, InDone, Env>(
1943
+ self: Channel<OutElem, unknown, OutErr, InErr, OutDone, InDone, Env>
1944
+ ) => Effect.Effect<[Chunk.Chunk<OutElem>, OutDone], OutErr, Env> = channel.runCollect
1945
+
1946
+ /**
1947
+ * Runs a channel until the end is received.
1948
+ *
1949
+ * @since 2.0.0
1950
+ * @category destructors
1951
+ */
1952
+ export const runDrain: <OutElem, OutErr, InErr, OutDone, InDone, Env>(
1953
+ self: Channel<OutElem, unknown, OutErr, InErr, OutDone, InDone, Env>
1954
+ ) => Effect.Effect<OutDone, OutErr, Env> = channel.runDrain
1955
+
1956
+ /**
1957
+ * Run the channel until it finishes with a done value or fails with an error.
1958
+ * The channel must not read any input or write any output.
1959
+ *
1960
+ * Closing the channel, which includes execution of all the finalizers
1961
+ * attached to the channel will be added to the current scope as a finalizer.
1962
+ *
1963
+ * @since 3.11.0
1964
+ * @category destructors
1965
+ */
1966
+ export const runScoped: <OutErr, InErr, OutDone, InDone, Env>(
1967
+ self: Channel<never, unknown, OutErr, InErr, OutDone, InDone, Env>
1968
+ ) => Effect.Effect<OutDone, OutErr, Env | Scope.Scope> = channel.runScoped
1969
+
1970
+ /**
1971
+ * Use a scoped effect to emit an output element.
1972
+ *
1973
+ * @since 2.0.0
1974
+ * @category constructors
1975
+ */
1976
+ export const scoped: <A, E, R>(
1977
+ effect: Effect.Effect<A, E, R>
1978
+ ) => Channel<A, unknown, E, unknown, unknown, unknown, Exclude<R, Scope.Scope>> = channel.scoped
1979
+
1980
+ /**
1981
+ * Use a function that receives a scope and returns an effect to emit an output
1982
+ * element. The output element will be the result of the returned effect, if
1983
+ * successful.
1984
+ *
1985
+ * @since 3.11.0
1986
+ * @category constructors
1987
+ */
1988
+ export const scopedWith: <A, E, R>(
1989
+ f: (scope: Scope.Scope) => Effect.Effect<A, E, R>
1990
+ ) => Channel<A, unknown, E, unknown, unknown, unknown, R> = channel.scopedWith
1991
+
1992
+ /**
1993
+ * Splits strings on newlines. Handles both Windows newlines (`\r\n`) and UNIX
1994
+ * newlines (`\n`).
1995
+ *
1996
+ * @since 2.0.0
1997
+ * @category combinators
1998
+ */
1999
+ export const splitLines: <Err, Done>() => Channel<
2000
+ Chunk.Chunk<string>,
2001
+ Chunk.Chunk<string>,
2002
+ Err,
2003
+ Err,
2004
+ Done,
2005
+ Done,
2006
+ never
2007
+ > = channel.splitLines
2008
+
2009
+ /**
2010
+ * Constructs a channel that succeeds immediately with the specified value.
2011
+ *
2012
+ * @since 2.0.0
2013
+ * @category constructors
2014
+ */
2015
+ export const succeed: <A>(value: A) => Channel<never, unknown, never, unknown, A, unknown> = core.succeed
2016
+
2017
+ /**
2018
+ * Lazily constructs a channel from the given side effect.
2019
+ *
2020
+ * @since 2.0.0
2021
+ * @category constructors
2022
+ */
2023
+ export const suspend: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2024
+ evaluate: LazyArg<Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>>
2025
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env> = core.suspend
2026
+
2027
+ /**
2028
+ * Constructs a channel that succeeds immediately with the specified lazy value.
2029
+ *
2030
+ * @since 2.0.0
2031
+ * @category constructors
2032
+ */
2033
+ export const sync: <OutDone>(
2034
+ evaluate: LazyArg<OutDone>
2035
+ ) => Channel<never, unknown, never, unknown, OutDone, unknown> = core.sync
2036
+
2037
+ /**
2038
+ * Converts a `Channel` to a `PubSub`.
2039
+ *
2040
+ * @since 2.0.0
2041
+ * @category destructors
2042
+ */
2043
+ export const toPubSub: <Done, Err, Elem>(
2044
+ pubsub: PubSub.PubSub<Either.Either<Elem, Exit.Exit<Done, Err>>>
2045
+ ) => Channel<never, Elem, never, Err, unknown, Done> = channel.toPubSub
2046
+
2047
+ /**
2048
+ * Returns a scoped `Effect` that can be used to repeatedly pull elements from
2049
+ * the constructed `Channel`. The pull effect fails with the channel's failure
2050
+ * in case the channel fails, or returns either the channel's done value or an
2051
+ * emitted element.
2052
+ *
2053
+ * @since 2.0.0
2054
+ * @category destructors
2055
+ */
2056
+ export const toPull: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2057
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
2058
+ ) => Effect.Effect<Effect.Effect<Either.Either<OutElem, OutDone>, OutErr, Env>, never, Scope.Scope | Env> =
2059
+ channel.toPull
2060
+
2061
+ /**
2062
+ * Returns an `Effect` that can be used to repeatedly pull elements from the
2063
+ * constructed `Channel` within the provided `Scope`. The pull effect fails
2064
+ * with the channel's failure in case the channel fails, or returns either the
2065
+ * channel's done value or an emitted element.
2066
+ *
2067
+ * @since 3.11.0
2068
+ * @category destructors
2069
+ */
2070
+ export const toPullIn: {
2071
+ (
2072
+ scope: Scope.Scope
2073
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2074
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
2075
+ ) => Effect.Effect<Effect.Effect<Either.Either<OutElem, OutDone>, OutErr, Env>, never, Env>
2076
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2077
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
2078
+ scope: Scope.Scope
2079
+ ): Effect.Effect<Effect.Effect<Either.Either<OutElem, OutDone>, OutErr, Env>, never, Env>
2080
+ } = channel.toPullIn
2081
+
2082
+ /**
2083
+ * Converts a `Channel` to a `Queue`.
2084
+ *
2085
+ * @since 2.0.0
2086
+ * @category destructors
2087
+ */
2088
+ export const toQueue: <Done, Err, Elem>(
2089
+ queue: Queue.Enqueue<Either.Either<Elem, Exit.Exit<Done, Err>>>
2090
+ ) => Channel<never, Elem, never, Err, unknown, Done> = channel.toQueue
2091
+
2092
+ /** Converts this channel to a `Sink`.
2093
+ *
2094
+ * @since 2.0.0
2095
+ * @category destructors
2096
+ */
2097
+ export const toSink: <OutElem, InElem, OutErr, InErr, OutDone, Env>(
2098
+ self: Channel<Chunk.Chunk<OutElem>, Chunk.Chunk<InElem>, OutErr, InErr, OutDone, unknown, Env>
2099
+ ) => Sink.Sink<OutDone, InElem, OutElem, OutErr, Env> = sink.channelToSink
2100
+
2101
+ /**
2102
+ * Converts this channel to a `Stream`.
2103
+ *
2104
+ * @since 2.0.0
2105
+ * @category destructors
2106
+ */
2107
+ export const toStream: <OutElem, OutErr, OutDone, Env>(
2108
+ self: Channel<Chunk.Chunk<OutElem>, unknown, OutErr, unknown, OutDone, unknown, Env>
2109
+ ) => Stream.Stream<OutElem, OutErr, Env> = stream.channelToStream
2110
+
2111
+ const void_: Channel<never> = core.void
2112
+ export {
2113
+ /**
2114
+ * @since 2.0.0
2115
+ * @category constructors
2116
+ */
2117
+ void_ as void
2118
+ }
2119
+
2120
+ /**
2121
+ * Constructs a `Channel` from an effect that will result in a `Channel` if
2122
+ * successful.
2123
+ *
2124
+ * @since 2.0.0
2125
+ * @category constructors
2126
+ */
2127
+ export const unwrap: <OutElem, InElem, OutErr, InErr, OutDone, InDone, R2, E, R>(
2128
+ channel: Effect.Effect<Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R2>, E, R>
2129
+ ) => Channel<OutElem, InElem, E | OutErr, InErr, OutDone, InDone, R | R2> = channel.unwrap
2130
+
2131
+ /**
2132
+ * Constructs a `Channel` from a scoped effect that will result in a
2133
+ * `Channel` if successful.
2134
+ *
2135
+ * @since 2.0.0
2136
+ * @category constructors
2137
+ */
2138
+ export const unwrapScoped: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, E, R>(
2139
+ self: Effect.Effect<Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>, E, R>
2140
+ ) => Channel<OutElem, InElem, E | OutErr, InErr, OutDone, InDone, Env | Exclude<R, Scope.Scope>> = channel.unwrapScoped
2141
+
2142
+ /**
2143
+ * Constructs a `Channel` from a function which receives a `Scope` and returns
2144
+ * an effect that will result in a `Channel` if successful.
2145
+ *
2146
+ * @since 3.11.0
2147
+ * @category constructors
2148
+ */
2149
+ export const unwrapScopedWith: <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, E, R>(
2150
+ f: (scope: Scope.Scope) => Effect.Effect<Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>, E, R>
2151
+ ) => Channel<OutElem, InElem, E | OutErr, InErr, OutDone, InDone, R | Env> = channel.unwrapScopedWith
2152
+
2153
+ /**
2154
+ * Updates a service in the context of this channel.
2155
+ *
2156
+ * @since 2.0.0
2157
+ * @category context
2158
+ */
2159
+ export const updateService: {
2160
+ <I, S>(
2161
+ tag: Context.Tag<I, S>,
2162
+ f: (resource: Types.NoInfer<S>) => Types.NoInfer<S>
2163
+ ): <OutElem, OutErr, InErr, OutDone, InDone, R>(
2164
+ self: Channel<OutElem, unknown, OutErr, InErr, OutDone, InDone, R>
2165
+ ) => Channel<OutElem, unknown, OutErr, InErr, OutDone, InDone, I | R>
2166
+ <OutElem, OutErr, InErr, OutDone, InDone, R, I, S>(
2167
+ self: Channel<OutElem, unknown, OutErr, InErr, OutDone, InDone, R>,
2168
+ tag: Context.Tag<I, S>,
2169
+ f: (resource: Types.NoInfer<S>) => Types.NoInfer<S>
2170
+ ): Channel<OutElem, unknown, OutErr, InErr, OutDone, InDone, I | R>
2171
+ } = channel.updateService
2172
+
2173
+ /**
2174
+ * Wraps the channel with a new span for tracing.
2175
+ *
2176
+ * @since 2.0.0
2177
+ * @category tracing
2178
+ */
2179
+ export const withSpan: {
2180
+ (
2181
+ name: string,
2182
+ options?: Tracer.SpanOptions | undefined
2183
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2184
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
2185
+ ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Exclude<Env, Tracer.ParentSpan>>
2186
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2187
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
2188
+ name: string,
2189
+ options?: Tracer.SpanOptions | undefined
2190
+ ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Exclude<Env, Tracer.ParentSpan>>
2191
+ } = channel.withSpan
2192
+
2193
+ /**
2194
+ * Writes a single value to the channel.
2195
+ *
2196
+ * @since 2.0.0
2197
+ * @category constructors
2198
+ */
2199
+ export const write: <OutElem>(out: OutElem) => Channel<OutElem> = core.write
2200
+
2201
+ /**
2202
+ * Writes a sequence of values to the channel.
2203
+ *
2204
+ * @since 2.0.0
2205
+ * @category constructors
2206
+ */
2207
+ export const writeAll: <OutElems extends Array<any>>(
2208
+ ...outs: OutElems
2209
+ ) => Channel<OutElems[number]> = channel.writeAll
2210
+
2211
+ /**
2212
+ * Writes a `Chunk` of values to the channel.
2213
+ *
2214
+ * @since 2.0.0
2215
+ * @category constructors
2216
+ */
2217
+ export const writeChunk: <OutElem>(
2218
+ outs: Chunk.Chunk<OutElem>
2219
+ ) => Channel<OutElem> = channel.writeChunk
2220
+
2221
+ /**
2222
+ * Returns a new channel that is the sequential composition of this channel
2223
+ * and the specified channel. The returned channel terminates with a tuple of
2224
+ * the terminal values of both channels.
2225
+ *
2226
+ * @since 2.0.0
2227
+ * @category zipping
2228
+ */
2229
+ export const zip: {
2230
+ <OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
2231
+ that: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
2232
+ options?: { readonly concurrent?: boolean | undefined } | undefined
2233
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2234
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
2235
+ ) => Channel<
2236
+ OutElem1 | OutElem,
2237
+ InElem & InElem1,
2238
+ OutErr1 | OutErr,
2239
+ InErr & InErr1,
2240
+ readonly [OutDone, OutDone1],
2241
+ InDone & InDone1,
2242
+ Env1 | Env
2243
+ >
2244
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
2245
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
2246
+ that: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
2247
+ options?: { readonly concurrent?: boolean | undefined } | undefined
2248
+ ): Channel<
2249
+ OutElem | OutElem1,
2250
+ InElem & InElem1,
2251
+ OutErr | OutErr1,
2252
+ InErr & InErr1,
2253
+ readonly [OutDone, OutDone1],
2254
+ InDone & InDone1,
2255
+ Env | Env1
2256
+ >
2257
+ } = channel.zip
2258
+
2259
+ /**
2260
+ * Returns a new channel that is the sequential composition of this channel
2261
+ * and the specified channel. The returned channel terminates with the
2262
+ * terminal value of this channel.
2263
+ *
2264
+ * @since 2.0.0
2265
+ * @category zipping
2266
+ */
2267
+ export const zipLeft: {
2268
+ <OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
2269
+ that: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
2270
+ options?: { readonly concurrent?: boolean | undefined } | undefined
2271
+ ): <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>(
2272
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
2273
+ ) => Channel<
2274
+ OutElem1 | OutElem,
2275
+ InElem & InElem1,
2276
+ OutErr1 | OutErr,
2277
+ InErr & InErr1,
2278
+ OutDone,
2279
+ InDone & InDone1,
2280
+ Env1 | Env
2281
+ >
2282
+ <OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>(
2283
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
2284
+ that: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
2285
+ options?: { readonly concurrent?: boolean | undefined } | undefined
2286
+ ): Channel<
2287
+ OutElem | OutElem1,
2288
+ InElem & InElem1,
2289
+ OutErr | OutErr1,
2290
+ InErr & InErr1,
2291
+ OutDone,
2292
+ InDone & InDone1,
2293
+ Env | Env1
2294
+ >
2295
+ } = channel.zipLeft
2296
+
2297
+ /**
2298
+ * Returns a new channel that is the sequential composition of this channel
2299
+ * and the specified channel. The returned channel terminates with the
2300
+ * terminal value of that channel.
2301
+ *
2302
+ * @since 2.0.0
2303
+ * @category zipping
2304
+ */
2305
+ export const zipRight: {
2306
+ <Env1, InErr1, InElem1, InDone1, OutErr1, OutElem1, OutDone1>(
2307
+ that: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
2308
+ options?: {
2309
+ readonly concurrent?: boolean | undefined
2310
+ }
2311
+ ): <Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>(
2312
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
2313
+ ) => Channel<
2314
+ OutElem1 | OutElem,
2315
+ InElem & InElem1,
2316
+ OutErr1 | OutErr,
2317
+ InErr & InErr1,
2318
+ OutDone1,
2319
+ InDone & InDone1,
2320
+ Env1 | Env
2321
+ >
2322
+ <Env, InErr, InElem, InDone, OutErr, OutElem, OutDone, Env1, InErr1, InElem1, InDone1, OutErr1, OutElem1, OutDone1>(
2323
+ self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
2324
+ that: Channel<OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1>,
2325
+ options?: {
2326
+ readonly concurrent?: boolean | undefined
2327
+ }
2328
+ ): Channel<
2329
+ OutElem | OutElem1,
2330
+ InElem & InElem1,
2331
+ OutErr | OutErr1,
2332
+ InErr & InErr1,
2333
+ OutDone1,
2334
+ InDone & InDone1,
2335
+ Env | Env1
2336
+ >
2337
+ } = channel.zipRight
2338
+
2339
+ /**
2340
+ * Represents a generic checked exception which occurs when a `Channel` is
2341
+ * executed.
2342
+ *
2343
+ * @since 2.0.0
2344
+ * @category errors
2345
+ */
2346
+ export const ChannelException: <E>(error: E) => ChannelException<E> = channel.ChannelException
2347
+
2348
+ /**
2349
+ * Returns `true` if the specified value is an `ChannelException`, `false`
2350
+ * otherwise.
2351
+ *
2352
+ * @since 2.0.0
2353
+ * @category refinements
2354
+ */
2355
+ export const isChannelException: (u: unknown) => u is ChannelException<unknown> = channel.isChannelException