effect 3.8.4 → 3.8.5

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 (595) hide show
  1. package/dist/cjs/Array.js.map +1 -1
  2. package/dist/cjs/BigDecimal.js +2 -3
  3. package/dist/cjs/BigDecimal.js.map +1 -1
  4. package/dist/cjs/BigInt.js.map +1 -1
  5. package/dist/cjs/Boolean.js.map +1 -1
  6. package/dist/cjs/Cause.js.map +1 -1
  7. package/dist/cjs/Channel.js.map +1 -1
  8. package/dist/cjs/ChildExecutorDecision.js.map +1 -1
  9. package/dist/cjs/Chunk.js.map +1 -1
  10. package/dist/cjs/Config.js.map +1 -1
  11. package/dist/cjs/ConfigError.js.map +1 -1
  12. package/dist/cjs/ConfigProvider.js.map +1 -1
  13. package/dist/cjs/ConfigProviderPathPatch.js.map +1 -1
  14. package/dist/cjs/Console.js.map +1 -1
  15. package/dist/cjs/Context.js.map +1 -1
  16. package/dist/cjs/Cron.js.map +1 -1
  17. package/dist/cjs/Data.js.map +1 -1
  18. package/dist/cjs/DateTime.js.map +1 -1
  19. package/dist/cjs/Deferred.js.map +1 -1
  20. package/dist/cjs/Differ.js.map +1 -1
  21. package/dist/cjs/Duration.js.map +1 -1
  22. package/dist/cjs/Effect.js.map +1 -1
  23. package/dist/cjs/Either.js.map +1 -1
  24. package/dist/cjs/Equivalence.js.map +1 -1
  25. package/dist/cjs/ExecutionStrategy.js.map +1 -1
  26. package/dist/cjs/Exit.js.map +1 -1
  27. package/dist/cjs/Fiber.js.map +1 -1
  28. package/dist/cjs/FiberHandle.js.map +1 -1
  29. package/dist/cjs/FiberId.js.map +1 -1
  30. package/dist/cjs/FiberMap.js.map +1 -1
  31. package/dist/cjs/FiberRef.js.map +1 -1
  32. package/dist/cjs/FiberRefs.js.map +1 -1
  33. package/dist/cjs/FiberRefsPatch.js.map +1 -1
  34. package/dist/cjs/FiberSet.js.map +1 -1
  35. package/dist/cjs/Function.js.map +1 -1
  36. package/dist/cjs/GroupBy.js.map +1 -1
  37. package/dist/cjs/Hash.js.map +1 -1
  38. package/dist/cjs/HashMap.js.map +1 -1
  39. package/dist/cjs/HashSet.js.map +1 -1
  40. package/dist/cjs/Iterable.js.map +1 -1
  41. package/dist/cjs/KeyedPool.js.map +1 -1
  42. package/dist/cjs/Layer.js.map +1 -1
  43. package/dist/cjs/List.js.map +1 -1
  44. package/dist/cjs/LogLevel.js.map +1 -1
  45. package/dist/cjs/Logger.js.map +1 -1
  46. package/dist/cjs/Mailbox.js.map +1 -1
  47. package/dist/cjs/MergeDecision.js.map +1 -1
  48. package/dist/cjs/MergeState.js.map +1 -1
  49. package/dist/cjs/MergeStrategy.js.map +1 -1
  50. package/dist/cjs/Metric.js.map +1 -1
  51. package/dist/cjs/MetricHook.js.map +1 -1
  52. package/dist/cjs/MetricKey.js.map +1 -1
  53. package/dist/cjs/MetricPolling.js.map +1 -1
  54. package/dist/cjs/MetricState.js.map +1 -1
  55. package/dist/cjs/Micro.js.map +1 -1
  56. package/dist/cjs/MutableHashMap.js.map +1 -1
  57. package/dist/cjs/MutableHashSet.js.map +1 -1
  58. package/dist/cjs/MutableList.js.map +1 -1
  59. package/dist/cjs/MutableQueue.js.map +1 -1
  60. package/dist/cjs/MutableRef.js.map +1 -1
  61. package/dist/cjs/Number.js.map +1 -1
  62. package/dist/cjs/Option.js.map +1 -1
  63. package/dist/cjs/Order.js.map +1 -1
  64. package/dist/cjs/Ordering.js.map +1 -1
  65. package/dist/cjs/Pipeable.js.map +1 -1
  66. package/dist/cjs/Pool.js.map +1 -1
  67. package/dist/cjs/Predicate.js.map +1 -1
  68. package/dist/cjs/PubSub.js.map +1 -1
  69. package/dist/cjs/Queue.js.map +1 -1
  70. package/dist/cjs/RcMap.js.map +1 -1
  71. package/dist/cjs/Readable.js.map +1 -1
  72. package/dist/cjs/Record.js.map +1 -1
  73. package/dist/cjs/RedBlackTree.js.map +1 -1
  74. package/dist/cjs/Ref.js.map +1 -1
  75. package/dist/cjs/Request.js.map +1 -1
  76. package/dist/cjs/RequestResolver.js.map +1 -1
  77. package/dist/cjs/Runtime.js.map +1 -1
  78. package/dist/cjs/RuntimeFlags.js.map +1 -1
  79. package/dist/cjs/RuntimeFlagsPatch.js.map +1 -1
  80. package/dist/cjs/STM.js.map +1 -1
  81. package/dist/cjs/Schedule.js.map +1 -1
  82. package/dist/cjs/ScheduleInterval.js.map +1 -1
  83. package/dist/cjs/ScheduleIntervals.js.map +1 -1
  84. package/dist/cjs/Scheduler.js.map +1 -1
  85. package/dist/cjs/Scope.js.map +1 -1
  86. package/dist/cjs/ScopedRef.js.map +1 -1
  87. package/dist/cjs/Sink.js.map +1 -1
  88. package/dist/cjs/SortedMap.js.map +1 -1
  89. package/dist/cjs/SortedSet.js.map +1 -1
  90. package/dist/cjs/Stream.js +17 -3
  91. package/dist/cjs/Stream.js.map +1 -1
  92. package/dist/cjs/StreamHaltStrategy.js.map +1 -1
  93. package/dist/cjs/String.js.map +1 -1
  94. package/dist/cjs/Struct.js.map +1 -1
  95. package/dist/cjs/Subscribable.js.map +1 -1
  96. package/dist/cjs/SubscriptionRef.js.map +1 -1
  97. package/dist/cjs/SynchronizedRef.js.map +1 -1
  98. package/dist/cjs/TArray.js.map +1 -1
  99. package/dist/cjs/TDeferred.js.map +1 -1
  100. package/dist/cjs/TMap.js.map +1 -1
  101. package/dist/cjs/TPriorityQueue.js.map +1 -1
  102. package/dist/cjs/TPubSub.js.map +1 -1
  103. package/dist/cjs/TQueue.js.map +1 -1
  104. package/dist/cjs/TReentrantLock.js.map +1 -1
  105. package/dist/cjs/TRef.js.map +1 -1
  106. package/dist/cjs/TSemaphore.js.map +1 -1
  107. package/dist/cjs/TSet.js.map +1 -1
  108. package/dist/cjs/Take.js.map +1 -1
  109. package/dist/cjs/TestAnnotationMap.js.map +1 -1
  110. package/dist/cjs/TestClock.js.map +1 -1
  111. package/dist/cjs/TestServices.js.map +1 -1
  112. package/dist/cjs/Trie.js.map +1 -1
  113. package/dist/cjs/Tuple.js.map +1 -1
  114. package/dist/cjs/Unify.js.map +1 -1
  115. package/dist/cjs/UpstreamPullRequest.js.map +1 -1
  116. package/dist/cjs/UpstreamPullStrategy.js.map +1 -1
  117. package/dist/cjs/Utils.js +1 -14
  118. package/dist/cjs/Utils.js.map +1 -1
  119. package/dist/cjs/internal/core.js +4 -3
  120. package/dist/cjs/internal/core.js.map +1 -1
  121. package/dist/cjs/internal/runtime.js +1 -1
  122. package/dist/cjs/internal/runtime.js.map +1 -1
  123. package/dist/cjs/internal/stream.js +12 -3
  124. package/dist/cjs/internal/stream.js.map +1 -1
  125. package/dist/cjs/internal/version.js +1 -1
  126. package/dist/dts/Array.d.ts +2684 -0
  127. package/dist/dts/Array.d.ts.map +1 -1
  128. package/dist/dts/BigDecimal.d.ts +558 -1
  129. package/dist/dts/BigDecimal.d.ts.map +1 -1
  130. package/dist/dts/BigInt.d.ts +490 -0
  131. package/dist/dts/BigInt.d.ts.map +1 -1
  132. package/dist/dts/Boolean.d.ts +228 -0
  133. package/dist/dts/Boolean.d.ts.map +1 -1
  134. package/dist/dts/Cause.d.ts +172 -0
  135. package/dist/dts/Cause.d.ts.map +1 -1
  136. package/dist/dts/Channel.d.ts +750 -0
  137. package/dist/dts/Channel.d.ts.map +1 -1
  138. package/dist/dts/ChildExecutorDecision.d.ts +12 -0
  139. package/dist/dts/ChildExecutorDecision.d.ts.map +1 -1
  140. package/dist/dts/Chunk.d.ts +791 -0
  141. package/dist/dts/Chunk.d.ts.map +1 -1
  142. package/dist/dts/Config.d.ts +174 -0
  143. package/dist/dts/Config.d.ts.map +1 -1
  144. package/dist/dts/ConfigError.d.ts +16 -0
  145. package/dist/dts/ConfigError.d.ts.map +1 -1
  146. package/dist/dts/ConfigProvider.d.ts +84 -0
  147. package/dist/dts/ConfigProvider.d.ts.map +1 -1
  148. package/dist/dts/ConfigProviderPathPatch.d.ts +32 -0
  149. package/dist/dts/ConfigProviderPathPatch.d.ts.map +1 -1
  150. package/dist/dts/Console.d.ts +24 -0
  151. package/dist/dts/Console.d.ts.map +1 -1
  152. package/dist/dts/Context.d.ts +232 -0
  153. package/dist/dts/Context.d.ts.map +1 -1
  154. package/dist/dts/Cron.d.ts +12 -0
  155. package/dist/dts/Cron.d.ts.map +1 -1
  156. package/dist/dts/Data.d.ts +165 -0
  157. package/dist/dts/Data.d.ts.map +1 -1
  158. package/dist/dts/DateTime.d.ts +878 -0
  159. package/dist/dts/DateTime.d.ts.map +1 -1
  160. package/dist/dts/Deferred.d.ts +170 -0
  161. package/dist/dts/Deferred.d.ts.map +1 -1
  162. package/dist/dts/Differ.d.ts +78 -0
  163. package/dist/dts/Differ.d.ts.map +1 -1
  164. package/dist/dts/Duration.d.ts +130 -0
  165. package/dist/dts/Duration.d.ts.map +1 -1
  166. package/dist/dts/Effect.d.ts +4117 -3
  167. package/dist/dts/Effect.d.ts.map +1 -1
  168. package/dist/dts/Either.d.ts +620 -0
  169. package/dist/dts/Either.d.ts.map +1 -1
  170. package/dist/dts/Equivalence.d.ts +24 -0
  171. package/dist/dts/Equivalence.d.ts.map +1 -1
  172. package/dist/dts/ExecutionStrategy.d.ts +14 -0
  173. package/dist/dts/ExecutionStrategy.d.ts.map +1 -1
  174. package/dist/dts/Exit.d.ts +252 -0
  175. package/dist/dts/Exit.d.ts.map +1 -1
  176. package/dist/dts/Fiber.d.ts +182 -0
  177. package/dist/dts/Fiber.d.ts.map +1 -1
  178. package/dist/dts/FiberHandle.d.ts +42 -0
  179. package/dist/dts/FiberHandle.d.ts.map +1 -1
  180. package/dist/dts/FiberId.d.ts +24 -0
  181. package/dist/dts/FiberId.d.ts.map +1 -1
  182. package/dist/dts/FiberMap.d.ts +102 -0
  183. package/dist/dts/FiberMap.d.ts.map +1 -1
  184. package/dist/dts/FiberRef.d.ts +80 -0
  185. package/dist/dts/FiberRef.d.ts.map +1 -1
  186. package/dist/dts/FiberRefs.d.ts +84 -0
  187. package/dist/dts/FiberRefs.d.ts.map +1 -1
  188. package/dist/dts/FiberRefsPatch.d.ts +30 -0
  189. package/dist/dts/FiberRefsPatch.d.ts.map +1 -1
  190. package/dist/dts/FiberSet.d.ts +38 -0
  191. package/dist/dts/FiberSet.d.ts.map +1 -1
  192. package/dist/dts/Function.d.ts +144 -28
  193. package/dist/dts/Function.d.ts.map +1 -1
  194. package/dist/dts/GroupBy.d.ts +38 -0
  195. package/dist/dts/GroupBy.d.ts.map +1 -1
  196. package/dist/dts/Hash.d.ts +8 -0
  197. package/dist/dts/Hash.d.ts.map +1 -1
  198. package/dist/dts/HashMap.d.ts +300 -0
  199. package/dist/dts/HashMap.d.ts.map +1 -1
  200. package/dist/dts/HashSet.d.ts +284 -0
  201. package/dist/dts/HashSet.d.ts.map +1 -1
  202. package/dist/dts/Iterable.d.ts +454 -0
  203. package/dist/dts/Iterable.d.ts.map +1 -1
  204. package/dist/dts/KeyedPool.d.ts +34 -0
  205. package/dist/dts/KeyedPool.d.ts.map +1 -1
  206. package/dist/dts/Layer.d.ts +414 -0
  207. package/dist/dts/Layer.d.ts.map +1 -1
  208. package/dist/dts/List.d.ts +430 -0
  209. package/dist/dts/List.d.ts.map +1 -1
  210. package/dist/dts/LogLevel.d.ts +46 -0
  211. package/dist/dts/LogLevel.d.ts.map +1 -1
  212. package/dist/dts/Logger.d.ts +194 -0
  213. package/dist/dts/Logger.d.ts.map +1 -1
  214. package/dist/dts/Mailbox.d.ts +16 -0
  215. package/dist/dts/Mailbox.d.ts.map +1 -1
  216. package/dist/dts/MergeDecision.d.ts +8 -0
  217. package/dist/dts/MergeDecision.d.ts.map +1 -1
  218. package/dist/dts/MergeState.d.ts +8 -0
  219. package/dist/dts/MergeState.d.ts.map +1 -1
  220. package/dist/dts/MergeStrategy.d.ts +12 -0
  221. package/dist/dts/MergeStrategy.d.ts.map +1 -1
  222. package/dist/dts/Metric.d.ts +410 -0
  223. package/dist/dts/Metric.d.ts.map +1 -1
  224. package/dist/dts/MetricHook.d.ts +24 -0
  225. package/dist/dts/MetricHook.d.ts.map +1 -1
  226. package/dist/dts/MetricKey.d.ts +48 -0
  227. package/dist/dts/MetricKey.d.ts.map +1 -1
  228. package/dist/dts/MetricPolling.d.ts +40 -0
  229. package/dist/dts/MetricPolling.d.ts.map +1 -1
  230. package/dist/dts/MetricState.d.ts +16 -0
  231. package/dist/dts/MetricState.d.ts.map +1 -1
  232. package/dist/dts/Micro.d.ts +1110 -0
  233. package/dist/dts/Micro.d.ts.map +1 -1
  234. package/dist/dts/MutableHashMap.d.ts +50 -0
  235. package/dist/dts/MutableHashMap.d.ts.map +1 -1
  236. package/dist/dts/MutableHashSet.d.ts +24 -0
  237. package/dist/dts/MutableHashSet.d.ts.map +1 -1
  238. package/dist/dts/MutableList.d.ts +36 -0
  239. package/dist/dts/MutableList.d.ts.map +1 -1
  240. package/dist/dts/MutableQueue.d.ts +62 -0
  241. package/dist/dts/MutableQueue.d.ts.map +1 -1
  242. package/dist/dts/MutableRef.d.ts +56 -0
  243. package/dist/dts/MutableRef.d.ts.map +1 -1
  244. package/dist/dts/Number.d.ts +474 -0
  245. package/dist/dts/Number.d.ts.map +1 -1
  246. package/dist/dts/Option.d.ts +1019 -0
  247. package/dist/dts/Option.d.ts.map +1 -1
  248. package/dist/dts/Order.d.ts +24 -0
  249. package/dist/dts/Order.d.ts.map +1 -1
  250. package/dist/dts/Ordering.d.ts +66 -0
  251. package/dist/dts/Ordering.d.ts.map +1 -1
  252. package/dist/dts/Pipeable.d.ts +21 -21
  253. package/dist/dts/Pipeable.d.ts.map +1 -1
  254. package/dist/dts/Pool.d.ts +16 -0
  255. package/dist/dts/Pool.d.ts.map +1 -1
  256. package/dist/dts/Predicate.d.ts +498 -0
  257. package/dist/dts/Predicate.d.ts.map +1 -1
  258. package/dist/dts/PubSub.d.ts +28 -0
  259. package/dist/dts/PubSub.d.ts.map +1 -1
  260. package/dist/dts/Queue.d.ts +104 -0
  261. package/dist/dts/Queue.d.ts.map +1 -1
  262. package/dist/dts/RcMap.d.ts +70 -0
  263. package/dist/dts/RcMap.d.ts.map +1 -1
  264. package/dist/dts/Readable.d.ts +16 -0
  265. package/dist/dts/Readable.d.ts.map +1 -1
  266. package/dist/dts/Record.d.ts +800 -0
  267. package/dist/dts/Record.d.ts.map +1 -1
  268. package/dist/dts/RedBlackTree.d.ts +300 -0
  269. package/dist/dts/RedBlackTree.d.ts.map +1 -1
  270. package/dist/dts/Ref.d.ts +88 -0
  271. package/dist/dts/Ref.d.ts.map +1 -1
  272. package/dist/dts/Request.d.ts +76 -0
  273. package/dist/dts/Request.d.ts.map +1 -1
  274. package/dist/dts/RequestResolver.d.ts +144 -0
  275. package/dist/dts/RequestResolver.d.ts.map +1 -1
  276. package/dist/dts/Runtime.d.ts +126 -0
  277. package/dist/dts/Runtime.d.ts.map +1 -1
  278. package/dist/dts/RuntimeFlags.d.ts +100 -0
  279. package/dist/dts/RuntimeFlags.d.ts.map +1 -1
  280. package/dist/dts/RuntimeFlagsPatch.d.ts +112 -0
  281. package/dist/dts/RuntimeFlagsPatch.d.ts.map +1 -1
  282. package/dist/dts/STM.d.ts +1090 -0
  283. package/dist/dts/STM.d.ts.map +1 -1
  284. package/dist/dts/Schedule.d.ts +704 -0
  285. package/dist/dts/Schedule.d.ts.map +1 -1
  286. package/dist/dts/ScheduleInterval.d.ts +68 -0
  287. package/dist/dts/ScheduleInterval.d.ts.map +1 -1
  288. package/dist/dts/ScheduleIntervals.d.ts +50 -0
  289. package/dist/dts/ScheduleIntervals.d.ts.map +1 -1
  290. package/dist/dts/Scope.d.ts +36 -0
  291. package/dist/dts/Scope.d.ts.map +1 -1
  292. package/dist/dts/ScopedRef.d.ts +22 -0
  293. package/dist/dts/ScopedRef.d.ts.map +1 -1
  294. package/dist/dts/Sink.d.ts +464 -0
  295. package/dist/dts/Sink.d.ts.map +1 -1
  296. package/dist/dts/SortedMap.d.ts +76 -0
  297. package/dist/dts/SortedMap.d.ts.map +1 -1
  298. package/dist/dts/SortedSet.d.ts +142 -0
  299. package/dist/dts/SortedSet.d.ts.map +1 -1
  300. package/dist/dts/Stream.d.ts +4998 -1
  301. package/dist/dts/Stream.d.ts.map +1 -1
  302. package/dist/dts/StreamHaltStrategy.d.ts +12 -0
  303. package/dist/dts/StreamHaltStrategy.d.ts.map +1 -1
  304. package/dist/dts/String.d.ts +200 -0
  305. package/dist/dts/String.d.ts.map +1 -1
  306. package/dist/dts/Struct.d.ts +84 -0
  307. package/dist/dts/Struct.d.ts.map +1 -1
  308. package/dist/dts/Subscribable.d.ts +16 -0
  309. package/dist/dts/Subscribable.d.ts.map +1 -1
  310. package/dist/dts/SubscriptionRef.d.ts +152 -0
  311. package/dist/dts/SubscriptionRef.d.ts.map +1 -1
  312. package/dist/dts/SynchronizedRef.d.ts +152 -0
  313. package/dist/dts/SynchronizedRef.d.ts.map +1 -1
  314. package/dist/dts/TArray.d.ts +426 -0
  315. package/dist/dts/TArray.d.ts.map +1 -1
  316. package/dist/dts/TDeferred.d.ts +24 -0
  317. package/dist/dts/TDeferred.d.ts.map +1 -1
  318. package/dist/dts/TMap.d.ts +366 -0
  319. package/dist/dts/TMap.d.ts.map +1 -1
  320. package/dist/dts/TPriorityQueue.d.ts +60 -0
  321. package/dist/dts/TPriorityQueue.d.ts.map +1 -1
  322. package/dist/dts/TPubSub.d.ts +28 -0
  323. package/dist/dts/TPubSub.d.ts.map +1 -1
  324. package/dist/dts/TQueue.d.ts +108 -0
  325. package/dist/dts/TQueue.d.ts.map +1 -1
  326. package/dist/dts/TReentrantLock.d.ts +36 -0
  327. package/dist/dts/TReentrantLock.d.ts.map +1 -1
  328. package/dist/dts/TRef.d.ts +88 -0
  329. package/dist/dts/TRef.d.ts.map +1 -1
  330. package/dist/dts/TSemaphore.d.ts +40 -0
  331. package/dist/dts/TSemaphore.d.ts.map +1 -1
  332. package/dist/dts/TSet.d.ts +254 -0
  333. package/dist/dts/TSet.d.ts.map +1 -1
  334. package/dist/dts/Take.d.ts +56 -0
  335. package/dist/dts/Take.d.ts.map +1 -1
  336. package/dist/dts/TestAnnotationMap.d.ts.map +1 -1
  337. package/dist/dts/TestClock.d.ts.map +1 -1
  338. package/dist/dts/TestServices.d.ts.map +1 -1
  339. package/dist/dts/Trie.d.ts +906 -0
  340. package/dist/dts/Trie.d.ts.map +1 -1
  341. package/dist/dts/Tuple.d.ts +144 -0
  342. package/dist/dts/Tuple.d.ts.map +1 -1
  343. package/dist/dts/Unify.d.ts +18 -0
  344. package/dist/dts/Unify.d.ts.map +1 -1
  345. package/dist/dts/UpstreamPullRequest.d.ts +12 -0
  346. package/dist/dts/UpstreamPullRequest.d.ts.map +1 -1
  347. package/dist/dts/UpstreamPullStrategy.d.ts +12 -0
  348. package/dist/dts/UpstreamPullStrategy.d.ts.map +1 -1
  349. package/dist/dts/Utils.d.ts.map +1 -1
  350. package/dist/dts/internal/stream.d.ts.map +1 -1
  351. package/dist/esm/Array.js.map +1 -1
  352. package/dist/esm/BigDecimal.js +2 -2
  353. package/dist/esm/BigDecimal.js.map +1 -1
  354. package/dist/esm/BigInt.js.map +1 -1
  355. package/dist/esm/Boolean.js.map +1 -1
  356. package/dist/esm/Cause.js.map +1 -1
  357. package/dist/esm/Channel.js.map +1 -1
  358. package/dist/esm/ChildExecutorDecision.js.map +1 -1
  359. package/dist/esm/Chunk.js.map +1 -1
  360. package/dist/esm/Config.js.map +1 -1
  361. package/dist/esm/ConfigError.js.map +1 -1
  362. package/dist/esm/ConfigProvider.js.map +1 -1
  363. package/dist/esm/ConfigProviderPathPatch.js.map +1 -1
  364. package/dist/esm/Console.js.map +1 -1
  365. package/dist/esm/Context.js.map +1 -1
  366. package/dist/esm/Cron.js.map +1 -1
  367. package/dist/esm/Data.js.map +1 -1
  368. package/dist/esm/DateTime.js.map +1 -1
  369. package/dist/esm/Deferred.js.map +1 -1
  370. package/dist/esm/Differ.js.map +1 -1
  371. package/dist/esm/Duration.js.map +1 -1
  372. package/dist/esm/Effect.js.map +1 -1
  373. package/dist/esm/Either.js.map +1 -1
  374. package/dist/esm/Equivalence.js.map +1 -1
  375. package/dist/esm/ExecutionStrategy.js.map +1 -1
  376. package/dist/esm/Exit.js.map +1 -1
  377. package/dist/esm/Fiber.js.map +1 -1
  378. package/dist/esm/FiberHandle.js.map +1 -1
  379. package/dist/esm/FiberId.js.map +1 -1
  380. package/dist/esm/FiberMap.js.map +1 -1
  381. package/dist/esm/FiberRef.js.map +1 -1
  382. package/dist/esm/FiberRefs.js.map +1 -1
  383. package/dist/esm/FiberRefsPatch.js.map +1 -1
  384. package/dist/esm/FiberSet.js.map +1 -1
  385. package/dist/esm/Function.js.map +1 -1
  386. package/dist/esm/GroupBy.js.map +1 -1
  387. package/dist/esm/Hash.js.map +1 -1
  388. package/dist/esm/HashMap.js.map +1 -1
  389. package/dist/esm/HashSet.js.map +1 -1
  390. package/dist/esm/Iterable.js.map +1 -1
  391. package/dist/esm/KeyedPool.js.map +1 -1
  392. package/dist/esm/Layer.js.map +1 -1
  393. package/dist/esm/List.js.map +1 -1
  394. package/dist/esm/LogLevel.js.map +1 -1
  395. package/dist/esm/Logger.js.map +1 -1
  396. package/dist/esm/Mailbox.js.map +1 -1
  397. package/dist/esm/MergeDecision.js.map +1 -1
  398. package/dist/esm/MergeState.js.map +1 -1
  399. package/dist/esm/MergeStrategy.js.map +1 -1
  400. package/dist/esm/Metric.js.map +1 -1
  401. package/dist/esm/MetricHook.js.map +1 -1
  402. package/dist/esm/MetricKey.js.map +1 -1
  403. package/dist/esm/MetricPolling.js.map +1 -1
  404. package/dist/esm/MetricState.js.map +1 -1
  405. package/dist/esm/Micro.js.map +1 -1
  406. package/dist/esm/MutableHashMap.js.map +1 -1
  407. package/dist/esm/MutableHashSet.js.map +1 -1
  408. package/dist/esm/MutableList.js.map +1 -1
  409. package/dist/esm/MutableQueue.js.map +1 -1
  410. package/dist/esm/MutableRef.js.map +1 -1
  411. package/dist/esm/Number.js.map +1 -1
  412. package/dist/esm/Option.js.map +1 -1
  413. package/dist/esm/Order.js.map +1 -1
  414. package/dist/esm/Ordering.js.map +1 -1
  415. package/dist/esm/Pipeable.js.map +1 -1
  416. package/dist/esm/Pool.js.map +1 -1
  417. package/dist/esm/Predicate.js.map +1 -1
  418. package/dist/esm/PubSub.js.map +1 -1
  419. package/dist/esm/Queue.js.map +1 -1
  420. package/dist/esm/RcMap.js.map +1 -1
  421. package/dist/esm/Readable.js.map +1 -1
  422. package/dist/esm/Record.js.map +1 -1
  423. package/dist/esm/RedBlackTree.js.map +1 -1
  424. package/dist/esm/Ref.js.map +1 -1
  425. package/dist/esm/Request.js.map +1 -1
  426. package/dist/esm/RequestResolver.js.map +1 -1
  427. package/dist/esm/Runtime.js.map +1 -1
  428. package/dist/esm/RuntimeFlags.js.map +1 -1
  429. package/dist/esm/RuntimeFlagsPatch.js.map +1 -1
  430. package/dist/esm/STM.js.map +1 -1
  431. package/dist/esm/Schedule.js.map +1 -1
  432. package/dist/esm/ScheduleInterval.js.map +1 -1
  433. package/dist/esm/ScheduleIntervals.js.map +1 -1
  434. package/dist/esm/Scheduler.js.map +1 -1
  435. package/dist/esm/Scope.js.map +1 -1
  436. package/dist/esm/ScopedRef.js.map +1 -1
  437. package/dist/esm/Sink.js.map +1 -1
  438. package/dist/esm/SortedMap.js.map +1 -1
  439. package/dist/esm/SortedSet.js.map +1 -1
  440. package/dist/esm/Stream.js +14 -0
  441. package/dist/esm/Stream.js.map +1 -1
  442. package/dist/esm/StreamHaltStrategy.js.map +1 -1
  443. package/dist/esm/String.js.map +1 -1
  444. package/dist/esm/Struct.js.map +1 -1
  445. package/dist/esm/Subscribable.js.map +1 -1
  446. package/dist/esm/SubscriptionRef.js.map +1 -1
  447. package/dist/esm/SynchronizedRef.js.map +1 -1
  448. package/dist/esm/TArray.js.map +1 -1
  449. package/dist/esm/TDeferred.js.map +1 -1
  450. package/dist/esm/TMap.js.map +1 -1
  451. package/dist/esm/TPriorityQueue.js.map +1 -1
  452. package/dist/esm/TPubSub.js.map +1 -1
  453. package/dist/esm/TQueue.js.map +1 -1
  454. package/dist/esm/TReentrantLock.js.map +1 -1
  455. package/dist/esm/TRef.js.map +1 -1
  456. package/dist/esm/TSemaphore.js.map +1 -1
  457. package/dist/esm/TSet.js.map +1 -1
  458. package/dist/esm/Take.js.map +1 -1
  459. package/dist/esm/TestAnnotationMap.js.map +1 -1
  460. package/dist/esm/TestClock.js.map +1 -1
  461. package/dist/esm/TestServices.js.map +1 -1
  462. package/dist/esm/Trie.js.map +1 -1
  463. package/dist/esm/Tuple.js.map +1 -1
  464. package/dist/esm/Unify.js.map +1 -1
  465. package/dist/esm/UpstreamPullRequest.js.map +1 -1
  466. package/dist/esm/UpstreamPullStrategy.js.map +1 -1
  467. package/dist/esm/Utils.js +1 -14
  468. package/dist/esm/Utils.js.map +1 -1
  469. package/dist/esm/internal/core.js +1 -1
  470. package/dist/esm/internal/core.js.map +1 -1
  471. package/dist/esm/internal/runtime.js +1 -1
  472. package/dist/esm/internal/runtime.js.map +1 -1
  473. package/dist/esm/internal/stream.js +9 -0
  474. package/dist/esm/internal/stream.js.map +1 -1
  475. package/dist/esm/internal/version.js +1 -1
  476. package/package.json +1 -1
  477. package/src/Array.ts +2723 -36
  478. package/src/BigDecimal.ts +585 -18
  479. package/src/BigInt.ts +516 -16
  480. package/src/Boolean.ts +241 -8
  481. package/src/Cause.ts +177 -1
  482. package/src/Channel.ts +766 -49
  483. package/src/ChildExecutorDecision.ts +12 -0
  484. package/src/Chunk.ts +818 -4
  485. package/src/Config.ts +187 -8
  486. package/src/ConfigError.ts +16 -0
  487. package/src/ConfigProvider.ts +89 -1
  488. package/src/ConfigProviderPathPatch.ts +32 -0
  489. package/src/Console.ts +37 -8
  490. package/src/Context.ts +232 -0
  491. package/src/Cron.ts +12 -0
  492. package/src/Data.ts +165 -0
  493. package/src/DateTime.ts +1006 -50
  494. package/src/Deferred.ts +170 -0
  495. package/src/Differ.ts +89 -27
  496. package/src/Duration.ts +156 -16
  497. package/src/Effect.ts +4297 -123
  498. package/src/Either.ts +650 -34
  499. package/src/Equivalence.ts +24 -0
  500. package/src/ExecutionStrategy.ts +29 -10
  501. package/src/Exit.ts +252 -0
  502. package/src/Fiber.ts +182 -0
  503. package/src/FiberHandle.ts +42 -0
  504. package/src/FiberId.ts +24 -0
  505. package/src/FiberMap.ts +144 -21
  506. package/src/FiberRef.ts +80 -0
  507. package/src/FiberRefs.ts +84 -0
  508. package/src/FiberRefsPatch.ts +35 -1
  509. package/src/FiberSet.ts +38 -0
  510. package/src/Function.ts +416 -31
  511. package/src/GroupBy.ts +38 -0
  512. package/src/Hash.ts +8 -0
  513. package/src/HashMap.ts +300 -0
  514. package/src/HashSet.ts +284 -0
  515. package/src/Iterable.ts +456 -6
  516. package/src/KeyedPool.ts +34 -0
  517. package/src/Layer.ts +426 -30
  518. package/src/List.ts +476 -3
  519. package/src/LogLevel.ts +46 -0
  520. package/src/Logger.ts +195 -4
  521. package/src/Mailbox.ts +16 -0
  522. package/src/MergeDecision.ts +8 -0
  523. package/src/MergeState.ts +8 -0
  524. package/src/MergeStrategy.ts +25 -8
  525. package/src/Metric.ts +426 -15
  526. package/src/MetricHook.ts +24 -0
  527. package/src/MetricKey.ts +62 -8
  528. package/src/MetricPolling.ts +42 -6
  529. package/src/MetricState.ts +16 -0
  530. package/src/Micro.ts +1212 -56
  531. package/src/MutableHashMap.ts +105 -1
  532. package/src/MutableHashSet.ts +24 -0
  533. package/src/MutableList.ts +36 -0
  534. package/src/MutableQueue.ts +62 -0
  535. package/src/MutableRef.ts +56 -0
  536. package/src/Number.ts +500 -16
  537. package/src/Option.ts +1042 -16
  538. package/src/Order.ts +24 -0
  539. package/src/Ordering.ts +66 -0
  540. package/src/Pipeable.ts +224 -21
  541. package/src/Pool.ts +16 -0
  542. package/src/Predicate.ts +498 -0
  543. package/src/PubSub.ts +28 -0
  544. package/src/Queue.ts +104 -0
  545. package/src/RcMap.ts +70 -0
  546. package/src/Readable.ts +18 -7
  547. package/src/Record.ts +814 -40
  548. package/src/RedBlackTree.ts +305 -1
  549. package/src/Ref.ts +88 -0
  550. package/src/Request.ts +76 -0
  551. package/src/RequestResolver.ts +145 -4
  552. package/src/Runtime.ts +134 -2
  553. package/src/RuntimeFlags.ts +100 -0
  554. package/src/RuntimeFlagsPatch.ts +112 -0
  555. package/src/STM.ts +1107 -11
  556. package/src/Schedule.ts +704 -0
  557. package/src/ScheduleInterval.ts +68 -0
  558. package/src/ScheduleIntervals.ts +50 -0
  559. package/src/Scheduler.ts +2 -0
  560. package/src/Scope.ts +36 -0
  561. package/src/ScopedRef.ts +22 -0
  562. package/src/Sink.ts +464 -0
  563. package/src/SortedMap.ts +76 -0
  564. package/src/SortedSet.ts +143 -3
  565. package/src/Stream.ts +5041 -54
  566. package/src/StreamHaltStrategy.ts +29 -12
  567. package/src/String.ts +200 -0
  568. package/src/Struct.ts +86 -7
  569. package/src/Subscribable.ts +16 -0
  570. package/src/SubscriptionRef.ts +159 -11
  571. package/src/SynchronizedRef.ts +169 -8
  572. package/src/TArray.ts +431 -1
  573. package/src/TDeferred.ts +24 -0
  574. package/src/TMap.ts +381 -12
  575. package/src/TPriorityQueue.ts +60 -0
  576. package/src/TPubSub.ts +28 -0
  577. package/src/TQueue.ts +108 -0
  578. package/src/TReentrantLock.ts +36 -0
  579. package/src/TRef.ts +88 -0
  580. package/src/TSemaphore.ts +40 -0
  581. package/src/TSet.ts +280 -12
  582. package/src/Take.ts +56 -0
  583. package/src/TestAnnotationMap.ts +45 -1
  584. package/src/TestClock.ts +6 -0
  585. package/src/TestServices.ts +66 -0
  586. package/src/Trie.ts +906 -0
  587. package/src/Tuple.ts +157 -8
  588. package/src/Unify.ts +19 -3
  589. package/src/UpstreamPullRequest.ts +12 -0
  590. package/src/UpstreamPullStrategy.ts +12 -0
  591. package/src/Utils.ts +1 -15
  592. package/src/internal/core.ts +1 -1
  593. package/src/internal/runtime.ts +1 -1
  594. package/src/internal/stream.ts +27 -0
  595. package/src/internal/version.ts +1 -1
package/src/Option.ts CHANGED
@@ -193,14 +193,67 @@ export const isSome: <A>(self: Option<A>) => self is Some<A> = option.isSome
193
193
  * @since 2.0.0
194
194
  */
195
195
  export const match: {
196
- <B, A, C = B>(options: {
197
- readonly onNone: LazyArg<B>
198
- readonly onSome: (a: A) => C
199
- }): (self: Option<A>) => B | C
200
- <A, B, C = B>(self: Option<A>, options: {
201
- readonly onNone: LazyArg<B>
202
- readonly onSome: (a: A) => C
203
- }): B | C
196
+ /**
197
+ * Matches the given `Option` and returns either the provided `onNone` value or the result of the provided `onSome`
198
+ * function when passed the `Option`'s value.
199
+ *
200
+ * @param self - The `Option` to match
201
+ * @param onNone - The value to be returned if the `Option` is `None`
202
+ * @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned
203
+ *
204
+ * @example
205
+ * import { pipe, Option } from "effect"
206
+ *
207
+ * assert.deepStrictEqual(
208
+ * pipe(Option.some(1), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
209
+ * 'a some containing 1'
210
+ * )
211
+ *
212
+ * assert.deepStrictEqual(
213
+ * pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
214
+ * 'a none'
215
+ * )
216
+ *
217
+ * @category pattern matching
218
+ * @since 2.0.0
219
+ */
220
+ <B, A, C = B>(
221
+ options: {
222
+ readonly onNone: LazyArg<B>
223
+ readonly onSome: (a: A) => C
224
+ }
225
+ ): (self: Option<A>) => B | C
226
+ /**
227
+ * Matches the given `Option` and returns either the provided `onNone` value or the result of the provided `onSome`
228
+ * function when passed the `Option`'s value.
229
+ *
230
+ * @param self - The `Option` to match
231
+ * @param onNone - The value to be returned if the `Option` is `None`
232
+ * @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned
233
+ *
234
+ * @example
235
+ * import { pipe, Option } from "effect"
236
+ *
237
+ * assert.deepStrictEqual(
238
+ * pipe(Option.some(1), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
239
+ * 'a some containing 1'
240
+ * )
241
+ *
242
+ * assert.deepStrictEqual(
243
+ * pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
244
+ * 'a none'
245
+ * )
246
+ *
247
+ * @category pattern matching
248
+ * @since 2.0.0
249
+ */
250
+ <A, B, C = B>(
251
+ self: Option<A>,
252
+ options: {
253
+ readonly onNone: LazyArg<B>
254
+ readonly onSome: (a: A) => C
255
+ }
256
+ ): B | C
204
257
  } = dual(
205
258
  2,
206
259
  <A, B, C = B>(self: Option<A>, { onNone, onSome }: {
@@ -295,7 +348,37 @@ export const getLeft: <R, L>(self: Either<R, L>) => Option<L> = either.getLeft
295
348
  * @since 2.0.0
296
349
  */
297
350
  export const getOrElse: {
351
+ /**
352
+ * Returns the value of the `Option` if it is `Some`, otherwise returns `onNone`
353
+ *
354
+ * @param self - The `Option` to get the value of.
355
+ * @param onNone - Function that returns the default value to return if the `Option` is `None`.
356
+ *
357
+ * @example
358
+ * import { pipe, Option } from "effect"
359
+ *
360
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
361
+ * assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
362
+ *
363
+ * @category getters
364
+ * @since 2.0.0
365
+ */
298
366
  <B>(onNone: LazyArg<B>): <A>(self: Option<A>) => B | A
367
+ /**
368
+ * Returns the value of the `Option` if it is `Some`, otherwise returns `onNone`
369
+ *
370
+ * @param self - The `Option` to get the value of.
371
+ * @param onNone - Function that returns the default value to return if the `Option` is `None`.
372
+ *
373
+ * @example
374
+ * import { pipe, Option } from "effect"
375
+ *
376
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
377
+ * assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
378
+ *
379
+ * @category getters
380
+ * @since 2.0.0
381
+ */
299
382
  <A, B>(self: Option<A>, onNone: LazyArg<B>): A | B
300
383
  } = dual(
301
384
  2,
@@ -344,7 +427,89 @@ export const getOrElse: {
344
427
  * @since 2.0.0
345
428
  */
346
429
  export const orElse: {
430
+ /**
431
+ * Returns the provided `Option` `that` if `self` is `None`, otherwise returns `self`.
432
+ *
433
+ * @param self - The first `Option` to be checked.
434
+ * @param that - The `Option` to return if `self` is `None`.
435
+ *
436
+ * @example
437
+ * import { pipe, Option } from "effect"
438
+ *
439
+ * assert.deepStrictEqual(
440
+ * pipe(
441
+ * Option.none(),
442
+ * Option.orElse(() => Option.none())
443
+ * ),
444
+ * Option.none()
445
+ * )
446
+ * assert.deepStrictEqual(
447
+ * pipe(
448
+ * Option.some('a'),
449
+ * Option.orElse(() => Option.none())
450
+ * ),
451
+ * Option.some('a')
452
+ * )
453
+ * assert.deepStrictEqual(
454
+ * pipe(
455
+ * Option.none(),
456
+ * Option.orElse(() => Option.some('b'))
457
+ * ),
458
+ * Option.some('b')
459
+ * )
460
+ * assert.deepStrictEqual(
461
+ * pipe(
462
+ * Option.some('a'),
463
+ * Option.orElse(() => Option.some('b'))
464
+ * ),
465
+ * Option.some('a')
466
+ * )
467
+ *
468
+ * @category error handling
469
+ * @since 2.0.0
470
+ */
347
471
  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<B | A>
472
+ /**
473
+ * Returns the provided `Option` `that` if `self` is `None`, otherwise returns `self`.
474
+ *
475
+ * @param self - The first `Option` to be checked.
476
+ * @param that - The `Option` to return if `self` is `None`.
477
+ *
478
+ * @example
479
+ * import { pipe, Option } from "effect"
480
+ *
481
+ * assert.deepStrictEqual(
482
+ * pipe(
483
+ * Option.none(),
484
+ * Option.orElse(() => Option.none())
485
+ * ),
486
+ * Option.none()
487
+ * )
488
+ * assert.deepStrictEqual(
489
+ * pipe(
490
+ * Option.some('a'),
491
+ * Option.orElse(() => Option.none())
492
+ * ),
493
+ * Option.some('a')
494
+ * )
495
+ * assert.deepStrictEqual(
496
+ * pipe(
497
+ * Option.none(),
498
+ * Option.orElse(() => Option.some('b'))
499
+ * ),
500
+ * Option.some('b')
501
+ * )
502
+ * assert.deepStrictEqual(
503
+ * pipe(
504
+ * Option.some('a'),
505
+ * Option.orElse(() => Option.some('b'))
506
+ * ),
507
+ * Option.some('a')
508
+ * )
509
+ *
510
+ * @category error handling
511
+ * @since 2.0.0
512
+ */
348
513
  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B>
349
514
  } = dual(
350
515
  2,
@@ -379,7 +544,61 @@ export const orElse: {
379
544
  * @since 2.0.0
380
545
  */
381
546
  export const orElseSome: {
547
+ /**
548
+ * Returns the provided default value as `Some` if `self` is `None`, otherwise returns `self`.
549
+ *
550
+ * @param self - The first `Option` to be checked.
551
+ * @param onNone - Function that returns the default value to return if the `Option` is `None`.
552
+ *
553
+ * @example
554
+ * import { pipe, Option } from "effect"
555
+ *
556
+ * assert.deepStrictEqual(
557
+ * pipe(
558
+ * Option.none(),
559
+ * Option.orElseSome(() => 'b')
560
+ * ),
561
+ * Option.some('b')
562
+ * )
563
+ * assert.deepStrictEqual(
564
+ * pipe(
565
+ * Option.some('a'),
566
+ * Option.orElseSome(() => 'b')
567
+ * ),
568
+ * Option.some('a')
569
+ * )
570
+ *
571
+ * @category error handling
572
+ * @since 2.0.0
573
+ */
382
574
  <B>(onNone: LazyArg<B>): <A>(self: Option<A>) => Option<B | A>
575
+ /**
576
+ * Returns the provided default value as `Some` if `self` is `None`, otherwise returns `self`.
577
+ *
578
+ * @param self - The first `Option` to be checked.
579
+ * @param onNone - Function that returns the default value to return if the `Option` is `None`.
580
+ *
581
+ * @example
582
+ * import { pipe, Option } from "effect"
583
+ *
584
+ * assert.deepStrictEqual(
585
+ * pipe(
586
+ * Option.none(),
587
+ * Option.orElseSome(() => 'b')
588
+ * ),
589
+ * Option.some('b')
590
+ * )
591
+ * assert.deepStrictEqual(
592
+ * pipe(
593
+ * Option.some('a'),
594
+ * Option.orElseSome(() => 'b')
595
+ * ),
596
+ * Option.some('a')
597
+ * )
598
+ *
599
+ * @category error handling
600
+ * @since 2.0.0
601
+ */
383
602
  <A, B>(self: Option<A>, onNone: LazyArg<B>): Option<A | B>
384
603
  } = dual(
385
604
  2,
@@ -399,7 +618,31 @@ export const orElseSome: {
399
618
  * @since 2.0.0
400
619
  */
401
620
  export const orElseEither: {
621
+ /**
622
+ * Similar to `orElse`, but instead of returning a simple union, it returns an `Either` object,
623
+ * which contains information about which of the two `Option`s has been chosen.
624
+ *
625
+ * This is useful when it's important to know whether the value was retrieved from the first `Option` or the second option.
626
+ *
627
+ * @param self - The first `Option` to be checked.
628
+ * @param that - The second `Option` to be considered if the first `Option` is `None`.
629
+ *
630
+ * @category error handling
631
+ * @since 2.0.0
632
+ */
402
633
  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<Either<B, A>>
634
+ /**
635
+ * Similar to `orElse`, but instead of returning a simple union, it returns an `Either` object,
636
+ * which contains information about which of the two `Option`s has been chosen.
637
+ *
638
+ * This is useful when it's important to know whether the value was retrieved from the first `Option` or the second option.
639
+ *
640
+ * @param self - The first `Option` to be checked.
641
+ * @param that - The second `Option` to be considered if the first `Option` is `None`.
642
+ *
643
+ * @category error handling
644
+ * @since 2.0.0
645
+ */
403
646
  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<Either<B, A>>
404
647
  } = dual(
405
648
  2,
@@ -561,7 +804,47 @@ export const liftThrowable = <A extends ReadonlyArray<unknown>, B>(
561
804
  * @since 2.0.0
562
805
  */
563
806
  export const getOrThrowWith: {
807
+ /**
808
+ * Extracts the value of an `Option` or throws if the `Option` is `None`.
809
+ *
810
+ * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.
811
+ *
812
+ * @param self - The `Option` to extract the value from.
813
+ * @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
814
+ *
815
+ * @example
816
+ * import { Option } from "effect"
817
+ *
818
+ * assert.deepStrictEqual(
819
+ * Option.getOrThrowWith(Option.some(1), () => new Error('Unexpected None')),
820
+ * 1
821
+ * )
822
+ * assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
823
+ *
824
+ * @category conversions
825
+ * @since 2.0.0
826
+ */
564
827
  (onNone: () => unknown): <A>(self: Option<A>) => A
828
+ /**
829
+ * Extracts the value of an `Option` or throws if the `Option` is `None`.
830
+ *
831
+ * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.
832
+ *
833
+ * @param self - The `Option` to extract the value from.
834
+ * @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
835
+ *
836
+ * @example
837
+ * import { Option } from "effect"
838
+ *
839
+ * assert.deepStrictEqual(
840
+ * Option.getOrThrowWith(Option.some(1), () => new Error('Unexpected None')),
841
+ * 1
842
+ * )
843
+ * assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
844
+ *
845
+ * @category conversions
846
+ * @since 2.0.0
847
+ */
565
848
  <A>(self: Option<A>, onNone: () => unknown): A
566
849
  } = dual(2, <A>(self: Option<A>, onNone: () => unknown): A => {
567
850
  if (isSome(self)) {
@@ -599,7 +882,25 @@ export const getOrThrow: <A>(self: Option<A>) => A = getOrThrowWith(() => new Er
599
882
  * @since 2.0.0
600
883
  */
601
884
  export const map: {
885
+ /**
886
+ * Maps the `Some` side of an `Option` value to a new `Option` value.
887
+ *
888
+ * @param self - An `Option` to map
889
+ * @param f - The function to map over the value of the `Option`
890
+ *
891
+ * @category mapping
892
+ * @since 2.0.0
893
+ */
602
894
  <A, B>(f: (a: A) => B): (self: Option<A>) => Option<B>
895
+ /**
896
+ * Maps the `Some` side of an `Option` value to a new `Option` value.
897
+ *
898
+ * @param self - An `Option` to map
899
+ * @param f - The function to map over the value of the `Option`
900
+ *
901
+ * @category mapping
902
+ * @since 2.0.0
903
+ */
603
904
  <A, B>(self: Option<A>, f: (a: A) => B): Option<B>
604
905
  } = dual(
605
906
  2,
@@ -613,6 +914,12 @@ export const map: {
613
914
  * @since 2.0.0
614
915
  */
615
916
  export const as: {
917
+ /**
918
+ * Maps the `Some` value of this `Option` to the specified constant value.
919
+ *
920
+ * @category mapping
921
+ * @since 2.0.0
922
+ */
616
923
  <B>(b: B): <X>(self: Option<X>) => Option<B>
617
924
  } = dual(2, <X, B>(self: Option<X>, b: B): Option<B> => map(self, () => b))
618
925
 
@@ -641,7 +948,19 @@ export {
641
948
  * @since 2.0.0
642
949
  */
643
950
  export const flatMap: {
951
+ /**
952
+ * Applies a function to the value of an `Option` and flattens the result, if the input is `Some`.
953
+ *
954
+ * @category sequencing
955
+ * @since 2.0.0
956
+ */
644
957
  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>
958
+ /**
959
+ * Applies a function to the value of an `Option` and flattens the result, if the input is `Some`.
960
+ *
961
+ * @category sequencing
962
+ * @since 2.0.0
963
+ */
645
964
  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>
646
965
  } = dual(
647
966
  2,
@@ -655,13 +974,61 @@ export const flatMap: {
655
974
  * @since 2.0.0
656
975
  */
657
976
  export const andThen: {
977
+ /**
978
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
979
+ *
980
+ * @category sequencing
981
+ * @since 2.0.0
982
+ */
658
983
  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>
984
+ /**
985
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
986
+ *
987
+ * @category sequencing
988
+ * @since 2.0.0
989
+ */
659
990
  <B>(f: Option<B>): <A>(self: Option<A>) => Option<B>
991
+ /**
992
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
993
+ *
994
+ * @category sequencing
995
+ * @since 2.0.0
996
+ */
660
997
  <A, B>(f: (a: A) => B): (self: Option<A>) => Option<B>
998
+ /**
999
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
1000
+ *
1001
+ * @category sequencing
1002
+ * @since 2.0.0
1003
+ */
661
1004
  <B>(f: NotFunction<B>): <A>(self: Option<A>) => Option<B>
1005
+ /**
1006
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
1007
+ *
1008
+ * @category sequencing
1009
+ * @since 2.0.0
1010
+ */
662
1011
  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>
1012
+ /**
1013
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
1014
+ *
1015
+ * @category sequencing
1016
+ * @since 2.0.0
1017
+ */
663
1018
  <A, B>(self: Option<A>, f: Option<B>): Option<B>
1019
+ /**
1020
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
1021
+ *
1022
+ * @category sequencing
1023
+ * @since 2.0.0
1024
+ */
664
1025
  <A, B>(self: Option<A>, f: (a: A) => B): Option<B>
1026
+ /**
1027
+ * Executes a sequence of two `Option`s. The second `Option` can be dependent on the result of the first `Option`.
1028
+ *
1029
+ * @category sequencing
1030
+ * @since 2.0.0
1031
+ */
665
1032
  <A, B>(self: Option<A>, f: NotFunction<B>): Option<B>
666
1033
  } = dual(
667
1034
  2,
@@ -712,7 +1079,85 @@ export const andThen: {
712
1079
  * @since 2.0.0
713
1080
  */
714
1081
  export const flatMapNullable: {
1082
+ /**
1083
+ * This is `flatMap` + `fromNullable`, useful when working with optional values.
1084
+ *
1085
+ * @example
1086
+ * import { pipe, Option } from "effect"
1087
+ *
1088
+ * interface Employee {
1089
+ * company?: {
1090
+ * address?: {
1091
+ * street?: {
1092
+ * name?: string
1093
+ * }
1094
+ * }
1095
+ * }
1096
+ * }
1097
+ *
1098
+ * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
1099
+ *
1100
+ * assert.deepStrictEqual(
1101
+ * pipe(
1102
+ * Option.some(employee1),
1103
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
1104
+ * ),
1105
+ * Option.some('high street')
1106
+ * )
1107
+ *
1108
+ * const employee2: Employee = { company: { address: { street: {} } } }
1109
+ *
1110
+ * assert.deepStrictEqual(
1111
+ * pipe(
1112
+ * Option.some(employee2),
1113
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
1114
+ * ),
1115
+ * Option.none()
1116
+ * )
1117
+ *
1118
+ * @category sequencing
1119
+ * @since 2.0.0
1120
+ */
715
1121
  <A, B>(f: (a: A) => B | null | undefined): (self: Option<A>) => Option<NonNullable<B>>
1122
+ /**
1123
+ * This is `flatMap` + `fromNullable`, useful when working with optional values.
1124
+ *
1125
+ * @example
1126
+ * import { pipe, Option } from "effect"
1127
+ *
1128
+ * interface Employee {
1129
+ * company?: {
1130
+ * address?: {
1131
+ * street?: {
1132
+ * name?: string
1133
+ * }
1134
+ * }
1135
+ * }
1136
+ * }
1137
+ *
1138
+ * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
1139
+ *
1140
+ * assert.deepStrictEqual(
1141
+ * pipe(
1142
+ * Option.some(employee1),
1143
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
1144
+ * ),
1145
+ * Option.some('high street')
1146
+ * )
1147
+ *
1148
+ * const employee2: Employee = { company: { address: { street: {} } } }
1149
+ *
1150
+ * assert.deepStrictEqual(
1151
+ * pipe(
1152
+ * Option.some(employee2),
1153
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
1154
+ * ),
1155
+ * Option.none()
1156
+ * )
1157
+ *
1158
+ * @category sequencing
1159
+ * @since 2.0.0
1160
+ */
716
1161
  <A, B>(self: Option<A>, f: (a: A) => B | null | undefined): Option<NonNullable<B>>
717
1162
  } = dual(
718
1163
  2,
@@ -731,7 +1176,15 @@ export const flatten: <A>(self: Option<Option<A>>) => Option<A> = flatMap(identi
731
1176
  * @since 2.0.0
732
1177
  */
733
1178
  export const zipRight: {
1179
+ /**
1180
+ * @category zipping
1181
+ * @since 2.0.0
1182
+ */
734
1183
  <B>(that: Option<B>): <_>(self: Option<_>) => Option<B>
1184
+ /**
1185
+ * @category zipping
1186
+ * @since 2.0.0
1187
+ */
735
1188
  <X, B>(self: Option<X>, that: Option<B>): Option<B>
736
1189
  } = dual(2, <X, B>(self: Option<X>, that: Option<B>): Option<B> => flatMap(self, () => that))
737
1190
 
@@ -740,7 +1193,15 @@ export const zipRight: {
740
1193
  * @since 2.0.0
741
1194
  */
742
1195
  export const composeK: {
1196
+ /**
1197
+ * @category sequencing
1198
+ * @since 2.0.0
1199
+ */
743
1200
  <B, C>(bfc: (b: B) => Option<C>): <A>(afb: (a: A) => Option<B>) => (a: A) => Option<C>
1201
+ /**
1202
+ * @category sequencing
1203
+ * @since 2.0.0
1204
+ */
744
1205
  <A, B, C>(afb: (a: A) => Option<B>, bfc: (b: B) => Option<C>): (a: A) => Option<C>
745
1206
  } = dual(2, <A, B, C>(afb: (a: A) => Option<B>, bfc: (b: B) => Option<C>) => (a: A): Option<C> => flatMap(afb(a), bfc))
746
1207
 
@@ -756,7 +1217,29 @@ export const composeK: {
756
1217
  * @since 2.0.0
757
1218
  */
758
1219
  export const zipLeft: {
1220
+ /**
1221
+ * Sequences the specified `that` `Option` but ignores its value.
1222
+ *
1223
+ * It is useful when we want to chain multiple operations, but only care about the result of `self`.
1224
+ *
1225
+ * @param that - The `Option` that will be ignored in the chain and discarded
1226
+ * @param self - The `Option` we care about
1227
+ *
1228
+ * @category zipping
1229
+ * @since 2.0.0
1230
+ */
759
1231
  <_>(that: Option<_>): <A>(self: Option<A>) => Option<A>
1232
+ /**
1233
+ * Sequences the specified `that` `Option` but ignores its value.
1234
+ *
1235
+ * It is useful when we want to chain multiple operations, but only care about the result of `self`.
1236
+ *
1237
+ * @param that - The `Option` that will be ignored in the chain and discarded
1238
+ * @param self - The `Option` we care about
1239
+ *
1240
+ * @category zipping
1241
+ * @since 2.0.0
1242
+ */
760
1243
  <A, X>(self: Option<A>, that: Option<X>): Option<A>
761
1244
  } = dual(2, <A, X>(self: Option<A>, that: Option<X>): Option<A> => tap(self, () => that))
762
1245
 
@@ -782,7 +1265,49 @@ export const zipLeft: {
782
1265
  * @since 2.0.0
783
1266
  */
784
1267
  export const tap: {
1268
+ /**
1269
+ * Applies the provided function `f` to the value of the `Option` if it is `Some` and returns the original `Option`
1270
+ * unless `f` returns `None`, in which case it returns `None`.
1271
+ *
1272
+ * This function is useful for performing additional computations on the value of the input `Option` without affecting its value.
1273
+ *
1274
+ * @param f - Function to apply to the value of the `Option` if it is `Some`
1275
+ * @param self - The `Option` to apply the function to
1276
+ *
1277
+ * @example
1278
+ * import { Option } from "effect"
1279
+ *
1280
+ * const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
1281
+ *
1282
+ * assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
1283
+ * assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
1284
+ * assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
1285
+ *
1286
+ * @category sequencing
1287
+ * @since 2.0.0
1288
+ */
785
1289
  <A, X>(f: (a: A) => Option<X>): (self: Option<A>) => Option<A>
1290
+ /**
1291
+ * Applies the provided function `f` to the value of the `Option` if it is `Some` and returns the original `Option`
1292
+ * unless `f` returns `None`, in which case it returns `None`.
1293
+ *
1294
+ * This function is useful for performing additional computations on the value of the input `Option` without affecting its value.
1295
+ *
1296
+ * @param f - Function to apply to the value of the `Option` if it is `Some`
1297
+ * @param self - The `Option` to apply the function to
1298
+ *
1299
+ * @example
1300
+ * import { Option } from "effect"
1301
+ *
1302
+ * const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
1303
+ *
1304
+ * assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
1305
+ * assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
1306
+ * assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
1307
+ *
1308
+ * @category sequencing
1309
+ * @since 2.0.0
1310
+ */
786
1311
  <A, X>(self: Option<A>, f: (a: A) => Option<X>): Option<A>
787
1312
  } = dual(2, <A, X>(self: Option<A>, f: (a: A) => Option<X>): Option<A> => flatMap(self, (a) => map(f(a), () => a)))
788
1313
 
@@ -890,7 +1415,55 @@ export const all: <const I extends Iterable<Option<any>> | Record<string, Option
890
1415
  * @since 2.0.0
891
1416
  */
892
1417
  export const zipWith: {
1418
+ /**
1419
+ * Zips two `Option` values together using a provided function, returning a new `Option` of the result.
1420
+ *
1421
+ * @param self - The left-hand side of the zip operation
1422
+ * @param that - The right-hand side of the zip operation
1423
+ * @param f - The function used to combine the values of the two `Option`s
1424
+ *
1425
+ * @example
1426
+ * import { Option } from "effect"
1427
+ *
1428
+ * type Complex = [real: number, imaginary: number]
1429
+ *
1430
+ * const complex = (real: number, imaginary: number): Complex => [real, imaginary]
1431
+ *
1432
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.none(), complex), Option.none())
1433
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.none(), complex), Option.none())
1434
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.some(1), complex), Option.none())
1435
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
1436
+ *
1437
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
1438
+ *
1439
+ * @category zipping
1440
+ * @since 2.0.0
1441
+ */
893
1442
  <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>
1443
+ /**
1444
+ * Zips two `Option` values together using a provided function, returning a new `Option` of the result.
1445
+ *
1446
+ * @param self - The left-hand side of the zip operation
1447
+ * @param that - The right-hand side of the zip operation
1448
+ * @param f - The function used to combine the values of the two `Option`s
1449
+ *
1450
+ * @example
1451
+ * import { Option } from "effect"
1452
+ *
1453
+ * type Complex = [real: number, imaginary: number]
1454
+ *
1455
+ * const complex = (real: number, imaginary: number): Complex => [real, imaginary]
1456
+ *
1457
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.none(), complex), Option.none())
1458
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.none(), complex), Option.none())
1459
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.some(1), complex), Option.none())
1460
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
1461
+ *
1462
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
1463
+ *
1464
+ * @category zipping
1465
+ * @since 2.0.0
1466
+ */
894
1467
  <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>
895
1468
  } = dual(
896
1469
  3,
@@ -903,7 +1476,15 @@ export const zipWith: {
903
1476
  * @since 2.0.0
904
1477
  */
905
1478
  export const ap: {
1479
+ /**
1480
+ * @category combining
1481
+ * @since 2.0.0
1482
+ */
906
1483
  <A>(that: Option<A>): <B>(self: Option<(a: A) => B>) => Option<B>
1484
+ /**
1485
+ * @category combining
1486
+ * @since 2.0.0
1487
+ */
907
1488
  <A, B>(self: Option<(a: A) => B>, that: Option<A>): Option<B>
908
1489
  } = dual(2, <A, B>(self: Option<(a: A) => B>, that: Option<A>): Option<B> => zipWith(self, that, (f, a) => f(a)))
909
1490
 
@@ -924,7 +1505,39 @@ export const ap: {
924
1505
  * @since 2.0.0
925
1506
  */
926
1507
  export const reduceCompact: {
1508
+ /**
1509
+ * Reduces an `Iterable` of `Option<A>` to a single value of type `B`, elements that are `None` are ignored.
1510
+ *
1511
+ * @param self - The Iterable of `Option<A>` to be reduced.
1512
+ * @param b - The initial value of the accumulator.
1513
+ * @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
1514
+ *
1515
+ * @example
1516
+ * import { pipe, Option } from "effect"
1517
+ *
1518
+ * const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
1519
+ * assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
1520
+ *
1521
+ * @category folding
1522
+ * @since 2.0.0
1523
+ */
927
1524
  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<Option<A>>) => B
1525
+ /**
1526
+ * Reduces an `Iterable` of `Option<A>` to a single value of type `B`, elements that are `None` are ignored.
1527
+ *
1528
+ * @param self - The Iterable of `Option<A>` to be reduced.
1529
+ * @param b - The initial value of the accumulator.
1530
+ * @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
1531
+ *
1532
+ * @example
1533
+ * import { pipe, Option } from "effect"
1534
+ *
1535
+ * const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
1536
+ * assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
1537
+ *
1538
+ * @category folding
1539
+ * @since 2.0.0
1540
+ */
928
1541
  <A, B>(self: Iterable<Option<A>>, b: B, f: (b: B, a: A) => B): B
929
1542
  } = dual(
930
1543
  3,
@@ -962,7 +1575,15 @@ export const toArray = <A>(self: Option<A>): Array<A> => isNone(self) ? [] : [se
962
1575
  * @since 2.0.0
963
1576
  */
964
1577
  export const partitionMap: {
1578
+ /**
1579
+ * @category filtering
1580
+ * @since 2.0.0
1581
+ */
965
1582
  <A, B, C>(f: (a: A) => Either<C, B>): (self: Option<A>) => [left: Option<B>, right: Option<C>]
1583
+ /**
1584
+ * @category filtering
1585
+ * @since 2.0.0
1586
+ */
966
1587
  <A, B, C>(self: Option<A>, f: (a: A) => Either<C, B>): [left: Option<B>, right: Option<C>]
967
1588
  } = dual(2, <A, B, C>(
968
1589
  self: Option<A>,
@@ -996,7 +1617,47 @@ export const partitionMap: {
996
1617
  * @since 2.0.0
997
1618
  */
998
1619
  export const filterMap: {
1620
+ /**
1621
+ * Maps over the value of an `Option` and filters out `None`s.
1622
+ *
1623
+ * Useful when in addition to filtering you also want to change the type of the `Option`.
1624
+ *
1625
+ * @param self - The `Option` to map over.
1626
+ * @param f - A function to apply to the value of the `Option`.
1627
+ *
1628
+ * @example
1629
+ * import { Option } from "effect"
1630
+ *
1631
+ * const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
1632
+ *
1633
+ * assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
1634
+ * assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
1635
+ * assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
1636
+ *
1637
+ * @category filtering
1638
+ * @since 2.0.0
1639
+ */
999
1640
  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>
1641
+ /**
1642
+ * Maps over the value of an `Option` and filters out `None`s.
1643
+ *
1644
+ * Useful when in addition to filtering you also want to change the type of the `Option`.
1645
+ *
1646
+ * @param self - The `Option` to map over.
1647
+ * @param f - A function to apply to the value of the `Option`.
1648
+ *
1649
+ * @example
1650
+ * import { Option } from "effect"
1651
+ *
1652
+ * const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
1653
+ *
1654
+ * assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
1655
+ * assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
1656
+ * assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
1657
+ *
1658
+ * @category filtering
1659
+ * @since 2.0.0
1660
+ */
1000
1661
  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>
1001
1662
  } = dual(
1002
1663
  2,
@@ -1032,9 +1693,121 @@ export const filterMap: {
1032
1693
  * @since 2.0.0
1033
1694
  */
1034
1695
  export const filter: {
1696
+ /**
1697
+ * Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
1698
+ *
1699
+ * If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
1700
+ *
1701
+ * @param predicate - A predicate function to apply to the `Option` value.
1702
+ * @param fb - The `Option` to filter.
1703
+ *
1704
+ * @example
1705
+ * import { Option } from "effect"
1706
+ *
1707
+ * // predicate
1708
+ * const isEven = (n: number) => n % 2 === 0
1709
+ *
1710
+ * assert.deepStrictEqual(Option.filter(Option.none(), isEven), Option.none())
1711
+ * assert.deepStrictEqual(Option.filter(Option.some(3), isEven), Option.none())
1712
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isEven), Option.some(2))
1713
+ *
1714
+ * // refinement
1715
+ * const isNumber = (v: unknown): v is number => typeof v === "number"
1716
+ *
1717
+ * assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
1718
+ * assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
1719
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
1720
+ *
1721
+ * @category filtering
1722
+ * @since 2.0.0
1723
+ */
1035
1724
  <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => Option<B>
1725
+ /**
1726
+ * Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
1727
+ *
1728
+ * If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
1729
+ *
1730
+ * @param predicate - A predicate function to apply to the `Option` value.
1731
+ * @param fb - The `Option` to filter.
1732
+ *
1733
+ * @example
1734
+ * import { Option } from "effect"
1735
+ *
1736
+ * // predicate
1737
+ * const isEven = (n: number) => n % 2 === 0
1738
+ *
1739
+ * assert.deepStrictEqual(Option.filter(Option.none(), isEven), Option.none())
1740
+ * assert.deepStrictEqual(Option.filter(Option.some(3), isEven), Option.none())
1741
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isEven), Option.some(2))
1742
+ *
1743
+ * // refinement
1744
+ * const isNumber = (v: unknown): v is number => typeof v === "number"
1745
+ *
1746
+ * assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
1747
+ * assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
1748
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
1749
+ *
1750
+ * @category filtering
1751
+ * @since 2.0.0
1752
+ */
1036
1753
  <A>(predicate: Predicate<NoInfer<A>>): (self: Option<A>) => Option<A>
1754
+ /**
1755
+ * Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
1756
+ *
1757
+ * If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
1758
+ *
1759
+ * @param predicate - A predicate function to apply to the `Option` value.
1760
+ * @param fb - The `Option` to filter.
1761
+ *
1762
+ * @example
1763
+ * import { Option } from "effect"
1764
+ *
1765
+ * // predicate
1766
+ * const isEven = (n: number) => n % 2 === 0
1767
+ *
1768
+ * assert.deepStrictEqual(Option.filter(Option.none(), isEven), Option.none())
1769
+ * assert.deepStrictEqual(Option.filter(Option.some(3), isEven), Option.none())
1770
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isEven), Option.some(2))
1771
+ *
1772
+ * // refinement
1773
+ * const isNumber = (v: unknown): v is number => typeof v === "number"
1774
+ *
1775
+ * assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
1776
+ * assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
1777
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
1778
+ *
1779
+ * @category filtering
1780
+ * @since 2.0.0
1781
+ */
1037
1782
  <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): Option<B>
1783
+ /**
1784
+ * Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
1785
+ *
1786
+ * If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
1787
+ *
1788
+ * @param predicate - A predicate function to apply to the `Option` value.
1789
+ * @param fb - The `Option` to filter.
1790
+ *
1791
+ * @example
1792
+ * import { Option } from "effect"
1793
+ *
1794
+ * // predicate
1795
+ * const isEven = (n: number) => n % 2 === 0
1796
+ *
1797
+ * assert.deepStrictEqual(Option.filter(Option.none(), isEven), Option.none())
1798
+ * assert.deepStrictEqual(Option.filter(Option.some(3), isEven), Option.none())
1799
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isEven), Option.some(2))
1800
+ *
1801
+ * // refinement
1802
+ * const isNumber = (v: unknown): v is number => typeof v === "number"
1803
+ *
1804
+ * assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
1805
+ * assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
1806
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
1807
+ *
1808
+ * @category filtering
1809
+ * @since 2.0.0
1810
+ */
1038
1811
  <A>(self: Option<A>, predicate: Predicate<A>): Option<A>
1039
1812
  } = dual(
1040
1813
  2,
@@ -1114,15 +1887,60 @@ export const lift2 = <A, B, C>(f: (a: A, b: B) => C): {
1114
1887
  */
1115
1888
  export const liftPredicate: { // Note: I intentionally avoid using the NoInfer pattern here.
1116
1889
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Option<B>
1890
+ /**
1891
+ * Transforms a `Predicate` function into a `Some` of the input value if the predicate returns `true` or `None`
1892
+ * if the predicate returns `false`.
1893
+ *
1894
+ * @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
1895
+ *
1896
+ * @example
1897
+ * import { Option } from "effect"
1898
+ *
1899
+ * const getOption = Option.liftPredicate((n: number) => n >= 0)
1900
+ *
1901
+ * assert.deepStrictEqual(getOption(-1), Option.none())
1902
+ * assert.deepStrictEqual(getOption(1), Option.some(1))
1903
+ *
1904
+ * @category lifting
1905
+ * @since 2.0.0
1906
+ */
1117
1907
  <B extends A, A = B>(predicate: Predicate<A>): (b: B) => Option<B>
1118
- <A, B extends A>(
1119
- self: A,
1120
- refinement: Refinement<A, B>
1121
- ): Option<B>
1122
- <B extends A, A = B>(
1123
- self: B,
1124
- predicate: Predicate<A>
1125
- ): Option<B>
1908
+ /**
1909
+ * Transforms a `Predicate` function into a `Some` of the input value if the predicate returns `true` or `None`
1910
+ * if the predicate returns `false`.
1911
+ *
1912
+ * @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
1913
+ *
1914
+ * @example
1915
+ * import { Option } from "effect"
1916
+ *
1917
+ * const getOption = Option.liftPredicate((n: number) => n >= 0)
1918
+ *
1919
+ * assert.deepStrictEqual(getOption(-1), Option.none())
1920
+ * assert.deepStrictEqual(getOption(1), Option.some(1))
1921
+ *
1922
+ * @category lifting
1923
+ * @since 2.0.0
1924
+ */
1925
+ <A, B extends A>(self: A, refinement: Refinement<A, B>): Option<B>
1926
+ /**
1927
+ * Transforms a `Predicate` function into a `Some` of the input value if the predicate returns `true` or `None`
1928
+ * if the predicate returns `false`.
1929
+ *
1930
+ * @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
1931
+ *
1932
+ * @example
1933
+ * import { Option } from "effect"
1934
+ *
1935
+ * const getOption = Option.liftPredicate((n: number) => n >= 0)
1936
+ *
1937
+ * assert.deepStrictEqual(getOption(-1), Option.none())
1938
+ * assert.deepStrictEqual(getOption(1), Option.some(1))
1939
+ *
1940
+ * @category lifting
1941
+ * @since 2.0.0
1942
+ */
1943
+ <B extends A, A = B>(self: B, predicate: Predicate<A>): Option<B>
1126
1944
  } = dual(
1127
1945
  2,
1128
1946
  <B extends A, A = B>(b: B, predicate: Predicate<A>): Option<B> => predicate(b) ? some(b) : none()
@@ -1159,7 +1977,19 @@ const _equivalence = Equal.equivalence()
1159
1977
  * @since 2.0.0
1160
1978
  */
1161
1979
  export const contains: {
1980
+ /**
1981
+ * Returns a function that checks if an `Option` contains a given value using the default `Equivalence`.
1982
+ *
1983
+ * @category elements
1984
+ * @since 2.0.0
1985
+ */
1162
1986
  <A>(a: A): (self: Option<A>) => boolean
1987
+ /**
1988
+ * Returns a function that checks if an `Option` contains a given value using the default `Equivalence`.
1989
+ *
1990
+ * @category elements
1991
+ * @since 2.0.0
1992
+ */
1163
1993
  <A>(self: Option<A>, a: A): boolean
1164
1994
  } = containsWith(_equivalence)
1165
1995
 
@@ -1181,9 +2011,77 @@ export const contains: {
1181
2011
  * @since 2.0.0
1182
2012
  */
1183
2013
  export const exists: {
2014
+ /**
2015
+ * Check if a value in an `Option` type meets a certain predicate.
2016
+ *
2017
+ * @param self - The `Option` to check.
2018
+ * @param predicate - The condition to check.
2019
+ *
2020
+ * @example
2021
+ * import { pipe, Option } from "effect"
2022
+ *
2023
+ * const isEven = (n: number) => n % 2 === 0
2024
+ *
2025
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
2026
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
2027
+ * assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
2028
+ *
2029
+ * @since 2.0.0
2030
+ */
1184
2031
  <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>
2032
+ /**
2033
+ * Check if a value in an `Option` type meets a certain predicate.
2034
+ *
2035
+ * @param self - The `Option` to check.
2036
+ * @param predicate - The condition to check.
2037
+ *
2038
+ * @example
2039
+ * import { pipe, Option } from "effect"
2040
+ *
2041
+ * const isEven = (n: number) => n % 2 === 0
2042
+ *
2043
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
2044
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
2045
+ * assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
2046
+ *
2047
+ * @since 2.0.0
2048
+ */
1185
2049
  <A>(predicate: Predicate<NoInfer<A>>): (self: Option<A>) => boolean
2050
+ /**
2051
+ * Check if a value in an `Option` type meets a certain predicate.
2052
+ *
2053
+ * @param self - The `Option` to check.
2054
+ * @param predicate - The condition to check.
2055
+ *
2056
+ * @example
2057
+ * import { pipe, Option } from "effect"
2058
+ *
2059
+ * const isEven = (n: number) => n % 2 === 0
2060
+ *
2061
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
2062
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
2063
+ * assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
2064
+ *
2065
+ * @since 2.0.0
2066
+ */
1186
2067
  <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>
2068
+ /**
2069
+ * Check if a value in an `Option` type meets a certain predicate.
2070
+ *
2071
+ * @param self - The `Option` to check.
2072
+ * @param predicate - The condition to check.
2073
+ *
2074
+ * @example
2075
+ * import { pipe, Option } from "effect"
2076
+ *
2077
+ * const isEven = (n: number) => n % 2 === 0
2078
+ *
2079
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
2080
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
2081
+ * assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
2082
+ *
2083
+ * @since 2.0.0
2084
+ */
1187
2085
  <A>(self: Option<A>, predicate: Predicate<A>): boolean
1188
2086
  } = dual(
1189
2087
  2,
@@ -1226,7 +2124,75 @@ export const exists: {
1226
2124
  * @since 2.0.0
1227
2125
  */
1228
2126
  export const bindTo: {
2127
+ // -------------------------------------------------------------------------------------
2128
+ // do notation
2129
+ // -------------------------------------------------------------------------------------
2130
+
2131
+ /**
2132
+ * The "do simulation" in Effect allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
2133
+ *
2134
+ * Here's how the do simulation works:
2135
+ *
2136
+ * 1. Start the do simulation using the `Do` value
2137
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
2138
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2139
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2140
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2141
+ *
2142
+ * @see {@link Do}
2143
+ * @see {@link bind}
2144
+ * @see {@link let_ let}
2145
+ *
2146
+ * @example
2147
+ * import { Option, pipe } from "effect"
2148
+ *
2149
+ * const result = pipe(
2150
+ * Option.Do,
2151
+ * Option.bind("x", () => Option.some(2)),
2152
+ * Option.bind("y", () => Option.some(3)),
2153
+ * Option.let("sum", ({ x, y }) => x + y),
2154
+ * Option.filter(({ x, y }) => x * y > 5)
2155
+ * )
2156
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
2157
+ *
2158
+ * @category do notation
2159
+ * @since 2.0.0
2160
+ */
1229
2161
  <N extends string>(name: N): <A>(self: Option<A>) => Option<{ [K in N]: A }>
2162
+ // -------------------------------------------------------------------------------------
2163
+ // do notation
2164
+ // -------------------------------------------------------------------------------------
2165
+
2166
+ /**
2167
+ * The "do simulation" in Effect allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
2168
+ *
2169
+ * Here's how the do simulation works:
2170
+ *
2171
+ * 1. Start the do simulation using the `Do` value
2172
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
2173
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2174
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2175
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2176
+ *
2177
+ * @see {@link Do}
2178
+ * @see {@link bind}
2179
+ * @see {@link let_ let}
2180
+ *
2181
+ * @example
2182
+ * import { Option, pipe } from "effect"
2183
+ *
2184
+ * const result = pipe(
2185
+ * Option.Do,
2186
+ * Option.bind("x", () => Option.some(2)),
2187
+ * Option.bind("y", () => Option.some(3)),
2188
+ * Option.let("sum", ({ x, y }) => x + y),
2189
+ * Option.filter(({ x, y }) => x * y > 5)
2190
+ * )
2191
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
2192
+ *
2193
+ * @category do notation
2194
+ * @since 2.0.0
2195
+ */
1230
2196
  <A, N extends string>(self: Option<A>, name: N): Option<{ [K in N]: A }>
1231
2197
  } = doNotation.bindTo<OptionTypeLambda>(map)
1232
2198
 
@@ -1307,10 +2273,70 @@ export {
1307
2273
  * @since 2.0.0
1308
2274
  */
1309
2275
  export const bind: {
2276
+ /**
2277
+ * The "do simulation" in Effect allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
2278
+ *
2279
+ * Here's how the do simulation works:
2280
+ *
2281
+ * 1. Start the do simulation using the `Do` value
2282
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
2283
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2284
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2285
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2286
+ *
2287
+ * @see {@link Do}
2288
+ * @see {@link bindTo}
2289
+ * @see {@link let_ let}
2290
+ *
2291
+ * @example
2292
+ * import { Option, pipe } from "effect"
2293
+ *
2294
+ * const result = pipe(
2295
+ * Option.Do,
2296
+ * Option.bind("x", () => Option.some(2)),
2297
+ * Option.bind("y", () => Option.some(3)),
2298
+ * Option.let("sum", ({ x, y }) => x + y),
2299
+ * Option.filter(({ x, y }) => x * y > 5)
2300
+ * )
2301
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
2302
+ *
2303
+ * @category do notation
2304
+ * @since 2.0.0
2305
+ */
1310
2306
  <N extends string, A extends object, B>(
1311
2307
  name: Exclude<N, keyof A>,
1312
2308
  f: (a: A) => Option<B>
1313
2309
  ): (self: Option<A>) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
2310
+ /**
2311
+ * The "do simulation" in Effect allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
2312
+ *
2313
+ * Here's how the do simulation works:
2314
+ *
2315
+ * 1. Start the do simulation using the `Do` value
2316
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
2317
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2318
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2319
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2320
+ *
2321
+ * @see {@link Do}
2322
+ * @see {@link bindTo}
2323
+ * @see {@link let_ let}
2324
+ *
2325
+ * @example
2326
+ * import { Option, pipe } from "effect"
2327
+ *
2328
+ * const result = pipe(
2329
+ * Option.Do,
2330
+ * Option.bind("x", () => Option.some(2)),
2331
+ * Option.bind("y", () => Option.some(3)),
2332
+ * Option.let("sum", ({ x, y }) => x + y),
2333
+ * Option.filter(({ x, y }) => x * y > 5)
2334
+ * )
2335
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
2336
+ *
2337
+ * @category do notation
2338
+ * @since 2.0.0
2339
+ */
1314
2340
  <A extends object, N extends string, B>(
1315
2341
  self: Option<A>,
1316
2342
  name: Exclude<N, keyof A>,