effect 4.0.0-beta.4 → 4.0.0-beta.40

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 (1222) hide show
  1. package/dist/Array.d.ts +213 -385
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +149 -102
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +46 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +35 -38
  8. package/dist/BigDecimal.js.map +1 -1
  9. package/dist/BigInt.d.ts +39 -32
  10. package/dist/BigInt.d.ts.map +1 -1
  11. package/dist/BigInt.js +32 -29
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Brand.d.ts +1 -1
  14. package/dist/Brand.d.ts.map +1 -1
  15. package/dist/Brand.js +1 -1
  16. package/dist/Brand.js.map +1 -1
  17. package/dist/Cache.d.ts +2 -2
  18. package/dist/Cache.d.ts.map +1 -1
  19. package/dist/Cache.js +6 -5
  20. package/dist/Cache.js.map +1 -1
  21. package/dist/Cause.d.ts +33 -2
  22. package/dist/Cause.d.ts.map +1 -1
  23. package/dist/Cause.js +19 -0
  24. package/dist/Cause.js.map +1 -1
  25. package/dist/Channel.d.ts +130 -35
  26. package/dist/Channel.d.ts.map +1 -1
  27. package/dist/Channel.js +96 -45
  28. package/dist/Channel.js.map +1 -1
  29. package/dist/Chunk.d.ts +112 -304
  30. package/dist/Chunk.d.ts.map +1 -1
  31. package/dist/Chunk.js +56 -88
  32. package/dist/Chunk.js.map +1 -1
  33. package/dist/Combiner.d.ts +280 -13
  34. package/dist/Combiner.d.ts.map +1 -1
  35. package/dist/Combiner.js +198 -7
  36. package/dist/Combiner.js.map +1 -1
  37. package/dist/Config.d.ts +169 -9
  38. package/dist/Config.d.ts.map +1 -1
  39. package/dist/Config.js +69 -11
  40. package/dist/Config.js.map +1 -1
  41. package/dist/ConfigProvider.d.ts +1 -1
  42. package/dist/Cron.d.ts +11 -7
  43. package/dist/Cron.d.ts.map +1 -1
  44. package/dist/Cron.js +120 -63
  45. package/dist/Cron.js.map +1 -1
  46. package/dist/Data.d.ts +535 -366
  47. package/dist/Data.d.ts.map +1 -1
  48. package/dist/Data.js +132 -79
  49. package/dist/Data.js.map +1 -1
  50. package/dist/DateTime.d.ts +72 -253
  51. package/dist/DateTime.d.ts.map +1 -1
  52. package/dist/DateTime.js +15 -60
  53. package/dist/DateTime.js.map +1 -1
  54. package/dist/Deferred.d.ts +7 -5
  55. package/dist/Deferred.d.ts.map +1 -1
  56. package/dist/Deferred.js +7 -5
  57. package/dist/Deferred.js.map +1 -1
  58. package/dist/Duration.d.ts +62 -32
  59. package/dist/Duration.d.ts.map +1 -1
  60. package/dist/Duration.js +108 -78
  61. package/dist/Duration.js.map +1 -1
  62. package/dist/Effect.d.ts +1224 -951
  63. package/dist/Effect.d.ts.map +1 -1
  64. package/dist/Effect.js +398 -338
  65. package/dist/Effect.js.map +1 -1
  66. package/dist/Encoding.d.ts +194 -0
  67. package/dist/Encoding.d.ts.map +1 -0
  68. package/dist/Encoding.js +352 -0
  69. package/dist/Encoding.js.map +1 -0
  70. package/dist/Equal.d.ts +276 -109
  71. package/dist/Equal.d.ts.map +1 -1
  72. package/dist/Equal.js +124 -48
  73. package/dist/Equal.js.map +1 -1
  74. package/dist/Equivalence.d.ts +60 -3
  75. package/dist/Equivalence.d.ts.map +1 -1
  76. package/dist/Equivalence.js +70 -13
  77. package/dist/Equivalence.js.map +1 -1
  78. package/dist/ErrorReporter.d.ts +374 -0
  79. package/dist/ErrorReporter.d.ts.map +1 -0
  80. package/dist/ErrorReporter.js +245 -0
  81. package/dist/ErrorReporter.js.map +1 -0
  82. package/dist/Exit.d.ts +24 -12
  83. package/dist/Exit.d.ts.map +1 -1
  84. package/dist/Exit.js +8 -4
  85. package/dist/Exit.js.map +1 -1
  86. package/dist/Fiber.d.ts +5 -3
  87. package/dist/Fiber.d.ts.map +1 -1
  88. package/dist/Fiber.js.map +1 -1
  89. package/dist/FiberHandle.d.ts +9 -8
  90. package/dist/FiberHandle.d.ts.map +1 -1
  91. package/dist/FiberHandle.js +8 -7
  92. package/dist/FiberHandle.js.map +1 -1
  93. package/dist/FiberMap.d.ts +20 -19
  94. package/dist/FiberMap.d.ts.map +1 -1
  95. package/dist/FiberMap.js +6 -6
  96. package/dist/FiberMap.js.map +1 -1
  97. package/dist/FileSystem.d.ts +18 -17
  98. package/dist/FileSystem.d.ts.map +1 -1
  99. package/dist/FileSystem.js +17 -13
  100. package/dist/FileSystem.js.map +1 -1
  101. package/dist/Filter.d.ts +34 -38
  102. package/dist/Filter.d.ts.map +1 -1
  103. package/dist/Filter.js +15 -13
  104. package/dist/Filter.js.map +1 -1
  105. package/dist/Formatter.d.ts +131 -47
  106. package/dist/Formatter.d.ts.map +1 -1
  107. package/dist/Formatter.js +229 -51
  108. package/dist/Formatter.js.map +1 -1
  109. package/dist/Function.d.ts +1 -9
  110. package/dist/Function.d.ts.map +1 -1
  111. package/dist/Function.js +2 -10
  112. package/dist/Function.js.map +1 -1
  113. package/dist/Graph.d.ts +65 -65
  114. package/dist/Graph.d.ts.map +1 -1
  115. package/dist/Graph.js +60 -62
  116. package/dist/Graph.js.map +1 -1
  117. package/dist/HashMap.d.ts +26 -19
  118. package/dist/HashMap.d.ts.map +1 -1
  119. package/dist/HashMap.js +7 -5
  120. package/dist/HashMap.js.map +1 -1
  121. package/dist/Iterable.d.ts +50 -50
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +106 -34
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/JsonSchema.d.ts +299 -10
  126. package/dist/JsonSchema.d.ts.map +1 -1
  127. package/dist/JsonSchema.js +323 -4
  128. package/dist/JsonSchema.js.map +1 -1
  129. package/dist/Latch.d.ts +175 -0
  130. package/dist/Latch.d.ts.map +1 -0
  131. package/dist/Latch.js +130 -0
  132. package/dist/Latch.js.map +1 -0
  133. package/dist/Layer.d.ts +306 -129
  134. package/dist/Layer.d.ts.map +1 -1
  135. package/dist/Layer.js +92 -47
  136. package/dist/Layer.js.map +1 -1
  137. package/dist/LayerMap.d.ts +9 -8
  138. package/dist/LayerMap.d.ts.map +1 -1
  139. package/dist/LayerMap.js +3 -3
  140. package/dist/LayerMap.js.map +1 -1
  141. package/dist/LogLevel.d.ts +32 -0
  142. package/dist/LogLevel.d.ts.map +1 -1
  143. package/dist/LogLevel.js +28 -100
  144. package/dist/LogLevel.js.map +1 -1
  145. package/dist/Logger.d.ts +29 -95
  146. package/dist/Logger.d.ts.map +1 -1
  147. package/dist/Logger.js +2 -3
  148. package/dist/Logger.js.map +1 -1
  149. package/dist/ManagedRuntime.d.ts +2 -2
  150. package/dist/ManagedRuntime.js +2 -2
  151. package/dist/Metric.d.ts +4 -6
  152. package/dist/Metric.d.ts.map +1 -1
  153. package/dist/Metric.js +3 -5
  154. package/dist/Metric.js.map +1 -1
  155. package/dist/MutableHashMap.d.ts +7 -0
  156. package/dist/MutableHashMap.d.ts.map +1 -1
  157. package/dist/MutableHashMap.js +8 -0
  158. package/dist/MutableHashMap.js.map +1 -1
  159. package/dist/MutableHashSet.d.ts +7 -0
  160. package/dist/MutableHashSet.d.ts.map +1 -1
  161. package/dist/MutableHashSet.js +8 -0
  162. package/dist/MutableHashSet.js.map +1 -1
  163. package/dist/Newtype.d.ts +291 -0
  164. package/dist/Newtype.d.ts.map +1 -0
  165. package/dist/Newtype.js +161 -0
  166. package/dist/Newtype.js.map +1 -0
  167. package/dist/Number.d.ts +74 -18
  168. package/dist/Number.d.ts.map +1 -1
  169. package/dist/Number.js +34 -15
  170. package/dist/Number.js.map +1 -1
  171. package/dist/Optic.d.ts +947 -18
  172. package/dist/Optic.d.ts.map +1 -1
  173. package/dist/Optic.js +454 -5
  174. package/dist/Optic.js.map +1 -1
  175. package/dist/Option.d.ts +25 -16
  176. package/dist/Option.d.ts.map +1 -1
  177. package/dist/Option.js +15 -9
  178. package/dist/Option.js.map +1 -1
  179. package/dist/Order.d.ts +6 -1
  180. package/dist/Order.d.ts.map +1 -1
  181. package/dist/Order.js +19 -14
  182. package/dist/Order.js.map +1 -1
  183. package/dist/PartitionedSemaphore.d.ts +146 -15
  184. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  185. package/dist/PartitionedSemaphore.js +174 -61
  186. package/dist/PartitionedSemaphore.js.map +1 -1
  187. package/dist/Pipeable.d.ts +17 -0
  188. package/dist/Pipeable.d.ts.map +1 -1
  189. package/dist/Pipeable.js +19 -1
  190. package/dist/Pipeable.js.map +1 -1
  191. package/dist/PlatformError.d.ts +10 -9
  192. package/dist/PlatformError.d.ts.map +1 -1
  193. package/dist/PlatformError.js +2 -2
  194. package/dist/PlatformError.js.map +1 -1
  195. package/dist/Pool.d.ts +6 -4
  196. package/dist/Pool.d.ts.map +1 -1
  197. package/dist/Pool.js +7 -5
  198. package/dist/Pool.js.map +1 -1
  199. package/dist/PubSub.d.ts +8 -6
  200. package/dist/PubSub.d.ts.map +1 -1
  201. package/dist/PubSub.js +18 -10
  202. package/dist/PubSub.js.map +1 -1
  203. package/dist/Pull.d.ts.map +1 -1
  204. package/dist/Pull.js +1 -1
  205. package/dist/Pull.js.map +1 -1
  206. package/dist/Queue.d.ts +9 -6
  207. package/dist/Queue.d.ts.map +1 -1
  208. package/dist/Queue.js +7 -5
  209. package/dist/Queue.js.map +1 -1
  210. package/dist/Random.d.ts +35 -1
  211. package/dist/Random.d.ts.map +1 -1
  212. package/dist/Random.js +46 -12
  213. package/dist/Random.js.map +1 -1
  214. package/dist/RcMap.d.ts +2 -2
  215. package/dist/RcMap.d.ts.map +1 -1
  216. package/dist/RcMap.js +1 -1
  217. package/dist/RcMap.js.map +1 -1
  218. package/dist/RcRef.d.ts +1 -1
  219. package/dist/RcRef.d.ts.map +1 -1
  220. package/dist/Record.d.ts +63 -160
  221. package/dist/Record.d.ts.map +1 -1
  222. package/dist/Record.js +37 -56
  223. package/dist/Record.js.map +1 -1
  224. package/dist/Reducer.d.ts +166 -7
  225. package/dist/Reducer.d.ts.map +1 -1
  226. package/dist/Reducer.js +135 -1
  227. package/dist/Reducer.js.map +1 -1
  228. package/dist/References.d.ts +242 -226
  229. package/dist/References.d.ts.map +1 -1
  230. package/dist/References.js +240 -247
  231. package/dist/References.js.map +1 -1
  232. package/dist/Request.d.ts +1 -1
  233. package/dist/Request.d.ts.map +1 -1
  234. package/dist/Request.js +2 -1
  235. package/dist/Request.js.map +1 -1
  236. package/dist/RequestResolver.d.ts +25 -45
  237. package/dist/RequestResolver.d.ts.map +1 -1
  238. package/dist/RequestResolver.js +10 -30
  239. package/dist/RequestResolver.js.map +1 -1
  240. package/dist/Resource.d.ts.map +1 -1
  241. package/dist/Resource.js +2 -1
  242. package/dist/Resource.js.map +1 -1
  243. package/dist/Result.d.ts +1 -1
  244. package/dist/Result.d.ts.map +1 -1
  245. package/dist/Result.js +1 -2
  246. package/dist/Result.js.map +1 -1
  247. package/dist/Runtime.d.ts +66 -0
  248. package/dist/Runtime.d.ts.map +1 -1
  249. package/dist/Runtime.js +79 -6
  250. package/dist/Runtime.js.map +1 -1
  251. package/dist/Schedule.d.ts +174 -291
  252. package/dist/Schedule.d.ts.map +1 -1
  253. package/dist/Schedule.js +160 -134
  254. package/dist/Schedule.js.map +1 -1
  255. package/dist/Scheduler.d.ts +34 -123
  256. package/dist/Scheduler.d.ts.map +1 -1
  257. package/dist/Scheduler.js +31 -123
  258. package/dist/Scheduler.js.map +1 -1
  259. package/dist/Schema.d.ts +2722 -247
  260. package/dist/Schema.d.ts.map +1 -1
  261. package/dist/Schema.js +1947 -224
  262. package/dist/Schema.js.map +1 -1
  263. package/dist/SchemaAST.d.ts +7 -2
  264. package/dist/SchemaAST.d.ts.map +1 -1
  265. package/dist/SchemaAST.js +131 -25
  266. package/dist/SchemaAST.js.map +1 -1
  267. package/dist/SchemaGetter.d.ts +5 -5
  268. package/dist/SchemaGetter.d.ts.map +1 -1
  269. package/dist/SchemaGetter.js +18 -18
  270. package/dist/SchemaGetter.js.map +1 -1
  271. package/dist/SchemaParser.d.ts +44 -54
  272. package/dist/SchemaParser.d.ts.map +1 -1
  273. package/dist/SchemaParser.js +55 -2
  274. package/dist/SchemaParser.js.map +1 -1
  275. package/dist/SchemaRepresentation.d.ts +46 -45
  276. package/dist/SchemaRepresentation.d.ts.map +1 -1
  277. package/dist/SchemaRepresentation.js +49 -24
  278. package/dist/SchemaRepresentation.js.map +1 -1
  279. package/dist/SchemaTransformation.d.ts +107 -3
  280. package/dist/SchemaTransformation.d.ts.map +1 -1
  281. package/dist/SchemaTransformation.js +173 -13
  282. package/dist/SchemaTransformation.js.map +1 -1
  283. package/dist/ScopedCache.d.ts +2 -2
  284. package/dist/ScopedCache.d.ts.map +1 -1
  285. package/dist/ScopedCache.js +1 -1
  286. package/dist/ScopedCache.js.map +1 -1
  287. package/dist/Semaphore.d.ts +307 -0
  288. package/dist/Semaphore.d.ts.map +1 -0
  289. package/dist/Semaphore.js +222 -0
  290. package/dist/Semaphore.js.map +1 -0
  291. package/dist/ServiceMap.d.ts +67 -31
  292. package/dist/ServiceMap.d.ts.map +1 -1
  293. package/dist/ServiceMap.js +39 -24
  294. package/dist/ServiceMap.js.map +1 -1
  295. package/dist/Sink.d.ts +18 -15
  296. package/dist/Sink.d.ts.map +1 -1
  297. package/dist/Sink.js +53 -6
  298. package/dist/Sink.js.map +1 -1
  299. package/dist/Stdio.d.ts +16 -4
  300. package/dist/Stdio.d.ts.map +1 -1
  301. package/dist/Stdio.js +18 -0
  302. package/dist/Stdio.js.map +1 -1
  303. package/dist/Stream.d.ts +284 -431
  304. package/dist/Stream.d.ts.map +1 -1
  305. package/dist/Stream.js +189 -88
  306. package/dist/Stream.js.map +1 -1
  307. package/dist/String.d.ts +114 -47
  308. package/dist/String.d.ts.map +1 -1
  309. package/dist/String.js +29 -47
  310. package/dist/String.js.map +1 -1
  311. package/dist/Struct.d.ts +23 -7
  312. package/dist/Struct.d.ts.map +1 -1
  313. package/dist/Struct.js +22 -0
  314. package/dist/Struct.js.map +1 -1
  315. package/dist/SubscriptionRef.d.ts +3 -3
  316. package/dist/SubscriptionRef.d.ts.map +1 -1
  317. package/dist/SubscriptionRef.js +85 -117
  318. package/dist/SubscriptionRef.js.map +1 -1
  319. package/dist/SynchronizedRef.d.ts +2 -1
  320. package/dist/SynchronizedRef.d.ts.map +1 -1
  321. package/dist/SynchronizedRef.js +2 -1
  322. package/dist/SynchronizedRef.js.map +1 -1
  323. package/dist/Terminal.d.ts +2 -1
  324. package/dist/Terminal.d.ts.map +1 -1
  325. package/dist/Terminal.js.map +1 -1
  326. package/dist/Tracer.d.ts +5 -4
  327. package/dist/Tracer.d.ts.map +1 -1
  328. package/dist/Tracer.js +2 -1
  329. package/dist/Tracer.js.map +1 -1
  330. package/dist/Trie.d.ts +44 -31
  331. package/dist/Trie.d.ts.map +1 -1
  332. package/dist/Trie.js +13 -9
  333. package/dist/Trie.js.map +1 -1
  334. package/dist/TxChunk.d.ts +37 -37
  335. package/dist/TxChunk.d.ts.map +1 -1
  336. package/dist/TxChunk.js +3 -3
  337. package/dist/TxChunk.js.map +1 -1
  338. package/dist/TxDeferred.d.ts +328 -0
  339. package/dist/TxDeferred.d.ts.map +1 -0
  340. package/dist/TxDeferred.js +197 -0
  341. package/dist/TxDeferred.js.map +1 -0
  342. package/dist/TxHashMap.d.ts +159 -140
  343. package/dist/TxHashMap.d.ts.map +1 -1
  344. package/dist/TxHashMap.js +51 -44
  345. package/dist/TxHashMap.js.map +1 -1
  346. package/dist/TxHashSet.d.ts +36 -36
  347. package/dist/TxHashSet.d.ts.map +1 -1
  348. package/dist/TxHashSet.js +16 -15
  349. package/dist/TxHashSet.js.map +1 -1
  350. package/dist/TxPriorityQueue.d.ts +609 -0
  351. package/dist/TxPriorityQueue.d.ts.map +1 -0
  352. package/dist/TxPriorityQueue.js +416 -0
  353. package/dist/TxPriorityQueue.js.map +1 -0
  354. package/dist/TxPubSub.d.ts +585 -0
  355. package/dist/TxPubSub.d.ts.map +1 -0
  356. package/dist/TxPubSub.js +521 -0
  357. package/dist/TxPubSub.js.map +1 -0
  358. package/dist/TxQueue.d.ts +32 -32
  359. package/dist/TxQueue.d.ts.map +1 -1
  360. package/dist/TxQueue.js +26 -26
  361. package/dist/TxQueue.js.map +1 -1
  362. package/dist/TxReentrantLock.d.ts +523 -0
  363. package/dist/TxReentrantLock.d.ts.map +1 -0
  364. package/dist/TxReentrantLock.js +504 -0
  365. package/dist/TxReentrantLock.js.map +1 -0
  366. package/dist/TxRef.d.ts +34 -34
  367. package/dist/TxRef.d.ts.map +1 -1
  368. package/dist/TxRef.js +21 -14
  369. package/dist/TxRef.js.map +1 -1
  370. package/dist/TxSemaphore.d.ts +170 -10
  371. package/dist/TxSemaphore.d.ts.map +1 -1
  372. package/dist/TxSemaphore.js +23 -8
  373. package/dist/TxSemaphore.js.map +1 -1
  374. package/dist/TxSubscriptionRef.d.ts +508 -0
  375. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  376. package/dist/TxSubscriptionRef.js +293 -0
  377. package/dist/TxSubscriptionRef.js.map +1 -0
  378. package/dist/Types.d.ts +80 -23
  379. package/dist/Types.d.ts.map +1 -1
  380. package/dist/Utils.d.ts +137 -65
  381. package/dist/Utils.d.ts.map +1 -1
  382. package/dist/Utils.js +38 -66
  383. package/dist/Utils.js.map +1 -1
  384. package/dist/index.d.ts +804 -53
  385. package/dist/index.d.ts.map +1 -1
  386. package/dist/index.js +804 -53
  387. package/dist/index.js.map +1 -1
  388. package/dist/internal/core.js +11 -3
  389. package/dist/internal/core.js.map +1 -1
  390. package/dist/internal/dateTime.js +77 -71
  391. package/dist/internal/dateTime.js.map +1 -1
  392. package/dist/internal/effect.js +281 -201
  393. package/dist/internal/effect.js.map +1 -1
  394. package/dist/internal/hashMap.js +7 -5
  395. package/dist/internal/hashMap.js.map +1 -1
  396. package/dist/internal/option.js +6 -0
  397. package/dist/internal/option.js.map +1 -1
  398. package/dist/internal/random.d.ts +2 -0
  399. package/dist/internal/random.d.ts.map +1 -0
  400. package/dist/internal/random.js +13 -0
  401. package/dist/internal/random.js.map +1 -0
  402. package/dist/internal/rcRef.js +3 -2
  403. package/dist/internal/rcRef.js.map +1 -1
  404. package/dist/internal/references.d.ts +2 -0
  405. package/dist/internal/references.d.ts.map +1 -0
  406. package/dist/internal/references.js +51 -0
  407. package/dist/internal/references.js.map +1 -0
  408. package/dist/internal/request.js +2 -2
  409. package/dist/internal/request.js.map +1 -1
  410. package/dist/internal/schema/annotations.js +2 -0
  411. package/dist/internal/schema/annotations.js.map +1 -1
  412. package/dist/internal/schema/representation.js +47 -106
  413. package/dist/internal/schema/representation.js.map +1 -1
  414. package/dist/internal/schema/schema.js +1 -0
  415. package/dist/internal/schema/schema.js.map +1 -1
  416. package/dist/internal/schema/to-codec.js +7 -10
  417. package/dist/internal/schema/to-codec.js.map +1 -1
  418. package/dist/internal/trie.js +8 -7
  419. package/dist/internal/trie.js.map +1 -1
  420. package/dist/testing/TestClock.d.ts +8 -7
  421. package/dist/testing/TestClock.d.ts.map +1 -1
  422. package/dist/testing/TestClock.js +6 -4
  423. package/dist/testing/TestClock.js.map +1 -1
  424. package/dist/testing/TestSchema.d.ts +266 -32
  425. package/dist/testing/TestSchema.d.ts.map +1 -1
  426. package/dist/testing/TestSchema.js +296 -23
  427. package/dist/testing/TestSchema.js.map +1 -1
  428. package/dist/testing/index.d.ts +64 -1
  429. package/dist/testing/index.d.ts.map +1 -1
  430. package/dist/testing/index.js +64 -1
  431. package/dist/testing/index.js.map +1 -1
  432. package/dist/unstable/ai/AiError.d.ts +136 -54
  433. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  434. package/dist/unstable/ai/AiError.js +28 -23
  435. package/dist/unstable/ai/AiError.js.map +1 -1
  436. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  437. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  438. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  439. package/dist/unstable/ai/Chat.d.ts +7 -8
  440. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  441. package/dist/unstable/ai/Chat.js +38 -44
  442. package/dist/unstable/ai/Chat.js.map +1 -1
  443. package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
  444. package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
  445. package/dist/unstable/ai/EmbeddingModel.js +127 -0
  446. package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
  447. package/dist/unstable/ai/LanguageModel.d.ts +53 -45
  448. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  449. package/dist/unstable/ai/LanguageModel.js +265 -143
  450. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  451. package/dist/unstable/ai/McpSchema.d.ts +183 -88
  452. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  453. package/dist/unstable/ai/McpSchema.js +57 -12
  454. package/dist/unstable/ai/McpSchema.js.map +1 -1
  455. package/dist/unstable/ai/McpServer.d.ts +66 -13
  456. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  457. package/dist/unstable/ai/McpServer.js +193 -51
  458. package/dist/unstable/ai/McpServer.js.map +1 -1
  459. package/dist/unstable/ai/Model.d.ts +25 -7
  460. package/dist/unstable/ai/Model.d.ts.map +1 -1
  461. package/dist/unstable/ai/Model.js +22 -6
  462. package/dist/unstable/ai/Model.js.map +1 -1
  463. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  464. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  465. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  466. package/dist/unstable/ai/Prompt.d.ts +20 -20
  467. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  468. package/dist/unstable/ai/Response.d.ts +26 -26
  469. package/dist/unstable/ai/Response.d.ts.map +1 -1
  470. package/dist/unstable/ai/Response.js +1 -1
  471. package/dist/unstable/ai/Response.js.map +1 -1
  472. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  473. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  474. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  475. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  476. package/dist/unstable/ai/Tool.d.ts +34 -4
  477. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  478. package/dist/unstable/ai/Tool.js +28 -10
  479. package/dist/unstable/ai/Tool.js.map +1 -1
  480. package/dist/unstable/ai/Toolkit.d.ts +1 -1
  481. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  482. package/dist/unstable/ai/Toolkit.js +4 -11
  483. package/dist/unstable/ai/Toolkit.js.map +1 -1
  484. package/dist/unstable/ai/index.d.ts +22 -1
  485. package/dist/unstable/ai/index.d.ts.map +1 -1
  486. package/dist/unstable/ai/index.js +22 -1
  487. package/dist/unstable/ai/index.js.map +1 -1
  488. package/dist/unstable/ai/internal/codec-transformer.js +0 -5
  489. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  490. package/dist/unstable/cli/Argument.d.ts +2 -4
  491. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  492. package/dist/unstable/cli/Argument.js +1 -3
  493. package/dist/unstable/cli/Argument.js.map +1 -1
  494. package/dist/unstable/cli/CliError.d.ts +27 -60
  495. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  496. package/dist/unstable/cli/CliError.js +25 -57
  497. package/dist/unstable/cli/CliError.js.map +1 -1
  498. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  499. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  500. package/dist/unstable/cli/CliOutput.js +65 -10
  501. package/dist/unstable/cli/CliOutput.js.map +1 -1
  502. package/dist/unstable/cli/Command.d.ts +371 -58
  503. package/dist/unstable/cli/Command.d.ts.map +1 -1
  504. package/dist/unstable/cli/Command.js +328 -67
  505. package/dist/unstable/cli/Command.js.map +1 -1
  506. package/dist/unstable/cli/Completions.d.ts +16 -0
  507. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  508. package/dist/unstable/cli/Completions.js +23 -0
  509. package/dist/unstable/cli/Completions.js.map +1 -0
  510. package/dist/unstable/cli/Flag.d.ts +2 -2
  511. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  512. package/dist/unstable/cli/Flag.js +1 -1
  513. package/dist/unstable/cli/Flag.js.map +1 -1
  514. package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
  515. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
  516. package/dist/unstable/cli/GlobalFlag.js +118 -0
  517. package/dist/unstable/cli/GlobalFlag.js.map +1 -0
  518. package/dist/unstable/cli/HelpDoc.d.ts +81 -11
  519. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  520. package/dist/unstable/cli/Param.d.ts +4 -4
  521. package/dist/unstable/cli/Param.d.ts.map +1 -1
  522. package/dist/unstable/cli/Param.js +7 -7
  523. package/dist/unstable/cli/Param.js.map +1 -1
  524. package/dist/unstable/cli/Primitive.d.ts +2 -2
  525. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  526. package/dist/unstable/cli/Primitive.js +1 -1
  527. package/dist/unstable/cli/Primitive.js.map +1 -1
  528. package/dist/unstable/cli/Prompt.js +258 -84
  529. package/dist/unstable/cli/Prompt.js.map +1 -1
  530. package/dist/unstable/cli/index.d.ts +8 -0
  531. package/dist/unstable/cli/index.d.ts.map +1 -1
  532. package/dist/unstable/cli/index.js +8 -0
  533. package/dist/unstable/cli/index.js.map +1 -1
  534. package/dist/unstable/cli/internal/command.d.ts +40 -14
  535. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  536. package/dist/unstable/cli/internal/command.js +72 -46
  537. package/dist/unstable/cli/internal/command.js.map +1 -1
  538. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +16 -4
  539. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  540. package/dist/unstable/cli/internal/config.js +42 -0
  541. package/dist/unstable/cli/internal/config.js.map +1 -1
  542. package/dist/unstable/cli/internal/help.d.ts +33 -0
  543. package/dist/unstable/cli/internal/help.d.ts.map +1 -0
  544. package/dist/unstable/cli/internal/help.js +125 -0
  545. package/dist/unstable/cli/internal/help.js.map +1 -0
  546. package/dist/unstable/cli/internal/parser.js +61 -43
  547. package/dist/unstable/cli/internal/parser.js.map +1 -1
  548. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  549. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  550. package/dist/unstable/cluster/ClusterCron.js +1 -1
  551. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  552. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  553. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  554. package/dist/unstable/cluster/ClusterWorkflowEngine.js +29 -26
  555. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  556. package/dist/unstable/cluster/DeliverAt.js +1 -1
  557. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  558. package/dist/unstable/cluster/Entity.d.ts +10 -8
  559. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  560. package/dist/unstable/cluster/Entity.js +7 -7
  561. package/dist/unstable/cluster/Entity.js.map +1 -1
  562. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  563. package/dist/unstable/cluster/EntityAddress.js +1 -1
  564. package/dist/unstable/cluster/EntityAddress.js.map +1 -1
  565. package/dist/unstable/cluster/EntityResource.d.ts +2 -2
  566. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  567. package/dist/unstable/cluster/Envelope.d.ts +1 -1
  568. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  569. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  570. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  571. package/dist/unstable/cluster/Message.d.ts +14 -13
  572. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  573. package/dist/unstable/cluster/Message.js +3 -2
  574. package/dist/unstable/cluster/Message.js.map +1 -1
  575. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  576. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  577. package/dist/unstable/cluster/MessageStorage.js +14 -13
  578. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  579. package/dist/unstable/cluster/Reply.d.ts +8 -7
  580. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  581. package/dist/unstable/cluster/Reply.js +4 -3
  582. package/dist/unstable/cluster/Reply.js.map +1 -1
  583. package/dist/unstable/cluster/Runner.d.ts +1 -1
  584. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  585. package/dist/unstable/cluster/Runner.js +1 -1
  586. package/dist/unstable/cluster/Runner.js.map +1 -1
  587. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  588. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  589. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  590. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  591. package/dist/unstable/cluster/RunnerServer.js +9 -8
  592. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  593. package/dist/unstable/cluster/Runners.d.ts +2 -1
  594. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  595. package/dist/unstable/cluster/Runners.js +11 -9
  596. package/dist/unstable/cluster/Runners.js.map +1 -1
  597. package/dist/unstable/cluster/ShardId.js +3 -3
  598. package/dist/unstable/cluster/ShardId.js.map +1 -1
  599. package/dist/unstable/cluster/Sharding.d.ts +2 -2
  600. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  601. package/dist/unstable/cluster/Sharding.js +28 -20
  602. package/dist/unstable/cluster/Sharding.js.map +1 -1
  603. package/dist/unstable/cluster/ShardingConfig.d.ts +26 -25
  604. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  605. package/dist/unstable/cluster/ShardingConfig.js +24 -24
  606. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  607. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  608. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  609. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  610. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  611. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  612. package/dist/unstable/cluster/internal/entityManager.js +14 -14
  613. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  614. package/dist/unstable/cluster/internal/entityReaper.js +2 -1
  615. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  616. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  617. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  618. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  619. package/dist/unstable/devtools/DevToolsClient.js +4 -3
  620. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  621. package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
  622. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  623. package/dist/unstable/devtools/DevToolsSchema.js +9 -2
  624. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  625. package/dist/unstable/encoding/Msgpack.d.ts +1 -1
  626. package/dist/unstable/encoding/Ndjson.d.ts +9 -9
  627. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  628. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  629. package/dist/unstable/encoding/Sse.d.ts +4 -4
  630. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  631. package/dist/unstable/encoding/Sse.js +1 -1
  632. package/dist/unstable/encoding/Sse.js.map +1 -1
  633. package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
  634. package/dist/unstable/eventlog/EventJournal.js +2 -2
  635. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  636. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  637. package/dist/unstable/eventlog/EventLog.js +3 -2
  638. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  639. package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
  640. package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
  641. package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
  642. package/dist/unstable/http/Cookies.d.ts +52 -7
  643. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  644. package/dist/unstable/http/Cookies.js +27 -6
  645. package/dist/unstable/http/Cookies.js.map +1 -1
  646. package/dist/unstable/http/Etag.d.ts.map +1 -1
  647. package/dist/unstable/http/Etag.js +5 -1
  648. package/dist/unstable/http/Etag.js.map +1 -1
  649. package/dist/unstable/http/Headers.d.ts +19 -2
  650. package/dist/unstable/http/Headers.d.ts.map +1 -1
  651. package/dist/unstable/http/Headers.js +40 -11
  652. package/dist/unstable/http/Headers.js.map +1 -1
  653. package/dist/unstable/http/HttpBody.d.ts +1 -1
  654. package/dist/unstable/http/HttpClient.d.ts +117 -15
  655. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  656. package/dist/unstable/http/HttpClient.js +191 -13
  657. package/dist/unstable/http/HttpClient.js.map +1 -1
  658. package/dist/unstable/http/HttpClientError.d.ts +7 -7
  659. package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
  660. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  661. package/dist/unstable/http/HttpClientRequest.js +131 -21
  662. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  663. package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
  664. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  665. package/dist/unstable/http/HttpClientResponse.js +6 -1
  666. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  667. package/dist/unstable/http/HttpEffect.d.ts +7 -5
  668. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  669. package/dist/unstable/http/HttpEffect.js +46 -54
  670. package/dist/unstable/http/HttpEffect.js.map +1 -1
  671. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
  672. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  673. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  674. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  675. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  676. package/dist/unstable/http/HttpMethod.js +3 -3
  677. package/dist/unstable/http/HttpMethod.js.map +1 -1
  678. package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
  679. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  680. package/dist/unstable/http/HttpMiddleware.js +24 -32
  681. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  682. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  683. package/dist/unstable/http/HttpPlatform.js +3 -2
  684. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  685. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  686. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  687. package/dist/unstable/http/HttpRouter.js +7 -7
  688. package/dist/unstable/http/HttpRouter.js.map +1 -1
  689. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  690. package/dist/unstable/http/HttpServer.js +2 -2
  691. package/dist/unstable/http/HttpServer.js.map +1 -1
  692. package/dist/unstable/http/HttpServerError.d.ts +22 -34
  693. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  694. package/dist/unstable/http/HttpServerError.js +39 -45
  695. package/dist/unstable/http/HttpServerError.js.map +1 -1
  696. package/dist/unstable/http/HttpServerRequest.d.ts +15 -3
  697. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  698. package/dist/unstable/http/HttpServerRequest.js +301 -7
  699. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  700. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  701. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  702. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  703. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  704. package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
  705. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  706. package/dist/unstable/http/HttpServerResponse.js +236 -1
  707. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  708. package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
  709. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
  710. package/dist/unstable/http/HttpStaticServer.js +353 -0
  711. package/dist/unstable/http/HttpStaticServer.js.map +1 -0
  712. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  713. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  714. package/dist/unstable/http/HttpTraceContext.js +27 -15
  715. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  716. package/dist/unstable/http/Multipart.d.ts +3 -3
  717. package/dist/unstable/http/Url.d.ts +604 -0
  718. package/dist/unstable/http/Url.d.ts.map +1 -0
  719. package/dist/unstable/http/Url.js +256 -0
  720. package/dist/unstable/http/Url.js.map +1 -0
  721. package/dist/unstable/http/UrlParams.d.ts +19 -10
  722. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  723. package/dist/unstable/http/UrlParams.js +6 -7
  724. package/dist/unstable/http/UrlParams.js.map +1 -1
  725. package/dist/unstable/http/index.d.ts +8 -0
  726. package/dist/unstable/http/index.d.ts.map +1 -1
  727. package/dist/unstable/http/index.js +8 -0
  728. package/dist/unstable/http/index.js.map +1 -1
  729. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  730. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  731. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  732. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  733. package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
  734. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  735. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  736. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
  737. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  738. package/dist/unstable/httpapi/HttpApiBuilder.js +40 -27
  739. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  740. package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
  741. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  742. package/dist/unstable/httpapi/HttpApiClient.js +78 -10
  743. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  744. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +207 -101
  745. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  746. package/dist/unstable/httpapi/HttpApiEndpoint.js +49 -43
  747. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  748. package/dist/unstable/httpapi/HttpApiError.d.ts +31 -14
  749. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  750. package/dist/unstable/httpapi/HttpApiError.js +125 -32
  751. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  752. package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
  753. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  754. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  755. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +46 -15
  756. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  757. package/dist/unstable/httpapi/HttpApiMiddleware.js +32 -3
  758. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  759. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  760. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  761. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  762. package/dist/unstable/httpapi/HttpApiSchema.d.ts +5 -0
  763. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  764. package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
  765. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  766. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
  767. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  768. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  769. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  770. package/dist/unstable/httpapi/OpenApi.js +34 -26
  771. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  772. package/dist/unstable/observability/Otlp.d.ts +12 -12
  773. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  774. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  775. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  776. package/dist/unstable/observability/OtlpExporter.js +3 -3
  777. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  778. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  779. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  780. package/dist/unstable/observability/OtlpLogger.js +7 -4
  781. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  782. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  783. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  784. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  785. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  786. package/dist/unstable/observability/OtlpTracer.js +7 -3
  787. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  788. package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
  789. package/dist/unstable/persistence/KeyValueStore.js +6 -6
  790. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  791. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  792. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  793. package/dist/unstable/persistence/Persistable.js +1 -1
  794. package/dist/unstable/persistence/Persistable.js.map +1 -1
  795. package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
  796. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  797. package/dist/unstable/persistence/PersistedCache.js +2 -1
  798. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  799. package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
  800. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  801. package/dist/unstable/persistence/PersistedQueue.js +12 -11
  802. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  803. package/dist/unstable/persistence/Persistence.d.ts +1 -1
  804. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  805. package/dist/unstable/persistence/Persistence.js +2 -2
  806. package/dist/unstable/persistence/Persistence.js.map +1 -1
  807. package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
  808. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  809. package/dist/unstable/persistence/RateLimiter.js +1 -1
  810. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  811. package/dist/unstable/process/ChildProcess.d.ts +5 -128
  812. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  813. package/dist/unstable/process/ChildProcess.js +1 -65
  814. package/dist/unstable/process/ChildProcess.js.map +1 -1
  815. package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
  816. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  817. package/dist/unstable/process/ChildProcessSpawner.js +21 -1
  818. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  819. package/dist/unstable/reactivity/Atom.d.ts +73 -12
  820. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  821. package/dist/unstable/reactivity/Atom.js +108 -25
  822. package/dist/unstable/reactivity/Atom.js.map +1 -1
  823. package/dist/unstable/reactivity/AtomHttpApi.d.ts +17 -15
  824. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  825. package/dist/unstable/reactivity/AtomHttpApi.js +45 -15
  826. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  827. package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
  828. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  829. package/dist/unstable/reactivity/AtomRegistry.js +54 -11
  830. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  831. package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
  832. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  833. package/dist/unstable/reactivity/AtomRpc.js +47 -21
  834. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  835. package/dist/unstable/reactivity/Hydration.d.ts +39 -0
  836. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
  837. package/dist/unstable/reactivity/Hydration.js +76 -0
  838. package/dist/unstable/reactivity/Hydration.js.map +1 -0
  839. package/dist/unstable/reactivity/index.d.ts +4 -0
  840. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  841. package/dist/unstable/reactivity/index.js +4 -0
  842. package/dist/unstable/reactivity/index.js.map +1 -1
  843. package/dist/unstable/rpc/Rpc.d.ts +5 -5
  844. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  845. package/dist/unstable/rpc/Rpc.js +4 -3
  846. package/dist/unstable/rpc/Rpc.js.map +1 -1
  847. package/dist/unstable/rpc/RpcClient.d.ts +5 -26
  848. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  849. package/dist/unstable/rpc/RpcClient.js +10 -17
  850. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  851. package/dist/unstable/rpc/RpcGroup.d.ts +3 -5
  852. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  853. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  854. package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
  855. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  856. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  857. package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
  858. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  859. package/dist/unstable/rpc/RpcSchema.js +17 -2
  860. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  861. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  862. package/dist/unstable/rpc/RpcSerialization.js +39 -11
  863. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  864. package/dist/unstable/rpc/RpcServer.d.ts +6 -10
  865. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  866. package/dist/unstable/rpc/RpcServer.js +20 -19
  867. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  868. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  869. package/dist/unstable/rpc/Utils.js +3 -2
  870. package/dist/unstable/rpc/Utils.js.map +1 -1
  871. package/dist/unstable/schema/Model.d.ts +22 -1
  872. package/dist/unstable/schema/Model.d.ts.map +1 -1
  873. package/dist/unstable/schema/Model.js +15 -0
  874. package/dist/unstable/schema/Model.js.map +1 -1
  875. package/dist/unstable/schema/VariantSchema.d.ts +6 -6
  876. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  877. package/dist/unstable/schema/VariantSchema.js +6 -6
  878. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  879. package/dist/unstable/socket/Socket.d.ts +6 -5
  880. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  881. package/dist/unstable/socket/Socket.js +12 -9
  882. package/dist/unstable/socket/Socket.js.map +1 -1
  883. package/dist/unstable/socket/SocketServer.d.ts +3 -3
  884. package/dist/unstable/sql/Migrator.d.ts +1 -1
  885. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  886. package/dist/unstable/sql/Migrator.js +2 -2
  887. package/dist/unstable/sql/Migrator.js.map +1 -1
  888. package/dist/unstable/sql/SqlClient.d.ts +1 -1
  889. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  890. package/dist/unstable/sql/SqlClient.js +1 -1
  891. package/dist/unstable/sql/SqlClient.js.map +1 -1
  892. package/dist/unstable/sql/SqlError.d.ts +237 -17
  893. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  894. package/dist/unstable/sql/SqlError.js +260 -4
  895. package/dist/unstable/sql/SqlError.js.map +1 -1
  896. package/dist/unstable/sql/SqlModel.d.ts +2 -2
  897. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  898. package/dist/unstable/sql/SqlModel.js +3 -3
  899. package/dist/unstable/sql/SqlModel.js.map +1 -1
  900. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  901. package/dist/unstable/sql/SqlResolver.js +17 -8
  902. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  903. package/dist/unstable/sql/SqlSchema.d.ts +17 -6
  904. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  905. package/dist/unstable/sql/SqlSchema.js +17 -7
  906. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  907. package/dist/unstable/sql/Statement.js +0 -1
  908. package/dist/unstable/sql/Statement.js.map +1 -1
  909. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  910. package/dist/unstable/workers/Worker.js +2 -1
  911. package/dist/unstable/workers/Worker.js.map +1 -1
  912. package/dist/unstable/workflow/DurableClock.d.ts +3 -3
  913. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  914. package/dist/unstable/workflow/DurableClock.js +3 -3
  915. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  916. package/dist/unstable/workflow/DurableDeferred.js +8 -8
  917. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  918. package/dist/unstable/workflow/Workflow.d.ts +5 -4
  919. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  920. package/dist/unstable/workflow/Workflow.js +1 -1
  921. package/dist/unstable/workflow/Workflow.js.map +1 -1
  922. package/dist/unstable/workflow/WorkflowEngine.d.ts +17 -5
  923. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  924. package/dist/unstable/workflow/WorkflowEngine.js +153 -12
  925. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  926. package/package.json +2 -2
  927. package/src/Array.ts +304 -447
  928. package/src/BigDecimal.ts +63 -66
  929. package/src/BigInt.ts +49 -41
  930. package/src/Brand.ts +1 -1
  931. package/src/Cache.ts +9 -8
  932. package/src/Cause.ts +37 -2
  933. package/src/Channel.ts +582 -154
  934. package/src/Chunk.ts +149 -331
  935. package/src/Combiner.ts +280 -13
  936. package/src/Config.ts +195 -25
  937. package/src/Cron.ts +155 -63
  938. package/src/Data.ts +539 -376
  939. package/src/DateTime.ts +75 -256
  940. package/src/Deferred.ts +8 -6
  941. package/src/Duration.ts +122 -66
  942. package/src/Effect.ts +1483 -1157
  943. package/src/Encoding.ts +879 -0
  944. package/src/Equal.ts +278 -111
  945. package/src/Equivalence.ts +114 -52
  946. package/src/ErrorReporter.ts +458 -0
  947. package/src/Exit.ts +24 -12
  948. package/src/Fiber.ts +12 -3
  949. package/src/FiberHandle.ts +10 -9
  950. package/src/FiberMap.ts +22 -22
  951. package/src/FileSystem.ts +34 -31
  952. package/src/Filter.ts +52 -63
  953. package/src/Formatter.ts +253 -51
  954. package/src/Function.ts +2 -10
  955. package/src/Graph.ts +131 -117
  956. package/src/HashMap.ts +26 -19
  957. package/src/Iterable.ts +117 -63
  958. package/src/JsonSchema.ts +383 -10
  959. package/src/Latch.ts +194 -0
  960. package/src/Layer.ts +393 -159
  961. package/src/LayerMap.ts +11 -9
  962. package/src/LogLevel.ts +37 -0
  963. package/src/Logger.ts +33 -100
  964. package/src/ManagedRuntime.ts +2 -2
  965. package/src/Metric.ts +6 -8
  966. package/src/MutableHashMap.ts +9 -0
  967. package/src/MutableHashSet.ts +9 -0
  968. package/src/Newtype.ts +308 -0
  969. package/src/Number.ts +85 -26
  970. package/src/Optic.ts +948 -19
  971. package/src/Option.ts +34 -24
  972. package/src/Order.ts +39 -32
  973. package/src/PartitionedSemaphore.ts +288 -56
  974. package/src/Pipeable.ts +32 -1
  975. package/src/PlatformError.ts +5 -5
  976. package/src/Pool.ts +13 -11
  977. package/src/PubSub.ts +30 -20
  978. package/src/Pull.ts +1 -1
  979. package/src/Queue.ts +11 -9
  980. package/src/Random.ts +51 -14
  981. package/src/RcMap.ts +5 -5
  982. package/src/RcRef.ts +1 -1
  983. package/src/Record.ts +94 -199
  984. package/src/Reducer.ts +166 -7
  985. package/src/References.ts +283 -287
  986. package/src/Request.ts +3 -2
  987. package/src/RequestResolver.ts +29 -49
  988. package/src/Resource.ts +2 -1
  989. package/src/Result.ts +2 -4
  990. package/src/Runtime.ts +102 -6
  991. package/src/Schedule.ts +458 -449
  992. package/src/Scheduler.ts +49 -126
  993. package/src/Schema.ts +3298 -392
  994. package/src/SchemaAST.ts +172 -33
  995. package/src/SchemaGetter.ts +19 -21
  996. package/src/SchemaParser.ts +92 -27
  997. package/src/SchemaRepresentation.ts +51 -26
  998. package/src/SchemaTransformation.ts +198 -13
  999. package/src/ScopedCache.ts +3 -3
  1000. package/src/Semaphore.ts +444 -0
  1001. package/src/ServiceMap.ts +133 -71
  1002. package/src/Sink.ts +83 -28
  1003. package/src/Stdio.ts +27 -4
  1004. package/src/Stream.ts +687 -617
  1005. package/src/String.ts +122 -69
  1006. package/src/Struct.ts +33 -7
  1007. package/src/SubscriptionRef.ts +101 -120
  1008. package/src/SynchronizedRef.ts +3 -2
  1009. package/src/Terminal.ts +2 -1
  1010. package/src/Tracer.ts +6 -5
  1011. package/src/Trie.ts +44 -31
  1012. package/src/TxChunk.ts +72 -53
  1013. package/src/TxDeferred.ts +394 -0
  1014. package/src/TxHashMap.ts +409 -343
  1015. package/src/TxHashSet.ts +113 -118
  1016. package/src/TxPriorityQueue.ts +766 -0
  1017. package/src/TxPubSub.ts +789 -0
  1018. package/src/TxQueue.ts +241 -251
  1019. package/src/TxReentrantLock.ts +753 -0
  1020. package/src/TxRef.ts +50 -38
  1021. package/src/TxSemaphore.ts +217 -44
  1022. package/src/TxSubscriptionRef.ts +639 -0
  1023. package/src/Types.ts +73 -19
  1024. package/src/Utils.ts +137 -111
  1025. package/src/index.ts +814 -54
  1026. package/src/internal/core.ts +12 -5
  1027. package/src/internal/dateTime.ts +91 -96
  1028. package/src/internal/effect.ts +841 -432
  1029. package/src/internal/hashMap.ts +12 -10
  1030. package/src/internal/option.ts +7 -0
  1031. package/src/internal/random.ts +20 -0
  1032. package/src/internal/rcRef.ts +4 -3
  1033. package/src/internal/references.ts +72 -0
  1034. package/src/internal/request.ts +2 -2
  1035. package/src/internal/schema/annotations.ts +2 -0
  1036. package/src/internal/schema/representation.ts +45 -94
  1037. package/src/internal/schema/schema.ts +1 -0
  1038. package/src/internal/schema/to-codec.ts +7 -17
  1039. package/src/internal/trie.ts +21 -15
  1040. package/src/testing/TestClock.ts +13 -11
  1041. package/src/testing/TestSchema.ts +332 -35
  1042. package/src/testing/index.ts +64 -1
  1043. package/src/unstable/ai/AiError.ts +111 -54
  1044. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  1045. package/src/unstable/ai/Chat.ts +62 -74
  1046. package/src/unstable/ai/EmbeddingModel.ts +209 -0
  1047. package/src/unstable/ai/LanguageModel.ts +544 -230
  1048. package/src/unstable/ai/McpSchema.ts +73 -13
  1049. package/src/unstable/ai/McpServer.ts +271 -61
  1050. package/src/unstable/ai/Model.ts +40 -9
  1051. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  1052. package/src/unstable/ai/Prompt.ts +37 -37
  1053. package/src/unstable/ai/Response.ts +25 -25
  1054. package/src/unstable/ai/ResponseIdTracker.ts +97 -0
  1055. package/src/unstable/ai/Tool.ts +42 -16
  1056. package/src/unstable/ai/Toolkit.ts +5 -14
  1057. package/src/unstable/ai/index.ts +24 -1
  1058. package/src/unstable/ai/internal/codec-transformer.ts +0 -7
  1059. package/src/unstable/cli/Argument.ts +2 -4
  1060. package/src/unstable/cli/CliError.ts +47 -59
  1061. package/src/unstable/cli/CliOutput.ts +85 -13
  1062. package/src/unstable/cli/Command.ts +801 -192
  1063. package/src/unstable/cli/Completions.ts +36 -0
  1064. package/src/unstable/cli/Flag.ts +2 -2
  1065. package/src/unstable/cli/GlobalFlag.ts +242 -0
  1066. package/src/unstable/cli/HelpDoc.ts +91 -11
  1067. package/src/unstable/cli/Param.ts +15 -11
  1068. package/src/unstable/cli/Primitive.ts +2 -2
  1069. package/src/unstable/cli/Prompt.ts +262 -100
  1070. package/src/unstable/cli/index.ts +10 -0
  1071. package/src/unstable/cli/internal/command.ts +109 -63
  1072. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +10 -4
  1073. package/src/unstable/cli/internal/config.ts +49 -0
  1074. package/src/unstable/cli/internal/help.ts +171 -0
  1075. package/src/unstable/cli/internal/parser.ts +71 -63
  1076. package/src/unstable/cluster/ClusterCron.ts +2 -2
  1077. package/src/unstable/cluster/ClusterWorkflowEngine.ts +40 -34
  1078. package/src/unstable/cluster/DeliverAt.ts +1 -1
  1079. package/src/unstable/cluster/Entity.ts +24 -22
  1080. package/src/unstable/cluster/EntityAddress.ts +1 -1
  1081. package/src/unstable/cluster/EntityResource.ts +4 -4
  1082. package/src/unstable/cluster/Envelope.ts +1 -1
  1083. package/src/unstable/cluster/K8sHttpClient.ts +5 -5
  1084. package/src/unstable/cluster/Message.ts +6 -5
  1085. package/src/unstable/cluster/MessageStorage.ts +29 -30
  1086. package/src/unstable/cluster/Reply.ts +7 -4
  1087. package/src/unstable/cluster/Runner.ts +1 -1
  1088. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  1089. package/src/unstable/cluster/RunnerServer.ts +10 -13
  1090. package/src/unstable/cluster/Runners.ts +14 -12
  1091. package/src/unstable/cluster/ShardId.ts +2 -2
  1092. package/src/unstable/cluster/Sharding.ts +36 -27
  1093. package/src/unstable/cluster/ShardingConfig.ts +36 -37
  1094. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  1095. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  1096. package/src/unstable/cluster/internal/entityManager.ts +36 -29
  1097. package/src/unstable/cluster/internal/entityReaper.ts +2 -1
  1098. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  1099. package/src/unstable/devtools/DevToolsClient.ts +23 -18
  1100. package/src/unstable/devtools/DevToolsSchema.ts +16 -3
  1101. package/src/unstable/encoding/Ndjson.ts +17 -17
  1102. package/src/unstable/encoding/Sse.ts +3 -5
  1103. package/src/unstable/eventlog/EventJournal.ts +2 -2
  1104. package/src/unstable/eventlog/EventLog.ts +3 -2
  1105. package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
  1106. package/src/unstable/http/Cookies.ts +94 -11
  1107. package/src/unstable/http/Etag.ts +5 -3
  1108. package/src/unstable/http/Headers.ts +68 -18
  1109. package/src/unstable/http/HttpClient.ts +376 -34
  1110. package/src/unstable/http/HttpClientRequest.ts +151 -39
  1111. package/src/unstable/http/HttpClientResponse.ts +12 -6
  1112. package/src/unstable/http/HttpEffect.ts +54 -68
  1113. package/src/unstable/http/HttpIncomingMessage.ts +3 -2
  1114. package/src/unstable/http/HttpMethod.ts +16 -4
  1115. package/src/unstable/http/HttpMiddleware.ts +25 -39
  1116. package/src/unstable/http/HttpPlatform.ts +3 -2
  1117. package/src/unstable/http/HttpRouter.ts +9 -9
  1118. package/src/unstable/http/HttpServer.ts +3 -9
  1119. package/src/unstable/http/HttpServerError.ts +45 -47
  1120. package/src/unstable/http/HttpServerRequest.ts +407 -16
  1121. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  1122. package/src/unstable/http/HttpServerResponse.ts +345 -7
  1123. package/src/unstable/http/HttpStaticServer.ts +456 -0
  1124. package/src/unstable/http/HttpTraceContext.ts +31 -17
  1125. package/src/unstable/http/Multipart.ts +2 -2
  1126. package/src/unstable/http/Url.ts +650 -0
  1127. package/src/unstable/http/UrlParams.ts +31 -19
  1128. package/src/unstable/http/index.ts +10 -0
  1129. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  1130. package/src/unstable/httpapi/HttpApi.ts +6 -6
  1131. package/src/unstable/httpapi/HttpApiBuilder.ts +106 -41
  1132. package/src/unstable/httpapi/HttpApiClient.ts +180 -28
  1133. package/src/unstable/httpapi/HttpApiEndpoint.ts +216 -104
  1134. package/src/unstable/httpapi/HttpApiError.ts +108 -30
  1135. package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
  1136. package/src/unstable/httpapi/HttpApiMiddleware.ts +83 -22
  1137. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  1138. package/src/unstable/httpapi/HttpApiSchema.ts +20 -2
  1139. package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
  1140. package/src/unstable/httpapi/OpenApi.ts +43 -29
  1141. package/src/unstable/observability/Otlp.ts +12 -12
  1142. package/src/unstable/observability/OtlpExporter.ts +8 -5
  1143. package/src/unstable/observability/OtlpLogger.ts +13 -9
  1144. package/src/unstable/observability/OtlpMetrics.ts +4 -4
  1145. package/src/unstable/observability/OtlpTracer.ts +12 -8
  1146. package/src/unstable/persistence/KeyValueStore.ts +6 -6
  1147. package/src/unstable/persistence/Persistable.ts +3 -3
  1148. package/src/unstable/persistence/PersistedCache.ts +20 -9
  1149. package/src/unstable/persistence/PersistedQueue.ts +25 -24
  1150. package/src/unstable/persistence/Persistence.ts +3 -3
  1151. package/src/unstable/persistence/RateLimiter.ts +4 -4
  1152. package/src/unstable/process/ChildProcess.ts +6 -208
  1153. package/src/unstable/process/ChildProcessSpawner.ts +75 -14
  1154. package/src/unstable/reactivity/Atom.ts +212 -54
  1155. package/src/unstable/reactivity/AtomHttpApi.ts +81 -41
  1156. package/src/unstable/reactivity/AtomRegistry.ts +66 -12
  1157. package/src/unstable/reactivity/AtomRpc.ts +51 -20
  1158. package/src/unstable/reactivity/Hydration.ts +112 -0
  1159. package/src/unstable/reactivity/index.ts +5 -0
  1160. package/src/unstable/rpc/Rpc.ts +11 -12
  1161. package/src/unstable/rpc/RpcClient.ts +22 -63
  1162. package/src/unstable/rpc/RpcGroup.ts +7 -7
  1163. package/src/unstable/rpc/RpcMiddleware.ts +15 -9
  1164. package/src/unstable/rpc/RpcSchema.ts +23 -5
  1165. package/src/unstable/rpc/RpcSerialization.ts +49 -11
  1166. package/src/unstable/rpc/RpcServer.ts +31 -35
  1167. package/src/unstable/rpc/Utils.ts +3 -2
  1168. package/src/unstable/schema/Model.ts +31 -0
  1169. package/src/unstable/schema/VariantSchema.ts +10 -10
  1170. package/src/unstable/socket/Socket.ts +31 -27
  1171. package/src/unstable/sql/Migrator.ts +7 -5
  1172. package/src/unstable/sql/SqlClient.ts +6 -4
  1173. package/src/unstable/sql/SqlError.ts +365 -11
  1174. package/src/unstable/sql/SqlModel.ts +5 -5
  1175. package/src/unstable/sql/SqlResolver.ts +17 -7
  1176. package/src/unstable/sql/SqlSchema.ts +42 -26
  1177. package/src/unstable/sql/Statement.ts +0 -1
  1178. package/src/unstable/workers/Worker.ts +2 -1
  1179. package/src/unstable/workflow/DurableClock.ts +8 -8
  1180. package/src/unstable/workflow/DurableDeferred.ts +8 -8
  1181. package/src/unstable/workflow/Workflow.ts +7 -3
  1182. package/src/unstable/workflow/WorkflowEngine.ts +211 -19
  1183. package/dist/NullOr.d.ts +0 -149
  1184. package/dist/NullOr.d.ts.map +0 -1
  1185. package/dist/NullOr.js +0 -152
  1186. package/dist/NullOr.js.map +0 -1
  1187. package/dist/encoding/Base64.d.ts +0 -67
  1188. package/dist/encoding/Base64.d.ts.map +0 -1
  1189. package/dist/encoding/Base64.js +0 -146
  1190. package/dist/encoding/Base64.js.map +0 -1
  1191. package/dist/encoding/Base64Url.d.ts +0 -60
  1192. package/dist/encoding/Base64Url.d.ts.map +0 -1
  1193. package/dist/encoding/Base64Url.js +0 -89
  1194. package/dist/encoding/Base64Url.js.map +0 -1
  1195. package/dist/encoding/EncodingError.d.ts +0 -31
  1196. package/dist/encoding/EncodingError.d.ts.map +0 -1
  1197. package/dist/encoding/EncodingError.js +0 -22
  1198. package/dist/encoding/EncodingError.js.map +0 -1
  1199. package/dist/encoding/Hex.d.ts +0 -61
  1200. package/dist/encoding/Hex.d.ts.map +0 -1
  1201. package/dist/encoding/Hex.js +0 -115
  1202. package/dist/encoding/Hex.js.map +0 -1
  1203. package/dist/encoding/index.d.ts +0 -26
  1204. package/dist/encoding/index.d.ts.map +0 -1
  1205. package/dist/encoding/index.js +0 -27
  1206. package/dist/encoding/index.js.map +0 -1
  1207. package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
  1208. package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
  1209. package/dist/unstable/cli/internal/builtInFlags.js +0 -44
  1210. package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
  1211. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  1212. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  1213. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  1214. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  1215. package/src/NullOr.ts +0 -204
  1216. package/src/encoding/Base64.ts +0 -366
  1217. package/src/encoding/Base64Url.ts +0 -104
  1218. package/src/encoding/EncodingError.ts +0 -35
  1219. package/src/encoding/Hex.ts +0 -390
  1220. package/src/encoding/index.ts +0 -31
  1221. package/src/unstable/cli/internal/builtInFlags.ts +0 -78
  1222. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
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,14 +48,26 @@ 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
54
57
  } from "./Types.ts"
55
58
  import type * as Unify from "./Unify.ts"
56
59
 
57
- const TypeId = "~effect/Stream"
60
+ /**
61
+ * @since 4.0.0
62
+ * @category Type Identifiers
63
+ */
64
+ export type TypeId = "~effect/Stream"
65
+
66
+ /**
67
+ * @since 4.0.0
68
+ * @category Type Identifiers
69
+ */
70
+ export const TypeId: TypeId = "~effect/Stream"
58
71
 
59
72
  /**
60
73
  * A `Stream<A, E, R>` describes a program that can emit many `A` values, fail
@@ -129,7 +142,7 @@ export interface StreamUnify<A extends { [Unify.typeSymbol]?: any }> extends Eff
129
142
  * @category Models
130
143
  * @since 2.0.0
131
144
  */
132
- export interface StreamUnifyIgnore extends Effect.EffectUnifyIgnore {
145
+ export interface StreamUnifyIgnore {
133
146
  Effect?: true
134
147
  }
135
148
 
@@ -471,7 +484,7 @@ export const fromEffectSchedule = <A, E, R, X, AS extends A, ES, RS>(
471
484
  * @since 2.0.0
472
485
  * @category Constructors
473
486
  */
474
- export const tick = (interval: Duration.DurationInput): Stream<void> =>
487
+ export const tick = (interval: Duration.Input): Stream<void> =>
475
488
  fromPull(Effect.sync(() => {
476
489
  let first = true
477
490
  const effect = Effect.succeed(Arr.of<void>(undefined))
@@ -960,6 +973,10 @@ export const fromIteratorSucceed = <A>(iterator: IterableIterator<A>, maxChunkSi
960
973
  /**
961
974
  * Creates a new `Stream` from an iterable collection of values.
962
975
  *
976
+ * **Options**
977
+ *
978
+ * - `chunkSize`: Maximum number of values emitted per chunk.
979
+ *
963
980
  * @example
964
981
  * ```ts
965
982
  * import { Console, Effect, Stream } from "effect"
@@ -979,10 +996,15 @@ export const fromIteratorSucceed = <A>(iterator: IterableIterator<A>, maxChunkSi
979
996
  * @since 2.0.0
980
997
  * @category Constructors
981
998
  */
982
- export const fromIterable = <A>(iterable: Iterable<A>): Stream<A> =>
983
- Array.isArray(iterable)
999
+ export const fromIterable = <A>(
1000
+ iterable: Iterable<A>,
1001
+ options?: {
1002
+ readonly chunkSize?: number | undefined
1003
+ }
1004
+ ): Stream<A> =>
1005
+ Array.isArray(iterable) && options?.chunkSize === undefined
984
1006
  ? fromArray(iterable)
985
- : fromChannel(Channel.fromIterableArray(iterable))
1007
+ : fromChannel(Channel.fromIterableArray(iterable, options?.chunkSize))
986
1008
 
987
1009
  /**
988
1010
  * Creates a stream from an effect producing an iterable of values.
@@ -1242,7 +1264,9 @@ export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): St
1242
1264
  *
1243
1265
  * @example
1244
1266
  * ```ts
1245
- * import { Console, Effect, Stream } from "effect"
1267
+ * import { Console, Data, Effect, Stream } from "effect"
1268
+ *
1269
+ * class StreamError extends Data.TaggedError("StreamError")<{ readonly cause: unknown }> {}
1246
1270
  *
1247
1271
  * const readableStream = new ReadableStream({
1248
1272
  * start(controller) {
@@ -1256,7 +1280,7 @@ export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): St
1256
1280
  * const program = Effect.gen(function*() {
1257
1281
  * const stream = Stream.fromReadableStream({
1258
1282
  * evaluate: () => readableStream,
1259
- * onError: (error) => new Error(String(error))
1283
+ * onError: (cause) => new StreamError({ cause })
1260
1284
  * })
1261
1285
  * const values = yield* Stream.runCollect(stream)
1262
1286
  * yield* Console.log(values)
@@ -1298,7 +1322,9 @@ export const fromReadableStream = <A, E>(
1298
1322
  *
1299
1323
  * @example
1300
1324
  * ```ts
1301
- * import { Console, Effect, Stream } from "effect"
1325
+ * import { Console, Data, Effect, Stream } from "effect"
1326
+ *
1327
+ * class StreamError extends Data.TaggedError("StreamError")<{ readonly cause: unknown }> {}
1302
1328
  *
1303
1329
  * const iterable = (async function*() {
1304
1330
  * yield 1
@@ -1307,7 +1333,7 @@ export const fromReadableStream = <A, E>(
1307
1333
  * })()
1308
1334
  *
1309
1335
  * const program = Effect.gen(function*() {
1310
- * const stream = Stream.fromAsyncIterable(iterable, (error) => new Error(String(error)))
1336
+ * const stream = Stream.fromAsyncIterable(iterable, (cause) => new StreamError({ cause }))
1311
1337
  * const values = yield* Stream.runCollect(stream)
1312
1338
  * yield* Console.log(values)
1313
1339
  * })
@@ -1334,7 +1360,7 @@ export const fromAsyncIterable = <A, E>(
1334
1360
  *
1335
1361
  * const program = Effect.gen(function*() {
1336
1362
  * const schedule = Schedule.spaced("50 millis").pipe(
1337
- * Schedule.compose(Schedule.recurs(2))
1363
+ * Schedule.both(Schedule.recurs(2))
1338
1364
  * )
1339
1365
  * const stream = Stream.fromSchedule(schedule)
1340
1366
  * const values = yield* Stream.runCollect(stream)
@@ -2648,8 +2674,8 @@ export const tapSink: {
2648
2674
  transformPullBracket(
2649
2675
  self,
2650
2676
  Effect.fnUntraced(function*(pull, _, scope) {
2651
- const upstreamLatch = Effect.makeLatchUnsafe()
2652
- const sinkLatch = Effect.makeLatchUnsafe()
2677
+ const upstreamLatch = Latch.makeUnsafe()
2678
+ const sinkLatch = Latch.makeUnsafe()
2653
2679
  let chunk: Arr.NonEmptyReadonlyArray<A> | undefined = undefined
2654
2680
  let causeSink: Cause.Cause<E2> | undefined = undefined
2655
2681
  let sinkDone = false
@@ -3316,7 +3342,7 @@ export const timeout: {
3316
3342
  * @since 2.0.0
3317
3343
  * @category Rate Limiting
3318
3344
  */
3319
- (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
3345
+ (duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
3320
3346
  /**
3321
3347
  * Ends the stream if it does not produce a value within the specified duration.
3322
3348
  *
@@ -3340,15 +3366,97 @@ export const timeout: {
3340
3366
  * @since 2.0.0
3341
3367
  * @category Rate Limiting
3342
3368
  */
3343
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R>
3369
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
3344
3370
  } = dual(
3345
3371
  2,
3346
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> =>
3347
- transformPull(self, (pull, _scope) =>
3348
- Effect.succeed(Effect.timeoutOrElse(pull, {
3349
- duration,
3350
- onTimeout: () => Cause.done()
3351
- })))
3372
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
3373
+ timeoutOrElse(self, {
3374
+ duration,
3375
+ orElse: () => empty
3376
+ })
3377
+ )
3378
+
3379
+ /**
3380
+ * @since 2.0.0
3381
+ * @category Rate Limiting
3382
+ */
3383
+ export const timeoutOrElse: {
3384
+ /**
3385
+ * @since 2.0.0
3386
+ * @category Rate Limiting
3387
+ */
3388
+ <B, E2, R2>(
3389
+ options: {
3390
+ readonly duration: Duration.Input
3391
+ readonly orElse: () => Stream<B, E2, R2>
3392
+ }
3393
+ ): <A, E, R>(self: Stream<A, E, R>) => Stream<A | B, E | E2, R | R2>
3394
+ /**
3395
+ * @since 2.0.0
3396
+ * @category Rate Limiting
3397
+ */
3398
+ <A, E, R, B, E2, R2>(
3399
+ self: Stream<A, E, R>,
3400
+ options: {
3401
+ readonly duration: Duration.Input
3402
+ readonly orElse: () => Stream<B, E2, R2>
3403
+ }
3404
+ ): Stream<A | B, E | E2, R | R2>
3405
+ } = dual(
3406
+ 2,
3407
+ <A, E, R, B, E2, R2>(
3408
+ self: Stream<A, E, R>,
3409
+ options: {
3410
+ readonly duration: Duration.Input
3411
+ readonly orElse: () => Stream<B, E2, R2>
3412
+ }
3413
+ ): Stream<A | B, E | E2, R | R2> => {
3414
+ const duration = Duration.fromInputUnsafe(options.duration)
3415
+ if (!Duration.isFinite(duration)) return self
3416
+ if (Duration.isZero(duration)) return suspend(options.orElse)
3417
+ const timeoutSymbol = Symbol()
3418
+ return catchCause(
3419
+ suspend(() => {
3420
+ const parent = Fiber.getCurrent()!
3421
+ const clock = parent.getRef(Clock)
3422
+ const durationMs = Duration.toMillis(duration)
3423
+ let deadline: number | undefined = undefined
3424
+ const latch = Latch.makeUnsafe(false)
3425
+ return merge(
3426
+ transformPull(self, (pull, _scope) =>
3427
+ Effect.suspend(() => {
3428
+ deadline = clock.currentTimeMillisUnsafe() + durationMs
3429
+ latch.openUnsafe()
3430
+ return pull
3431
+ }).pipe(
3432
+ Effect.map((arr) => {
3433
+ latch.closeUnsafe()
3434
+ deadline = undefined
3435
+ return arr
3436
+ }),
3437
+ Effect.succeed
3438
+ )),
3439
+ fromEffectDrain(Effect.gen(function*() {
3440
+ while (true) {
3441
+ yield* latch.await
3442
+ if (deadline === undefined) continue
3443
+ yield* Effect.sleep(deadline - clock.currentTimeMillisUnsafe())
3444
+ if (deadline === undefined) continue
3445
+ const remaining = deadline - clock.currentTimeMillisUnsafe()
3446
+ if (remaining > 0) continue
3447
+ return yield* Effect.die(timeoutSymbol)
3448
+ }
3449
+ })),
3450
+ { haltStrategy: "left" }
3451
+ )
3452
+ }),
3453
+ (cause): Stream<B, E | E2, R2> => {
3454
+ const isTimeout = cause.reasons.find((r) => r._tag === "Die" && r.defect === timeoutSymbol)
3455
+ if (isTimeout) return options.orElse()
3456
+ return failCause(cause as Cause.Cause<E>)
3457
+ }
3458
+ )
3459
+ }
3352
3460
  )
3353
3461
 
3354
3462
  /**
@@ -3801,7 +3909,7 @@ export const merge: {
3801
3909
  } | undefined
3802
3910
  ): Stream<A | A2, E | E2, R | R2>
3803
3911
  } = dual(
3804
- 2,
3912
+ (args) => isStream(args[0]) && isStream(args[1]),
3805
3913
  <A, E, R, A2, E2, R2>(
3806
3914
  self: Stream<A, E, R>,
3807
3915
  that: Stream<A2, E2, R2>,
@@ -5341,7 +5449,7 @@ export const zipLatestAll = <T extends ReadonlyArray<Stream<any, any, any>>>(
5341
5449
  fromChannel(Channel.suspend(() => {
5342
5450
  const latest: Array<any> = []
5343
5451
  const emitted = new Set<number>()
5344
- const readyLatch = Effect.makeLatchUnsafe()
5452
+ const readyLatch = Latch.makeUnsafe()
5345
5453
  return Channel.mergeAll(
5346
5454
  Channel.fromArray(
5347
5455
  streams.map((s, i) =>
@@ -5763,7 +5871,7 @@ export const filter: {
5763
5871
  * @since 2.0.0
5764
5872
  * @category Filtering
5765
5873
  */
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>
5874
+ <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
5767
5875
  /**
5768
5876
  * Filters a stream to the elements that satisfy a predicate.
5769
5877
  *
@@ -5809,27 +5917,52 @@ export const filter: {
5809
5917
  * @since 2.0.0
5810
5918
  * @category Filtering
5811
5919
  */
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>
5920
+ <A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R>
5813
5921
  } = dual(
5814
5922
  2,
5815
- <A, E, R, Result extends Filter.ResultOrBool>(
5923
+ <A, E, R>(
5816
5924
  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))
5925
+ predicate: Predicate<A>
5926
+ ): Stream<A, E, R> => fromChannel(Channel.filterArray(toChannel(self), predicate))
5819
5927
  )
5820
5928
 
5821
5929
  /**
5822
- * Effectfully filters and maps elements in a single pass.
5930
+ * Filters and maps stream elements in one pass using a `Filter`.
5931
+ *
5932
+ * @since 4.0.0
5933
+ * @category Filtering
5934
+ */
5935
+ export const filterMap: {
5936
+ /**
5937
+ * Filters and maps stream elements in one pass using a `Filter`.
5938
+ *
5939
+ * @since 4.0.0
5940
+ * @category Filtering
5941
+ */
5942
+ <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
5943
+ /**
5944
+ * Filters and maps stream elements in one pass using a `Filter`.
5945
+ *
5946
+ * @since 4.0.0
5947
+ * @category Filtering
5948
+ */
5949
+ <A, E, R, B, X>(self: Stream<A, E, R>, filter: Filter.Filter<A, B, X>): Stream<B, E, R>
5950
+ } = dual(
5951
+ 2,
5952
+ <A, E, R, B, X>(
5953
+ self: Stream<A, E, R>,
5954
+ filter: Filter.Filter<A, B, X>
5955
+ ): Stream<B, E, R> => fromChannel(Channel.filterMapArray(toChannel(self), filter))
5956
+ )
5957
+
5958
+ /**
5959
+ * Effectfully filters elements in a single pass.
5823
5960
  *
5824
5961
  * @example
5825
5962
  * ```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
- * )
5963
+ * import { Console, Effect, Stream } from "effect"
5831
5964
  *
5832
- * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(filter))
5965
+ * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
5833
5966
  *
5834
5967
  * const program = Effect.gen(function*() {
5835
5968
  * const result = yield* Stream.runCollect(stream)
@@ -5837,7 +5970,7 @@ export const filter: {
5837
5970
  * })
5838
5971
  *
5839
5972
  * Effect.runPromise(program)
5840
- * // Output: [ 4, 5 ]
5973
+ * // Output: [ 3, 4 ]
5841
5974
  * ```
5842
5975
  *
5843
5976
  * @since 2.0.0
@@ -5845,17 +5978,13 @@ export const filter: {
5845
5978
  */
5846
5979
  export const filterEffect: {
5847
5980
  /**
5848
- * Effectfully filters and maps elements in a single pass.
5981
+ * Effectfully filters elements in a single pass.
5849
5982
  *
5850
5983
  * @example
5851
5984
  * ```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
- * )
5985
+ * import { Console, Effect, Stream } from "effect"
5857
5986
  *
5858
- * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(filter))
5987
+ * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
5859
5988
  *
5860
5989
  * const program = Effect.gen(function*() {
5861
5990
  * const result = yield* Stream.runCollect(stream)
@@ -5863,25 +5992,21 @@ export const filterEffect: {
5863
5992
  * })
5864
5993
  *
5865
5994
  * Effect.runPromise(program)
5866
- * // Output: [ 4, 5 ]
5995
+ * // Output: [ 3, 4 ]
5867
5996
  * ```
5868
5997
  *
5869
5998
  * @since 2.0.0
5870
5999
  * @category Filtering
5871
6000
  */
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>
6001
+ <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
6002
  /**
5874
- * Effectfully filters and maps elements in a single pass.
6003
+ * Effectfully filters elements in a single pass.
5875
6004
  *
5876
6005
  * @example
5877
6006
  * ```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
- * )
6007
+ * import { Console, Effect, Stream } from "effect"
5883
6008
  *
5884
- * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(filter))
6009
+ * const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
5885
6010
  *
5886
6011
  * const program = Effect.gen(function*() {
5887
6012
  * const result = yield* Stream.runCollect(stream)
@@ -5889,35 +6014,65 @@ export const filterEffect: {
5889
6014
  * })
5890
6015
  *
5891
6016
  * Effect.runPromise(program)
5892
- * // Output: [ 4, 5 ]
6017
+ * // Output: [ 3, 4 ]
5893
6018
  * ```
5894
6019
  *
5895
6020
  * @since 2.0.0
5896
6021
  * @category Filtering
5897
6022
  */
6023
+ <A, E, R, EX, RX>(
6024
+ self: Stream<A, E, R>,
6025
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>
6026
+ ): Stream<A, E | EX, R | RX>
6027
+ } = dual(
6028
+ 2,
6029
+ <A, E, R, EX, RX>(
6030
+ self: Stream<A, E, R>,
6031
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>
6032
+ ): Stream<A, E | EX, R | RX> => fromChannel(Channel.filterArrayEffect(toChannel(self), predicate))
6033
+ )
6034
+
6035
+ /**
6036
+ * Effectfully filters and maps elements in a single pass.
6037
+ *
6038
+ * @since 4.0.0
6039
+ * @category Filtering
6040
+ */
6041
+ export const filterMapEffect: {
6042
+ /**
6043
+ * Effectfully filters and maps elements in a single pass.
6044
+ *
6045
+ * @since 4.0.0
6046
+ * @category Filtering
6047
+ */
6048
+ <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>
6049
+ /**
6050
+ * Effectfully filters and maps elements in a single pass.
6051
+ *
6052
+ * @since 4.0.0
6053
+ * @category Filtering
6054
+ */
5898
6055
  <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
6056
  } = dual(
5900
6057
  2,
5901
6058
  <A, E, R, B, X, EX, RX>(
5902
6059
  self: Stream<A, E, R>,
5903
6060
  filter: Filter.FilterEffect<A, B, X, EX, RX>
5904
- ): Stream<B, E | EX, R | RX> => fromChannel(Channel.filterArrayEffect(toChannel(self), filter))
6061
+ ): Stream<B, E | EX, R | RX> => fromChannel(Channel.filterMapArrayEffect(toChannel(self), filter))
5905
6062
  )
5906
6063
 
5907
6064
  /**
5908
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6065
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
5909
6066
  *
5910
6067
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
5911
6068
  *
5912
6069
  * @example
5913
6070
  * ```ts
5914
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6071
+ * import { Console, Effect, Result, Stream } from "effect"
5915
6072
  *
5916
6073
  * const program = Effect.gen(function*() {
5917
6074
  * 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
- * )
6075
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
5921
6076
  * )
5922
6077
  *
5923
6078
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -5937,63 +6092,17 @@ export const filterEffect: {
5937
6092
  */
5938
6093
  export const partitionQueue: {
5939
6094
  /**
5940
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6095
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
5941
6096
  *
5942
6097
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
5943
6098
  *
5944
6099
  * @example
5945
6100
  * ```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.
5985
- *
5986
- * Each queue fails with the stream error or `Cause.Done` when the source ends.
5987
- *
5988
- * @example
5989
- * ```ts
5990
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6101
+ * import { Console, Effect, Result, Stream } from "effect"
5991
6102
  *
5992
6103
  * const program = Effect.gen(function*() {
5993
6104
  * 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
- * )
6105
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
5997
6106
  * )
5998
6107
  *
5999
6108
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6011,78 +6120,31 @@ export const partitionQueue: {
6011
6120
  * @since 4.0.0
6012
6121
  * @category Filtering
6013
6122
  */
6014
- <A, Result extends Filter.ResultOrBool>(
6015
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6123
+ <A, Pass, Fail>(
6124
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6016
6125
  options?: {
6017
6126
  readonly capacity?: number | "unbounded" | undefined
6018
6127
  }
6019
6128
  ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<
6020
6129
  [
6021
- passes: Queue.Dequeue<Filter.Pass<A, Result>, E | Cause.Done>,
6022
- fails: Queue.Dequeue<Filter.Fail<A, Result>, E | Cause.Done>
6130
+ passes: Queue.Dequeue<Pass, E | Cause.Done>,
6131
+ fails: Queue.Dequeue<Fail, E | Cause.Done>
6023
6132
  ],
6024
6133
  never,
6025
6134
  R | Scope.Scope
6026
6135
  >
6027
6136
  /**
6028
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6137
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6029
6138
  *
6030
6139
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6031
6140
  *
6032
6141
  * @example
6033
6142
  * ```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>
6068
- ],
6069
- never,
6070
- R | Scope.Scope
6071
- >
6072
- /**
6073
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6074
- *
6075
- * Each queue fails with the stream error or `Cause.Done` when the source ends.
6076
- *
6077
- * @example
6078
- * ```ts
6079
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6143
+ * import { Console, Effect, Result, Stream } from "effect"
6080
6144
  *
6081
6145
  * const program = Effect.gen(function*() {
6082
6146
  * 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
- * )
6147
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6086
6148
  * )
6087
6149
  *
6088
6150
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6100,16 +6162,16 @@ export const partitionQueue: {
6100
6162
  * @since 4.0.0
6101
6163
  * @category Filtering
6102
6164
  */
6103
- <A, E, R, Result extends Filter.ResultOrBool>(
6165
+ <A, E, R, Pass, Fail>(
6104
6166
  self: Stream<A, E, R>,
6105
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6167
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6106
6168
  options?: {
6107
6169
  readonly capacity?: number | "unbounded" | undefined
6108
6170
  }
6109
6171
  ): Effect.Effect<
6110
6172
  [
6111
- passes: Queue.Dequeue<Filter.Pass<A, Result>, E | Cause.Done>,
6112
- fails: Queue.Dequeue<Filter.Fail<A, Result>, E | Cause.Done>
6173
+ passes: Queue.Dequeue<Pass, E | Cause.Done>,
6174
+ fails: Queue.Dequeue<Fail, E | Cause.Done>
6113
6175
  ],
6114
6176
  never,
6115
6177
  R | Scope.Scope
@@ -6117,16 +6179,16 @@ export const partitionQueue: {
6117
6179
  } = dual(
6118
6180
  (args) => isStream(args[0]),
6119
6181
  Effect.fnUntraced(
6120
- function*<A, E, R, Result extends Filter.ResultOrBool>(
6182
+ function*<A, E, R, Pass, Fail>(
6121
6183
  self: Stream<A, E, R>,
6122
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6184
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6123
6185
  options?: {
6124
6186
  readonly capacity?: number | "unbounded" | undefined
6125
6187
  }
6126
6188
  ): Effect.fn.Return<
6127
6189
  [
6128
- passes: Queue.Dequeue<any, E | Cause.Done>,
6129
- fails: Queue.Dequeue<any, E | Cause.Done>
6190
+ passes: Queue.Dequeue<Pass, E | Cause.Done>,
6191
+ fails: Queue.Dequeue<Fail, E | Cause.Done>
6130
6192
  ],
6131
6193
  never,
6132
6194
  R | Scope.Scope
@@ -6135,19 +6197,17 @@ export const partitionQueue: {
6135
6197
  const pull = yield* Channel.toPullScoped(self.channel, scope)
6136
6198
  const capacity = options?.capacity === "unbounded" ? undefined : options?.capacity ?? DefaultChunkSize
6137
6199
  const passes = yield* Queue.make</**
6138
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6200
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6139
6201
  *
6140
6202
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6141
6203
  *
6142
6204
  * @example
6143
6205
  * ```ts
6144
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6206
+ * import { Console, Effect, Result, Stream } from "effect"
6145
6207
  *
6146
6208
  * const program = Effect.gen(function*() {
6147
6209
  * 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
- * )
6210
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6151
6211
  * )
6152
6212
  *
6153
6213
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6165,20 +6225,18 @@ export const partitionQueue: {
6165
6225
  * @since 4.0.0
6166
6226
  * @category Filtering
6167
6227
  */
6168
- any, /**
6169
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6228
+ Pass, /**
6229
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6170
6230
  *
6171
6231
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6172
6232
  *
6173
6233
  * @example
6174
6234
  * ```ts
6175
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6235
+ * import { Console, Effect, Result, Stream } from "effect"
6176
6236
  *
6177
6237
  * const program = Effect.gen(function*() {
6178
6238
  * 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
- * )
6239
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6182
6240
  * )
6183
6241
  *
6184
6242
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6198,19 +6256,17 @@ export const partitionQueue: {
6198
6256
  */
6199
6257
  E | Cause.Done>({ capacity })
6200
6258
  const fails = yield* Queue.make</**
6201
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6259
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6202
6260
  *
6203
6261
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6204
6262
  *
6205
6263
  * @example
6206
6264
  * ```ts
6207
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6265
+ * import { Console, Effect, Result, Stream } from "effect"
6208
6266
  *
6209
6267
  * const program = Effect.gen(function*() {
6210
6268
  * 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
- * )
6269
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6214
6270
  * )
6215
6271
  *
6216
6272
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6228,20 +6284,18 @@ export const partitionQueue: {
6228
6284
  * @since 4.0.0
6229
6285
  * @category Filtering
6230
6286
  */
6231
- any, /**
6232
- * Partitions a stream using a Filter and exposes passing and failing values as queues.
6287
+ Fail, /**
6288
+ * Partitions a stream using a `Filter` and exposes passing and failing values as queues.
6233
6289
  *
6234
6290
  * Each queue fails with the stream error or `Cause.Done` when the source ends.
6235
6291
  *
6236
6292
  * @example
6237
6293
  * ```ts
6238
- * import { Console, Effect, Filter, Result, Stream } from "effect"
6294
+ * import { Console, Effect, Result, Stream } from "effect"
6239
6295
  *
6240
6296
  * const program = Effect.gen(function*() {
6241
6297
  * 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
- * )
6298
+ * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6245
6299
  * )
6246
6300
  *
6247
6301
  * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
@@ -6261,12 +6315,19 @@ export const partitionQueue: {
6261
6315
  */
6262
6316
  E | Cause.Done>({ capacity })
6263
6317
 
6264
- const partitionArr = Arr.partition(filter as any)
6265
-
6266
6318
  yield* Effect.gen(function*() {
6267
6319
  while (true) {
6268
6320
  const chunk = yield* pull
6269
- const [excluded, satisfying] = partitionArr(chunk)
6321
+ const excluded: Array<Fail> = []
6322
+ const satisfying: Array<Pass> = []
6323
+ for (let i = 0; i < chunk.length; i++) {
6324
+ const result = filter(chunk[i] as NoInfer<A>)
6325
+ if (Result.isFailure(result)) {
6326
+ excluded.push(result.failure)
6327
+ } else {
6328
+ satisfying.push(result.success)
6329
+ }
6330
+ }
6270
6331
  let passFiber: Fiber.Fiber<any> | undefined = undefined
6271
6332
  if (satisfying.length > 0) {
6272
6333
  const leftover = Queue.offerAllUnsafe(passes, satisfying)
@@ -6297,147 +6358,112 @@ export const partitionQueue: {
6297
6358
  )
6298
6359
 
6299
6360
  /**
6300
- * Splits a stream using an effectful filter, producing pass and fail streams.
6361
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6301
6362
  *
6302
6363
  * @since 4.0.0
6303
6364
  * @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
6365
  */
6328
6366
  export const partitionEffect: {
6329
6367
  /**
6330
- * Splits a stream using an effectful filter, producing pass and fail streams.
6368
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6331
6369
  *
6332
6370
  * @since 4.0.0
6333
6371
  * @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
6372
  */
6358
- <A, B, X, EX, RX>(
6359
- filter: Filter.FilterEffect<A, B, X, EX, RX>,
6373
+ <A, Pass, Fail, EX, RX>(
6374
+ filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>,
6360
6375
  options?: {
6361
6376
  readonly capacity?: number | "unbounded" | undefined
6362
6377
  readonly concurrency?: number | "unbounded" | undefined
6363
6378
  }
6364
6379
  ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<
6365
6380
  [
6366
- passes: Stream<B, E | EX>,
6367
- fails: Stream<X, E | EX>
6381
+ passes: Stream<Pass, E | EX>,
6382
+ fails: Stream<Fail, E | EX>
6368
6383
  ],
6369
6384
  never,
6370
6385
  R | RX | Scope.Scope
6371
6386
  >
6372
6387
  /**
6373
- * Splits a stream using an effectful filter, producing pass and fail streams.
6388
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6374
6389
  *
6375
6390
  * @since 4.0.0
6376
6391
  * @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
6392
  */
6401
- <A, E, R, B, X, EX, RX>(
6393
+ <A, E, R, Pass, Fail, EX, RX>(
6402
6394
  self: Stream<A, E, R>,
6403
- filter: Filter.FilterEffect<A, B, X, EX, RX>,
6395
+ filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>,
6404
6396
  options?: {
6405
6397
  readonly capacity?: number | "unbounded" | undefined
6406
6398
  readonly concurrency?: number | "unbounded" | undefined
6407
6399
  }
6408
6400
  ): Effect.Effect<
6409
6401
  [
6410
- passes: Stream<B, E | EX>,
6411
- fails: Stream<X, E | EX>
6402
+ passes: Stream<Pass, E | EX>,
6403
+ fails: Stream<Fail, E | EX>
6412
6404
  ],
6413
6405
  never,
6414
6406
  R | RX | Scope.Scope
6415
6407
  >
6416
6408
  } = dual(
6417
6409
  (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<
6410
+ <A, E, R, Pass, Fail, EX, RX>(
6411
+ self: Stream<A, E, R>,
6412
+ filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>,
6413
+ options?: {
6414
+ readonly capacity?: number | "unbounded" | undefined
6415
+ readonly concurrency?: number | "unbounded" | undefined
6416
+ }
6417
+ ): Effect.Effect<
6422
6418
  [
6423
- passes: Stream<B, E | EX>,
6424
- fails: Stream<X, E | EX>
6419
+ passes: Stream<Pass, E | EX>,
6420
+ fails: Stream<Fail, E | EX>
6425
6421
  ],
6426
6422
  never,
6427
6423
  R | RX | Scope.Scope
6428
6424
  > =>
6429
6425
  Effect.map(
6430
- self.pipe(
6431
- mapEffect(filter, options),
6432
- partitionQueue(identity as any, options)
6426
+ partitionQueue</**
6427
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6428
+ *
6429
+ * @since 4.0.0
6430
+ * @category Filtering
6431
+ */
6432
+ Result.Result<Pass, Fail>, /**
6433
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6434
+ *
6435
+ * @since 4.0.0
6436
+ * @category Filtering
6437
+ */
6438
+ E | EX, /**
6439
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6440
+ *
6441
+ * @since 4.0.0
6442
+ * @category Filtering
6443
+ */
6444
+ R | RX, /**
6445
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6446
+ *
6447
+ * @since 4.0.0
6448
+ * @category Filtering
6449
+ */
6450
+ Pass, /**
6451
+ * Splits a stream using an effectful `Filter`, producing pass and fail streams.
6452
+ *
6453
+ * @since 4.0.0
6454
+ * @category Filtering
6455
+ */
6456
+ Fail>(
6457
+ mapEffect(self, (a) => filter(a as NoInfer<A>), options),
6458
+ (result) => result,
6459
+ options
6433
6460
  ),
6434
- ([passes, fails]) => [fromQueue(passes), fromQueue(fails)]
6435
- ) as any
6461
+ ([passes, fails]) => [fromQueue(passes), fromQueue(fails)] as const
6462
+ )
6436
6463
  )
6437
6464
 
6438
6465
  /**
6439
- * Splits a stream into excluded and satisfying substreams using a predicate,
6440
- * refinement, or Filter.
6466
+ * Splits a stream into excluded and satisfying substreams using a `Filter`.
6441
6467
  *
6442
6468
  * The faster stream may advance up to `bufferSize` elements ahead of the slower
6443
6469
  * one.
@@ -6447,102 +6473,25 @@ export const partitionEffect: {
6447
6473
  *
6448
6474
  * @example
6449
6475
  * ```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
- >
6476
+ * import { Console, Effect, Result, Stream } from "effect"
6477
+ *
6478
+ * const program = Effect.gen(function*() {
6479
+ * const [excluded, satisfying] = yield* Stream.partition(
6480
+ * Stream.make(1, 2, 3, 4),
6481
+ * (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
6482
+ * )
6483
+ * const left = yield* Stream.runCollect(excluded)
6484
+ * const right = yield* Stream.runCollect(satisfying)
6485
+ * yield* Console.log(left)
6486
+ * // Output: [ 1, 3 ]
6487
+ * yield* Console.log(right)
6488
+ * // Output: [ 2, 4 ]
6489
+ * })
6490
+ * ```
6491
+ */
6492
+ export const partition: {
6543
6493
  /**
6544
- * Splits a stream into excluded and satisfying substreams using a predicate,
6545
- * refinement, or Filter.
6494
+ * Splits a stream into excluded and satisfying substreams using a `Filter`.
6546
6495
  *
6547
6496
  * The faster stream may advance up to `bufferSize` elements ahead of the slower
6548
6497
  * one.
@@ -6552,12 +6501,12 @@ export const partition: {
6552
6501
  *
6553
6502
  * @example
6554
6503
  * ```ts
6555
- * import { Console, Effect, Stream } from "effect"
6504
+ * import { Console, Effect, Result, Stream } from "effect"
6556
6505
  *
6557
6506
  * const program = Effect.gen(function*() {
6558
6507
  * const [excluded, satisfying] = yield* Stream.partition(
6559
6508
  * Stream.make(1, 2, 3, 4),
6560
- * (n) => n % 2 === 0
6509
+ * (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
6561
6510
  * )
6562
6511
  * const left = yield* Stream.runCollect(excluded)
6563
6512
  * const right = yield* Stream.runCollect(satisfying)
@@ -6568,18 +6517,18 @@ export const partition: {
6568
6517
  * })
6569
6518
  * ```
6570
6519
  */
6571
- <C extends A, E, R, B extends A, A = C>(
6572
- self: Stream<C, E, R>,
6573
- refinement: Refinement<A, B>,
6520
+ <A, Pass, Fail>(
6521
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6574
6522
  options?: { readonly bufferSize?: number | undefined }
6575
- ): Effect.Effect<
6576
- [excluded: Stream<Exclude<C, B>, E>, satisfying: Stream<B, E>],
6523
+ ): <E, R>(
6524
+ self: Stream<A, E, R>
6525
+ ) => Effect.Effect<
6526
+ [excluded: Stream<Fail, E>, satisfying: Stream<Pass, E>],
6577
6527
  never,
6578
6528
  R | Scope.Scope
6579
6529
  >
6580
6530
  /**
6581
- * Splits a stream into excluded and satisfying substreams using a predicate,
6582
- * refinement, or Filter.
6531
+ * Splits a stream into excluded and satisfying substreams using a `Filter`.
6583
6532
  *
6584
6533
  * The faster stream may advance up to `bufferSize` elements ahead of the slower
6585
6534
  * one.
@@ -6589,12 +6538,12 @@ export const partition: {
6589
6538
  *
6590
6539
  * @example
6591
6540
  * ```ts
6592
- * import { Console, Effect, Stream } from "effect"
6541
+ * import { Console, Effect, Result, Stream } from "effect"
6593
6542
  *
6594
6543
  * const program = Effect.gen(function*() {
6595
6544
  * const [excluded, satisfying] = yield* Stream.partition(
6596
6545
  * Stream.make(1, 2, 3, 4),
6597
- * (n) => n % 2 === 0
6546
+ * (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
6598
6547
  * )
6599
6548
  * const left = yield* Stream.runCollect(excluded)
6600
6549
  * const right = yield* Stream.runCollect(satisfying)
@@ -6605,28 +6554,28 @@ export const partition: {
6605
6554
  * })
6606
6555
  * ```
6607
6556
  */
6608
- <A, E, R, Result extends Filter.ResultOrBool>(
6557
+ <A, E, R, Pass, Fail>(
6609
6558
  self: Stream<A, E, R>,
6610
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6559
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6611
6560
  options?: { readonly bufferSize?: number | undefined }
6612
6561
  ): Effect.Effect<
6613
- [excluded: Stream<Filter.Fail<A, Result>, E>, satisfying: Stream<Filter.Pass<A, Result>, E>],
6562
+ [excluded: Stream<Fail, E>, satisfying: Stream<Pass, E>],
6614
6563
  never,
6615
6564
  R | Scope.Scope
6616
6565
  >
6617
6566
  } = dual(
6618
6567
  (args) => isStream(args[0]),
6619
- <A, E, R, Result extends Filter.ResultOrBool>(
6568
+ <A, E, R, Pass, Fail>(
6620
6569
  self: Stream<A, E, R>,
6621
- filter: Filter.OrPredicate<NoInfer<A>, Result>,
6570
+ filter: Filter.Filter<NoInfer<A>, Pass, Fail>,
6622
6571
  options?: { readonly bufferSize?: number | undefined }
6623
6572
  ): Effect.Effect<
6624
- [excluded: Stream<Filter.Fail<A, Result>, E>, satisfying: Stream<Filter.Pass<A, Result>, E>],
6573
+ [excluded: Stream<Fail, E>, satisfying: Stream<Pass, E>],
6625
6574
  never,
6626
6575
  R | Scope.Scope
6627
6576
  > =>
6628
6577
  Effect.map(
6629
- partitionQueue(filter, { capacity: options?.bufferSize ?? 16 })(self),
6578
+ partitionQueue(self, filter, { capacity: options?.bufferSize ?? 16 }),
6630
6579
  ([passes, fails]) => [fromQueue(fails), fromQueue(passes)] as const
6631
6580
  )
6632
6581
  )
@@ -7408,7 +7357,7 @@ export const tapError: {
7408
7357
  ))
7409
7358
 
7410
7359
  /**
7411
- * Recovers from errors that match a filter by switching to a recovery stream.
7360
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7412
7361
  *
7413
7362
  * When a failure matches the filter, the stream switches to the recovery
7414
7363
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7422,12 +7371,12 @@ export const tapError: {
7422
7371
  *
7423
7372
  * @example
7424
7373
  * ```ts
7425
- * import { Console, Effect, Filter, Stream } from "effect"
7374
+ * import { Console, Effect, Stream } from "effect"
7426
7375
  *
7427
7376
  * const stream = Stream.make(1, 2).pipe(
7428
7377
  * Stream.concat(Stream.fail(42)),
7429
7378
  * Stream.catchIf(
7430
- * Filter.fromPredicate((error): error is 42 => error === 42),
7379
+ * (error): error is 42 => error === 42,
7431
7380
  * () => Stream.make(999)
7432
7381
  * )
7433
7382
  * )
@@ -7446,7 +7395,7 @@ export const tapError: {
7446
7395
  */
7447
7396
  export const catchIf: {
7448
7397
  /**
7449
- * Recovers from errors that match a filter by switching to a recovery stream.
7398
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7450
7399
  *
7451
7400
  * When a failure matches the filter, the stream switches to the recovery
7452
7401
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7460,12 +7409,12 @@ export const catchIf: {
7460
7409
  *
7461
7410
  * @example
7462
7411
  * ```ts
7463
- * import { Console, Effect, Filter, Stream } from "effect"
7412
+ * import { Console, Effect, Stream } from "effect"
7464
7413
  *
7465
7414
  * const stream = Stream.make(1, 2).pipe(
7466
7415
  * Stream.concat(Stream.fail(42)),
7467
7416
  * Stream.catchIf(
7468
- * Filter.fromPredicate((error): error is 42 => error === 42),
7417
+ * (error): error is 42 => error === 42,
7469
7418
  * () => Stream.make(999)
7470
7419
  * )
7471
7420
  * )
@@ -7488,7 +7437,7 @@ export const catchIf: {
7488
7437
  orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined
7489
7438
  ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A | A3, E2 | E3, R2 | R | R3>
7490
7439
  /**
7491
- * Recovers from errors that match a filter by switching to a recovery stream.
7440
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7492
7441
  *
7493
7442
  * When a failure matches the filter, the stream switches to the recovery
7494
7443
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7502,12 +7451,12 @@ export const catchIf: {
7502
7451
  *
7503
7452
  * @example
7504
7453
  * ```ts
7505
- * import { Console, Effect, Filter, Stream } from "effect"
7454
+ * import { Console, Effect, Stream } from "effect"
7506
7455
  *
7507
7456
  * const stream = Stream.make(1, 2).pipe(
7508
7457
  * Stream.concat(Stream.fail(42)),
7509
7458
  * Stream.catchIf(
7510
- * Filter.fromPredicate((error): error is 42 => error === 42),
7459
+ * (error): error is 42 => error === 42,
7511
7460
  * () => Stream.make(999)
7512
7461
  * )
7513
7462
  * )
@@ -7524,13 +7473,13 @@ export const catchIf: {
7524
7473
  * @since 4.0.0
7525
7474
  * @category Error Handling
7526
7475
  */
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>
7476
+ <E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
7477
+ predicate: Predicate<NoInfer<E>>,
7478
+ f: (e: NoInfer<E>) => Stream<A2, E2, R2>,
7479
+ orElse?: ((e: NoInfer<E>) => Stream<A3, E3, R3>) | undefined
7480
+ ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A | A3, E2 | E3, R2 | R | R3>
7532
7481
  /**
7533
- * Recovers from errors that match a filter by switching to a recovery stream.
7482
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7534
7483
  *
7535
7484
  * When a failure matches the filter, the stream switches to the recovery
7536
7485
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7544,12 +7493,12 @@ export const catchIf: {
7544
7493
  *
7545
7494
  * @example
7546
7495
  * ```ts
7547
- * import { Console, Effect, Filter, Stream } from "effect"
7496
+ * import { Console, Effect, Stream } from "effect"
7548
7497
  *
7549
7498
  * const stream = Stream.make(1, 2).pipe(
7550
7499
  * Stream.concat(Stream.fail(42)),
7551
7500
  * Stream.catchIf(
7552
- * Filter.fromPredicate((error): error is 42 => error === 42),
7501
+ * (error): error is 42 => error === 42,
7553
7502
  * () => Stream.make(999)
7554
7503
  * )
7555
7504
  * )
@@ -7573,7 +7522,7 @@ export const catchIf: {
7573
7522
  orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined
7574
7523
  ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7575
7524
  /**
7576
- * Recovers from errors that match a filter by switching to a recovery stream.
7525
+ * Recovers from errors that match a predicate by switching to a recovery stream.
7577
7526
  *
7578
7527
  * When a failure matches the filter, the stream switches to the recovery
7579
7528
  * stream. Non-matching failures propagate downstream, so the error type is
@@ -7587,12 +7536,12 @@ export const catchIf: {
7587
7536
  *
7588
7537
  * @example
7589
7538
  * ```ts
7590
- * import { Console, Effect, Filter, Stream } from "effect"
7539
+ * import { Console, Effect, Stream } from "effect"
7591
7540
  *
7592
7541
  * const stream = Stream.make(1, 2).pipe(
7593
7542
  * Stream.concat(Stream.fail(42)),
7594
7543
  * Stream.catchIf(
7595
- * Filter.fromPredicate((error): error is 42 => error === 42),
7544
+ * (error): error is 42 => error === 42,
7596
7545
  * () => Stream.make(999)
7597
7546
  * )
7598
7547
  * )
@@ -7609,37 +7558,96 @@ export const catchIf: {
7609
7558
  * @since 4.0.0
7610
7559
  * @category Error Handling
7611
7560
  */
7612
- <A, E, R, Result extends Filter.ResultOrBool, A2, E2, R2, A3 = never, E3 = Filter.Fail<E, Result>, R3 = never>(
7561
+ <A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
7613
7562
  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
7563
+ predicate: Predicate<E>,
7564
+ f: (e: E) => Stream<A2, E2, R2>,
7565
+ orElse?: ((e: E) => Stream<A3, E3, R3>) | undefined
7617
7566
  ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7618
7567
  } = dual((args) => isStream(args[0]), <
7619
7568
  A,
7620
7569
  E,
7621
7570
  R,
7622
- Result extends Filter.ResultOrBool,
7623
7571
  A2,
7624
7572
  E2,
7625
7573
  R2,
7626
7574
  A3 = never,
7627
- E3 = Filter.Fail<E, Result>,
7575
+ E3 = E,
7628
7576
  R3 = never
7629
7577
  >(
7630
7578
  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
7579
+ predicate: Predicate<E>,
7580
+ f: (failure: E) => Stream<A2, E2, R2>,
7581
+ orElse?: ((failure: E) => Stream<A3, E3, R3>) | undefined
7634
7582
  ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3> =>
7635
7583
  fromChannel(
7636
7584
  Channel.catchIf(
7637
7585
  toChannel(self),
7638
- filter as any,
7639
- (e: any) => f(e).channel,
7640
- orElse && ((e: any) => orElse(e).channel)
7586
+ predicate,
7587
+ (e) => f(e).channel,
7588
+ orElse && ((e) => orElse(e).channel)
7589
+ )
7590
+ ))
7591
+
7592
+ /**
7593
+ * Recovers from errors that match a `Filter` by switching to a recovery
7594
+ * stream.
7595
+ *
7596
+ * @since 4.0.0
7597
+ * @category Error Handling
7598
+ */
7599
+ export const catchFilter: {
7600
+ /**
7601
+ * Recovers from errors that match a `Filter` by switching to a recovery
7602
+ * stream.
7603
+ *
7604
+ * @since 4.0.0
7605
+ * @category Error Handling
7606
+ */
7607
+ <E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
7608
+ filter: Filter.Filter<NoInfer<E>, EB, X>,
7609
+ f: (failure: EB) => Stream<A2, E2, R2>,
7610
+ orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined
7611
+ ): <A, R>(self: Stream<A, E, R>) => Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7612
+ /**
7613
+ * Recovers from errors that match a `Filter` by switching to a recovery
7614
+ * stream.
7615
+ *
7616
+ * @since 4.0.0
7617
+ * @category Error Handling
7618
+ */
7619
+ <A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
7620
+ self: Stream<A, E, R>,
7621
+ filter: Filter.Filter<NoInfer<E>, EB, X>,
7622
+ f: (failure: EB) => Stream<A2, E2, R2>,
7623
+ orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined
7624
+ ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>
7625
+ } = dual((args) => isStream(args[0]), <
7626
+ A,
7627
+ E,
7628
+ R,
7629
+ EB,
7630
+ A2,
7631
+ E2,
7632
+ R2,
7633
+ X,
7634
+ A3 = never,
7635
+ E3 = X,
7636
+ R3 = never
7637
+ >(
7638
+ self: Stream<A, E, R>,
7639
+ filter: Filter.Filter<NoInfer<E>, EB, X>,
7640
+ f: (failure: EB) => Stream<A2, E2, R2>,
7641
+ orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined
7642
+ ): Stream<A | A2 | A3, E2 | E3, R | R2 | R3> =>
7643
+ fromChannel(
7644
+ Channel.catchFilter(
7645
+ toChannel(self),
7646
+ filter,
7647
+ (e) => f(e).channel,
7648
+ orElse && ((e) => orElse(e).channel)
7641
7649
  )
7642
- ) as any)
7650
+ ))
7643
7651
 
7644
7652
  /**
7645
7653
  * Recovers from failures whose `_tag` matches the provided value by switching to
@@ -7978,7 +7986,7 @@ export const catchTags: {
7978
7986
  >
7979
7987
  } = dual((args) => isStream(args[0]), (self, cases, orElse) => {
7980
7988
  let keys: Array<string>
7981
- return catchIf(
7989
+ return catchFilter(
7982
7990
  self,
7983
7991
  (e: any) => {
7984
7992
  keys ??= Object.keys(cases)
@@ -8091,8 +8099,16 @@ export const catchReason: {
8091
8099
  >(
8092
8100
  errorTag: K,
8093
8101
  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
8102
+ f: (
8103
+ reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
8104
+ error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
8105
+ ) => Stream<A2, E2, R2>,
8106
+ orElse?:
8107
+ | ((
8108
+ reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
8109
+ error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
8110
+ ) => Stream<A3, E3, R3>)
8111
+ | undefined
8096
8112
  ): <A, R>(
8097
8113
  self: Stream<A, E, R>
8098
8114
  ) => Stream<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
@@ -8155,8 +8171,10 @@ export const catchReason: {
8155
8171
  self: Stream<A, E, R>,
8156
8172
  errorTag: K,
8157
8173
  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
8174
+ f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Stream<A2, E2, R2>,
8175
+ orElse?:
8176
+ | ((reason: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Stream<A3, E3, R3>)
8177
+ | undefined
8160
8178
  ): Stream<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
8161
8179
  } = dual(
8162
8180
  (args) => isStream(args[0]),
@@ -8176,16 +8194,18 @@ export const catchReason: {
8176
8194
  self: Stream<A, E, R>,
8177
8195
  errorTag: K,
8178
8196
  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
8197
+ f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Stream<A2, E2, R2>,
8198
+ orElse?:
8199
+ | ((reason: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Stream<A3, E3, R3>)
8200
+ | undefined
8181
8201
  ): Stream<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3> =>
8182
8202
  fromChannel(
8183
8203
  Channel.catchReason(
8184
8204
  toChannel(self),
8185
8205
  errorTag,
8186
8206
  reasonTag,
8187
- (reason) => f(reason).channel,
8188
- orElse && ((reason) => orElse(reason).channel)
8207
+ (reason, error) => f(reason, error).channel,
8208
+ orElse && ((reason, error) => orElse(reason, error).channel)
8189
8209
  )
8190
8210
  ) as any
8191
8211
  )
@@ -8278,7 +8298,8 @@ export const catchReasons: {
8278
8298
  E,
8279
8299
  Cases extends {
8280
8300
  [RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
8281
- reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>
8301
+ reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
8302
+ error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
8282
8303
  ) => Stream<any, any, any>
8283
8304
  },
8284
8305
  A2 = unassigned,
@@ -8288,7 +8309,10 @@ export const catchReasons: {
8288
8309
  errorTag: K,
8289
8310
  cases: Cases,
8290
8311
  orElse?:
8291
- | ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Stream<A2, E2, R2>)
8312
+ | ((
8313
+ reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
8314
+ error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
8315
+ ) => Stream<A2, E2, R2>)
8292
8316
  | undefined
8293
8317
  ): <A, R>(self: Stream<A, E, R>) => Stream<
8294
8318
  | A
@@ -8355,7 +8379,8 @@ export const catchReasons: {
8355
8379
  K extends Tags<E>,
8356
8380
  Cases extends {
8357
8381
  [RK in ReasonTags<ExtractTag<E, K>>]+?: (
8358
- reason: ExtractReason<ExtractTag<E, K>, RK>
8382
+ reason: ExtractReason<ExtractTag<E, K>, RK>,
8383
+ error: NarrowReason<ExtractTag<E, K>, RK>
8359
8384
  ) => Stream<any, any, any>
8360
8385
  },
8361
8386
  A2 = unassigned,
@@ -8366,7 +8391,10 @@ export const catchReasons: {
8366
8391
  errorTag: K,
8367
8392
  cases: Cases,
8368
8393
  orElse?:
8369
- | ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Stream<A2, E2, R2>)
8394
+ | ((
8395
+ reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
8396
+ error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
8397
+ ) => Stream<A2, E2, R2>)
8370
8398
  | undefined
8371
8399
  ): Stream<
8372
8400
  | A
@@ -8386,12 +8414,12 @@ export const catchReasons: {
8386
8414
  }[keyof Cases]
8387
8415
  >
8388
8416
  } = 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>> = {}
8417
+ const handlers: Record<string, (reason: any, error: any) => Channel.Channel<any, any, any, any, any, any, any>> = {}
8390
8418
  for (const key of Object.keys(cases)) {
8391
8419
  const handler = (cases as any)[key]
8392
- handlers[key] = (reason) => handler(reason).channel
8420
+ handlers[key] = (reason, error) => handler(reason, error).channel
8393
8421
  }
8394
- const orElseHandler = orElse && ((reason: any) => orElse(reason).channel)
8422
+ const orElseHandler = orElse && ((reason: any, error: any) => orElse(reason, error).channel)
8395
8423
  return fromChannel(
8396
8424
  Channel.catchReasons(self.channel, errorTag as any, handlers as any, orElseHandler as any) as Channel.Channel<
8397
8425
  Arr.NonEmptyReadonlyArray<any>,
@@ -8549,12 +8577,12 @@ export const catchCauseIf: {
8549
8577
  * @since 4.0.0
8550
8578
  * @category Error Handling
8551
8579
  */
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>
8580
+ <E, A2, E2, R2>(
8581
+ predicate: Predicate<Cause.Cause<E>>,
8582
+ f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8555
8583
  ): <A, R>(
8556
8584
  self: Stream<A, E, R>
8557
- ) => Stream<A | A2, Cause.Cause.Error<Filter.Fail<Cause.Cause<E>, Result>> | E2, R2 | R>
8585
+ ) => Stream<A | A2, E | E2, R2 | R>
8558
8586
  /**
8559
8587
  * Recovers from stream failures by filtering the `Cause` and switching to a recovery stream.
8560
8588
  * Non-matching causes are re-emitted as failures.
@@ -8588,19 +8616,68 @@ export const catchCauseIf: {
8588
8616
  * @since 4.0.0
8589
8617
  * @category Error Handling
8590
8618
  */
8591
- <A, E, R, A2, E2, R2, Result extends Filter.ResultOrBool<Cause.Cause<any>>>(
8619
+ <A, E, R, A2, E2, R2>(
8620
+ self: Stream<A, E, R>,
8621
+ predicate: Predicate<Cause.Cause<E>>,
8622
+ f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8623
+ ): Stream<A | A2, E | E2, R | R2>
8624
+ } = dual(3, <A, E, R, A2, E2, R2>(
8625
+ self: Stream<A, E, R>,
8626
+ predicate: Predicate<Cause.Cause<E>>,
8627
+ f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8628
+ ): Stream<A | A2, E | E2, R | R2> =>
8629
+ fromChannel(
8630
+ Channel.catchCauseIf(
8631
+ self.channel,
8632
+ predicate,
8633
+ (cause) => f(cause).channel
8634
+ )
8635
+ ))
8636
+
8637
+ /**
8638
+ * Recovers from stream failures by filtering the `Cause` and switching to a
8639
+ * recovery stream.
8640
+ *
8641
+ * @since 4.0.0
8642
+ * @category Error Handling
8643
+ */
8644
+ export const catchCauseFilter: {
8645
+ /**
8646
+ * Recovers from stream failures by filtering the `Cause` and switching to a
8647
+ * recovery stream.
8648
+ *
8649
+ * @since 4.0.0
8650
+ * @category Error Handling
8651
+ */
8652
+ <E, EB, A2, E2, R2, X extends Cause.Cause<any>>(
8653
+ filter: Filter.Filter<Cause.Cause<E>, EB, X>,
8654
+ f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8655
+ ): <A, R>(
8656
+ self: Stream<A, E, R>
8657
+ ) => Stream<A | A2, Cause.Cause.Error<X> | E2, R2 | R>
8658
+ /**
8659
+ * Recovers from stream failures by filtering the `Cause` and switching to a
8660
+ * recovery stream.
8661
+ *
8662
+ * @since 4.0.0
8663
+ * @category Error Handling
8664
+ */
8665
+ <A, E, R, EB, A2, E2, R2, X extends Cause.Cause<any>>(
8592
8666
  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>>>(
8667
+ filter: Filter.Filter<Cause.Cause<E>, EB, X>,
8668
+ f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8669
+ ): Stream<A | A2, Cause.Cause.Error<X> | E2, R | R2>
8670
+ } = dual(3, <A, E, R, EB, A2, E2, R2, X extends Cause.Cause<any>>(
8597
8671
  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> =>
8672
+ filter: Filter.Filter<Cause.Cause<E>, EB, X>,
8673
+ f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>
8674
+ ): Stream<A | A2, Cause.Cause.Error<X> | E2, R | R2> =>
8601
8675
  fromChannel(
8602
- Channel.catchCauseIf(self.channel, filter as any, (failure: any, cause: any) =>
8603
- (f as any)(failure, cause).channel) as any
8676
+ Channel.catchCauseFilter(
8677
+ self.channel,
8678
+ filter,
8679
+ (failure, cause) => f(failure, cause).channel
8680
+ )
8604
8681
  ))
8605
8682
 
8606
8683
  /**
@@ -8819,12 +8896,12 @@ export const orDie = <A, E, R>(self: Stream<A, E, R>): Stream<A, never, R> => fr
8819
8896
  */
8820
8897
  export const ignore: <
8821
8898
  Arg extends Stream<any, any, any> | {
8822
- readonly log?: boolean | LogLevel | undefined
8899
+ readonly log?: boolean | Severity | undefined
8823
8900
  } | undefined
8824
8901
  >(
8825
8902
  selfOrOptions: Arg,
8826
8903
  options?: {
8827
- readonly log?: boolean | LogLevel | undefined
8904
+ readonly log?: boolean | Severity | undefined
8828
8905
  } | undefined
8829
8906
  ) => [Arg] extends [Stream<infer A, infer _E, infer R>] ? Stream<A, never, R>
8830
8907
  : <A, E, R>(self: Stream<A, E, R>) => Stream<A, never, R> = dual(
@@ -8832,7 +8909,7 @@ export const ignore: <
8832
8909
  <A, E, R>(
8833
8910
  self: Stream<A, E, R>,
8834
8911
  options?: {
8835
- readonly log?: boolean | LogLevel | undefined
8912
+ readonly log?: boolean | Severity | undefined
8836
8913
  } | undefined
8837
8914
  ): Stream<A, never, R> => fromChannel(Channel.ignore(self.channel, options))
8838
8915
  )
@@ -8859,19 +8936,19 @@ export const ignore: <
8859
8936
  */
8860
8937
  export const ignoreCause: <
8861
8938
  Arg extends Stream<any, any, any> | {
8862
- readonly log?: boolean | LogLevel | undefined
8939
+ readonly log?: boolean | Severity | undefined
8863
8940
  } | undefined
8864
8941
  >(
8865
8942
  streamOrOptions: Arg,
8866
8943
  options?: {
8867
- readonly log?: boolean | LogLevel | undefined
8944
+ readonly log?: boolean | Severity | undefined
8868
8945
  } | undefined
8869
8946
  ) => [Arg] extends [Stream<infer A, infer _E, infer R>] ? Stream<A, never, R>
8870
8947
  : <A, E, R>(self: Stream<A, E, R>) => Stream<A, never, R> = dual(
8871
8948
  (args) => isStream(args[0]),
8872
8949
  <A, E, R>(
8873
8950
  self: Stream<A, E, R>,
8874
- options?: { readonly log?: boolean | LogLevel | undefined } | undefined
8951
+ options?: { readonly log?: boolean | Severity | undefined } | undefined
8875
8952
  ): Stream<A, never, R> => fromChannel(Channel.ignoreCause(self.channel, options))
8876
8953
  )
8877
8954
 
@@ -9741,7 +9818,7 @@ export const takeWhile: {
9741
9818
  * @since 2.0.0
9742
9819
  * @category Filtering
9743
9820
  */
9744
- <A, B, X>(f: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
9821
+ <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
9822
  /**
9746
9823
  * Takes the longest initial prefix of elements that satisfy the predicate.
9747
9824
  *
@@ -9765,71 +9842,71 @@ export const takeWhile: {
9765
9842
  * @since 2.0.0
9766
9843
  * @category Filtering
9767
9844
  */
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>
9845
+ <A, E, R>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, n: number) => boolean): Stream<A, E, R>
9846
+ } = dual(
9847
+ 2,
9848
+ <A, E, R>(
9849
+ self: Stream<A, E, R>,
9850
+ predicate: (a: A, n: number) => boolean
9851
+ ): Stream<A, E, R> =>
9852
+ transformPull(self, (pull, _scope) =>
9853
+ Effect.sync(() => {
9854
+ let i = 0
9855
+ let done = false
9856
+ const pump: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void, R> = Effect.flatMap(
9857
+ Effect.suspend(() => done ? Cause.done() : pull),
9858
+ (chunk) => {
9859
+ const out: Array<A> = []
9860
+ for (let j = 0; j < chunk.length; j++) {
9861
+ if (!predicate(chunk[j], i++)) {
9862
+ done = true
9863
+ break
9864
+ }
9865
+ out.push(chunk[j])
9866
+ }
9867
+ return Arr.isReadonlyArrayNonEmpty(out) ? Effect.succeed(out) : done ? Cause.done() : pump
9868
+ }
9869
+ )
9870
+ return pump
9871
+ }))
9872
+ )
9873
+
9874
+ /**
9875
+ * Takes the longest initial prefix of elements that satisfy the filter.
9876
+ *
9877
+ * @since 4.0.0
9878
+ * @category Filtering
9879
+ */
9880
+ export const takeWhileFilter: {
9769
9881
  /**
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
- * ```
9882
+ * Takes the longest initial prefix of elements that satisfy the filter.
9788
9883
  *
9789
- * @since 2.0.0
9884
+ * @since 4.0.0
9790
9885
  * @category Filtering
9791
9886
  */
9792
- <A, E, R>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, n: number) => boolean): Stream<A, E, R>
9887
+ <A, B, X>(f: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
9793
9888
  /**
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
- * ```
9889
+ * Takes the longest initial prefix of elements that satisfy the filter.
9812
9890
  *
9813
- * @since 2.0.0
9891
+ * @since 4.0.0
9814
9892
  * @category Filtering
9815
9893
  */
9816
9894
  <A, E, R, B, X>(self: Stream<A, E, R>, f: Filter.Filter<NoInfer<A>, B, X>): Stream<B, E, R>
9817
9895
  } = dual(
9818
9896
  2,
9819
- <A, E, R>(
9897
+ <A, E, R, B, X>(
9820
9898
  self: Stream<A, E, R>,
9821
- f: Filter.Filter<A, any, any> | ((a: A, n: number) => boolean)
9822
- ): Stream<any, E, R> =>
9899
+ filter: Filter.Filter<NoInfer<A>, B, X>
9900
+ ): Stream<B, E, R> =>
9823
9901
  transformPull(self, (pull, _scope) =>
9824
9902
  Effect.sync(() => {
9825
- let i = 0
9826
9903
  let done = false
9827
- const pump: Pull.Pull<Arr.NonEmptyReadonlyArray<any>, E, void, R> = Effect.flatMap(
9904
+ const pump: Pull.Pull<Arr.NonEmptyReadonlyArray<B>, E, void, R> = Effect.flatMap(
9828
9905
  Effect.suspend(() => done ? Cause.done() : pull),
9829
9906
  (chunk) => {
9830
- const out: Array<any> = []
9907
+ const out: Array<B> = []
9831
9908
  for (let j = 0; j < chunk.length; j++) {
9832
- const result = Filter.apply(f as any, chunk[j], i++)
9909
+ const result = filter(chunk[j])
9833
9910
  if (Result.isFailure(result)) {
9834
9911
  done = true
9835
9912
  break
@@ -10224,29 +10301,6 @@ export const dropWhile: {
10224
10301
  * @category Filtering
10225
10302
  */
10226
10303
  <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
10304
  /**
10251
10305
  * Drops elements from the stream while the specified predicate evaluates to `true`.
10252
10306
  *
@@ -10273,39 +10327,53 @@ export const dropWhile: {
10273
10327
  self: Stream<A, E, R>,
10274
10328
  predicate: (a: NoInfer<A>, index: number) => boolean
10275
10329
  ): Stream<A, E, R>
10330
+ } = dual(2, <A, E, R>(
10331
+ self: Stream<A, E, R>,
10332
+ predicate: (a: A, index: number) => boolean
10333
+ ): Stream<A, E, R> =>
10334
+ transformPull(self, (pull, _scope) =>
10335
+ Effect.sync(() => {
10336
+ let dropping = true
10337
+ let index = 0
10338
+ const filtered: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E> = Effect.flatMap(pull, (arr) => {
10339
+ const found = arr.findIndex((a) => !predicate(a, index++))
10340
+ if (found === -1) return filtered
10341
+ dropping = false
10342
+ return Effect.succeed(arr.slice(found) as Arr.NonEmptyArray<A>)
10343
+ })
10344
+ return Effect.suspend(() => dropping ? filtered : pull)
10345
+ })))
10346
+
10347
+ /**
10348
+ * Drops elements while the filter succeeds.
10349
+ *
10350
+ * @since 4.0.0
10351
+ * @category Filtering
10352
+ */
10353
+ export const dropWhileFilter: {
10276
10354
  /**
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
- * })
10355
+ * Drops elements while the filter succeeds.
10290
10356
  *
10291
- * Effect.runPromise(program)
10292
- * // Output: [ 3, 4, 5 ]
10293
- * ```
10357
+ * @since 4.0.0
10358
+ * @category Filtering
10359
+ */
10360
+ <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
10361
+ /**
10362
+ * Drops elements while the filter succeeds.
10294
10363
  *
10295
- * @since 2.0.0
10364
+ * @since 4.0.0
10296
10365
  * @category Filtering
10297
10366
  */
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>(
10367
+ <A, E, R, B, X>(self: Stream<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>): Stream<A, E, R>
10368
+ } = dual(2, <A, E, R, B, X>(
10300
10369
  self: Stream<A, E, R>,
10301
- f: Filter.Filter<A, any, any> | ((a: A, index: number) => boolean)
10370
+ filter: Filter.Filter<NoInfer<A>, B, X>
10302
10371
  ): Stream<A, E, R> =>
10303
10372
  transformPull(self, (pull, _scope) =>
10304
10373
  Effect.sync(() => {
10305
10374
  let dropping = true
10306
- let index = 0
10307
10375
  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++)))
10376
+ const found = arr.findIndex((a) => Result.isFailure(filter(a)))
10309
10377
  if (found === -1) return filtered
10310
10378
  dropping = false
10311
10379
  return Effect.succeed(arr.slice(found) as Arr.NonEmptyArray<A>)
@@ -12174,7 +12242,7 @@ export const debounce: {
12174
12242
  * @since 2.0.0
12175
12243
  * @category Rate Limiting
12176
12244
  */
12177
- (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
12245
+ (duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
12178
12246
  /**
12179
12247
  * Drops earlier elements within the debounce window and emits only the latest element after the pause.
12180
12248
  *
@@ -12198,21 +12266,21 @@ export const debounce: {
12198
12266
  * @since 2.0.0
12199
12267
  * @category Rate Limiting
12200
12268
  */
12201
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R>
12269
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
12202
12270
  } = dual(
12203
12271
  2,
12204
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> =>
12272
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
12205
12273
  transformPull(
12206
12274
  self,
12207
12275
  Effect.fnUntraced(function*(pull, scope) {
12208
12276
  const clock = yield* Clock
12209
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12277
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12210
12278
  let lastArr: Arr.NonEmptyReadonlyArray<A> | undefined
12211
12279
  let cause: Cause.Cause<Cause.Done | E> | undefined
12212
12280
  let emitAtMs = Infinity
12213
- const pullLatch = Effect.makeLatchUnsafe()
12214
- const emitLatch = Effect.makeLatchUnsafe()
12215
- const endLatch = Effect.makeLatchUnsafe()
12281
+ const pullLatch = Latch.makeUnsafe()
12282
+ const emitLatch = Latch.makeUnsafe()
12283
+ const endLatch = Latch.makeUnsafe()
12216
12284
 
12217
12285
  yield* pull.pipe(
12218
12286
  pullLatch.whenOpen,
@@ -12346,7 +12414,7 @@ export const throttleEffect: {
12346
12414
  options: {
12347
12415
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12348
12416
  readonly units: number
12349
- readonly duration: Duration.DurationInput
12417
+ readonly duration: Duration.Input
12350
12418
  readonly burst?: number | undefined
12351
12419
  readonly strategy?: "enforce" | "shape" | undefined
12352
12420
  }
@@ -12392,7 +12460,7 @@ export const throttleEffect: {
12392
12460
  options: {
12393
12461
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12394
12462
  readonly units: number
12395
- readonly duration: Duration.DurationInput
12463
+ readonly duration: Duration.Input
12396
12464
  readonly burst?: number | undefined
12397
12465
  readonly strategy?: "enforce" | "shape" | undefined
12398
12466
  }
@@ -12404,7 +12472,7 @@ export const throttleEffect: {
12404
12472
  options: {
12405
12473
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12406
12474
  readonly units: number
12407
- readonly duration: Duration.DurationInput
12475
+ readonly duration: Duration.Input
12408
12476
  readonly burst?: number | undefined
12409
12477
  readonly strategy?: "enforce" | "shape" | undefined
12410
12478
  }
@@ -12421,12 +12489,12 @@ const throttleEnforceEffect = <A, E, R, E2, R2>(
12421
12489
  self: Stream<A, E, R>,
12422
12490
  cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
12423
12491
  units: number,
12424
- duration: Duration.DurationInput,
12492
+ duration: Duration.Input,
12425
12493
  burst: number
12426
12494
  ): Stream<A, E | E2, R | R2> =>
12427
12495
  transformPull(self, (pull) =>
12428
12496
  Effect.clockWith((clock) => {
12429
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12497
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12430
12498
  const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
12431
12499
  let tokens = units
12432
12500
  let timestampMs = clock.currentTimeMillisUnsafe()
@@ -12457,12 +12525,12 @@ const throttleShapeEffect = <A, E, R, E2, R2>(
12457
12525
  self: Stream<A, E, R>,
12458
12526
  cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
12459
12527
  units: number,
12460
- duration: Duration.DurationInput,
12528
+ duration: Duration.Input,
12461
12529
  burst: number
12462
12530
  ): Stream<A, E | E2, R | R2> =>
12463
12531
  transformPull(self, (pull) =>
12464
12532
  Effect.clockWith((clock) => {
12465
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12533
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12466
12534
  const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
12467
12535
  let tokens = units
12468
12536
  let timestampMs = clock.currentTimeMillisUnsafe()
@@ -12575,7 +12643,7 @@ export const throttle: {
12575
12643
  options: {
12576
12644
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12577
12645
  readonly units: number
12578
- readonly duration: Duration.DurationInput
12646
+ readonly duration: Duration.Input
12579
12647
  readonly burst?: number | undefined
12580
12648
  readonly strategy?: "enforce" | "shape" | undefined
12581
12649
  }
@@ -12620,7 +12688,7 @@ export const throttle: {
12620
12688
  options: {
12621
12689
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12622
12690
  readonly units: number
12623
- readonly duration: Duration.DurationInput
12691
+ readonly duration: Duration.Input
12624
12692
  readonly burst?: number | undefined
12625
12693
  readonly strategy?: "enforce" | "shape" | undefined
12626
12694
  }
@@ -12632,7 +12700,7 @@ export const throttle: {
12632
12700
  options: {
12633
12701
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12634
12702
  readonly units: number
12635
- readonly duration: Duration.DurationInput
12703
+ readonly duration: Duration.Input
12636
12704
  readonly burst?: number | undefined
12637
12705
  readonly strategy?: "enforce" | "shape" | undefined
12638
12706
  }
@@ -12770,7 +12838,7 @@ export const groupedWithin: {
12770
12838
  * @since 2.0.0
12771
12839
  * @category Grouping
12772
12840
  */
12773
- (chunkSize: number, duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
12841
+ (chunkSize: number, duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
12774
12842
  /**
12775
12843
  * Partitions the stream into arrays, emitting when the chunk size is reached
12776
12844
  * or the duration passes.
@@ -12794,11 +12862,11 @@ export const groupedWithin: {
12794
12862
  * @since 2.0.0
12795
12863
  * @category Grouping
12796
12864
  */
12797
- <A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.DurationInput): Stream<Array<A>, E, R>
12865
+ <A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.Input): Stream<Array<A>, E, R>
12798
12866
  } = dual(3, <A, E, R>(
12799
12867
  self: Stream<A, E, R>,
12800
12868
  chunkSize: number,
12801
- duration: Duration.DurationInput
12869
+ duration: Duration.Input
12802
12870
  ): Stream<Array<A>, E, R> =>
12803
12871
  aggregateWithin(
12804
12872
  self,
@@ -12873,7 +12941,7 @@ export const groupBy: {
12873
12941
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12874
12942
  options?: {
12875
12943
  readonly bufferSize?: number | undefined
12876
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12944
+ readonly idleTimeToLive?: Duration.Input | undefined
12877
12945
  }
12878
12946
  ): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<V>], E | E2, R | R2>
12879
12947
  /**
@@ -12912,7 +12980,7 @@ export const groupBy: {
12912
12980
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12913
12981
  options?: {
12914
12982
  readonly bufferSize?: number | undefined
12915
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12983
+ readonly idleTimeToLive?: Duration.Input | undefined
12916
12984
  }
12917
12985
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2>
12918
12986
  } = dual((args) => isStream(args[0]), <A, E, R, K, V, E2, R2>(
@@ -12920,7 +12988,7 @@ export const groupBy: {
12920
12988
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12921
12989
  options?: {
12922
12990
  readonly bufferSize?: number | undefined
12923
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12991
+ readonly idleTimeToLive?: Duration.Input | undefined
12924
12992
  }
12925
12993
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
12926
12994
  groupByImpl(
@@ -13002,7 +13070,7 @@ export const groupByKey: {
13002
13070
  f: (a: NoInfer<A>) => K,
13003
13071
  options?: {
13004
13072
  readonly bufferSize?: number | undefined
13005
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13073
+ readonly idleTimeToLive?: Duration.Input | undefined
13006
13074
  }
13007
13075
  ): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<A>], E, R>
13008
13076
  /**
@@ -13039,7 +13107,7 @@ export const groupByKey: {
13039
13107
  f: (a: NoInfer<A>) => K,
13040
13108
  options?: {
13041
13109
  readonly bufferSize?: number | undefined
13042
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13110
+ readonly idleTimeToLive?: Duration.Input | undefined
13043
13111
  }
13044
13112
  ): Stream<readonly [K, Stream<A>], E, R>
13045
13113
  } = dual((args) => isStream(args[0]), <A, E, R, K>(
@@ -13047,7 +13115,7 @@ export const groupByKey: {
13047
13115
  f: (a: NoInfer<A>) => K,
13048
13116
  options?: {
13049
13117
  readonly bufferSize?: number | undefined
13050
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13118
+ readonly idleTimeToLive?: Duration.Input | undefined
13051
13119
  }
13052
13120
  ): Stream<readonly [K, Stream<A>], E, R> =>
13053
13121
  suspend(() => {
@@ -13145,7 +13213,7 @@ const groupByImpl = <A, E, R, K, V, E2, R2>(
13145
13213
  ) => Effect.Effect<void, E2, R2>,
13146
13214
  options?: {
13147
13215
  readonly bufferSize?: number | undefined
13148
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13216
+ readonly idleTimeToLive?: Duration.Input | undefined
13149
13217
  }
13150
13218
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
13151
13219
  transformPullBracket(
@@ -13537,7 +13605,7 @@ export const aggregateWithin: {
13537
13605
  fromChannel(Channel.fromTransformBracket(Effect.fnUntraced(function*(_upstream, _, scope) {
13538
13606
  const pull = yield* Channel.toPullScoped(self.channel, _)
13539
13607
 
13540
- const pullLatch = Effect.makeLatchUnsafe(false)
13608
+ const pullLatch = Latch.makeUnsafe(false)
13541
13609
  const scheduleStep = Symbol()
13542
13610
  const buffer = yield* Queue.make</**
13543
13611
  * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
@@ -13637,12 +13705,15 @@ export const aggregateWithin: {
13637
13705
  * @category Aggregation
13638
13706
  */
13639
13707
  B>()
13708
+ let leftover: Arr.NonEmptyReadonlyArray<A2> | undefined
13640
13709
  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
- )
13710
+ const stepToBuffer = Effect.suspend(function loop(): Pull.Pull<never, E3, void, R3> {
13711
+ return step(lastOutput).pipe(
13712
+ Effect.flatMap(() => !hadChunk && leftover === undefined ? loop() : Queue.offer(buffer, scheduleStep)),
13713
+ Effect.flatMap(() => Effect.never),
13714
+ Pull.catchDone(() => Cause.done())
13715
+ )
13716
+ })
13646
13717
 
13647
13718
  // buffer -> sink
13648
13719
  const pullFromBuffer: Pull.Pull<
@@ -13652,7 +13723,6 @@ export const aggregateWithin: {
13652
13723
  Effect.flatMap((arr) => arr === scheduleStep ? Cause.done() : Effect.succeed(arr))
13653
13724
  )
13654
13725
 
13655
- let leftover: Arr.NonEmptyReadonlyArray<A2> | undefined
13656
13726
  const sinkUpstream = Effect.suspend((): Pull.Pull<Arr.NonEmptyReadonlyArray<A | A2>, E> => {
13657
13727
  if (leftover !== undefined) {
13658
13728
  const chunk = leftover
@@ -13664,7 +13734,7 @@ export const aggregateWithin: {
13664
13734
  return pullFromBuffer
13665
13735
  })
13666
13736
  const catchSinkHalt = Effect.flatMap(([value, leftover_]: Sink.End<B, A2>) => {
13667
- // ignore the last output if the upsteam only pulled a halt
13737
+ // ignore the last output if the upstream only pulled a halt
13668
13738
  if (!hadChunk && buffer.state._tag === "Done") return Cause.done()
13669
13739
  lastOutput = Option.some(value)
13670
13740
  leftover = leftover_
@@ -13879,12 +13949,12 @@ export const share: {
13879
13949
  options: {
13880
13950
  readonly capacity: "unbounded"
13881
13951
  readonly replay?: number | undefined
13882
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13952
+ readonly idleTimeToLive?: Duration.Input | undefined
13883
13953
  } | {
13884
13954
  readonly capacity: number
13885
13955
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13886
13956
  readonly replay?: number | undefined
13887
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13957
+ readonly idleTimeToLive?: Duration.Input | undefined
13888
13958
  }
13889
13959
  ): <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
13890
13960
  /**
@@ -13923,12 +13993,12 @@ export const share: {
13923
13993
  options: {
13924
13994
  readonly capacity: "unbounded"
13925
13995
  readonly replay?: number | undefined
13926
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13996
+ readonly idleTimeToLive?: Duration.Input | undefined
13927
13997
  } | {
13928
13998
  readonly capacity: number
13929
13999
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13930
14000
  readonly replay?: number | undefined
13931
- readonly idleTimeToLive?: Duration.DurationInput | undefined
14001
+ readonly idleTimeToLive?: Duration.Input | undefined
13932
14002
  }
13933
14003
  ): Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
13934
14004
  } = dual(2, <A, E, R>(
@@ -13936,12 +14006,12 @@ export const share: {
13936
14006
  options: {
13937
14007
  readonly capacity: "unbounded"
13938
14008
  readonly replay?: number | undefined
13939
- readonly idleTimeToLive?: Duration.DurationInput | undefined
14009
+ readonly idleTimeToLive?: Duration.Input | undefined
13940
14010
  } | {
13941
14011
  readonly capacity: number
13942
14012
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13943
14013
  readonly replay?: number | undefined
13944
- readonly idleTimeToLive?: Duration.DurationInput | undefined
14014
+ readonly idleTimeToLive?: Duration.Input | undefined
13945
14015
  }
13946
14016
  ): Effect.Effect<Stream<A, E>, never, Scope.Scope | R> =>
13947
14017
  Effect.map(
@@ -16121,7 +16191,7 @@ export const provideService: {
16121
16191
  * @since 4.0.0
16122
16192
  * @category Services
16123
16193
  */
16124
- <I, S>(key: ServiceMap.Service<I, S>, service: NoInfer<S>): <A, E, R>(
16194
+ <I, S>(key: ServiceMap.Key<I, S>, service: NoInfer<S>): <A, E, R>(
16125
16195
  self: Stream<A, E, R>
16126
16196
  ) => Stream<A, E, Exclude<R, I>>
16127
16197
  /**
@@ -16160,10 +16230,10 @@ export const provideService: {
16160
16230
  * @since 4.0.0
16161
16231
  * @category Services
16162
16232
  */
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>>
16233
+ <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
16234
  } = dual(3, <A, E, R, I, S>(
16165
16235
  self: Stream<A, E, R>,
16166
- key: ServiceMap.Service<I, S>,
16236
+ key: ServiceMap.Key<I, S>,
16167
16237
  service: NoInfer<S>
16168
16238
  ): Stream<A, E, Exclude<R, I>> => fromChannel(Channel.provideService(self.channel, key, service)))
16169
16239
 
@@ -16244,7 +16314,7 @@ export const provideServiceEffect: {
16244
16314
  * @since 4.0.0
16245
16315
  * @category Services
16246
16316
  */
16247
- <I, S, ES, RS>(key: ServiceMap.Service<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <A, E, R>(
16317
+ <I, S, ES, RS>(key: ServiceMap.Key<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <A, E, R>(
16248
16318
  self: Stream<A, E, R>
16249
16319
  ) => Stream<A, E | ES, Exclude<R, I> | RS>
16250
16320
  /**
@@ -16287,12 +16357,12 @@ export const provideServiceEffect: {
16287
16357
  */
16288
16358
  <A, E, R, I, S, ES, RS>(
16289
16359
  self: Stream<A, E, R>,
16290
- key: ServiceMap.Service<I, S>,
16360
+ key: ServiceMap.Key<I, S>,
16291
16361
  service: Effect.Effect<NoInfer<S>, ES, RS>
16292
16362
  ): Stream<A, E | ES, Exclude<R, I> | RS>
16293
16363
  } = dual(3, <A, E, R, I, S, ES, RS>(
16294
16364
  self: Stream<A, E, R>,
16295
- key: ServiceMap.Service<I, S>,
16365
+ key: ServiceMap.Key<I, S>,
16296
16366
  service: Effect.Effect<NoInfer<S>, ES, RS>
16297
16367
  ): Stream<A, E | ES, Exclude<R, I> | RS> => fromChannel(Channel.provideServiceEffect(self.channel, key, service)))
16298
16368
 
@@ -16477,7 +16547,7 @@ export const updateService: {
16477
16547
  * @since 2.0.0
16478
16548
  * @category Services
16479
16549
  */
16480
- <I, S>(key: ServiceMap.Service<I, S>, f: (service: NoInfer<S>) => S): <A, E, R>(
16550
+ <I, S>(key: ServiceMap.Key<I, S>, f: (service: NoInfer<S>) => S): <A, E, R>(
16481
16551
  self: Stream<A, E, R>
16482
16552
  ) => Stream<A, E, R | I>
16483
16553
  /**
@@ -16507,12 +16577,12 @@ export const updateService: {
16507
16577
  */
16508
16578
  <A, E, R, I, S>(
16509
16579
  self: Stream<A, E, R>,
16510
- key: ServiceMap.Service<I, S>,
16580
+ key: ServiceMap.Key<I, S>,
16511
16581
  f: (service: NoInfer<S>) => S
16512
16582
  ): Stream<A, E, R | I>
16513
16583
  } = dual(3, <A, E, R, I, S>(
16514
16584
  self: Stream<A, E, R>,
16515
- service: ServiceMap.Service<I, S>,
16585
+ service: ServiceMap.Key<I, S>,
16516
16586
  f: (service: NoInfer<S>) => S
16517
16587
  ): Stream<A, E, R | I> =>
16518
16588
  updateServices(self, (services) =>
@@ -16591,7 +16661,7 @@ export const withSpan: {
16591
16661
  } = function() {
16592
16662
  const dataFirst = isStream(arguments[0])
16593
16663
  const name = dataFirst ? arguments[1] : arguments[0]
16594
- const options = addSpanStackTrace(dataFirst ? arguments[1] : arguments[2])
16664
+ const options = addSpanStackTrace(dataFirst ? arguments[2] : arguments[1])
16595
16665
  if (dataFirst) {
16596
16666
  const self = arguments[0] as Stream<any, any, any>
16597
16667
  return fromChannel(Channel.withSpan(self.channel, name, options))
@@ -17747,7 +17817,7 @@ export const toReadableStreamWith = dual<
17747
17817
  ): ReadableStream<A> => {
17748
17818
  let currentResolve: (() => void) | undefined = undefined
17749
17819
  let fiber: Fiber.Fiber<void, E> | undefined = undefined
17750
- const latch = Effect.makeLatchUnsafe(false)
17820
+ const latch = Latch.makeUnsafe(false)
17751
17821
 
17752
17822
  return new ReadableStream<A>({
17753
17823
  start(controller) {