effect 3.8.4 → 3.9.0

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 (757) hide show
  1. package/dist/cjs/Array.js +24 -3
  2. package/dist/cjs/Array.js.map +1 -1
  3. package/dist/cjs/BigDecimal.js +5 -3
  4. package/dist/cjs/BigDecimal.js.map +1 -1
  5. package/dist/cjs/BigInt.js.map +1 -1
  6. package/dist/cjs/Boolean.js.map +1 -1
  7. package/dist/cjs/Cause.js.map +1 -1
  8. package/dist/cjs/Channel.js.map +1 -1
  9. package/dist/cjs/ChildExecutorDecision.js.map +1 -1
  10. package/dist/cjs/Chunk.js +3 -0
  11. package/dist/cjs/Chunk.js.map +1 -1
  12. package/dist/cjs/Config.js.map +1 -1
  13. package/dist/cjs/ConfigError.js.map +1 -1
  14. package/dist/cjs/ConfigProvider.js.map +1 -1
  15. package/dist/cjs/ConfigProviderPathPatch.js.map +1 -1
  16. package/dist/cjs/Console.js.map +1 -1
  17. package/dist/cjs/Context.js.map +1 -1
  18. package/dist/cjs/Cron.js +3 -0
  19. package/dist/cjs/Cron.js.map +1 -1
  20. package/dist/cjs/Data.js.map +1 -1
  21. package/dist/cjs/DateTime.js +6 -0
  22. package/dist/cjs/DateTime.js.map +1 -1
  23. package/dist/cjs/Deferred.js.map +1 -1
  24. package/dist/cjs/Differ.js.map +1 -1
  25. package/dist/cjs/Duration.js +3 -0
  26. package/dist/cjs/Duration.js.map +1 -1
  27. package/dist/cjs/Effect.js +122 -35
  28. package/dist/cjs/Effect.js.map +1 -1
  29. package/dist/cjs/Either.js.map +1 -1
  30. package/dist/cjs/Equivalence.js.map +1 -1
  31. package/dist/cjs/ExecutionStrategy.js.map +1 -1
  32. package/dist/cjs/Exit.js.map +1 -1
  33. package/dist/cjs/Fiber.js.map +1 -1
  34. package/dist/cjs/FiberHandle.js +3 -0
  35. package/dist/cjs/FiberHandle.js.map +1 -1
  36. package/dist/cjs/FiberId.js.map +1 -1
  37. package/dist/cjs/FiberMap.js +3 -0
  38. package/dist/cjs/FiberMap.js.map +1 -1
  39. package/dist/cjs/FiberRef.js.map +1 -1
  40. package/dist/cjs/FiberRefs.js.map +1 -1
  41. package/dist/cjs/FiberRefsPatch.js.map +1 -1
  42. package/dist/cjs/FiberSet.js +3 -0
  43. package/dist/cjs/FiberSet.js.map +1 -1
  44. package/dist/cjs/Function.js.map +1 -1
  45. package/dist/cjs/GroupBy.js.map +1 -1
  46. package/dist/cjs/Hash.js.map +1 -1
  47. package/dist/cjs/HashMap.js.map +1 -1
  48. package/dist/cjs/HashSet.js.map +1 -1
  49. package/dist/cjs/Inspectable.js +15 -1
  50. package/dist/cjs/Inspectable.js.map +1 -1
  51. package/dist/cjs/Iterable.js.map +1 -1
  52. package/dist/cjs/KeyedPool.js.map +1 -1
  53. package/dist/cjs/Layer.js.map +1 -1
  54. package/dist/cjs/List.js +6 -0
  55. package/dist/cjs/List.js.map +1 -1
  56. package/dist/cjs/LogLevel.js.map +1 -1
  57. package/dist/cjs/Logger.js.map +1 -1
  58. package/dist/cjs/Mailbox.js.map +1 -1
  59. package/dist/cjs/ManagedRuntime.js +16 -1
  60. package/dist/cjs/ManagedRuntime.js.map +1 -1
  61. package/dist/cjs/MergeDecision.js.map +1 -1
  62. package/dist/cjs/MergeState.js.map +1 -1
  63. package/dist/cjs/MergeStrategy.js.map +1 -1
  64. package/dist/cjs/Metric.js.map +1 -1
  65. package/dist/cjs/MetricHook.js.map +1 -1
  66. package/dist/cjs/MetricKey.js.map +1 -1
  67. package/dist/cjs/MetricPolling.js.map +1 -1
  68. package/dist/cjs/MetricState.js.map +1 -1
  69. package/dist/cjs/Micro.js +6 -0
  70. package/dist/cjs/Micro.js.map +1 -1
  71. package/dist/cjs/MutableHashMap.js +3 -0
  72. package/dist/cjs/MutableHashMap.js.map +1 -1
  73. package/dist/cjs/MutableHashSet.js +3 -0
  74. package/dist/cjs/MutableHashSet.js.map +1 -1
  75. package/dist/cjs/MutableList.js +3 -0
  76. package/dist/cjs/MutableList.js.map +1 -1
  77. package/dist/cjs/MutableQueue.js +3 -0
  78. package/dist/cjs/MutableQueue.js.map +1 -1
  79. package/dist/cjs/MutableRef.js +3 -0
  80. package/dist/cjs/MutableRef.js.map +1 -1
  81. package/dist/cjs/Number.js.map +1 -1
  82. package/dist/cjs/Option.js.map +1 -1
  83. package/dist/cjs/Order.js.map +1 -1
  84. package/dist/cjs/Ordering.js.map +1 -1
  85. package/dist/cjs/Pipeable.js.map +1 -1
  86. package/dist/cjs/Pool.js.map +1 -1
  87. package/dist/cjs/Predicate.js +18 -2
  88. package/dist/cjs/Predicate.js.map +1 -1
  89. package/dist/cjs/PubSub.js.map +1 -1
  90. package/dist/cjs/Queue.js.map +1 -1
  91. package/dist/cjs/RcMap.js.map +1 -1
  92. package/dist/cjs/Readable.js.map +1 -1
  93. package/dist/cjs/Record.js.map +1 -1
  94. package/dist/cjs/RedBlackTree.js.map +1 -1
  95. package/dist/cjs/Ref.js.map +1 -1
  96. package/dist/cjs/RegExp.js +20 -1
  97. package/dist/cjs/RegExp.js.map +1 -1
  98. package/dist/cjs/Request.js.map +1 -1
  99. package/dist/cjs/RequestResolver.js.map +1 -1
  100. package/dist/cjs/Resource.js.map +1 -1
  101. package/dist/cjs/Runtime.js.map +1 -1
  102. package/dist/cjs/RuntimeFlags.js.map +1 -1
  103. package/dist/cjs/RuntimeFlagsPatch.js.map +1 -1
  104. package/dist/cjs/STM.js.map +1 -1
  105. package/dist/cjs/Schedule.js.map +1 -1
  106. package/dist/cjs/ScheduleInterval.js.map +1 -1
  107. package/dist/cjs/ScheduleIntervals.js.map +1 -1
  108. package/dist/cjs/Scheduler.js.map +1 -1
  109. package/dist/cjs/Scope.js.map +1 -1
  110. package/dist/cjs/ScopedRef.js.map +1 -1
  111. package/dist/cjs/Sink.js.map +1 -1
  112. package/dist/cjs/SortedMap.js +3 -0
  113. package/dist/cjs/SortedMap.js.map +1 -1
  114. package/dist/cjs/SortedSet.js +3 -0
  115. package/dist/cjs/SortedSet.js.map +1 -1
  116. package/dist/cjs/Stream.js +17 -3
  117. package/dist/cjs/Stream.js.map +1 -1
  118. package/dist/cjs/StreamHaltStrategy.js.map +1 -1
  119. package/dist/cjs/String.js.map +1 -1
  120. package/dist/cjs/Struct.js.map +1 -1
  121. package/dist/cjs/Subscribable.js.map +1 -1
  122. package/dist/cjs/SubscriptionRef.js.map +1 -1
  123. package/dist/cjs/SynchronizedRef.js.map +1 -1
  124. package/dist/cjs/TArray.js.map +1 -1
  125. package/dist/cjs/TDeferred.js.map +1 -1
  126. package/dist/cjs/TMap.js.map +1 -1
  127. package/dist/cjs/TPriorityQueue.js.map +1 -1
  128. package/dist/cjs/TPubSub.js.map +1 -1
  129. package/dist/cjs/TQueue.js.map +1 -1
  130. package/dist/cjs/TReentrantLock.js.map +1 -1
  131. package/dist/cjs/TRef.js.map +1 -1
  132. package/dist/cjs/TSemaphore.js.map +1 -1
  133. package/dist/cjs/TSet.js.map +1 -1
  134. package/dist/cjs/Take.js.map +1 -1
  135. package/dist/cjs/TestAnnotationMap.js.map +1 -1
  136. package/dist/cjs/TestClock.js.map +1 -1
  137. package/dist/cjs/TestServices.js.map +1 -1
  138. package/dist/cjs/Trie.js.map +1 -1
  139. package/dist/cjs/Tuple.js +21 -2
  140. package/dist/cjs/Tuple.js.map +1 -1
  141. package/dist/cjs/Unify.js.map +1 -1
  142. package/dist/cjs/UpstreamPullRequest.js.map +1 -1
  143. package/dist/cjs/UpstreamPullStrategy.js.map +1 -1
  144. package/dist/cjs/Utils.js +1 -14
  145. package/dist/cjs/Utils.js.map +1 -1
  146. package/dist/cjs/internal/cause.js +3 -0
  147. package/dist/cjs/internal/cause.js.map +1 -1
  148. package/dist/cjs/internal/context.js +6 -1
  149. package/dist/cjs/internal/context.js.map +1 -1
  150. package/dist/cjs/internal/core-effect.js.map +1 -1
  151. package/dist/cjs/internal/core.js +16 -3
  152. package/dist/cjs/internal/core.js.map +1 -1
  153. package/dist/cjs/internal/effect/circular.js +5 -1
  154. package/dist/cjs/internal/effect/circular.js.map +1 -1
  155. package/dist/cjs/internal/fiberId.js +9 -0
  156. package/dist/cjs/internal/fiberId.js.map +1 -1
  157. package/dist/cjs/internal/hashMap.js +3 -0
  158. package/dist/cjs/internal/hashMap.js.map +1 -1
  159. package/dist/cjs/internal/hashSet.js +3 -0
  160. package/dist/cjs/internal/hashSet.js.map +1 -1
  161. package/dist/cjs/internal/layer.js +33 -19
  162. package/dist/cjs/internal/layer.js.map +1 -1
  163. package/dist/cjs/internal/mailbox.js +3 -0
  164. package/dist/cjs/internal/mailbox.js.map +1 -1
  165. package/dist/cjs/internal/managedRuntime/circular.js +10 -0
  166. package/dist/cjs/internal/managedRuntime/circular.js.map +1 -0
  167. package/dist/cjs/internal/managedRuntime.js +23 -9
  168. package/dist/cjs/internal/managedRuntime.js.map +1 -1
  169. package/dist/cjs/internal/option.js +3 -0
  170. package/dist/cjs/internal/option.js.map +1 -1
  171. package/dist/cjs/internal/pool.js +6 -1
  172. package/dist/cjs/internal/pool.js.map +1 -1
  173. package/dist/cjs/internal/redBlackTree.js +3 -0
  174. package/dist/cjs/internal/redBlackTree.js.map +1 -1
  175. package/dist/cjs/internal/resource.js +15 -5
  176. package/dist/cjs/internal/resource.js.map +1 -1
  177. package/dist/cjs/internal/runtime.js +4 -1
  178. package/dist/cjs/internal/runtime.js.map +1 -1
  179. package/dist/cjs/internal/scopedRef.js +11 -8
  180. package/dist/cjs/internal/scopedRef.js.map +1 -1
  181. package/dist/cjs/internal/stm/core.js +1 -2
  182. package/dist/cjs/internal/stm/core.js.map +1 -1
  183. package/dist/cjs/internal/stream.js +12 -3
  184. package/dist/cjs/internal/stream.js.map +1 -1
  185. package/dist/cjs/internal/trie.js +3 -0
  186. package/dist/cjs/internal/trie.js.map +1 -1
  187. package/dist/cjs/internal/version.js +1 -1
  188. package/dist/dts/Array.d.ts +2735 -2
  189. package/dist/dts/Array.d.ts.map +1 -1
  190. package/dist/dts/BigDecimal.d.ts +558 -1
  191. package/dist/dts/BigDecimal.d.ts.map +1 -1
  192. package/dist/dts/BigInt.d.ts +490 -0
  193. package/dist/dts/BigInt.d.ts.map +1 -1
  194. package/dist/dts/Boolean.d.ts +228 -0
  195. package/dist/dts/Boolean.d.ts.map +1 -1
  196. package/dist/dts/Cause.d.ts +172 -0
  197. package/dist/dts/Cause.d.ts.map +1 -1
  198. package/dist/dts/Channel.d.ts +750 -0
  199. package/dist/dts/Channel.d.ts.map +1 -1
  200. package/dist/dts/ChildExecutorDecision.d.ts +12 -0
  201. package/dist/dts/ChildExecutorDecision.d.ts.map +1 -1
  202. package/dist/dts/Chunk.d.ts +791 -0
  203. package/dist/dts/Chunk.d.ts.map +1 -1
  204. package/dist/dts/Config.d.ts +174 -0
  205. package/dist/dts/Config.d.ts.map +1 -1
  206. package/dist/dts/ConfigError.d.ts +16 -0
  207. package/dist/dts/ConfigError.d.ts.map +1 -1
  208. package/dist/dts/ConfigProvider.d.ts +84 -0
  209. package/dist/dts/ConfigProvider.d.ts.map +1 -1
  210. package/dist/dts/ConfigProviderPathPatch.d.ts +32 -0
  211. package/dist/dts/ConfigProviderPathPatch.d.ts.map +1 -1
  212. package/dist/dts/Console.d.ts +24 -0
  213. package/dist/dts/Console.d.ts.map +1 -1
  214. package/dist/dts/Context.d.ts +234 -3
  215. package/dist/dts/Context.d.ts.map +1 -1
  216. package/dist/dts/Cron.d.ts +12 -0
  217. package/dist/dts/Cron.d.ts.map +1 -1
  218. package/dist/dts/Data.d.ts +165 -0
  219. package/dist/dts/Data.d.ts.map +1 -1
  220. package/dist/dts/DateTime.d.ts +878 -0
  221. package/dist/dts/DateTime.d.ts.map +1 -1
  222. package/dist/dts/Deferred.d.ts +171 -1
  223. package/dist/dts/Deferred.d.ts.map +1 -1
  224. package/dist/dts/Differ.d.ts +78 -0
  225. package/dist/dts/Differ.d.ts.map +1 -1
  226. package/dist/dts/Duration.d.ts +130 -0
  227. package/dist/dts/Duration.d.ts.map +1 -1
  228. package/dist/dts/Effect.d.ts +4350 -13
  229. package/dist/dts/Effect.d.ts.map +1 -1
  230. package/dist/dts/Either.d.ts +620 -0
  231. package/dist/dts/Either.d.ts.map +1 -1
  232. package/dist/dts/Equivalence.d.ts +24 -0
  233. package/dist/dts/Equivalence.d.ts.map +1 -1
  234. package/dist/dts/ExecutionStrategy.d.ts +14 -0
  235. package/dist/dts/ExecutionStrategy.d.ts.map +1 -1
  236. package/dist/dts/Exit.d.ts +252 -0
  237. package/dist/dts/Exit.d.ts.map +1 -1
  238. package/dist/dts/Fiber.d.ts +182 -0
  239. package/dist/dts/Fiber.d.ts.map +1 -1
  240. package/dist/dts/FiberHandle.d.ts +42 -0
  241. package/dist/dts/FiberHandle.d.ts.map +1 -1
  242. package/dist/dts/FiberId.d.ts +24 -0
  243. package/dist/dts/FiberId.d.ts.map +1 -1
  244. package/dist/dts/FiberMap.d.ts +102 -0
  245. package/dist/dts/FiberMap.d.ts.map +1 -1
  246. package/dist/dts/FiberRef.d.ts +80 -0
  247. package/dist/dts/FiberRef.d.ts.map +1 -1
  248. package/dist/dts/FiberRefs.d.ts +84 -0
  249. package/dist/dts/FiberRefs.d.ts.map +1 -1
  250. package/dist/dts/FiberRefsPatch.d.ts +30 -0
  251. package/dist/dts/FiberRefsPatch.d.ts.map +1 -1
  252. package/dist/dts/FiberSet.d.ts +38 -0
  253. package/dist/dts/FiberSet.d.ts.map +1 -1
  254. package/dist/dts/Function.d.ts +144 -28
  255. package/dist/dts/Function.d.ts.map +1 -1
  256. package/dist/dts/GroupBy.d.ts +38 -0
  257. package/dist/dts/GroupBy.d.ts.map +1 -1
  258. package/dist/dts/Hash.d.ts +8 -0
  259. package/dist/dts/Hash.d.ts.map +1 -1
  260. package/dist/dts/HashMap.d.ts +315 -0
  261. package/dist/dts/HashMap.d.ts.map +1 -1
  262. package/dist/dts/HashSet.d.ts +284 -0
  263. package/dist/dts/HashSet.d.ts.map +1 -1
  264. package/dist/dts/Inspectable.d.ts +15 -0
  265. package/dist/dts/Inspectable.d.ts.map +1 -1
  266. package/dist/dts/Iterable.d.ts +454 -0
  267. package/dist/dts/Iterable.d.ts.map +1 -1
  268. package/dist/dts/KeyedPool.d.ts +34 -0
  269. package/dist/dts/KeyedPool.d.ts.map +1 -1
  270. package/dist/dts/Layer.d.ts +460 -5
  271. package/dist/dts/Layer.d.ts.map +1 -1
  272. package/dist/dts/List.d.ts +430 -0
  273. package/dist/dts/List.d.ts.map +1 -1
  274. package/dist/dts/LogLevel.d.ts +46 -0
  275. package/dist/dts/LogLevel.d.ts.map +1 -1
  276. package/dist/dts/Logger.d.ts +194 -0
  277. package/dist/dts/Logger.d.ts.map +1 -1
  278. package/dist/dts/Mailbox.d.ts +16 -0
  279. package/dist/dts/Mailbox.d.ts.map +1 -1
  280. package/dist/dts/ManagedRuntime.d.ts +41 -2
  281. package/dist/dts/ManagedRuntime.d.ts.map +1 -1
  282. package/dist/dts/MergeDecision.d.ts +8 -0
  283. package/dist/dts/MergeDecision.d.ts.map +1 -1
  284. package/dist/dts/MergeState.d.ts +8 -0
  285. package/dist/dts/MergeState.d.ts.map +1 -1
  286. package/dist/dts/MergeStrategy.d.ts +12 -0
  287. package/dist/dts/MergeStrategy.d.ts.map +1 -1
  288. package/dist/dts/Metric.d.ts +410 -0
  289. package/dist/dts/Metric.d.ts.map +1 -1
  290. package/dist/dts/MetricHook.d.ts +24 -0
  291. package/dist/dts/MetricHook.d.ts.map +1 -1
  292. package/dist/dts/MetricKey.d.ts +48 -0
  293. package/dist/dts/MetricKey.d.ts.map +1 -1
  294. package/dist/dts/MetricPolling.d.ts +40 -0
  295. package/dist/dts/MetricPolling.d.ts.map +1 -1
  296. package/dist/dts/MetricState.d.ts +16 -0
  297. package/dist/dts/MetricState.d.ts.map +1 -1
  298. package/dist/dts/Micro.d.ts +1110 -0
  299. package/dist/dts/Micro.d.ts.map +1 -1
  300. package/dist/dts/MutableHashMap.d.ts +50 -0
  301. package/dist/dts/MutableHashMap.d.ts.map +1 -1
  302. package/dist/dts/MutableHashSet.d.ts +24 -0
  303. package/dist/dts/MutableHashSet.d.ts.map +1 -1
  304. package/dist/dts/MutableList.d.ts +36 -0
  305. package/dist/dts/MutableList.d.ts.map +1 -1
  306. package/dist/dts/MutableQueue.d.ts +62 -0
  307. package/dist/dts/MutableQueue.d.ts.map +1 -1
  308. package/dist/dts/MutableRef.d.ts +56 -0
  309. package/dist/dts/MutableRef.d.ts.map +1 -1
  310. package/dist/dts/Number.d.ts +474 -0
  311. package/dist/dts/Number.d.ts.map +1 -1
  312. package/dist/dts/Option.d.ts +1019 -0
  313. package/dist/dts/Option.d.ts.map +1 -1
  314. package/dist/dts/Order.d.ts +24 -0
  315. package/dist/dts/Order.d.ts.map +1 -1
  316. package/dist/dts/Ordering.d.ts +66 -0
  317. package/dist/dts/Ordering.d.ts.map +1 -1
  318. package/dist/dts/Pipeable.d.ts +21 -21
  319. package/dist/dts/Pipeable.d.ts.map +1 -1
  320. package/dist/dts/Pool.d.ts +37 -1
  321. package/dist/dts/Pool.d.ts.map +1 -1
  322. package/dist/dts/Predicate.d.ts +513 -0
  323. package/dist/dts/Predicate.d.ts.map +1 -1
  324. package/dist/dts/PubSub.d.ts +28 -0
  325. package/dist/dts/PubSub.d.ts.map +1 -1
  326. package/dist/dts/Queue.d.ts +106 -2
  327. package/dist/dts/Queue.d.ts.map +1 -1
  328. package/dist/dts/RcMap.d.ts +70 -0
  329. package/dist/dts/RcMap.d.ts.map +1 -1
  330. package/dist/dts/Readable.d.ts +16 -0
  331. package/dist/dts/Readable.d.ts.map +1 -1
  332. package/dist/dts/Record.d.ts +800 -0
  333. package/dist/dts/Record.d.ts.map +1 -1
  334. package/dist/dts/RedBlackTree.d.ts +300 -0
  335. package/dist/dts/RedBlackTree.d.ts.map +1 -1
  336. package/dist/dts/Ref.d.ts +88 -0
  337. package/dist/dts/Ref.d.ts.map +1 -1
  338. package/dist/dts/RegExp.d.ts +12 -2
  339. package/dist/dts/RegExp.d.ts.map +1 -1
  340. package/dist/dts/Request.d.ts +76 -0
  341. package/dist/dts/Request.d.ts.map +1 -1
  342. package/dist/dts/RequestResolver.d.ts +144 -0
  343. package/dist/dts/RequestResolver.d.ts.map +1 -1
  344. package/dist/dts/Resource.d.ts +21 -1
  345. package/dist/dts/Resource.d.ts.map +1 -1
  346. package/dist/dts/Runtime.d.ts +126 -0
  347. package/dist/dts/Runtime.d.ts.map +1 -1
  348. package/dist/dts/RuntimeFlags.d.ts +100 -0
  349. package/dist/dts/RuntimeFlags.d.ts.map +1 -1
  350. package/dist/dts/RuntimeFlagsPatch.d.ts +112 -0
  351. package/dist/dts/RuntimeFlagsPatch.d.ts.map +1 -1
  352. package/dist/dts/STM.d.ts +1090 -0
  353. package/dist/dts/STM.d.ts.map +1 -1
  354. package/dist/dts/Schedule.d.ts +704 -0
  355. package/dist/dts/Schedule.d.ts.map +1 -1
  356. package/dist/dts/ScheduleInterval.d.ts +68 -0
  357. package/dist/dts/ScheduleInterval.d.ts.map +1 -1
  358. package/dist/dts/ScheduleIntervals.d.ts +50 -0
  359. package/dist/dts/ScheduleIntervals.d.ts.map +1 -1
  360. package/dist/dts/Scope.d.ts +36 -0
  361. package/dist/dts/Scope.d.ts.map +1 -1
  362. package/dist/dts/ScopedRef.d.ts +43 -1
  363. package/dist/dts/ScopedRef.d.ts.map +1 -1
  364. package/dist/dts/Sink.d.ts +464 -0
  365. package/dist/dts/Sink.d.ts.map +1 -1
  366. package/dist/dts/SortedMap.d.ts +76 -0
  367. package/dist/dts/SortedMap.d.ts.map +1 -1
  368. package/dist/dts/SortedSet.d.ts +142 -0
  369. package/dist/dts/SortedSet.d.ts.map +1 -1
  370. package/dist/dts/Stream.d.ts +4998 -1
  371. package/dist/dts/Stream.d.ts.map +1 -1
  372. package/dist/dts/StreamHaltStrategy.d.ts +12 -0
  373. package/dist/dts/StreamHaltStrategy.d.ts.map +1 -1
  374. package/dist/dts/String.d.ts +200 -0
  375. package/dist/dts/String.d.ts.map +1 -1
  376. package/dist/dts/Struct.d.ts +84 -0
  377. package/dist/dts/Struct.d.ts.map +1 -1
  378. package/dist/dts/Subscribable.d.ts +16 -0
  379. package/dist/dts/Subscribable.d.ts.map +1 -1
  380. package/dist/dts/SubscriptionRef.d.ts +152 -0
  381. package/dist/dts/SubscriptionRef.d.ts.map +1 -1
  382. package/dist/dts/SynchronizedRef.d.ts +152 -0
  383. package/dist/dts/SynchronizedRef.d.ts.map +1 -1
  384. package/dist/dts/TArray.d.ts +426 -0
  385. package/dist/dts/TArray.d.ts.map +1 -1
  386. package/dist/dts/TDeferred.d.ts +24 -0
  387. package/dist/dts/TDeferred.d.ts.map +1 -1
  388. package/dist/dts/TMap.d.ts +366 -0
  389. package/dist/dts/TMap.d.ts.map +1 -1
  390. package/dist/dts/TPriorityQueue.d.ts +60 -0
  391. package/dist/dts/TPriorityQueue.d.ts.map +1 -1
  392. package/dist/dts/TPubSub.d.ts +28 -0
  393. package/dist/dts/TPubSub.d.ts.map +1 -1
  394. package/dist/dts/TQueue.d.ts +108 -0
  395. package/dist/dts/TQueue.d.ts.map +1 -1
  396. package/dist/dts/TReentrantLock.d.ts +36 -0
  397. package/dist/dts/TReentrantLock.d.ts.map +1 -1
  398. package/dist/dts/TRef.d.ts +88 -0
  399. package/dist/dts/TRef.d.ts.map +1 -1
  400. package/dist/dts/TSemaphore.d.ts +40 -0
  401. package/dist/dts/TSemaphore.d.ts.map +1 -1
  402. package/dist/dts/TSet.d.ts +254 -0
  403. package/dist/dts/TSet.d.ts.map +1 -1
  404. package/dist/dts/Take.d.ts +56 -0
  405. package/dist/dts/Take.d.ts.map +1 -1
  406. package/dist/dts/TestAnnotationMap.d.ts.map +1 -1
  407. package/dist/dts/TestClock.d.ts.map +1 -1
  408. package/dist/dts/TestServices.d.ts.map +1 -1
  409. package/dist/dts/Trie.d.ts +906 -0
  410. package/dist/dts/Trie.d.ts.map +1 -1
  411. package/dist/dts/Tuple.d.ts +203 -0
  412. package/dist/dts/Tuple.d.ts.map +1 -1
  413. package/dist/dts/Types.d.ts +39 -0
  414. package/dist/dts/Types.d.ts.map +1 -1
  415. package/dist/dts/Unify.d.ts +26 -13
  416. package/dist/dts/Unify.d.ts.map +1 -1
  417. package/dist/dts/UpstreamPullRequest.d.ts +12 -0
  418. package/dist/dts/UpstreamPullRequest.d.ts.map +1 -1
  419. package/dist/dts/UpstreamPullStrategy.d.ts +12 -0
  420. package/dist/dts/UpstreamPullStrategy.d.ts.map +1 -1
  421. package/dist/dts/Utils.d.ts.map +1 -1
  422. package/dist/dts/internal/core.d.ts.map +1 -1
  423. package/dist/dts/internal/hashMap.d.ts.map +1 -1
  424. package/dist/dts/internal/layer.d.ts.map +1 -1
  425. package/dist/dts/internal/managedRuntime/circular.d.ts +2 -0
  426. package/dist/dts/internal/managedRuntime/circular.d.ts.map +1 -0
  427. package/dist/dts/internal/stream.d.ts.map +1 -1
  428. package/dist/esm/Array.js +21 -0
  429. package/dist/esm/Array.js.map +1 -1
  430. package/dist/esm/BigDecimal.js +6 -3
  431. package/dist/esm/BigDecimal.js.map +1 -1
  432. package/dist/esm/BigInt.js.map +1 -1
  433. package/dist/esm/Boolean.js.map +1 -1
  434. package/dist/esm/Cause.js.map +1 -1
  435. package/dist/esm/Channel.js.map +1 -1
  436. package/dist/esm/ChildExecutorDecision.js.map +1 -1
  437. package/dist/esm/Chunk.js +4 -1
  438. package/dist/esm/Chunk.js.map +1 -1
  439. package/dist/esm/Config.js.map +1 -1
  440. package/dist/esm/ConfigError.js.map +1 -1
  441. package/dist/esm/ConfigProvider.js.map +1 -1
  442. package/dist/esm/ConfigProviderPathPatch.js.map +1 -1
  443. package/dist/esm/Console.js.map +1 -1
  444. package/dist/esm/Context.js.map +1 -1
  445. package/dist/esm/Cron.js +4 -1
  446. package/dist/esm/Cron.js.map +1 -1
  447. package/dist/esm/Data.js.map +1 -1
  448. package/dist/esm/DateTime.js +6 -0
  449. package/dist/esm/DateTime.js.map +1 -1
  450. package/dist/esm/Deferred.js.map +1 -1
  451. package/dist/esm/Differ.js.map +1 -1
  452. package/dist/esm/Duration.js +4 -1
  453. package/dist/esm/Duration.js.map +1 -1
  454. package/dist/esm/Effect.js +116 -30
  455. package/dist/esm/Effect.js.map +1 -1
  456. package/dist/esm/Either.js.map +1 -1
  457. package/dist/esm/Equivalence.js.map +1 -1
  458. package/dist/esm/ExecutionStrategy.js.map +1 -1
  459. package/dist/esm/Exit.js.map +1 -1
  460. package/dist/esm/Fiber.js.map +1 -1
  461. package/dist/esm/FiberHandle.js +3 -0
  462. package/dist/esm/FiberHandle.js.map +1 -1
  463. package/dist/esm/FiberId.js.map +1 -1
  464. package/dist/esm/FiberMap.js +3 -0
  465. package/dist/esm/FiberMap.js.map +1 -1
  466. package/dist/esm/FiberRef.js.map +1 -1
  467. package/dist/esm/FiberRefs.js.map +1 -1
  468. package/dist/esm/FiberRefsPatch.js.map +1 -1
  469. package/dist/esm/FiberSet.js +3 -0
  470. package/dist/esm/FiberSet.js.map +1 -1
  471. package/dist/esm/Function.js.map +1 -1
  472. package/dist/esm/GroupBy.js.map +1 -1
  473. package/dist/esm/Hash.js.map +1 -1
  474. package/dist/esm/HashMap.js.map +1 -1
  475. package/dist/esm/HashSet.js.map +1 -1
  476. package/dist/esm/Inspectable.js +14 -0
  477. package/dist/esm/Inspectable.js.map +1 -1
  478. package/dist/esm/Iterable.js.map +1 -1
  479. package/dist/esm/KeyedPool.js.map +1 -1
  480. package/dist/esm/Layer.js.map +1 -1
  481. package/dist/esm/List.js +7 -1
  482. package/dist/esm/List.js.map +1 -1
  483. package/dist/esm/LogLevel.js.map +1 -1
  484. package/dist/esm/Logger.js.map +1 -1
  485. package/dist/esm/Mailbox.js.map +1 -1
  486. package/dist/esm/ManagedRuntime.js +15 -0
  487. package/dist/esm/ManagedRuntime.js.map +1 -1
  488. package/dist/esm/MergeDecision.js.map +1 -1
  489. package/dist/esm/MergeState.js.map +1 -1
  490. package/dist/esm/MergeStrategy.js.map +1 -1
  491. package/dist/esm/Metric.js.map +1 -1
  492. package/dist/esm/MetricHook.js.map +1 -1
  493. package/dist/esm/MetricKey.js.map +1 -1
  494. package/dist/esm/MetricPolling.js.map +1 -1
  495. package/dist/esm/MetricState.js.map +1 -1
  496. package/dist/esm/Micro.js +7 -1
  497. package/dist/esm/Micro.js.map +1 -1
  498. package/dist/esm/MutableHashMap.js +4 -1
  499. package/dist/esm/MutableHashMap.js.map +1 -1
  500. package/dist/esm/MutableHashSet.js +4 -1
  501. package/dist/esm/MutableHashSet.js.map +1 -1
  502. package/dist/esm/MutableList.js +4 -1
  503. package/dist/esm/MutableList.js.map +1 -1
  504. package/dist/esm/MutableQueue.js +4 -1
  505. package/dist/esm/MutableQueue.js.map +1 -1
  506. package/dist/esm/MutableRef.js +4 -1
  507. package/dist/esm/MutableRef.js.map +1 -1
  508. package/dist/esm/Number.js.map +1 -1
  509. package/dist/esm/Option.js.map +1 -1
  510. package/dist/esm/Order.js.map +1 -1
  511. package/dist/esm/Ordering.js.map +1 -1
  512. package/dist/esm/Pipeable.js.map +1 -1
  513. package/dist/esm/Pool.js.map +1 -1
  514. package/dist/esm/Predicate.js +15 -0
  515. package/dist/esm/Predicate.js.map +1 -1
  516. package/dist/esm/PubSub.js.map +1 -1
  517. package/dist/esm/Queue.js.map +1 -1
  518. package/dist/esm/RcMap.js.map +1 -1
  519. package/dist/esm/Readable.js.map +1 -1
  520. package/dist/esm/Record.js.map +1 -1
  521. package/dist/esm/RedBlackTree.js.map +1 -1
  522. package/dist/esm/Ref.js.map +1 -1
  523. package/dist/esm/RegExp.js +16 -0
  524. package/dist/esm/RegExp.js.map +1 -1
  525. package/dist/esm/Request.js.map +1 -1
  526. package/dist/esm/RequestResolver.js.map +1 -1
  527. package/dist/esm/Resource.js.map +1 -1
  528. package/dist/esm/Runtime.js.map +1 -1
  529. package/dist/esm/RuntimeFlags.js.map +1 -1
  530. package/dist/esm/RuntimeFlagsPatch.js.map +1 -1
  531. package/dist/esm/STM.js.map +1 -1
  532. package/dist/esm/Schedule.js.map +1 -1
  533. package/dist/esm/ScheduleInterval.js.map +1 -1
  534. package/dist/esm/ScheduleIntervals.js.map +1 -1
  535. package/dist/esm/Scheduler.js.map +1 -1
  536. package/dist/esm/Scope.js.map +1 -1
  537. package/dist/esm/ScopedRef.js.map +1 -1
  538. package/dist/esm/Sink.js.map +1 -1
  539. package/dist/esm/SortedMap.js +4 -1
  540. package/dist/esm/SortedMap.js.map +1 -1
  541. package/dist/esm/SortedSet.js +4 -1
  542. package/dist/esm/SortedSet.js.map +1 -1
  543. package/dist/esm/Stream.js +14 -0
  544. package/dist/esm/Stream.js.map +1 -1
  545. package/dist/esm/StreamHaltStrategy.js.map +1 -1
  546. package/dist/esm/String.js.map +1 -1
  547. package/dist/esm/Struct.js.map +1 -1
  548. package/dist/esm/Subscribable.js.map +1 -1
  549. package/dist/esm/SubscriptionRef.js.map +1 -1
  550. package/dist/esm/SynchronizedRef.js.map +1 -1
  551. package/dist/esm/TArray.js.map +1 -1
  552. package/dist/esm/TDeferred.js.map +1 -1
  553. package/dist/esm/TMap.js.map +1 -1
  554. package/dist/esm/TPriorityQueue.js.map +1 -1
  555. package/dist/esm/TPubSub.js.map +1 -1
  556. package/dist/esm/TQueue.js.map +1 -1
  557. package/dist/esm/TReentrantLock.js.map +1 -1
  558. package/dist/esm/TRef.js.map +1 -1
  559. package/dist/esm/TSemaphore.js.map +1 -1
  560. package/dist/esm/TSet.js.map +1 -1
  561. package/dist/esm/Take.js.map +1 -1
  562. package/dist/esm/TestAnnotationMap.js.map +1 -1
  563. package/dist/esm/TestClock.js.map +1 -1
  564. package/dist/esm/TestServices.js.map +1 -1
  565. package/dist/esm/Trie.js.map +1 -1
  566. package/dist/esm/Tuple.js +19 -0
  567. package/dist/esm/Tuple.js.map +1 -1
  568. package/dist/esm/Unify.js.map +1 -1
  569. package/dist/esm/UpstreamPullRequest.js.map +1 -1
  570. package/dist/esm/UpstreamPullStrategy.js.map +1 -1
  571. package/dist/esm/Utils.js +1 -14
  572. package/dist/esm/Utils.js.map +1 -1
  573. package/dist/esm/internal/cause.js +4 -1
  574. package/dist/esm/internal/cause.js.map +1 -1
  575. package/dist/esm/internal/context.js +7 -2
  576. package/dist/esm/internal/context.js.map +1 -1
  577. package/dist/esm/internal/core-effect.js.map +1 -1
  578. package/dist/esm/internal/core.js +14 -2
  579. package/dist/esm/internal/core.js.map +1 -1
  580. package/dist/esm/internal/effect/circular.js +5 -1
  581. package/dist/esm/internal/effect/circular.js.map +1 -1
  582. package/dist/esm/internal/fiberId.js +10 -1
  583. package/dist/esm/internal/fiberId.js.map +1 -1
  584. package/dist/esm/internal/hashMap.js +4 -1
  585. package/dist/esm/internal/hashMap.js.map +1 -1
  586. package/dist/esm/internal/hashSet.js +4 -1
  587. package/dist/esm/internal/hashSet.js.map +1 -1
  588. package/dist/esm/internal/layer.js +32 -18
  589. package/dist/esm/internal/layer.js.map +1 -1
  590. package/dist/esm/internal/mailbox.js +3 -0
  591. package/dist/esm/internal/mailbox.js.map +1 -1
  592. package/dist/esm/internal/managedRuntime/circular.js +4 -0
  593. package/dist/esm/internal/managedRuntime/circular.js.map +1 -0
  594. package/dist/esm/internal/managedRuntime.js +21 -8
  595. package/dist/esm/internal/managedRuntime.js.map +1 -1
  596. package/dist/esm/internal/option.js +4 -1
  597. package/dist/esm/internal/option.js.map +1 -1
  598. package/dist/esm/internal/pool.js +6 -1
  599. package/dist/esm/internal/pool.js.map +1 -1
  600. package/dist/esm/internal/redBlackTree.js +4 -1
  601. package/dist/esm/internal/redBlackTree.js.map +1 -1
  602. package/dist/esm/internal/resource.js +15 -5
  603. package/dist/esm/internal/resource.js.map +1 -1
  604. package/dist/esm/internal/runtime.js +4 -1
  605. package/dist/esm/internal/runtime.js.map +1 -1
  606. package/dist/esm/internal/scopedRef.js +11 -8
  607. package/dist/esm/internal/scopedRef.js.map +1 -1
  608. package/dist/esm/internal/stm/core.js +1 -2
  609. package/dist/esm/internal/stm/core.js.map +1 -1
  610. package/dist/esm/internal/stream.js +9 -0
  611. package/dist/esm/internal/stream.js.map +1 -1
  612. package/dist/esm/internal/trie.js +4 -1
  613. package/dist/esm/internal/trie.js.map +1 -1
  614. package/dist/esm/internal/version.js +1 -1
  615. package/package.json +1 -1
  616. package/src/Array.ts +2791 -40
  617. package/src/BigDecimal.ts +589 -19
  618. package/src/BigInt.ts +516 -16
  619. package/src/Boolean.ts +241 -8
  620. package/src/Cause.ts +177 -1
  621. package/src/Channel.ts +766 -49
  622. package/src/ChildExecutorDecision.ts +12 -0
  623. package/src/Chunk.ts +822 -5
  624. package/src/Config.ts +187 -8
  625. package/src/ConfigError.ts +16 -0
  626. package/src/ConfigProvider.ts +89 -1
  627. package/src/ConfigProviderPathPatch.ts +32 -0
  628. package/src/Console.ts +37 -8
  629. package/src/Context.ts +234 -3
  630. package/src/Cron.ts +16 -1
  631. package/src/Data.ts +165 -0
  632. package/src/DateTime.ts +1012 -50
  633. package/src/Deferred.ts +171 -1
  634. package/src/Differ.ts +89 -27
  635. package/src/Duration.ts +160 -17
  636. package/src/Effect.ts +4717 -164
  637. package/src/Either.ts +650 -34
  638. package/src/Equivalence.ts +24 -0
  639. package/src/ExecutionStrategy.ts +29 -10
  640. package/src/Exit.ts +252 -0
  641. package/src/Fiber.ts +182 -0
  642. package/src/FiberHandle.ts +45 -0
  643. package/src/FiberId.ts +24 -0
  644. package/src/FiberMap.ts +147 -21
  645. package/src/FiberRef.ts +80 -0
  646. package/src/FiberRefs.ts +84 -0
  647. package/src/FiberRefsPatch.ts +35 -1
  648. package/src/FiberSet.ts +41 -0
  649. package/src/Function.ts +416 -31
  650. package/src/GroupBy.ts +38 -0
  651. package/src/Hash.ts +8 -0
  652. package/src/HashMap.ts +316 -0
  653. package/src/HashSet.ts +284 -0
  654. package/src/Inspectable.ts +22 -0
  655. package/src/Iterable.ts +456 -6
  656. package/src/KeyedPool.ts +34 -0
  657. package/src/Layer.ts +475 -38
  658. package/src/List.ts +483 -4
  659. package/src/LogLevel.ts +46 -0
  660. package/src/Logger.ts +195 -4
  661. package/src/Mailbox.ts +16 -0
  662. package/src/ManagedRuntime.ts +46 -2
  663. package/src/MergeDecision.ts +8 -0
  664. package/src/MergeState.ts +8 -0
  665. package/src/MergeStrategy.ts +25 -8
  666. package/src/Metric.ts +426 -15
  667. package/src/MetricHook.ts +24 -0
  668. package/src/MetricKey.ts +62 -8
  669. package/src/MetricPolling.ts +42 -6
  670. package/src/MetricState.ts +16 -0
  671. package/src/Micro.ts +1223 -61
  672. package/src/MutableHashMap.ts +109 -2
  673. package/src/MutableHashSet.ts +28 -1
  674. package/src/MutableList.ts +40 -1
  675. package/src/MutableQueue.ts +66 -1
  676. package/src/MutableRef.ts +60 -1
  677. package/src/Number.ts +500 -16
  678. package/src/Option.ts +1042 -16
  679. package/src/Order.ts +24 -0
  680. package/src/Ordering.ts +66 -0
  681. package/src/Pipeable.ts +224 -21
  682. package/src/Pool.ts +42 -1
  683. package/src/Predicate.ts +514 -0
  684. package/src/PubSub.ts +28 -0
  685. package/src/Queue.ts +106 -2
  686. package/src/RcMap.ts +70 -0
  687. package/src/Readable.ts +18 -7
  688. package/src/Record.ts +814 -40
  689. package/src/RedBlackTree.ts +305 -1
  690. package/src/Ref.ts +88 -0
  691. package/src/RegExp.ts +17 -0
  692. package/src/Request.ts +76 -0
  693. package/src/RequestResolver.ts +145 -4
  694. package/src/Resource.ts +22 -1
  695. package/src/Runtime.ts +134 -2
  696. package/src/RuntimeFlags.ts +100 -0
  697. package/src/RuntimeFlagsPatch.ts +112 -0
  698. package/src/STM.ts +1107 -11
  699. package/src/Schedule.ts +704 -0
  700. package/src/ScheduleInterval.ts +68 -0
  701. package/src/ScheduleIntervals.ts +50 -0
  702. package/src/Scheduler.ts +2 -0
  703. package/src/Scope.ts +36 -0
  704. package/src/ScopedRef.ts +44 -1
  705. package/src/Sink.ts +464 -0
  706. package/src/SortedMap.ts +80 -1
  707. package/src/SortedSet.ts +147 -4
  708. package/src/Stream.ts +5041 -54
  709. package/src/StreamHaltStrategy.ts +29 -12
  710. package/src/String.ts +200 -0
  711. package/src/Struct.ts +86 -7
  712. package/src/Subscribable.ts +16 -0
  713. package/src/SubscriptionRef.ts +159 -11
  714. package/src/SynchronizedRef.ts +169 -8
  715. package/src/TArray.ts +431 -1
  716. package/src/TDeferred.ts +24 -0
  717. package/src/TMap.ts +381 -12
  718. package/src/TPriorityQueue.ts +60 -0
  719. package/src/TPubSub.ts +28 -0
  720. package/src/TQueue.ts +108 -0
  721. package/src/TReentrantLock.ts +36 -0
  722. package/src/TRef.ts +88 -0
  723. package/src/TSemaphore.ts +40 -0
  724. package/src/TSet.ts +280 -12
  725. package/src/Take.ts +56 -0
  726. package/src/TestAnnotationMap.ts +45 -1
  727. package/src/TestClock.ts +6 -0
  728. package/src/TestServices.ts +66 -0
  729. package/src/Trie.ts +906 -0
  730. package/src/Tuple.ts +223 -8
  731. package/src/Types.ts +41 -0
  732. package/src/Unify.ts +28 -17
  733. package/src/UpstreamPullRequest.ts +12 -0
  734. package/src/UpstreamPullStrategy.ts +12 -0
  735. package/src/Utils.ts +1 -15
  736. package/src/internal/cause.ts +4 -1
  737. package/src/internal/context.ts +7 -2
  738. package/src/internal/core-effect.ts +7 -7
  739. package/src/internal/core.ts +14 -2
  740. package/src/internal/effect/circular.ts +8 -2
  741. package/src/internal/fiberId.ts +10 -1
  742. package/src/internal/hashMap.ts +4 -1
  743. package/src/internal/hashSet.ts +4 -1
  744. package/src/internal/layer.ts +105 -38
  745. package/src/internal/mailbox.ts +3 -0
  746. package/src/internal/managedRuntime/circular.ts +6 -0
  747. package/src/internal/managedRuntime.ts +36 -22
  748. package/src/internal/option.ts +4 -1
  749. package/src/internal/pool.ts +7 -1
  750. package/src/internal/redBlackTree.ts +4 -1
  751. package/src/internal/resource.ts +16 -5
  752. package/src/internal/runtime.ts +4 -1
  753. package/src/internal/scopedRef.ts +12 -8
  754. package/src/internal/stm/core.ts +2 -3
  755. package/src/internal/stream.ts +27 -0
  756. package/src/internal/trie.ts +4 -1
  757. package/src/internal/version.ts +1 -1
@@ -95,7 +95,33 @@ export declare const range: (start: number, end: number) => NonEmptyArray<number
95
95
  * @since 2.0.0
96
96
  */
97
97
  export declare const replicate: {
98
+ /**
99
+ * Return a `NonEmptyArray` containing a value repeated the specified number of times.
100
+ *
101
+ * **Note**. `n` is normalized to an integer >= 1.
102
+ *
103
+ * @example
104
+ * import { Array } from "effect"
105
+ *
106
+ * assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
107
+ *
108
+ * @category constructors
109
+ * @since 2.0.0
110
+ */
98
111
  (n: number): <A>(a: A) => NonEmptyArray<A>;
112
+ /**
113
+ * Return a `NonEmptyArray` containing a value repeated the specified number of times.
114
+ *
115
+ * **Note**. `n` is normalized to an integer >= 1.
116
+ *
117
+ * @example
118
+ * import { Array } from "effect"
119
+ *
120
+ * assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
121
+ *
122
+ * @category constructors
123
+ * @since 2.0.0
124
+ */
99
125
  <A>(a: A, n: number): NonEmptyArray<A>;
100
126
  };
101
127
  /**
@@ -173,10 +199,42 @@ export declare const fromOption: <A>(self: Option<A>) => Array<A>;
173
199
  * @since 2.0.0
174
200
  */
175
201
  export declare const match: {
202
+ /**
203
+ * Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
204
+ *
205
+ * @example
206
+ * import { Array } from "effect"
207
+ *
208
+ * const match = Array.match({
209
+ * onEmpty: () => "empty",
210
+ * onNonEmpty: ([head, ...tail]) => `head: ${head}, tail: ${tail.length}`
211
+ * })
212
+ * assert.deepStrictEqual(match([]), "empty")
213
+ * assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
214
+ *
215
+ * @category pattern matching
216
+ * @since 2.0.0
217
+ */
176
218
  <B, A, C = B>(options: {
177
219
  readonly onEmpty: LazyArg<B>;
178
220
  readonly onNonEmpty: (self: NonEmptyReadonlyArray<A>) => C;
179
221
  }): (self: ReadonlyArray<A>) => B | C;
222
+ /**
223
+ * Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
224
+ *
225
+ * @example
226
+ * import { Array } from "effect"
227
+ *
228
+ * const match = Array.match({
229
+ * onEmpty: () => "empty",
230
+ * onNonEmpty: ([head, ...tail]) => `head: ${head}, tail: ${tail.length}`
231
+ * })
232
+ * assert.deepStrictEqual(match([]), "empty")
233
+ * assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
234
+ *
235
+ * @category pattern matching
236
+ * @since 2.0.0
237
+ */
180
238
  <A, B, C = B>(self: ReadonlyArray<A>, options: {
181
239
  readonly onEmpty: LazyArg<B>;
182
240
  readonly onNonEmpty: (self: NonEmptyReadonlyArray<A>) => C;
@@ -199,10 +257,42 @@ export declare const match: {
199
257
  * @since 2.0.0
200
258
  */
201
259
  export declare const matchLeft: {
260
+ /**
261
+ * Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
262
+ *
263
+ * @example
264
+ * import { Array } from "effect"
265
+ *
266
+ * const matchLeft = Array.matchLeft({
267
+ * onEmpty: () => "empty",
268
+ * onNonEmpty: (head, tail) => `head: ${head}, tail: ${tail.length}`
269
+ * })
270
+ * assert.deepStrictEqual(matchLeft([]), "empty")
271
+ * assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
272
+ *
273
+ * @category pattern matching
274
+ * @since 2.0.0
275
+ */
202
276
  <B, A, C = B>(options: {
203
277
  readonly onEmpty: LazyArg<B>;
204
278
  readonly onNonEmpty: (head: A, tail: Array<A>) => C;
205
279
  }): (self: ReadonlyArray<A>) => B | C;
280
+ /**
281
+ * Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
282
+ *
283
+ * @example
284
+ * import { Array } from "effect"
285
+ *
286
+ * const matchLeft = Array.matchLeft({
287
+ * onEmpty: () => "empty",
288
+ * onNonEmpty: (head, tail) => `head: ${head}, tail: ${tail.length}`
289
+ * })
290
+ * assert.deepStrictEqual(matchLeft([]), "empty")
291
+ * assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
292
+ *
293
+ * @category pattern matching
294
+ * @since 2.0.0
295
+ */
206
296
  <A, B, C = B>(self: ReadonlyArray<A>, options: {
207
297
  readonly onEmpty: LazyArg<B>;
208
298
  readonly onNonEmpty: (head: A, tail: Array<A>) => C;
@@ -225,10 +315,42 @@ export declare const matchLeft: {
225
315
  * @since 2.0.0
226
316
  */
227
317
  export declare const matchRight: {
318
+ /**
319
+ * Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
320
+ *
321
+ * @example
322
+ * import { Array } from "effect"
323
+ *
324
+ * const matchRight = Array.matchRight({
325
+ * onEmpty: () => "empty",
326
+ * onNonEmpty: (init, last) => `init: ${init.length}, last: ${last}`
327
+ * })
328
+ * assert.deepStrictEqual(matchRight([]), "empty")
329
+ * assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
330
+ *
331
+ * @category pattern matching
332
+ * @since 2.0.0
333
+ */
228
334
  <B, A, C = B>(options: {
229
335
  readonly onEmpty: LazyArg<B>;
230
336
  readonly onNonEmpty: (init: Array<A>, last: A) => C;
231
337
  }): (self: ReadonlyArray<A>) => B | C;
338
+ /**
339
+ * Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
340
+ *
341
+ * @example
342
+ * import { Array } from "effect"
343
+ *
344
+ * const matchRight = Array.matchRight({
345
+ * onEmpty: () => "empty",
346
+ * onNonEmpty: (init, last) => `init: ${init.length}, last: ${last}`
347
+ * })
348
+ * assert.deepStrictEqual(matchRight([]), "empty")
349
+ * assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
350
+ *
351
+ * @category pattern matching
352
+ * @since 2.0.0
353
+ */
232
354
  <A, B, C = B>(self: ReadonlyArray<A>, options: {
233
355
  readonly onEmpty: LazyArg<B>;
234
356
  readonly onNonEmpty: (init: Array<A>, last: A) => C;
@@ -248,7 +370,33 @@ export declare const matchRight: {
248
370
  * @since 2.0.0
249
371
  */
250
372
  export declare const prepend: {
373
+ /**
374
+ * Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
375
+ *
376
+ * @example
377
+ * import { Array } from "effect"
378
+ *
379
+ * const original = [2, 3, 4];
380
+ * const result = Array.prepend(original, 1);
381
+ * assert.deepStrictEqual(result, [1, 2, 3, 4]);
382
+ *
383
+ * @category concatenating
384
+ * @since 2.0.0
385
+ */
251
386
  <B>(head: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>;
387
+ /**
388
+ * Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
389
+ *
390
+ * @example
391
+ * import { Array } from "effect"
392
+ *
393
+ * const original = [2, 3, 4];
394
+ * const result = Array.prepend(original, 1);
395
+ * assert.deepStrictEqual(result, [1, 2, 3, 4]);
396
+ *
397
+ * @category concatenating
398
+ * @since 2.0.0
399
+ */
252
400
  <A, B>(self: Iterable<A>, head: B): NonEmptyArray<A | B>;
253
401
  };
254
402
  /**
@@ -267,9 +415,69 @@ export declare const prepend: {
267
415
  * @since 2.0.0
268
416
  */
269
417
  export declare const prependAll: {
418
+ /**
419
+ * Prepends the specified prefix array (or iterable) to the beginning of the specified array (or iterable).
420
+ * If either array is non-empty, the result is also a non-empty array.
421
+ *
422
+ * @example
423
+ * import { Array } from "effect"
424
+ *
425
+ * const prefix = [0, 1];
426
+ * const array = [2, 3];
427
+ * const result = Array.prependAll(array, prefix);
428
+ * assert.deepStrictEqual(result, [0, 1, 2, 3]);
429
+ *
430
+ * @category concatenating
431
+ * @since 2.0.0
432
+ */
270
433
  <S extends Iterable<any>, T extends Iterable<any>>(that: T): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>;
434
+ /**
435
+ * Prepends the specified prefix array (or iterable) to the beginning of the specified array (or iterable).
436
+ * If either array is non-empty, the result is also a non-empty array.
437
+ *
438
+ * @example
439
+ * import { Array } from "effect"
440
+ *
441
+ * const prefix = [0, 1];
442
+ * const array = [2, 3];
443
+ * const result = Array.prependAll(array, prefix);
444
+ * assert.deepStrictEqual(result, [0, 1, 2, 3]);
445
+ *
446
+ * @category concatenating
447
+ * @since 2.0.0
448
+ */
271
449
  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>;
450
+ /**
451
+ * Prepends the specified prefix array (or iterable) to the beginning of the specified array (or iterable).
452
+ * If either array is non-empty, the result is also a non-empty array.
453
+ *
454
+ * @example
455
+ * import { Array } from "effect"
456
+ *
457
+ * const prefix = [0, 1];
458
+ * const array = [2, 3];
459
+ * const result = Array.prependAll(array, prefix);
460
+ * assert.deepStrictEqual(result, [0, 1, 2, 3]);
461
+ *
462
+ * @category concatenating
463
+ * @since 2.0.0
464
+ */
272
465
  <A, B>(self: NonEmptyReadonlyArray<A>, that: Iterable<B>): NonEmptyArray<A | B>;
466
+ /**
467
+ * Prepends the specified prefix array (or iterable) to the beginning of the specified array (or iterable).
468
+ * If either array is non-empty, the result is also a non-empty array.
469
+ *
470
+ * @example
471
+ * import { Array } from "effect"
472
+ *
473
+ * const prefix = [0, 1];
474
+ * const array = [2, 3];
475
+ * const result = Array.prependAll(array, prefix);
476
+ * assert.deepStrictEqual(result, [0, 1, 2, 3]);
477
+ *
478
+ * @category concatenating
479
+ * @since 2.0.0
480
+ */
273
481
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>;
274
482
  };
275
483
  /**
@@ -286,7 +494,33 @@ export declare const prependAll: {
286
494
  * @since 2.0.0
287
495
  */
288
496
  export declare const append: {
497
+ /**
498
+ * Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
499
+ *
500
+ * @example
501
+ * import { Array } from "effect"
502
+ *
503
+ * const original = [1, 2, 3];
504
+ * const result = Array.append(original, 4);
505
+ * assert.deepStrictEqual(result, [1, 2, 3, 4]);
506
+ *
507
+ * @category concatenating
508
+ * @since 2.0.0
509
+ */
289
510
  <B>(last: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>;
511
+ /**
512
+ * Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
513
+ *
514
+ * @example
515
+ * import { Array } from "effect"
516
+ *
517
+ * const original = [1, 2, 3];
518
+ * const result = Array.append(original, 4);
519
+ * assert.deepStrictEqual(result, [1, 2, 3, 4]);
520
+ *
521
+ * @category concatenating
522
+ * @since 2.0.0
523
+ */
290
524
  <A, B>(self: Iterable<A>, last: B): NonEmptyArray<A | B>;
291
525
  };
292
526
  /**
@@ -297,9 +531,37 @@ export declare const append: {
297
531
  * @since 2.0.0
298
532
  */
299
533
  export declare const appendAll: {
534
+ /**
535
+ * Concatenates two arrays (or iterables), combining their elements.
536
+ * If either array is non-empty, the result is also a non-empty array.
537
+ *
538
+ * @category concatenating
539
+ * @since 2.0.0
540
+ */
300
541
  <S extends Iterable<any>, T extends Iterable<any>>(that: T): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>;
542
+ /**
543
+ * Concatenates two arrays (or iterables), combining their elements.
544
+ * If either array is non-empty, the result is also a non-empty array.
545
+ *
546
+ * @category concatenating
547
+ * @since 2.0.0
548
+ */
301
549
  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>;
550
+ /**
551
+ * Concatenates two arrays (or iterables), combining their elements.
552
+ * If either array is non-empty, the result is also a non-empty array.
553
+ *
554
+ * @category concatenating
555
+ * @since 2.0.0
556
+ */
302
557
  <A, B>(self: NonEmptyReadonlyArray<A>, that: Iterable<B>): NonEmptyArray<A | B>;
558
+ /**
559
+ * Concatenates two arrays (or iterables), combining their elements.
560
+ * If either array is non-empty, the result is also a non-empty array.
561
+ *
562
+ * @category concatenating
563
+ * @since 2.0.0
564
+ */
303
565
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>;
304
566
  };
305
567
  /**
@@ -324,7 +586,49 @@ export declare const appendAll: {
324
586
  * @since 2.0.0
325
587
  */
326
588
  export declare const scan: {
589
+ /**
590
+ * Accumulates values from an `Iterable` starting from the left, storing
591
+ * each intermediate result in an array. Useful for tracking the progression of
592
+ * a value through a series of transformations.
593
+ *
594
+ * @example
595
+ * import { Array } from "effect";
596
+ *
597
+ * const numbers = [1, 2, 3, 4]
598
+ * const result = Array.scan(numbers, 0, (acc, value) => acc + value)
599
+ * assert.deepStrictEqual(result, [0, 1, 3, 6, 10])
600
+ *
601
+ * // Explanation:
602
+ * // This function starts with the initial value (0 in this case)
603
+ * // and adds each element of the array to this accumulator one by one,
604
+ * // keeping track of the cumulative sum after each addition.
605
+ * // Each of these sums is captured in the resulting array.
606
+ *
607
+ * @category folding
608
+ * @since 2.0.0
609
+ */
327
610
  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<A>) => NonEmptyArray<B>;
611
+ /**
612
+ * Accumulates values from an `Iterable` starting from the left, storing
613
+ * each intermediate result in an array. Useful for tracking the progression of
614
+ * a value through a series of transformations.
615
+ *
616
+ * @example
617
+ * import { Array } from "effect";
618
+ *
619
+ * const numbers = [1, 2, 3, 4]
620
+ * const result = Array.scan(numbers, 0, (acc, value) => acc + value)
621
+ * assert.deepStrictEqual(result, [0, 1, 3, 6, 10])
622
+ *
623
+ * // Explanation:
624
+ * // This function starts with the initial value (0 in this case)
625
+ * // and adds each element of the array to this accumulator one by one,
626
+ * // keeping track of the cumulative sum after each addition.
627
+ * // Each of these sums is captured in the resulting array.
628
+ *
629
+ * @category folding
630
+ * @since 2.0.0
631
+ */
328
632
  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): NonEmptyArray<B>;
329
633
  };
330
634
  /**
@@ -343,7 +647,37 @@ export declare const scan: {
343
647
  * @since 2.0.0
344
648
  */
345
649
  export declare const scanRight: {
650
+ /**
651
+ * Accumulates values from an `Iterable` starting from the right, storing
652
+ * each intermediate result in an array. Useful for tracking the progression of
653
+ * a value through a series of transformations.
654
+ *
655
+ * @example
656
+ * import { Array } from "effect";
657
+ *
658
+ * const numbers = [1, 2, 3, 4]
659
+ * const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
660
+ * assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
661
+ *
662
+ * @category folding
663
+ * @since 2.0.0
664
+ */
346
665
  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<A>) => NonEmptyArray<B>;
666
+ /**
667
+ * Accumulates values from an `Iterable` starting from the right, storing
668
+ * each intermediate result in an array. Useful for tracking the progression of
669
+ * a value through a series of transformations.
670
+ *
671
+ * @example
672
+ * import { Array } from "effect";
673
+ *
674
+ * const numbers = [1, 2, 3, 4]
675
+ * const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
676
+ * assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
677
+ *
678
+ * @category folding
679
+ * @since 2.0.0
680
+ */
347
681
  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): NonEmptyArray<B>;
348
682
  };
349
683
  /**
@@ -361,7 +695,35 @@ export declare const scanRight: {
361
695
  * @since 2.0.0
362
696
  */
363
697
  export declare const isArray: {
698
+ /**
699
+ * Determine if `unknown` is an Array.
700
+ *
701
+ * @param self - The value to check.
702
+ *
703
+ * @example
704
+ * import { isArray } from "effect/Array"
705
+ *
706
+ * assert.deepStrictEqual(isArray(null), false);
707
+ * assert.deepStrictEqual(isArray([1, 2, 3]), true);
708
+ *
709
+ * @category guards
710
+ * @since 2.0.0
711
+ */
364
712
  (self: unknown): self is Array<unknown>;
713
+ /**
714
+ * Determine if `unknown` is an Array.
715
+ *
716
+ * @param self - The value to check.
717
+ *
718
+ * @example
719
+ * import { isArray } from "effect/Array"
720
+ *
721
+ * assert.deepStrictEqual(isArray(null), false);
722
+ * assert.deepStrictEqual(isArray([1, 2, 3]), true);
723
+ *
724
+ * @category guards
725
+ * @since 2.0.0
726
+ */
365
727
  <T>(self: T): self is Extract<T, ReadonlyArray<any>>;
366
728
  };
367
729
  /**
@@ -442,7 +804,19 @@ export declare const length: <A>(self: ReadonlyArray<A>) => number;
442
804
  * @since 2.0.0
443
805
  */
444
806
  export declare const get: {
807
+ /**
808
+ * This function provides a safe way to read a value at a particular index from a `ReadonlyArray`.
809
+ *
810
+ * @category getters
811
+ * @since 2.0.0
812
+ */
445
813
  (index: number): <A>(self: ReadonlyArray<A>) => Option<A>;
814
+ /**
815
+ * This function provides a safe way to read a value at a particular index from a `ReadonlyArray`.
816
+ *
817
+ * @category getters
818
+ * @since 2.0.0
819
+ */
446
820
  <A>(self: ReadonlyArray<A>, index: number): Option<A>;
447
821
  };
448
822
  /**
@@ -452,7 +826,19 @@ export declare const get: {
452
826
  * @category unsafe
453
827
  */
454
828
  export declare const unsafeGet: {
829
+ /**
830
+ * Gets an element unsafely, will throw on out of bounds.
831
+ *
832
+ * @since 2.0.0
833
+ * @category unsafe
834
+ */
455
835
  (index: number): <A>(self: ReadonlyArray<A>) => A;
836
+ /**
837
+ * Gets an element unsafely, will throw on out of bounds.
838
+ *
839
+ * @since 2.0.0
840
+ * @category unsafe
841
+ */
456
842
  <A>(self: ReadonlyArray<A>, index: number): A;
457
843
  };
458
844
  /**
@@ -577,7 +963,37 @@ export declare const initNonEmpty: <A>(self: NonEmptyReadonlyArray<A>) => Array<
577
963
  * @since 2.0.0
578
964
  */
579
965
  export declare const take: {
966
+ /**
967
+ * Keep only a max number of elements from the start of an `Iterable`, creating a new `Array`.
968
+ *
969
+ * **Note**. `n` is normalized to a non negative integer.
970
+ *
971
+ * @example
972
+ * import { Array } from "effect"
973
+ *
974
+ * const numbers = [1, 2, 3, 4, 5]
975
+ * const result = Array.take(numbers, 3)
976
+ * assert.deepStrictEqual(result, [1, 2, 3])
977
+ *
978
+ * @category getters
979
+ * @since 2.0.0
980
+ */
580
981
  (n: number): <A>(self: Iterable<A>) => Array<A>;
982
+ /**
983
+ * Keep only a max number of elements from the start of an `Iterable`, creating a new `Array`.
984
+ *
985
+ * **Note**. `n` is normalized to a non negative integer.
986
+ *
987
+ * @example
988
+ * import { Array } from "effect"
989
+ *
990
+ * const numbers = [1, 2, 3, 4, 5]
991
+ * const result = Array.take(numbers, 3)
992
+ * assert.deepStrictEqual(result, [1, 2, 3])
993
+ *
994
+ * @category getters
995
+ * @since 2.0.0
996
+ */
581
997
  <A>(self: Iterable<A>, n: number): Array<A>;
582
998
  };
583
999
  /**
@@ -596,7 +1012,37 @@ export declare const take: {
596
1012
  * @since 2.0.0
597
1013
  */
598
1014
  export declare const takeRight: {
1015
+ /**
1016
+ * Keep only a max number of elements from the end of an `Iterable`, creating a new `Array`.
1017
+ *
1018
+ * **Note**. `n` is normalized to a non negative integer.
1019
+ *
1020
+ * @example
1021
+ * import { Array } from "effect"
1022
+ *
1023
+ * const numbers = [1, 2, 3, 4, 5]
1024
+ * const result = Array.takeRight(numbers, 3)
1025
+ * assert.deepStrictEqual(result, [3, 4, 5])
1026
+ *
1027
+ * @category getters
1028
+ * @since 2.0.0
1029
+ */
599
1030
  (n: number): <A>(self: Iterable<A>) => Array<A>;
1031
+ /**
1032
+ * Keep only a max number of elements from the end of an `Iterable`, creating a new `Array`.
1033
+ *
1034
+ * **Note**. `n` is normalized to a non negative integer.
1035
+ *
1036
+ * @example
1037
+ * import { Array } from "effect"
1038
+ *
1039
+ * const numbers = [1, 2, 3, 4, 5]
1040
+ * const result = Array.takeRight(numbers, 3)
1041
+ * assert.deepStrictEqual(result, [3, 4, 5])
1042
+ *
1043
+ * @category getters
1044
+ * @since 2.0.0
1045
+ */
600
1046
  <A>(self: Iterable<A>, n: number): Array<A>;
601
1047
  };
602
1048
  /**
@@ -619,9 +1065,85 @@ export declare const takeRight: {
619
1065
  * @since 2.0.0
620
1066
  */
621
1067
  export declare const takeWhile: {
1068
+ /**
1069
+ * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
1070
+ *
1071
+ * @example
1072
+ * import { Array } from "effect"
1073
+ *
1074
+ * const numbers = [1, 3, 2, 4, 1, 2]
1075
+ * const result = Array.takeWhile(numbers, x => x < 4)
1076
+ * assert.deepStrictEqual(result, [1, 3, 2])
1077
+ *
1078
+ * // Explanation:
1079
+ * // - The function starts with the first element (`1`), which is less than `4`, so it adds `1` to the result.
1080
+ * // - The next element (`3`) is also less than `4`, so it adds `3`.
1081
+ * // - The next element (`2`) is again less than `4`, so it adds `2`.
1082
+ * // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
1083
+ *
1084
+ * @category getters
1085
+ * @since 2.0.0
1086
+ */
622
1087
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Array<B>;
1088
+ /**
1089
+ * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
1090
+ *
1091
+ * @example
1092
+ * import { Array } from "effect"
1093
+ *
1094
+ * const numbers = [1, 3, 2, 4, 1, 2]
1095
+ * const result = Array.takeWhile(numbers, x => x < 4)
1096
+ * assert.deepStrictEqual(result, [1, 3, 2])
1097
+ *
1098
+ * // Explanation:
1099
+ * // - The function starts with the first element (`1`), which is less than `4`, so it adds `1` to the result.
1100
+ * // - The next element (`3`) is also less than `4`, so it adds `3`.
1101
+ * // - The next element (`2`) is again less than `4`, so it adds `2`.
1102
+ * // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
1103
+ *
1104
+ * @category getters
1105
+ * @since 2.0.0
1106
+ */
623
1107
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Array<A>;
1108
+ /**
1109
+ * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
1110
+ *
1111
+ * @example
1112
+ * import { Array } from "effect"
1113
+ *
1114
+ * const numbers = [1, 3, 2, 4, 1, 2]
1115
+ * const result = Array.takeWhile(numbers, x => x < 4)
1116
+ * assert.deepStrictEqual(result, [1, 3, 2])
1117
+ *
1118
+ * // Explanation:
1119
+ * // - The function starts with the first element (`1`), which is less than `4`, so it adds `1` to the result.
1120
+ * // - The next element (`3`) is also less than `4`, so it adds `3`.
1121
+ * // - The next element (`2`) is again less than `4`, so it adds `2`.
1122
+ * // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
1123
+ *
1124
+ * @category getters
1125
+ * @since 2.0.0
1126
+ */
624
1127
  <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Array<B>;
1128
+ /**
1129
+ * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
1130
+ *
1131
+ * @example
1132
+ * import { Array } from "effect"
1133
+ *
1134
+ * const numbers = [1, 3, 2, 4, 1, 2]
1135
+ * const result = Array.takeWhile(numbers, x => x < 4)
1136
+ * assert.deepStrictEqual(result, [1, 3, 2])
1137
+ *
1138
+ * // Explanation:
1139
+ * // - The function starts with the first element (`1`), which is less than `4`, so it adds `1` to the result.
1140
+ * // - The next element (`3`) is also less than `4`, so it adds `3`.
1141
+ * // - The next element (`2`) is again less than `4`, so it adds `2`.
1142
+ * // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
1143
+ *
1144
+ * @category getters
1145
+ * @since 2.0.0
1146
+ */
625
1147
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Array<A>;
626
1148
  };
627
1149
  /**
@@ -634,9 +1156,45 @@ export declare const takeWhile: {
634
1156
  * @since 2.0.0
635
1157
  */
636
1158
  export declare const span: {
1159
+ /**
1160
+ * Split an `Iterable` into two parts:
1161
+ *
1162
+ * 1. the longest initial subarray for which all elements satisfy the specified predicate
1163
+ * 2. the remaining elements
1164
+ *
1165
+ * @category splitting
1166
+ * @since 2.0.0
1167
+ */
637
1168
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => [init: Array<B>, rest: Array<Exclude<A, B>>];
1169
+ /**
1170
+ * Split an `Iterable` into two parts:
1171
+ *
1172
+ * 1. the longest initial subarray for which all elements satisfy the specified predicate
1173
+ * 2. the remaining elements
1174
+ *
1175
+ * @category splitting
1176
+ * @since 2.0.0
1177
+ */
638
1178
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => [init: Array<A>, rest: Array<A>];
1179
+ /**
1180
+ * Split an `Iterable` into two parts:
1181
+ *
1182
+ * 1. the longest initial subarray for which all elements satisfy the specified predicate
1183
+ * 2. the remaining elements
1184
+ *
1185
+ * @category splitting
1186
+ * @since 2.0.0
1187
+ */
639
1188
  <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): [init: Array<B>, rest: Array<Exclude<A, B>>];
1189
+ /**
1190
+ * Split an `Iterable` into two parts:
1191
+ *
1192
+ * 1. the longest initial subarray for which all elements satisfy the specified predicate
1193
+ * 2. the remaining elements
1194
+ *
1195
+ * @category splitting
1196
+ * @since 2.0.0
1197
+ */
640
1198
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): [init: Array<A>, rest: Array<A>];
641
1199
  };
642
1200
  /**
@@ -655,7 +1213,37 @@ export declare const span: {
655
1213
  * @since 2.0.0
656
1214
  */
657
1215
  export declare const drop: {
1216
+ /**
1217
+ * Drop a max number of elements from the start of an `Iterable`, creating a new `Array`.
1218
+ *
1219
+ * **Note**. `n` is normalized to a non negative integer.
1220
+ *
1221
+ * @example
1222
+ * import { Array } from "effect"
1223
+ *
1224
+ * const numbers = [1, 2, 3, 4, 5]
1225
+ * const result = Array.drop(numbers, 2)
1226
+ * assert.deepStrictEqual(result, [3, 4, 5])
1227
+ *
1228
+ * @category getters
1229
+ * @since 2.0.0
1230
+ */
658
1231
  (n: number): <A>(self: Iterable<A>) => Array<A>;
1232
+ /**
1233
+ * Drop a max number of elements from the start of an `Iterable`, creating a new `Array`.
1234
+ *
1235
+ * **Note**. `n` is normalized to a non negative integer.
1236
+ *
1237
+ * @example
1238
+ * import { Array } from "effect"
1239
+ *
1240
+ * const numbers = [1, 2, 3, 4, 5]
1241
+ * const result = Array.drop(numbers, 2)
1242
+ * assert.deepStrictEqual(result, [3, 4, 5])
1243
+ *
1244
+ * @category getters
1245
+ * @since 2.0.0
1246
+ */
659
1247
  <A>(self: Iterable<A>, n: number): Array<A>;
660
1248
  };
661
1249
  /**
@@ -674,7 +1262,37 @@ export declare const drop: {
674
1262
  * @since 2.0.0
675
1263
  */
676
1264
  export declare const dropRight: {
1265
+ /**
1266
+ * Drop a max number of elements from the end of an `Iterable`, creating a new `Array`.
1267
+ *
1268
+ * **Note**. `n` is normalized to a non negative integer.
1269
+ *
1270
+ * @example
1271
+ * import { Array } from "effect"
1272
+ *
1273
+ * const numbers = [1, 2, 3, 4, 5]
1274
+ * const result = Array.dropRight(numbers, 2)
1275
+ * assert.deepStrictEqual(result, [1, 2, 3])
1276
+ *
1277
+ * @category getters
1278
+ * @since 2.0.0
1279
+ */
677
1280
  (n: number): <A>(self: Iterable<A>) => Array<A>;
1281
+ /**
1282
+ * Drop a max number of elements from the end of an `Iterable`, creating a new `Array`.
1283
+ *
1284
+ * **Note**. `n` is normalized to a non negative integer.
1285
+ *
1286
+ * @example
1287
+ * import { Array } from "effect"
1288
+ *
1289
+ * const numbers = [1, 2, 3, 4, 5]
1290
+ * const result = Array.dropRight(numbers, 2)
1291
+ * assert.deepStrictEqual(result, [1, 2, 3])
1292
+ *
1293
+ * @category getters
1294
+ * @since 2.0.0
1295
+ */
678
1296
  <A>(self: Iterable<A>, n: number): Array<A>;
679
1297
  };
680
1298
  /**
@@ -691,7 +1309,33 @@ export declare const dropRight: {
691
1309
  * @since 2.0.0
692
1310
  */
693
1311
  export declare const dropWhile: {
1312
+ /**
1313
+ * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
1314
+ *
1315
+ * @example
1316
+ * import { Array } from "effect"
1317
+ *
1318
+ * const numbers = [1, 2, 3, 4, 5]
1319
+ * const result = Array.dropWhile(numbers, x => x < 4)
1320
+ * assert.deepStrictEqual(result, [4, 5])
1321
+ *
1322
+ * @category getters
1323
+ * @since 2.0.0
1324
+ */
694
1325
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Array<A>;
1326
+ /**
1327
+ * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
1328
+ *
1329
+ * @example
1330
+ * import { Array } from "effect"
1331
+ *
1332
+ * const numbers = [1, 2, 3, 4, 5]
1333
+ * const result = Array.dropWhile(numbers, x => x < 4)
1334
+ * assert.deepStrictEqual(result, [4, 5])
1335
+ *
1336
+ * @category getters
1337
+ * @since 2.0.0
1338
+ */
695
1339
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Array<A>;
696
1340
  };
697
1341
  /**
@@ -708,7 +1352,33 @@ export declare const dropWhile: {
708
1352
  * @since 2.0.0
709
1353
  */
710
1354
  export declare const findFirstIndex: {
1355
+ /**
1356
+ * Return the first index for which a predicate holds.
1357
+ *
1358
+ * @example
1359
+ * import { Array, Option } from "effect"
1360
+ *
1361
+ * const numbers = [5, 3, 8, 9]
1362
+ * const result = Array.findFirstIndex(numbers, x => x > 5)
1363
+ * assert.deepStrictEqual(result, Option.some(2))
1364
+ *
1365
+ * @category elements
1366
+ * @since 2.0.0
1367
+ */
711
1368
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<number>;
1369
+ /**
1370
+ * Return the first index for which a predicate holds.
1371
+ *
1372
+ * @example
1373
+ * import { Array, Option } from "effect"
1374
+ *
1375
+ * const numbers = [5, 3, 8, 9]
1376
+ * const result = Array.findFirstIndex(numbers, x => x > 5)
1377
+ * assert.deepStrictEqual(result, Option.some(2))
1378
+ *
1379
+ * @category elements
1380
+ * @since 2.0.0
1381
+ */
712
1382
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<number>;
713
1383
  };
714
1384
  /**
@@ -725,7 +1395,33 @@ export declare const findFirstIndex: {
725
1395
  * @since 2.0.0
726
1396
  */
727
1397
  export declare const findLastIndex: {
1398
+ /**
1399
+ * Return the last index for which a predicate holds.
1400
+ *
1401
+ * @example
1402
+ * import { Array, Option } from "effect"
1403
+ *
1404
+ * const numbers = [1, 3, 8, 9]
1405
+ * const result = Array.findLastIndex(numbers, x => x < 5)
1406
+ * assert.deepStrictEqual(result, Option.some(1))
1407
+ *
1408
+ * @category elements
1409
+ * @since 2.0.0
1410
+ */
728
1411
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<number>;
1412
+ /**
1413
+ * Return the last index for which a predicate holds.
1414
+ *
1415
+ * @example
1416
+ * import { Array, Option } from "effect"
1417
+ *
1418
+ * const numbers = [1, 3, 8, 9]
1419
+ * const result = Array.findLastIndex(numbers, x => x < 5)
1420
+ * assert.deepStrictEqual(result, Option.some(1))
1421
+ *
1422
+ * @category elements
1423
+ * @since 2.0.0
1424
+ */
729
1425
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<number>;
730
1426
  };
731
1427
  /**
@@ -743,11 +1439,95 @@ export declare const findLastIndex: {
743
1439
  * @since 2.0.0
744
1440
  */
745
1441
  export declare const findFirst: {
1442
+ /**
1443
+ * Returns the first element that satisfies the specified
1444
+ * predicate, or `None` if no such element exists.
1445
+ *
1446
+ * @example
1447
+ * import { Array, Option } from "effect"
1448
+ *
1449
+ * const numbers = [1, 2, 3, 4, 5]
1450
+ * const result = Array.findFirst(numbers, x => x > 3)
1451
+ * assert.deepStrictEqual(result, Option.some(4))
1452
+ *
1453
+ * @category elements
1454
+ * @since 2.0.0
1455
+ */
746
1456
  <A, B>(f: (a: NoInfer<A>, i: number) => Option<B>): (self: Iterable<A>) => Option<B>;
1457
+ /**
1458
+ * Returns the first element that satisfies the specified
1459
+ * predicate, or `None` if no such element exists.
1460
+ *
1461
+ * @example
1462
+ * import { Array, Option } from "effect"
1463
+ *
1464
+ * const numbers = [1, 2, 3, 4, 5]
1465
+ * const result = Array.findFirst(numbers, x => x > 3)
1466
+ * assert.deepStrictEqual(result, Option.some(4))
1467
+ *
1468
+ * @category elements
1469
+ * @since 2.0.0
1470
+ */
747
1471
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option<B>;
1472
+ /**
1473
+ * Returns the first element that satisfies the specified
1474
+ * predicate, or `None` if no such element exists.
1475
+ *
1476
+ * @example
1477
+ * import { Array, Option } from "effect"
1478
+ *
1479
+ * const numbers = [1, 2, 3, 4, 5]
1480
+ * const result = Array.findFirst(numbers, x => x > 3)
1481
+ * assert.deepStrictEqual(result, Option.some(4))
1482
+ *
1483
+ * @category elements
1484
+ * @since 2.0.0
1485
+ */
748
1486
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<A>;
1487
+ /**
1488
+ * Returns the first element that satisfies the specified
1489
+ * predicate, or `None` if no such element exists.
1490
+ *
1491
+ * @example
1492
+ * import { Array, Option } from "effect"
1493
+ *
1494
+ * const numbers = [1, 2, 3, 4, 5]
1495
+ * const result = Array.findFirst(numbers, x => x > 3)
1496
+ * assert.deepStrictEqual(result, Option.some(4))
1497
+ *
1498
+ * @category elements
1499
+ * @since 2.0.0
1500
+ */
749
1501
  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Option<B>;
1502
+ /**
1503
+ * Returns the first element that satisfies the specified
1504
+ * predicate, or `None` if no such element exists.
1505
+ *
1506
+ * @example
1507
+ * import { Array, Option } from "effect"
1508
+ *
1509
+ * const numbers = [1, 2, 3, 4, 5]
1510
+ * const result = Array.findFirst(numbers, x => x > 3)
1511
+ * assert.deepStrictEqual(result, Option.some(4))
1512
+ *
1513
+ * @category elements
1514
+ * @since 2.0.0
1515
+ */
750
1516
  <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option<B>;
1517
+ /**
1518
+ * Returns the first element that satisfies the specified
1519
+ * predicate, or `None` if no such element exists.
1520
+ *
1521
+ * @example
1522
+ * import { Array, Option } from "effect"
1523
+ *
1524
+ * const numbers = [1, 2, 3, 4, 5]
1525
+ * const result = Array.findFirst(numbers, x => x > 3)
1526
+ * assert.deepStrictEqual(result, Option.some(4))
1527
+ *
1528
+ * @category elements
1529
+ * @since 2.0.0
1530
+ */
751
1531
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<A>;
752
1532
  };
753
1533
  /**
@@ -765,11 +1545,95 @@ export declare const findFirst: {
765
1545
  * @since 2.0.0
766
1546
  */
767
1547
  export declare const findLast: {
1548
+ /**
1549
+ * Finds the last element in an iterable collection that satisfies the given predicate or refinement.
1550
+ * Returns an `Option` containing the found element, or `Option.none` if no element matches.
1551
+ *
1552
+ * @example
1553
+ * import { Array, Option } from "effect"
1554
+ *
1555
+ * const numbers = [1, 2, 3, 4, 5]
1556
+ * const result = Array.findLast(numbers, n => n % 2 === 0)
1557
+ * assert.deepStrictEqual(result, Option.some(4))
1558
+ *
1559
+ * @category elements
1560
+ * @since 2.0.0
1561
+ */
768
1562
  <A, B>(f: (a: NoInfer<A>, i: number) => Option<B>): (self: Iterable<A>) => Option<B>;
1563
+ /**
1564
+ * Finds the last element in an iterable collection that satisfies the given predicate or refinement.
1565
+ * Returns an `Option` containing the found element, or `Option.none` if no element matches.
1566
+ *
1567
+ * @example
1568
+ * import { Array, Option } from "effect"
1569
+ *
1570
+ * const numbers = [1, 2, 3, 4, 5]
1571
+ * const result = Array.findLast(numbers, n => n % 2 === 0)
1572
+ * assert.deepStrictEqual(result, Option.some(4))
1573
+ *
1574
+ * @category elements
1575
+ * @since 2.0.0
1576
+ */
769
1577
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option<B>;
1578
+ /**
1579
+ * Finds the last element in an iterable collection that satisfies the given predicate or refinement.
1580
+ * Returns an `Option` containing the found element, or `Option.none` if no element matches.
1581
+ *
1582
+ * @example
1583
+ * import { Array, Option } from "effect"
1584
+ *
1585
+ * const numbers = [1, 2, 3, 4, 5]
1586
+ * const result = Array.findLast(numbers, n => n % 2 === 0)
1587
+ * assert.deepStrictEqual(result, Option.some(4))
1588
+ *
1589
+ * @category elements
1590
+ * @since 2.0.0
1591
+ */
770
1592
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<A>;
1593
+ /**
1594
+ * Finds the last element in an iterable collection that satisfies the given predicate or refinement.
1595
+ * Returns an `Option` containing the found element, or `Option.none` if no element matches.
1596
+ *
1597
+ * @example
1598
+ * import { Array, Option } from "effect"
1599
+ *
1600
+ * const numbers = [1, 2, 3, 4, 5]
1601
+ * const result = Array.findLast(numbers, n => n % 2 === 0)
1602
+ * assert.deepStrictEqual(result, Option.some(4))
1603
+ *
1604
+ * @category elements
1605
+ * @since 2.0.0
1606
+ */
771
1607
  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Option<B>;
1608
+ /**
1609
+ * Finds the last element in an iterable collection that satisfies the given predicate or refinement.
1610
+ * Returns an `Option` containing the found element, or `Option.none` if no element matches.
1611
+ *
1612
+ * @example
1613
+ * import { Array, Option } from "effect"
1614
+ *
1615
+ * const numbers = [1, 2, 3, 4, 5]
1616
+ * const result = Array.findLast(numbers, n => n % 2 === 0)
1617
+ * assert.deepStrictEqual(result, Option.some(4))
1618
+ *
1619
+ * @category elements
1620
+ * @since 2.0.0
1621
+ */
772
1622
  <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option<B>;
1623
+ /**
1624
+ * Finds the last element in an iterable collection that satisfies the given predicate or refinement.
1625
+ * Returns an `Option` containing the found element, or `Option.none` if no element matches.
1626
+ *
1627
+ * @example
1628
+ * import { Array, Option } from "effect"
1629
+ *
1630
+ * const numbers = [1, 2, 3, 4, 5]
1631
+ * const result = Array.findLast(numbers, n => n % 2 === 0)
1632
+ * assert.deepStrictEqual(result, Option.some(4))
1633
+ *
1634
+ * @category elements
1635
+ * @since 2.0.0
1636
+ */
773
1637
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<A>;
774
1638
  };
775
1639
  /**
@@ -786,7 +1650,33 @@ export declare const findLast: {
786
1650
  * @since 2.0.0
787
1651
  */
788
1652
  export declare const insertAt: {
1653
+ /**
1654
+ * Insert an element at the specified index, creating a new `NonEmptyArray`,
1655
+ * or return `None` if the index is out of bounds.
1656
+ *
1657
+ * @example
1658
+ * import { Array, Option } from "effect"
1659
+ *
1660
+ * const letters = ['a', 'b', 'c', 'e']
1661
+ * const result = Array.insertAt(letters, 3, 'd')
1662
+ * assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
1663
+ *
1664
+ * @since 2.0.0
1665
+ */
789
1666
  <B>(i: number, b: B): <A>(self: Iterable<A>) => Option<NonEmptyArray<A | B>>;
1667
+ /**
1668
+ * Insert an element at the specified index, creating a new `NonEmptyArray`,
1669
+ * or return `None` if the index is out of bounds.
1670
+ *
1671
+ * @example
1672
+ * import { Array, Option } from "effect"
1673
+ *
1674
+ * const letters = ['a', 'b', 'c', 'e']
1675
+ * const result = Array.insertAt(letters, 3, 'd')
1676
+ * assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
1677
+ *
1678
+ * @since 2.0.0
1679
+ */
790
1680
  <A, B>(self: Iterable<A>, i: number, b: B): Option<NonEmptyArray<A | B>>;
791
1681
  };
792
1682
  /**
@@ -803,7 +1693,33 @@ export declare const insertAt: {
803
1693
  * @since 2.0.0
804
1694
  */
805
1695
  export declare const replace: {
1696
+ /**
1697
+ * Change the element at the specified index, creating a new `Array`,
1698
+ * or return a copy of the input if the index is out of bounds.
1699
+ *
1700
+ * @example
1701
+ * import { Array } from "effect"
1702
+ *
1703
+ * const letters = ['a', 'b', 'c', 'd']
1704
+ * const result = Array.replace(letters, 1, 'z')
1705
+ * assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
1706
+ *
1707
+ * @since 2.0.0
1708
+ */
806
1709
  <B>(i: number, b: B): <A, S extends Iterable<A> = Iterable<A>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>;
1710
+ /**
1711
+ * Change the element at the specified index, creating a new `Array`,
1712
+ * or return a copy of the input if the index is out of bounds.
1713
+ *
1714
+ * @example
1715
+ * import { Array } from "effect"
1716
+ *
1717
+ * const letters = ['a', 'b', 'c', 'd']
1718
+ * const result = Array.replace(letters, 1, 'z')
1719
+ * assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
1720
+ *
1721
+ * @since 2.0.0
1722
+ */
807
1723
  <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, b: B): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>;
808
1724
  };
809
1725
  /**
@@ -819,7 +1735,31 @@ export declare const replace: {
819
1735
  * @since 2.0.0
820
1736
  */
821
1737
  export declare const replaceOption: {
1738
+ /**
1739
+ * Replaces an element in an array with the given value, returning an option of the updated array.
1740
+ *
1741
+ * @example
1742
+ * import { Array, Option } from "effect"
1743
+ *
1744
+ * const numbers = [1, 2, 3]
1745
+ * const result = Array.replaceOption(numbers, 1, 4)
1746
+ * assert.deepStrictEqual(result, Option.some([1, 4, 3]))
1747
+ *
1748
+ * @since 2.0.0
1749
+ */
822
1750
  <B>(i: number, b: B): <A, S extends Iterable<A> = Iterable<A>>(self: S) => Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>;
1751
+ /**
1752
+ * Replaces an element in an array with the given value, returning an option of the updated array.
1753
+ *
1754
+ * @example
1755
+ * import { Array, Option } from "effect"
1756
+ *
1757
+ * const numbers = [1, 2, 3]
1758
+ * const result = Array.replaceOption(numbers, 1, 4)
1759
+ * assert.deepStrictEqual(result, Option.some([1, 4, 3]))
1760
+ *
1761
+ * @since 2.0.0
1762
+ */
823
1763
  <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, b: B): Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>;
824
1764
  };
825
1765
  /**
@@ -836,7 +1776,33 @@ export declare const replaceOption: {
836
1776
  * @since 2.0.0
837
1777
  */
838
1778
  export declare const modify: {
1779
+ /**
1780
+ * Apply a function to the element at the specified index, creating a new `Array`,
1781
+ * or return a copy of the input if the index is out of bounds.
1782
+ *
1783
+ * @example
1784
+ * import { Array } from "effect"
1785
+ *
1786
+ * const numbers = [1, 2, 3, 4]
1787
+ * const result = Array.modify(numbers, 2, (n) => n * 2)
1788
+ * assert.deepStrictEqual(result, [1, 2, 6, 4])
1789
+ *
1790
+ * @since 2.0.0
1791
+ */
839
1792
  <A, B, S extends Iterable<A> = Iterable<A>>(i: number, f: (a: ReadonlyArray.Infer<S>) => B): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>;
1793
+ /**
1794
+ * Apply a function to the element at the specified index, creating a new `Array`,
1795
+ * or return a copy of the input if the index is out of bounds.
1796
+ *
1797
+ * @example
1798
+ * import { Array } from "effect"
1799
+ *
1800
+ * const numbers = [1, 2, 3, 4]
1801
+ * const result = Array.modify(numbers, 2, (n) => n * 2)
1802
+ * assert.deepStrictEqual(result, [1, 2, 6, 4])
1803
+ *
1804
+ * @since 2.0.0
1805
+ */
840
1806
  <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, f: (a: ReadonlyArray.Infer<S>) => B): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>;
841
1807
  };
842
1808
  /**
@@ -856,7 +1822,39 @@ export declare const modify: {
856
1822
  * @since 2.0.0
857
1823
  */
858
1824
  export declare const modifyOption: {
1825
+ /**
1826
+ * Apply a function to the element at the specified index, creating a new `Array`,
1827
+ * or return `None` if the index is out of bounds.
1828
+ *
1829
+ * @example
1830
+ * import { Array, Option } from "effect"
1831
+ *
1832
+ * const numbers = [1, 2, 3, 4]
1833
+ * const result = Array.modifyOption(numbers, 2, (n) => n * 2)
1834
+ * assert.deepStrictEqual(result, Option.some([1, 2, 6, 4]))
1835
+ *
1836
+ * const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
1837
+ * assert.deepStrictEqual(outOfBoundsResult, Option.none())
1838
+ *
1839
+ * @since 2.0.0
1840
+ */
859
1841
  <A, B, S extends Iterable<A> = Iterable<A>>(i: number, f: (a: ReadonlyArray.Infer<S>) => B): (self: S) => Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>;
1842
+ /**
1843
+ * Apply a function to the element at the specified index, creating a new `Array`,
1844
+ * or return `None` if the index is out of bounds.
1845
+ *
1846
+ * @example
1847
+ * import { Array, Option } from "effect"
1848
+ *
1849
+ * const numbers = [1, 2, 3, 4]
1850
+ * const result = Array.modifyOption(numbers, 2, (n) => n * 2)
1851
+ * assert.deepStrictEqual(result, Option.some([1, 2, 6, 4]))
1852
+ *
1853
+ * const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
1854
+ * assert.deepStrictEqual(outOfBoundsResult, Option.none())
1855
+ *
1856
+ * @since 2.0.0
1857
+ */
860
1858
  <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, f: (a: ReadonlyArray.Infer<S>) => B): Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>;
861
1859
  };
862
1860
  /**
@@ -876,7 +1874,39 @@ export declare const modifyOption: {
876
1874
  * @since 2.0.0
877
1875
  */
878
1876
  export declare const remove: {
1877
+ /**
1878
+ * Delete the element at the specified index, creating a new `Array`,
1879
+ * or return a copy of the input if the index is out of bounds.
1880
+ *
1881
+ * @example
1882
+ * import { Array } from "effect"
1883
+ *
1884
+ * const numbers = [1, 2, 3, 4]
1885
+ * const result = Array.remove(numbers, 2)
1886
+ * assert.deepStrictEqual(result, [1, 2, 4])
1887
+ *
1888
+ * const outOfBoundsResult = Array.remove(numbers, 5)
1889
+ * assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
1890
+ *
1891
+ * @since 2.0.0
1892
+ */
879
1893
  (i: number): <A>(self: Iterable<A>) => Array<A>;
1894
+ /**
1895
+ * Delete the element at the specified index, creating a new `Array`,
1896
+ * or return a copy of the input if the index is out of bounds.
1897
+ *
1898
+ * @example
1899
+ * import { Array } from "effect"
1900
+ *
1901
+ * const numbers = [1, 2, 3, 4]
1902
+ * const result = Array.remove(numbers, 2)
1903
+ * assert.deepStrictEqual(result, [1, 2, 4])
1904
+ *
1905
+ * const outOfBoundsResult = Array.remove(numbers, 5)
1906
+ * assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
1907
+ *
1908
+ * @since 2.0.0
1909
+ */
880
1910
  <A>(self: Iterable<A>, i: number): Array<A>;
881
1911
  };
882
1912
  /**
@@ -901,8 +1931,29 @@ export declare const reverse: <S extends Iterable<any> | NonEmptyReadonlyArray<a
901
1931
  * @since 2.0.0
902
1932
  */
903
1933
  export declare const sort: {
1934
+ /**
1935
+ * Create a new array with elements sorted in increasing order based on the specified comparator.
1936
+ * If the input is a `NonEmptyReadonlyArray`, the output will also be a `NonEmptyReadonlyArray`.
1937
+ *
1938
+ * @category sorting
1939
+ * @since 2.0.0
1940
+ */
904
1941
  <B>(O: Order.Order<B>): <A extends B, S extends ReadonlyArray<A> | Iterable<A>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>;
1942
+ /**
1943
+ * Create a new array with elements sorted in increasing order based on the specified comparator.
1944
+ * If the input is a `NonEmptyReadonlyArray`, the output will also be a `NonEmptyReadonlyArray`.
1945
+ *
1946
+ * @category sorting
1947
+ * @since 2.0.0
1948
+ */
905
1949
  <A extends B, B>(self: NonEmptyReadonlyArray<A>, O: Order.Order<B>): NonEmptyArray<A>;
1950
+ /**
1951
+ * Create a new array with elements sorted in increasing order based on the specified comparator.
1952
+ * If the input is a `NonEmptyReadonlyArray`, the output will also be a `NonEmptyReadonlyArray`.
1953
+ *
1954
+ * @category sorting
1955
+ * @since 2.0.0
1956
+ */
906
1957
  <A extends B, B>(self: Iterable<A>, O: Order.Order<B>): Array<A>;
907
1958
  };
908
1959
  /**
@@ -926,8 +1977,68 @@ export declare const sort: {
926
1977
  * @category elements
927
1978
  */
928
1979
  export declare const sortWith: {
1980
+ /**
1981
+ * Sorts an array based on a provided mapping function and order. The mapping
1982
+ * function transforms the elements into a value that can be compared, and the
1983
+ * order defines how those values should be sorted.
1984
+ *
1985
+ * @example
1986
+ * import { Array, Order } from "effect"
1987
+ *
1988
+ * const strings = ["aaa", "b", "cc"]
1989
+ * const result = Array.sortWith(strings, (s) => s.length, Order.number)
1990
+ * assert.deepStrictEqual(result, ["b", "cc", "aaa"])
1991
+ *
1992
+ * // Explanation:
1993
+ * // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
1994
+ * // converts each string into its length, and the `Order.number` specifies that the lengths should
1995
+ * // be sorted in ascending order.
1996
+ *
1997
+ * @since 2.0.0
1998
+ * @category elements
1999
+ */
929
2000
  <S extends Iterable<any> | NonEmptyReadonlyArray<any>, B>(f: (a: ReadonlyArray.Infer<S>) => B, order: Order.Order<B>): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>;
2001
+ /**
2002
+ * Sorts an array based on a provided mapping function and order. The mapping
2003
+ * function transforms the elements into a value that can be compared, and the
2004
+ * order defines how those values should be sorted.
2005
+ *
2006
+ * @example
2007
+ * import { Array, Order } from "effect"
2008
+ *
2009
+ * const strings = ["aaa", "b", "cc"]
2010
+ * const result = Array.sortWith(strings, (s) => s.length, Order.number)
2011
+ * assert.deepStrictEqual(result, ["b", "cc", "aaa"])
2012
+ *
2013
+ * // Explanation:
2014
+ * // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
2015
+ * // converts each string into its length, and the `Order.number` specifies that the lengths should
2016
+ * // be sorted in ascending order.
2017
+ *
2018
+ * @since 2.0.0
2019
+ * @category elements
2020
+ */
930
2021
  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B, O: Order.Order<B>): NonEmptyArray<A>;
2022
+ /**
2023
+ * Sorts an array based on a provided mapping function and order. The mapping
2024
+ * function transforms the elements into a value that can be compared, and the
2025
+ * order defines how those values should be sorted.
2026
+ *
2027
+ * @example
2028
+ * import { Array, Order } from "effect"
2029
+ *
2030
+ * const strings = ["aaa", "b", "cc"]
2031
+ * const result = Array.sortWith(strings, (s) => s.length, Order.number)
2032
+ * assert.deepStrictEqual(result, ["b", "cc", "aaa"])
2033
+ *
2034
+ * // Explanation:
2035
+ * // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
2036
+ * // converts each string into its length, and the `Order.number` specifies that the lengths should
2037
+ * // be sorted in ascending order.
2038
+ *
2039
+ * @since 2.0.0
2040
+ * @category elements
2041
+ */
931
2042
  <A, B>(self: Iterable<A>, f: (a: A) => B, order: Order.Order<B>): Array<A>;
932
2043
  };
933
2044
  /**
@@ -980,9 +2091,73 @@ export declare const sortBy: <S extends Iterable<any> | NonEmptyReadonlyArray<an
980
2091
  * @since 2.0.0
981
2092
  */
982
2093
  export declare const zip: {
2094
+ /**
2095
+ * Takes two `Iterable`s and returns an `Array` of corresponding pairs.
2096
+ * If one input `Iterable` is short, excess elements of the
2097
+ * longer `Iterable` are discarded.
2098
+ *
2099
+ * @example
2100
+ * import { Array } from "effect"
2101
+ *
2102
+ * const array1 = [1, 2, 3]
2103
+ * const array2 = ['a', 'b']
2104
+ * const result = Array.zip(array1, array2)
2105
+ * assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
2106
+ *
2107
+ * @category zipping
2108
+ * @since 2.0.0
2109
+ */
983
2110
  <B>(that: NonEmptyReadonlyArray<B>): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<[A, B]>;
2111
+ /**
2112
+ * Takes two `Iterable`s and returns an `Array` of corresponding pairs.
2113
+ * If one input `Iterable` is short, excess elements of the
2114
+ * longer `Iterable` are discarded.
2115
+ *
2116
+ * @example
2117
+ * import { Array } from "effect"
2118
+ *
2119
+ * const array1 = [1, 2, 3]
2120
+ * const array2 = ['a', 'b']
2121
+ * const result = Array.zip(array1, array2)
2122
+ * assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
2123
+ *
2124
+ * @category zipping
2125
+ * @since 2.0.0
2126
+ */
984
2127
  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<[A, B]>;
2128
+ /**
2129
+ * Takes two `Iterable`s and returns an `Array` of corresponding pairs.
2130
+ * If one input `Iterable` is short, excess elements of the
2131
+ * longer `Iterable` are discarded.
2132
+ *
2133
+ * @example
2134
+ * import { Array } from "effect"
2135
+ *
2136
+ * const array1 = [1, 2, 3]
2137
+ * const array2 = ['a', 'b']
2138
+ * const result = Array.zip(array1, array2)
2139
+ * assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
2140
+ *
2141
+ * @category zipping
2142
+ * @since 2.0.0
2143
+ */
985
2144
  <A, B>(self: NonEmptyReadonlyArray<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<[A, B]>;
2145
+ /**
2146
+ * Takes two `Iterable`s and returns an `Array` of corresponding pairs.
2147
+ * If one input `Iterable` is short, excess elements of the
2148
+ * longer `Iterable` are discarded.
2149
+ *
2150
+ * @example
2151
+ * import { Array } from "effect"
2152
+ *
2153
+ * const array1 = [1, 2, 3]
2154
+ * const array2 = ['a', 'b']
2155
+ * const result = Array.zip(array1, array2)
2156
+ * assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
2157
+ *
2158
+ * @category zipping
2159
+ * @since 2.0.0
2160
+ */
986
2161
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<[A, B]>;
987
2162
  };
988
2163
  /**
@@ -1001,9 +2176,69 @@ export declare const zip: {
1001
2176
  * @since 2.0.0
1002
2177
  */
1003
2178
  export declare const zipWith: {
2179
+ /**
2180
+ * Apply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one
2181
+ * input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
2182
+ *
2183
+ * @example
2184
+ * import { Array } from "effect"
2185
+ *
2186
+ * const array1 = [1, 2, 3]
2187
+ * const array2 = [4, 5, 6]
2188
+ * const result = Array.zipWith(array1, array2, (a, b) => a + b)
2189
+ * assert.deepStrictEqual(result, [5, 7, 9])
2190
+ *
2191
+ * @category zipping
2192
+ * @since 2.0.0
2193
+ */
1004
2194
  <B, A, C>(that: NonEmptyReadonlyArray<B>, f: (a: A, b: B) => C): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<C>;
2195
+ /**
2196
+ * Apply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one
2197
+ * input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
2198
+ *
2199
+ * @example
2200
+ * import { Array } from "effect"
2201
+ *
2202
+ * const array1 = [1, 2, 3]
2203
+ * const array2 = [4, 5, 6]
2204
+ * const result = Array.zipWith(array1, array2, (a, b) => a + b)
2205
+ * assert.deepStrictEqual(result, [5, 7, 9])
2206
+ *
2207
+ * @category zipping
2208
+ * @since 2.0.0
2209
+ */
1005
2210
  <B, A, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Array<C>;
2211
+ /**
2212
+ * Apply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one
2213
+ * input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
2214
+ *
2215
+ * @example
2216
+ * import { Array } from "effect"
2217
+ *
2218
+ * const array1 = [1, 2, 3]
2219
+ * const array2 = [4, 5, 6]
2220
+ * const result = Array.zipWith(array1, array2, (a, b) => a + b)
2221
+ * assert.deepStrictEqual(result, [5, 7, 9])
2222
+ *
2223
+ * @category zipping
2224
+ * @since 2.0.0
2225
+ */
1006
2226
  <A, B, C>(self: NonEmptyReadonlyArray<A>, that: NonEmptyReadonlyArray<B>, f: (a: A, b: B) => C): NonEmptyArray<C>;
2227
+ /**
2228
+ * Apply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one
2229
+ * input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
2230
+ *
2231
+ * @example
2232
+ * import { Array } from "effect"
2233
+ *
2234
+ * const array1 = [1, 2, 3]
2235
+ * const array2 = [4, 5, 6]
2236
+ * const result = Array.zipWith(array1, array2, (a, b) => a + b)
2237
+ * assert.deepStrictEqual(result, [5, 7, 9])
2238
+ *
2239
+ * @category zipping
2240
+ * @since 2.0.0
2241
+ */
1007
2242
  <B, A, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Array<C>;
1008
2243
  };
1009
2244
  /**
@@ -1032,8 +2267,47 @@ export declare const unzip: <S extends Iterable<readonly [any, any]> | NonEmptyR
1032
2267
  * @since 2.0.0
1033
2268
  */
1034
2269
  export declare const intersperse: {
2270
+ /**
2271
+ * Places an element in between members of an `Iterable`.
2272
+ * If the input is a non-empty array, the result is also a non-empty array.
2273
+ *
2274
+ * @example
2275
+ * import { Array } from "effect"
2276
+ *
2277
+ * const numbers = [1, 2, 3]
2278
+ * const result = Array.intersperse(numbers, 0)
2279
+ * assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
2280
+ *
2281
+ * @since 2.0.0
2282
+ */
1035
2283
  <B>(middle: B): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>;
2284
+ /**
2285
+ * Places an element in between members of an `Iterable`.
2286
+ * If the input is a non-empty array, the result is also a non-empty array.
2287
+ *
2288
+ * @example
2289
+ * import { Array } from "effect"
2290
+ *
2291
+ * const numbers = [1, 2, 3]
2292
+ * const result = Array.intersperse(numbers, 0)
2293
+ * assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
2294
+ *
2295
+ * @since 2.0.0
2296
+ */
1036
2297
  <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>;
2298
+ /**
2299
+ * Places an element in between members of an `Iterable`.
2300
+ * If the input is a non-empty array, the result is also a non-empty array.
2301
+ *
2302
+ * @example
2303
+ * import { Array } from "effect"
2304
+ *
2305
+ * const numbers = [1, 2, 3]
2306
+ * const result = Array.intersperse(numbers, 0)
2307
+ * assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
2308
+ *
2309
+ * @since 2.0.0
2310
+ */
1037
2311
  <A, B>(self: Iterable<A>, middle: B): Array<A | B>;
1038
2312
  };
1039
2313
  /**
@@ -1048,7 +2322,29 @@ export declare const intersperse: {
1048
2322
  * @since 2.0.0
1049
2323
  */
1050
2324
  export declare const modifyNonEmptyHead: {
2325
+ /**
2326
+ * Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
2327
+ *
2328
+ * @example
2329
+ * import { Array } from "effect"
2330
+ *
2331
+ * const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
2332
+ * assert.deepStrictEqual(result, [10, 2, 3])
2333
+ *
2334
+ * @since 2.0.0
2335
+ */
1051
2336
  <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>;
2337
+ /**
2338
+ * Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
2339
+ *
2340
+ * @example
2341
+ * import { Array } from "effect"
2342
+ *
2343
+ * const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
2344
+ * assert.deepStrictEqual(result, [10, 2, 3])
2345
+ *
2346
+ * @since 2.0.0
2347
+ */
1052
2348
  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>;
1053
2349
  };
1054
2350
  /**
@@ -1063,7 +2359,29 @@ export declare const modifyNonEmptyHead: {
1063
2359
  * @since 2.0.0
1064
2360
  */
1065
2361
  export declare const setNonEmptyHead: {
2362
+ /**
2363
+ * Change the head, creating a new `NonEmptyReadonlyArray`.
2364
+ *
2365
+ * @example
2366
+ * import { Array } from "effect"
2367
+ *
2368
+ * const result = Array.setNonEmptyHead([1, 2, 3], 10)
2369
+ * assert.deepStrictEqual(result, [10, 2, 3])
2370
+ *
2371
+ * @since 2.0.0
2372
+ */
1066
2373
  <B>(b: B): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>;
2374
+ /**
2375
+ * Change the head, creating a new `NonEmptyReadonlyArray`.
2376
+ *
2377
+ * @example
2378
+ * import { Array } from "effect"
2379
+ *
2380
+ * const result = Array.setNonEmptyHead([1, 2, 3], 10)
2381
+ * assert.deepStrictEqual(result, [10, 2, 3])
2382
+ *
2383
+ * @since 2.0.0
2384
+ */
1067
2385
  <A, B>(self: NonEmptyReadonlyArray<A>, b: B): NonEmptyArray<A | B>;
1068
2386
  };
1069
2387
  /**
@@ -1078,7 +2396,29 @@ export declare const setNonEmptyHead: {
1078
2396
  * @since 2.0.0
1079
2397
  */
1080
2398
  export declare const modifyNonEmptyLast: {
2399
+ /**
2400
+ * Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
2401
+ *
2402
+ * @example
2403
+ * import { Array } from "effect"
2404
+ *
2405
+ * const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
2406
+ * assert.deepStrictEqual(result, [1, 2, 6])
2407
+ *
2408
+ * @since 2.0.0
2409
+ */
1081
2410
  <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>;
2411
+ /**
2412
+ * Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
2413
+ *
2414
+ * @example
2415
+ * import { Array } from "effect"
2416
+ *
2417
+ * const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
2418
+ * assert.deepStrictEqual(result, [1, 2, 6])
2419
+ *
2420
+ * @since 2.0.0
2421
+ */
1082
2422
  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>;
1083
2423
  };
1084
2424
  /**
@@ -1093,7 +2433,29 @@ export declare const modifyNonEmptyLast: {
1093
2433
  * @since 2.0.0
1094
2434
  */
1095
2435
  export declare const setNonEmptyLast: {
2436
+ /**
2437
+ * Change the last element, creating a new `NonEmptyReadonlyArray`.
2438
+ *
2439
+ * @example
2440
+ * import { Array } from "effect"
2441
+ *
2442
+ * const result = Array.setNonEmptyLast([1, 2, 3], 4)
2443
+ * assert.deepStrictEqual(result, [1, 2, 4])
2444
+ *
2445
+ * @since 2.0.0
2446
+ */
1096
2447
  <B>(b: B): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>;
2448
+ /**
2449
+ * Change the last element, creating a new `NonEmptyReadonlyArray`.
2450
+ *
2451
+ * @example
2452
+ * import { Array } from "effect"
2453
+ *
2454
+ * const result = Array.setNonEmptyLast([1, 2, 3], 4)
2455
+ * assert.deepStrictEqual(result, [1, 2, 4])
2456
+ *
2457
+ * @since 2.0.0
2458
+ */
1097
2459
  <A, B>(self: NonEmptyReadonlyArray<A>, b: B): NonEmptyArray<A | B>;
1098
2460
  };
1099
2461
  /**
@@ -1110,8 +2472,47 @@ export declare const setNonEmptyLast: {
1110
2472
  * @since 2.0.0
1111
2473
  */
1112
2474
  export declare const rotate: {
2475
+ /**
2476
+ * Rotate an `Iterable` by `n` steps.
2477
+ * If the input is a non-empty array, the result is also a non-empty array.
2478
+ *
2479
+ * @example
2480
+ * import { Array } from "effect"
2481
+ *
2482
+ * const letters = ['a', 'b', 'c', 'd']
2483
+ * const result = Array.rotate(letters, 2)
2484
+ * assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
2485
+ *
2486
+ * @since 2.0.0
2487
+ */
1113
2488
  (n: number): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>;
2489
+ /**
2490
+ * Rotate an `Iterable` by `n` steps.
2491
+ * If the input is a non-empty array, the result is also a non-empty array.
2492
+ *
2493
+ * @example
2494
+ * import { Array } from "effect"
2495
+ *
2496
+ * const letters = ['a', 'b', 'c', 'd']
2497
+ * const result = Array.rotate(letters, 2)
2498
+ * assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
2499
+ *
2500
+ * @since 2.0.0
2501
+ */
1114
2502
  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<A>;
2503
+ /**
2504
+ * Rotate an `Iterable` by `n` steps.
2505
+ * If the input is a non-empty array, the result is also a non-empty array.
2506
+ *
2507
+ * @example
2508
+ * import { Array } from "effect"
2509
+ *
2510
+ * const letters = ['a', 'b', 'c', 'd']
2511
+ * const result = Array.rotate(letters, 2)
2512
+ * assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
2513
+ *
2514
+ * @since 2.0.0
2515
+ */
1115
2516
  <A>(self: Iterable<A>, n: number): Array<A>;
1116
2517
  };
1117
2518
  /**
@@ -1147,7 +2548,33 @@ export declare const containsWith: <A>(isEquivalent: (self: A, that: A) => boole
1147
2548
  * @since 2.0.0
1148
2549
  */
1149
2550
  export declare const contains: {
2551
+ /**
2552
+ * Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
2553
+ *
2554
+ * @example
2555
+ * import { Array } from "effect"
2556
+ *
2557
+ * const letters = ['a', 'b', 'c', 'd']
2558
+ * const result = Array.contains('c')(letters)
2559
+ * assert.deepStrictEqual(result, true)
2560
+ *
2561
+ * @category elements
2562
+ * @since 2.0.0
2563
+ */
1150
2564
  <A>(a: A): (self: Iterable<A>) => boolean;
2565
+ /**
2566
+ * Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
2567
+ *
2568
+ * @example
2569
+ * import { Array } from "effect"
2570
+ *
2571
+ * const letters = ['a', 'b', 'c', 'd']
2572
+ * const result = Array.contains('c')(letters)
2573
+ * assert.deepStrictEqual(result, true)
2574
+ *
2575
+ * @category elements
2576
+ * @since 2.0.0
2577
+ */
1151
2578
  <A>(self: Iterable<A>, a: A): boolean;
1152
2579
  };
1153
2580
  /**
@@ -1170,8 +2597,65 @@ export declare const contains: {
1170
2597
  * @since 2.0.0
1171
2598
  */
1172
2599
  export declare const chop: {
2600
+ /**
2601
+ * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for "chopping" up the input
2602
+ * `Iterable`. Typically chop is called with some function that will consume an initial prefix of the `Iterable` and produce a
2603
+ * value and the rest of the `Array`.
2604
+ *
2605
+ * @example
2606
+ * import { Array } from "effect"
2607
+ *
2608
+ * const numbers = [1, 2, 3, 4, 5]
2609
+ * const result = Array.chop(numbers, (as): [number, Array<number>] => [as[0] * 2, as.slice(1)])
2610
+ * assert.deepStrictEqual(result, [2, 4, 6, 8, 10])
2611
+ *
2612
+ * // Explanation:
2613
+ * // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
2614
+ * // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
2615
+ * // resulting in a new array `[2, 4, 6, 8, 10]`.
2616
+ *
2617
+ * @since 2.0.0
2618
+ */
1173
2619
  <S extends Iterable<any>, B>(f: (as: NonEmptyReadonlyArray<ReadonlyArray.Infer<S>>) => readonly [B, ReadonlyArray<ReadonlyArray.Infer<S>>]): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>;
2620
+ /**
2621
+ * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for "chopping" up the input
2622
+ * `Iterable`. Typically chop is called with some function that will consume an initial prefix of the `Iterable` and produce a
2623
+ * value and the rest of the `Array`.
2624
+ *
2625
+ * @example
2626
+ * import { Array } from "effect"
2627
+ *
2628
+ * const numbers = [1, 2, 3, 4, 5]
2629
+ * const result = Array.chop(numbers, (as): [number, Array<number>] => [as[0] * 2, as.slice(1)])
2630
+ * assert.deepStrictEqual(result, [2, 4, 6, 8, 10])
2631
+ *
2632
+ * // Explanation:
2633
+ * // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
2634
+ * // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
2635
+ * // resulting in a new array `[2, 4, 6, 8, 10]`.
2636
+ *
2637
+ * @since 2.0.0
2638
+ */
1174
2639
  <A, B>(self: NonEmptyReadonlyArray<A>, f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]): NonEmptyArray<B>;
2640
+ /**
2641
+ * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for "chopping" up the input
2642
+ * `Iterable`. Typically chop is called with some function that will consume an initial prefix of the `Iterable` and produce a
2643
+ * value and the rest of the `Array`.
2644
+ *
2645
+ * @example
2646
+ * import { Array } from "effect"
2647
+ *
2648
+ * const numbers = [1, 2, 3, 4, 5]
2649
+ * const result = Array.chop(numbers, (as): [number, Array<number>] => [as[0] * 2, as.slice(1)])
2650
+ * assert.deepStrictEqual(result, [2, 4, 6, 8, 10])
2651
+ *
2652
+ * // Explanation:
2653
+ * // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
2654
+ * // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
2655
+ * // resulting in a new array `[2, 4, 6, 8, 10]`.
2656
+ *
2657
+ * @since 2.0.0
2658
+ */
1175
2659
  <A, B>(self: Iterable<A>, f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]): Array<B>;
1176
2660
  };
1177
2661
  /**
@@ -1189,7 +2673,35 @@ export declare const chop: {
1189
2673
  * @since 2.0.0
1190
2674
  */
1191
2675
  export declare const splitAt: {
2676
+ /**
2677
+ * Splits an `Iterable` into two segments, with the first segment containing a maximum of `n` elements.
2678
+ * The value of `n` can be `0`.
2679
+ *
2680
+ * @example
2681
+ * import { Array } from "effect"
2682
+ *
2683
+ * const numbers = [1, 2, 3, 4, 5]
2684
+ * const result = Array.splitAt(numbers, 3)
2685
+ * assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
2686
+ *
2687
+ * @category splitting
2688
+ * @since 2.0.0
2689
+ */
1192
2690
  (n: number): <A>(self: Iterable<A>) => [beforeIndex: Array<A>, fromIndex: Array<A>];
2691
+ /**
2692
+ * Splits an `Iterable` into two segments, with the first segment containing a maximum of `n` elements.
2693
+ * The value of `n` can be `0`.
2694
+ *
2695
+ * @example
2696
+ * import { Array } from "effect"
2697
+ *
2698
+ * const numbers = [1, 2, 3, 4, 5]
2699
+ * const result = Array.splitAt(numbers, 3)
2700
+ * assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
2701
+ *
2702
+ * @category splitting
2703
+ * @since 2.0.0
2704
+ */
1193
2705
  <A>(self: Iterable<A>, n: number): [beforeIndex: Array<A>, fromIndex: Array<A>];
1194
2706
  };
1195
2707
  /**
@@ -1206,7 +2718,33 @@ export declare const splitAt: {
1206
2718
  * @since 2.0.0
1207
2719
  */
1208
2720
  export declare const splitNonEmptyAt: {
2721
+ /**
2722
+ * Splits a `NonEmptyReadonlyArray` into two segments, with the first segment containing a maximum of `n` elements.
2723
+ * The value of `n` must be `>= 1`.
2724
+ *
2725
+ * @example
2726
+ * import { Array } from "effect"
2727
+ *
2728
+ * const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
2729
+ * assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
2730
+ *
2731
+ * @category splitting
2732
+ * @since 2.0.0
2733
+ */
1209
2734
  (n: number): <A>(self: NonEmptyReadonlyArray<A>) => [beforeIndex: NonEmptyArray<A>, fromIndex: Array<A>];
2735
+ /**
2736
+ * Splits a `NonEmptyReadonlyArray` into two segments, with the first segment containing a maximum of `n` elements.
2737
+ * The value of `n` must be `>= 1`.
2738
+ *
2739
+ * @example
2740
+ * import { Array } from "effect"
2741
+ *
2742
+ * const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
2743
+ * assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
2744
+ *
2745
+ * @category splitting
2746
+ * @since 2.0.0
2747
+ */
1210
2748
  <A>(self: NonEmptyReadonlyArray<A>, n: number): [beforeIndex: NonEmptyArray<A>, fromIndex: Array<A>];
1211
2749
  };
1212
2750
  /**
@@ -1223,7 +2761,33 @@ export declare const splitNonEmptyAt: {
1223
2761
  * @category splitting
1224
2762
  */
1225
2763
  export declare const split: {
2764
+ /**
2765
+ * Splits this iterable into `n` equally sized arrays.
2766
+ *
2767
+ * @example
2768
+ * import { Array } from "effect"
2769
+ *
2770
+ * const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
2771
+ * const result = Array.split(numbers, 3)
2772
+ * assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
2773
+ *
2774
+ * @since 2.0.0
2775
+ * @category splitting
2776
+ */
1226
2777
  (n: number): <A>(self: Iterable<A>) => Array<Array<A>>;
2778
+ /**
2779
+ * Splits this iterable into `n` equally sized arrays.
2780
+ *
2781
+ * @example
2782
+ * import { Array } from "effect"
2783
+ *
2784
+ * const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
2785
+ * const result = Array.split(numbers, 3)
2786
+ * assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
2787
+ *
2788
+ * @since 2.0.0
2789
+ * @category splitting
2790
+ */
1227
2791
  <A>(self: Iterable<A>, n: number): Array<Array<A>>;
1228
2792
  };
1229
2793
  /**
@@ -1241,7 +2805,35 @@ export declare const split: {
1241
2805
  * @since 2.0.0
1242
2806
  */
1243
2807
  export declare const splitWhere: {
2808
+ /**
2809
+ * Splits this iterable on the first element that matches this predicate.
2810
+ * Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
2811
+ *
2812
+ * @example
2813
+ * import { Array } from "effect"
2814
+ *
2815
+ * const numbers = [1, 2, 3, 4, 5]
2816
+ * const result = Array.splitWhere(numbers, n => n > 3)
2817
+ * assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
2818
+ *
2819
+ * @category splitting
2820
+ * @since 2.0.0
2821
+ */
1244
2822
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => [beforeMatch: Array<A>, fromMatch: Array<A>];
2823
+ /**
2824
+ * Splits this iterable on the first element that matches this predicate.
2825
+ * Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
2826
+ *
2827
+ * @example
2828
+ * import { Array } from "effect"
2829
+ *
2830
+ * const numbers = [1, 2, 3, 4, 5]
2831
+ * const result = Array.splitWhere(numbers, n => n > 3)
2832
+ * assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
2833
+ *
2834
+ * @category splitting
2835
+ * @since 2.0.0
2836
+ */
1245
2837
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): [beforeMatch: Array<A>, fromMatch: Array<A>];
1246
2838
  };
1247
2839
  /**
@@ -1257,9 +2849,82 @@ export declare const splitWhere: {
1257
2849
  * @since 2.0.0
1258
2850
  */
1259
2851
  export declare const copy: {
2852
+ /**
2853
+ * Copies an array.
2854
+ *
2855
+ * @example
2856
+ * import { Array } from "effect"
2857
+ *
2858
+ * const numbers = [1, 2, 3]
2859
+ * const copy = Array.copy(numbers)
2860
+ * assert.deepStrictEqual(copy, [1, 2, 3])
2861
+ *
2862
+ * @since 2.0.0
2863
+ */
1260
2864
  <A>(self: NonEmptyReadonlyArray<A>): NonEmptyArray<A>;
2865
+ /**
2866
+ * Copies an array.
2867
+ *
2868
+ * @example
2869
+ * import { Array } from "effect"
2870
+ *
2871
+ * const numbers = [1, 2, 3]
2872
+ * const copy = Array.copy(numbers)
2873
+ * assert.deepStrictEqual(copy, [1, 2, 3])
2874
+ *
2875
+ * @since 2.0.0
2876
+ */
1261
2877
  <A>(self: ReadonlyArray<A>): Array<A>;
1262
2878
  };
2879
+ /**
2880
+ * Pads an array.
2881
+ * Returns a new array of length `n` with the elements of `array` followed by `fill` elements if `array` is shorter than `n`.
2882
+ * If `array` is longer than `n`, the returned array will be a slice of `array` containing the `n` first elements of `array`.
2883
+ * If `n` is less than or equal to 0, the returned array will be an empty array.
2884
+ *
2885
+ * @example
2886
+ * import { Array } from "effect"
2887
+ *
2888
+ * const arr = [1, 2, 3]
2889
+ * const result = Array.pad(arr, 6, 0)
2890
+ * assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
2891
+ *
2892
+ * @since 3.8.4
2893
+ */
2894
+ export declare const pad: {
2895
+ /**
2896
+ * Pads an array.
2897
+ * Returns a new array of length `n` with the elements of `array` followed by `fill` elements if `array` is shorter than `n`.
2898
+ * If `array` is longer than `n`, the returned array will be a slice of `array` containing the `n` first elements of `array`.
2899
+ * If `n` is less than or equal to 0, the returned array will be an empty array.
2900
+ *
2901
+ * @example
2902
+ * import { Array } from "effect"
2903
+ *
2904
+ * const arr = [1, 2, 3]
2905
+ * const result = Array.pad(arr, 6, 0)
2906
+ * assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
2907
+ *
2908
+ * @since 3.8.4
2909
+ */
2910
+ <A, T>(n: number, fill: T): (self: Array<A>) => Array<A | T>;
2911
+ /**
2912
+ * Pads an array.
2913
+ * Returns a new array of length `n` with the elements of `array` followed by `fill` elements if `array` is shorter than `n`.
2914
+ * If `array` is longer than `n`, the returned array will be a slice of `array` containing the `n` first elements of `array`.
2915
+ * If `n` is less than or equal to 0, the returned array will be an empty array.
2916
+ *
2917
+ * @example
2918
+ * import { Array } from "effect"
2919
+ *
2920
+ * const arr = [1, 2, 3]
2921
+ * const result = Array.pad(arr, 6, 0)
2922
+ * assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
2923
+ *
2924
+ * @since 3.8.4
2925
+ */
2926
+ <A, T>(self: Array<A>, n: number, fill: T): Array<A | T>;
2927
+ };
1263
2928
  /**
1264
2929
  * Splits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
1265
2930
  * the `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive
@@ -1288,8 +2953,89 @@ export declare const copy: {
1288
2953
  * @since 2.0.0
1289
2954
  */
1290
2955
  export declare const chunksOf: {
2956
+ /**
2957
+ * Splits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
2958
+ * the `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive
2959
+ * definition of `chunksOf`; it satisfies the property that
2960
+ *
2961
+ * ```ts
2962
+ * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))
2963
+ * ```
2964
+ *
2965
+ * whenever `n` evenly divides the length of `self`.
2966
+ *
2967
+ * @example
2968
+ * import { Array } from "effect"
2969
+ *
2970
+ * const numbers = [1, 2, 3, 4, 5]
2971
+ * const result = Array.chunksOf(numbers, 2)
2972
+ * assert.deepStrictEqual(result, [[1, 2], [3, 4], [5]])
2973
+ *
2974
+ * // Explanation:
2975
+ * // The `chunksOf` function takes an array of numbers `[1, 2, 3, 4, 5]` and a number `2`.
2976
+ * // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
2977
+ * // the last chunk contains the remaining elements.
2978
+ * // The result is `[[1, 2], [3, 4], [5]]`.
2979
+ *
2980
+ * @category splitting
2981
+ * @since 2.0.0
2982
+ */
1291
2983
  (n: number): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, NonEmptyArray<ReadonlyArray.Infer<S>>>;
2984
+ /**
2985
+ * Splits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
2986
+ * the `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive
2987
+ * definition of `chunksOf`; it satisfies the property that
2988
+ *
2989
+ * ```ts
2990
+ * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))
2991
+ * ```
2992
+ *
2993
+ * whenever `n` evenly divides the length of `self`.
2994
+ *
2995
+ * @example
2996
+ * import { Array } from "effect"
2997
+ *
2998
+ * const numbers = [1, 2, 3, 4, 5]
2999
+ * const result = Array.chunksOf(numbers, 2)
3000
+ * assert.deepStrictEqual(result, [[1, 2], [3, 4], [5]])
3001
+ *
3002
+ * // Explanation:
3003
+ * // The `chunksOf` function takes an array of numbers `[1, 2, 3, 4, 5]` and a number `2`.
3004
+ * // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
3005
+ * // the last chunk contains the remaining elements.
3006
+ * // The result is `[[1, 2], [3, 4], [5]]`.
3007
+ *
3008
+ * @category splitting
3009
+ * @since 2.0.0
3010
+ */
1292
3011
  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<NonEmptyArray<A>>;
3012
+ /**
3013
+ * Splits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
3014
+ * the `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive
3015
+ * definition of `chunksOf`; it satisfies the property that
3016
+ *
3017
+ * ```ts
3018
+ * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))
3019
+ * ```
3020
+ *
3021
+ * whenever `n` evenly divides the length of `self`.
3022
+ *
3023
+ * @example
3024
+ * import { Array } from "effect"
3025
+ *
3026
+ * const numbers = [1, 2, 3, 4, 5]
3027
+ * const result = Array.chunksOf(numbers, 2)
3028
+ * assert.deepStrictEqual(result, [[1, 2], [3, 4], [5]])
3029
+ *
3030
+ * // Explanation:
3031
+ * // The `chunksOf` function takes an array of numbers `[1, 2, 3, 4, 5]` and a number `2`.
3032
+ * // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
3033
+ * // the last chunk contains the remaining elements.
3034
+ * // The result is `[[1, 2], [3, 4], [5]]`.
3035
+ *
3036
+ * @category splitting
3037
+ * @since 2.0.0
3038
+ */
1293
3039
  <A>(self: Iterable<A>, n: number): Array<NonEmptyArray<A>>;
1294
3040
  };
1295
3041
  /**
@@ -1305,7 +3051,31 @@ export declare const chunksOf: {
1305
3051
  * @since 2.0.0
1306
3052
  */
1307
3053
  export declare const groupWith: {
3054
+ /**
3055
+ * Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
3056
+ *
3057
+ * @example
3058
+ * import { Array } from "effect"
3059
+ *
3060
+ * const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
3061
+ * assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
3062
+ *
3063
+ * @category grouping
3064
+ * @since 2.0.0
3065
+ */
1308
3066
  <A>(isEquivalent: (self: A, that: A) => boolean): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<NonEmptyArray<A>>;
3067
+ /**
3068
+ * Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
3069
+ *
3070
+ * @example
3071
+ * import { Array } from "effect"
3072
+ *
3073
+ * const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
3074
+ * assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
3075
+ *
3076
+ * @category grouping
3077
+ * @since 2.0.0
3078
+ */
1309
3079
  <A>(self: NonEmptyReadonlyArray<A>, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray<NonEmptyArray<A>>;
1310
3080
  };
1311
3081
  /**
@@ -1343,7 +3113,49 @@ export declare const group: <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray
1343
3113
  * @since 2.0.0
1344
3114
  */
1345
3115
  export declare const groupBy: {
3116
+ /**
3117
+ * Splits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning
3118
+ * function on each element, and grouping the results according to values returned
3119
+ *
3120
+ * @example
3121
+ * import { Array } from "effect"
3122
+ *
3123
+ * const people = [
3124
+ * { name: "Alice", group: "A" },
3125
+ * { name: "Bob", group: "B" },
3126
+ * { name: "Charlie", group: "A" }
3127
+ * ]
3128
+ * const result = Array.groupBy(people, person => person.group)
3129
+ * assert.deepStrictEqual(result, {
3130
+ * A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
3131
+ * B: [{ name: "Bob", group: "B" }]
3132
+ * })
3133
+ *
3134
+ * @category grouping
3135
+ * @since 2.0.0
3136
+ */
1346
3137
  <A, K extends string | symbol>(f: (a: A) => K): (self: Iterable<A>) => Record<Record.ReadonlyRecord.NonLiteralKey<K>, NonEmptyArray<A>>;
3138
+ /**
3139
+ * Splits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning
3140
+ * function on each element, and grouping the results according to values returned
3141
+ *
3142
+ * @example
3143
+ * import { Array } from "effect"
3144
+ *
3145
+ * const people = [
3146
+ * { name: "Alice", group: "A" },
3147
+ * { name: "Bob", group: "B" },
3148
+ * { name: "Charlie", group: "A" }
3149
+ * ]
3150
+ * const result = Array.groupBy(people, person => person.group)
3151
+ * assert.deepStrictEqual(result, {
3152
+ * A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
3153
+ * B: [{ name: "Bob", group: "B" }]
3154
+ * })
3155
+ *
3156
+ * @category grouping
3157
+ * @since 2.0.0
3158
+ */
1347
3159
  <A, K extends string | symbol>(self: Iterable<A>, f: (a: A) => K): Record<Record.ReadonlyRecord.NonLiteralKey<K>, NonEmptyArray<A>>;
1348
3160
  };
1349
3161
  /**
@@ -1360,9 +3172,61 @@ export declare const groupBy: {
1360
3172
  * @since 2.0.0
1361
3173
  */
1362
3174
  export declare const unionWith: {
3175
+ /**
3176
+ * Calculates the union of two arrays using the provided equivalence relation.
3177
+ *
3178
+ * @example
3179
+ * import { Array } from "effect"
3180
+ *
3181
+ * const array1 = [1, 2]
3182
+ * const array2 = [2, 3]
3183
+ * const union = Array.unionWith(array1, array2, (a, b) => a === b)
3184
+ * assert.deepStrictEqual(union, [1, 2, 3])
3185
+ *
3186
+ * @since 2.0.0
3187
+ */
1363
3188
  <S extends Iterable<any>, T extends Iterable<any>>(that: T, isEquivalent: (self: ReadonlyArray.Infer<S>, that: ReadonlyArray.Infer<T>) => boolean): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>;
3189
+ /**
3190
+ * Calculates the union of two arrays using the provided equivalence relation.
3191
+ *
3192
+ * @example
3193
+ * import { Array } from "effect"
3194
+ *
3195
+ * const array1 = [1, 2]
3196
+ * const array2 = [2, 3]
3197
+ * const union = Array.unionWith(array1, array2, (a, b) => a === b)
3198
+ * assert.deepStrictEqual(union, [1, 2, 3])
3199
+ *
3200
+ * @since 2.0.0
3201
+ */
1364
3202
  <A, B>(self: NonEmptyReadonlyArray<A>, that: Iterable<B>, isEquivalent: (self: A, that: B) => boolean): NonEmptyArray<A | B>;
3203
+ /**
3204
+ * Calculates the union of two arrays using the provided equivalence relation.
3205
+ *
3206
+ * @example
3207
+ * import { Array } from "effect"
3208
+ *
3209
+ * const array1 = [1, 2]
3210
+ * const array2 = [2, 3]
3211
+ * const union = Array.unionWith(array1, array2, (a, b) => a === b)
3212
+ * assert.deepStrictEqual(union, [1, 2, 3])
3213
+ *
3214
+ * @since 2.0.0
3215
+ */
1365
3216
  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>, isEquivalent: (self: A, that: B) => boolean): NonEmptyArray<A | B>;
3217
+ /**
3218
+ * Calculates the union of two arrays using the provided equivalence relation.
3219
+ *
3220
+ * @example
3221
+ * import { Array } from "effect"
3222
+ *
3223
+ * const array1 = [1, 2]
3224
+ * const array2 = [2, 3]
3225
+ * const union = Array.unionWith(array1, array2, (a, b) => a === b)
3226
+ * assert.deepStrictEqual(union, [1, 2, 3])
3227
+ *
3228
+ * @since 2.0.0
3229
+ */
1366
3230
  <A, B>(self: Iterable<A>, that: Iterable<B>, isEquivalent: (self: A, that: B) => boolean): Array<A | B>;
1367
3231
  };
1368
3232
  /**
@@ -1379,9 +3243,61 @@ export declare const unionWith: {
1379
3243
  * @since 2.0.0
1380
3244
  */
1381
3245
  export declare const union: {
3246
+ /**
3247
+ * Creates a union of two arrays, removing duplicates.
3248
+ *
3249
+ * @example
3250
+ * import { Array } from "effect"
3251
+ *
3252
+ * const array1 = [1, 2]
3253
+ * const array2 = [2, 3]
3254
+ * const result = Array.union(array1, array2)
3255
+ * assert.deepStrictEqual(result, [1, 2, 3])
3256
+ *
3257
+ * @since 2.0.0
3258
+ */
1382
3259
  <T extends Iterable<any>>(that: T): <S extends Iterable<any>>(self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>;
3260
+ /**
3261
+ * Creates a union of two arrays, removing duplicates.
3262
+ *
3263
+ * @example
3264
+ * import { Array } from "effect"
3265
+ *
3266
+ * const array1 = [1, 2]
3267
+ * const array2 = [2, 3]
3268
+ * const result = Array.union(array1, array2)
3269
+ * assert.deepStrictEqual(result, [1, 2, 3])
3270
+ *
3271
+ * @since 2.0.0
3272
+ */
1383
3273
  <A, B>(self: NonEmptyReadonlyArray<A>, that: ReadonlyArray<B>): NonEmptyArray<A | B>;
3274
+ /**
3275
+ * Creates a union of two arrays, removing duplicates.
3276
+ *
3277
+ * @example
3278
+ * import { Array } from "effect"
3279
+ *
3280
+ * const array1 = [1, 2]
3281
+ * const array2 = [2, 3]
3282
+ * const result = Array.union(array1, array2)
3283
+ * assert.deepStrictEqual(result, [1, 2, 3])
3284
+ *
3285
+ * @since 2.0.0
3286
+ */
1384
3287
  <A, B>(self: ReadonlyArray<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>;
3288
+ /**
3289
+ * Creates a union of two arrays, removing duplicates.
3290
+ *
3291
+ * @example
3292
+ * import { Array } from "effect"
3293
+ *
3294
+ * const array1 = [1, 2]
3295
+ * const array2 = [2, 3]
3296
+ * const result = Array.union(array1, array2)
3297
+ * assert.deepStrictEqual(result, [1, 2, 3])
3298
+ *
3299
+ * @since 2.0.0
3300
+ */
1385
3301
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>;
1386
3302
  };
1387
3303
  /**
@@ -1418,7 +3334,35 @@ export declare const intersectionWith: <A>(isEquivalent: (self: A, that: A) => b
1418
3334
  * @since 2.0.0
1419
3335
  */
1420
3336
  export declare const intersection: {
3337
+ /**
3338
+ * Creates an `Array` of unique values that are included in all given `Iterable`s.
3339
+ * The order and references of result values are determined by the first `Iterable`.
3340
+ *
3341
+ * @example
3342
+ * import { Array } from "effect"
3343
+ *
3344
+ * const array1 = [1, 2, 3]
3345
+ * const array2 = [3, 4, 1]
3346
+ * const result = Array.intersection(array1, array2)
3347
+ * assert.deepStrictEqual(result, [1, 3])
3348
+ *
3349
+ * @since 2.0.0
3350
+ */
1421
3351
  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<A & B>;
3352
+ /**
3353
+ * Creates an `Array` of unique values that are included in all given `Iterable`s.
3354
+ * The order and references of result values are determined by the first `Iterable`.
3355
+ *
3356
+ * @example
3357
+ * import { Array } from "effect"
3358
+ *
3359
+ * const array1 = [1, 2, 3]
3360
+ * const array2 = [3, 4, 1]
3361
+ * const result = Array.intersection(array1, array2)
3362
+ * assert.deepStrictEqual(result, [1, 3])
3363
+ *
3364
+ * @since 2.0.0
3365
+ */
1422
3366
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A & B>;
1423
3367
  };
1424
3368
  /**
@@ -1454,7 +3398,35 @@ export declare const differenceWith: <A>(isEquivalent: (self: A, that: A) => boo
1454
3398
  * @since 2.0.0
1455
3399
  */
1456
3400
  export declare const difference: {
3401
+ /**
3402
+ * Creates a `Array` of values not included in the other given `Iterable`.
3403
+ * The order and references of result values are determined by the first `Iterable`.
3404
+ *
3405
+ * @example
3406
+ * import { Array } from "effect"
3407
+ *
3408
+ * const array1 = [1, 2, 3]
3409
+ * const array2 = [2, 3, 4]
3410
+ * const difference = Array.difference(array1, array2)
3411
+ * assert.deepStrictEqual(difference, [1])
3412
+ *
3413
+ * @since 2.0.0
3414
+ */
1457
3415
  <A>(that: Iterable<A>): (self: Iterable<A>) => Array<A>;
3416
+ /**
3417
+ * Creates a `Array` of values not included in the other given `Iterable`.
3418
+ * The order and references of result values are determined by the first `Iterable`.
3419
+ *
3420
+ * @example
3421
+ * import { Array } from "effect"
3422
+ *
3423
+ * const array1 = [1, 2, 3]
3424
+ * const array2 = [2, 3, 4]
3425
+ * const difference = Array.difference(array1, array2)
3426
+ * assert.deepStrictEqual(difference, [1])
3427
+ *
3428
+ * @since 2.0.0
3429
+ */
1458
3430
  <A>(self: Iterable<A>, that: Iterable<A>): Array<A>;
1459
3431
  };
1460
3432
  /**
@@ -1499,7 +3471,15 @@ export declare namespace ReadonlyArray {
1499
3471
  * @since 2.0.0
1500
3472
  */
1501
3473
  export declare const map: {
3474
+ /**
3475
+ * @category mapping
3476
+ * @since 2.0.0
3477
+ */
1502
3478
  <S extends ReadonlyArray<any>, B>(f: (a: ReadonlyArray.Infer<S>, i: number) => B): (self: S) => ReadonlyArray.With<S, B>;
3479
+ /**
3480
+ * @category mapping
3481
+ * @since 2.0.0
3482
+ */
1503
3483
  <S extends ReadonlyArray<any>, B>(self: S, f: (a: ReadonlyArray.Infer<S>, i: number) => B): ReadonlyArray.With<S, B>;
1504
3484
  };
1505
3485
  /**
@@ -1509,8 +3489,26 @@ export declare const map: {
1509
3489
  * @since 2.0.0
1510
3490
  */
1511
3491
  export declare const flatMap: {
3492
+ /**
3493
+ * Applies a function to each element in an array and returns a new array containing the concatenated mapped elements.
3494
+ *
3495
+ * @category sequencing
3496
+ * @since 2.0.0
3497
+ */
1512
3498
  <S extends ReadonlyArray<any>, T extends ReadonlyArray<any>>(f: (a: ReadonlyArray.Infer<S>, i: number) => T): (self: S) => ReadonlyArray.AndNonEmpty<S, T, ReadonlyArray.Infer<T>>;
3499
+ /**
3500
+ * Applies a function to each element in an array and returns a new array containing the concatenated mapped elements.
3501
+ *
3502
+ * @category sequencing
3503
+ * @since 2.0.0
3504
+ */
1513
3505
  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A, i: number) => NonEmptyReadonlyArray<B>): NonEmptyArray<B>;
3506
+ /**
3507
+ * Applies a function to each element in an array and returns a new array containing the concatenated mapped elements.
3508
+ *
3509
+ * @category sequencing
3510
+ * @since 2.0.0
3511
+ */
1514
3512
  <A, B>(self: ReadonlyArray<A>, f: (a: A, i: number) => ReadonlyArray<B>): Array<B>;
1515
3513
  };
1516
3514
  /**
@@ -1547,7 +3545,39 @@ export declare const flatten: <S extends ReadonlyArray<ReadonlyArray<any>>>(self
1547
3545
  * @since 2.0.0
1548
3546
  */
1549
3547
  export declare const filterMap: {
3548
+ /**
3549
+ * Applies a function to each element of the `Iterable` and filters based on the result, keeping the transformed values where the function returns `Some`.
3550
+ * This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
3551
+ *
3552
+ * @example
3553
+ * import { Array, Option } from "effect";
3554
+ *
3555
+ * const data = [1, 2, 3, 4, 5];
3556
+ * const evenSquares = (x: number) => x % 2 === 0 ? Option.some(x * x) : Option.none();
3557
+ * const result = Array.filterMap(data, evenSquares);
3558
+ *
3559
+ * assert.deepStrictEqual(result, [4, 16]);
3560
+ *
3561
+ * @category filtering
3562
+ * @since 2.0.0
3563
+ */
1550
3564
  <A, B>(f: (a: A, i: number) => Option<B>): (self: Iterable<A>) => Array<B>;
3565
+ /**
3566
+ * Applies a function to each element of the `Iterable` and filters based on the result, keeping the transformed values where the function returns `Some`.
3567
+ * This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
3568
+ *
3569
+ * @example
3570
+ * import { Array, Option } from "effect";
3571
+ *
3572
+ * const data = [1, 2, 3, 4, 5];
3573
+ * const evenSquares = (x: number) => x % 2 === 0 ? Option.some(x * x) : Option.none();
3574
+ * const result = Array.filterMap(data, evenSquares);
3575
+ *
3576
+ * assert.deepStrictEqual(result, [4, 16]);
3577
+ *
3578
+ * @category filtering
3579
+ * @since 2.0.0
3580
+ */
1551
3581
  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Array<B>;
1552
3582
  };
1553
3583
  /**
@@ -1568,7 +3598,41 @@ export declare const filterMap: {
1568
3598
  * @since 2.0.0
1569
3599
  */
1570
3600
  export declare const filterMapWhile: {
3601
+ /**
3602
+ * Applies a function to each element of the array and filters based on the result, stopping when a condition is not met.
3603
+ * This method combines filtering and mapping in a single pass, and short-circuits, i.e., stops processing, as soon as the function returns `None`.
3604
+ * This is useful when you need to transform an array but only up to the point where a certain condition holds true.
3605
+ *
3606
+ * @example
3607
+ * import { Array, Option } from "effect";
3608
+ *
3609
+ * const data = [2, 4, 5];
3610
+ * const toSquareTillOdd = (x: number) => x % 2 === 0 ? Option.some(x * x) : Option.none();
3611
+ * const result = Array.filterMapWhile(data, toSquareTillOdd);
3612
+ *
3613
+ * assert.deepStrictEqual(result, [4, 16]);
3614
+ *
3615
+ * @category filtering
3616
+ * @since 2.0.0
3617
+ */
1571
3618
  <A, B>(f: (a: A, i: number) => Option<B>): (self: Iterable<A>) => Array<B>;
3619
+ /**
3620
+ * Applies a function to each element of the array and filters based on the result, stopping when a condition is not met.
3621
+ * This method combines filtering and mapping in a single pass, and short-circuits, i.e., stops processing, as soon as the function returns `None`.
3622
+ * This is useful when you need to transform an array but only up to the point where a certain condition holds true.
3623
+ *
3624
+ * @example
3625
+ * import { Array, Option } from "effect";
3626
+ *
3627
+ * const data = [2, 4, 5];
3628
+ * const toSquareTillOdd = (x: number) => x % 2 === 0 ? Option.some(x * x) : Option.none();
3629
+ * const result = Array.filterMapWhile(data, toSquareTillOdd);
3630
+ *
3631
+ * assert.deepStrictEqual(result, [4, 16]);
3632
+ *
3633
+ * @category filtering
3634
+ * @since 2.0.0
3635
+ */
1572
3636
  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Array<B>;
1573
3637
  };
1574
3638
  /**
@@ -1595,7 +3659,53 @@ export declare const filterMapWhile: {
1595
3659
  * @since 2.0.0
1596
3660
  */
1597
3661
  export declare const partitionMap: {
3662
+ /**
3663
+ * Applies a function to each element of the `Iterable`, categorizing the results into two separate arrays.
3664
+ * This function is particularly useful for operations where each element can result in two possible types,
3665
+ * and you want to separate these types into different collections. For instance, separating validation results
3666
+ * into successes and failures.
3667
+ *
3668
+ * @example
3669
+ * import { Array, Either } from "effect";
3670
+ *
3671
+ * const data = [1, 2, 3, 4, 5]
3672
+ * const isEven = (x: number) => x % 2 === 0
3673
+ * const partitioned = Array.partitionMap(data, x =>
3674
+ * isEven(x) ? Either.right(x) : Either.left(x)
3675
+ * )
3676
+ *
3677
+ * assert.deepStrictEqual(partitioned, [
3678
+ * [1, 3, 5],
3679
+ * [2, 4]
3680
+ * ])
3681
+ *
3682
+ * @category filtering
3683
+ * @since 2.0.0
3684
+ */
1598
3685
  <A, B, C>(f: (a: A, i: number) => array_<C, B>): (self: Iterable<A>) => [left: Array<B>, right: Array<C>];
3686
+ /**
3687
+ * Applies a function to each element of the `Iterable`, categorizing the results into two separate arrays.
3688
+ * This function is particularly useful for operations where each element can result in two possible types,
3689
+ * and you want to separate these types into different collections. For instance, separating validation results
3690
+ * into successes and failures.
3691
+ *
3692
+ * @example
3693
+ * import { Array, Either } from "effect";
3694
+ *
3695
+ * const data = [1, 2, 3, 4, 5]
3696
+ * const isEven = (x: number) => x % 2 === 0
3697
+ * const partitioned = Array.partitionMap(data, x =>
3698
+ * isEven(x) ? Either.right(x) : Either.left(x)
3699
+ * )
3700
+ *
3701
+ * assert.deepStrictEqual(partitioned, [
3702
+ * [1, 3, 5],
3703
+ * [2, 4]
3704
+ * ])
3705
+ *
3706
+ * @category filtering
3707
+ * @since 2.0.0
3708
+ */
1599
3709
  <A, B, C>(self: Iterable<A>, f: (a: A, i: number) => array_<C, B>): [left: Array<B>, right: Array<C>];
1600
3710
  };
1601
3711
  /**
@@ -1648,9 +3758,25 @@ export declare const getRights: <T extends Iterable<array_<any, any>>>(self: T)
1648
3758
  * @since 2.0.0
1649
3759
  */
1650
3760
  export declare const filter: {
3761
+ /**
3762
+ * @category filtering
3763
+ * @since 2.0.0
3764
+ */
1651
3765
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Array<B>;
3766
+ /**
3767
+ * @category filtering
3768
+ * @since 2.0.0
3769
+ */
1652
3770
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Array<A>;
3771
+ /**
3772
+ * @category filtering
3773
+ * @since 2.0.0
3774
+ */
1653
3775
  <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Array<B>;
3776
+ /**
3777
+ * @category filtering
3778
+ * @since 2.0.0
3779
+ */
1654
3780
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Array<A>;
1655
3781
  };
1656
3782
  /**
@@ -1660,9 +3786,33 @@ export declare const filter: {
1660
3786
  * @since 2.0.0
1661
3787
  */
1662
3788
  export declare const partition: {
3789
+ /**
3790
+ * Separate elements based on a predicate that also exposes the index of the element.
3791
+ *
3792
+ * @category filtering
3793
+ * @since 2.0.0
3794
+ */
1663
3795
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => [excluded: Array<Exclude<A, B>>, satisfying: Array<B>];
3796
+ /**
3797
+ * Separate elements based on a predicate that also exposes the index of the element.
3798
+ *
3799
+ * @category filtering
3800
+ * @since 2.0.0
3801
+ */
1664
3802
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => [excluded: Array<A>, satisfying: Array<A>];
3803
+ /**
3804
+ * Separate elements based on a predicate that also exposes the index of the element.
3805
+ *
3806
+ * @category filtering
3807
+ * @since 2.0.0
3808
+ */
1665
3809
  <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): [excluded: Array<Exclude<A, B>>, satisfying: Array<B>];
3810
+ /**
3811
+ * Separate elements based on a predicate that also exposes the index of the element.
3812
+ *
3813
+ * @category filtering
3814
+ * @since 2.0.0
3815
+ */
1666
3816
  <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): [excluded: Array<A>, satisfying: Array<A>];
1667
3817
  };
1668
3818
  /**
@@ -1693,7 +3843,33 @@ export declare const separate: <T extends Iterable<array_<any, any>>>(self: T) =
1693
3843
  * @since 2.0.0
1694
3844
  */
1695
3845
  export declare const reduce: {
3846
+ /**
3847
+ * Reduces an array from the left.
3848
+ *
3849
+ * @example
3850
+ * import { Array } from "effect"
3851
+ *
3852
+ * const numbers = [1, 2, 3]
3853
+ * const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
3854
+ * assert.deepStrictEqual(result, 6)
3855
+ *
3856
+ * @category folding
3857
+ * @since 2.0.0
3858
+ */
1696
3859
  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Iterable<A>) => B;
3860
+ /**
3861
+ * Reduces an array from the left.
3862
+ *
3863
+ * @example
3864
+ * import { Array } from "effect"
3865
+ *
3866
+ * const numbers = [1, 2, 3]
3867
+ * const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
3868
+ * assert.deepStrictEqual(result, 6)
3869
+ *
3870
+ * @category folding
3871
+ * @since 2.0.0
3872
+ */
1697
3873
  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B;
1698
3874
  };
1699
3875
  /**
@@ -1710,7 +3886,33 @@ export declare const reduce: {
1710
3886
  * @since 2.0.0
1711
3887
  */
1712
3888
  export declare const reduceRight: {
3889
+ /**
3890
+ * Reduces an array from the right.
3891
+ *
3892
+ * @example
3893
+ * import { Array } from "effect"
3894
+ *
3895
+ * const numbers = [1, 2, 3]
3896
+ * const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
3897
+ * assert.deepStrictEqual(result, 6)
3898
+ *
3899
+ * @category folding
3900
+ * @since 2.0.0
3901
+ */
1713
3902
  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Iterable<A>) => B;
3903
+ /**
3904
+ * Reduces an array from the right.
3905
+ *
3906
+ * @example
3907
+ * import { Array } from "effect"
3908
+ *
3909
+ * const numbers = [1, 2, 3]
3910
+ * const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
3911
+ * assert.deepStrictEqual(result, 6)
3912
+ *
3913
+ * @category folding
3914
+ * @since 2.0.0
3915
+ */
1714
3916
  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B;
1715
3917
  };
1716
3918
  /**
@@ -1729,6 +3931,20 @@ export declare const reduceRight: {
1729
3931
  */
1730
3932
  export declare const liftPredicate: {
1731
3933
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Array<B>;
3934
+ /**
3935
+ * Lifts a predicate into an array.
3936
+ *
3937
+ * @example
3938
+ * import { Array } from "effect"
3939
+ *
3940
+ * const isEven = (n: number) => n % 2 === 0
3941
+ * const to = Array.liftPredicate(isEven)
3942
+ * assert.deepStrictEqual(to(1), [])
3943
+ * assert.deepStrictEqual(to(2), [2])
3944
+ *
3945
+ * @category lifting
3946
+ * @since 2.0.0
3947
+ */
1732
3948
  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Array<B>;
1733
3949
  };
1734
3950
  /**
@@ -1765,7 +3981,43 @@ export declare const liftNullable: <A extends Array<unknown>, B>(f: (...a: A) =>
1765
3981
  * @since 2.0.0
1766
3982
  */
1767
3983
  export declare const flatMapNullable: {
3984
+ /**
3985
+ * Maps over an array and flattens the result, removing null and undefined values.
3986
+ *
3987
+ * @example
3988
+ * import { Array } from "effect"
3989
+ *
3990
+ * const numbers = [1, 2, 3]
3991
+ * const result = Array.flatMapNullable(numbers, n => (n % 2 === 0 ? null : n))
3992
+ * assert.deepStrictEqual(result, [1, 3])
3993
+ *
3994
+ * // Explanation:
3995
+ * // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
3996
+ * // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
3997
+ * // to remove null values, resulting in [1, 3].
3998
+ *
3999
+ * @category sequencing
4000
+ * @since 2.0.0
4001
+ */
1768
4002
  <A, B>(f: (a: A) => B | null | undefined): (self: ReadonlyArray<A>) => Array<NonNullable<B>>;
4003
+ /**
4004
+ * Maps over an array and flattens the result, removing null and undefined values.
4005
+ *
4006
+ * @example
4007
+ * import { Array } from "effect"
4008
+ *
4009
+ * const numbers = [1, 2, 3]
4010
+ * const result = Array.flatMapNullable(numbers, n => (n % 2 === 0 ? null : n))
4011
+ * assert.deepStrictEqual(result, [1, 3])
4012
+ *
4013
+ * // Explanation:
4014
+ * // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
4015
+ * // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
4016
+ * // to remove null values, resulting in [1, 3].
4017
+ *
4018
+ * @category sequencing
4019
+ * @since 2.0.0
4020
+ */
1769
4021
  <A, B>(self: ReadonlyArray<A>, f: (a: A) => B | null | undefined): Array<NonNullable<B>>;
1770
4022
  };
1771
4023
  /**
@@ -1803,9 +4055,33 @@ export declare const liftEither: <A extends Array<unknown>, E, B>(f: (...a: A) =
1803
4055
  * @since 2.0.0
1804
4056
  */
1805
4057
  export declare const every: {
4058
+ /**
4059
+ * Check if a predicate holds true for every `ReadonlyArray` element.
4060
+ *
4061
+ * @category elements
4062
+ * @since 2.0.0
4063
+ */
1806
4064
  <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: ReadonlyArray<A>) => self is ReadonlyArray<B>;
4065
+ /**
4066
+ * Check if a predicate holds true for every `ReadonlyArray` element.
4067
+ *
4068
+ * @category elements
4069
+ * @since 2.0.0
4070
+ */
1807
4071
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: ReadonlyArray<A>) => boolean;
4072
+ /**
4073
+ * Check if a predicate holds true for every `ReadonlyArray` element.
4074
+ *
4075
+ * @category elements
4076
+ * @since 2.0.0
4077
+ */
1808
4078
  <A, B extends A>(self: ReadonlyArray<A>, refinement: (a: A, i: number) => a is B): self is ReadonlyArray<B>;
4079
+ /**
4080
+ * Check if a predicate holds true for every `ReadonlyArray` element.
4081
+ *
4082
+ * @category elements
4083
+ * @since 2.0.0
4084
+ */
1809
4085
  <A>(self: ReadonlyArray<A>, predicate: (a: A, i: number) => boolean): boolean;
1810
4086
  };
1811
4087
  /**
@@ -1815,7 +4091,19 @@ export declare const every: {
1815
4091
  * @since 2.0.0
1816
4092
  */
1817
4093
  export declare const some: {
4094
+ /**
4095
+ * Check if a predicate holds true for some `ReadonlyArray` element.
4096
+ *
4097
+ * @category elements
4098
+ * @since 2.0.0
4099
+ */
1818
4100
  <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: ReadonlyArray<A>) => self is NonEmptyReadonlyArray<A>;
4101
+ /**
4102
+ * Check if a predicate holds true for some `ReadonlyArray` element.
4103
+ *
4104
+ * @category elements
4105
+ * @since 2.0.0
4106
+ */
1819
4107
  <A>(self: ReadonlyArray<A>, predicate: (a: A, i: number) => boolean): self is NonEmptyReadonlyArray<A>;
1820
4108
  };
1821
4109
  /**
@@ -1837,7 +4125,43 @@ export declare const some: {
1837
4125
  * @since 2.0.0
1838
4126
  */
1839
4127
  export declare const extend: {
4128
+ /**
4129
+ * Extends an array with a function that maps each subarray to a value.
4130
+ *
4131
+ * @example
4132
+ * import { Array } from "effect"
4133
+ *
4134
+ * const numbers = [1, 2, 3]
4135
+ * const result = Array.extend(numbers, as => as.length)
4136
+ * assert.deepStrictEqual(result, [3, 2, 1])
4137
+ *
4138
+ * // Explanation:
4139
+ * // The function maps each subarray starting from each element to its length.
4140
+ * // The subarrays are: [1, 2, 3], [2, 3], [3].
4141
+ * // The lengths are: 3, 2, 1.
4142
+ * // Therefore, the result is [3, 2, 1].
4143
+ *
4144
+ * @since 2.0.0
4145
+ */
1840
4146
  <A, B>(f: (as: ReadonlyArray<A>) => B): (self: ReadonlyArray<A>) => Array<B>;
4147
+ /**
4148
+ * Extends an array with a function that maps each subarray to a value.
4149
+ *
4150
+ * @example
4151
+ * import { Array } from "effect"
4152
+ *
4153
+ * const numbers = [1, 2, 3]
4154
+ * const result = Array.extend(numbers, as => as.length)
4155
+ * assert.deepStrictEqual(result, [3, 2, 1])
4156
+ *
4157
+ * // Explanation:
4158
+ * // The function maps each subarray starting from each element to its length.
4159
+ * // The subarrays are: [1, 2, 3], [2, 3], [3].
4160
+ * // The lengths are: 3, 2, 1.
4161
+ * // Therefore, the result is [3, 2, 1].
4162
+ *
4163
+ * @since 2.0.0
4164
+ */
1841
4165
  <A, B>(self: ReadonlyArray<A>, f: (as: ReadonlyArray<A>) => B): Array<B>;
1842
4166
  };
1843
4167
  /**
@@ -1852,7 +4176,29 @@ export declare const extend: {
1852
4176
  * @since 2.0.0
1853
4177
  */
1854
4178
  export declare const min: {
4179
+ /**
4180
+ * Finds the minimum element in an array based on a comparator.
4181
+ *
4182
+ * @example
4183
+ * import { Array, Order } from "effect"
4184
+ *
4185
+ * const min = Array.min([3, 1, 2], Order.number)
4186
+ * assert.deepStrictEqual(min, 1)
4187
+ *
4188
+ * @since 2.0.0
4189
+ */
1855
4190
  <A>(O: Order.Order<A>): (self: NonEmptyReadonlyArray<A>) => A;
4191
+ /**
4192
+ * Finds the minimum element in an array based on a comparator.
4193
+ *
4194
+ * @example
4195
+ * import { Array, Order } from "effect"
4196
+ *
4197
+ * const min = Array.min([3, 1, 2], Order.number)
4198
+ * assert.deepStrictEqual(min, 1)
4199
+ *
4200
+ * @since 2.0.0
4201
+ */
1856
4202
  <A>(self: NonEmptyReadonlyArray<A>, O: Order.Order<A>): A;
1857
4203
  };
1858
4204
  /**
@@ -1867,7 +4213,29 @@ export declare const min: {
1867
4213
  * @since 2.0.0
1868
4214
  */
1869
4215
  export declare const max: {
4216
+ /**
4217
+ * Finds the maximum element in an array based on a comparator.
4218
+ *
4219
+ * @example
4220
+ * import { Array, Order } from "effect"
4221
+ *
4222
+ * const max = Array.max([3, 1, 2], Order.number)
4223
+ * assert.deepStrictEqual(max, 3)
4224
+ *
4225
+ * @since 2.0.0
4226
+ */
1870
4227
  <A>(O: Order.Order<A>): (self: NonEmptyReadonlyArray<A>) => A;
4228
+ /**
4229
+ * Finds the maximum element in an array based on a comparator.
4230
+ *
4231
+ * @example
4232
+ * import { Array, Order } from "effect"
4233
+ *
4234
+ * const max = Array.max([3, 1, 2], Order.number)
4235
+ * assert.deepStrictEqual(max, 3)
4236
+ *
4237
+ * @since 2.0.0
4238
+ */
1871
4239
  <A>(self: NonEmptyReadonlyArray<A>, O: Order.Order<A>): A;
1872
4240
  };
1873
4241
  /**
@@ -1912,7 +4280,29 @@ export declare const getEquivalence: <A>(isEquivalent: Equivalence.Equivalence<A
1912
4280
  * @since 2.0.0
1913
4281
  */
1914
4282
  export declare const forEach: {
4283
+ /**
4284
+ * Performs a side-effect for each element of the `Iterable`.
4285
+ *
4286
+ * @example
4287
+ * import { Array } from "effect"
4288
+ *
4289
+ * const numbers = [1, 2, 3]
4290
+ * Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
4291
+ *
4292
+ * @since 2.0.0
4293
+ */
1915
4294
  <A>(f: (a: A, i: number) => void): (self: Iterable<A>) => void;
4295
+ /**
4296
+ * Performs a side-effect for each element of the `Iterable`.
4297
+ *
4298
+ * @example
4299
+ * import { Array } from "effect"
4300
+ *
4301
+ * const numbers = [1, 2, 3]
4302
+ * Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
4303
+ *
4304
+ * @since 2.0.0
4305
+ */
1916
4306
  <A>(self: Iterable<A>, f: (a: A, i: number) => void): void;
1917
4307
  };
1918
4308
  /**
@@ -1929,8 +4319,47 @@ export declare const forEach: {
1929
4319
  * @since 2.0.0
1930
4320
  */
1931
4321
  export declare const dedupeWith: {
4322
+ /**
4323
+ * Remove duplicates from an `Iterable` using the provided `isEquivalent` function,
4324
+ * preserving the order of the first occurrence of each element.
4325
+ *
4326
+ * @example
4327
+ * import { Array } from "effect"
4328
+ *
4329
+ * const numbers = [1, 2, 2, 3, 3, 3]
4330
+ * const unique = Array.dedupeWith(numbers, (a, b) => a === b)
4331
+ * assert.deepStrictEqual(unique, [1, 2, 3])
4332
+ *
4333
+ * @since 2.0.0
4334
+ */
1932
4335
  <S extends Iterable<any>>(isEquivalent: (self: ReadonlyArray.Infer<S>, that: ReadonlyArray.Infer<S>) => boolean): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>;
4336
+ /**
4337
+ * Remove duplicates from an `Iterable` using the provided `isEquivalent` function,
4338
+ * preserving the order of the first occurrence of each element.
4339
+ *
4340
+ * @example
4341
+ * import { Array } from "effect"
4342
+ *
4343
+ * const numbers = [1, 2, 2, 3, 3, 3]
4344
+ * const unique = Array.dedupeWith(numbers, (a, b) => a === b)
4345
+ * assert.deepStrictEqual(unique, [1, 2, 3])
4346
+ *
4347
+ * @since 2.0.0
4348
+ */
1933
4349
  <A>(self: NonEmptyReadonlyArray<A>, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray<A>;
4350
+ /**
4351
+ * Remove duplicates from an `Iterable` using the provided `isEquivalent` function,
4352
+ * preserving the order of the first occurrence of each element.
4353
+ *
4354
+ * @example
4355
+ * import { Array } from "effect"
4356
+ *
4357
+ * const numbers = [1, 2, 2, 3, 3, 3]
4358
+ * const unique = Array.dedupeWith(numbers, (a, b) => a === b)
4359
+ * assert.deepStrictEqual(unique, [1, 2, 3])
4360
+ *
4361
+ * @since 2.0.0
4362
+ */
1934
4363
  <A>(self: Iterable<A>, isEquivalent: (self: A, that: A) => boolean): Array<A>;
1935
4364
  };
1936
4365
  /**
@@ -1953,7 +4382,31 @@ export declare const dedupe: <S extends Iterable<any> | NonEmptyReadonlyArray<an
1953
4382
  * @since 2.0.0
1954
4383
  */
1955
4384
  export declare const dedupeAdjacentWith: {
4385
+ /**
4386
+ * Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
4387
+ *
4388
+ * @example
4389
+ * import { Array } from "effect"
4390
+ *
4391
+ * const numbers = [1, 1, 2, 2, 3, 3]
4392
+ * const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
4393
+ * assert.deepStrictEqual(unique, [1, 2, 3])
4394
+ *
4395
+ * @since 2.0.0
4396
+ */
1956
4397
  <A>(isEquivalent: (self: A, that: A) => boolean): (self: Iterable<A>) => Array<A>;
4398
+ /**
4399
+ * Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
4400
+ *
4401
+ * @example
4402
+ * import { Array } from "effect"
4403
+ *
4404
+ * const numbers = [1, 1, 2, 2, 3, 3]
4405
+ * const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
4406
+ * assert.deepStrictEqual(unique, [1, 2, 3])
4407
+ *
4408
+ * @since 2.0.0
4409
+ */
1957
4410
  <A>(self: Iterable<A>, isEquivalent: (self: A, that: A) => boolean): Array<A>;
1958
4411
  };
1959
4412
  /**
@@ -1983,7 +4436,33 @@ export declare const dedupeAdjacent: <A>(self: Iterable<A>) => Array<A>;
1983
4436
  * @category folding
1984
4437
  */
1985
4438
  export declare const join: {
4439
+ /**
4440
+ * Joins the elements together with "sep" in the middle.
4441
+ *
4442
+ * @example
4443
+ * import { Array } from "effect"
4444
+ *
4445
+ * const strings = ["a", "b", "c"]
4446
+ * const joined = Array.join(strings, "-")
4447
+ * assert.deepStrictEqual(joined, "a-b-c")
4448
+ *
4449
+ * @since 2.0.0
4450
+ * @category folding
4451
+ */
1986
4452
  (sep: string): (self: Iterable<string>) => string;
4453
+ /**
4454
+ * Joins the elements together with "sep" in the middle.
4455
+ *
4456
+ * @example
4457
+ * import { Array } from "effect"
4458
+ *
4459
+ * const strings = ["a", "b", "c"]
4460
+ * const joined = Array.join(strings, "-")
4461
+ * assert.deepStrictEqual(joined, "a-b-c")
4462
+ *
4463
+ * @since 2.0.0
4464
+ * @category folding
4465
+ */
1987
4466
  (self: Iterable<string>, sep: string): string;
1988
4467
  };
1989
4468
  /**
@@ -2000,8 +4479,34 @@ export declare const join: {
2000
4479
  * @category folding
2001
4480
  */
2002
4481
  export declare const mapAccum: {
2003
- <S, A, B>(s: S, f: (s: S, a: A, i: number) => readonly [S, B]): (self: Iterable<A>) => [state: S, mappedArray: Array<B>];
2004
- <S, A, B>(self: Iterable<A>, s: S, f: (s: S, a: A, i: number) => readonly [S, B]): [state: S, mappedArray: Array<B>];
4482
+ /**
4483
+ * Statefully maps over the chunk, producing new elements of type `B`.
4484
+ *
4485
+ * @example
4486
+ * import { Array } from "effect"
4487
+ *
4488
+ * const numbers = [1, 2, 3]
4489
+ * const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
4490
+ * assert.deepStrictEqual(result, [6, [1, 3, 6]])
4491
+ *
4492
+ * @since 2.0.0
4493
+ * @category folding
4494
+ */
4495
+ <S, A, B, I extends Iterable<A> = Iterable<A>>(s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With<I, B>];
4496
+ /**
4497
+ * Statefully maps over the chunk, producing new elements of type `B`.
4498
+ *
4499
+ * @example
4500
+ * import { Array } from "effect"
4501
+ *
4502
+ * const numbers = [1, 2, 3]
4503
+ * const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
4504
+ * assert.deepStrictEqual(result, [6, [1, 3, 6]])
4505
+ *
4506
+ * @since 2.0.0
4507
+ * @category folding
4508
+ */
4509
+ <S, A, B, I extends Iterable<A> = Iterable<A>>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer<I>, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With<I, B>];
2005
4510
  };
2006
4511
  /**
2007
4512
  * Zips this chunk crosswise with the specified chunk using the specified combiner.
@@ -2018,7 +4523,35 @@ export declare const mapAccum: {
2018
4523
  * @category elements
2019
4524
  */
2020
4525
  export declare const cartesianWith: {
4526
+ /**
4527
+ * Zips this chunk crosswise with the specified chunk using the specified combiner.
4528
+ *
4529
+ * @example
4530
+ * import { Array } from "effect"
4531
+ *
4532
+ * const array1 = [1, 2]
4533
+ * const array2 = ["a", "b"]
4534
+ * const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
4535
+ * assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
4536
+ *
4537
+ * @since 2.0.0
4538
+ * @category elements
4539
+ */
2021
4540
  <A, B, C>(that: ReadonlyArray<B>, f: (a: A, b: B) => C): (self: ReadonlyArray<A>) => Array<C>;
4541
+ /**
4542
+ * Zips this chunk crosswise with the specified chunk using the specified combiner.
4543
+ *
4544
+ * @example
4545
+ * import { Array } from "effect"
4546
+ *
4547
+ * const array1 = [1, 2]
4548
+ * const array2 = ["a", "b"]
4549
+ * const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
4550
+ * assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
4551
+ *
4552
+ * @since 2.0.0
4553
+ * @category elements
4554
+ */
2022
4555
  <A, B, C>(self: ReadonlyArray<A>, that: ReadonlyArray<B>, f: (a: A, b: B) => C): Array<C>;
2023
4556
  };
2024
4557
  /**
@@ -2036,7 +4569,35 @@ export declare const cartesianWith: {
2036
4569
  * @category elements
2037
4570
  */
2038
4571
  export declare const cartesian: {
4572
+ /**
4573
+ * Zips this chunk crosswise with the specified chunk.
4574
+ *
4575
+ * @example
4576
+ * import { Array } from "effect"
4577
+ *
4578
+ * const array1 = [1, 2]
4579
+ * const array2 = ["a", "b"]
4580
+ * const product = Array.cartesian(array1, array2)
4581
+ * assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
4582
+ *
4583
+ * @since 2.0.0
4584
+ * @category elements
4585
+ */
2039
4586
  <B>(that: ReadonlyArray<B>): <A>(self: ReadonlyArray<A>) => Array<[A, B]>;
4587
+ /**
4588
+ * Zips this chunk crosswise with the specified chunk.
4589
+ *
4590
+ * @example
4591
+ * import { Array } from "effect"
4592
+ *
4593
+ * const array1 = [1, 2]
4594
+ * const array2 = ["a", "b"]
4595
+ * const product = Array.cartesian(array1, array2)
4596
+ * assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
4597
+ *
4598
+ * @since 2.0.0
4599
+ * @category elements
4600
+ */
2040
4601
  <A, B>(self: ReadonlyArray<A>, that: ReadonlyArray<B>): Array<[A, B]>;
2041
4602
  };
2042
4603
  /**
@@ -2127,9 +4688,95 @@ export declare const Do: ReadonlyArray<{}>;
2127
4688
  * @since 3.2.0
2128
4689
  */
2129
4690
  export declare const bind: {
4691
+ /**
4692
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
4693
+ *
4694
+ * It can be used to simulate "array comprehension".
4695
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
4696
+ *
4697
+ * Here's how the do simulation works:
4698
+ *
4699
+ * 1. Start the do simulation using the `Do` value
4700
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
4701
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
4702
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
4703
+ * 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
4704
+ *
4705
+ * @see {@link bindTo}
4706
+ * @see {@link Do}
4707
+ * @see {@link let_ let}
4708
+ *
4709
+ * @example
4710
+ * import { Array as Arr, pipe } from "effect"
4711
+ * const doResult = pipe(
4712
+ * Arr.Do,
4713
+ * Arr.bind("x", () => [1, 3, 5]),
4714
+ * Arr.bind("y", () => [2, 4, 6]),
4715
+ * Arr.filter(({ x, y }) => x < y), // condition
4716
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
4717
+ * )
4718
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
4719
+ *
4720
+ * // equivalent
4721
+ * const x = [1, 3, 5],
4722
+ * y = [2, 4, 6],
4723
+ * result = [];
4724
+ * for(let i = 0; i < x.length; i++) {
4725
+ * for(let j = 0; j < y.length; j++) {
4726
+ * const _x = x[i], _y = y[j];
4727
+ * if(_x < _y) result.push([_x, _y] as const)
4728
+ * }
4729
+ * }
4730
+ *
4731
+ * @category do notation
4732
+ * @since 3.2.0
4733
+ */
2130
4734
  <A extends object, N extends string, B>(tag: Exclude<N, keyof A>, f: (a: A) => ReadonlyArray<B>): (self: ReadonlyArray<A>) => Array<{
2131
4735
  [K in N | keyof A]: K extends keyof A ? A[K] : B;
2132
4736
  }>;
4737
+ /**
4738
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
4739
+ *
4740
+ * It can be used to simulate "array comprehension".
4741
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
4742
+ *
4743
+ * Here's how the do simulation works:
4744
+ *
4745
+ * 1. Start the do simulation using the `Do` value
4746
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
4747
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
4748
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
4749
+ * 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
4750
+ *
4751
+ * @see {@link bindTo}
4752
+ * @see {@link Do}
4753
+ * @see {@link let_ let}
4754
+ *
4755
+ * @example
4756
+ * import { Array as Arr, pipe } from "effect"
4757
+ * const doResult = pipe(
4758
+ * Arr.Do,
4759
+ * Arr.bind("x", () => [1, 3, 5]),
4760
+ * Arr.bind("y", () => [2, 4, 6]),
4761
+ * Arr.filter(({ x, y }) => x < y), // condition
4762
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
4763
+ * )
4764
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
4765
+ *
4766
+ * // equivalent
4767
+ * const x = [1, 3, 5],
4768
+ * y = [2, 4, 6],
4769
+ * result = [];
4770
+ * for(let i = 0; i < x.length; i++) {
4771
+ * for(let j = 0; j < y.length; j++) {
4772
+ * const _x = x[i], _y = y[j];
4773
+ * if(_x < _y) result.push([_x, _y] as const)
4774
+ * }
4775
+ * }
4776
+ *
4777
+ * @category do notation
4778
+ * @since 3.2.0
4779
+ */
2133
4780
  <A extends object, N extends string, B>(self: ReadonlyArray<A>, tag: Exclude<N, keyof A>, f: (a: A) => ReadonlyArray<B>): Array<{
2134
4781
  [K in N | keyof A]: K extends keyof A ? A[K] : B;
2135
4782
  }>;
@@ -2178,9 +4825,95 @@ export declare const bind: {
2178
4825
  * @since 3.2.0
2179
4826
  */
2180
4827
  export declare const bindTo: {
4828
+ /**
4829
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
4830
+ *
4831
+ * It can be used to simulate "array comprehension".
4832
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
4833
+ *
4834
+ * Here's how the do simulation works:
4835
+ *
4836
+ * 1. Start the do simulation using the `Do` value
4837
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
4838
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
4839
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
4840
+ * 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
4841
+ *
4842
+ * @see {@link bindTo}
4843
+ * @see {@link Do}
4844
+ * @see {@link let_ let}
4845
+ *
4846
+ * @example
4847
+ * import { Array as Arr, pipe } from "effect"
4848
+ * const doResult = pipe(
4849
+ * Arr.Do,
4850
+ * Arr.bind("x", () => [1, 3, 5]),
4851
+ * Arr.bind("y", () => [2, 4, 6]),
4852
+ * Arr.filter(({ x, y }) => x < y), // condition
4853
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
4854
+ * )
4855
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
4856
+ *
4857
+ * // equivalent
4858
+ * const x = [1, 3, 5],
4859
+ * y = [2, 4, 6],
4860
+ * result = [];
4861
+ * for(let i = 0; i < x.length; i++) {
4862
+ * for(let j = 0; j < y.length; j++) {
4863
+ * const _x = x[i], _y = y[j];
4864
+ * if(_x < _y) result.push([_x, _y] as const)
4865
+ * }
4866
+ * }
4867
+ *
4868
+ * @category do notation
4869
+ * @since 3.2.0
4870
+ */
2181
4871
  <N extends string>(tag: N): <A>(self: ReadonlyArray<A>) => Array<{
2182
4872
  [K in N]: A;
2183
4873
  }>;
4874
+ /**
4875
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
4876
+ *
4877
+ * It can be used to simulate "array comprehension".
4878
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
4879
+ *
4880
+ * Here's how the do simulation works:
4881
+ *
4882
+ * 1. Start the do simulation using the `Do` value
4883
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
4884
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
4885
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
4886
+ * 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
4887
+ *
4888
+ * @see {@link bindTo}
4889
+ * @see {@link Do}
4890
+ * @see {@link let_ let}
4891
+ *
4892
+ * @example
4893
+ * import { Array as Arr, pipe } from "effect"
4894
+ * const doResult = pipe(
4895
+ * Arr.Do,
4896
+ * Arr.bind("x", () => [1, 3, 5]),
4897
+ * Arr.bind("y", () => [2, 4, 6]),
4898
+ * Arr.filter(({ x, y }) => x < y), // condition
4899
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
4900
+ * )
4901
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
4902
+ *
4903
+ * // equivalent
4904
+ * const x = [1, 3, 5],
4905
+ * y = [2, 4, 6],
4906
+ * result = [];
4907
+ * for(let i = 0; i < x.length; i++) {
4908
+ * for(let j = 0; j < y.length; j++) {
4909
+ * const _x = x[i], _y = y[j];
4910
+ * if(_x < _y) result.push([_x, _y] as const)
4911
+ * }
4912
+ * }
4913
+ *
4914
+ * @category do notation
4915
+ * @since 3.2.0
4916
+ */
2184
4917
  <A, N extends string>(self: ReadonlyArray<A>, tag: N): Array<{
2185
4918
  [K in N]: A;
2186
4919
  }>;