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

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/Sink.ts ADDED
@@ -0,0 +1,1461 @@
1
+ /**
2
+ * @since 2.0.0
3
+ */
4
+ import type * as Cause from "./Cause.js"
5
+ import type * as Channel from "./Channel.js"
6
+ import type * as Chunk from "./Chunk.js"
7
+ import type * as Context from "./Context.js"
8
+ import type * as Duration from "./Duration.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 type * as HashMap from "./HashMap.js"
14
+ import type * as HashSet from "./HashSet.js"
15
+ import * as internal from "./internal/sink.js"
16
+ import type * as MergeDecision from "./MergeDecision.js"
17
+ import type * as Option from "./Option.js"
18
+ import type { Pipeable } from "./Pipeable.js"
19
+ import type { Predicate, Refinement } from "./Predicate.js"
20
+ import type * as PubSub from "./PubSub.js"
21
+ import type * as Queue from "./Queue.js"
22
+ import type * as Scope from "./Scope.js"
23
+ import type * as Types from "./Types.js"
24
+ import type * as Unify from "./Unify.js"
25
+
26
+ /**
27
+ * @since 2.0.0
28
+ * @category symbols
29
+ */
30
+ export const SinkTypeId: unique symbol = internal.SinkTypeId
31
+
32
+ /**
33
+ * @since 2.0.0
34
+ * @category symbols
35
+ */
36
+ export type SinkTypeId = typeof SinkTypeId
37
+
38
+ /**
39
+ * A `Sink<A, In, L, E, R>` is used to consume elements produced by a `Stream`.
40
+ * You can think of a sink as a function that will consume a variable amount of
41
+ * `In` elements (could be 0, 1, or many), might fail with an error of type `E`,
42
+ * and will eventually yield a value of type `A` together with a remainder of
43
+ * type `L` (i.e. any leftovers).
44
+ *
45
+ * @since 2.0.0
46
+ * @category models
47
+ */
48
+ export interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>
49
+ extends Sink.Variance<A, In, L, E, R>, Pipeable
50
+ {}
51
+
52
+ /**
53
+ * @since 2.0.0
54
+ * @category models
55
+ */
56
+ export interface SinkUnify<A extends { [Unify.typeSymbol]?: any }> extends Effect.EffectUnify<A> {
57
+ Sink?: () => A[Unify.typeSymbol] extends
58
+ | Sink<
59
+ infer A,
60
+ infer In,
61
+ infer L,
62
+ infer E,
63
+ infer R
64
+ >
65
+ | infer _ ? Sink<A, In, L, E, R>
66
+ : never
67
+ }
68
+
69
+ /**
70
+ * @category models
71
+ * @since 2.0.0
72
+ */
73
+ export interface SinkUnifyIgnore extends Effect.EffectUnifyIgnore {
74
+ Sink?: true
75
+ }
76
+
77
+ /**
78
+ * @since 2.0.0
79
+ * @category models
80
+ */
81
+ declare module "./Effect.js" {
82
+ interface Effect<A, E, R> extends Sink<A, unknown, never, E, R> {}
83
+ interface EffectUnifyIgnore {
84
+ Sink?: true
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @since 2.0.0
90
+ */
91
+ export declare namespace Sink {
92
+ /**
93
+ * @since 2.0.0
94
+ * @category models
95
+ */
96
+ export interface Variance<out A, in In, out L, out E, out R> {
97
+ readonly [SinkTypeId]: VarianceStruct<A, In, L, E, R>
98
+ }
99
+ /**
100
+ * @since 2.0.0
101
+ * @category models
102
+ */
103
+ export interface VarianceStruct<out A, in In, out L, out E, out R> {
104
+ _A: Types.Covariant<A>
105
+ _In: Types.Contravariant<In>
106
+ _L: Types.Covariant<L>
107
+ _E: Types.Covariant<E>
108
+ _R: Types.Covariant<R>
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Replaces this sink's result with the provided value.
114
+ *
115
+ * @since 2.0.0
116
+ * @category mapping
117
+ */
118
+ export const as: {
119
+ <A2>(a: A2): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L, E, R>
120
+ <A, In, L, E, R, A2>(self: Sink<A, In, L, E, R>, a: A2): Sink<A2, In, L, E, R>
121
+ } = internal.as
122
+
123
+ /**
124
+ * A sink that collects all elements into a `Chunk`.
125
+ *
126
+ * @since 2.0.0
127
+ * @category constructors
128
+ */
129
+ export const collectAll: <In>() => Sink<Chunk.Chunk<In>, In> = internal.collectAll
130
+
131
+ /**
132
+ * A sink that collects first `n` elements into a chunk.
133
+ *
134
+ * @since 2.0.0
135
+ * @category constructors
136
+ */
137
+ export const collectAllN: <In>(n: number) => Sink<Chunk.Chunk<In>, In, In> = internal.collectAllN
138
+
139
+ /**
140
+ * Repeatedly runs the sink and accumulates its results into a `Chunk`.
141
+ *
142
+ * @since 2.0.0
143
+ * @category utils
144
+ */
145
+ export const collectAllFrom: <A, In, L extends In, E, R>(
146
+ self: Sink<A, In, L, E, R>
147
+ ) => Sink<Chunk.Chunk<A>, In, L, E, R> = internal.collectAllFrom
148
+
149
+ /**
150
+ * A sink that collects all of its inputs into a map. The keys are extracted
151
+ * from inputs using the keying function `key`; if multiple inputs use the
152
+ * same key, they are merged using the `merge` function.
153
+ *
154
+ * @since 2.0.0
155
+ * @category constructors
156
+ */
157
+ export const collectAllToMap: <In, K>(
158
+ key: (input: In) => K,
159
+ merge: (x: In, y: In) => In
160
+ ) => Sink<HashMap.HashMap<K, In>, In> = internal.collectAllToMap
161
+
162
+ /**
163
+ * A sink that collects first `n` keys into a map. The keys are calculated
164
+ * from inputs using the keying function `key`; if multiple inputs use the the
165
+ * same key, they are merged using the `merge` function.
166
+ *
167
+ * @since 2.0.0
168
+ * @category constructors
169
+ */
170
+ export const collectAllToMapN: <In, K>(
171
+ n: number,
172
+ key: (input: In) => K,
173
+ merge: (x: In, y: In) => In
174
+ ) => Sink<HashMap.HashMap<K, In>, In, In> = internal.collectAllToMapN
175
+
176
+ /**
177
+ * A sink that collects all of its inputs into a set.
178
+ *
179
+ * @since 2.0.0
180
+ * @category constructors
181
+ */
182
+ export const collectAllToSet: <In>() => Sink<HashSet.HashSet<In>, In> = internal.collectAllToSet
183
+
184
+ /**
185
+ * A sink that collects first `n` distinct inputs into a set.
186
+ *
187
+ * @since 2.0.0
188
+ * @category constructors
189
+ */
190
+ export const collectAllToSetN: <In>(n: number) => Sink<HashSet.HashSet<In>, In, In> = internal.collectAllToSetN
191
+
192
+ /**
193
+ * Accumulates incoming elements into a chunk until predicate `p` is
194
+ * satisfied.
195
+ *
196
+ * @since 2.0.0
197
+ * @category constructors
198
+ */
199
+ export const collectAllUntil: <In>(p: Predicate<In>) => Sink<Chunk.Chunk<In>, In, In> = internal.collectAllUntil
200
+
201
+ /**
202
+ * Accumulates incoming elements into a chunk until effectful predicate `p` is
203
+ * satisfied.
204
+ *
205
+ * @since 2.0.0
206
+ * @category constructors
207
+ */
208
+ export const collectAllUntilEffect: <In, E, R>(
209
+ p: (input: In) => Effect.Effect<boolean, E, R>
210
+ ) => Sink<Chunk.Chunk<In>, In, In, E, R> = internal.collectAllUntilEffect
211
+
212
+ /**
213
+ * Accumulates incoming elements into a chunk as long as they verify predicate
214
+ * `p`.
215
+ *
216
+ * @since 2.0.0
217
+ * @category constructors
218
+ */
219
+ export const collectAllWhile: {
220
+ <In, Out extends In>(refinement: Refinement<In, Out>): Sink<Chunk.Chunk<Out>, In, In>
221
+ <In>(predicate: Predicate<In>): Sink<Chunk.Chunk<In>, In, In>
222
+ } = internal.collectAllWhile
223
+
224
+ /**
225
+ * Accumulates incoming elements into a chunk as long as they verify effectful
226
+ * predicate `p`.
227
+ *
228
+ * @since 2.0.0
229
+ * @category constructors
230
+ */
231
+ export const collectAllWhileEffect: <In, E, R>(
232
+ predicate: (input: In) => Effect.Effect<boolean, E, R>
233
+ ) => Sink<Chunk.Chunk<In>, In, In, E, R> = internal.collectAllWhileEffect
234
+
235
+ /**
236
+ * Repeatedly runs the sink for as long as its results satisfy the predicate
237
+ * `p`. The sink's results will be accumulated using the stepping function `f`.
238
+ *
239
+ * @since 2.0.0
240
+ * @category utils
241
+ */
242
+ export const collectAllWhileWith: {
243
+ <A, S>(
244
+ options: { readonly initial: S; readonly while: Predicate<A>; readonly body: (s: S, a: A) => S }
245
+ ): <In, L extends In, E, R>(self: Sink<A, In, L, E, R>) => Sink<S, In, L, E, R>
246
+ <A, In, L extends In, E, R, S>(
247
+ self: Sink<A, In, L, E, R>,
248
+ options: { readonly initial: S; readonly while: Predicate<A>; readonly body: (s: S, a: A) => S }
249
+ ): Sink<S, In, L, E, R>
250
+ } = internal.collectAllWhileWith as any
251
+
252
+ /**
253
+ * Collects the leftovers from the stream when the sink succeeds and returns
254
+ * them as part of the sink's result.
255
+ *
256
+ * @since 2.0.0
257
+ * @category utils
258
+ */
259
+ export const collectLeftover: <A, In, L, E, R>(
260
+ self: Sink<A, In, L, E, R>
261
+ ) => Sink<[A, Chunk.Chunk<L>], In, never, E, R> = internal.collectLeftover
262
+
263
+ /**
264
+ * Transforms this sink's input elements.
265
+ *
266
+ * @since 2.0.0
267
+ * @category mapping
268
+ */
269
+ export const mapInput: {
270
+ <In0, In>(f: (input: In0) => In): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E, R>
271
+ <A, In, L, E, R, In0>(self: Sink<A, In, L, E, R>, f: (input: In0) => In): Sink<A, In0, L, E, R>
272
+ } = internal.mapInput
273
+
274
+ /**
275
+ * Effectfully transforms this sink's input elements.
276
+ *
277
+ * @since 2.0.0
278
+ * @category mapping
279
+ */
280
+ export const mapInputEffect: {
281
+ <In0, In, E2, R2>(
282
+ f: (input: In0) => Effect.Effect<In, E2, R2>
283
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E2 | E, R2 | R>
284
+ <A, In, L, E, R, In0, E2, R2>(
285
+ self: Sink<A, In, L, E, R>,
286
+ f: (input: In0) => Effect.Effect<In, E2, R2>
287
+ ): Sink<A, In0, L, E | E2, R | R2>
288
+ } = internal.mapInputEffect
289
+
290
+ /**
291
+ * Transforms this sink's input chunks. `f` must preserve chunking-invariance.
292
+ *
293
+ * @since 2.0.0
294
+ * @category mapping
295
+ */
296
+ export const mapInputChunks: {
297
+ <In0, In>(
298
+ f: (chunk: Chunk.Chunk<In0>) => Chunk.Chunk<In>
299
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E, R>
300
+ <A, In, L, E, R, In0>(
301
+ self: Sink<A, In, L, E, R>,
302
+ f: (chunk: Chunk.Chunk<In0>) => Chunk.Chunk<In>
303
+ ): Sink<A, In0, L, E, R>
304
+ } = internal.mapInputChunks
305
+
306
+ /**
307
+ * Effectfully transforms this sink's input chunks. `f` must preserve
308
+ * chunking-invariance.
309
+ *
310
+ * @since 2.0.0
311
+ * @category mapping
312
+ */
313
+ export const mapInputChunksEffect: {
314
+ <In0, In, E2, R2>(
315
+ f: (chunk: Chunk.Chunk<In0>) => Effect.Effect<Chunk.Chunk<In>, E2, R2>
316
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E2 | E, R2 | R>
317
+ <A, In, L, E, R, In0, E2, R2>(
318
+ self: Sink<A, In, L, E, R>,
319
+ f: (chunk: Chunk.Chunk<In0>) => Effect.Effect<Chunk.Chunk<In>, E2, R2>
320
+ ): Sink<A, In0, L, E | E2, R | R2>
321
+ } = internal.mapInputChunksEffect
322
+
323
+ /**
324
+ * A sink that counts the number of elements fed to it.
325
+ *
326
+ * @since 2.0.0
327
+ * @category constructors
328
+ */
329
+ export const count: Sink<number, unknown> = internal.count
330
+
331
+ /**
332
+ * Creates a sink halting with the specified defect.
333
+ *
334
+ * @since 2.0.0
335
+ * @category constructors
336
+ */
337
+ export const die: (defect: unknown) => Sink<never, unknown> = internal.die
338
+
339
+ /**
340
+ * Creates a sink halting with the specified message, wrapped in a
341
+ * `RuntimeException`.
342
+ *
343
+ * @since 2.0.0
344
+ * @category constructors
345
+ */
346
+ export const dieMessage: (message: string) => Sink<never, unknown> = internal.dieMessage
347
+
348
+ /**
349
+ * Creates a sink halting with the specified defect.
350
+ *
351
+ * @since 2.0.0
352
+ * @category constructors
353
+ */
354
+ export const dieSync: (evaluate: LazyArg<unknown>) => Sink<never, unknown> = internal.dieSync
355
+
356
+ /**
357
+ * Transforms both inputs and result of this sink using the provided
358
+ * functions.
359
+ *
360
+ * @since 2.0.0
361
+ * @category mapping
362
+ */
363
+ export const dimap: {
364
+ <In0, In, A, A2>(
365
+ options: { readonly onInput: (input: In0) => In; readonly onDone: (a: A) => A2 }
366
+ ): <L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In0, L, E, R>
367
+ <A, In, L, E, R, In0, A2>(
368
+ self: Sink<A, In, L, E, R>,
369
+ options: { readonly onInput: (input: In0) => In; readonly onDone: (a: A) => A2 }
370
+ ): Sink<A2, In0, L, E, R>
371
+ } = internal.dimap
372
+
373
+ /**
374
+ * Effectfully transforms both inputs and result of this sink using the
375
+ * provided functions.
376
+ *
377
+ * @since 2.0.0
378
+ * @category mapping
379
+ */
380
+ export const dimapEffect: {
381
+ <In0, In, E2, R2, A, A2, E3, R3>(
382
+ options: {
383
+ readonly onInput: (input: In0) => Effect.Effect<In, E2, R2>
384
+ readonly onDone: (a: A) => Effect.Effect<A2, E3, R3>
385
+ }
386
+ ): <L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In0, L, E2 | E3 | E, R2 | R3 | R>
387
+ <A, In, L, E, R, In0, E2, R2, A2, E3, R3>(
388
+ self: Sink<A, In, L, E, R>,
389
+ options: {
390
+ readonly onInput: (input: In0) => Effect.Effect<In, E2, R2>
391
+ readonly onDone: (a: A) => Effect.Effect<A2, E3, R3>
392
+ }
393
+ ): Sink<A2, In0, L, E | E2 | E3, R | R2 | R3>
394
+ } = internal.dimapEffect
395
+
396
+ /**
397
+ * Transforms both input chunks and result of this sink using the provided
398
+ * functions.
399
+ *
400
+ * @since 2.0.0
401
+ * @category mapping
402
+ */
403
+ export const dimapChunks: {
404
+ <In0, In, A, A2>(
405
+ options: { readonly onInput: (chunk: Chunk.Chunk<In0>) => Chunk.Chunk<In>; readonly onDone: (a: A) => A2 }
406
+ ): <L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In0, L, E, R>
407
+ <A, In, L, E, R, In0, A2>(
408
+ self: Sink<A, In, L, E, R>,
409
+ options: { readonly onInput: (chunk: Chunk.Chunk<In0>) => Chunk.Chunk<In>; readonly onDone: (a: A) => A2 }
410
+ ): Sink<A2, In0, L, E, R>
411
+ } = internal.dimapChunks
412
+
413
+ /**
414
+ * Effectfully transforms both input chunks and result of this sink using the
415
+ * provided functions. `f` and `g` must preserve chunking-invariance.
416
+ *
417
+ * @since 2.0.0
418
+ * @category mapping
419
+ */
420
+ export const dimapChunksEffect: {
421
+ <In0, In, E2, R2, A, A2, E3, R3>(
422
+ options: {
423
+ readonly onInput: (chunk: Chunk.Chunk<In0>) => Effect.Effect<Chunk.Chunk<In>, E2, R2>
424
+ readonly onDone: (a: A) => Effect.Effect<A2, E3, R3>
425
+ }
426
+ ): <L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In0, L, E2 | E3 | E, R2 | R3 | R>
427
+ <A, In, L, E, R, In0, E2, R2, A2, E3, R3>(
428
+ self: Sink<A, In, L, E, R>,
429
+ options: {
430
+ readonly onInput: (chunk: Chunk.Chunk<In0>) => Effect.Effect<Chunk.Chunk<In>, E2, R2>
431
+ readonly onDone: (a: A) => Effect.Effect<A2, E3, R3>
432
+ }
433
+ ): Sink<A2, In0, L, E | E2 | E3, R | R2 | R3>
434
+ } = internal.dimapChunksEffect
435
+
436
+ /**
437
+ * A sink that ignores its inputs.
438
+ *
439
+ * @since 2.0.0
440
+ * @category constructors
441
+ */
442
+ export const drain: Sink<void, unknown> = internal.drain
443
+
444
+ /**
445
+ * Creates a sink that drops `n` elements.
446
+ *
447
+ * @since 2.0.0
448
+ * @category constructors
449
+ */
450
+ export const drop: <In>(n: number) => Sink<unknown, In, In> = internal.drop
451
+
452
+ /**
453
+ * Drops incoming elements until the predicate is satisfied.
454
+ *
455
+ * @since 2.0.0
456
+ * @category constructors
457
+ */
458
+ export const dropUntil: <In>(predicate: Predicate<In>) => Sink<unknown, In, In> = internal.dropUntil
459
+
460
+ /**
461
+ * Drops incoming elements until the effectful predicate is satisfied.
462
+ *
463
+ * @since 2.0.0
464
+ * @category constructors
465
+ */
466
+ export const dropUntilEffect: <In, E, R>(
467
+ predicate: (input: In) => Effect.Effect<boolean, E, R>
468
+ ) => Sink<unknown, In, In, E, R> = internal.dropUntilEffect
469
+
470
+ /**
471
+ * Drops incoming elements as long as the predicate is satisfied.
472
+ *
473
+ * @since 2.0.0
474
+ * @category constructors
475
+ */
476
+ export const dropWhile: <In>(predicate: Predicate<In>) => Sink<unknown, In, In> = internal.dropWhile
477
+
478
+ /**
479
+ * Drops incoming elements as long as the effectful predicate is satisfied.
480
+ *
481
+ * @since 2.0.0
482
+ * @category constructors
483
+ */
484
+ export const dropWhileEffect: <In, E, R>(
485
+ predicate: (input: In) => Effect.Effect<boolean, E, R>
486
+ ) => Sink<unknown, In, In, E, R> = internal.dropWhileEffect
487
+
488
+ /**
489
+ * Returns a new sink with an attached finalizer. The finalizer is guaranteed
490
+ * to be executed so long as the sink begins execution (and regardless of
491
+ * whether or not it completes).
492
+ *
493
+ * @since 2.0.0
494
+ * @category finalization
495
+ */
496
+ export const ensuring: {
497
+ <X, R2>(
498
+ finalizer: Effect.Effect<X, never, R2>
499
+ ): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E, R2 | R>
500
+ <A, In, L, E, R, X, R2>(self: Sink<A, In, L, E, R>, finalizer: Effect.Effect<X, never, R2>): Sink<A, In, L, E, R | R2>
501
+ } = internal.ensuring
502
+
503
+ /**
504
+ * Returns a new sink with an attached finalizer. The finalizer is guaranteed
505
+ * to be executed so long as the sink begins execution (and regardless of
506
+ * whether or not it completes).
507
+ *
508
+ * @since 2.0.0
509
+ * @category finalization
510
+ */
511
+ export const ensuringWith: {
512
+ <A, E, X, R2>(
513
+ finalizer: (exit: Exit.Exit<A, E>) => Effect.Effect<X, never, R2>
514
+ ): <In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E, R2 | R>
515
+ <A, In, L, E, R, X, R2>(
516
+ self: Sink<A, In, L, E, R>,
517
+ finalizer: (exit: Exit.Exit<A, E>) => Effect.Effect<X, never, R2>
518
+ ): Sink<A, In, L, E, R | R2>
519
+ } = internal.ensuringWith
520
+
521
+ /**
522
+ * Accesses the whole context of the sink.
523
+ *
524
+ * @since 2.0.0
525
+ * @category constructors
526
+ */
527
+ export const context: <R>() => Sink<Context.Context<R>, unknown, never, never, R> = internal.context
528
+
529
+ /**
530
+ * Accesses the context of the sink.
531
+ *
532
+ * @since 2.0.0
533
+ * @category constructors
534
+ */
535
+ export const contextWith: <R, Z>(f: (context: Context.Context<R>) => Z) => Sink<Z, unknown, never, never, R> =
536
+ internal.contextWith
537
+
538
+ /**
539
+ * Accesses the context of the sink in the context of an effect.
540
+ *
541
+ * @since 2.0.0
542
+ * @category constructors
543
+ */
544
+ export const contextWithEffect: <R0, A, E, R>(
545
+ f: (context: Context.Context<R0>) => Effect.Effect<A, E, R>
546
+ ) => Sink<A, unknown, never, E, R0 | R> = internal.contextWithEffect
547
+
548
+ /**
549
+ * Accesses the context of the sink in the context of a sink.
550
+ *
551
+ * @since 2.0.0
552
+ * @category constructors
553
+ */
554
+ export const contextWithSink: <R0, A, In, L, E, R>(
555
+ f: (context: Context.Context<R0>) => Sink<A, In, L, E, R>
556
+ ) => Sink<A, In, L, E, R0 | R> = internal.contextWithSink
557
+
558
+ /**
559
+ * A sink that returns whether all elements satisfy the specified predicate.
560
+ *
561
+ * @since 2.0.0
562
+ * @category constructors
563
+ */
564
+ export const every: <In>(predicate: Predicate<In>) => Sink<boolean, In, In> = internal.every
565
+
566
+ /**
567
+ * A sink that always fails with the specified error.
568
+ *
569
+ * @since 2.0.0
570
+ * @category constructors
571
+ */
572
+ export const fail: <E>(e: E) => Sink<never, unknown, never, E> = internal.fail
573
+
574
+ /**
575
+ * A sink that always fails with the specified lazily evaluated error.
576
+ *
577
+ * @since 2.0.0
578
+ * @category constructors
579
+ */
580
+ export const failSync: <E>(evaluate: LazyArg<E>) => Sink<never, unknown, never, E> = internal.failSync
581
+
582
+ /**
583
+ * Creates a sink halting with a specified `Cause`.
584
+ *
585
+ * @since 2.0.0
586
+ * @category constructors
587
+ */
588
+ export const failCause: <E>(cause: Cause.Cause<E>) => Sink<never, unknown, never, E> = internal.failCause
589
+
590
+ /**
591
+ * Creates a sink halting with a specified lazily evaluated `Cause`.
592
+ *
593
+ * @since 2.0.0
594
+ * @category constructors
595
+ */
596
+ export const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Sink<never, unknown, never, E> =
597
+ internal.failCauseSync
598
+
599
+ /**
600
+ * Filters the sink's input with the given predicate.
601
+ *
602
+ * @since 2.0.0
603
+ * @category filtering
604
+ */
605
+ export const filterInput: {
606
+ <In, In1 extends In, In2 extends In1>(
607
+ f: Refinement<In1, In2>
608
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In2, L, E, R>
609
+ <In, In1 extends In>(f: Predicate<In1>): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In1, L, E, R>
610
+ } = internal.filterInput
611
+
612
+ /**
613
+ * Effectfully filter the input of this sink using the specified predicate.
614
+ *
615
+ * @since 2.0.0
616
+ * @category filtering
617
+ */
618
+ export const filterInputEffect: {
619
+ <In, In1 extends In, E2, R2>(
620
+ f: (input: In1) => Effect.Effect<boolean, E2, R2>
621
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In1, L, E2 | E, R2 | R>
622
+ <A, In, L, E, R, In1 extends In, E2, R2>(
623
+ self: Sink<A, In, L, E, R>,
624
+ f: (input: In1) => Effect.Effect<boolean, E2, R2>
625
+ ): Sink<A, In1, L, E | E2, R | R2>
626
+ } = internal.filterInputEffect
627
+
628
+ /**
629
+ * Creates a sink that produces values until one verifies the predicate `f`.
630
+ *
631
+ * @since 2.0.0
632
+ * @category elements
633
+ */
634
+ export const findEffect: {
635
+ <A, E2, R2>(
636
+ f: (a: A) => Effect.Effect<boolean, E2, R2>
637
+ ): <In, L extends In, E, R>(self: Sink<A, In, L, E, R>) => Sink<Option.Option<A>, In, L, E2 | E, R2 | R>
638
+ <A, In, L extends In, E, R, E2, R2>(
639
+ self: Sink<A, In, L, E, R>,
640
+ f: (a: A) => Effect.Effect<boolean, E2, R2>
641
+ ): Sink<Option.Option<A>, In, L, E | E2, R | R2>
642
+ } = internal.findEffect as any
643
+
644
+ /**
645
+ * A sink that folds its inputs with the provided function, termination
646
+ * predicate and initial state.
647
+ *
648
+ * @since 2.0.0
649
+ * @category folding
650
+ */
651
+ export const fold: <S, In>(s: S, contFn: Predicate<S>, f: (s: S, input: In) => S) => Sink<S, In, In> = internal.fold
652
+
653
+ /**
654
+ * Folds over the result of the sink
655
+ *
656
+ * @since 2.0.0
657
+ * @category folding
658
+ */
659
+ export const foldSink: {
660
+ <E, A1, In, In1 extends In, L1, E1, R1, A, A2, In2 extends In, L2, E2, R2>(
661
+ options: {
662
+ readonly onFailure: (err: E) => Sink<A1, In1, L1, E1, R1>
663
+ readonly onSuccess: (a: A) => Sink<A2, In2, L2, E2, R2>
664
+ }
665
+ ): <L, R>(self: Sink<A, In, L, E, R>) => Sink<A1 | A2, In1 & In2, L1 | L2, E1 | E2, R1 | R2 | R>
666
+ <A, In, L, E, R, A1, In1 extends In, L1, E1, R1, A2, In2 extends In, L2, E2, R2>(
667
+ self: Sink<A, In, L, E, R>,
668
+ options: {
669
+ readonly onFailure: (err: E) => Sink<A1, In1, L1, E1, R1>
670
+ readonly onSuccess: (a: A) => Sink<A2, In2, L2, E2, R2>
671
+ }
672
+ ): Sink<A1 | A2, In1 & In2, L1 | L2, E1 | E2, R | R1 | R2>
673
+ } = internal.foldSink
674
+
675
+ /**
676
+ * A sink that folds its input chunks with the provided function, termination
677
+ * predicate and initial state. `contFn` condition is checked only for the
678
+ * initial value and at the end of processing of each chunk. `f` and `contFn`
679
+ * must preserve chunking-invariance.
680
+ *
681
+ * @since 2.0.0
682
+ * @category constructors
683
+ */
684
+ export const foldChunks: <S, In>(
685
+ s: S,
686
+ contFn: Predicate<S>,
687
+ f: (s: S, chunk: Chunk.Chunk<In>) => S
688
+ ) => Sink<S, In> = internal.foldChunks
689
+
690
+ /**
691
+ * A sink that effectfully folds its input chunks with the provided function,
692
+ * termination predicate and initial state. `contFn` condition is checked only
693
+ * for the initial value and at the end of processing of each chunk. `f` and
694
+ * `contFn` must preserve chunking-invariance.
695
+ *
696
+ * @since 2.0.0
697
+ * @category constructors
698
+ */
699
+ export const foldChunksEffect: <S, In, E, R>(
700
+ s: S,
701
+ contFn: Predicate<S>,
702
+ f: (s: S, chunk: Chunk.Chunk<In>) => Effect.Effect<S, E, R>
703
+ ) => Sink<S, In, In, E, R> = internal.foldChunksEffect
704
+
705
+ /**
706
+ * A sink that effectfully folds its inputs with the provided function,
707
+ * termination predicate and initial state.
708
+ *
709
+ * @since 2.0.0
710
+ * @category constructors
711
+ */
712
+ export const foldEffect: <S, In, E, R>(
713
+ s: S,
714
+ contFn: Predicate<S>,
715
+ f: (s: S, input: In) => Effect.Effect<S, E, R>
716
+ ) => Sink<S, In, In, E, R> = internal.foldEffect
717
+
718
+ /**
719
+ * A sink that folds its inputs with the provided function and initial state.
720
+ *
721
+ * @since 2.0.0
722
+ * @category constructors
723
+ */
724
+ export const foldLeft: <S, In>(s: S, f: (s: S, input: In) => S) => Sink<S, In> = internal.foldLeft
725
+
726
+ /**
727
+ * A sink that folds its input chunks with the provided function and initial
728
+ * state. `f` must preserve chunking-invariance.
729
+ *
730
+ * @since 2.0.0
731
+ * @category constructors
732
+ */
733
+ export const foldLeftChunks: <S, In>(s: S, f: (s: S, chunk: Chunk.Chunk<In>) => S) => Sink<S, In> =
734
+ internal.foldLeftChunks
735
+
736
+ /**
737
+ * A sink that effectfully folds its input chunks with the provided function
738
+ * and initial state. `f` must preserve chunking-invariance.
739
+ *
740
+ * @since 2.0.0
741
+ * @category constructors
742
+ */
743
+ export const foldLeftChunksEffect: <S, In, E, R>(
744
+ s: S,
745
+ f: (s: S, chunk: Chunk.Chunk<In>) => Effect.Effect<S, E, R>
746
+ ) => Sink<S, In, never, E, R> = internal.foldLeftChunksEffect
747
+
748
+ /**
749
+ * A sink that effectfully folds its inputs with the provided function and
750
+ * initial state.
751
+ *
752
+ * @since 2.0.0
753
+ * @category constructors
754
+ */
755
+ export const foldLeftEffect: <S, In, E, R>(
756
+ s: S,
757
+ f: (s: S, input: In) => Effect.Effect<S, E, R>
758
+ ) => Sink<S, In, In, E, R> = internal.foldLeftEffect
759
+
760
+ /**
761
+ * Creates a sink that folds elements of type `In` into a structure of type
762
+ * `S` until `max` elements have been folded.
763
+ *
764
+ * Like `Sink.foldWeighted`, but with a constant cost function of `1`.
765
+ *
766
+ * @since 2.0.0
767
+ * @category constructors
768
+ */
769
+ export const foldUntil: <In, S>(s: S, max: number, f: (s: S, input: In) => S) => Sink<S, In, In> = internal.foldUntil
770
+
771
+ /**
772
+ * Creates a sink that effectfully folds elements of type `In` into a
773
+ * structure of type `S` until `max` elements have been folded.
774
+ *
775
+ * Like `Sink.foldWeightedEffect` but with a constant cost function of `1`.
776
+ *
777
+ * @since 2.0.0
778
+ * @category constructors
779
+ */
780
+ export const foldUntilEffect: <S, In, E, R>(
781
+ s: S,
782
+ max: number,
783
+ f: (s: S, input: In) => Effect.Effect<S, E, R>
784
+ ) => Sink<S, In, In, E, R> = internal.foldUntilEffect
785
+
786
+ /**
787
+ * Creates a sink that folds elements of type `In` into a structure of type `S`,
788
+ * until `max` worth of elements (determined by the `costFn`) have been folded.
789
+ *
790
+ * **Note**
791
+ *
792
+ * Elements that have an individual cost larger than `max` will force the sink
793
+ * to cross the `max` cost. See `Sink.foldWeightedDecompose` for a variant
794
+ * that can handle these cases.
795
+ *
796
+ * @since 2.0.0
797
+ * @category constructors
798
+ */
799
+ export const foldWeighted: <S, In>(
800
+ options: {
801
+ readonly initial: S
802
+ readonly maxCost: number
803
+ readonly cost: (s: S, input: In) => number
804
+ readonly body: (s: S, input: In) => S
805
+ }
806
+ ) => Sink<S, In, In> = internal.foldWeighted
807
+
808
+ /**
809
+ * Creates a sink that folds elements of type `In` into a structure of type
810
+ * `S`, until `max` worth of elements (determined by the `costFn`) have been
811
+ * folded.
812
+ *
813
+ * The `decompose` function will be used for decomposing elements that cause
814
+ * an `S` aggregate to cross `max` into smaller elements. For example:
815
+ *
816
+ * ```ts skip-type-checking
817
+ * pipe(
818
+ * Stream.make(1, 5, 1),
819
+ * Stream.transduce(
820
+ * Sink.foldWeightedDecompose(
821
+ * Chunk.empty<number>(),
822
+ * 4,
823
+ * (n: number) => n,
824
+ * (n: number) => Chunk.make(n - 1, 1),
825
+ * (acc, el) => pipe(acc, Chunk.append(el))
826
+ * )
827
+ * ),
828
+ * Stream.runCollect
829
+ * )
830
+ * ```
831
+ *
832
+ * The stream would emit the elements `Chunk(1), Chunk(4), Chunk(1, 1)`.
833
+ *
834
+ * Be vigilant with this function, it has to generate "simpler" values or the
835
+ * fold may never end. A value is considered indivisible if `decompose` yields
836
+ * the empty chunk or a single-valued chunk. In these cases, there is no other
837
+ * choice than to yield a value that will cross the threshold.
838
+ *
839
+ * `Sink.foldWeightedDecomposeEffect` allows the decompose function to return an
840
+ * effect value, and consequently it allows the sink to fail.
841
+ *
842
+ * @since 2.0.0
843
+ * @category constructors
844
+ */
845
+ export const foldWeightedDecompose: <S, In>(
846
+ options: {
847
+ readonly initial: S
848
+ readonly maxCost: number
849
+ readonly cost: (s: S, input: In) => number
850
+ readonly decompose: (input: In) => Chunk.Chunk<In>
851
+ readonly body: (s: S, input: In) => S
852
+ }
853
+ ) => Sink<S, In, In> = internal.foldWeightedDecompose
854
+
855
+ /**
856
+ * Creates a sink that effectfully folds elements of type `In` into a
857
+ * structure of type `S`, until `max` worth of elements (determined by the
858
+ * `costFn`) have been folded.
859
+ *
860
+ * The `decompose` function will be used for decomposing elements that cause
861
+ * an `S` aggregate to cross `max` into smaller elements. Be vigilant with
862
+ * this function, it has to generate "simpler" values or the fold may never
863
+ * end. A value is considered indivisible if `decompose` yields the empty
864
+ * chunk or a single-valued chunk. In these cases, there is no other choice
865
+ * than to yield a value that will cross the threshold.
866
+ *
867
+ * See `Sink.foldWeightedDecompose` for an example.
868
+ *
869
+ * @since 2.0.0
870
+ * @category constructors
871
+ */
872
+ export const foldWeightedDecomposeEffect: <S, In, E, R, E2, R2, E3, R3>(
873
+ options: {
874
+ readonly initial: S
875
+ readonly maxCost: number
876
+ readonly cost: (s: S, input: In) => Effect.Effect<number, E, R>
877
+ readonly decompose: (input: In) => Effect.Effect<Chunk.Chunk<In>, E2, R2>
878
+ readonly body: (s: S, input: In) => Effect.Effect<S, E3, R3>
879
+ }
880
+ ) => Sink<S, In, In, E | E2 | E3, R | R2 | R3> = internal.foldWeightedDecomposeEffect
881
+
882
+ /**
883
+ * Creates a sink that effectfully folds elements of type `In` into a
884
+ * structure of type `S`, until `max` worth of elements (determined by the
885
+ * `costFn`) have been folded.
886
+ *
887
+ * @note
888
+ * Elements that have an individual cost larger than `max` will force the
889
+ * sink to cross the `max` cost. See `Sink.foldWeightedDecomposeEffect` for
890
+ * a variant that can handle these cases.
891
+ *
892
+ * @since 2.0.0
893
+ * @category constructors
894
+ */
895
+ export const foldWeightedEffect: <S, In, E, R, E2, R2>(
896
+ options: {
897
+ readonly initial: S
898
+ readonly maxCost: number
899
+ readonly cost: (s: S, input: In) => Effect.Effect<number, E, R>
900
+ readonly body: (s: S, input: In) => Effect.Effect<S, E2, R2>
901
+ }
902
+ ) => Sink<S, In, In, E | E2, R | R2> = internal.foldWeightedEffect
903
+
904
+ /**
905
+ * A sink that executes the provided effectful function for every element fed
906
+ * to it.
907
+ *
908
+ * @since 2.0.0
909
+ * @category constructors
910
+ */
911
+ export const forEach: <In, X, E, R>(f: (input: In) => Effect.Effect<X, E, R>) => Sink<void, In, never, E, R> =
912
+ internal.forEach
913
+
914
+ /**
915
+ * A sink that executes the provided effectful function for every chunk fed to
916
+ * it.
917
+ *
918
+ * @since 2.0.0
919
+ * @category constructors
920
+ */
921
+ export const forEachChunk: <In, X, E, R>(
922
+ f: (input: Chunk.Chunk<In>) => Effect.Effect<X, E, R>
923
+ ) => Sink<void, In, never, E, R> = internal.forEachChunk
924
+
925
+ /**
926
+ * A sink that executes the provided effectful function for every chunk fed to
927
+ * it until `f` evaluates to `false`.
928
+ *
929
+ * @since 2.0.0
930
+ * @category constructors
931
+ */
932
+ export const forEachChunkWhile: <In, E, R>(
933
+ f: (input: Chunk.Chunk<In>) => Effect.Effect<boolean, E, R>
934
+ ) => Sink<void, In, In, E, R> = internal.forEachChunkWhile
935
+
936
+ /**
937
+ * A sink that executes the provided effectful function for every element fed
938
+ * to it until `f` evaluates to `false`.
939
+ *
940
+ * @since 2.0.0
941
+ * @category constructors
942
+ */
943
+ export const forEachWhile: <In, E, R>(f: (input: In) => Effect.Effect<boolean, E, R>) => Sink<void, In, In, E, R> =
944
+ internal.forEachWhile
945
+
946
+ /**
947
+ * Runs this sink until it yields a result, then uses that result to create
948
+ * another sink from the provided function which will continue to run until it
949
+ * yields a result.
950
+ *
951
+ * This function essentially runs sinks in sequence.
952
+ *
953
+ * @since 2.0.0
954
+ * @category sequencing
955
+ */
956
+ export const flatMap: {
957
+ <A, A1, In, In1 extends In, L1, E1, R1>(
958
+ f: (a: A) => Sink<A1, In1, L1, E1, R1>
959
+ ): <L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A1, In & In1, L1 | L, E1 | E, R1 | R>
960
+ <A, In, L, E, R, A1, In1 extends In, L1, E1, R1>(
961
+ self: Sink<A, In, L, E, R>,
962
+ f: (a: A) => Sink<A1, In1, L1, E1, R1>
963
+ ): Sink<A1, In & In1, L | L1, E | E1, R | R1>
964
+ } = internal.flatMap
965
+
966
+ /**
967
+ * Creates a sink from a `Channel`.
968
+ *
969
+ * @since 2.0.0
970
+ * @category constructors
971
+ */
972
+ export const fromChannel: <L, In, E, A, R>(
973
+ channel: Channel.Channel<Chunk.Chunk<L>, Chunk.Chunk<In>, E, never, A, unknown, R>
974
+ ) => Sink<A, In, L, E, R> = internal.fromChannel
975
+
976
+ /**
977
+ * Creates a `Channel` from a Sink.
978
+ *
979
+ * @since 2.0.0
980
+ * @category constructors
981
+ */
982
+ export const toChannel: <A, In, L, E, R>(
983
+ self: Sink<A, In, L, E, R>
984
+ ) => Channel.Channel<Chunk.Chunk<L>, Chunk.Chunk<In>, E, never, A, unknown, R> = internal.toChannel
985
+
986
+ /**
987
+ * Creates a single-value sink produced from an effect.
988
+ *
989
+ * @since 2.0.0
990
+ * @category constructors
991
+ */
992
+ export const fromEffect: <A, E, R>(effect: Effect.Effect<A, E, R>) => Sink<A, unknown, never, E, R> =
993
+ internal.fromEffect
994
+
995
+ /**
996
+ * Create a sink which publishes each element to the specified `PubSub`.
997
+ *
998
+ * If the `shutdown` parameter is `true`, the `PubSub` will be shutdown after
999
+ * the sink is evaluated (defaults to `false`).
1000
+ *
1001
+ * @since 2.0.0
1002
+ * @category constructors
1003
+ */
1004
+ export const fromPubSub: <In>(
1005
+ pubsub: PubSub.PubSub<In>,
1006
+ options?: {
1007
+ readonly shutdown?: boolean | undefined
1008
+ }
1009
+ ) => Sink<void, In> = internal.fromPubSub
1010
+
1011
+ /**
1012
+ * Creates a sink from a chunk processing function.
1013
+ *
1014
+ * @since 2.0.0
1015
+ * @category constructors
1016
+ */
1017
+ export const fromPush: <In, L0, R0, L, R>(
1018
+ push: Effect.Effect<
1019
+ (_: Option.Option<Chunk.Chunk<In>>) => Effect.Effect<void, readonly [Either.Either<R0, L0>, Chunk.Chunk<L>], R>,
1020
+ never,
1021
+ R
1022
+ >
1023
+ ) => Sink<R0, In, L, L0, Exclude<R, Scope.Scope>> = internal.fromPush
1024
+
1025
+ /**
1026
+ * Create a sink which enqueues each element into the specified queue.
1027
+ *
1028
+ * If the `shutdown` parameter is `true`, the queue will be shutdown after the
1029
+ * sink is evaluated (defaults to `false`).
1030
+ *
1031
+ * @since 2.0.0
1032
+ * @category constructors
1033
+ */
1034
+ export const fromQueue: <In>(
1035
+ queue: Queue.Enqueue<In>,
1036
+ options?: {
1037
+ readonly shutdown?: boolean | undefined
1038
+ }
1039
+ ) => Sink<void, In> = internal.fromQueue
1040
+
1041
+ /**
1042
+ * Creates a sink containing the first value.
1043
+ *
1044
+ * @since 2.0.0
1045
+ * @category constructors
1046
+ */
1047
+ export const head: <In>() => Sink<Option.Option<In>, In, In> = internal.head
1048
+
1049
+ /**
1050
+ * Drains the remaining elements from the stream after the sink finishes
1051
+ *
1052
+ * @since 2.0.0
1053
+ * @category utils
1054
+ */
1055
+ export const ignoreLeftover: <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, never, E, R> =
1056
+ internal.ignoreLeftover
1057
+
1058
+ /**
1059
+ * Creates a sink containing the last value.
1060
+ *
1061
+ * @since 2.0.0
1062
+ * @category constructors
1063
+ */
1064
+ export const last: <In>() => Sink<Option.Option<In>, In, In> = internal.last
1065
+
1066
+ /**
1067
+ * Creates a sink that does not consume any input but provides the given chunk
1068
+ * as its leftovers
1069
+ *
1070
+ * @since 2.0.0
1071
+ * @category constructors
1072
+ */
1073
+ export const leftover: <L>(chunk: Chunk.Chunk<L>) => Sink<void, unknown, L> = internal.leftover
1074
+
1075
+ /**
1076
+ * Transforms this sink's result.
1077
+ *
1078
+ * @since 2.0.0
1079
+ * @category mapping
1080
+ */
1081
+ export const map: {
1082
+ <A, A2>(f: (a: A) => A2): <In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L, E, R>
1083
+ <A, In, L, E, R, A2>(self: Sink<A, In, L, E, R>, f: (a: A) => A2): Sink<A2, In, L, E, R>
1084
+ } = internal.map
1085
+
1086
+ /**
1087
+ * Effectfully transforms this sink's result.
1088
+ *
1089
+ * @since 2.0.0
1090
+ * @category mapping
1091
+ */
1092
+ export const mapEffect: {
1093
+ <A, A2, E2, R2>(
1094
+ f: (a: A) => Effect.Effect<A2, E2, R2>
1095
+ ): <In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L, E2 | E, R2 | R>
1096
+ <A, In, L, E, R, A2, E2, R2>(
1097
+ self: Sink<A, In, L, E, R>,
1098
+ f: (a: A) => Effect.Effect<A2, E2, R2>
1099
+ ): Sink<A2, In, L, E | E2, R | R2>
1100
+ } = internal.mapEffect
1101
+
1102
+ /**
1103
+ * Transforms the errors emitted by this sink using `f`.
1104
+ *
1105
+ * @since 2.0.0
1106
+ * @category mapping
1107
+ */
1108
+ export const mapError: {
1109
+ <E, E2>(f: (error: E) => E2): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E2, R>
1110
+ <A, In, L, E, R, E2>(self: Sink<A, In, L, E, R>, f: (error: E) => E2): Sink<A, In, L, E2, R>
1111
+ } = internal.mapError
1112
+
1113
+ /**
1114
+ * Transforms the leftovers emitted by this sink using `f`.
1115
+ *
1116
+ * @since 2.0.0
1117
+ * @category mapping
1118
+ */
1119
+ export const mapLeftover: {
1120
+ <L, L2>(f: (leftover: L) => L2): <A, In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L2, E, R>
1121
+ <A, In, L, E, R, L2>(self: Sink<A, In, L, E, R>, f: (leftover: L) => L2): Sink<A, In, L2, E, R>
1122
+ } = internal.mapLeftover
1123
+
1124
+ /**
1125
+ * Creates a sink which transforms it's inputs into a string.
1126
+ *
1127
+ * @since 2.0.0
1128
+ * @category constructors
1129
+ */
1130
+ export const mkString: Sink<string, unknown> = internal.mkString
1131
+
1132
+ /**
1133
+ * Creates a sink which never terminates.
1134
+ *
1135
+ * @since 2.0.0
1136
+ * @category constructors
1137
+ */
1138
+ export const never: Sink<never, unknown> = internal.never
1139
+
1140
+ /**
1141
+ * Switch to another sink in case of failure
1142
+ *
1143
+ * @since 2.0.0
1144
+ * @category error handling
1145
+ */
1146
+ export const orElse: {
1147
+ <A2, In2, L2, E2, R2>(
1148
+ that: LazyArg<Sink<A2, In2, L2, E2, R2>>
1149
+ ): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2 | A, In & In2, L2 | L, E2 | E, R2 | R>
1150
+ <A, In, L, E, R, A2, In2, L2, E2, R2>(
1151
+ self: Sink<A, In, L, E, R>,
1152
+ that: LazyArg<Sink<A2, In2, L2, E2, R2>>
1153
+ ): Sink<A | A2, In & In2, L | L2, E | E2, R | R2>
1154
+ } = internal.orElse
1155
+
1156
+ /**
1157
+ * Provides the sink with its required context, which eliminates its
1158
+ * dependency on `R`.
1159
+ *
1160
+ * @since 2.0.0
1161
+ * @category context
1162
+ */
1163
+ export const provideContext: {
1164
+ <R>(context: Context.Context<R>): <A, In, L, E>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E, never>
1165
+ <A, In, L, E, R>(self: Sink<A, In, L, E, R>, context: Context.Context<R>): Sink<A, In, L, E, never>
1166
+ } = internal.provideContext
1167
+
1168
+ /**
1169
+ * Runs both sinks in parallel on the input, , returning the result or the
1170
+ * error from the one that finishes first.
1171
+ *
1172
+ * @since 2.0.0
1173
+ * @category utils
1174
+ */
1175
+ export const race: {
1176
+ <R1, E1, In1, L1, A1>(
1177
+ that: Sink<A1, In1, L1, E1, R1>
1178
+ ): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A1 | A, In & In1, L1 | L, E1 | E, R1 | R>
1179
+ <A, In, L, E, R, A1, In1, L1, E1, R1>(
1180
+ self: Sink<A, In, L, E, R>,
1181
+ that: Sink<A1, In1, L1, E1, R1>
1182
+ ): Sink<A | A1, In & In1, L | L1, E | E1, R | R1>
1183
+ } = internal.race
1184
+
1185
+ /**
1186
+ * Runs both sinks in parallel on the input, returning the result or the error
1187
+ * from the one that finishes first.
1188
+ *
1189
+ * @since 2.0.0
1190
+ * @category utils
1191
+ */
1192
+ export const raceBoth: {
1193
+ <A1, In1, L1, E1, R1>(
1194
+ that: Sink<A1, In1, L1, E1, R1>,
1195
+ options?: { readonly capacity?: number | undefined } | undefined
1196
+ ): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<Either.Either<A1, A>, In & In1, L1 | L, E1 | E, R1 | R>
1197
+ <A, In, L, E, R, A1, In1, L1, E1, R1>(
1198
+ self: Sink<A, In, L, E, R>,
1199
+ that: Sink<A1, In1, L1, E1, R1>,
1200
+ options?: { readonly capacity?: number | undefined } | undefined
1201
+ ): Sink<Either.Either<A1, A>, In & In1, L | L1, E | E1, R | R1>
1202
+ } = internal.raceBoth
1203
+
1204
+ /**
1205
+ * Runs both sinks in parallel on the input, using the specified merge
1206
+ * function as soon as one result or the other has been computed.
1207
+ *
1208
+ * @since 2.0.0
1209
+ * @category utils
1210
+ */
1211
+ export const raceWith: {
1212
+ <A2, In2, L2, E2, R2, A, E, A3, A4>(
1213
+ options: {
1214
+ readonly other: Sink<A2, In2, L2, E2, R2>
1215
+ readonly onSelfDone: (exit: Exit.Exit<A, E>) => MergeDecision.MergeDecision<R2, E2, A2, E2 | E, A3>
1216
+ readonly onOtherDone: (exit: Exit.Exit<A2, E2>) => MergeDecision.MergeDecision<R2, E, A, E2 | E, A4>
1217
+ readonly capacity?: number | undefined
1218
+ }
1219
+ ): <In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A3 | A4, In & In2, L2 | L, E2 | E, R2 | R>
1220
+ <A, In, L, E, R, A2, In2, L2, E2, R2, A3, A4>(
1221
+ self: Sink<A, In, L, E, R>,
1222
+ options: {
1223
+ readonly other: Sink<A2, In2, L2, E2, R2>
1224
+ readonly onSelfDone: (exit: Exit.Exit<A, E>) => MergeDecision.MergeDecision<R2, E2, A2, E | E2, A3>
1225
+ readonly onOtherDone: (exit: Exit.Exit<A2, E2>) => MergeDecision.MergeDecision<R2, E, A, E | E2, A4>
1226
+ readonly capacity?: number | undefined
1227
+ }
1228
+ ): Sink<A3 | A4, In & In2, L | L2, E | E2, R | R2>
1229
+ } = internal.raceWith
1230
+
1231
+ /**
1232
+ * @since 2.0.0
1233
+ * @category error handling
1234
+ */
1235
+ export const refineOrDie: {
1236
+ <E, E2>(pf: (error: E) => Option.Option<E2>): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E2, R>
1237
+ <A, In, L, E, R, E2>(self: Sink<A, In, L, E, R>, pf: (error: E) => Option.Option<E2>): Sink<A, In, L, E2, R>
1238
+ } = internal.refineOrDie
1239
+
1240
+ /**
1241
+ * @since 2.0.0
1242
+ * @category error handling
1243
+ */
1244
+ export const refineOrDieWith: {
1245
+ <E, E2>(
1246
+ pf: (error: E) => Option.Option<E2>,
1247
+ f: (error: E) => unknown
1248
+ ): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E2, R>
1249
+ <A, In, L, E, R, E2>(
1250
+ self: Sink<A, In, L, E, R>,
1251
+ pf: (error: E) => Option.Option<E2>,
1252
+ f: (error: E) => unknown
1253
+ ): Sink<A, In, L, E2, R>
1254
+ } = internal.refineOrDieWith
1255
+
1256
+ /**
1257
+ * A sink that returns whether an element satisfies the specified predicate.
1258
+ *
1259
+ * @since 2.0.0
1260
+ * @category constructors
1261
+ */
1262
+ export const some: <In>(predicate: Predicate<In>) => Sink<boolean, In, In> = internal.some
1263
+
1264
+ /**
1265
+ * Splits the sink on the specified predicate, returning a new sink that
1266
+ * consumes elements until an element after the first satisfies the specified
1267
+ * predicate.
1268
+ *
1269
+ * @since 2.0.0
1270
+ * @category utils
1271
+ */
1272
+ export const splitWhere: {
1273
+ <In>(f: Predicate<In>): <A, L extends In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, In, E, R>
1274
+ <A, In, L extends In, E, R>(self: Sink<A, In, L, E, R>, f: Predicate<In>): Sink<A, In, In, E, R>
1275
+ } = internal.splitWhere
1276
+
1277
+ /**
1278
+ * A sink that immediately ends with the specified value.
1279
+ *
1280
+ * @since 2.0.0
1281
+ * @category constructors
1282
+ */
1283
+ export const succeed: <A>(a: A) => Sink<A, unknown> = internal.succeed
1284
+
1285
+ /**
1286
+ * A sink that sums incoming numeric values.
1287
+ *
1288
+ * @since 2.0.0
1289
+ * @category constructors
1290
+ */
1291
+ export const sum: Sink<number, number> = internal.sum
1292
+
1293
+ /**
1294
+ * Summarize a sink by running an effect when the sink starts and again when
1295
+ * it completes.
1296
+ *
1297
+ * @since 2.0.0
1298
+ * @category utils
1299
+ */
1300
+ export const summarized: {
1301
+ <A2, E2, R2, A3>(
1302
+ summary: Effect.Effect<A2, E2, R2>,
1303
+ f: (start: A2, end: A2) => A3
1304
+ ): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<[A, A3], In, L, E2 | E, R2 | R>
1305
+ <A, In, L, E, R, A2, E2, R2, A3>(
1306
+ self: Sink<A, In, L, E, R>,
1307
+ summary: Effect.Effect<A2, E2, R2>,
1308
+ f: (start: A2, end: A2) => A3
1309
+ ): Sink<[A, A3], In, L, E | E2, R | R2>
1310
+ } = internal.summarized
1311
+
1312
+ /**
1313
+ * Returns a lazily constructed sink that may require effects for its
1314
+ * creation.
1315
+ *
1316
+ * @since 2.0.0
1317
+ * @category constructors
1318
+ */
1319
+ export const suspend: <A, In, L, E, R>(evaluate: LazyArg<Sink<A, In, L, E, R>>) => Sink<A, In, L, E, R> =
1320
+ internal.suspend
1321
+
1322
+ /**
1323
+ * A sink that immediately ends with the specified lazy value.
1324
+ *
1325
+ * @since 2.0.0
1326
+ * @category constructors
1327
+ */
1328
+ export const sync: <A>(evaluate: LazyArg<A>) => Sink<A, unknown> = internal.sync
1329
+
1330
+ /**
1331
+ * A sink that takes the specified number of values.
1332
+ *
1333
+ * @since 2.0.0
1334
+ * @category constructors
1335
+ */
1336
+ export const take: <In>(n: number) => Sink<Chunk.Chunk<In>, In, In> = internal.take
1337
+
1338
+ /**
1339
+ * @since 2.0.0
1340
+ * @category constructors
1341
+ */
1342
+ export const timed: Sink<Duration.Duration, unknown> = internal.timed
1343
+
1344
+ /**
1345
+ * Creates a sink produced from an effect.
1346
+ *
1347
+ * @since 2.0.0
1348
+ * @category constructors
1349
+ */
1350
+ export const unwrap: <A, In, L, E2, R2, E, R>(
1351
+ effect: Effect.Effect<Sink<A, In, L, E2, R2>, E, R>
1352
+ ) => Sink<A, In, L, E2 | E, R2 | R> = internal.unwrap
1353
+
1354
+ /**
1355
+ * Creates a sink produced from a scoped effect.
1356
+ *
1357
+ * @since 2.0.0
1358
+ * @category constructors
1359
+ */
1360
+ export const unwrapScoped: <A, In, L, E, R>(
1361
+ effect: Effect.Effect<Sink<A, In, L, E, R>, E, R>
1362
+ ) => Sink<A, In, L, E, Exclude<R, Scope.Scope>> = internal.unwrapScoped
1363
+
1364
+ /**
1365
+ * Constructs a `Sink` from a function which receives a `Scope` and returns
1366
+ * an effect that will result in a `Sink` if successful.
1367
+ *
1368
+ * @since 3.11.0
1369
+ * @category constructors
1370
+ */
1371
+ export const unwrapScopedWith: <A, In, L, E, R>(
1372
+ f: (scope: Scope.Scope) => Effect.Effect<Sink<A, In, L, E, R>, E, R>
1373
+ ) => Sink<A, In, L, E, R> = internal.unwrapScopedWith
1374
+
1375
+ /**
1376
+ * Returns the sink that executes this one and times its execution.
1377
+ *
1378
+ * @since 2.0.0
1379
+ * @category utils
1380
+ */
1381
+ export const withDuration: <A, In, L, E, R>(
1382
+ self: Sink<A, In, L, E, R>
1383
+ ) => Sink<[A, Duration.Duration], In, L, E, R> = internal.withDuration
1384
+
1385
+ /**
1386
+ * Feeds inputs to this sink until it yields a result, then switches over to
1387
+ * the provided sink until it yields a result, finally combining the two
1388
+ * results into a tuple.
1389
+ *
1390
+ * @since 2.0.0
1391
+ * @category zipping
1392
+ */
1393
+ export const zip: {
1394
+ <A2, In, In2 extends In, L2, E2, R2>(
1395
+ that: Sink<A2, In2, L2, E2, R2>,
1396
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1397
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<[A, A2], In & In2, L2 | L, E2 | E, R2 | R>
1398
+ <A, In, L, E, R, A2, In2 extends In, L2, E2, R2>(
1399
+ self: Sink<A, In, L, E, R>,
1400
+ that: Sink<A2, In2, L2, E2, R2>,
1401
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1402
+ ): Sink<[A, A2], In & In2, L | L2, E | E2, R | R2>
1403
+ } = internal.zip
1404
+
1405
+ /**
1406
+ * Like `Sink.zip` but keeps only the result from this sink.
1407
+ *
1408
+ * @since 2.0.0
1409
+ * @category zipping
1410
+ */
1411
+ export const zipLeft: {
1412
+ <A2, In, In2 extends In, L2, E2, R2>(
1413
+ that: Sink<A2, In2, L2, E2, R2>,
1414
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1415
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In & In2, L2 | L, E2 | E, R2 | R>
1416
+ <A, In, L, E, R, A2, In2 extends In, L2, E2, R2>(
1417
+ self: Sink<A, In, L, E, R>,
1418
+ that: Sink<A2, In2, L2, E2, R2>,
1419
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1420
+ ): Sink<A, In & In2, L | L2, E | E2, R | R2>
1421
+ } = internal.zipLeft
1422
+
1423
+ /**
1424
+ * Like `Sink.zip` but keeps only the result from `that` sink.
1425
+ *
1426
+ * @since 2.0.0
1427
+ * @category zipping
1428
+ */
1429
+ export const zipRight: {
1430
+ <A2, In, In2 extends In, L2, E2, R2>(
1431
+ that: Sink<A2, In2, L2, E2, R2>,
1432
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1433
+ ): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In & In2, L2 | L, E2 | E, R2 | R>
1434
+ <A, In, L, E, R, A2, In2 extends In, L2, E2, R2>(
1435
+ self: Sink<A, In, L, E, R>,
1436
+ that: Sink<A2, In2, L2, E2, R2>,
1437
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1438
+ ): Sink<A2, In & In2, L | L2, E | E2, R | R2>
1439
+ } = internal.zipRight
1440
+
1441
+ /**
1442
+ * Feeds inputs to this sink until it yields a result, then switches over to
1443
+ * the provided sink until it yields a result, finally combining the two
1444
+ * results with `f`.
1445
+ *
1446
+ * @since 2.0.0
1447
+ * @category zipping
1448
+ */
1449
+ export const zipWith: {
1450
+ <A2, In, In2 extends In, L2, E2, R2, A, A3>(
1451
+ that: Sink<A2, In2, L2, E2, R2>,
1452
+ f: (a: A, a2: A2) => A3,
1453
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1454
+ ): <L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A3, In & In2, L2 | L, E2 | E, R2 | R>
1455
+ <A, In, L, E, R, A2, In2 extends In, L2, E2, R2, A3>(
1456
+ self: Sink<A, In, L, E, R>,
1457
+ that: Sink<A2, In2, L2, E2, R2>,
1458
+ f: (a: A, a2: A2) => A3,
1459
+ options?: { readonly concurrent?: boolean | undefined } | undefined
1460
+ ): Sink<A3, In & In2, L | L2, E | E2, R | R2>
1461
+ } = internal.zipWith