effect 4.0.0-beta.3 → 4.0.0-beta.30

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 (983) hide show
  1. package/dist/Array.d.ts +126 -299
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +102 -62
  4. package/dist/Array.js.map +1 -1
  5. package/dist/Brand.d.ts +1 -1
  6. package/dist/Brand.d.ts.map +1 -1
  7. package/dist/Brand.js +1 -1
  8. package/dist/Brand.js.map +1 -1
  9. package/dist/Cache.d.ts +2 -2
  10. package/dist/Cache.d.ts.map +1 -1
  11. package/dist/Cache.js +6 -5
  12. package/dist/Cache.js.map +1 -1
  13. package/dist/Cause.d.ts +2 -2
  14. package/dist/Cause.d.ts.map +1 -1
  15. package/dist/Channel.d.ts +116 -30
  16. package/dist/Channel.d.ts.map +1 -1
  17. package/dist/Channel.js +82 -37
  18. package/dist/Channel.js.map +1 -1
  19. package/dist/Chunk.d.ts +54 -247
  20. package/dist/Chunk.d.ts.map +1 -1
  21. package/dist/Chunk.js +36 -67
  22. package/dist/Chunk.js.map +1 -1
  23. package/dist/Combiner.d.ts +280 -13
  24. package/dist/Combiner.d.ts.map +1 -1
  25. package/dist/Combiner.js +198 -7
  26. package/dist/Combiner.js.map +1 -1
  27. package/dist/Config.d.ts +165 -9
  28. package/dist/Config.d.ts.map +1 -1
  29. package/dist/Config.js +65 -10
  30. package/dist/Config.js.map +1 -1
  31. package/dist/ConfigProvider.d.ts +1 -1
  32. package/dist/Cron.d.ts +1 -1
  33. package/dist/Data.d.ts +535 -366
  34. package/dist/Data.d.ts.map +1 -1
  35. package/dist/Data.js +132 -79
  36. package/dist/Data.js.map +1 -1
  37. package/dist/DateTime.d.ts +23 -161
  38. package/dist/DateTime.d.ts.map +1 -1
  39. package/dist/DateTime.js +6 -51
  40. package/dist/DateTime.js.map +1 -1
  41. package/dist/Duration.d.ts +11 -11
  42. package/dist/Duration.d.ts.map +1 -1
  43. package/dist/Duration.js +11 -11
  44. package/dist/Duration.js.map +1 -1
  45. package/dist/Effect.d.ts +1206 -924
  46. package/dist/Effect.d.ts.map +1 -1
  47. package/dist/Effect.js +390 -329
  48. package/dist/Effect.js.map +1 -1
  49. package/dist/Encoding.d.ts +194 -0
  50. package/dist/Encoding.d.ts.map +1 -0
  51. package/dist/Encoding.js +352 -0
  52. package/dist/Encoding.js.map +1 -0
  53. package/dist/Equal.d.ts +276 -109
  54. package/dist/Equal.d.ts.map +1 -1
  55. package/dist/Equal.js +124 -48
  56. package/dist/Equal.js.map +1 -1
  57. package/dist/ErrorReporter.d.ts +374 -0
  58. package/dist/ErrorReporter.d.ts.map +1 -0
  59. package/dist/ErrorReporter.js +244 -0
  60. package/dist/ErrorReporter.js.map +1 -0
  61. package/dist/Exit.d.ts +24 -12
  62. package/dist/Exit.d.ts.map +1 -1
  63. package/dist/Exit.js +8 -4
  64. package/dist/Exit.js.map +1 -1
  65. package/dist/Fiber.d.ts +3 -2
  66. package/dist/Fiber.d.ts.map +1 -1
  67. package/dist/Fiber.js.map +1 -1
  68. package/dist/FileSystem.d.ts +1 -1
  69. package/dist/FileSystem.d.ts.map +1 -1
  70. package/dist/FileSystem.js +5 -5
  71. package/dist/FileSystem.js.map +1 -1
  72. package/dist/Filter.d.ts +34 -38
  73. package/dist/Filter.d.ts.map +1 -1
  74. package/dist/Filter.js +15 -13
  75. package/dist/Filter.js.map +1 -1
  76. package/dist/Formatter.d.ts +131 -47
  77. package/dist/Formatter.d.ts.map +1 -1
  78. package/dist/Formatter.js +229 -51
  79. package/dist/Formatter.js.map +1 -1
  80. package/dist/Function.d.ts +1 -9
  81. package/dist/Function.d.ts.map +1 -1
  82. package/dist/Function.js +2 -10
  83. package/dist/Function.js.map +1 -1
  84. package/dist/Graph.d.ts +1 -1
  85. package/dist/Graph.d.ts.map +1 -1
  86. package/dist/Graph.js +5 -8
  87. package/dist/Graph.js.map +1 -1
  88. package/dist/HashMap.d.ts +15 -14
  89. package/dist/HashMap.d.ts.map +1 -1
  90. package/dist/HashMap.js +4 -4
  91. package/dist/HashMap.js.map +1 -1
  92. package/dist/Iterable.d.ts +39 -39
  93. package/dist/Iterable.d.ts.map +1 -1
  94. package/dist/Iterable.js +94 -22
  95. package/dist/Iterable.js.map +1 -1
  96. package/dist/JsonSchema.d.ts +299 -10
  97. package/dist/JsonSchema.d.ts.map +1 -1
  98. package/dist/JsonSchema.js +323 -4
  99. package/dist/JsonSchema.js.map +1 -1
  100. package/dist/Latch.d.ts +109 -0
  101. package/dist/Latch.d.ts.map +1 -0
  102. package/dist/Latch.js +72 -0
  103. package/dist/Latch.js.map +1 -0
  104. package/dist/Layer.d.ts +121 -126
  105. package/dist/Layer.d.ts.map +1 -1
  106. package/dist/Layer.js +43 -44
  107. package/dist/Layer.js.map +1 -1
  108. package/dist/LayerMap.d.ts +8 -8
  109. package/dist/LayerMap.d.ts.map +1 -1
  110. package/dist/LayerMap.js +3 -3
  111. package/dist/LogLevel.d.ts +32 -0
  112. package/dist/LogLevel.d.ts.map +1 -1
  113. package/dist/LogLevel.js +28 -100
  114. package/dist/LogLevel.js.map +1 -1
  115. package/dist/Logger.d.ts +29 -95
  116. package/dist/Logger.d.ts.map +1 -1
  117. package/dist/Logger.js +2 -3
  118. package/dist/Logger.js.map +1 -1
  119. package/dist/ManagedRuntime.d.ts +2 -2
  120. package/dist/ManagedRuntime.js +2 -2
  121. package/dist/Metric.d.ts +4 -6
  122. package/dist/Metric.d.ts.map +1 -1
  123. package/dist/Metric.js +3 -5
  124. package/dist/Metric.js.map +1 -1
  125. package/dist/Newtype.d.ts +291 -0
  126. package/dist/Newtype.d.ts.map +1 -0
  127. package/dist/Newtype.js +161 -0
  128. package/dist/Newtype.js.map +1 -0
  129. package/dist/Optic.d.ts +947 -18
  130. package/dist/Optic.d.ts.map +1 -1
  131. package/dist/Optic.js +454 -5
  132. package/dist/Optic.js.map +1 -1
  133. package/dist/Option.d.ts +23 -16
  134. package/dist/Option.d.ts.map +1 -1
  135. package/dist/Option.js +15 -9
  136. package/dist/Option.js.map +1 -1
  137. package/dist/Pipeable.d.ts +17 -0
  138. package/dist/Pipeable.d.ts.map +1 -1
  139. package/dist/Pipeable.js +19 -1
  140. package/dist/Pipeable.js.map +1 -1
  141. package/dist/PlatformError.d.ts +10 -9
  142. package/dist/PlatformError.d.ts.map +1 -1
  143. package/dist/PlatformError.js +2 -2
  144. package/dist/PlatformError.js.map +1 -1
  145. package/dist/Pool.d.ts +6 -4
  146. package/dist/Pool.d.ts.map +1 -1
  147. package/dist/Pool.js +7 -5
  148. package/dist/Pool.js.map +1 -1
  149. package/dist/PubSub.d.ts +3 -2
  150. package/dist/PubSub.d.ts.map +1 -1
  151. package/dist/PubSub.js +3 -2
  152. package/dist/PubSub.js.map +1 -1
  153. package/dist/Pull.d.ts.map +1 -1
  154. package/dist/Pull.js +1 -1
  155. package/dist/Pull.js.map +1 -1
  156. package/dist/Queue.d.ts.map +1 -1
  157. package/dist/Queue.js +0 -1
  158. package/dist/Queue.js.map +1 -1
  159. package/dist/Random.d.ts +35 -1
  160. package/dist/Random.d.ts.map +1 -1
  161. package/dist/Random.js +46 -12
  162. package/dist/Random.js.map +1 -1
  163. package/dist/RcMap.d.ts +2 -2
  164. package/dist/RcMap.d.ts.map +1 -1
  165. package/dist/RcMap.js +1 -1
  166. package/dist/RcMap.js.map +1 -1
  167. package/dist/RcRef.d.ts +1 -1
  168. package/dist/RcRef.d.ts.map +1 -1
  169. package/dist/Record.d.ts +23 -120
  170. package/dist/Record.d.ts.map +1 -1
  171. package/dist/Record.js +21 -41
  172. package/dist/Record.js.map +1 -1
  173. package/dist/Reducer.d.ts +166 -7
  174. package/dist/Reducer.d.ts.map +1 -1
  175. package/dist/Reducer.js +135 -1
  176. package/dist/Reducer.js.map +1 -1
  177. package/dist/References.d.ts +9 -4
  178. package/dist/References.d.ts.map +1 -1
  179. package/dist/References.js +6 -1
  180. package/dist/References.js.map +1 -1
  181. package/dist/Request.d.ts +1 -1
  182. package/dist/Request.d.ts.map +1 -1
  183. package/dist/Request.js +2 -1
  184. package/dist/Request.js.map +1 -1
  185. package/dist/RequestResolver.d.ts +25 -45
  186. package/dist/RequestResolver.d.ts.map +1 -1
  187. package/dist/RequestResolver.js +10 -30
  188. package/dist/RequestResolver.js.map +1 -1
  189. package/dist/Result.d.ts +1 -1
  190. package/dist/Result.d.ts.map +1 -1
  191. package/dist/Result.js +1 -2
  192. package/dist/Result.js.map +1 -1
  193. package/dist/Runtime.d.ts +66 -0
  194. package/dist/Runtime.d.ts.map +1 -1
  195. package/dist/Runtime.js +79 -6
  196. package/dist/Runtime.js.map +1 -1
  197. package/dist/Schedule.d.ts +191 -102
  198. package/dist/Schedule.d.ts.map +1 -1
  199. package/dist/Schedule.js +152 -66
  200. package/dist/Schedule.js.map +1 -1
  201. package/dist/Scheduler.d.ts +9 -0
  202. package/dist/Scheduler.d.ts.map +1 -1
  203. package/dist/Scheduler.js +11 -0
  204. package/dist/Scheduler.js.map +1 -1
  205. package/dist/Schema.d.ts +309 -88
  206. package/dist/Schema.d.ts.map +1 -1
  207. package/dist/Schema.js +499 -109
  208. package/dist/Schema.js.map +1 -1
  209. package/dist/SchemaAST.d.ts.map +1 -1
  210. package/dist/SchemaAST.js +129 -23
  211. package/dist/SchemaAST.js.map +1 -1
  212. package/dist/SchemaGetter.d.ts +5 -5
  213. package/dist/SchemaGetter.d.ts.map +1 -1
  214. package/dist/SchemaGetter.js +12 -14
  215. package/dist/SchemaGetter.js.map +1 -1
  216. package/dist/SchemaParser.d.ts +5 -0
  217. package/dist/SchemaParser.d.ts.map +1 -1
  218. package/dist/SchemaParser.js +10 -0
  219. package/dist/SchemaParser.js.map +1 -1
  220. package/dist/SchemaRepresentation.d.ts +44 -43
  221. package/dist/SchemaRepresentation.d.ts.map +1 -1
  222. package/dist/SchemaRepresentation.js +49 -24
  223. package/dist/SchemaRepresentation.js.map +1 -1
  224. package/dist/SchemaTransformation.d.ts +107 -3
  225. package/dist/SchemaTransformation.d.ts.map +1 -1
  226. package/dist/SchemaTransformation.js +159 -4
  227. package/dist/SchemaTransformation.js.map +1 -1
  228. package/dist/ScopedCache.d.ts +2 -2
  229. package/dist/ScopedCache.d.ts.map +1 -1
  230. package/dist/ScopedCache.js +1 -1
  231. package/dist/ScopedCache.js.map +1 -1
  232. package/dist/Semaphore.d.ts +211 -0
  233. package/dist/Semaphore.d.ts.map +1 -0
  234. package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
  235. package/dist/Semaphore.js.map +1 -0
  236. package/dist/ServiceMap.d.ts +41 -31
  237. package/dist/ServiceMap.d.ts.map +1 -1
  238. package/dist/ServiceMap.js +3 -3
  239. package/dist/ServiceMap.js.map +1 -1
  240. package/dist/Sink.d.ts +13 -13
  241. package/dist/Sink.d.ts.map +1 -1
  242. package/dist/Sink.js +53 -6
  243. package/dist/Sink.js.map +1 -1
  244. package/dist/Stdio.d.ts +16 -4
  245. package/dist/Stdio.d.ts.map +1 -1
  246. package/dist/Stdio.js +18 -0
  247. package/dist/Stdio.js.map +1 -1
  248. package/dist/Stream.d.ts +250 -428
  249. package/dist/Stream.d.ts.map +1 -1
  250. package/dist/Stream.js +137 -82
  251. package/dist/Stream.js.map +1 -1
  252. package/dist/Struct.d.ts +16 -0
  253. package/dist/Struct.d.ts.map +1 -1
  254. package/dist/Struct.js +22 -0
  255. package/dist/Struct.js.map +1 -1
  256. package/dist/SubscriptionRef.d.ts +2 -1
  257. package/dist/SubscriptionRef.d.ts.map +1 -1
  258. package/dist/SubscriptionRef.js +2 -1
  259. package/dist/SubscriptionRef.js.map +1 -1
  260. package/dist/SynchronizedRef.d.ts +2 -1
  261. package/dist/SynchronizedRef.d.ts.map +1 -1
  262. package/dist/SynchronizedRef.js +2 -1
  263. package/dist/SynchronizedRef.js.map +1 -1
  264. package/dist/Trie.d.ts +18 -17
  265. package/dist/Trie.d.ts.map +1 -1
  266. package/dist/Trie.js +5 -5
  267. package/dist/Trie.js.map +1 -1
  268. package/dist/TxChunk.d.ts +37 -37
  269. package/dist/TxChunk.d.ts.map +1 -1
  270. package/dist/TxChunk.js +3 -3
  271. package/dist/TxChunk.js.map +1 -1
  272. package/dist/TxDeferred.d.ts +328 -0
  273. package/dist/TxDeferred.d.ts.map +1 -0
  274. package/dist/TxDeferred.js +196 -0
  275. package/dist/TxDeferred.js.map +1 -0
  276. package/dist/TxHashMap.d.ts +84 -83
  277. package/dist/TxHashMap.d.ts.map +1 -1
  278. package/dist/TxHashMap.js +24 -24
  279. package/dist/TxHashMap.js.map +1 -1
  280. package/dist/TxHashSet.d.ts +35 -35
  281. package/dist/TxHashSet.d.ts.map +1 -1
  282. package/dist/TxHashSet.js +14 -14
  283. package/dist/TxHashSet.js.map +1 -1
  284. package/dist/TxPriorityQueue.d.ts +609 -0
  285. package/dist/TxPriorityQueue.d.ts.map +1 -0
  286. package/dist/TxPriorityQueue.js +415 -0
  287. package/dist/TxPriorityQueue.js.map +1 -0
  288. package/dist/TxPubSub.d.ts +585 -0
  289. package/dist/TxPubSub.d.ts.map +1 -0
  290. package/dist/TxPubSub.js +521 -0
  291. package/dist/TxPubSub.js.map +1 -0
  292. package/dist/TxQueue.d.ts +32 -32
  293. package/dist/TxQueue.d.ts.map +1 -1
  294. package/dist/TxQueue.js +26 -26
  295. package/dist/TxQueue.js.map +1 -1
  296. package/dist/TxReentrantLock.d.ts +523 -0
  297. package/dist/TxReentrantLock.d.ts.map +1 -0
  298. package/dist/TxReentrantLock.js +504 -0
  299. package/dist/TxReentrantLock.js.map +1 -0
  300. package/dist/TxRef.d.ts +34 -34
  301. package/dist/TxRef.d.ts.map +1 -1
  302. package/dist/TxRef.js +21 -14
  303. package/dist/TxRef.js.map +1 -1
  304. package/dist/TxSemaphore.d.ts +8 -8
  305. package/dist/TxSemaphore.d.ts.map +1 -1
  306. package/dist/TxSemaphore.js +7 -7
  307. package/dist/TxSemaphore.js.map +1 -1
  308. package/dist/TxSubscriptionRef.d.ts +508 -0
  309. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  310. package/dist/TxSubscriptionRef.js +293 -0
  311. package/dist/TxSubscriptionRef.js.map +1 -0
  312. package/dist/Types.d.ts +80 -23
  313. package/dist/Types.d.ts.map +1 -1
  314. package/dist/Utils.d.ts +137 -65
  315. package/dist/Utils.d.ts.map +1 -1
  316. package/dist/Utils.js +38 -66
  317. package/dist/Utils.js.map +1 -1
  318. package/dist/index.d.ts +718 -23
  319. package/dist/index.d.ts.map +1 -1
  320. package/dist/index.js +718 -23
  321. package/dist/index.js.map +1 -1
  322. package/dist/internal/core.js +11 -3
  323. package/dist/internal/core.js.map +1 -1
  324. package/dist/internal/dateTime.js +3 -11
  325. package/dist/internal/dateTime.js.map +1 -1
  326. package/dist/internal/effect.js +264 -126
  327. package/dist/internal/effect.js.map +1 -1
  328. package/dist/internal/hashMap.js +5 -4
  329. package/dist/internal/hashMap.js.map +1 -1
  330. package/dist/internal/random.d.ts +2 -0
  331. package/dist/internal/random.d.ts.map +1 -0
  332. package/dist/internal/random.js +13 -0
  333. package/dist/internal/random.js.map +1 -0
  334. package/dist/internal/rcRef.js +3 -2
  335. package/dist/internal/rcRef.js.map +1 -1
  336. package/dist/internal/request.js +2 -2
  337. package/dist/internal/request.js.map +1 -1
  338. package/dist/internal/schema/annotations.js +2 -0
  339. package/dist/internal/schema/annotations.js.map +1 -1
  340. package/dist/internal/schema/representation.js +47 -106
  341. package/dist/internal/schema/representation.js.map +1 -1
  342. package/dist/internal/schema/schema.js +1 -0
  343. package/dist/internal/schema/schema.js.map +1 -1
  344. package/dist/internal/schema/to-codec.js +7 -10
  345. package/dist/internal/schema/to-codec.js.map +1 -1
  346. package/dist/internal/trie.js +5 -4
  347. package/dist/internal/trie.js.map +1 -1
  348. package/dist/testing/TestClock.d.ts +8 -7
  349. package/dist/testing/TestClock.d.ts.map +1 -1
  350. package/dist/testing/TestClock.js +6 -4
  351. package/dist/testing/TestClock.js.map +1 -1
  352. package/dist/testing/TestSchema.d.ts +266 -32
  353. package/dist/testing/TestSchema.d.ts.map +1 -1
  354. package/dist/testing/TestSchema.js +296 -23
  355. package/dist/testing/TestSchema.js.map +1 -1
  356. package/dist/testing/index.d.ts +64 -1
  357. package/dist/testing/index.d.ts.map +1 -1
  358. package/dist/testing/index.js +64 -1
  359. package/dist/testing/index.js.map +1 -1
  360. package/dist/unstable/ai/AiError.d.ts +134 -51
  361. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  362. package/dist/unstable/ai/AiError.js +19 -16
  363. package/dist/unstable/ai/AiError.js.map +1 -1
  364. package/dist/unstable/ai/Chat.d.ts +5 -5
  365. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  366. package/dist/unstable/ai/Chat.js +38 -44
  367. package/dist/unstable/ai/Chat.js.map +1 -1
  368. package/dist/unstable/ai/LanguageModel.d.ts +16 -30
  369. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  370. package/dist/unstable/ai/LanguageModel.js +97 -37
  371. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  372. package/dist/unstable/ai/McpSchema.d.ts +183 -88
  373. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  374. package/dist/unstable/ai/McpSchema.js +57 -12
  375. package/dist/unstable/ai/McpSchema.js.map +1 -1
  376. package/dist/unstable/ai/McpServer.d.ts +66 -13
  377. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  378. package/dist/unstable/ai/McpServer.js +193 -51
  379. package/dist/unstable/ai/McpServer.js.map +1 -1
  380. package/dist/unstable/ai/Model.d.ts +25 -7
  381. package/dist/unstable/ai/Model.d.ts.map +1 -1
  382. package/dist/unstable/ai/Model.js +22 -6
  383. package/dist/unstable/ai/Model.js.map +1 -1
  384. package/dist/unstable/ai/Prompt.d.ts +20 -20
  385. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  386. package/dist/unstable/ai/Response.d.ts +26 -26
  387. package/dist/unstable/ai/Response.d.ts.map +1 -1
  388. package/dist/unstable/ai/Response.js +1 -1
  389. package/dist/unstable/ai/Response.js.map +1 -1
  390. package/dist/unstable/ai/Tool.d.ts +20 -4
  391. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  392. package/dist/unstable/ai/Tool.js +14 -9
  393. package/dist/unstable/ai/Tool.js.map +1 -1
  394. package/dist/unstable/ai/Toolkit.d.ts +1 -1
  395. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  396. package/dist/unstable/ai/Toolkit.js +4 -11
  397. package/dist/unstable/ai/Toolkit.js.map +1 -1
  398. package/dist/unstable/ai/index.d.ts +1 -1
  399. package/dist/unstable/ai/index.js +1 -1
  400. package/dist/unstable/ai/internal/codec-transformer.js +0 -5
  401. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  402. package/dist/unstable/cli/CliError.d.ts +27 -60
  403. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  404. package/dist/unstable/cli/CliError.js +25 -57
  405. package/dist/unstable/cli/CliError.js.map +1 -1
  406. package/dist/unstable/cli/CliOutput.js +59 -6
  407. package/dist/unstable/cli/CliOutput.js.map +1 -1
  408. package/dist/unstable/cli/Command.d.ts +368 -56
  409. package/dist/unstable/cli/Command.d.ts.map +1 -1
  410. package/dist/unstable/cli/Command.js +325 -64
  411. package/dist/unstable/cli/Command.js.map +1 -1
  412. package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
  413. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
  414. package/dist/unstable/cli/GlobalFlag.js +118 -0
  415. package/dist/unstable/cli/GlobalFlag.js.map +1 -0
  416. package/dist/unstable/cli/HelpDoc.d.ts +70 -2
  417. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  418. package/dist/unstable/cli/Primitive.d.ts +1 -1
  419. package/dist/unstable/cli/Primitive.js +1 -1
  420. package/dist/unstable/cli/Prompt.js +35 -8
  421. package/dist/unstable/cli/Prompt.js.map +1 -1
  422. package/dist/unstable/cli/index.d.ts +4 -0
  423. package/dist/unstable/cli/index.d.ts.map +1 -1
  424. package/dist/unstable/cli/index.js +4 -0
  425. package/dist/unstable/cli/index.js.map +1 -1
  426. package/dist/unstable/cli/internal/command.d.ts +40 -14
  427. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  428. package/dist/unstable/cli/internal/command.js +72 -46
  429. package/dist/unstable/cli/internal/command.js.map +1 -1
  430. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +7 -2
  431. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  432. package/dist/unstable/cli/internal/config.js +42 -0
  433. package/dist/unstable/cli/internal/config.js.map +1 -1
  434. package/dist/unstable/cli/internal/help.d.ts +33 -0
  435. package/dist/unstable/cli/internal/help.d.ts.map +1 -0
  436. package/dist/unstable/cli/internal/help.js +125 -0
  437. package/dist/unstable/cli/internal/help.js.map +1 -0
  438. package/dist/unstable/cli/internal/parser.js +55 -42
  439. package/dist/unstable/cli/internal/parser.js.map +1 -1
  440. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  441. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  442. package/dist/unstable/cluster/ClusterCron.js +1 -1
  443. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  444. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  445. package/dist/unstable/cluster/ClusterWorkflowEngine.js +4 -3
  446. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  447. package/dist/unstable/cluster/Entity.d.ts +7 -6
  448. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  449. package/dist/unstable/cluster/Entity.js.map +1 -1
  450. package/dist/unstable/cluster/EntityResource.d.ts +2 -2
  451. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  452. package/dist/unstable/cluster/Envelope.d.ts +1 -1
  453. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  454. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  455. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  456. package/dist/unstable/cluster/Message.d.ts +10 -10
  457. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  458. package/dist/unstable/cluster/MessageStorage.js +2 -1
  459. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  460. package/dist/unstable/cluster/Reply.d.ts +6 -6
  461. package/dist/unstable/cluster/Runner.d.ts +1 -1
  462. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  463. package/dist/unstable/cluster/Runners.js +4 -3
  464. package/dist/unstable/cluster/Runners.js.map +1 -1
  465. package/dist/unstable/cluster/Sharding.d.ts +2 -2
  466. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  467. package/dist/unstable/cluster/Sharding.js +9 -7
  468. package/dist/unstable/cluster/Sharding.js.map +1 -1
  469. package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
  470. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  471. package/dist/unstable/cluster/ShardingConfig.js +20 -20
  472. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  473. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  474. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  475. package/dist/unstable/cluster/internal/entityManager.js +5 -4
  476. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  477. package/dist/unstable/cluster/internal/entityReaper.js +2 -1
  478. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  479. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  480. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  481. package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
  482. package/dist/unstable/encoding/Msgpack.d.ts +1 -1
  483. package/dist/unstable/encoding/Ndjson.d.ts +1 -1
  484. package/dist/unstable/encoding/Sse.d.ts +4 -4
  485. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  486. package/dist/unstable/encoding/Sse.js +1 -1
  487. package/dist/unstable/encoding/Sse.js.map +1 -1
  488. package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
  489. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  490. package/dist/unstable/eventlog/EventLog.js +2 -1
  491. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  492. package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
  493. package/dist/unstable/http/Cookies.d.ts +47 -3
  494. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  495. package/dist/unstable/http/Cookies.js +24 -2
  496. package/dist/unstable/http/Cookies.js.map +1 -1
  497. package/dist/unstable/http/Headers.d.ts +16 -0
  498. package/dist/unstable/http/Headers.d.ts.map +1 -1
  499. package/dist/unstable/http/Headers.js +38 -10
  500. package/dist/unstable/http/Headers.js.map +1 -1
  501. package/dist/unstable/http/HttpBody.d.ts +3 -3
  502. package/dist/unstable/http/HttpBody.d.ts.map +1 -1
  503. package/dist/unstable/http/HttpBody.js +6 -6
  504. package/dist/unstable/http/HttpBody.js.map +1 -1
  505. package/dist/unstable/http/HttpClient.d.ts +117 -15
  506. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  507. package/dist/unstable/http/HttpClient.js +189 -12
  508. package/dist/unstable/http/HttpClient.js.map +1 -1
  509. package/dist/unstable/http/HttpClientError.d.ts +7 -7
  510. package/dist/unstable/http/HttpClientRequest.d.ts +16 -11
  511. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  512. package/dist/unstable/http/HttpClientRequest.js +31 -20
  513. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  514. package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
  515. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  516. package/dist/unstable/http/HttpClientResponse.js +4 -0
  517. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  518. package/dist/unstable/http/HttpEffect.d.ts +7 -5
  519. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  520. package/dist/unstable/http/HttpEffect.js +46 -54
  521. package/dist/unstable/http/HttpEffect.js.map +1 -1
  522. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  523. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  524. package/dist/unstable/http/HttpMethod.js +3 -3
  525. package/dist/unstable/http/HttpMethod.js.map +1 -1
  526. package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
  527. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  528. package/dist/unstable/http/HttpMiddleware.js +8 -17
  529. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  530. package/dist/unstable/http/HttpServerError.d.ts +20 -33
  531. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  532. package/dist/unstable/http/HttpServerError.js +37 -44
  533. package/dist/unstable/http/HttpServerError.js.map +1 -1
  534. package/dist/unstable/http/HttpServerRequest.d.ts +12 -1
  535. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  536. package/dist/unstable/http/HttpServerRequest.js +291 -1
  537. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  538. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  539. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  540. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  541. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  542. package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
  543. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  544. package/dist/unstable/http/HttpServerResponse.js +234 -1
  545. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  546. package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
  547. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
  548. package/dist/unstable/http/HttpStaticServer.js +353 -0
  549. package/dist/unstable/http/HttpStaticServer.js.map +1 -0
  550. package/dist/unstable/http/Multipart.d.ts +3 -3
  551. package/dist/unstable/http/UrlParams.d.ts +14 -6
  552. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  553. package/dist/unstable/http/UrlParams.js +1 -1
  554. package/dist/unstable/http/UrlParams.js.map +1 -1
  555. package/dist/unstable/http/index.d.ts +4 -0
  556. package/dist/unstable/http/index.d.ts.map +1 -1
  557. package/dist/unstable/http/index.js +4 -0
  558. package/dist/unstable/http/index.js.map +1 -1
  559. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  560. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  561. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  562. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  563. package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
  564. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  565. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  566. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
  567. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  568. package/dist/unstable/httpapi/HttpApiBuilder.js +28 -18
  569. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  570. package/dist/unstable/httpapi/HttpApiClient.d.ts +66 -6
  571. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  572. package/dist/unstable/httpapi/HttpApiClient.js +40 -3
  573. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  574. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +41 -54
  575. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  576. package/dist/unstable/httpapi/HttpApiEndpoint.js +17 -26
  577. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  578. package/dist/unstable/httpapi/HttpApiError.d.ts +16 -14
  579. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  580. package/dist/unstable/httpapi/HttpApiError.js +44 -29
  581. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  582. package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
  583. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  584. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  585. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -4
  586. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  587. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  588. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  589. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  590. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  591. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
  592. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  593. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  594. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  595. package/dist/unstable/httpapi/OpenApi.js +32 -21
  596. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  597. package/dist/unstable/observability/Otlp.d.ts +12 -12
  598. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  599. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  600. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  601. package/dist/unstable/observability/OtlpExporter.js +1 -1
  602. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  603. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  604. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  605. package/dist/unstable/observability/OtlpLogger.js +7 -4
  606. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  607. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  608. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  609. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  610. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  611. package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
  612. package/dist/unstable/persistence/KeyValueStore.js +6 -6
  613. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  614. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  615. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  616. package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
  617. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  618. package/dist/unstable/persistence/PersistedCache.js +2 -1
  619. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  620. package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
  621. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  622. package/dist/unstable/persistence/PersistedQueue.js +12 -11
  623. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  624. package/dist/unstable/persistence/Persistence.d.ts +1 -1
  625. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  626. package/dist/unstable/persistence/Persistence.js +2 -2
  627. package/dist/unstable/persistence/Persistence.js.map +1 -1
  628. package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
  629. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  630. package/dist/unstable/persistence/RateLimiter.js +1 -1
  631. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  632. package/dist/unstable/process/ChildProcess.d.ts +5 -128
  633. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  634. package/dist/unstable/process/ChildProcess.js +1 -65
  635. package/dist/unstable/process/ChildProcess.js.map +1 -1
  636. package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
  637. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  638. package/dist/unstable/process/ChildProcessSpawner.js +21 -1
  639. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  640. package/dist/unstable/reactivity/Atom.d.ts +73 -12
  641. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  642. package/dist/unstable/reactivity/Atom.js +107 -20
  643. package/dist/unstable/reactivity/Atom.js.map +1 -1
  644. package/dist/unstable/reactivity/AtomHttpApi.d.ts +10 -12
  645. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  646. package/dist/unstable/reactivity/AtomHttpApi.js +42 -12
  647. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  648. package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
  649. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  650. package/dist/unstable/reactivity/AtomRegistry.js +50 -9
  651. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  652. package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
  653. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  654. package/dist/unstable/reactivity/AtomRpc.js +47 -21
  655. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  656. package/dist/unstable/reactivity/Hydration.d.ts +39 -0
  657. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
  658. package/dist/unstable/reactivity/Hydration.js +76 -0
  659. package/dist/unstable/reactivity/Hydration.js.map +1 -0
  660. package/dist/unstable/reactivity/index.d.ts +4 -0
  661. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  662. package/dist/unstable/reactivity/index.js +4 -0
  663. package/dist/unstable/reactivity/index.js.map +1 -1
  664. package/dist/unstable/rpc/Rpc.d.ts +5 -5
  665. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  666. package/dist/unstable/rpc/Rpc.js.map +1 -1
  667. package/dist/unstable/rpc/RpcClient.d.ts +5 -26
  668. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  669. package/dist/unstable/rpc/RpcClient.js +6 -13
  670. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  671. package/dist/unstable/rpc/RpcGroup.d.ts +2 -2
  672. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  673. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  674. package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
  675. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  676. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  677. package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
  678. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  679. package/dist/unstable/rpc/RpcSchema.js +14 -0
  680. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  681. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  682. package/dist/unstable/rpc/RpcSerialization.js +34 -9
  683. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  684. package/dist/unstable/rpc/RpcServer.d.ts +5 -9
  685. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  686. package/dist/unstable/rpc/RpcServer.js +17 -17
  687. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  688. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  689. package/dist/unstable/rpc/Utils.js +3 -2
  690. package/dist/unstable/rpc/Utils.js.map +1 -1
  691. package/dist/unstable/schema/Model.d.ts +22 -1
  692. package/dist/unstable/schema/Model.d.ts.map +1 -1
  693. package/dist/unstable/schema/Model.js +15 -0
  694. package/dist/unstable/schema/Model.js.map +1 -1
  695. package/dist/unstable/schema/VariantSchema.d.ts +5 -5
  696. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  697. package/dist/unstable/schema/VariantSchema.js +6 -6
  698. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  699. package/dist/unstable/socket/Socket.d.ts +4 -4
  700. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  701. package/dist/unstable/socket/Socket.js +6 -5
  702. package/dist/unstable/socket/Socket.js.map +1 -1
  703. package/dist/unstable/socket/SocketServer.d.ts +3 -3
  704. package/dist/unstable/sql/Migrator.d.ts +1 -1
  705. package/dist/unstable/sql/SqlClient.d.ts +1 -1
  706. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  707. package/dist/unstable/sql/SqlError.d.ts +14 -14
  708. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  709. package/dist/unstable/sql/SqlError.js +9 -3
  710. package/dist/unstable/sql/SqlError.js.map +1 -1
  711. package/dist/unstable/sql/SqlModel.d.ts +2 -2
  712. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  713. package/dist/unstable/sql/SqlModel.js +3 -3
  714. package/dist/unstable/sql/SqlModel.js.map +1 -1
  715. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  716. package/dist/unstable/sql/SqlResolver.js +17 -8
  717. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  718. package/dist/unstable/sql/SqlSchema.d.ts +17 -6
  719. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  720. package/dist/unstable/sql/SqlSchema.js +17 -7
  721. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  722. package/dist/unstable/sql/Statement.js +0 -1
  723. package/dist/unstable/sql/Statement.js.map +1 -1
  724. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  725. package/dist/unstable/workers/Worker.js +2 -1
  726. package/dist/unstable/workers/Worker.js.map +1 -1
  727. package/dist/unstable/workflow/DurableClock.d.ts +3 -3
  728. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  729. package/dist/unstable/workflow/DurableClock.js +3 -3
  730. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  731. package/dist/unstable/workflow/DurableDeferred.js +2 -2
  732. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  733. package/dist/unstable/workflow/Workflow.d.ts +3 -3
  734. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  735. package/dist/unstable/workflow/Workflow.js +1 -1
  736. package/dist/unstable/workflow/Workflow.js.map +1 -1
  737. package/dist/unstable/workflow/WorkflowEngine.d.ts +12 -1
  738. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  739. package/dist/unstable/workflow/WorkflowEngine.js +137 -1
  740. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  741. package/package.json +2 -2
  742. package/src/Array.ts +192 -342
  743. package/src/Brand.ts +1 -1
  744. package/src/Cache.ts +9 -8
  745. package/src/Cause.ts +2 -2
  746. package/src/Channel.ts +554 -138
  747. package/src/Chunk.ts +81 -268
  748. package/src/Combiner.ts +280 -13
  749. package/src/Config.ts +186 -24
  750. package/src/Data.ts +539 -376
  751. package/src/DateTime.ts +24 -164
  752. package/src/Duration.ts +13 -13
  753. package/src/Effect.ts +1477 -1126
  754. package/src/Encoding.ts +879 -0
  755. package/src/Equal.ts +278 -111
  756. package/src/ErrorReporter.ts +457 -0
  757. package/src/Exit.ts +24 -12
  758. package/src/Fiber.ts +10 -2
  759. package/src/FileSystem.ts +7 -8
  760. package/src/Filter.ts +52 -63
  761. package/src/Formatter.ts +253 -51
  762. package/src/Function.ts +2 -10
  763. package/src/Graph.ts +24 -11
  764. package/src/HashMap.ts +15 -14
  765. package/src/Iterable.ts +104 -50
  766. package/src/JsonSchema.ts +383 -10
  767. package/src/Latch.ts +112 -0
  768. package/src/Layer.ts +123 -132
  769. package/src/LayerMap.ts +9 -9
  770. package/src/LogLevel.ts +37 -0
  771. package/src/Logger.ts +33 -100
  772. package/src/ManagedRuntime.ts +2 -2
  773. package/src/Metric.ts +6 -8
  774. package/src/Newtype.ts +308 -0
  775. package/src/Optic.ts +948 -19
  776. package/src/Option.ts +32 -24
  777. package/src/Pipeable.ts +32 -1
  778. package/src/PlatformError.ts +5 -5
  779. package/src/Pool.ts +13 -11
  780. package/src/PubSub.ts +10 -9
  781. package/src/Pull.ts +1 -1
  782. package/src/Queue.ts +0 -1
  783. package/src/Random.ts +51 -14
  784. package/src/RcMap.ts +5 -5
  785. package/src/RcRef.ts +1 -1
  786. package/src/Record.ts +42 -152
  787. package/src/Reducer.ts +166 -7
  788. package/src/References.ts +10 -5
  789. package/src/Request.ts +3 -2
  790. package/src/RequestResolver.ts +29 -49
  791. package/src/Result.ts +2 -4
  792. package/src/Runtime.ts +102 -6
  793. package/src/Schedule.ts +462 -242
  794. package/src/Scheduler.ts +12 -0
  795. package/src/Schema.ts +796 -194
  796. package/src/SchemaAST.ts +164 -31
  797. package/src/SchemaGetter.ts +15 -17
  798. package/src/SchemaParser.ts +11 -0
  799. package/src/SchemaRepresentation.ts +49 -24
  800. package/src/SchemaTransformation.ts +189 -4
  801. package/src/ScopedCache.ts +3 -3
  802. package/src/Semaphore.ts +356 -0
  803. package/src/ServiceMap.ts +50 -40
  804. package/src/Sink.ts +78 -26
  805. package/src/Stdio.ts +27 -4
  806. package/src/Stream.ts +586 -608
  807. package/src/Struct.ts +26 -0
  808. package/src/SubscriptionRef.ts +3 -2
  809. package/src/SynchronizedRef.ts +3 -2
  810. package/src/Trie.ts +18 -17
  811. package/src/TxChunk.ts +72 -53
  812. package/src/TxDeferred.ts +394 -0
  813. package/src/TxHashMap.ts +332 -285
  814. package/src/TxHashSet.ts +111 -116
  815. package/src/TxPriorityQueue.ts +767 -0
  816. package/src/TxPubSub.ts +789 -0
  817. package/src/TxQueue.ts +241 -251
  818. package/src/TxReentrantLock.ts +753 -0
  819. package/src/TxRef.ts +50 -38
  820. package/src/TxSemaphore.ts +29 -32
  821. package/src/TxSubscriptionRef.ts +639 -0
  822. package/src/Types.ts +73 -19
  823. package/src/Utils.ts +137 -111
  824. package/src/index.ts +728 -24
  825. package/src/internal/core.ts +12 -5
  826. package/src/internal/dateTime.ts +9 -30
  827. package/src/internal/effect.ts +774 -301
  828. package/src/internal/hashMap.ts +8 -7
  829. package/src/internal/random.ts +20 -0
  830. package/src/internal/rcRef.ts +4 -3
  831. package/src/internal/request.ts +2 -2
  832. package/src/internal/schema/annotations.ts +2 -0
  833. package/src/internal/schema/representation.ts +45 -94
  834. package/src/internal/schema/schema.ts +1 -0
  835. package/src/internal/schema/to-codec.ts +7 -17
  836. package/src/internal/trie.ts +15 -9
  837. package/src/testing/TestClock.ts +13 -11
  838. package/src/testing/TestSchema.ts +332 -35
  839. package/src/testing/index.ts +64 -1
  840. package/src/unstable/ai/AiError.ts +105 -48
  841. package/src/unstable/ai/Chat.ts +47 -61
  842. package/src/unstable/ai/LanguageModel.ts +153 -68
  843. package/src/unstable/ai/McpSchema.ts +73 -13
  844. package/src/unstable/ai/McpServer.ts +271 -61
  845. package/src/unstable/ai/Model.ts +40 -9
  846. package/src/unstable/ai/Prompt.ts +37 -37
  847. package/src/unstable/ai/Response.ts +25 -25
  848. package/src/unstable/ai/Tool.ts +20 -14
  849. package/src/unstable/ai/Toolkit.ts +5 -14
  850. package/src/unstable/ai/index.ts +1 -1
  851. package/src/unstable/ai/internal/codec-transformer.ts +0 -7
  852. package/src/unstable/cli/CliError.ts +47 -59
  853. package/src/unstable/cli/CliOutput.ts +75 -6
  854. package/src/unstable/cli/Command.ts +796 -187
  855. package/src/unstable/cli/GlobalFlag.ts +243 -0
  856. package/src/unstable/cli/HelpDoc.ts +80 -2
  857. package/src/unstable/cli/Primitive.ts +1 -1
  858. package/src/unstable/cli/Prompt.ts +31 -9
  859. package/src/unstable/cli/index.ts +5 -0
  860. package/src/unstable/cli/internal/command.ts +109 -63
  861. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +7 -2
  862. package/src/unstable/cli/internal/config.ts +49 -0
  863. package/src/unstable/cli/internal/help.ts +171 -0
  864. package/src/unstable/cli/internal/parser.ts +66 -61
  865. package/src/unstable/cluster/ClusterCron.ts +2 -2
  866. package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -4
  867. package/src/unstable/cluster/Entity.ts +11 -10
  868. package/src/unstable/cluster/EntityResource.ts +4 -4
  869. package/src/unstable/cluster/Envelope.ts +1 -1
  870. package/src/unstable/cluster/K8sHttpClient.ts +5 -5
  871. package/src/unstable/cluster/MessageStorage.ts +3 -5
  872. package/src/unstable/cluster/Runners.ts +6 -5
  873. package/src/unstable/cluster/Sharding.ts +12 -10
  874. package/src/unstable/cluster/ShardingConfig.ts +30 -31
  875. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  876. package/src/unstable/cluster/internal/entityManager.ts +9 -8
  877. package/src/unstable/cluster/internal/entityReaper.ts +2 -1
  878. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  879. package/src/unstable/encoding/Sse.ts +3 -5
  880. package/src/unstable/eventlog/EventLog.ts +2 -1
  881. package/src/unstable/http/Cookies.ts +87 -3
  882. package/src/unstable/http/Headers.ts +62 -13
  883. package/src/unstable/http/HttpBody.ts +6 -6
  884. package/src/unstable/http/HttpClient.ts +374 -33
  885. package/src/unstable/http/HttpClientRequest.ts +38 -30
  886. package/src/unstable/http/HttpClientResponse.ts +7 -2
  887. package/src/unstable/http/HttpEffect.ts +54 -68
  888. package/src/unstable/http/HttpMethod.ts +16 -4
  889. package/src/unstable/http/HttpMiddleware.ts +9 -24
  890. package/src/unstable/http/HttpServerError.ts +42 -45
  891. package/src/unstable/http/HttpServerRequest.ts +389 -2
  892. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  893. package/src/unstable/http/HttpServerResponse.ts +337 -4
  894. package/src/unstable/http/HttpStaticServer.ts +456 -0
  895. package/src/unstable/http/Multipart.ts +2 -2
  896. package/src/unstable/http/UrlParams.ts +20 -5
  897. package/src/unstable/http/index.ts +5 -0
  898. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  899. package/src/unstable/httpapi/HttpApi.ts +6 -6
  900. package/src/unstable/httpapi/HttpApiBuilder.ts +81 -28
  901. package/src/unstable/httpapi/HttpApiClient.ts +100 -11
  902. package/src/unstable/httpapi/HttpApiEndpoint.ts +71 -87
  903. package/src/unstable/httpapi/HttpApiError.ts +51 -28
  904. package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
  905. package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -4
  906. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  907. package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
  908. package/src/unstable/httpapi/OpenApi.ts +41 -23
  909. package/src/unstable/observability/Otlp.ts +12 -12
  910. package/src/unstable/observability/OtlpExporter.ts +3 -3
  911. package/src/unstable/observability/OtlpLogger.ts +13 -9
  912. package/src/unstable/observability/OtlpMetrics.ts +4 -4
  913. package/src/unstable/observability/OtlpTracer.ts +4 -4
  914. package/src/unstable/persistence/KeyValueStore.ts +6 -6
  915. package/src/unstable/persistence/Persistable.ts +2 -2
  916. package/src/unstable/persistence/PersistedCache.ts +20 -9
  917. package/src/unstable/persistence/PersistedQueue.ts +25 -24
  918. package/src/unstable/persistence/Persistence.ts +3 -3
  919. package/src/unstable/persistence/RateLimiter.ts +4 -4
  920. package/src/unstable/process/ChildProcess.ts +6 -208
  921. package/src/unstable/process/ChildProcessSpawner.ts +75 -14
  922. package/src/unstable/reactivity/Atom.ts +211 -50
  923. package/src/unstable/reactivity/AtomHttpApi.ts +66 -31
  924. package/src/unstable/reactivity/AtomRegistry.ts +61 -9
  925. package/src/unstable/reactivity/AtomRpc.ts +51 -20
  926. package/src/unstable/reactivity/Hydration.ts +112 -0
  927. package/src/unstable/reactivity/index.ts +5 -0
  928. package/src/unstable/rpc/Rpc.ts +7 -9
  929. package/src/unstable/rpc/RpcClient.ts +12 -54
  930. package/src/unstable/rpc/RpcGroup.ts +4 -4
  931. package/src/unstable/rpc/RpcMiddleware.ts +15 -9
  932. package/src/unstable/rpc/RpcSchema.ts +17 -0
  933. package/src/unstable/rpc/RpcSerialization.ts +44 -9
  934. package/src/unstable/rpc/RpcServer.ts +28 -32
  935. package/src/unstable/rpc/Utils.ts +3 -2
  936. package/src/unstable/schema/Model.ts +31 -0
  937. package/src/unstable/schema/VariantSchema.ts +9 -9
  938. package/src/unstable/socket/Socket.ts +16 -17
  939. package/src/unstable/sql/SqlClient.ts +1 -1
  940. package/src/unstable/sql/SqlError.ts +11 -9
  941. package/src/unstable/sql/SqlModel.ts +5 -5
  942. package/src/unstable/sql/SqlResolver.ts +17 -7
  943. package/src/unstable/sql/SqlSchema.ts +42 -26
  944. package/src/unstable/sql/Statement.ts +0 -1
  945. package/src/unstable/workers/Worker.ts +2 -1
  946. package/src/unstable/workflow/DurableClock.ts +8 -8
  947. package/src/unstable/workflow/DurableDeferred.ts +2 -2
  948. package/src/unstable/workflow/Workflow.ts +6 -2
  949. package/src/unstable/workflow/WorkflowEngine.ts +185 -2
  950. package/dist/PartitionedSemaphore.d.ts +0 -52
  951. package/dist/PartitionedSemaphore.d.ts.map +0 -1
  952. package/dist/PartitionedSemaphore.js.map +0 -1
  953. package/dist/encoding/Base64.d.ts +0 -67
  954. package/dist/encoding/Base64.d.ts.map +0 -1
  955. package/dist/encoding/Base64.js +0 -146
  956. package/dist/encoding/Base64.js.map +0 -1
  957. package/dist/encoding/Base64Url.d.ts +0 -60
  958. package/dist/encoding/Base64Url.d.ts.map +0 -1
  959. package/dist/encoding/Base64Url.js +0 -89
  960. package/dist/encoding/Base64Url.js.map +0 -1
  961. package/dist/encoding/EncodingError.d.ts +0 -31
  962. package/dist/encoding/EncodingError.d.ts.map +0 -1
  963. package/dist/encoding/EncodingError.js +0 -22
  964. package/dist/encoding/EncodingError.js.map +0 -1
  965. package/dist/encoding/Hex.d.ts +0 -61
  966. package/dist/encoding/Hex.d.ts.map +0 -1
  967. package/dist/encoding/Hex.js +0 -115
  968. package/dist/encoding/Hex.js.map +0 -1
  969. package/dist/encoding/index.d.ts +0 -26
  970. package/dist/encoding/index.d.ts.map +0 -1
  971. package/dist/encoding/index.js +0 -27
  972. package/dist/encoding/index.js.map +0 -1
  973. package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
  974. package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
  975. package/dist/unstable/cli/internal/builtInFlags.js +0 -44
  976. package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
  977. package/src/PartitionedSemaphore.ts +0 -182
  978. package/src/encoding/Base64.ts +0 -366
  979. package/src/encoding/Base64Url.ts +0 -104
  980. package/src/encoding/EncodingError.ts +0 -35
  981. package/src/encoding/Hex.ts +0 -390
  982. package/src/encoding/index.ts +0 -31
  983. package/src/unstable/cli/internal/builtInFlags.ts +0 -78
package/src/Stream.ts CHANGED
@@ -12,7 +12,7 @@ import * as Equal from "./Equal.ts"
12
12
  import * as ExecutionPlan from "./ExecutionPlan.ts"
13
13
  import * as Exit from "./Exit.ts"
14
14
  import * as Fiber from "./Fiber.ts"
15
- import * as Filter from "./Filter.ts"
15
+ import type * as Filter from "./Filter.ts"
16
16
  import type { LazyArg } from "./Function.ts"
17
17
  import { constant, constTrue, constVoid, dual, identity } from "./Function.ts"
18
18
  import type { TypeLambda } from "./HKT.ts"
@@ -20,8 +20,9 @@ import * as internalExecutionPlan from "./internal/executionPlan.ts"
20
20
  import * as internal from "./internal/stream.ts"
21
21
  import { addSpanStackTrace } from "./internal/tracer.ts"
22
22
  import * as Iterable from "./Iterable.ts"
23
+ import * as Latch from "./Latch.ts"
23
24
  import type * as Layer from "./Layer.ts"
24
- import type { LogLevel } from "./LogLevel.ts"
25
+ import type { Severity } from "./LogLevel.ts"
25
26
  import * as MutableHashMap from "./MutableHashMap.ts"
26
27
  import * as MutableList from "./MutableList.ts"
27
28
  import * as Option from "./Option.ts"
@@ -47,7 +48,9 @@ import type {
47
48
  ExcludeTag,
48
49
  ExtractReason,
49
50
  ExtractTag,
51
+ NarrowReason,
50
52
  NoInfer,
53
+ OmitReason,
51
54
  ReasonTags,
52
55
  Tags,
53
56
  unassigned
@@ -471,7 +474,7 @@ export const fromEffectSchedule = <A, E, R, X, AS extends A, ES, RS>(
471
474
  * @since 2.0.0
472
475
  * @category Constructors
473
476
  */
474
- export const tick = (interval: Duration.DurationInput): Stream<void> =>
477
+ export const tick = (interval: Duration.Input): Stream<void> =>
475
478
  fromPull(Effect.sync(() => {
476
479
  let first = true
477
480
  const effect = Effect.succeed(Arr.of<void>(undefined))
@@ -960,6 +963,10 @@ export const fromIteratorSucceed = <A>(iterator: IterableIterator<A>, maxChunkSi
960
963
  /**
961
964
  * Creates a new `Stream` from an iterable collection of values.
962
965
  *
966
+ * **Options**
967
+ *
968
+ * - `chunkSize`: Maximum number of values emitted per chunk.
969
+ *
963
970
  * @example
964
971
  * ```ts
965
972
  * import { Console, Effect, Stream } from "effect"
@@ -979,10 +986,15 @@ export const fromIteratorSucceed = <A>(iterator: IterableIterator<A>, maxChunkSi
979
986
  * @since 2.0.0
980
987
  * @category Constructors
981
988
  */
982
- export const fromIterable = <A>(iterable: Iterable<A>): Stream<A> =>
983
- Array.isArray(iterable)
989
+ export const fromIterable = <A>(
990
+ iterable: Iterable<A>,
991
+ options?: {
992
+ readonly chunkSize?: number | undefined
993
+ }
994
+ ): Stream<A> =>
995
+ Array.isArray(iterable) && options?.chunkSize === undefined
984
996
  ? fromArray(iterable)
985
- : fromChannel(Channel.fromIterableArray(iterable))
997
+ : fromChannel(Channel.fromIterableArray(iterable, options?.chunkSize))
986
998
 
987
999
  /**
988
1000
  * Creates a stream from an effect producing an iterable of values.
@@ -1242,7 +1254,9 @@ export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): St
1242
1254
  *
1243
1255
  * @example
1244
1256
  * ```ts
1245
- * import { Console, Effect, Stream } from "effect"
1257
+ * import { Console, Data, Effect, Stream } from "effect"
1258
+ *
1259
+ * class StreamError extends Data.TaggedError("StreamError")<{ readonly cause: unknown }> {}
1246
1260
  *
1247
1261
  * const readableStream = new ReadableStream({
1248
1262
  * start(controller) {
@@ -1256,7 +1270,7 @@ export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): St
1256
1270
  * const program = Effect.gen(function*() {
1257
1271
  * const stream = Stream.fromReadableStream({
1258
1272
  * evaluate: () => readableStream,
1259
- * onError: (error) => new Error(String(error))
1273
+ * onError: (cause) => new StreamError({ cause })
1260
1274
  * })
1261
1275
  * const values = yield* Stream.runCollect(stream)
1262
1276
  * yield* Console.log(values)
@@ -1298,7 +1312,9 @@ export const fromReadableStream = <A, E>(
1298
1312
  *
1299
1313
  * @example
1300
1314
  * ```ts
1301
- * import { Console, Effect, Stream } from "effect"
1315
+ * import { Console, Data, Effect, Stream } from "effect"
1316
+ *
1317
+ * class StreamError extends Data.TaggedError("StreamError")<{ readonly cause: unknown }> {}
1302
1318
  *
1303
1319
  * const iterable = (async function*() {
1304
1320
  * yield 1
@@ -1307,7 +1323,7 @@ export const fromReadableStream = <A, E>(
1307
1323
  * })()
1308
1324
  *
1309
1325
  * const program = Effect.gen(function*() {
1310
- * const stream = Stream.fromAsyncIterable(iterable, (error) => new Error(String(error)))
1326
+ * const stream = Stream.fromAsyncIterable(iterable, (cause) => new StreamError({ cause }))
1311
1327
  * const values = yield* Stream.runCollect(stream)
1312
1328
  * yield* Console.log(values)
1313
1329
  * })
@@ -2648,8 +2664,8 @@ export const tapSink: {
2648
2664
  transformPullBracket(
2649
2665
  self,
2650
2666
  Effect.fnUntraced(function*(pull, _, scope) {
2651
- const upstreamLatch = Effect.makeLatchUnsafe()
2652
- const sinkLatch = Effect.makeLatchUnsafe()
2667
+ const upstreamLatch = Latch.makeUnsafe()
2668
+ const sinkLatch = Latch.makeUnsafe()
2653
2669
  let chunk: Arr.NonEmptyReadonlyArray<A> | undefined = undefined
2654
2670
  let causeSink: Cause.Cause<E2> | undefined = undefined
2655
2671
  let sinkDone = false
@@ -3316,7 +3332,7 @@ export const timeout: {
3316
3332
  * @since 2.0.0
3317
3333
  * @category Rate Limiting
3318
3334
  */
3319
- (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
3335
+ (duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
3320
3336
  /**
3321
3337
  * Ends the stream if it does not produce a value within the specified duration.
3322
3338
  *
@@ -3340,10 +3356,10 @@ export const timeout: {
3340
3356
  * @since 2.0.0
3341
3357
  * @category Rate Limiting
3342
3358
  */
3343
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R>
3359
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
3344
3360
  } = dual(
3345
3361
  2,
3346
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> =>
3362
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
3347
3363
  transformPull(self, (pull, _scope) =>
3348
3364
  Effect.succeed(Effect.timeoutOrElse(pull, {
3349
3365
  duration,
@@ -5341,7 +5357,7 @@ export const zipLatestAll = <T extends ReadonlyArray<Stream<any, any, any>>>(
5341
5357
  fromChannel(Channel.suspend(() => {
5342
5358
  const latest: Array<any> = []
5343
5359
  const emitted = new Set<number>()
5344
- const readyLatch = Effect.makeLatchUnsafe()
5360
+ const readyLatch = Latch.makeUnsafe()
5345
5361
  return Channel.mergeAll(
5346
5362
  Channel.fromArray(
5347
5363
  streams.map((s, i) =>
@@ -5763,7 +5779,7 @@ export const filter: {
5763
5779
  * @since 2.0.0
5764
5780
  * @category Filtering
5765
5781
  */
5766
- <A, Result extends Filter.ResultOrBool>(filter: Filter.OrPredicate<NoInfer<A>, Result>): <E, R>(self: Stream<A, E, R>) => Stream<Filter.Pass<A, Result>, E, R>
5782
+ <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
5767
5783
  /**
5768
5784
  * Filters a stream to the elements that satisfy a predicate.
5769
5785
  *
@@ -5809,27 +5825,52 @@ export const filter: {
5809
5825
  * @since 2.0.0
5810
5826
  * @category Filtering
5811
5827
  */
5812
- <A, E, R, Result extends Filter.ResultOrBool>(self: Stream<A, E, R>, filter: Filter.OrPredicate<NoInfer<A>, Result>): Stream<Filter.Pass<A, Result>, E, R>
5828
+ <A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R>
5813
5829
  } = dual(
5814
5830
  2,
5815
- <A, E, R, Result extends Filter.ResultOrBool>(
5831
+ <A, E, R>(
5816
5832
  self: Stream<A, E, R>,
5817
- filter: Filter.OrPredicate<NoInfer<A>, Result>
5818
- ): Stream<Filter.Pass<A, Result>, E, R> => fromChannel(Channel.filterArray(toChannel(self), filter))
5833
+ predicate: Predicate<A>
5834
+ ): Stream<A, E, R> => fromChannel(Channel.filterArray(toChannel(self), predicate))
5819
5835
  )
5820
5836
 
5821
5837
  /**
5822
- * Effectfully filters and maps elements in a single pass.
5838
+ * Filters and maps stream elements in one pass using a `Filter`.
5839
+ *
5840
+ * @since 4.0.0
5841
+ * @category Filtering
5842
+ */
5843
+ export const filterMap: {
5844
+ /**
5845
+ * Filters and maps stream elements in one pass using a `Filter`.
5846
+ *
5847
+ * @since 4.0.0
5848
+ * @category Filtering
5849
+ */
5850
+ <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
5851
+ /**
5852
+ * Filters and maps stream elements in one pass using a `Filter`.
5853
+ *
5854
+ * @since 4.0.0
5855
+ * @category Filtering
5856
+ */
5857
+ <A, E, R, B, X>(self: Stream<A, E, R>, filter: Filter.Filter<A, B, X>): Stream<B, E, R>
5858
+ } = dual(
5859
+ 2,
5860
+ <A, E, R, B, X>(
5861
+ self: Stream<A, E, R>,
5862
+ filter: Filter.Filter<A, B, X>
5863
+ ): Stream<B, E, R> => fromChannel(Channel.filterMapArray(toChannel(self), filter))
5864
+ )
5865
+
5866
+ /**
5867
+ * Effectfully filters elements in a single pass.
5823
5868
  *
5824
5869
  * @example
5825
5870
  * ```ts
5826
- * import { Console, Effect, Filter, Result, Stream } from "effect"
5827
- *
5828
- * const filter = Filter.makeEffect((n: number) =>
5829
- * Effect.succeed(n > 2 ? Result.succeed(n + 1) : Result.fail(n))
5830
- * )
5871
+ * import { Console, Effect, Stream } from "effect"
5831
5872
  *
5832
- * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(filter))
5873
+ * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
5833
5874
  *
5834
5875
  * const program = Effect.gen(function*() {
5835
5876
  * const result = yield* Stream.runCollect(stream)
@@ -5837,7 +5878,7 @@ export const filter: {
5837
5878
  * })
5838
5879
  *
5839
5880
  * Effect.runPromise(program)
5840
- * // Output: [ 4, 5 ]
5881
+ * // Output: [ 3, 4 ]
5841
5882
  * ```
5842
5883
  *
5843
5884
  * @since 2.0.0
@@ -5845,17 +5886,13 @@ export const filter: {
5845
5886
  */
5846
5887
  export const filterEffect: {
5847
5888
  /**
5848
- * Effectfully filters and maps elements in a single pass.
5889
+ * Effectfully filters elements in a single pass.
5849
5890
  *
5850
5891
  * @example
5851
5892
  * ```ts
5852
- * import { Console, Effect, Filter, Result, Stream } from "effect"
5853
- *
5854
- * const filter = Filter.makeEffect((n: number) =>
5855
- * Effect.succeed(n > 2 ? Result.succeed(n + 1) : Result.fail(n))
5856
- * )
5893
+ * import { Console, Effect, Stream } from "effect"
5857
5894
  *
5858
- * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(filter))
5895
+ * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
5859
5896
  *
5860
5897
  * const program = Effect.gen(function*() {
5861
5898
  * const result = yield* Stream.runCollect(stream)
@@ -5863,25 +5900,21 @@ export const filterEffect: {
5863
5900
  * })
5864
5901
  *
5865
5902
  * Effect.runPromise(program)
5866
- * // Output: [ 4, 5 ]
5903
+ * // Output: [ 3, 4 ]
5867
5904
  * ```
5868
5905
  *
5869
5906
  * @since 2.0.0
5870
5907
  * @category Filtering
5871
5908
  */
5872
- <A, B, X, EX, RX>(filter: Filter.FilterEffect<A, B, X, EX, RX>): <E, R>(self: Stream<A, E, R>) => Stream<B, E | EX, R | RX>
5909
+ <A, EX, RX>(predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>): <E, R>(self: Stream<A, E, R>) => Stream<A, E | EX, R | RX>
5873
5910
  /**
5874
- * Effectfully filters and maps elements in a single pass.
5911
+ * Effectfully filters elements in a single pass.
5875
5912
  *
5876
5913
  * @example
5877
5914
  * ```ts
5878
- * import { Console, Effect, Filter, Result, Stream } from "effect"
5879
- *
5880
- * const filter = Filter.makeEffect((n: number) =>
5881
- * Effect.succeed(n > 2 ? Result.succeed(n + 1) : Result.fail(n))
5882
- * )
5915
+ * import { Console, Effect, Stream } from "effect"
5883
5916
  *
5884
- * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(filter))
5917
+ * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
5885
5918
  *
5886
5919
  * const program = Effect.gen(function*() {
5887
5920
  * const result = yield* Stream.runCollect(stream)
@@ -5889,35 +5922,65 @@ export const filterEffect: {
5889
5922
  * })
5890
5923
  *
5891
5924
  * Effect.runPromise(program)
5892
- * // Output: [ 4, 5 ]
5925
+ * // Output: [ 3, 4 ]
5893
5926
  * ```
5894
5927
  *
5895
5928
  * @since 2.0.0
5896
5929
  * @category Filtering
5897
5930
  */
5931
+ <A, E, R, EX, RX>(
5932
+ self: Stream<A, E, R>,
5933
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>
5934
+ ): Stream<A, E | EX, R | RX>
5935
+ } = dual(
5936
+ 2,
5937
+ <A, E, R, EX, RX>(
5938
+ self: Stream<A, E, R>,
5939
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>
5940
+ ): Stream<A, E | EX, R | RX> => fromChannel(Channel.filterArrayEffect(toChannel(self), predicate))
5941
+ )
5942
+
5943
+ /**
5944
+ * Effectfully filters and maps elements in a single pass.
5945
+ *
5946
+ * @since 4.0.0
5947
+ * @category Filtering
5948
+ */
5949
+ export const filterMapEffect: {
5950
+ /**
5951
+ * Effectfully filters and maps elements in a single pass.
5952
+ *
5953
+ * @since 4.0.0
5954
+ * @category Filtering
5955
+ */
5956
+ <A, B, X, EX, RX>(filter: Filter.FilterEffect<NoInfer<A>, B, X, EX, RX>): <E, R>(self: Stream<A, E, R>) => Stream<B, E | EX, R | RX>
5957
+ /**
5958
+ * Effectfully filters and maps elements in a single pass.
5959
+ *
5960
+ * @since 4.0.0
5961
+ * @category Filtering
5962
+ */
5898
5963
  <A, E, R, B, X, EX, RX>(self: Stream<A, E, R>, filter: Filter.FilterEffect<A, B, X, EX, RX>): Stream<B, E | EX, R | RX>
5899
5964
  } = dual(
5900
5965
  2,
5901
5966
  <A, E, R, B, X, EX, RX>(
5902
5967
  self: Stream<A, E, R>,
5903
5968
  filter: Filter.FilterEffect<A, B, X, EX, RX>
5904
- ): Stream<B, E | EX, R | RX> => fromChannel(Channel.filterArrayEffect(toChannel(self), filter))
5969
+ ): Stream<B, E | EX, R | RX> => fromChannel(Channel.filterMapArrayEffect(toChannel(self), filter))
5905
5970
  )
5906
5971
 
5907
5972
  /**
5908
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
5973
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
5909
5974
  *
5910
5975
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
5911
5976
  *
5912
5977
  * @example
5913
5978
  * ```ts
5914
- * import { Console, Effect, Filter, Result, Stream } from "effect"
5979
+ * import { Console, Effect, Result, Stream } from "effect"
5915
5980
  *
5916
5981
  * const program = Effect.gen(function*() {
5917
5982
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
5918
- * Stream.partitionQueue(
5919
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
5920
- * )
5983
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
5921
5984
  * )
5922
5985
  *
5923
5986
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -5937,63 +6000,17 @@ export const filterEffect: {
5937
6000
  */
5938
6001
  export const partitionQueue: {
5939
6002
  /**
5940
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
5941
- *
5942
- * Each queue fails with the stream error or `Cause.Done` when the source ends.
5943
- *
5944
- * @example
5945
- * ```ts
5946
- * import { Console, Effect, Filter, Result, Stream } from "effect"
5947
- *
5948
- * const program = Effect.gen(function*() {
5949
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
5950
- * Stream.partitionQueue(
5951
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
5952
- * )
5953
- * )
5954
- *
5955
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
5956
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
5957
- *
5958
- * yield* Console.log(passValues)
5959
- * // Output: [ 2, 4 ]
5960
- * yield* Console.log(failValues)
5961
- * // Output: [ 1, 3 ]
5962
- * })
5963
- *
5964
- * Effect.runPromise(Effect.scoped(program))
5965
- * ```
5966
- *
5967
- * @since 4.0.0
5968
- * @category Filtering
5969
- */
5970
- <A, B extends A>(
5971
- refinement: Refinement<NoInfer<A>, B>,
5972
- options?: {
5973
- readonly capacity?: number | "unbounded" | undefined
5974
- }
5975
- ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<
5976
- [
5977
- passes: Queue.Dequeue<B, E | Cause.Done>,
5978
- fails: Queue.Dequeue<Exclude<A, B>, E | Cause.Done>
5979
- ],
5980
- never,
5981
- R | Scope.Scope
5982
- >
5983
- /**
5984
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6003
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
5985
6004
  *
5986
6005
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
5987
6006
  *
5988
6007
  * @example
5989
6008
  * ```ts
5990
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6009
+ * import { Console, Effect, Result, Stream } from "effect"
5991
6010
  *
5992
6011
  * const program = Effect.gen(function*() {
5993
6012
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
5994
- * Stream.partitionQueue(
5995
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
5996
- * )
6013
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
5997
6014
  * )
5998
6015
  *
5999
6016
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6011,78 +6028,31 @@ export const partitionQueue: {
6011
6028
  * @since 4.0.0
6012
6029
  * @category Filtering
6013
6030
  */
6014
- <A, Result extends Filter.ResultOrBool>(
6015
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6031
+ <A, Pass, Fail>(
6032
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6016
6033
  options?: {
6017
6034
  readonly capacity?: number | "unbounded" | undefined
6018
6035
  }
6019
6036
  ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<
6020
6037
  [
6021
- passes: Queue.Dequeue<Filter.Pass<A, Result>, E | Cause.Done>,
6022
- fails: Queue.Dequeue<Filter.Fail<A, Result>, E | Cause.Done>
6023
- ],
6024
- never,
6025
- R | Scope.Scope
6026
- >
6027
- /**
6028
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6029
- *
6030
- * Each queue fails with the stream error or `Cause.Done` when the source ends.
6031
- *
6032
- * @example
6033
- * ```ts
6034
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6035
- *
6036
- * const program = Effect.gen(function*() {
6037
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6038
- * Stream.partitionQueue(
6039
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
6040
- * )
6041
- * )
6042
- *
6043
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6044
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6045
- *
6046
- * yield* Console.log(passValues)
6047
- * // Output: [ 2, 4 ]
6048
- * yield* Console.log(failValues)
6049
- * // Output: [ 1, 3 ]
6050
- * })
6051
- *
6052
- * Effect.runPromise(Effect.scoped(program))
6053
- * ```
6054
- *
6055
- * @since 4.0.0
6056
- * @category Filtering
6057
- */
6058
- <A, E, R, B extends A>(
6059
- self: Stream<A, E, R>,
6060
- refinement: Refinement<A, B>,
6061
- options?: {
6062
- readonly capacity?: number | "unbounded" | undefined
6063
- }
6064
- ): Effect.Effect<
6065
- [
6066
- passes: Queue.Dequeue<B, E | Cause.Done>,
6067
- fails: Queue.Dequeue<Exclude<A, B>, E | Cause.Done>
6038
+ passes: Queue.Dequeue<Pass, E | Cause.Done>,
6039
+ fails: Queue.Dequeue<Fail, E | Cause.Done>
6068
6040
  ],
6069
6041
  never,
6070
6042
  R | Scope.Scope
6071
6043
  >
6072
6044
  /**
6073
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6045
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6074
6046
  *
6075
6047
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6076
6048
  *
6077
6049
  * @example
6078
6050
  * ```ts
6079
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6051
+ * import { Console, Effect, Result, Stream } from "effect"
6080
6052
  *
6081
6053
  * const program = Effect.gen(function*() {
6082
6054
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6083
- * Stream.partitionQueue(
6084
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
6085
- * )
6055
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6086
6056
  * )
6087
6057
  *
6088
6058
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6100,16 +6070,16 @@ export const partitionQueue: {
6100
6070
  * @since 4.0.0
6101
6071
  * @category Filtering
6102
6072
  */
6103
- <A, E, R, Result extends Filter.ResultOrBool>(
6073
+ <A, E, R, Pass, Fail>(
6104
6074
  self: Stream<A, E, R>,
6105
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6075
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6106
6076
  options?: {
6107
6077
  readonly capacity?: number | "unbounded" | undefined
6108
6078
  }
6109
6079
  ): Effect.Effect<
6110
6080
  [
6111
- passes: Queue.Dequeue<Filter.Pass<A, Result>, E | Cause.Done>,
6112
- fails: Queue.Dequeue<Filter.Fail<A, Result>, E | Cause.Done>
6081
+ passes: Queue.Dequeue<Pass, E | Cause.Done>,
6082
+ fails: Queue.Dequeue<Fail, E | Cause.Done>
6113
6083
  ],
6114
6084
  never,
6115
6085
  R | Scope.Scope
@@ -6117,16 +6087,16 @@ export const partitionQueue: {
6117
6087
  } = dual(
6118
6088
  (args) => isStream(args[0]),
6119
6089
  Effect.fnUntraced(
6120
- function*<A, E, R, Result extends Filter.ResultOrBool>(
6090
+ function*<A, E, R, Pass, Fail>(
6121
6091
  self: Stream<A, E, R>,
6122
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6092
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6123
6093
  options?: {
6124
6094
  readonly capacity?: number | "unbounded" | undefined
6125
6095
  }
6126
6096
  ): Effect.fn.Return<
6127
6097
  [
6128
- passes: Queue.Dequeue<any, E | Cause.Done>,
6129
- fails: Queue.Dequeue<any, E | Cause.Done>
6098
+ passes: Queue.Dequeue<Pass, E | Cause.Done>,
6099
+ fails: Queue.Dequeue<Fail, E | Cause.Done>
6130
6100
  ],
6131
6101
  never,
6132
6102
  R | Scope.Scope
@@ -6135,19 +6105,17 @@ export const partitionQueue: {
6135
6105
  const pull = yield* Channel.toPullScoped(self.channel, scope)
6136
6106
  const capacity = options?.capacity === "unbounded" ? undefined : options?.capacity ?? DefaultChunkSize
6137
6107
  const passes = yield* Queue.make</**
6138
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6108
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6139
6109
  *
6140
6110
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6141
6111
  *
6142
6112
  * @example
6143
6113
  * ```ts
6144
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6114
+ * import { Console, Effect, Result, Stream } from "effect"
6145
6115
  *
6146
6116
  * const program = Effect.gen(function*() {
6147
6117
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6148
- * Stream.partitionQueue(
6149
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
6150
- * )
6118
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6151
6119
  * )
6152
6120
  *
6153
6121
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6165,20 +6133,18 @@ export const partitionQueue: {
6165
6133
  * @since 4.0.0
6166
6134
  * @category Filtering
6167
6135
  */
6168
- any, /**
6169
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6136
+ Pass, /**
6137
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6170
6138
  *
6171
6139
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6172
6140
  *
6173
6141
  * @example
6174
6142
  * ```ts
6175
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6143
+ * import { Console, Effect, Result, Stream } from "effect"
6176
6144
  *
6177
6145
  * const program = Effect.gen(function*() {
6178
6146
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6179
- * Stream.partitionQueue(
6180
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
6181
- * )
6147
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6182
6148
  * )
6183
6149
  *
6184
6150
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6198,19 +6164,17 @@ export const partitionQueue: {
6198
6164
  */
6199
6165
  E | Cause.Done>({ capacity })
6200
6166
  const fails = yield* Queue.make</**
6201
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6167
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6202
6168
  *
6203
6169
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6204
6170
  *
6205
6171
  * @example
6206
6172
  * ```ts
6207
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6173
+ * import { Console, Effect, Result, Stream } from "effect"
6208
6174
  *
6209
6175
  * const program = Effect.gen(function*() {
6210
6176
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6211
- * Stream.partitionQueue(
6212
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
6213
- * )
6177
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6214
6178
  * )
6215
6179
  *
6216
6180
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6228,20 +6192,18 @@ export const partitionQueue: {
6228
6192
  * @since 4.0.0
6229
6193
  * @category Filtering
6230
6194
  */
6231
- any, /**
6232
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6195
+ Fail, /**
6196
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6233
6197
  *
6234
6198
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6235
6199
  *
6236
6200
  * @example
6237
6201
  * ```ts
6238
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6202
+ * import { Console, Effect, Result, Stream } from "effect"
6239
6203
  *
6240
6204
  * const program = Effect.gen(function*() {
6241
6205
  * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6242
- * Stream.partitionQueue(
6243
- * Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
6244
- * )
6206
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6245
6207
  * )
6246
6208
  *
6247
6209
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6261,12 +6223,19 @@ export const partitionQueue: {
6261
6223
  */
6262
6224
  E | Cause.Done>({ capacity })
6263
6225
 
6264
- const partitionArr = Arr.partition(filter as any)
6265
-
6266
6226
  yield* Effect.gen(function*() {
6267
6227
  while (true) {
6268
6228
  const chunk = yield* pull
6269
- const [excluded, satisfying] = partitionArr(chunk)
6229
+ const excluded: Array<Fail> = []
6230
+ const satisfying: Array<Pass> = []
6231
+ for (let i = 0; i < chunk.length; i++) {
6232
+ const result = filter(chunk[i] as NoInfer<A>)
6233
+ if (Result.isFailure(result)) {
6234
+ excluded.push(result.failure)
6235
+ } else {
6236
+ satisfying.push(result.success)
6237
+ }
6238
+ }
6270
6239
  let passFiber: Fiber.Fiber<any> | undefined = undefined
6271
6240
  if (satisfying.length > 0) {
6272
6241
  const leftover = Queue.offerAllUnsafe(passes, satisfying)
@@ -6297,147 +6266,112 @@ export const partitionQueue: {
6297
6266
  )
6298
6267
 
6299
6268
  /**
6300
- * Splits a stream using an effectful filter, producing pass and fail streams.
6269
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6301
6270
  *
6302
6271
  * @since 4.0.0
6303
6272
  * @category Filtering
6304
- *
6305
- * @example
6306
- * ```ts
6307
- * import { Console, Effect, Result, Stream } from "effect"
6308
- *
6309
- * const program = Effect.scoped(
6310
- * Effect.gen(function*() {
6311
- * const [evens, odds] = yield* Stream.make(1, 2, 3, 4).pipe(
6312
- * Stream.partitionEffect((n) =>
6313
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6314
- * )
6315
- * )
6316
- * const result = yield* Effect.all({
6317
- * evens: Stream.runCollect(evens),
6318
- * odds: Stream.runCollect(odds)
6319
- * })
6320
- * yield* Console.log(result)
6321
- * })
6322
- * )
6323
- *
6324
- * Effect.runPromise(program)
6325
- * // Output: { evens: [ 2, 4 ], odds: [ 1, 3 ] }
6326
- * ```
6327
6273
  */
6328
6274
  export const partitionEffect: {
6329
6275
  /**
6330
- * Splits a stream using an effectful filter, producing pass and fail streams.
6276
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6331
6277
  *
6332
6278
  * @since 4.0.0
6333
6279
  * @category Filtering
6334
- *
6335
- * @example
6336
- * ```ts
6337
- * import { Console, Effect, Result, Stream } from "effect"
6338
- *
6339
- * const program = Effect.scoped(
6340
- * Effect.gen(function*() {
6341
- * const [evens, odds] = yield* Stream.make(1, 2, 3, 4).pipe(
6342
- * Stream.partitionEffect((n) =>
6343
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6344
- * )
6345
- * )
6346
- * const result = yield* Effect.all({
6347
- * evens: Stream.runCollect(evens),
6348
- * odds: Stream.runCollect(odds)
6349
- * })
6350
- * yield* Console.log(result)
6351
- * })
6352
- * )
6353
- *
6354
- * Effect.runPromise(program)
6355
- * // Output: { evens: [ 2, 4 ], odds: [ 1, 3 ] }
6356
- * ```
6357
6280
  */
6358
- <A, B, X, EX, RX>(
6359
- filter: Filter.FilterEffect<A, B, X, EX, RX>,
6281
+ <A, Pass, Fail, EX, RX>(
6282
+ filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>,
6360
6283
  options?: {
6361
6284
  readonly capacity?: number | "unbounded" | undefined
6362
6285
  readonly concurrency?: number | "unbounded" | undefined
6363
6286
  }
6364
6287
  ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<
6365
6288
  [
6366
- passes: Stream<B, E | EX>,
6367
- fails: Stream<X, E | EX>
6289
+ passes: Stream<Pass, E | EX>,
6290
+ fails: Stream<Fail, E | EX>
6368
6291
  ],
6369
6292
  never,
6370
6293
  R | RX | Scope.Scope
6371
6294
  >
6372
6295
  /**
6373
- * Splits a stream using an effectful filter, producing pass and fail streams.
6296
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6374
6297
  *
6375
6298
  * @since 4.0.0
6376
6299
  * @category Filtering
6377
- *
6378
- * @example
6379
- * ```ts
6380
- * import { Console, Effect, Result, Stream } from "effect"
6381
- *
6382
- * const program = Effect.scoped(
6383
- * Effect.gen(function*() {
6384
- * const [evens, odds] = yield* Stream.make(1, 2, 3, 4).pipe(
6385
- * Stream.partitionEffect((n) =>
6386
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6387
- * )
6388
- * )
6389
- * const result = yield* Effect.all({
6390
- * evens: Stream.runCollect(evens),
6391
- * odds: Stream.runCollect(odds)
6392
- * })
6393
- * yield* Console.log(result)
6394
- * })
6395
- * )
6396
- *
6397
- * Effect.runPromise(program)
6398
- * // Output: { evens: [ 2, 4 ], odds: [ 1, 3 ] }
6399
- * ```
6400
6300
  */
6401
- <A, E, R, B, X, EX, RX>(
6301
+ <A, E, R, Pass, Fail, EX, RX>(
6402
6302
  self: Stream<A, E, R>,
6403
- filter: Filter.FilterEffect<A, B, X, EX, RX>,
6303
+ filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>,
6404
6304
  options?: {
6405
6305
  readonly capacity?: number | "unbounded" | undefined
6406
6306
  readonly concurrency?: number | "unbounded" | undefined
6407
6307
  }
6408
6308
  ): Effect.Effect<
6409
6309
  [
6410
- passes: Stream<B, E | EX>,
6411
- fails: Stream<X, E | EX>
6310
+ passes: Stream<Pass, E | EX>,
6311
+ fails: Stream<Fail, E | EX>
6412
6312
  ],
6413
6313
  never,
6414
6314
  R | RX | Scope.Scope
6415
6315
  >
6416
6316
  } = dual(
6417
6317
  (args) => isStream(args[0]),
6418
- <A, E, R, B, X, EX, RX>(self: Stream<A, E, R>, filter: Filter.FilterEffect<A, B, X, EX, RX>, options?: {
6419
- readonly capacity?: number | "unbounded" | undefined
6420
- readonly concurrency?: number | "unbounded" | undefined
6421
- }): Effect.Effect<
6318
+ <A, E, R, Pass, Fail, EX, RX>(
6319
+ self: Stream<A, E, R>,
6320
+ filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>,
6321
+ options?: {
6322
+ readonly capacity?: number | "unbounded" | undefined
6323
+ readonly concurrency?: number | "unbounded" | undefined
6324
+ }
6325
+ ): Effect.Effect<
6422
6326
  [
6423
- passes: Stream<B, E | EX>,
6424
- fails: Stream<X, E | EX>
6327
+ passes: Stream<Pass, E | EX>,
6328
+ fails: Stream<Fail, E | EX>
6425
6329
  ],
6426
6330
  never,
6427
6331
  R | RX | Scope.Scope
6428
6332
  > =>
6429
6333
  Effect.map(
6430
- self.pipe(
6431
- mapEffect(filter, options),
6432
- partitionQueue(identity as any, options)
6334
+ partitionQueue</**
6335
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6336
+ *
6337
+ * @since 4.0.0
6338
+ * @category Filtering
6339
+ */
6340
+ Result.Result<Pass, Fail>, /**
6341
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6342
+ *
6343
+ * @since 4.0.0
6344
+ * @category Filtering
6345
+ */
6346
+ E | EX, /**
6347
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6348
+ *
6349
+ * @since 4.0.0
6350
+ * @category Filtering
6351
+ */
6352
+ R | RX, /**
6353
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6354
+ *
6355
+ * @since 4.0.0
6356
+ * @category Filtering
6357
+ */
6358
+ Pass, /**
6359
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6360
+ *
6361
+ * @since 4.0.0
6362
+ * @category Filtering
6363
+ */
6364
+ Fail>(
6365
+ mapEffect(self, (a) => filter(a as NoInfer<A>), options),
6366
+ (result) => result,
6367
+ options
6433
6368
  ),
6434
- ([passes, fails]) => [fromQueue(passes), fromQueue(fails)]
6435
- ) as any
6369
+ ([passes, fails]) => [fromQueue(passes), fromQueue(fails)] as const
6370
+ )
6436
6371
  )
6437
6372
 
6438
6373
  /**
6439
- * Splits a stream into excluded and satisfying substreams using a predicate,
6440
- * refinement, or Filter.
6374
+ * Splits a stream into excluded and satisfying substreams using a `Filter`.
6441
6375
  *
6442
6376
  * The faster stream may advance up to `bufferSize` elements ahead of the slower
6443
6377
  * one.
@@ -6447,102 +6381,25 @@ export const partitionEffect: {
6447
6381
  *
6448
6382
  * @example
6449
6383
  * ```ts
6450
- * import { Console, Effect, Stream } from "effect"
6451
- *
6452
- * const program = Effect.gen(function*() {
6453
- * const [excluded, satisfying] = yield* Stream.partition(
6454
- * Stream.make(1, 2, 3, 4),
6455
- * (n) => n % 2 === 0
6456
- * )
6457
- * const left = yield* Stream.runCollect(excluded)
6458
- * const right = yield* Stream.runCollect(satisfying)
6459
- * yield* Console.log(left)
6460
- * // Output: [ 1, 3 ]
6461
- * yield* Console.log(right)
6462
- * // Output: [ 2, 4 ]
6463
- * })
6464
- * ```
6465
- */
6466
- export const partition: {
6467
- /**
6468
- * Splits a stream into excluded and satisfying substreams using a predicate,
6469
- * refinement, or Filter.
6470
- *
6471
- * The faster stream may advance up to `bufferSize` elements ahead of the slower
6472
- * one.
6473
- *
6474
- * @since 4.0.0
6475
- * @category Filtering
6476
- *
6477
- * @example
6478
- * ```ts
6479
- * import { Console, Effect, Stream } from "effect"
6480
- *
6481
- * const program = Effect.gen(function*() {
6482
- * const [excluded, satisfying] = yield* Stream.partition(
6483
- * Stream.make(1, 2, 3, 4),
6484
- * (n) => n % 2 === 0
6485
- * )
6486
- * const left = yield* Stream.runCollect(excluded)
6487
- * const right = yield* Stream.runCollect(satisfying)
6488
- * yield* Console.log(left)
6489
- * // Output: [ 1, 3 ]
6490
- * yield* Console.log(right)
6491
- * // Output: [ 2, 4 ]
6492
- * })
6493
- * ```
6494
- */
6495
- <C extends A, B extends A, A = C>(
6496
- refinement: Refinement<NoInfer<A>, B>,
6497
- options?: { readonly bufferSize?: number | undefined }
6498
- ): <E, R>(
6499
- self: Stream<C, E, R>
6500
- ) => Effect.Effect<
6501
- [excluded: Stream<Exclude<C, B>, E>, satisfying: Stream<B, E>],
6502
- never,
6503
- R | Scope.Scope
6504
- >
6505
- /**
6506
- * Splits a stream into excluded and satisfying substreams using a predicate,
6507
- * refinement, or Filter.
6508
- *
6509
- * The faster stream may advance up to `bufferSize` elements ahead of the slower
6510
- * one.
6511
- *
6512
- * @since 4.0.0
6513
- * @category Filtering
6514
- *
6515
- * @example
6516
- * ```ts
6517
- * import { Console, Effect, Stream } from "effect"
6518
- *
6519
- * const program = Effect.gen(function*() {
6520
- * const [excluded, satisfying] = yield* Stream.partition(
6521
- * Stream.make(1, 2, 3, 4),
6522
- * (n) => n % 2 === 0
6523
- * )
6524
- * const left = yield* Stream.runCollect(excluded)
6525
- * const right = yield* Stream.runCollect(satisfying)
6526
- * yield* Console.log(left)
6527
- * // Output: [ 1, 3 ]
6528
- * yield* Console.log(right)
6529
- * // Output: [ 2, 4 ]
6530
- * })
6531
- * ```
6532
- */
6533
- <A, Result extends Filter.ResultOrBool>(
6534
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6535
- options?: { readonly bufferSize?: number | undefined }
6536
- ): <E, R>(
6537
- self: Stream<A, E, R>
6538
- ) => Effect.Effect<
6539
- [excluded: Stream<Filter.Fail<A, Result>, E>, satisfying: Stream<Filter.Pass<A, Result>, E>],
6540
- never,
6541
- R | Scope.Scope
6542
- >
6384
+ * import { Console, Effect, Result, Stream } from "effect"
6385
+ *
6386
+ * const program = Effect.gen(function*() {
6387
+ * const [excluded, satisfying] = yield* Stream.partition(
6388
+ * Stream.make(1, 2, 3, 4),
6389
+ * (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
6390
+ * )
6391
+ * const left = yield* Stream.runCollect(excluded)
6392
+ * const right = yield* Stream.runCollect(satisfying)
6393
+ * yield* Console.log(left)
6394
+ * // Output: [ 1, 3 ]
6395
+ * yield* Console.log(right)
6396
+ * // Output: [ 2, 4 ]
6397
+ * })
6398
+ * ```
6399
+ */
6400
+ export const partition: {
6543
6401
  /**
6544
- * Splits a stream into excluded and satisfying substreams using a predicate,
6545
- * refinement, or Filter.
6402
+ * Splits a stream into excluded and satisfying substreams using a `Filter`.
6546
6403
  *
6547
6404
  * The faster stream may advance up to `bufferSize` elements ahead of the slower
6548
6405
  * one.
@@ -6552,12 +6409,12 @@ export const partition: {
6552
6409
  *
6553
6410
  * @example
6554
6411
  * ```ts
6555
- * import { Console, Effect, Stream } from "effect"
6412
+ * import { Console, Effect, Result, Stream } from "effect"
6556
6413
  *
6557
6414
  * const program = Effect.gen(function*() {
6558
6415
  * const [excluded, satisfying] = yield* Stream.partition(
6559
6416
  * Stream.make(1, 2, 3, 4),
6560
- * (n) => n % 2 === 0
6417
+ * (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
6561
6418
  * )
6562
6419
  * const left = yield* Stream.runCollect(excluded)
6563
6420
  * const right = yield* Stream.runCollect(satisfying)
@@ -6568,18 +6425,18 @@ export const partition: {
6568
6425
  * })
6569
6426
  * ```
6570
6427
  */
6571
- <C extends A, E, R, B extends A, A = C>(
6572
- self: Stream<C, E, R>,
6573
- refinement: Refinement<A, B>,
6428
+ <A, Pass, Fail>(
6429
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6574
6430
  options?: { readonly bufferSize?: number | undefined }
6575
- ): Effect.Effect<
6576
- [excluded: Stream<Exclude<C, B>, E>, satisfying: Stream<B, E>],
6431
+ ): <E, R>(
6432
+ self: Stream<A, E, R>
6433
+ ) => Effect.Effect<
6434
+ [excluded: Stream<Fail, E>, satisfying: Stream<Pass, E>],
6577
6435
  never,
6578
6436
  R | Scope.Scope
6579
6437
  >
6580
6438
  /**
6581
- * Splits a stream into excluded and satisfying substreams using a predicate,
6582
- * refinement, or Filter.
6439
+ * Splits a stream into excluded and satisfying substreams using a `Filter`.
6583
6440
  *
6584
6441
  * The faster stream may advance up to `bufferSize` elements ahead of the slower
6585
6442
  * one.
@@ -6589,12 +6446,12 @@ export const partition: {
6589
6446
  *
6590
6447
  * @example
6591
6448
  * ```ts
6592
- * import { Console, Effect, Stream } from "effect"
6449
+ * import { Console, Effect, Result, Stream } from "effect"
6593
6450
  *
6594
6451
  * const program = Effect.gen(function*() {
6595
6452
  * const [excluded, satisfying] = yield* Stream.partition(
6596
6453
  * Stream.make(1, 2, 3, 4),
6597
- * (n) => n % 2 === 0
6454
+ * (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
6598
6455
  * )
6599
6456
  * const left = yield* Stream.runCollect(excluded)
6600
6457
  * const right = yield* Stream.runCollect(satisfying)
@@ -6605,28 +6462,28 @@ export const partition: {
6605
6462
  * })
6606
6463
  * ```
6607
6464
  */
6608
- <A, E, R, Result extends Filter.ResultOrBool>(
6465
+ <A, E, R, Pass, Fail>(
6609
6466
  self: Stream<A, E, R>,
6610
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6467
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6611
6468
  options?: { readonly bufferSize?: number | undefined }
6612
6469
  ): Effect.Effect<
6613
- [excluded: Stream<Filter.Fail<A, Result>, E>, satisfying: Stream<Filter.Pass<A, Result>, E>],
6470
+ [excluded: Stream<Fail, E>, satisfying: Stream<Pass, E>],
6614
6471
  never,
6615
6472
  R | Scope.Scope
6616
6473
  >
6617
6474
  } = dual(
6618
6475
  (args) => isStream(args[0]),
6619
- <A, E, R, Result extends Filter.ResultOrBool>(
6476
+ <A, E, R, Pass, Fail>(
6620
6477
  self: Stream<A, E, R>,
6621
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6478
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6622
6479
  options?: { readonly bufferSize?: number | undefined }
6623
6480
  ): Effect.Effect<
6624
- [excluded: Stream<Filter.Fail<A, Result>, E>, satisfying: Stream<Filter.Pass<A, Result>, E>],
6481
+ [excluded: Stream<Fail, E>, satisfying: Stream<Pass, E>],
6625
6482
  never,
6626
6483
  R | Scope.Scope
6627
6484
  > =>
6628
6485
  Effect.map(
6629
- partitionQueue(filter, { capacity: options?.bufferSize ?? 16 })(self),
6486
+ partitionQueue(self, filter, { capacity: options?.bufferSize ?? 16 }),
6630
6487
  ([passes, fails]) => [fromQueue(fails), fromQueue(passes)] as const
6631
6488
  )
6632
6489
  )
@@ -7408,7 +7265,7 @@ export const tapError: {
7408
7265
  ))
7409
7266
 
7410
7267
  /**
7411
- * Recovers from errors that match a filter by switching to a recovery stream.
7268
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7412
7269
  *
7413
7270
  * When a failure matches the filter, the stream switches to the recovery
7414
7271
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7422,12 +7279,12 @@ export const tapError: {
7422
7279
  *
7423
7280
  * @example
7424
7281
  * ```ts
7425
- * import { Console, Effect, Filter, Stream } from "effect"
7282
+ * import { Console, Effect, Stream } from "effect"
7426
7283
  *
7427
7284
  * const stream = Stream.make(1, 2).pipe(
7428
7285
  * Stream.concat(Stream.fail(42)),
7429
7286
  * Stream.catchIf(
7430
- * Filter.fromPredicate((error): error is 42 => error === 42),
7287
+ * (error): error is 42 => error === 42,
7431
7288
  * () => Stream.make(999)
7432
7289
  * )
7433
7290
  * )
@@ -7446,7 +7303,7 @@ export const tapError: {
7446
7303
  */
7447
7304
  export const catchIf: {
7448
7305
  /**
7449
- * Recovers from errors that match a filter by switching to a recovery stream.
7306
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7450
7307
  *
7451
7308
  * When a failure matches the filter, the stream switches to the recovery
7452
7309
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7460,12 +7317,12 @@ export const catchIf: {
7460
7317
  *
7461
7318
  * @example
7462
7319
  * ```ts
7463
- * import { Console, Effect, Filter, Stream } from "effect"
7320
+ * import { Console, Effect, Stream } from "effect"
7464
7321
  *
7465
7322
  * const stream = Stream.make(1, 2).pipe(
7466
7323
  * Stream.concat(Stream.fail(42)),
7467
7324
  * Stream.catchIf(
7468
- * Filter.fromPredicate((error): error is 42 => error === 42),
7325
+ * (error): error is 42 => error === 42,
7469
7326
  * () => Stream.make(999)
7470
7327
  * )
7471
7328
  * )
@@ -7488,7 +7345,7 @@ export const catchIf: {
7488
7345
  orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined
7489
7346
  ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A | A3, E2 | E3, R2 | R | R3>
7490
7347
  /**
7491
- * Recovers from errors that match a filter by switching to a recovery stream.
7348
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7492
7349
  *
7493
7350
  * When a failure matches the filter, the stream switches to the recovery
7494
7351
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7502,12 +7359,12 @@ export const catchIf: {
7502
7359
  *
7503
7360
  * @example
7504
7361
  * ```ts
7505
- * import { Console, Effect, Filter, Stream } from "effect"
7362
+ * import { Console, Effect, Stream } from "effect"
7506
7363
  *
7507
7364
  * const stream = Stream.make(1, 2).pipe(
7508
7365
  * Stream.concat(Stream.fail(42)),
7509
7366
  * Stream.catchIf(
7510
- * Filter.fromPredicate((error): error is 42 => error === 42),
7367
+ * (error): error is 42 => error === 42,
7511
7368
  * () => Stream.make(999)
7512
7369
  * )
7513
7370
  * )
@@ -7524,13 +7381,13 @@ export const catchIf: {
7524
7381
  * @since 4.0.0
7525
7382
  * @category Error Handling
7526
7383
  */
7527
- <E, Result extends Filter.ResultOrBool, A2, E2, R2, A3 = never, E3 = Filter.Fail<E, Result>, R3 = never>(
7528
- filter: Filter.OrPredicate<NoInfer<E>, Result>,
7529
- f: (failure: Filter.Pass<E, Result>) => Stream<A2, E2, R2>,
7530
- orElse?: ((failure: Filter.Fail<E, Result>) => Stream<A3, E3, R3>) | undefined
7531
- ): <A, R>(self: Stream<A, E, R>) => Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7384
+ <E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
7385
+ predicate: Predicate<NoInfer<E>>,
7386
+ f: (e: NoInfer<E>) => Stream<A2, E2, R2>,
7387
+ orElse?: ((e: NoInfer<E>) => Stream<A3, E3, R3>) | undefined
7388
+ ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A | A3, E2 | E3, R2 | R | R3>
7532
7389
  /**
7533
- * Recovers from errors that match a filter by switching to a recovery stream.
7390
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7534
7391
  *
7535
7392
  * When a failure matches the filter, the stream switches to the recovery
7536
7393
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7544,12 +7401,12 @@ export const catchIf: {
7544
7401
  *
7545
7402
  * @example
7546
7403
  * ```ts
7547
- * import { Console, Effect, Filter, Stream } from "effect"
7404
+ * import { Console, Effect, Stream } from "effect"
7548
7405
  *
7549
7406
  * const stream = Stream.make(1, 2).pipe(
7550
7407
  * Stream.concat(Stream.fail(42)),
7551
7408
  * Stream.catchIf(
7552
- * Filter.fromPredicate((error): error is 42 => error === 42),
7409
+ * (error): error is 42 => error === 42,
7553
7410
  * () => Stream.make(999)
7554
7411
  * )
7555
7412
  * )
@@ -7573,7 +7430,7 @@ export const catchIf: {
7573
7430
  orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined
7574
7431
  ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7575
7432
  /**
7576
- * Recovers from errors that match a filter by switching to a recovery stream.
7433
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7577
7434
  *
7578
7435
  * When a failure matches the filter, the stream switches to the recovery
7579
7436
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7587,12 +7444,12 @@ export const catchIf: {
7587
7444
  *
7588
7445
  * @example
7589
7446
  * ```ts
7590
- * import { Console, Effect, Filter, Stream } from "effect"
7447
+ * import { Console, Effect, Stream } from "effect"
7591
7448
  *
7592
7449
  * const stream = Stream.make(1, 2).pipe(
7593
7450
  * Stream.concat(Stream.fail(42)),
7594
7451
  * Stream.catchIf(
7595
- * Filter.fromPredicate((error): error is 42 => error === 42),
7452
+ * (error): error is 42 => error === 42,
7596
7453
  * () => Stream.make(999)
7597
7454
  * )
7598
7455
  * )
@@ -7609,37 +7466,96 @@ export const catchIf: {
7609
7466
  * @since 4.0.0
7610
7467
  * @category Error Handling
7611
7468
  */
7612
- <A, E, R, Result extends Filter.ResultOrBool, A2, E2, R2, A3 = never, E3 = Filter.Fail<E, Result>, R3 = never>(
7469
+ <A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
7613
7470
  self: Stream<A, E, R>,
7614
- filter: Filter.OrPredicate<NoInfer<E>, Result>,
7615
- f: (failure: Filter.Pass<E, Result>) => Stream<A2, E2, R2>,
7616
- orElse?: ((failure: Filter.Fail<E, Result>) => Stream<A3, E3, R3>) | undefined
7471
+ predicate: Predicate<E>,
7472
+ f: (e: E) => Stream<A2, E2, R2>,
7473
+ orElse?: ((e: E) => Stream<A3, E3, R3>) | undefined
7617
7474
  ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7618
7475
  } = dual((args) => isStream(args[0]), <
7619
7476
  A,
7620
7477
  E,
7621
7478
  R,
7622
- Result extends Filter.ResultOrBool,
7623
7479
  A2,
7624
7480
  E2,
7625
7481
  R2,
7626
7482
  A3 = never,
7627
- E3 = Filter.Fail<E, Result>,
7483
+ E3 = E,
7628
7484
  R3 = never
7629
7485
  >(
7630
7486
  self: Stream<A, E, R>,
7631
- filter: Filter.OrPredicate<NoInfer<E>, Result>,
7632
- f: (failure: Filter.Pass<E, Result>) => Stream<A2, E2, R2>,
7633
- orElse?: ((failure: Filter.Fail<E, Result>) => Stream<A3, E3, R3>) | undefined
7487
+ predicate: Predicate<E>,
7488
+ f: (failure: E) => Stream<A2, E2, R2>,
7489
+ orElse?: ((failure: E) => Stream<A3, E3, R3>) | undefined
7634
7490
  ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3> =>
7635
7491
  fromChannel(
7636
7492
  Channel.catchIf(
7637
7493
  toChannel(self),
7638
- filter as any,
7639
- (e: any) => f(e).channel,
7640
- orElse && ((e: any) => orElse(e).channel)
7494
+ predicate,
7495
+ (e) => f(e).channel,
7496
+ orElse && ((e) => orElse(e).channel)
7497
+ )
7498
+ ))
7499
+
7500
+ /**
7501
+ * Recovers from errors that match a `Filter` by switching to a recovery
7502
+ * stream.
7503
+ *
7504
+ * @since 4.0.0
7505
+ * @category Error Handling
7506
+ */
7507
+ export const catchFilter: {
7508
+ /**
7509
+ * Recovers from errors that match a `Filter` by switching to a recovery
7510
+ * stream.
7511
+ *
7512
+ * @since 4.0.0
7513
+ * @category Error Handling
7514
+ */
7515
+ <E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
7516
+ filter: Filter.Filter<NoInfer<E>, EB, X>,
7517
+ f: (failure: EB) => Stream<A2, E2, R2>,
7518
+ orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined
7519
+ ): <A, R>(self: Stream<A, E, R>) => Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7520
+ /**
7521
+ * Recovers from errors that match a `Filter` by switching to a recovery
7522
+ * stream.
7523
+ *
7524
+ * @since 4.0.0
7525
+ * @category Error Handling
7526
+ */
7527
+ <A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
7528
+ self: Stream<A, E, R>,
7529
+ filter: Filter.Filter<NoInfer<E>, EB, X>,
7530
+ f: (failure: EB) => Stream<A2, E2, R2>,
7531
+ orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined
7532
+ ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7533
+ } = dual((args) => isStream(args[0]), <
7534
+ A,
7535
+ E,
7536
+ R,
7537
+ EB,
7538
+ A2,
7539
+ E2,
7540
+ R2,
7541
+ X,
7542
+ A3 = never,
7543
+ E3 = X,
7544
+ R3 = never
7545
+ >(
7546
+ self: Stream<A, E, R>,
7547
+ filter: Filter.Filter<NoInfer<E>, EB, X>,
7548
+ f: (failure: EB) => Stream<A2, E2, R2>,
7549
+ orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined
7550
+ ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3> =>
7551
+ fromChannel(
7552
+ Channel.catchFilter(
7553
+ toChannel(self),
7554
+ filter,
7555
+ (e) => f(e).channel,
7556
+ orElse && ((e) => orElse(e).channel)
7641
7557
  )
7642
- ) as any)
7558
+ ))
7643
7559
 
7644
7560
  /**
7645
7561
  * Recovers from failures whose `_tag` matches the provided value by switching to
@@ -7978,7 +7894,7 @@ export const catchTags: {
7978
7894
  >
7979
7895
  } = dual((args) => isStream(args[0]), (self, cases, orElse) => {
7980
7896
  let keys: Array<string>
7981
- return catchIf(
7897
+ return catchFilter(
7982
7898
  self,
7983
7899
  (e: any) => {
7984
7900
  keys ??= Object.keys(cases)
@@ -8091,8 +8007,16 @@ export const catchReason: {
8091
8007
  >(
8092
8008
  errorTag: K,
8093
8009
  reasonTag: RK,
8094
- f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Stream<A2, E2, R2>,
8095
- orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>) => Stream<A3, E3, R3>) | undefined
8010
+ f: (
8011
+ reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
8012
+ error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
8013
+ ) => Stream<A2, E2, R2>,
8014
+ orElse?:
8015
+ | ((
8016
+ reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
8017
+ error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
8018
+ ) => Stream<A3, E3, R3>)
8019
+ | undefined
8096
8020
  ): <A, R>(
8097
8021
  self: Stream<A, E, R>
8098
8022
  ) => Stream<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
@@ -8155,8 +8079,10 @@ export const catchReason: {
8155
8079
  self: Stream<A, E, R>,
8156
8080
  errorTag: K,
8157
8081
  reasonTag: RK,
8158
- f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Stream<A2, E2, R2>,
8159
- orElse?: ((reason: ExcludeReason<ExtractTag<E, K>, RK>) => Stream<A3, E3, R3>) | undefined
8082
+ f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Stream<A2, E2, R2>,
8083
+ orElse?:
8084
+ | ((reason: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Stream<A3, E3, R3>)
8085
+ | undefined
8160
8086
  ): Stream<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
8161
8087
  } = dual(
8162
8088
  (args) => isStream(args[0]),
@@ -8176,16 +8102,18 @@ export const catchReason: {
8176
8102
  self: Stream<A, E, R>,
8177
8103
  errorTag: K,
8178
8104
  reasonTag: RK,
8179
- f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Stream<A2, E2, R2>,
8180
- orElse?: ((reason: ExcludeReason<ExtractTag<E, K>, RK>) => Stream<A3, E3, R3>) | undefined
8105
+ f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Stream<A2, E2, R2>,
8106
+ orElse?:
8107
+ | ((reason: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Stream<A3, E3, R3>)
8108
+ | undefined
8181
8109
  ): Stream<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3> =>
8182
8110
  fromChannel(
8183
8111
  Channel.catchReason(
8184
8112
  toChannel(self),
8185
8113
  errorTag,
8186
8114
  reasonTag,
8187
- (reason) => f(reason).channel,
8188
- orElse && ((reason) => orElse(reason).channel)
8115
+ (reason, error) => f(reason, error).channel,
8116
+ orElse && ((reason, error) => orElse(reason, error).channel)
8189
8117
  )
8190
8118
  ) as any
8191
8119
  )
@@ -8278,7 +8206,8 @@ export const catchReasons: {
8278
8206
  E,
8279
8207
  Cases extends {
8280
8208
  [RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
8281
- reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>
8209
+ reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
8210
+ error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
8282
8211
  ) => Stream<any, any, any>
8283
8212
  },
8284
8213
  A2 = unassigned,
@@ -8288,7 +8217,10 @@ export const catchReasons: {
8288
8217
  errorTag: K,
8289
8218
  cases: Cases,
8290
8219
  orElse?:
8291
- | ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Stream<A2, E2, R2>)
8220
+ | ((
8221
+ reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
8222
+ error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
8223
+ ) => Stream<A2, E2, R2>)
8292
8224
  | undefined
8293
8225
  ): <A, R>(self: Stream<A, E, R>) => Stream<
8294
8226
  | A
@@ -8355,7 +8287,8 @@ export const catchReasons: {
8355
8287
  K extends Tags<E>,
8356
8288
  Cases extends {
8357
8289
  [RK in ReasonTags<ExtractTag<E, K>>]+?: (
8358
- reason: ExtractReason<ExtractTag<E, K>, RK>
8290
+ reason: ExtractReason<ExtractTag<E, K>, RK>,
8291
+ error: NarrowReason<ExtractTag<E, K>, RK>
8359
8292
  ) => Stream<any, any, any>
8360
8293
  },
8361
8294
  A2 = unassigned,
@@ -8366,7 +8299,10 @@ export const catchReasons: {
8366
8299
  errorTag: K,
8367
8300
  cases: Cases,
8368
8301
  orElse?:
8369
- | ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Stream<A2, E2, R2>)
8302
+ | ((
8303
+ reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
8304
+ error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
8305
+ ) => Stream<A2, E2, R2>)
8370
8306
  | undefined
8371
8307
  ): Stream<
8372
8308
  | A
@@ -8386,12 +8322,12 @@ export const catchReasons: {
8386
8322
  }[keyof Cases]
8387
8323
  >
8388
8324
  } = dual((args) => isStream(args[0]), (self, errorTag, cases, orElse) => {
8389
- const handlers: Record<string, (reason: any) => Channel.Channel<any, any, any, any, any, any, any>> = {}
8325
+ const handlers: Record<string, (reason: any, error: any) => Channel.Channel<any, any, any, any, any, any, any>> = {}
8390
8326
  for (const key of Object.keys(cases)) {
8391
8327
  const handler = (cases as any)[key]
8392
- handlers[key] = (reason) => handler(reason).channel
8328
+ handlers[key] = (reason, error) => handler(reason, error).channel
8393
8329
  }
8394
- const orElseHandler = orElse && ((reason: any) => orElse(reason).channel)
8330
+ const orElseHandler = orElse && ((reason: any, error: any) => orElse(reason, error).channel)
8395
8331
  return fromChannel(
8396
8332
  Channel.catchReasons(self.channel, errorTag as any, handlers as any, orElseHandler as any) as Channel.Channel<
8397
8333
  Arr.NonEmptyReadonlyArray<any>,
@@ -8549,12 +8485,12 @@ export const catchCauseIf: {
8549
8485
  * @since 4.0.0
8550
8486
  * @category Error Handling
8551
8487
  */
8552
- <E, Result extends Filter.ResultOrBool<Cause.Cause<any>>, A2, E2, R2>(
8553
- filter: Filter.OrPredicate<Cause.Cause<E>, Result>,
8554
- f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8488
+ <E, A2, E2, R2>(
8489
+ predicate: Predicate<Cause.Cause<E>>,
8490
+ f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8555
8491
  ): <A, R>(
8556
8492
  self: Stream<A, E, R>
8557
- ) => Stream<A | A2, Cause.Cause.Error<Filter.Fail<Cause.Cause<E>, Result>> | E2, R2 | R>
8493
+ ) => Stream<A | A2, E | E2, R2 | R>
8558
8494
  /**
8559
8495
  * Recovers from stream failures by filtering the `Cause` and switching to a recovery stream.
8560
8496
  * Non-matching causes are re-emitted as failures.
@@ -8588,19 +8524,68 @@ export const catchCauseIf: {
8588
8524
  * @since 4.0.0
8589
8525
  * @category Error Handling
8590
8526
  */
8591
- <A, E, R, A2, E2, R2, Result extends Filter.ResultOrBool<Cause.Cause<any>>>(
8527
+ <A, E, R, A2, E2, R2>(
8528
+ self: Stream<A, E, R>,
8529
+ predicate: Predicate<Cause.Cause<E>>,
8530
+ f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8531
+ ): Stream<A | A2, E | E2, R | R2>
8532
+ } = dual(3, <A, E, R, A2, E2, R2>(
8533
+ self: Stream<A, E, R>,
8534
+ predicate: Predicate<Cause.Cause<E>>,
8535
+ f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8536
+ ): Stream<A | A2, E | E2, R | R2> =>
8537
+ fromChannel(
8538
+ Channel.catchCauseIf(
8539
+ self.channel,
8540
+ predicate,
8541
+ (cause) => f(cause).channel
8542
+ )
8543
+ ))
8544
+
8545
+ /**
8546
+ * Recovers from stream failures by filtering the `Cause` and switching to a
8547
+ * recovery stream.
8548
+ *
8549
+ * @since 4.0.0
8550
+ * @category Error Handling
8551
+ */
8552
+ export const catchCauseFilter: {
8553
+ /**
8554
+ * Recovers from stream failures by filtering the `Cause` and switching to a
8555
+ * recovery stream.
8556
+ *
8557
+ * @since 4.0.0
8558
+ * @category Error Handling
8559
+ */
8560
+ <E, EB, A2, E2, R2, X extends Cause.Cause<any>>(
8561
+ filter: Filter.Filter<Cause.Cause<E>, EB, X>,
8562
+ f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8563
+ ): <A, R>(
8564
+ self: Stream<A, E, R>
8565
+ ) => Stream<A | A2, Cause.Cause.Error<X> | E2, R2 | R>
8566
+ /**
8567
+ * Recovers from stream failures by filtering the `Cause` and switching to a
8568
+ * recovery stream.
8569
+ *
8570
+ * @since 4.0.0
8571
+ * @category Error Handling
8572
+ */
8573
+ <A, E, R, EB, A2, E2, R2, X extends Cause.Cause<any>>(
8592
8574
  self: Stream<A, E, R>,
8593
- filter: Filter.OrPredicate<Cause.Cause<E>, Result>,
8594
- f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8595
- ): Stream<A | A2, Cause.Cause.Error<Filter.Fail<Cause.Cause<E>, Result>> | E2, R | R2>
8596
- } = dual(3, <A, E, R, A2, E2, R2, Result extends Filter.ResultOrBool<Cause.Cause<any>>>(
8575
+ filter: Filter.Filter<Cause.Cause<E>, EB, X>,
8576
+ f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8577
+ ): Stream<A | A2, Cause.Cause.Error<X> | E2, R | R2>
8578
+ } = dual(3, <A, E, R, EB, A2, E2, R2, X extends Cause.Cause<any>>(
8597
8579
  self: Stream<A, E, R>,
8598
- filter: Filter.OrPredicate<Cause.Cause<E>, Result>,
8599
- f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8600
- ): Stream<A | A2, Cause.Cause.Error<Filter.Fail<Cause.Cause<E>, Result>> | E2, R | R2> =>
8580
+ filter: Filter.Filter<Cause.Cause<E>, EB, X>,
8581
+ f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8582
+ ): Stream<A | A2, Cause.Cause.Error<X> | E2, R | R2> =>
8601
8583
  fromChannel(
8602
- Channel.catchCauseIf(self.channel, filter as any, (failure: any, cause: any) =>
8603
- (f as any)(failure, cause).channel) as any
8584
+ Channel.catchCauseFilter(
8585
+ self.channel,
8586
+ filter,
8587
+ (failure, cause) => f(failure, cause).channel
8588
+ )
8604
8589
  ))
8605
8590
 
8606
8591
  /**
@@ -8819,12 +8804,12 @@ export const orDie = <A, E, R>(self: Stream<A, E, R>): Stream<A, never, R> => fr
8819
8804
  */
8820
8805
  export const ignore: <
8821
8806
  Arg extends Stream<any, any, any> | {
8822
- readonly log?: boolean | LogLevel | undefined
8807
+ readonly log?: boolean | Severity | undefined
8823
8808
  } | undefined
8824
8809
  >(
8825
8810
  selfOrOptions: Arg,
8826
8811
  options?: {
8827
- readonly log?: boolean | LogLevel | undefined
8812
+ readonly log?: boolean | Severity | undefined
8828
8813
  } | undefined
8829
8814
  ) => [Arg] extends [Stream<infer A, infer _E, infer R>] ? Stream<A, never, R>
8830
8815
  : <A, E, R>(self: Stream<A, E, R>) => Stream<A, never, R> = dual(
@@ -8832,7 +8817,7 @@ export const ignore: <
8832
8817
  <A, E, R>(
8833
8818
  self: Stream<A, E, R>,
8834
8819
  options?: {
8835
- readonly log?: boolean | LogLevel | undefined
8820
+ readonly log?: boolean | Severity | undefined
8836
8821
  } | undefined
8837
8822
  ): Stream<A, never, R> => fromChannel(Channel.ignore(self.channel, options))
8838
8823
  )
@@ -8859,19 +8844,19 @@ export const ignore: <
8859
8844
  */
8860
8845
  export const ignoreCause: <
8861
8846
  Arg extends Stream<any, any, any> | {
8862
- readonly log?: boolean | LogLevel | undefined
8847
+ readonly log?: boolean | Severity | undefined
8863
8848
  } | undefined
8864
8849
  >(
8865
8850
  streamOrOptions: Arg,
8866
8851
  options?: {
8867
- readonly log?: boolean | LogLevel | undefined
8852
+ readonly log?: boolean | Severity | undefined
8868
8853
  } | undefined
8869
8854
  ) => [Arg] extends [Stream<infer A, infer _E, infer R>] ? Stream<A, never, R>
8870
8855
  : <A, E, R>(self: Stream<A, E, R>) => Stream<A, never, R> = dual(
8871
8856
  (args) => isStream(args[0]),
8872
8857
  <A, E, R>(
8873
8858
  self: Stream<A, E, R>,
8874
- options?: { readonly log?: boolean | LogLevel | undefined } | undefined
8859
+ options?: { readonly log?: boolean | Severity | undefined } | undefined
8875
8860
  ): Stream<A, never, R> => fromChannel(Channel.ignoreCause(self.channel, options))
8876
8861
  )
8877
8862
 
@@ -9741,7 +9726,7 @@ export const takeWhile: {
9741
9726
  * @since 2.0.0
9742
9727
  * @category Filtering
9743
9728
  */
9744
- <A, B, X>(f: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
9729
+ <A, E, R, B extends A>(self: Stream<A, E, R>, refinement: (a: NoInfer<A>, n: number) => a is B): Stream<B, E, R>
9745
9730
  /**
9746
9731
  * Takes the longest initial prefix of elements that satisfy the predicate.
9747
9732
  *
@@ -9765,71 +9750,71 @@ export const takeWhile: {
9765
9750
  * @since 2.0.0
9766
9751
  * @category Filtering
9767
9752
  */
9768
- <A, E, R, B extends A>(self: Stream<A, E, R>, refinement: (a: NoInfer<A>, n: number) => a is B): Stream<B, E, R>
9753
+ <A, E, R>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, n: number) => boolean): Stream<A, E, R>
9754
+ } = dual(
9755
+ 2,
9756
+ <A, E, R>(
9757
+ self: Stream<A, E, R>,
9758
+ predicate: (a: A, n: number) => boolean
9759
+ ): Stream<A, E, R> =>
9760
+ transformPull(self, (pull, _scope) =>
9761
+ Effect.sync(() => {
9762
+ let i = 0
9763
+ let done = false
9764
+ const pump: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R> = Effect.flatMap(
9765
+ Effect.suspend(() => done ? Cause.done() : pull),
9766
+ (chunk) => {
9767
+ const out: Array<A> = []
9768
+ for (let j = 0; j < chunk.length; j++) {
9769
+ if (!predicate(chunk[j], i++)) {
9770
+ done = true
9771
+ break
9772
+ }
9773
+ out.push(chunk[j])
9774
+ }
9775
+ return Arr.isReadonlyArrayNonEmpty(out) ? Effect.succeed(out) : done ? Cause.done() : pump
9776
+ }
9777
+ )
9778
+ return pump
9779
+ }))
9780
+ )
9781
+
9782
+ /**
9783
+ * Takes the longest initial prefix of elements that satisfy the filter.
9784
+ *
9785
+ * @since 4.0.0
9786
+ * @category Filtering
9787
+ */
9788
+ export const takeWhileFilter: {
9769
9789
  /**
9770
- * Takes the longest initial prefix of elements that satisfy the predicate.
9771
- *
9772
- * @example
9773
- * ```ts
9774
- * import { Console, Effect, Stream } from "effect"
9775
- *
9776
- * const stream = Stream.range(1, 5).pipe(
9777
- * Stream.takeWhile((n) => n % 3 !== 0)
9778
- * )
9779
- *
9780
- * const program = Effect.gen(function*() {
9781
- * const result = yield* Stream.runCollect(stream)
9782
- * yield* Console.log(result)
9783
- * })
9784
- *
9785
- * Effect.runPromise(program)
9786
- * // Output: [ 1, 2 ]
9787
- * ```
9790
+ * Takes the longest initial prefix of elements that satisfy the filter.
9788
9791
  *
9789
- * @since 2.0.0
9792
+ * @since 4.0.0
9790
9793
  * @category Filtering
9791
9794
  */
9792
- <A, E, R>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, n: number) => boolean): Stream<A, E, R>
9795
+ <A, B, X>(f: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
9793
9796
  /**
9794
- * Takes the longest initial prefix of elements that satisfy the predicate.
9795
- *
9796
- * @example
9797
- * ```ts
9798
- * import { Console, Effect, Stream } from "effect"
9799
- *
9800
- * const stream = Stream.range(1, 5).pipe(
9801
- * Stream.takeWhile((n) => n % 3 !== 0)
9802
- * )
9803
- *
9804
- * const program = Effect.gen(function*() {
9805
- * const result = yield* Stream.runCollect(stream)
9806
- * yield* Console.log(result)
9807
- * })
9808
- *
9809
- * Effect.runPromise(program)
9810
- * // Output: [ 1, 2 ]
9811
- * ```
9797
+ * Takes the longest initial prefix of elements that satisfy the filter.
9812
9798
  *
9813
- * @since 2.0.0
9799
+ * @since 4.0.0
9814
9800
  * @category Filtering
9815
9801
  */
9816
9802
  <A, E, R, B, X>(self: Stream<A, E, R>, f: Filter.Filter<NoInfer<A>, B, X>): Stream<B, E, R>
9817
9803
  } = dual(
9818
9804
  2,
9819
- <A, E, R>(
9805
+ <A, E, R, B, X>(
9820
9806
  self: Stream<A, E, R>,
9821
- f: Filter.Filter<A, any, any> | ((a: A, n: number) => boolean)
9822
- ): Stream<any, E, R> =>
9807
+ filter: Filter.Filter<NoInfer<A>, B, X>
9808
+ ): Stream<B, E, R> =>
9823
9809
  transformPull(self, (pull, _scope) =>
9824
9810
  Effect.sync(() => {
9825
- let i = 0
9826
9811
  let done = false
9827
- const pump: Pull.Pull<Arr.NonEmptyReadonlyArray<any>, E, void, R> = Effect.flatMap(
9812
+ const pump: Pull.Pull<Arr.NonEmptyReadonlyArray<B>, E, void, R> = Effect.flatMap(
9828
9813
  Effect.suspend(() => done ? Cause.done() : pull),
9829
9814
  (chunk) => {
9830
- const out: Array<any> = []
9815
+ const out: Array<B> = []
9831
9816
  for (let j = 0; j < chunk.length; j++) {
9832
- const result = Filter.apply(f as any, chunk[j], i++)
9817
+ const result = filter(chunk[j])
9833
9818
  if (Result.isFailure(result)) {
9834
9819
  done = true
9835
9820
  break
@@ -10224,29 +10209,6 @@ export const dropWhile: {
10224
10209
  * @category Filtering
10225
10210
  */
10226
10211
  <A>(predicate: (a: NoInfer<A>, index: number) => boolean): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
10227
- /**
10228
- * Drops elements from the stream while the specified predicate evaluates to `true`.
10229
- *
10230
- * @example
10231
- * ```ts
10232
- * import { Console, Effect, Stream } from "effect"
10233
- *
10234
- * const program = Effect.gen(function*() {
10235
- * const values = yield* Stream.make(1, 2, 3, 4, 5).pipe(
10236
- * Stream.dropWhile((n) => n < 3),
10237
- * Stream.runCollect
10238
- * )
10239
- * yield* Console.log(values)
10240
- * })
10241
- *
10242
- * Effect.runPromise(program)
10243
- * // Output: [ 3, 4, 5 ]
10244
- * ```
10245
- *
10246
- * @since 2.0.0
10247
- * @category Filtering
10248
- */
10249
- <A, B, X>(f: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
10250
10212
  /**
10251
10213
  * Drops elements from the stream while the specified predicate evaluates to `true`.
10252
10214
  *
@@ -10273,39 +10235,53 @@ export const dropWhile: {
10273
10235
  self: Stream<A, E, R>,
10274
10236
  predicate: (a: NoInfer<A>, index: number) => boolean
10275
10237
  ): Stream<A, E, R>
10238
+ } = dual(2, <A, E, R>(
10239
+ self: Stream<A, E, R>,
10240
+ predicate: (a: A, index: number) => boolean
10241
+ ): Stream<A, E, R> =>
10242
+ transformPull(self, (pull, _scope) =>
10243
+ Effect.sync(() => {
10244
+ let dropping = true
10245
+ let index = 0
10246
+ const filtered: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E> = Effect.flatMap(pull, (arr) => {
10247
+ const found = arr.findIndex((a) => !predicate(a, index++))
10248
+ if (found === -1) return filtered
10249
+ dropping = false
10250
+ return Effect.succeed(arr.slice(found) as Arr.NonEmptyArray<A>)
10251
+ })
10252
+ return Effect.suspend(() => dropping ? filtered : pull)
10253
+ })))
10254
+
10255
+ /**
10256
+ * Drops elements while the filter succeeds.
10257
+ *
10258
+ * @since 4.0.0
10259
+ * @category Filtering
10260
+ */
10261
+ export const dropWhileFilter: {
10276
10262
  /**
10277
- * Drops elements from the stream while the specified predicate evaluates to `true`.
10278
- *
10279
- * @example
10280
- * ```ts
10281
- * import { Console, Effect, Stream } from "effect"
10282
- *
10283
- * const program = Effect.gen(function*() {
10284
- * const values = yield* Stream.make(1, 2, 3, 4, 5).pipe(
10285
- * Stream.dropWhile((n) => n < 3),
10286
- * Stream.runCollect
10287
- * )
10288
- * yield* Console.log(values)
10289
- * })
10263
+ * Drops elements while the filter succeeds.
10290
10264
  *
10291
- * Effect.runPromise(program)
10292
- * // Output: [ 3, 4, 5 ]
10293
- * ```
10265
+ * @since 4.0.0
10266
+ * @category Filtering
10267
+ */
10268
+ <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
10269
+ /**
10270
+ * Drops elements while the filter succeeds.
10294
10271
  *
10295
- * @since 2.0.0
10272
+ * @since 4.0.0
10296
10273
  * @category Filtering
10297
10274
  */
10298
- <A, E, R, B, X>(self: Stream<A, E, R>, f: Filter.Filter<NoInfer<A>, B, X>): Stream<A, E, R>
10299
- } = dual(2, <A, E, R>(
10275
+ <A, E, R, B, X>(self: Stream<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>): Stream<A, E, R>
10276
+ } = dual(2, <A, E, R, B, X>(
10300
10277
  self: Stream<A, E, R>,
10301
- f: Filter.Filter<A, any, any> | ((a: A, index: number) => boolean)
10278
+ filter: Filter.Filter<NoInfer<A>, B, X>
10302
10279
  ): Stream<A, E, R> =>
10303
10280
  transformPull(self, (pull, _scope) =>
10304
10281
  Effect.sync(() => {
10305
10282
  let dropping = true
10306
- let index = 0
10307
10283
  const filtered: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E> = Effect.flatMap(pull, (arr) => {
10308
- const found = arr.findIndex((a) => Result.isFailure(Filter.apply(f as any, a, index++)))
10284
+ const found = arr.findIndex((a) => Result.isFailure(filter(a)))
10309
10285
  if (found === -1) return filtered
10310
10286
  dropping = false
10311
10287
  return Effect.succeed(arr.slice(found) as Arr.NonEmptyArray<A>)
@@ -12174,7 +12150,7 @@ export const debounce: {
12174
12150
  * @since 2.0.0
12175
12151
  * @category Rate Limiting
12176
12152
  */
12177
- (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
12153
+ (duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
12178
12154
  /**
12179
12155
  * Drops earlier elements within the debounce window and emits only the latest element after the pause.
12180
12156
  *
@@ -12198,21 +12174,21 @@ export const debounce: {
12198
12174
  * @since 2.0.0
12199
12175
  * @category Rate Limiting
12200
12176
  */
12201
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R>
12177
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
12202
12178
  } = dual(
12203
12179
  2,
12204
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> =>
12180
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
12205
12181
  transformPull(
12206
12182
  self,
12207
12183
  Effect.fnUntraced(function*(pull, scope) {
12208
12184
  const clock = yield* Clock
12209
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12185
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12210
12186
  let lastArr: Arr.NonEmptyReadonlyArray<A> | undefined
12211
12187
  let cause: Cause.Cause<Cause.Done | E> | undefined
12212
12188
  let emitAtMs = Infinity
12213
- const pullLatch = Effect.makeLatchUnsafe()
12214
- const emitLatch = Effect.makeLatchUnsafe()
12215
- const endLatch = Effect.makeLatchUnsafe()
12189
+ const pullLatch = Latch.makeUnsafe()
12190
+ const emitLatch = Latch.makeUnsafe()
12191
+ const endLatch = Latch.makeUnsafe()
12216
12192
 
12217
12193
  yield* pull.pipe(
12218
12194
  pullLatch.whenOpen,
@@ -12346,7 +12322,7 @@ export const throttleEffect: {
12346
12322
  options: {
12347
12323
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12348
12324
  readonly units: number
12349
- readonly duration: Duration.DurationInput
12325
+ readonly duration: Duration.Input
12350
12326
  readonly burst?: number | undefined
12351
12327
  readonly strategy?: "enforce" | "shape" | undefined
12352
12328
  }
@@ -12392,7 +12368,7 @@ export const throttleEffect: {
12392
12368
  options: {
12393
12369
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12394
12370
  readonly units: number
12395
- readonly duration: Duration.DurationInput
12371
+ readonly duration: Duration.Input
12396
12372
  readonly burst?: number | undefined
12397
12373
  readonly strategy?: "enforce" | "shape" | undefined
12398
12374
  }
@@ -12404,7 +12380,7 @@ export const throttleEffect: {
12404
12380
  options: {
12405
12381
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12406
12382
  readonly units: number
12407
- readonly duration: Duration.DurationInput
12383
+ readonly duration: Duration.Input
12408
12384
  readonly burst?: number | undefined
12409
12385
  readonly strategy?: "enforce" | "shape" | undefined
12410
12386
  }
@@ -12421,12 +12397,12 @@ const throttleEnforceEffect = <A, E, R, E2, R2>(
12421
12397
  self: Stream<A, E, R>,
12422
12398
  cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
12423
12399
  units: number,
12424
- duration: Duration.DurationInput,
12400
+ duration: Duration.Input,
12425
12401
  burst: number
12426
12402
  ): Stream<A, E | E2, R | R2> =>
12427
12403
  transformPull(self, (pull) =>
12428
12404
  Effect.clockWith((clock) => {
12429
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12405
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12430
12406
  const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
12431
12407
  let tokens = units
12432
12408
  let timestampMs = clock.currentTimeMillisUnsafe()
@@ -12457,12 +12433,12 @@ const throttleShapeEffect = <A, E, R, E2, R2>(
12457
12433
  self: Stream<A, E, R>,
12458
12434
  cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
12459
12435
  units: number,
12460
- duration: Duration.DurationInput,
12436
+ duration: Duration.Input,
12461
12437
  burst: number
12462
12438
  ): Stream<A, E | E2, R | R2> =>
12463
12439
  transformPull(self, (pull) =>
12464
12440
  Effect.clockWith((clock) => {
12465
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12441
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12466
12442
  const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
12467
12443
  let tokens = units
12468
12444
  let timestampMs = clock.currentTimeMillisUnsafe()
@@ -12575,7 +12551,7 @@ export const throttle: {
12575
12551
  options: {
12576
12552
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12577
12553
  readonly units: number
12578
- readonly duration: Duration.DurationInput
12554
+ readonly duration: Duration.Input
12579
12555
  readonly burst?: number | undefined
12580
12556
  readonly strategy?: "enforce" | "shape" | undefined
12581
12557
  }
@@ -12620,7 +12596,7 @@ export const throttle: {
12620
12596
  options: {
12621
12597
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12622
12598
  readonly units: number
12623
- readonly duration: Duration.DurationInput
12599
+ readonly duration: Duration.Input
12624
12600
  readonly burst?: number | undefined
12625
12601
  readonly strategy?: "enforce" | "shape" | undefined
12626
12602
  }
@@ -12632,7 +12608,7 @@ export const throttle: {
12632
12608
  options: {
12633
12609
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12634
12610
  readonly units: number
12635
- readonly duration: Duration.DurationInput
12611
+ readonly duration: Duration.Input
12636
12612
  readonly burst?: number | undefined
12637
12613
  readonly strategy?: "enforce" | "shape" | undefined
12638
12614
  }
@@ -12770,7 +12746,7 @@ export const groupedWithin: {
12770
12746
  * @since 2.0.0
12771
12747
  * @category Grouping
12772
12748
  */
12773
- (chunkSize: number, duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
12749
+ (chunkSize: number, duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
12774
12750
  /**
12775
12751
  * Partitions the stream into arrays, emitting when the chunk size is reached
12776
12752
  * or the duration passes.
@@ -12794,11 +12770,11 @@ export const groupedWithin: {
12794
12770
  * @since 2.0.0
12795
12771
  * @category Grouping
12796
12772
  */
12797
- <A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.DurationInput): Stream<Array<A>, E, R>
12773
+ <A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.Input): Stream<Array<A>, E, R>
12798
12774
  } = dual(3, <A, E, R>(
12799
12775
  self: Stream<A, E, R>,
12800
12776
  chunkSize: number,
12801
- duration: Duration.DurationInput
12777
+ duration: Duration.Input
12802
12778
  ): Stream<Array<A>, E, R> =>
12803
12779
  aggregateWithin(
12804
12780
  self,
@@ -12873,7 +12849,7 @@ export const groupBy: {
12873
12849
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12874
12850
  options?: {
12875
12851
  readonly bufferSize?: number | undefined
12876
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12852
+ readonly idleTimeToLive?: Duration.Input | undefined
12877
12853
  }
12878
12854
  ): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<V>], E | E2, R | R2>
12879
12855
  /**
@@ -12912,7 +12888,7 @@ export const groupBy: {
12912
12888
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12913
12889
  options?: {
12914
12890
  readonly bufferSize?: number | undefined
12915
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12891
+ readonly idleTimeToLive?: Duration.Input | undefined
12916
12892
  }
12917
12893
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2>
12918
12894
  } = dual((args) => isStream(args[0]), <A, E, R, K, V, E2, R2>(
@@ -12920,7 +12896,7 @@ export const groupBy: {
12920
12896
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12921
12897
  options?: {
12922
12898
  readonly bufferSize?: number | undefined
12923
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12899
+ readonly idleTimeToLive?: Duration.Input | undefined
12924
12900
  }
12925
12901
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
12926
12902
  groupByImpl(
@@ -13002,7 +12978,7 @@ export const groupByKey: {
13002
12978
  f: (a: NoInfer<A>) => K,
13003
12979
  options?: {
13004
12980
  readonly bufferSize?: number | undefined
13005
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12981
+ readonly idleTimeToLive?: Duration.Input | undefined
13006
12982
  }
13007
12983
  ): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<A>], E, R>
13008
12984
  /**
@@ -13039,7 +13015,7 @@ export const groupByKey: {
13039
13015
  f: (a: NoInfer<A>) => K,
13040
13016
  options?: {
13041
13017
  readonly bufferSize?: number | undefined
13042
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13018
+ readonly idleTimeToLive?: Duration.Input | undefined
13043
13019
  }
13044
13020
  ): Stream<readonly [K, Stream<A>], E, R>
13045
13021
  } = dual((args) => isStream(args[0]), <A, E, R, K>(
@@ -13047,7 +13023,7 @@ export const groupByKey: {
13047
13023
  f: (a: NoInfer<A>) => K,
13048
13024
  options?: {
13049
13025
  readonly bufferSize?: number | undefined
13050
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13026
+ readonly idleTimeToLive?: Duration.Input | undefined
13051
13027
  }
13052
13028
  ): Stream<readonly [K, Stream<A>], E, R> =>
13053
13029
  suspend(() => {
@@ -13145,7 +13121,7 @@ const groupByImpl = <A, E, R, K, V, E2, R2>(
13145
13121
  ) => Effect.Effect<void, E2, R2>,
13146
13122
  options?: {
13147
13123
  readonly bufferSize?: number | undefined
13148
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13124
+ readonly idleTimeToLive?: Duration.Input | undefined
13149
13125
  }
13150
13126
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
13151
13127
  transformPullBracket(
@@ -13537,7 +13513,7 @@ export const aggregateWithin: {
13537
13513
  fromChannel(Channel.fromTransformBracket(Effect.fnUntraced(function*(_upstream, _, scope) {
13538
13514
  const pull = yield* Channel.toPullScoped(self.channel, _)
13539
13515
 
13540
- const pullLatch = Effect.makeLatchUnsafe(false)
13516
+ const pullLatch = Latch.makeUnsafe(false)
13541
13517
  const scheduleStep = Symbol()
13542
13518
  const buffer = yield* Queue.make</**
13543
13519
  * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
@@ -13637,12 +13613,15 @@ export const aggregateWithin: {
13637
13613
  * @category Aggregation
13638
13614
  */
13639
13615
  B>()
13616
+ let leftover: Arr.NonEmptyReadonlyArray<A2> | undefined
13640
13617
  const step = yield* Schedule.toStepWithSleep(schedule)
13641
- const stepToBuffer = Effect.suspend(() => step(lastOutput)).pipe(
13642
- Effect.flatMap(() => Queue.offer(buffer, scheduleStep)),
13643
- Effect.flatMap(() => Effect.never),
13644
- Pull.catchDone(() => Cause.done())
13645
- )
13618
+ const stepToBuffer = Effect.suspend(function loop(): Pull.Pull<never, E3, void, R3> {
13619
+ return step(lastOutput).pipe(
13620
+ Effect.flatMap(() => !hadChunk && leftover === undefined ? loop() : Queue.offer(buffer, scheduleStep)),
13621
+ Effect.flatMap(() => Effect.never),
13622
+ Pull.catchDone(() => Cause.done())
13623
+ )
13624
+ })
13646
13625
 
13647
13626
  // buffer -> sink
13648
13627
  const pullFromBuffer: Pull.Pull<
@@ -13652,7 +13631,6 @@ export const aggregateWithin: {
13652
13631
  Effect.flatMap((arr) => arr === scheduleStep ? Cause.done() : Effect.succeed(arr))
13653
13632
  )
13654
13633
 
13655
- let leftover: Arr.NonEmptyReadonlyArray<A2> | undefined
13656
13634
  const sinkUpstream = Effect.suspend((): Pull.Pull<Arr.NonEmptyReadonlyArray<A | A2>, E> => {
13657
13635
  if (leftover !== undefined) {
13658
13636
  const chunk = leftover
@@ -13664,7 +13642,7 @@ export const aggregateWithin: {
13664
13642
  return pullFromBuffer
13665
13643
  })
13666
13644
  const catchSinkHalt = Effect.flatMap(([value, leftover_]: Sink.End<B, A2>) => {
13667
- // ignore the last output if the upsteam only pulled a halt
13645
+ // ignore the last output if the upstream only pulled a halt
13668
13646
  if (!hadChunk && buffer.state._tag === "Done") return Cause.done()
13669
13647
  lastOutput = Option.some(value)
13670
13648
  leftover = leftover_
@@ -13879,12 +13857,12 @@ export const share: {
13879
13857
  options: {
13880
13858
  readonly capacity: "unbounded"
13881
13859
  readonly replay?: number | undefined
13882
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13860
+ readonly idleTimeToLive?: Duration.Input | undefined
13883
13861
  } | {
13884
13862
  readonly capacity: number
13885
13863
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13886
13864
  readonly replay?: number | undefined
13887
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13865
+ readonly idleTimeToLive?: Duration.Input | undefined
13888
13866
  }
13889
13867
  ): <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
13890
13868
  /**
@@ -13923,12 +13901,12 @@ export const share: {
13923
13901
  options: {
13924
13902
  readonly capacity: "unbounded"
13925
13903
  readonly replay?: number | undefined
13926
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13904
+ readonly idleTimeToLive?: Duration.Input | undefined
13927
13905
  } | {
13928
13906
  readonly capacity: number
13929
13907
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13930
13908
  readonly replay?: number | undefined
13931
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13909
+ readonly idleTimeToLive?: Duration.Input | undefined
13932
13910
  }
13933
13911
  ): Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
13934
13912
  } = dual(2, <A, E, R>(
@@ -13936,12 +13914,12 @@ export const share: {
13936
13914
  options: {
13937
13915
  readonly capacity: "unbounded"
13938
13916
  readonly replay?: number | undefined
13939
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13917
+ readonly idleTimeToLive?: Duration.Input | undefined
13940
13918
  } | {
13941
13919
  readonly capacity: number
13942
13920
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13943
13921
  readonly replay?: number | undefined
13944
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13922
+ readonly idleTimeToLive?: Duration.Input | undefined
13945
13923
  }
13946
13924
  ): Effect.Effect<Stream<A, E>, never, Scope.Scope | R> =>
13947
13925
  Effect.map(
@@ -16121,7 +16099,7 @@ export const provideService: {
16121
16099
  * @since 4.0.0
16122
16100
  * @category Services
16123
16101
  */
16124
- <I, S>(key: ServiceMap.Service<I, S>, service: NoInfer<S>): <A, E, R>(
16102
+ <I, S>(key: ServiceMap.Key<I, S>, service: NoInfer<S>): <A, E, R>(
16125
16103
  self: Stream<A, E, R>
16126
16104
  ) => Stream<A, E, Exclude<R, I>>
16127
16105
  /**
@@ -16160,10 +16138,10 @@ export const provideService: {
16160
16138
  * @since 4.0.0
16161
16139
  * @category Services
16162
16140
  */
16163
- <A, E, R, I, S>(self: Stream<A, E, R>, key: ServiceMap.Service<I, S>, service: NoInfer<S>): Stream<A, E, Exclude<R, I>>
16141
+ <A, E, R, I, S>(self: Stream<A, E, R>, key: ServiceMap.Key<I, S>, service: NoInfer<S>): Stream<A, E, Exclude<R, I>>
16164
16142
  } = dual(3, <A, E, R, I, S>(
16165
16143
  self: Stream<A, E, R>,
16166
- key: ServiceMap.Service<I, S>,
16144
+ key: ServiceMap.Key<I, S>,
16167
16145
  service: NoInfer<S>
16168
16146
  ): Stream<A, E, Exclude<R, I>> => fromChannel(Channel.provideService(self.channel, key, service)))
16169
16147
 
@@ -16244,7 +16222,7 @@ export const provideServiceEffect: {
16244
16222
  * @since 4.0.0
16245
16223
  * @category Services
16246
16224
  */
16247
- <I, S, ES, RS>(key: ServiceMap.Service<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <A, E, R>(
16225
+ <I, S, ES, RS>(key: ServiceMap.Key<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <A, E, R>(
16248
16226
  self: Stream<A, E, R>
16249
16227
  ) => Stream<A, E | ES, Exclude<R, I> | RS>
16250
16228
  /**
@@ -16287,12 +16265,12 @@ export const provideServiceEffect: {
16287
16265
  */
16288
16266
  <A, E, R, I, S, ES, RS>(
16289
16267
  self: Stream<A, E, R>,
16290
- key: ServiceMap.Service<I, S>,
16268
+ key: ServiceMap.Key<I, S>,
16291
16269
  service: Effect.Effect<NoInfer<S>, ES, RS>
16292
16270
  ): Stream<A, E | ES, Exclude<R, I> | RS>
16293
16271
  } = dual(3, <A, E, R, I, S, ES, RS>(
16294
16272
  self: Stream<A, E, R>,
16295
- key: ServiceMap.Service<I, S>,
16273
+ key: ServiceMap.Key<I, S>,
16296
16274
  service: Effect.Effect<NoInfer<S>, ES, RS>
16297
16275
  ): Stream<A, E | ES, Exclude<R, I> | RS> => fromChannel(Channel.provideServiceEffect(self.channel, key, service)))
16298
16276
 
@@ -16477,7 +16455,7 @@ export const updateService: {
16477
16455
  * @since 2.0.0
16478
16456
  * @category Services
16479
16457
  */
16480
- <I, S>(key: ServiceMap.Service<I, S>, f: (service: NoInfer<S>) => S): <A, E, R>(
16458
+ <I, S>(key: ServiceMap.Key<I, S>, f: (service: NoInfer<S>) => S): <A, E, R>(
16481
16459
  self: Stream<A, E, R>
16482
16460
  ) => Stream<A, E, R | I>
16483
16461
  /**
@@ -16507,12 +16485,12 @@ export const updateService: {
16507
16485
  */
16508
16486
  <A, E, R, I, S>(
16509
16487
  self: Stream<A, E, R>,
16510
- key: ServiceMap.Service<I, S>,
16488
+ key: ServiceMap.Key<I, S>,
16511
16489
  f: (service: NoInfer<S>) => S
16512
16490
  ): Stream<A, E, R | I>
16513
16491
  } = dual(3, <A, E, R, I, S>(
16514
16492
  self: Stream<A, E, R>,
16515
- service: ServiceMap.Service<I, S>,
16493
+ service: ServiceMap.Key<I, S>,
16516
16494
  f: (service: NoInfer<S>) => S
16517
16495
  ): Stream<A, E, R | I> =>
16518
16496
  updateServices(self, (services) =>
@@ -16591,7 +16569,7 @@ export const withSpan: {
16591
16569
  } = function() {
16592
16570
  const dataFirst = isStream(arguments[0])
16593
16571
  const name = dataFirst ? arguments[1] : arguments[0]
16594
- const options = addSpanStackTrace(dataFirst ? arguments[1] : arguments[2])
16572
+ const options = addSpanStackTrace(dataFirst ? arguments[2] : arguments[1])
16595
16573
  if (dataFirst) {
16596
16574
  const self = arguments[0] as Stream<any, any, any>
16597
16575
  return fromChannel(Channel.withSpan(self.channel, name, options))
@@ -17747,7 +17725,7 @@ export const toReadableStreamWith = dual<
17747
17725
  ): ReadableStream<A> => {
17748
17726
  let currentResolve: (() => void) | undefined = undefined
17749
17727
  let fiber: Fiber.Fiber<void, E> | undefined = undefined
17750
- const latch = Effect.makeLatchUnsafe(false)
17728
+ const latch = Latch.makeUnsafe(false)
17751
17729
 
17752
17730
  return new ReadableStream<A>({
17753
17731
  start(controller) {