effect 4.0.0-beta.101 → 4.0.0-beta.103
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.
- package/dist/Array.d.ts +971 -1037
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +462 -412
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +433 -756
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +200 -325
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +207 -267
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +107 -135
- package/dist/BigInt.js.map +1 -1
- package/dist/Boolean.d.ts +146 -188
- package/dist/Boolean.d.ts.map +1 -1
- package/dist/Boolean.js +64 -84
- package/dist/Boolean.js.map +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +405 -254
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +166 -101
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +167 -277
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +122 -176
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +729 -768
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +541 -449
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +834 -1173
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +326 -439
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +180 -49
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +96 -31
- package/dist/Clock.js.map +1 -1
- package/dist/Combiner.d.ts +20 -33
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +18 -30
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +226 -174
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +339 -267
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +194 -68
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +122 -87
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +233 -33
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js +232 -32
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +151 -274
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +171 -214
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +68 -77
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +57 -66
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +13 -15
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +9 -10
- package/dist/Crypto.js.map +1 -1
- package/dist/Data.d.ts +60 -80
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +18 -24
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +562 -660
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +307 -362
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +253 -256
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +104 -96
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +216 -308
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +132 -186
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +2897 -3342
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1383 -1580
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +22 -40
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +22 -40
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +33 -37
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +29 -21
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +103 -105
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +77 -79
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +51 -27
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +50 -26
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +13 -55
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +7 -28
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +116 -192
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +82 -130
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +82 -146
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +48 -87
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +152 -105
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +109 -75
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +213 -168
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +114 -89
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +123 -81
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +85 -59
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +153 -264
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +42 -147
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +61 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +26 -15
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +25 -33
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +48 -49
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +76 -145
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +40 -57
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +360 -714
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +168 -297
- package/dist/Graph.js.map +1 -1
- package/dist/HKT.d.ts +12 -6
- package/dist/HKT.d.ts.map +1 -1
- package/dist/Hash.d.ts +47 -83
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +46 -68
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +319 -411
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +122 -166
- package/dist/HashMap.js.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +1 -0
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +177 -284
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js +68 -109
- package/dist/HashSet.js.map +1 -1
- package/dist/Inspectable.d.ts +12 -12
- package/dist/Inspectable.js +8 -8
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +620 -786
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +230 -307
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts +11 -13
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +46 -103
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +8 -8
- package/dist/JsonPointer.js +8 -8
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +98 -44
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +300 -239
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +23 -35
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +16 -28
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +359 -260
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +195 -175
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +42 -29
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +31 -21
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +6 -2
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +6 -2
- package/dist/LayerRef.js.map +1 -1
- package/dist/LogLevel.d.ts +114 -214
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +41 -76
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +218 -467
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +207 -452
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +16 -5
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +10 -5
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +217 -252
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +150 -183
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +442 -993
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +202 -645
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +144 -173
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +68 -79
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +84 -89
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +44 -47
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +71 -370
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +59 -284
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts +420 -243
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +209 -120
- package/dist/MutableRef.js.map +1 -1
- package/dist/Newtype.d.ts +21 -14
- package/dist/Newtype.d.ts.map +1 -1
- package/dist/Newtype.js +15 -13
- package/dist/Newtype.js.map +1 -1
- package/dist/NonEmptyIterable.d.ts +7 -137
- package/dist/NonEmptyIterable.d.ts.map +1 -1
- package/dist/NonEmptyIterable.js +5 -93
- package/dist/NonEmptyIterable.js.map +1 -1
- package/dist/Number.d.ts +196 -233
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +90 -109
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +97 -189
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +190 -292
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +447 -812
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +213 -393
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +109 -109
- package/dist/Order.js +91 -91
- package/dist/Order.js.map +1 -1
- package/dist/Ordering.d.ts +20 -23
- package/dist/Ordering.d.ts.map +1 -1
- package/dist/Ordering.js +8 -9
- package/dist/Ordering.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -4
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +38 -41
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +3 -4
- package/dist/Path.js.map +1 -1
- package/dist/Pipeable.d.ts +6 -5
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +2 -2
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +4 -4
- package/dist/PlatformError.js +3 -3
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +4 -2
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +4 -2
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +200 -181
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +100 -108
- package/dist/Predicate.js.map +1 -1
- package/dist/PrimaryKey.d.ts +7 -7
- package/dist/PrimaryKey.js +5 -5
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +425 -494
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +373 -362
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts +24 -18
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +11 -9
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +200 -159
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +162 -132
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +49 -74
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +35 -54
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +121 -63
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +42 -21
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +24 -13
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/RcRef.js +15 -9
- package/dist/RcRef.js.map +1 -1
- package/dist/Record.d.ts +361 -466
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +163 -216
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +6 -2
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +7 -2
- package/dist/Redactable.js.map +1 -1
- package/dist/Redacted.d.ts +25 -25
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +19 -20
- package/dist/Redacted.js.map +1 -1
- package/dist/Reducer.d.ts +8 -15
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +6 -12
- package/dist/Reducer.js.map +1 -1
- package/dist/Ref.d.ts +95 -165
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +75 -122
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +102 -213
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +102 -213
- package/dist/References.js.map +1 -1
- package/dist/RegExp.d.ts +10 -14
- package/dist/RegExp.d.ts.map +1 -1
- package/dist/RegExp.js +10 -14
- package/dist/RegExp.js.map +1 -1
- package/dist/Request.d.ts +31 -21
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +25 -19
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +201 -90
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +87 -41
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +302 -470
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +135 -218
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +50 -75
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +39 -60
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +290 -1636
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +162 -803
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +5 -5
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +18 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +1835 -1060
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2708 -1050
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +29 -52
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +537 -391
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +7 -6
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +8 -7
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +230 -185
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +252 -209
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +62 -190
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +74 -266
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +2 -2
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +123 -86
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +398 -1513
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +290 -2854
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +116 -76
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +123 -88
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +123 -151
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +72 -92
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/ScopedRef.d.ts +3 -3
- package/dist/ScopedRef.js +2 -2
- package/dist/ScopedRef.js.map +1 -1
- package/dist/Semaphore.d.ts +101 -13
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +78 -39
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +117 -107
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +107 -100
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +1 -1
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +2430 -2958
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1124 -1397
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +262 -308
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +184 -215
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +109 -114
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +46 -54
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +282 -250
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +104 -92
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Symbol.d.ts +3 -3
- package/dist/Symbol.js +3 -3
- package/dist/Symbol.js.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Take.js.map +1 -1
- package/dist/Terminal.d.ts +2 -2
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +100 -54
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +41 -24
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +287 -679
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +109 -251
- package/dist/Trie.js.map +1 -1
- package/dist/Tuple.d.ts +92 -127
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js +42 -57
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +201 -121
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +85 -56
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +62 -46
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +30 -22
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +631 -779
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +268 -330
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +297 -236
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +130 -100
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +126 -95
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +74 -56
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +101 -88
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +87 -66
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +200 -180
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +160 -136
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +97 -66
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +67 -45
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +51 -32
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +23 -15
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +129 -95
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +85 -70
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +97 -70
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +44 -34
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +127 -70
- package/dist/Types.d.ts.map +1 -1
- package/dist/UndefinedOr.js.map +1 -1
- package/dist/Unify.d.ts +45 -65
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js +6 -9
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +23 -16
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +3 -7
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/array.js.map +1 -1
- package/dist/internal/core.js +3 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +4 -0
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/doNotation.js.map +1 -1
- package/dist/internal/effect.js +141 -61
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/persistence.d.ts +2 -0
- package/dist/internal/persistence.d.ts.map +1 -0
- package/dist/internal/persistence.js +3 -0
- package/dist/internal/persistence.js.map +1 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/record.d.ts +0 -3
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +10 -5
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/redacted.js.map +1 -1
- package/dist/internal/references.js +3 -4
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js +12 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/cause.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +745 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/fromRepresentation.d.ts +2 -0
- package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/fromRepresentation.js +245 -0
- package/dist/internal/schema/fromRepresentation.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +14 -0
- package/dist/internal/schema/parser.d.ts.map +1 -0
- package/dist/internal/schema/parser.js +13 -0
- package/dist/internal/schema/parser.js.map +1 -0
- package/dist/internal/schema/schema.js +28 -40
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
- package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
- package/dist/internal/schema/toArbitrary.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.d.ts +2 -0
- package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +438 -0
- package/dist/internal/schema/toCodeDocument.js.map +1 -0
- package/dist/internal/schema/toEquivalence.d.ts +2 -0
- package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
- package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
- package/dist/internal/schema/toEquivalence.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +508 -0
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/toRepresentation.d.ts +2 -0
- package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/toRepresentation.js +349 -0
- package/dist/internal/schema/toRepresentation.js.map +1 -0
- package/dist/internal/stackTraceLimit.js +3 -6
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +13 -9
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/FastCheck.d.ts +8 -7
- package/dist/testing/FastCheck.d.ts.map +1 -1
- package/dist/testing/FastCheck.js +8 -7
- package/dist/testing/FastCheck.js.map +1 -1
- package/dist/testing/TestClock.d.ts +57 -28
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +54 -19
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +32 -31
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +24 -22
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +29 -29
- package/dist/testing/TestSchema.js +25 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +121 -144
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +99 -121
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +22 -7
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +87 -317
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +132 -97
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +55 -51
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts +32 -28
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +26 -21
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +111 -68
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +123 -81
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpProtocol.d.ts +30 -0
- package/dist/unstable/ai/McpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/McpProtocol.js +20 -0
- package/dist/unstable/ai/McpProtocol.js.map +1 -0
- package/dist/unstable/ai/McpSchema.d.ts +316 -250
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +71 -63
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +71 -62
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +765 -245
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +8 -19
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +9 -20
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +33 -11
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +194 -378
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +112 -38
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +53 -17
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +47 -33
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +23 -18
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts +46 -13
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +18 -7
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +14 -3
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +10 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +63 -44
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +59 -42
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +35 -9
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +32 -14
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +15 -12
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/mcpProtocol.d.ts +21 -0
- package/dist/unstable/ai/internal/mcpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocol.js +22 -0
- package/dist/unstable/ai/internal/mcpProtocol.js.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts +2 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js +32 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js.map +1 -0
- package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
- package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +315 -0
- package/dist/unstable/ai/internal/structured-output.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +273 -69
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +111 -33
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliConfig.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +105 -74
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +98 -63
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +35 -54
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -42
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +705 -107
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +252 -47
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +418 -138
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +197 -71
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +1 -1
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +12 -4
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +292 -78
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +131 -49
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +370 -149
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +345 -137
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -14
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +23 -14
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/auto-suggest.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +3 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +11 -4
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +0 -48
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +8 -10
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/lexer.js +17 -7
- package/dist/unstable/cli/internal/lexer.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +2 -2
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterMetrics.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +8 -8
- package/dist/unstable/cluster/ClusterSchema.js +8 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +6 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +10 -10
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +9 -9
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityId.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts +4 -2
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +4 -2
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/EntityType.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +5 -4
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts +2 -2
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +6 -4
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/MachineId.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +9 -9
- package/dist/unstable/cluster/Message.js +6 -6
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +15 -15
- package/dist/unstable/cluster/MessageStorage.js +5 -5
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +5 -5
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +1 -1
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +2 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +16 -16
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +2 -2
- package/dist/unstable/cluster/RunnerStorage.js +1 -1
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +6 -6
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +19 -10
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +128 -26
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +13 -5
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +3 -3
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/ShardingRegistrationEvent.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js +2 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/Singleton.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +1 -1
- package/dist/unstable/cluster/SingletonAddress.js +1 -1
- package/dist/unstable/cluster/SingletonAddress.js.map +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts +8 -8
- package/dist/unstable/cluster/Snowflake.js +8 -8
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +56 -25
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +127 -65
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/TestRunner.js.map +1 -1
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +24 -12
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/hash.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
- package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/shardLock.js +4 -0
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
- package/dist/unstable/devtools/DevTools.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +8 -5
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/devtools/DevToolsServer.js.map +1 -1
- package/dist/unstable/devtools/index.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +6 -8
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +72 -8
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +58 -8
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +20 -20
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +4 -4
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +16 -16
- package/dist/unstable/eventlog/EventJournal.js +14 -14
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +3 -3
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +18 -14
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +2 -2
- package/dist/unstable/eventlog/EventLogEncryption.js +2 -2
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +6 -6
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +9 -4
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/eventlog/EventLogRemote.js +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +11 -2
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +45 -21
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +4 -4
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +13 -5
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +5 -5
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +14 -6
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +2 -2
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +54 -40
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +1 -1
- package/dist/unstable/http/Etag.js +1 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +2 -2
- package/dist/unstable/http/Headers.js +10 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +5 -3
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +11 -5
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +51 -44
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +46 -17
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +16 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +4 -4
- package/dist/unstable/http/HttpClientResponse.js +2 -2
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +6 -6
- package/dist/unstable/http/HttpEffect.js +3 -3
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +6 -9
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +6 -9
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +75 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +164 -39
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +76 -0
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +32 -0
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +88 -89
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +78 -79
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +13 -13
- package/dist/unstable/http/HttpServer.js +6 -6
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -2
- package/dist/unstable/http/HttpServerError.js +2 -2
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +4 -4
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +9 -8
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +22 -0
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +10 -0
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +35 -7
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +35 -7
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +6 -6
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +22 -20
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +33 -63
- package/dist/unstable/http/Url.d.ts.map +1 -1
- package/dist/unstable/http/Url.js +14 -28
- package/dist/unstable/http/Url.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +10 -18
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +26 -31
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.d.ts +2 -0
- package/dist/unstable/http/internal/compression.d.ts.map +1 -0
- package/dist/unstable/http/internal/compression.js +155 -0
- package/dist/unstable/http/internal/compression.js.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +3 -3
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +10 -11
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -5
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +16 -18
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +42 -42
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +13 -13
- package/dist/unstable/httpapi/HttpApiError.js +13 -13
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +15 -15
- package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +71 -24
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +57 -10
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +0 -12
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +6 -6
- package/dist/unstable/httpapi/HttpApiSchema.js +4 -4
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +13 -13
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +50 -37
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/index.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -1
- package/dist/unstable/observability/Otlp.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +70 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +84 -6
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +2 -2
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +11 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +5 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts +16 -7
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +21 -12
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +2 -2
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +13 -4
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +10 -3
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/index.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +3 -0
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +8 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +22 -13
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +8 -8
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +2 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +6 -6
- package/dist/unstable/persistence/PersistedQueue.js +6 -6
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +3 -3
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +91 -15
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +28 -17
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +26 -15
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +2 -2
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +3 -3
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/persistence/index.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +64 -21
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +14 -5
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +21 -10
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +4 -2
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/process/index.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +8 -8
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +14 -13
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +105 -19
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +44 -12
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +4 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRef.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +25 -4
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +4 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +1 -1
- package/dist/unstable/reactivity/Hydration.js +1 -1
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +35 -33
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -2
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +12 -12
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +14 -12
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +8 -8
- package/dist/unstable/rpc/RpcGroup.js +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +31 -30
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +6 -6
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +10 -10
- package/dist/unstable/rpc/RpcMiddleware.js +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +4 -4
- package/dist/unstable/rpc/RpcSchema.js +3 -3
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +58 -7
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +175 -96
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +13 -13
- package/dist/unstable/rpc/RpcServer.js +17 -13
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcTest.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +5 -5
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/rpc/index.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +52 -50
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +35 -33
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +6 -7
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +15 -12
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/schema/index.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +12 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +10 -5
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/socket/index.js.map +1 -1
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +2 -2
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.js +2 -2
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.js +2 -2
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +5 -5
- package/dist/unstable/sql/SqlResolver.js +2 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/SqlStream.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +6 -6
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +22 -21
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/sql/index.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +2 -2
- package/dist/unstable/workers/Worker.js +2 -2
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +7 -7
- package/dist/unstable/workers/WorkerError.js +6 -6
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workers/WorkerRunner.d.ts +1 -1
- package/dist/unstable/workers/WorkerRunner.js +1 -1
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workers/index.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.js +2 -2
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +10 -10
- package/dist/unstable/workflow/DurableDeferred.js +5 -5
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +22 -20
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +22 -20
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +21 -21
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +13 -14
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +4 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/dist/unstable/workflow/index.js.map +1 -1
- package/dist/unstable/workflow/internal/crypto.js.map +1 -1
- package/package.json +5 -6
- package/src/Array.ts +1068 -1070
- package/src/BigDecimal.ts +433 -756
- package/src/BigInt.ts +213 -269
- package/src/Boolean.ts +146 -188
- package/src/Cache.ts +409 -255
- package/src/Cause.ts +167 -277
- package/src/Channel.ts +923 -830
- package/src/ChannelSchema.ts +1 -1
- package/src/Chunk.ts +841 -1181
- package/src/Clock.ts +181 -49
- package/src/Combiner.ts +20 -33
- package/src/Config.ts +618 -334
- package/src/ConfigProvider.ts +221 -127
- package/src/Console.ts +289 -39
- package/src/Context.ts +319 -378
- package/src/Cron.ts +68 -77
- package/src/Crypto.ts +13 -15
- package/src/Data.ts +63 -82
- package/src/DateTime.ts +564 -660
- package/src/Deferred.ts +253 -256
- package/src/Duration.ts +216 -308
- package/src/Effect.ts +2958 -3390
- package/src/Encoding.ts +22 -40
- package/src/Equal.ts +49 -39
- package/src/Equivalence.ts +103 -105
- package/src/ErrorReporter.ts +51 -27
- package/src/ExecutionPlan.ts +13 -55
- package/src/Exit.ts +116 -192
- package/src/Fiber.ts +81 -148
- package/src/FiberHandle.ts +155 -107
- package/src/FiberMap.ts +225 -174
- package/src/FiberSet.ts +124 -82
- package/src/FileSystem.ts +155 -263
- package/src/Filter.ts +61 -33
- package/src/Formatter.ts +54 -56
- package/src/Function.ts +76 -145
- package/src/Graph.ts +416 -770
- package/src/HKT.ts +12 -6
- package/src/Hash.ts +52 -83
- package/src/HashMap.ts +319 -411
- package/src/HashRing.ts +1 -0
- package/src/HashSet.ts +177 -284
- package/src/Inspectable.ts +12 -12
- package/src/Iterable.ts +622 -787
- package/src/JsonPatch.ts +60 -113
- package/src/JsonPointer.ts +8 -8
- package/src/JsonSchema.ts +405 -249
- package/src/Latch.ts +23 -35
- package/src/Layer.ts +359 -260
- package/src/LayerMap.ts +49 -29
- package/src/LayerRef.ts +6 -2
- package/src/LogLevel.ts +114 -214
- package/src/Logger.ts +347 -699
- package/src/ManagedRuntime.ts +20 -5
- package/src/Match.ts +217 -252
- package/src/Metric.ts +520 -1092
- package/src/MutableHashMap.ts +218 -255
- package/src/MutableHashSet.ts +84 -89
- package/src/MutableList.ts +73 -370
- package/src/MutableRef.ts +420 -243
- package/src/Newtype.ts +21 -14
- package/src/NonEmptyIterable.ts +7 -137
- package/src/Number.ts +196 -233
- package/src/Optic.ts +246 -385
- package/src/Option.ts +449 -813
- package/src/Order.ts +109 -109
- package/src/Ordering.ts +20 -23
- package/src/PartitionedSemaphore.ts +1 -4
- package/src/Path.ts +38 -41
- package/src/Pipeable.ts +6 -5
- package/src/PlatformError.ts +4 -4
- package/src/Pool.ts +4 -2
- package/src/Predicate.ts +200 -181
- package/src/PrimaryKey.ts +7 -7
- package/src/PubSub.ts +526 -552
- package/src/Pull.ts +24 -18
- package/src/Queue.ts +200 -159
- package/src/Random.ts +49 -74
- package/src/RcMap.ts +121 -63
- package/src/RcRef.ts +24 -13
- package/src/Record.ts +387 -487
- package/src/Redactable.ts +10 -3
- package/src/Redacted.ts +25 -25
- package/src/Reducer.ts +8 -15
- package/src/Ref.ts +221 -361
- package/src/References.ts +102 -214
- package/src/RegExp.ts +10 -14
- package/src/Request.ts +36 -28
- package/src/RequestResolver.ts +202 -91
- package/src/Result.ts +314 -485
- package/src/Runtime.ts +50 -75
- package/src/Schedule.ts +308 -1734
- package/src/Scheduler.ts +20 -7
- package/src/Schema.ts +3156 -1634
- package/src/SchemaAST.ts +676 -489
- package/src/SchemaError.ts +8 -7
- package/src/SchemaGetter.ts +277 -218
- package/src/SchemaIssue.ts +90 -276
- package/src/SchemaParser.ts +179 -116
- package/src/SchemaRepresentation.ts +698 -3417
- package/src/SchemaTransformation.ts +132 -91
- package/src/Scope.ts +123 -151
- package/src/ScopedRef.ts +4 -4
- package/src/Semaphore.ts +157 -54
- package/src/Sink.ts +128 -113
- package/src/Stdio.ts +1 -1
- package/src/Stream.ts +2665 -3142
- package/src/String.ts +275 -312
- package/src/Struct.ts +114 -118
- package/src/SubscriptionRef.ts +284 -252
- package/src/Symbol.ts +3 -3
- package/src/Terminal.ts +2 -2
- package/src/Tracer.ts +102 -55
- package/src/Trie.ts +287 -679
- package/src/Tuple.ts +92 -127
- package/src/TxChunk.ts +201 -121
- package/src/TxDeferred.ts +62 -46
- package/src/TxHashMap.ts +645 -799
- package/src/TxHashSet.ts +443 -356
- package/src/TxPriorityQueue.ts +130 -98
- package/src/TxPubSub.ts +107 -80
- package/src/TxQueue.ts +214 -183
- package/src/TxReentrantLock.ts +97 -66
- package/src/TxRef.ts +51 -32
- package/src/TxSemaphore.ts +129 -95
- package/src/TxSubscriptionRef.ts +97 -70
- package/src/Types.ts +127 -70
- package/src/Unify.ts +45 -65
- package/src/Utils.ts +23 -16
- package/src/index.ts +0 -5
- package/src/internal/core.ts +5 -4
- package/src/internal/dateTime.ts +6 -0
- package/src/internal/effect.ts +160 -79
- package/src/internal/matcher.ts +1 -1
- package/src/internal/persistence.ts +2 -0
- package/src/internal/record.ts +11 -7
- package/src/internal/references.ts +3 -7
- package/src/internal/schema/annotations.ts +44 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +959 -0
- package/src/internal/schema/fromRepresentation.ts +339 -0
- package/src/internal/schema/parser.ts +22 -0
- package/src/internal/schema/schema.ts +45 -46
- package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
- package/src/internal/schema/toCodeDocument.ts +572 -0
- package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
- package/src/internal/schema/toJsonSchemaDocument.ts +529 -0
- package/src/internal/schema/toRepresentation.ts +386 -0
- package/src/internal/stackTraceLimit.ts +3 -7
- package/src/internal/trie.ts +10 -11
- package/src/testing/FastCheck.ts +8 -7
- package/src/testing/TestClock.ts +73 -31
- package/src/testing/TestConsole.ts +32 -31
- package/src/testing/TestSchema.ts +29 -29
- package/src/unstable/ai/AiError.ts +100 -122
- package/src/unstable/ai/AnthropicStructuredOutput.ts +103 -334
- package/src/unstable/ai/Chat.ts +132 -97
- package/src/unstable/ai/EmbeddingModel.ts +1 -1
- package/src/unstable/ai/IdGenerator.ts +32 -28
- package/src/unstable/ai/LanguageModel.ts +137 -95
- package/src/unstable/ai/McpProtocol.ts +48 -0
- package/src/unstable/ai/McpSchema.ts +75 -65
- package/src/unstable/ai/McpServer.ts +1045 -303
- package/src/unstable/ai/Model.ts +9 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +231 -396
- package/src/unstable/ai/Prompt.ts +145 -43
- package/src/unstable/ai/Response.ts +52 -38
- package/src/unstable/ai/Telemetry.ts +46 -13
- package/src/unstable/ai/Tokenizer.ts +14 -3
- package/src/unstable/ai/Tool.ts +81 -48
- package/src/unstable/ai/Toolkit.ts +45 -15
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/ai/internal/codec-transformer.ts +13 -7
- package/src/unstable/ai/internal/mcpProtocol.ts +85 -0
- package/src/unstable/ai/internal/mcpProtocolRegistry.ts +70 -0
- package/src/unstable/ai/internal/structured-output.ts +453 -0
- package/src/unstable/cli/Argument.ts +273 -69
- package/src/unstable/cli/CliError.ts +116 -77
- package/src/unstable/cli/CliOutput.ts +44 -58
- package/src/unstable/cli/Command.ts +709 -111
- package/src/unstable/cli/Flag.ts +418 -138
- package/src/unstable/cli/GlobalFlag.ts +1 -1
- package/src/unstable/cli/HelpDoc.ts +12 -4
- package/src/unstable/cli/Param.ts +295 -81
- package/src/unstable/cli/Primitive.ts +371 -150
- package/src/unstable/cli/Prompt.ts +28 -14
- package/src/unstable/cli/internal/command.ts +13 -5
- package/src/unstable/cli/internal/config.ts +8 -10
- package/src/unstable/cli/internal/lexer.ts +8 -2
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +8 -8
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +8 -4
- package/src/unstable/cluster/Entity.ts +16 -17
- package/src/unstable/cluster/EntityProxy.ts +4 -2
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/Envelope.ts +5 -4
- package/src/unstable/cluster/HttpRunner.ts +6 -4
- package/src/unstable/cluster/Message.ts +9 -9
- package/src/unstable/cluster/MessageStorage.ts +15 -15
- package/src/unstable/cluster/Reply.ts +5 -7
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerHealth.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +41 -8
- package/src/unstable/cluster/RunnerStorage.ts +2 -2
- package/src/unstable/cluster/Runners.ts +23 -12
- package/src/unstable/cluster/ShardId.ts +1 -1
- package/src/unstable/cluster/Sharding.ts +168 -42
- package/src/unstable/cluster/ShardingConfig.ts +8 -4
- package/src/unstable/cluster/SingleRunner.ts +4 -2
- package/src/unstable/cluster/SingletonAddress.ts +1 -1
- package/src/unstable/cluster/Snowflake.ts +8 -8
- package/src/unstable/cluster/SqlMessageStorage.ts +84 -36
- package/src/unstable/cluster/SqlRunnerStorage.ts +205 -119
- package/src/unstable/cluster/internal/entityManager.ts +42 -25
- package/src/unstable/cluster/internal/shardLock.ts +9 -0
- package/src/unstable/devtools/DevToolsSchema.ts +10 -5
- package/src/unstable/encoding/Msgpack.ts +6 -8
- package/src/unstable/encoding/Sse.ts +98 -16
- package/src/unstable/eventlog/Event.ts +20 -20
- package/src/unstable/eventlog/EventGroup.ts +4 -4
- package/src/unstable/eventlog/EventJournal.ts +16 -16
- package/src/unstable/eventlog/EventLog.ts +24 -14
- package/src/unstable/eventlog/EventLogEncryption.ts +2 -2
- package/src/unstable/eventlog/EventLogMessage.ts +12 -5
- package/src/unstable/eventlog/EventLogRemote.ts +1 -1
- package/src/unstable/eventlog/EventLogServer.ts +41 -7
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +13 -5
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +14 -6
- package/src/unstable/eventlog/EventLogSessionAuth.ts +1 -1
- package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
- package/src/unstable/http/Cookies.ts +64 -45
- package/src/unstable/http/Etag.ts +1 -1
- package/src/unstable/http/FetchHttpClient.ts +3 -1
- package/src/unstable/http/Headers.ts +10 -10
- package/src/unstable/http/HttpBody.ts +20 -5
- package/src/unstable/http/HttpClient.ts +83 -55
- package/src/unstable/http/HttpClientRequest.ts +59 -0
- package/src/unstable/http/HttpClientResponse.ts +4 -4
- package/src/unstable/http/HttpEffect.ts +8 -8
- package/src/unstable/http/HttpMethod.ts +6 -9
- package/src/unstable/http/HttpMiddleware.ts +202 -39
- package/src/unstable/http/HttpPlatform.ts +95 -0
- package/src/unstable/http/HttpRouter.ts +102 -98
- package/src/unstable/http/HttpServer.ts +13 -13
- package/src/unstable/http/HttpServerError.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +9 -8
- package/src/unstable/http/HttpServerResponse.ts +30 -0
- package/src/unstable/http/HttpStaticServer.ts +35 -7
- package/src/unstable/http/Multipart.ts +22 -19
- package/src/unstable/http/Template.ts +1 -1
- package/src/unstable/http/Url.ts +33 -63
- package/src/unstable/http/UrlParams.ts +27 -32
- package/src/unstable/http/internal/compression.ts +196 -0
- package/src/unstable/httpapi/HttpApi.ts +3 -3
- package/src/unstable/httpapi/HttpApiBuilder.ts +10 -9
- package/src/unstable/httpapi/HttpApiClient.ts +19 -19
- package/src/unstable/httpapi/HttpApiEndpoint.ts +42 -42
- package/src/unstable/httpapi/HttpApiError.ts +13 -13
- package/src/unstable/httpapi/HttpApiGroup.ts +16 -16
- package/src/unstable/httpapi/HttpApiMiddleware.ts +71 -24
- package/src/unstable/httpapi/HttpApiScalar.ts +0 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +6 -6
- package/src/unstable/httpapi/OpenApi.ts +65 -41
- package/src/unstable/observability/OtlpExporter.ts +126 -10
- package/src/unstable/observability/OtlpLogger.ts +5 -5
- package/src/unstable/observability/OtlpMetrics.ts +12 -5
- package/src/unstable/observability/OtlpResource.ts +26 -17
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/observability/PrometheusMetrics.ts +13 -4
- package/src/unstable/observability/internal/otlpEnv.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +3 -0
- package/src/unstable/persistence/KeyValueStore.ts +72 -49
- package/src/unstable/persistence/Persistable.ts +11 -10
- package/src/unstable/persistence/PersistedQueue.ts +6 -6
- package/src/unstable/persistence/Persistence.ts +126 -19
- package/src/unstable/persistence/RateLimiter.ts +28 -17
- package/src/unstable/persistence/Redis.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +64 -21
- package/src/unstable/process/ChildProcessSpawner.ts +22 -11
- package/src/unstable/reactivity/AsyncResult.ts +16 -16
- package/src/unstable/reactivity/Atom.ts +117 -22
- package/src/unstable/reactivity/AtomHttpApi.ts +5 -4
- package/src/unstable/reactivity/AtomRegistry.ts +25 -4
- package/src/unstable/reactivity/AtomRpc.ts +5 -4
- package/src/unstable/reactivity/Hydration.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +35 -33
- package/src/unstable/rpc/RpcClient.ts +18 -16
- package/src/unstable/rpc/RpcGroup.ts +8 -8
- package/src/unstable/rpc/RpcMessage.ts +31 -30
- package/src/unstable/rpc/RpcMiddleware.ts +10 -10
- package/src/unstable/rpc/RpcSchema.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +167 -68
- package/src/unstable/rpc/RpcServer.ts +18 -15
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/schema/Model.ts +52 -50
- package/src/unstable/schema/VariantSchema.ts +19 -29
- package/src/unstable/socket/Socket.ts +18 -5
- package/src/unstable/sql/SqlClient.ts +5 -6
- package/src/unstable/sql/SqlError.ts +2 -2
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +5 -5
- package/src/unstable/sql/Statement.ts +31 -29
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +2 -2
- package/src/unstable/workers/WorkerError.ts +7 -7
- package/src/unstable/workers/WorkerRunner.ts +1 -1
- package/src/unstable/workflow/Activity.ts +2 -2
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +10 -10
- package/src/unstable/workflow/DurableQueue.ts +22 -20
- package/src/unstable/workflow/Workflow.ts +23 -23
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
- package/src/unstable/workflow/WorkflowProxy.ts +4 -2
- package/dist/SchemaUtils.d.ts +0 -28
- package/dist/SchemaUtils.d.ts.map +0 -1
- package/dist/SchemaUtils.js +0 -45
- package/dist/SchemaUtils.js.map +0 -1
- package/dist/internal/schema/arbitrary.d.ts.map +0 -1
- package/dist/internal/schema/arbitrary.js.map +0 -1
- package/dist/internal/schema/equivalence.d.ts +0 -2
- package/dist/internal/schema/equivalence.d.ts.map +0 -1
- package/dist/internal/schema/equivalence.js.map +0 -1
- package/dist/internal/schema/representation.d.ts +0 -2
- package/dist/internal/schema/representation.d.ts.map +0 -1
- package/dist/internal/schema/representation.js +0 -865
- package/dist/internal/schema/representation.js.map +0 -1
- package/dist/internal/version.d.ts +0 -3
- package/dist/internal/version.d.ts.map +0 -1
- package/dist/internal/version.js +0 -2
- package/dist/internal/version.js.map +0 -1
- package/src/SchemaUtils.ts +0 -51
- package/src/internal/schema/representation.ts +0 -795
- package/src/internal/version.ts +0 -2
package/src/Iterable.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import type { NonEmptyArray } from "./Array.ts"
|
|
13
13
|
import * as Equal from "./Equal.ts"
|
|
14
14
|
import { dual } from "./Function.ts"
|
|
15
|
+
import * as InternalRecord from "./internal/record.ts"
|
|
15
16
|
import type { Option } from "./Option.ts"
|
|
16
17
|
import * as O from "./Option.ts"
|
|
17
18
|
import { isBoolean } from "./Predicate.ts"
|
|
@@ -32,21 +33,21 @@ import type { NoInfer } from "./Types.ts"
|
|
|
32
33
|
*
|
|
33
34
|
* **Example** (Generating values by index)
|
|
34
35
|
*
|
|
35
|
-
* ```ts
|
|
36
|
+
* ```ts import.meta.vitest
|
|
36
37
|
* import { Iterable } from "effect"
|
|
37
38
|
*
|
|
38
39
|
* // Generate first 5 even numbers
|
|
39
40
|
* const evens = Iterable.makeBy((n) => n * 2, { length: 5 })
|
|
40
|
-
*
|
|
41
|
+
* Array.from(evens) // => [0, 2, 4, 6, 8]
|
|
41
42
|
*
|
|
42
43
|
* // Generate squares
|
|
43
44
|
* const squares = Iterable.makeBy((n) => n * n, { length: 4 })
|
|
44
|
-
*
|
|
45
|
+
* Array.from(squares) // => [0, 1, 4, 9]
|
|
45
46
|
*
|
|
46
47
|
* // Infinite sequence (be careful when consuming!)
|
|
47
48
|
* const naturals = Iterable.makeBy((n) => n)
|
|
48
49
|
* const first10 = Iterable.take(naturals, 10)
|
|
49
|
-
*
|
|
50
|
+
* Array.from(first10) // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
50
51
|
* ```
|
|
51
52
|
*
|
|
52
53
|
* @category constructors
|
|
@@ -82,11 +83,10 @@ export const makeBy = <A>(f: (i: number) => A, options?: {
|
|
|
82
83
|
*
|
|
83
84
|
* **Example** (Creating a range)
|
|
84
85
|
*
|
|
85
|
-
* ```ts
|
|
86
|
+
* ```ts import.meta.vitest
|
|
86
87
|
* import { Iterable } from "effect"
|
|
87
|
-
* import * as assert from "node:assert"
|
|
88
88
|
*
|
|
89
|
-
*
|
|
89
|
+
* Array.from(Iterable.range(1, 3)) // => [1, 2, 3]
|
|
90
90
|
* ```
|
|
91
91
|
*
|
|
92
92
|
* @category constructors
|
|
@@ -110,11 +110,10 @@ export const range = (start: number, end?: number): Iterable<number> => {
|
|
|
110
110
|
*
|
|
111
111
|
* **Example** (Repeating a value)
|
|
112
112
|
*
|
|
113
|
-
* ```ts
|
|
113
|
+
* ```ts import.meta.vitest
|
|
114
114
|
* import { Iterable } from "effect"
|
|
115
|
-
* import * as assert from "node:assert"
|
|
116
115
|
*
|
|
117
|
-
*
|
|
116
|
+
* Array.from(Iterable.replicate("a", 3)) // => ["a", "a", "a"]
|
|
118
117
|
* ```
|
|
119
118
|
*
|
|
120
119
|
* @category constructors
|
|
@@ -130,11 +129,10 @@ export const replicate: {
|
|
|
130
129
|
*
|
|
131
130
|
* **Example** (Repeating a value)
|
|
132
131
|
*
|
|
133
|
-
* ```ts
|
|
132
|
+
* ```ts import.meta.vitest
|
|
134
133
|
* import { Iterable } from "effect"
|
|
135
|
-
* import * as assert from "node:assert"
|
|
136
134
|
*
|
|
137
|
-
*
|
|
135
|
+
* Array.from(Iterable.replicate("a", 3)) // => ["a", "a", "a"]
|
|
138
136
|
* ```
|
|
139
137
|
*
|
|
140
138
|
* @category constructors
|
|
@@ -150,11 +148,10 @@ export const replicate: {
|
|
|
150
148
|
*
|
|
151
149
|
* **Example** (Repeating a value)
|
|
152
150
|
*
|
|
153
|
-
* ```ts
|
|
151
|
+
* ```ts import.meta.vitest
|
|
154
152
|
* import { Iterable } from "effect"
|
|
155
|
-
* import * as assert from "node:assert"
|
|
156
153
|
*
|
|
157
|
-
*
|
|
154
|
+
* Array.from(Iterable.replicate("a", 3)) // => ["a", "a", "a"]
|
|
158
155
|
* ```
|
|
159
156
|
*
|
|
160
157
|
* @category constructors
|
|
@@ -245,15 +242,11 @@ export const forever = <A>(self: Iterable<A>): Iterable<A> => repeat(self, Infin
|
|
|
245
242
|
*
|
|
246
243
|
* **Example** (Converting a record to entries)
|
|
247
244
|
*
|
|
248
|
-
* ```ts
|
|
245
|
+
* ```ts import.meta.vitest
|
|
249
246
|
* import { Iterable } from "effect"
|
|
250
|
-
* import * as assert from "node:assert"
|
|
251
247
|
*
|
|
252
248
|
* const x = { a: 1, b: 2, c: 3 }
|
|
253
|
-
*
|
|
254
|
-
* "c",
|
|
255
|
-
* 3
|
|
256
|
-
* ]])
|
|
249
|
+
* Array.from(Iterable.fromRecord(x)) // => [["a", 1], ["b", 2], ["c", 3]]
|
|
257
250
|
* ```
|
|
258
251
|
*
|
|
259
252
|
* @category converting
|
|
@@ -274,17 +267,17 @@ export const fromRecord = <K extends string, A>(self: Readonly<Record<K, A>>): I
|
|
|
274
267
|
*
|
|
275
268
|
* **Example** (Prepending an element)
|
|
276
269
|
*
|
|
277
|
-
* ```ts
|
|
270
|
+
* ```ts import.meta.vitest
|
|
278
271
|
* import { Iterable } from "effect"
|
|
279
272
|
*
|
|
280
273
|
* const numbers = [2, 3, 4]
|
|
281
274
|
* const withOne = Iterable.prepend(numbers, 1)
|
|
282
|
-
*
|
|
275
|
+
* Array.from(withOne) // => [1, 2, 3, 4]
|
|
283
276
|
*
|
|
284
277
|
* // Works with any iterable
|
|
285
278
|
* const letters = "abc"
|
|
286
279
|
* const withZ = Iterable.prepend(letters, "z")
|
|
287
|
-
*
|
|
280
|
+
* Array.from(withZ) // => ["z", "a", "b", "c"]
|
|
288
281
|
* ```
|
|
289
282
|
*
|
|
290
283
|
* @category combining
|
|
@@ -296,17 +289,17 @@ export const prepend: {
|
|
|
296
289
|
*
|
|
297
290
|
* **Example** (Prepending an element)
|
|
298
291
|
*
|
|
299
|
-
* ```ts
|
|
292
|
+
* ```ts import.meta.vitest
|
|
300
293
|
* import { Iterable } from "effect"
|
|
301
294
|
*
|
|
302
295
|
* const numbers = [2, 3, 4]
|
|
303
296
|
* const withOne = Iterable.prepend(numbers, 1)
|
|
304
|
-
*
|
|
297
|
+
* Array.from(withOne) // => [1, 2, 3, 4]
|
|
305
298
|
*
|
|
306
299
|
* // Works with any iterable
|
|
307
300
|
* const letters = "abc"
|
|
308
301
|
* const withZ = Iterable.prepend(letters, "z")
|
|
309
|
-
*
|
|
302
|
+
* Array.from(withZ) // => ["z", "a", "b", "c"]
|
|
310
303
|
* ```
|
|
311
304
|
*
|
|
312
305
|
* @category combining
|
|
@@ -318,17 +311,17 @@ export const prepend: {
|
|
|
318
311
|
*
|
|
319
312
|
* **Example** (Prepending an element)
|
|
320
313
|
*
|
|
321
|
-
* ```ts
|
|
314
|
+
* ```ts import.meta.vitest
|
|
322
315
|
* import { Iterable } from "effect"
|
|
323
316
|
*
|
|
324
317
|
* const numbers = [2, 3, 4]
|
|
325
318
|
* const withOne = Iterable.prepend(numbers, 1)
|
|
326
|
-
*
|
|
319
|
+
* Array.from(withOne) // => [1, 2, 3, 4]
|
|
327
320
|
*
|
|
328
321
|
* // Works with any iterable
|
|
329
322
|
* const letters = "abc"
|
|
330
323
|
* const withZ = Iterable.prepend(letters, "z")
|
|
331
|
-
*
|
|
324
|
+
* Array.from(withZ) // => ["z", "a", "b", "c"]
|
|
332
325
|
* ```
|
|
333
326
|
*
|
|
334
327
|
* @category combining
|
|
@@ -342,14 +335,10 @@ export const prepend: {
|
|
|
342
335
|
*
|
|
343
336
|
* **Example** (Prepending another iterable)
|
|
344
337
|
*
|
|
345
|
-
* ```ts
|
|
338
|
+
* ```ts import.meta.vitest
|
|
346
339
|
* import { Iterable } from "effect"
|
|
347
|
-
* import * as assert from "node:assert"
|
|
348
340
|
*
|
|
349
|
-
*
|
|
350
|
-
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
|
|
351
|
-
* ["a", "b", 1, 2]
|
|
352
|
-
* )
|
|
341
|
+
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])) // => ["a", "b", 1, 2]
|
|
353
342
|
* ```
|
|
354
343
|
*
|
|
355
344
|
* @category combining
|
|
@@ -361,14 +350,10 @@ export const prependAll: {
|
|
|
361
350
|
*
|
|
362
351
|
* **Example** (Prepending another iterable)
|
|
363
352
|
*
|
|
364
|
-
* ```ts
|
|
353
|
+
* ```ts import.meta.vitest
|
|
365
354
|
* import { Iterable } from "effect"
|
|
366
|
-
* import * as assert from "node:assert"
|
|
367
355
|
*
|
|
368
|
-
*
|
|
369
|
-
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
|
|
370
|
-
* ["a", "b", 1, 2]
|
|
371
|
-
* )
|
|
356
|
+
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])) // => ["a", "b", 1, 2]
|
|
372
357
|
* ```
|
|
373
358
|
*
|
|
374
359
|
* @category combining
|
|
@@ -380,14 +365,10 @@ export const prependAll: {
|
|
|
380
365
|
*
|
|
381
366
|
* **Example** (Prepending another iterable)
|
|
382
367
|
*
|
|
383
|
-
* ```ts
|
|
368
|
+
* ```ts import.meta.vitest
|
|
384
369
|
* import { Iterable } from "effect"
|
|
385
|
-
* import * as assert from "node:assert"
|
|
386
370
|
*
|
|
387
|
-
*
|
|
388
|
-
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
|
|
389
|
-
* ["a", "b", 1, 2]
|
|
390
|
-
* )
|
|
371
|
+
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])) // => ["a", "b", 1, 2]
|
|
391
372
|
* ```
|
|
392
373
|
*
|
|
393
374
|
* @category combining
|
|
@@ -419,19 +400,11 @@ export const prependAll: {
|
|
|
419
400
|
*
|
|
420
401
|
* **Example** (Appending an element)
|
|
421
402
|
*
|
|
422
|
-
* ```ts
|
|
403
|
+
* ```ts import.meta.vitest
|
|
423
404
|
* import { Iterable } from "effect"
|
|
424
405
|
*
|
|
425
406
|
* const numbers = [1, 2, 3]
|
|
426
|
-
*
|
|
427
|
-
* console.log(Array.from(withFour)) // [1, 2, 3, 4]
|
|
428
|
-
*
|
|
429
|
-
* // Chain multiple appends
|
|
430
|
-
* const result = Iterable.append(
|
|
431
|
-
* Iterable.append([1, 2], 3),
|
|
432
|
-
* 4
|
|
433
|
-
* )
|
|
434
|
-
* console.log(Array.from(result)) // [1, 2, 3, 4]
|
|
407
|
+
* Array.from(Iterable.append(numbers, 4)) // => [1, 2, 3, 4]
|
|
435
408
|
* ```
|
|
436
409
|
*
|
|
437
410
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -461,19 +434,11 @@ export const append: {
|
|
|
461
434
|
*
|
|
462
435
|
* **Example** (Appending an element)
|
|
463
436
|
*
|
|
464
|
-
* ```ts
|
|
437
|
+
* ```ts import.meta.vitest
|
|
465
438
|
* import { Iterable } from "effect"
|
|
466
439
|
*
|
|
467
440
|
* const numbers = [1, 2, 3]
|
|
468
|
-
*
|
|
469
|
-
* console.log(Array.from(withFour)) // [1, 2, 3, 4]
|
|
470
|
-
*
|
|
471
|
-
* // Chain multiple appends
|
|
472
|
-
* const result = Iterable.append(
|
|
473
|
-
* Iterable.append([1, 2], 3),
|
|
474
|
-
* 4
|
|
475
|
-
* )
|
|
476
|
-
* console.log(Array.from(result)) // [1, 2, 3, 4]
|
|
441
|
+
* Array.from(Iterable.append(numbers, 4)) // => [1, 2, 3, 4]
|
|
477
442
|
* ```
|
|
478
443
|
*
|
|
479
444
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -503,19 +468,11 @@ export const append: {
|
|
|
503
468
|
*
|
|
504
469
|
* **Example** (Appending an element)
|
|
505
470
|
*
|
|
506
|
-
* ```ts
|
|
471
|
+
* ```ts import.meta.vitest
|
|
507
472
|
* import { Iterable } from "effect"
|
|
508
473
|
*
|
|
509
474
|
* const numbers = [1, 2, 3]
|
|
510
|
-
*
|
|
511
|
-
* console.log(Array.from(withFour)) // [1, 2, 3, 4]
|
|
512
|
-
*
|
|
513
|
-
* // Chain multiple appends
|
|
514
|
-
* const result = Iterable.append(
|
|
515
|
-
* Iterable.append([1, 2], 3),
|
|
516
|
-
* 4
|
|
517
|
-
* )
|
|
518
|
-
* console.log(Array.from(result)) // [1, 2, 3, 4]
|
|
475
|
+
* Array.from(Iterable.append(numbers, 4)) // => [1, 2, 3, 4]
|
|
519
476
|
* ```
|
|
520
477
|
*
|
|
521
478
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -546,25 +503,21 @@ export const append: {
|
|
|
546
503
|
*
|
|
547
504
|
* **Example** (Concatenating iterables)
|
|
548
505
|
*
|
|
549
|
-
* ```ts
|
|
506
|
+
* ```ts import.meta.vitest
|
|
550
507
|
* import { Iterable } from "effect"
|
|
551
508
|
*
|
|
552
|
-
*
|
|
553
|
-
* const second = [4, 5, 6]
|
|
554
|
-
* const combined = Iterable.appendAll(first, second)
|
|
555
|
-
* console.log(Array.from(combined)) // [1, 2, 3, 4, 5, 6]
|
|
509
|
+
* Array.from(Iterable.appendAll([1, 2, 3], [4, 5, 6])) // => [1, 2, 3, 4, 5, 6]
|
|
556
510
|
*
|
|
557
511
|
* // Works with different iterable types
|
|
558
512
|
* const numbers = [1, 2]
|
|
559
513
|
* const letters = "abc"
|
|
560
514
|
* const mixed = Iterable.appendAll(numbers, letters)
|
|
561
|
-
*
|
|
515
|
+
* Array.from(mixed) // => [1, 2, "a", "b", "c"]
|
|
562
516
|
*
|
|
563
517
|
* // Lazy evaluation - only consumes what's needed
|
|
564
518
|
* const infinite = Iterable.range(1)
|
|
565
519
|
* const finite = [0, -1, -2]
|
|
566
|
-
*
|
|
567
|
-
* console.log(Array.from(result)) // [0, -1, -2, 1, 2]
|
|
520
|
+
* Array.from(Iterable.take(Iterable.appendAll(finite, infinite), 5)) // => [0, -1, -2, 1, 2]
|
|
568
521
|
* ```
|
|
569
522
|
*
|
|
570
523
|
* @see {@link append} for appending one value instead of another iterable
|
|
@@ -593,25 +546,21 @@ export const appendAll: {
|
|
|
593
546
|
*
|
|
594
547
|
* **Example** (Concatenating iterables)
|
|
595
548
|
*
|
|
596
|
-
* ```ts
|
|
549
|
+
* ```ts import.meta.vitest
|
|
597
550
|
* import { Iterable } from "effect"
|
|
598
551
|
*
|
|
599
|
-
*
|
|
600
|
-
* const second = [4, 5, 6]
|
|
601
|
-
* const combined = Iterable.appendAll(first, second)
|
|
602
|
-
* console.log(Array.from(combined)) // [1, 2, 3, 4, 5, 6]
|
|
552
|
+
* Array.from(Iterable.appendAll([1, 2, 3], [4, 5, 6])) // => [1, 2, 3, 4, 5, 6]
|
|
603
553
|
*
|
|
604
554
|
* // Works with different iterable types
|
|
605
555
|
* const numbers = [1, 2]
|
|
606
556
|
* const letters = "abc"
|
|
607
557
|
* const mixed = Iterable.appendAll(numbers, letters)
|
|
608
|
-
*
|
|
558
|
+
* Array.from(mixed) // => [1, 2, "a", "b", "c"]
|
|
609
559
|
*
|
|
610
560
|
* // Lazy evaluation - only consumes what's needed
|
|
611
561
|
* const infinite = Iterable.range(1)
|
|
612
562
|
* const finite = [0, -1, -2]
|
|
613
|
-
*
|
|
614
|
-
* console.log(Array.from(result)) // [0, -1, -2, 1, 2]
|
|
563
|
+
* Array.from(Iterable.take(Iterable.appendAll(finite, infinite), 5)) // => [0, -1, -2, 1, 2]
|
|
615
564
|
* ```
|
|
616
565
|
*
|
|
617
566
|
* @see {@link append} for appending one value instead of another iterable
|
|
@@ -640,25 +589,21 @@ export const appendAll: {
|
|
|
640
589
|
*
|
|
641
590
|
* **Example** (Concatenating iterables)
|
|
642
591
|
*
|
|
643
|
-
* ```ts
|
|
592
|
+
* ```ts import.meta.vitest
|
|
644
593
|
* import { Iterable } from "effect"
|
|
645
594
|
*
|
|
646
|
-
*
|
|
647
|
-
* const second = [4, 5, 6]
|
|
648
|
-
* const combined = Iterable.appendAll(first, second)
|
|
649
|
-
* console.log(Array.from(combined)) // [1, 2, 3, 4, 5, 6]
|
|
595
|
+
* Array.from(Iterable.appendAll([1, 2, 3], [4, 5, 6])) // => [1, 2, 3, 4, 5, 6]
|
|
650
596
|
*
|
|
651
597
|
* // Works with different iterable types
|
|
652
598
|
* const numbers = [1, 2]
|
|
653
599
|
* const letters = "abc"
|
|
654
600
|
* const mixed = Iterable.appendAll(numbers, letters)
|
|
655
|
-
*
|
|
601
|
+
* Array.from(mixed) // => [1, 2, "a", "b", "c"]
|
|
656
602
|
*
|
|
657
603
|
* // Lazy evaluation - only consumes what's needed
|
|
658
604
|
* const infinite = Iterable.range(1)
|
|
659
605
|
* const finite = [0, -1, -2]
|
|
660
|
-
*
|
|
661
|
-
* console.log(Array.from(result)) // [0, -1, -2, 1, 2]
|
|
606
|
+
* Array.from(Iterable.take(Iterable.appendAll(finite, infinite), 5)) // => [0, -1, -2, 1, 2]
|
|
662
607
|
* ```
|
|
663
608
|
*
|
|
664
609
|
* @see {@link append} for appending one value instead of another iterable
|
|
@@ -698,23 +643,23 @@ export const appendAll: {
|
|
|
698
643
|
*
|
|
699
644
|
* **Example** (Tracking running results)
|
|
700
645
|
*
|
|
701
|
-
* ```ts
|
|
646
|
+
* ```ts import.meta.vitest
|
|
702
647
|
* import { Iterable } from "effect"
|
|
703
648
|
*
|
|
704
649
|
* // Running sum of numbers
|
|
705
650
|
* const numbers = [1, 2, 3, 4, 5]
|
|
706
651
|
* const runningSum = Iterable.scan(numbers, 0, (acc, n) => acc + n)
|
|
707
|
-
*
|
|
652
|
+
* Array.from(runningSum) // => [0, 1, 3, 6, 10, 15]
|
|
708
653
|
*
|
|
709
654
|
* // Build strings progressively
|
|
710
655
|
* const letters = ["a", "b", "c"]
|
|
711
656
|
* const progressive = Iterable.scan(letters, "", (acc, letter) => acc + letter)
|
|
712
|
-
*
|
|
657
|
+
* Array.from(progressive) // => ["", "a", "ab", "abc"]
|
|
713
658
|
*
|
|
714
659
|
* // Track maximum values seen so far
|
|
715
660
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
716
661
|
* const runningMax = Iterable.scan(values, -Infinity, Math.max)
|
|
717
|
-
*
|
|
662
|
+
* Array.from(runningMax) // => [-Infinity, 3, 3, 4, 4, 5, 9, 9]
|
|
718
663
|
* ```
|
|
719
664
|
*
|
|
720
665
|
* @category folding
|
|
@@ -726,23 +671,23 @@ export const scan: {
|
|
|
726
671
|
*
|
|
727
672
|
* **Example** (Tracking running results)
|
|
728
673
|
*
|
|
729
|
-
* ```ts
|
|
674
|
+
* ```ts import.meta.vitest
|
|
730
675
|
* import { Iterable } from "effect"
|
|
731
676
|
*
|
|
732
677
|
* // Running sum of numbers
|
|
733
678
|
* const numbers = [1, 2, 3, 4, 5]
|
|
734
679
|
* const runningSum = Iterable.scan(numbers, 0, (acc, n) => acc + n)
|
|
735
|
-
*
|
|
680
|
+
* Array.from(runningSum) // => [0, 1, 3, 6, 10, 15]
|
|
736
681
|
*
|
|
737
682
|
* // Build strings progressively
|
|
738
683
|
* const letters = ["a", "b", "c"]
|
|
739
684
|
* const progressive = Iterable.scan(letters, "", (acc, letter) => acc + letter)
|
|
740
|
-
*
|
|
685
|
+
* Array.from(progressive) // => ["", "a", "ab", "abc"]
|
|
741
686
|
*
|
|
742
687
|
* // Track maximum values seen so far
|
|
743
688
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
744
689
|
* const runningMax = Iterable.scan(values, -Infinity, Math.max)
|
|
745
|
-
*
|
|
690
|
+
* Array.from(runningMax) // => [-Infinity, 3, 3, 4, 4, 5, 9, 9]
|
|
746
691
|
* ```
|
|
747
692
|
*
|
|
748
693
|
* @category folding
|
|
@@ -754,23 +699,23 @@ export const scan: {
|
|
|
754
699
|
*
|
|
755
700
|
* **Example** (Tracking running results)
|
|
756
701
|
*
|
|
757
|
-
* ```ts
|
|
702
|
+
* ```ts import.meta.vitest
|
|
758
703
|
* import { Iterable } from "effect"
|
|
759
704
|
*
|
|
760
705
|
* // Running sum of numbers
|
|
761
706
|
* const numbers = [1, 2, 3, 4, 5]
|
|
762
707
|
* const runningSum = Iterable.scan(numbers, 0, (acc, n) => acc + n)
|
|
763
|
-
*
|
|
708
|
+
* Array.from(runningSum) // => [0, 1, 3, 6, 10, 15]
|
|
764
709
|
*
|
|
765
710
|
* // Build strings progressively
|
|
766
711
|
* const letters = ["a", "b", "c"]
|
|
767
712
|
* const progressive = Iterable.scan(letters, "", (acc, letter) => acc + letter)
|
|
768
|
-
*
|
|
713
|
+
* Array.from(progressive) // => ["", "a", "ab", "abc"]
|
|
769
714
|
*
|
|
770
715
|
* // Track maximum values seen so far
|
|
771
716
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
772
717
|
* const runningMax = Iterable.scan(values, -Infinity, Math.max)
|
|
773
|
-
*
|
|
718
|
+
* Array.from(runningMax) // => [-Infinity, 3, 3, 4, 4, 5, 9, 9]
|
|
774
719
|
* ```
|
|
775
720
|
*
|
|
776
721
|
* @category folding
|
|
@@ -802,12 +747,11 @@ export const scan: {
|
|
|
802
747
|
*
|
|
803
748
|
* **Example** (Checking for emptiness)
|
|
804
749
|
*
|
|
805
|
-
* ```ts
|
|
750
|
+
* ```ts import.meta.vitest
|
|
806
751
|
* import { Iterable } from "effect"
|
|
807
|
-
* import * as assert from "node:assert"
|
|
808
752
|
*
|
|
809
|
-
*
|
|
810
|
-
*
|
|
753
|
+
* Iterable.isEmpty([]) // => true
|
|
754
|
+
* Iterable.isEmpty([1, 2, 3]) // => false
|
|
811
755
|
* ```
|
|
812
756
|
*
|
|
813
757
|
* @category guards
|
|
@@ -823,22 +767,22 @@ export const isEmpty = <A>(self: Iterable<A>): self is Iterable<never> => {
|
|
|
823
767
|
*
|
|
824
768
|
* **Example** (Counting iterable elements)
|
|
825
769
|
*
|
|
826
|
-
* ```ts
|
|
770
|
+
* ```ts import.meta.vitest
|
|
827
771
|
* import { Iterable } from "effect"
|
|
828
772
|
*
|
|
829
773
|
* const numbers = [1, 2, 3, 4, 5]
|
|
830
|
-
*
|
|
774
|
+
* Iterable.size(numbers) // => 5
|
|
831
775
|
*
|
|
832
776
|
* const empty = Iterable.empty<number>()
|
|
833
|
-
*
|
|
777
|
+
* Iterable.size(empty) // => 0
|
|
834
778
|
*
|
|
835
779
|
* // Works with any iterable
|
|
836
780
|
* const letters = "hello"
|
|
837
|
-
*
|
|
781
|
+
* Iterable.size(letters) // => 5
|
|
838
782
|
*
|
|
839
783
|
* // Note: This consumes the entire iterable
|
|
840
784
|
* const range = Iterable.range(1, 100)
|
|
841
|
-
*
|
|
785
|
+
* Iterable.size(range) // => 100
|
|
842
786
|
* ```
|
|
843
787
|
*
|
|
844
788
|
* @category getters
|
|
@@ -858,24 +802,24 @@ export const size = <A>(self: Iterable<A>): number => {
|
|
|
858
802
|
*
|
|
859
803
|
* **Example** (Getting the first element)
|
|
860
804
|
*
|
|
861
|
-
* ```ts
|
|
805
|
+
* ```ts import.meta.vitest
|
|
862
806
|
* import { Iterable, Option } from "effect"
|
|
863
807
|
*
|
|
864
808
|
* const numbers = [1, 2, 3]
|
|
865
|
-
*
|
|
809
|
+
* Iterable.head(numbers) // => Option.some(1)
|
|
866
810
|
*
|
|
867
811
|
* const empty = Iterable.empty<number>()
|
|
868
|
-
*
|
|
812
|
+
* Iterable.head(empty) // => Option.none()
|
|
869
813
|
*
|
|
870
814
|
* // Safe way to get first element
|
|
871
815
|
* const firstEven = Iterable.head(
|
|
872
816
|
* Iterable.filter([1, 3, 4, 5], (x) => x % 2 === 0)
|
|
873
817
|
* )
|
|
874
|
-
*
|
|
818
|
+
* firstEven // => Option.some(4)
|
|
875
819
|
*
|
|
876
820
|
* // Use with Option methods
|
|
877
821
|
* const doubled = Option.map(Iterable.head([5, 10, 15]), (x) => x * 2)
|
|
878
|
-
*
|
|
822
|
+
* doubled // => Option.some(10)
|
|
879
823
|
* ```
|
|
880
824
|
*
|
|
881
825
|
* @category getters
|
|
@@ -901,21 +845,21 @@ export const head = <A>(self: Iterable<A>): Option<A> => {
|
|
|
901
845
|
*
|
|
902
846
|
* **Example** (Getting the first element unsafely)
|
|
903
847
|
*
|
|
904
|
-
* ```ts
|
|
848
|
+
* ```ts import.meta.vitest
|
|
905
849
|
* import { Iterable } from "effect"
|
|
906
850
|
*
|
|
907
851
|
* const numbers = [1, 2, 3]
|
|
908
|
-
*
|
|
852
|
+
* Iterable.headUnsafe(numbers) // => 1
|
|
909
853
|
*
|
|
910
854
|
* const letters = "hello"
|
|
911
|
-
*
|
|
855
|
+
* Iterable.headUnsafe(letters) // => "h"
|
|
912
856
|
*
|
|
913
857
|
* // Iterable.headUnsafe(Iterable.empty<number>())
|
|
914
858
|
* // throws Error: "headUnsafe: empty iterable"
|
|
915
859
|
*
|
|
916
860
|
* // Use only when you're certain the iterable is non-empty
|
|
917
861
|
* const nonEmpty = Iterable.range(1, 10)
|
|
918
|
-
*
|
|
862
|
+
* Iterable.headUnsafe(nonEmpty) // => 1
|
|
919
863
|
* ```
|
|
920
864
|
*
|
|
921
865
|
* @category getters
|
|
@@ -937,25 +881,25 @@ export const headUnsafe = <A>(self: Iterable<A>): A => {
|
|
|
937
881
|
*
|
|
938
882
|
* **Example** (Taking from the start)
|
|
939
883
|
*
|
|
940
|
-
* ```ts
|
|
884
|
+
* ```ts import.meta.vitest
|
|
941
885
|
* import { Iterable } from "effect"
|
|
942
886
|
*
|
|
943
887
|
* const numbers = [1, 2, 3, 4, 5]
|
|
944
888
|
* const firstThree = Iterable.take(numbers, 3)
|
|
945
|
-
*
|
|
889
|
+
* Array.from(firstThree) // => [1, 2, 3]
|
|
946
890
|
*
|
|
947
891
|
* // Taking more than available returns all elements
|
|
948
892
|
* const firstTen = Iterable.take(numbers, 10)
|
|
949
|
-
*
|
|
893
|
+
* Array.from(firstTen) // => [1, 2, 3, 4, 5]
|
|
950
894
|
*
|
|
951
895
|
* // Taking 0 or negative returns empty
|
|
952
896
|
* const none = Iterable.take(numbers, 0)
|
|
953
|
-
*
|
|
897
|
+
* Array.from(none) // => []
|
|
954
898
|
*
|
|
955
899
|
* // Useful with infinite iterables
|
|
956
900
|
* const naturals = Iterable.range(1)
|
|
957
901
|
* const firstFive = Iterable.take(naturals, 5)
|
|
958
|
-
*
|
|
902
|
+
* Array.from(firstFive) // => [1, 2, 3, 4, 5]
|
|
959
903
|
* ```
|
|
960
904
|
*
|
|
961
905
|
* @category getters
|
|
@@ -971,25 +915,25 @@ export const take: {
|
|
|
971
915
|
*
|
|
972
916
|
* **Example** (Taking from the start)
|
|
973
917
|
*
|
|
974
|
-
* ```ts
|
|
918
|
+
* ```ts import.meta.vitest
|
|
975
919
|
* import { Iterable } from "effect"
|
|
976
920
|
*
|
|
977
921
|
* const numbers = [1, 2, 3, 4, 5]
|
|
978
922
|
* const firstThree = Iterable.take(numbers, 3)
|
|
979
|
-
*
|
|
923
|
+
* Array.from(firstThree) // => [1, 2, 3]
|
|
980
924
|
*
|
|
981
925
|
* // Taking more than available returns all elements
|
|
982
926
|
* const firstTen = Iterable.take(numbers, 10)
|
|
983
|
-
*
|
|
927
|
+
* Array.from(firstTen) // => [1, 2, 3, 4, 5]
|
|
984
928
|
*
|
|
985
929
|
* // Taking 0 or negative returns empty
|
|
986
930
|
* const none = Iterable.take(numbers, 0)
|
|
987
|
-
*
|
|
931
|
+
* Array.from(none) // => []
|
|
988
932
|
*
|
|
989
933
|
* // Useful with infinite iterables
|
|
990
934
|
* const naturals = Iterable.range(1)
|
|
991
935
|
* const firstFive = Iterable.take(naturals, 5)
|
|
992
|
-
*
|
|
936
|
+
* Array.from(firstFive) // => [1, 2, 3, 4, 5]
|
|
993
937
|
* ```
|
|
994
938
|
*
|
|
995
939
|
* @category getters
|
|
@@ -1005,25 +949,25 @@ export const take: {
|
|
|
1005
949
|
*
|
|
1006
950
|
* **Example** (Taking from the start)
|
|
1007
951
|
*
|
|
1008
|
-
* ```ts
|
|
952
|
+
* ```ts import.meta.vitest
|
|
1009
953
|
* import { Iterable } from "effect"
|
|
1010
954
|
*
|
|
1011
955
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1012
956
|
* const firstThree = Iterable.take(numbers, 3)
|
|
1013
|
-
*
|
|
957
|
+
* Array.from(firstThree) // => [1, 2, 3]
|
|
1014
958
|
*
|
|
1015
959
|
* // Taking more than available returns all elements
|
|
1016
960
|
* const firstTen = Iterable.take(numbers, 10)
|
|
1017
|
-
*
|
|
961
|
+
* Array.from(firstTen) // => [1, 2, 3, 4, 5]
|
|
1018
962
|
*
|
|
1019
963
|
* // Taking 0 or negative returns empty
|
|
1020
964
|
* const none = Iterable.take(numbers, 0)
|
|
1021
|
-
*
|
|
965
|
+
* Array.from(none) // => []
|
|
1022
966
|
*
|
|
1023
967
|
* // Useful with infinite iterables
|
|
1024
968
|
* const naturals = Iterable.range(1)
|
|
1025
969
|
* const firstFive = Iterable.take(naturals, 5)
|
|
1026
|
-
*
|
|
970
|
+
* Array.from(firstFive) // => [1, 2, 3, 4, 5]
|
|
1027
971
|
* ```
|
|
1028
972
|
*
|
|
1029
973
|
* @category getters
|
|
@@ -1052,22 +996,22 @@ export const take: {
|
|
|
1052
996
|
*
|
|
1053
997
|
* **Example** (Taking while a predicate holds)
|
|
1054
998
|
*
|
|
1055
|
-
* ```ts
|
|
999
|
+
* ```ts import.meta.vitest
|
|
1056
1000
|
* import { Iterable } from "effect"
|
|
1057
1001
|
*
|
|
1058
1002
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1059
1003
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1060
|
-
*
|
|
1004
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1061
1005
|
*
|
|
1062
1006
|
* // With index
|
|
1063
1007
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1064
1008
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1065
|
-
*
|
|
1009
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1066
1010
|
*
|
|
1067
1011
|
* // Stops at first non-matching element
|
|
1068
1012
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1069
1013
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1070
|
-
*
|
|
1014
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1071
1015
|
*
|
|
1072
1016
|
* // Type refinement
|
|
1073
1017
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1075,7 +1019,7 @@ export const take: {
|
|
|
1075
1019
|
* values,
|
|
1076
1020
|
* (x): x is string => typeof x === "string"
|
|
1077
1021
|
* )
|
|
1078
|
-
*
|
|
1022
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1079
1023
|
* ```
|
|
1080
1024
|
*
|
|
1081
1025
|
* @category getters
|
|
@@ -1088,22 +1032,22 @@ export const takeWhile: {
|
|
|
1088
1032
|
*
|
|
1089
1033
|
* **Example** (Taking while a predicate holds)
|
|
1090
1034
|
*
|
|
1091
|
-
* ```ts
|
|
1035
|
+
* ```ts import.meta.vitest
|
|
1092
1036
|
* import { Iterable } from "effect"
|
|
1093
1037
|
*
|
|
1094
1038
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1095
1039
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1096
|
-
*
|
|
1040
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1097
1041
|
*
|
|
1098
1042
|
* // With index
|
|
1099
1043
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1100
1044
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1101
|
-
*
|
|
1045
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1102
1046
|
*
|
|
1103
1047
|
* // Stops at first non-matching element
|
|
1104
1048
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1105
1049
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1106
|
-
*
|
|
1050
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1107
1051
|
*
|
|
1108
1052
|
* // Type refinement
|
|
1109
1053
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1111,7 +1055,7 @@ export const takeWhile: {
|
|
|
1111
1055
|
* values,
|
|
1112
1056
|
* (x): x is string => typeof x === "string"
|
|
1113
1057
|
* )
|
|
1114
|
-
*
|
|
1058
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1115
1059
|
* ```
|
|
1116
1060
|
*
|
|
1117
1061
|
* @category getters
|
|
@@ -1124,22 +1068,22 @@ export const takeWhile: {
|
|
|
1124
1068
|
*
|
|
1125
1069
|
* **Example** (Taking while a predicate holds)
|
|
1126
1070
|
*
|
|
1127
|
-
* ```ts
|
|
1071
|
+
* ```ts import.meta.vitest
|
|
1128
1072
|
* import { Iterable } from "effect"
|
|
1129
1073
|
*
|
|
1130
1074
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1131
1075
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1132
|
-
*
|
|
1076
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1133
1077
|
*
|
|
1134
1078
|
* // With index
|
|
1135
1079
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1136
1080
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1137
|
-
*
|
|
1081
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1138
1082
|
*
|
|
1139
1083
|
* // Stops at first non-matching element
|
|
1140
1084
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1141
1085
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1142
|
-
*
|
|
1086
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1143
1087
|
*
|
|
1144
1088
|
* // Type refinement
|
|
1145
1089
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1147,7 +1091,7 @@ export const takeWhile: {
|
|
|
1147
1091
|
* values,
|
|
1148
1092
|
* (x): x is string => typeof x === "string"
|
|
1149
1093
|
* )
|
|
1150
|
-
*
|
|
1094
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1151
1095
|
* ```
|
|
1152
1096
|
*
|
|
1153
1097
|
* @category getters
|
|
@@ -1160,22 +1104,22 @@ export const takeWhile: {
|
|
|
1160
1104
|
*
|
|
1161
1105
|
* **Example** (Taking while a predicate holds)
|
|
1162
1106
|
*
|
|
1163
|
-
* ```ts
|
|
1107
|
+
* ```ts import.meta.vitest
|
|
1164
1108
|
* import { Iterable } from "effect"
|
|
1165
1109
|
*
|
|
1166
1110
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1167
1111
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1168
|
-
*
|
|
1112
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1169
1113
|
*
|
|
1170
1114
|
* // With index
|
|
1171
1115
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1172
1116
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1173
|
-
*
|
|
1117
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1174
1118
|
*
|
|
1175
1119
|
* // Stops at first non-matching element
|
|
1176
1120
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1177
1121
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1178
|
-
*
|
|
1122
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1179
1123
|
*
|
|
1180
1124
|
* // Type refinement
|
|
1181
1125
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1183,7 +1127,7 @@ export const takeWhile: {
|
|
|
1183
1127
|
* values,
|
|
1184
1128
|
* (x): x is string => typeof x === "string"
|
|
1185
1129
|
* )
|
|
1186
|
-
*
|
|
1130
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1187
1131
|
* ```
|
|
1188
1132
|
*
|
|
1189
1133
|
* @category getters
|
|
@@ -1196,22 +1140,22 @@ export const takeWhile: {
|
|
|
1196
1140
|
*
|
|
1197
1141
|
* **Example** (Taking while a predicate holds)
|
|
1198
1142
|
*
|
|
1199
|
-
* ```ts
|
|
1143
|
+
* ```ts import.meta.vitest
|
|
1200
1144
|
* import { Iterable } from "effect"
|
|
1201
1145
|
*
|
|
1202
1146
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1203
1147
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1204
|
-
*
|
|
1148
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1205
1149
|
*
|
|
1206
1150
|
* // With index
|
|
1207
1151
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1208
1152
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1209
|
-
*
|
|
1153
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1210
1154
|
*
|
|
1211
1155
|
* // Stops at first non-matching element
|
|
1212
1156
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1213
1157
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1214
|
-
*
|
|
1158
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1215
1159
|
*
|
|
1216
1160
|
* // Type refinement
|
|
1217
1161
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1219,7 +1163,7 @@ export const takeWhile: {
|
|
|
1219
1163
|
* values,
|
|
1220
1164
|
* (x): x is string => typeof x === "string"
|
|
1221
1165
|
* )
|
|
1222
|
-
*
|
|
1166
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1223
1167
|
* ```
|
|
1224
1168
|
*
|
|
1225
1169
|
* @category getters
|
|
@@ -1251,24 +1195,24 @@ export const takeWhile: {
|
|
|
1251
1195
|
*
|
|
1252
1196
|
* **Example** (Dropping from the start)
|
|
1253
1197
|
*
|
|
1254
|
-
* ```ts
|
|
1198
|
+
* ```ts import.meta.vitest
|
|
1255
1199
|
* import { Iterable } from "effect"
|
|
1256
1200
|
*
|
|
1257
1201
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1258
1202
|
* const withoutFirstTwo = Iterable.drop(numbers, 2)
|
|
1259
|
-
*
|
|
1203
|
+
* Array.from(withoutFirstTwo) // => [3, 4, 5]
|
|
1260
1204
|
*
|
|
1261
1205
|
* // Dropping more than available returns empty
|
|
1262
1206
|
* const withoutFirstTen = Iterable.drop(numbers, 10)
|
|
1263
|
-
*
|
|
1207
|
+
* Array.from(withoutFirstTen) // => []
|
|
1264
1208
|
*
|
|
1265
1209
|
* // Dropping 0 or negative returns all elements
|
|
1266
1210
|
* const all = Iterable.drop(numbers, 0)
|
|
1267
|
-
*
|
|
1211
|
+
* Array.from(all) // => [1, 2, 3, 4, 5]
|
|
1268
1212
|
*
|
|
1269
1213
|
* // Combine with take for slicing
|
|
1270
1214
|
* const slice = Iterable.take(Iterable.drop(numbers, 1), 3)
|
|
1271
|
-
*
|
|
1215
|
+
* Array.from(slice) // => [2, 3, 4]
|
|
1272
1216
|
* ```
|
|
1273
1217
|
*
|
|
1274
1218
|
* @category getters
|
|
@@ -1284,24 +1228,24 @@ export const drop: {
|
|
|
1284
1228
|
*
|
|
1285
1229
|
* **Example** (Dropping from the start)
|
|
1286
1230
|
*
|
|
1287
|
-
* ```ts
|
|
1231
|
+
* ```ts import.meta.vitest
|
|
1288
1232
|
* import { Iterable } from "effect"
|
|
1289
1233
|
*
|
|
1290
1234
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1291
1235
|
* const withoutFirstTwo = Iterable.drop(numbers, 2)
|
|
1292
|
-
*
|
|
1236
|
+
* Array.from(withoutFirstTwo) // => [3, 4, 5]
|
|
1293
1237
|
*
|
|
1294
1238
|
* // Dropping more than available returns empty
|
|
1295
1239
|
* const withoutFirstTen = Iterable.drop(numbers, 10)
|
|
1296
|
-
*
|
|
1240
|
+
* Array.from(withoutFirstTen) // => []
|
|
1297
1241
|
*
|
|
1298
1242
|
* // Dropping 0 or negative returns all elements
|
|
1299
1243
|
* const all = Iterable.drop(numbers, 0)
|
|
1300
|
-
*
|
|
1244
|
+
* Array.from(all) // => [1, 2, 3, 4, 5]
|
|
1301
1245
|
*
|
|
1302
1246
|
* // Combine with take for slicing
|
|
1303
1247
|
* const slice = Iterable.take(Iterable.drop(numbers, 1), 3)
|
|
1304
|
-
*
|
|
1248
|
+
* Array.from(slice) // => [2, 3, 4]
|
|
1305
1249
|
* ```
|
|
1306
1250
|
*
|
|
1307
1251
|
* @category getters
|
|
@@ -1317,24 +1261,24 @@ export const drop: {
|
|
|
1317
1261
|
*
|
|
1318
1262
|
* **Example** (Dropping from the start)
|
|
1319
1263
|
*
|
|
1320
|
-
* ```ts
|
|
1264
|
+
* ```ts import.meta.vitest
|
|
1321
1265
|
* import { Iterable } from "effect"
|
|
1322
1266
|
*
|
|
1323
1267
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1324
1268
|
* const withoutFirstTwo = Iterable.drop(numbers, 2)
|
|
1325
|
-
*
|
|
1269
|
+
* Array.from(withoutFirstTwo) // => [3, 4, 5]
|
|
1326
1270
|
*
|
|
1327
1271
|
* // Dropping more than available returns empty
|
|
1328
1272
|
* const withoutFirstTen = Iterable.drop(numbers, 10)
|
|
1329
|
-
*
|
|
1273
|
+
* Array.from(withoutFirstTen) // => []
|
|
1330
1274
|
*
|
|
1331
1275
|
* // Dropping 0 or negative returns all elements
|
|
1332
1276
|
* const all = Iterable.drop(numbers, 0)
|
|
1333
|
-
*
|
|
1277
|
+
* Array.from(all) // => [1, 2, 3, 4, 5]
|
|
1334
1278
|
*
|
|
1335
1279
|
* // Combine with take for slicing
|
|
1336
1280
|
* const slice = Iterable.take(Iterable.drop(numbers, 1), 3)
|
|
1337
|
-
*
|
|
1281
|
+
* Array.from(slice) // => [2, 3, 4]
|
|
1338
1282
|
* ```
|
|
1339
1283
|
*
|
|
1340
1284
|
* @category getters
|
|
@@ -1366,20 +1310,20 @@ export const drop: {
|
|
|
1366
1310
|
*
|
|
1367
1311
|
* **Example** (Finding the first match)
|
|
1368
1312
|
*
|
|
1369
|
-
* ```ts
|
|
1313
|
+
* ```ts import.meta.vitest
|
|
1370
1314
|
* import { Iterable, Option } from "effect"
|
|
1371
1315
|
*
|
|
1372
1316
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1373
1317
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1374
|
-
*
|
|
1318
|
+
* firstEven // => Option.some(4)
|
|
1375
1319
|
*
|
|
1376
1320
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1377
|
-
*
|
|
1321
|
+
* firstGreaterThan10 // => Option.none()
|
|
1378
1322
|
*
|
|
1379
1323
|
* // With index
|
|
1380
1324
|
* const letters = ["a", "b", "c", "d"]
|
|
1381
1325
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1382
|
-
*
|
|
1326
|
+
* atEvenIndex // => Option.some("a")
|
|
1383
1327
|
*
|
|
1384
1328
|
* // Type refinement
|
|
1385
1329
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1387,17 +1331,17 @@ export const drop: {
|
|
|
1387
1331
|
* mixed,
|
|
1388
1332
|
* (x): x is string => typeof x === "string"
|
|
1389
1333
|
* )
|
|
1390
|
-
*
|
|
1334
|
+
* firstString // => Option.some("hello")
|
|
1391
1335
|
*
|
|
1392
1336
|
* // Transform during search
|
|
1393
1337
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1394
1338
|
* const sqrt = Math.sqrt(x)
|
|
1395
1339
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1396
1340
|
* })
|
|
1397
|
-
*
|
|
1341
|
+
* findSquareRoot // => Option.some(1)
|
|
1398
1342
|
* ```
|
|
1399
1343
|
*
|
|
1400
|
-
* @category
|
|
1344
|
+
* @category searching
|
|
1401
1345
|
* @since 2.0.0
|
|
1402
1346
|
*/
|
|
1403
1347
|
export const findFirst: {
|
|
@@ -1407,20 +1351,20 @@ export const findFirst: {
|
|
|
1407
1351
|
*
|
|
1408
1352
|
* **Example** (Finding the first match)
|
|
1409
1353
|
*
|
|
1410
|
-
* ```ts
|
|
1354
|
+
* ```ts import.meta.vitest
|
|
1411
1355
|
* import { Iterable, Option } from "effect"
|
|
1412
1356
|
*
|
|
1413
1357
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1414
1358
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1415
|
-
*
|
|
1359
|
+
* firstEven // => Option.some(4)
|
|
1416
1360
|
*
|
|
1417
1361
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1418
|
-
*
|
|
1362
|
+
* firstGreaterThan10 // => Option.none()
|
|
1419
1363
|
*
|
|
1420
1364
|
* // With index
|
|
1421
1365
|
* const letters = ["a", "b", "c", "d"]
|
|
1422
1366
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1423
|
-
*
|
|
1367
|
+
* atEvenIndex // => Option.some("a")
|
|
1424
1368
|
*
|
|
1425
1369
|
* // Type refinement
|
|
1426
1370
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1428,17 +1372,17 @@ export const findFirst: {
|
|
|
1428
1372
|
* mixed,
|
|
1429
1373
|
* (x): x is string => typeof x === "string"
|
|
1430
1374
|
* )
|
|
1431
|
-
*
|
|
1375
|
+
* firstString // => Option.some("hello")
|
|
1432
1376
|
*
|
|
1433
1377
|
* // Transform during search
|
|
1434
1378
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1435
1379
|
* const sqrt = Math.sqrt(x)
|
|
1436
1380
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1437
1381
|
* })
|
|
1438
|
-
*
|
|
1382
|
+
* findSquareRoot // => Option.some(1)
|
|
1439
1383
|
* ```
|
|
1440
1384
|
*
|
|
1441
|
-
* @category
|
|
1385
|
+
* @category searching
|
|
1442
1386
|
* @since 2.0.0
|
|
1443
1387
|
*/
|
|
1444
1388
|
<A, B>(f: (a: NoInfer<A>, i: number) => Option<B>): (self: Iterable<A>) => Option<B>
|
|
@@ -1448,20 +1392,20 @@ export const findFirst: {
|
|
|
1448
1392
|
*
|
|
1449
1393
|
* **Example** (Finding the first match)
|
|
1450
1394
|
*
|
|
1451
|
-
* ```ts
|
|
1395
|
+
* ```ts import.meta.vitest
|
|
1452
1396
|
* import { Iterable, Option } from "effect"
|
|
1453
1397
|
*
|
|
1454
1398
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1455
1399
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1456
|
-
*
|
|
1400
|
+
* firstEven // => Option.some(4)
|
|
1457
1401
|
*
|
|
1458
1402
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1459
|
-
*
|
|
1403
|
+
* firstGreaterThan10 // => Option.none()
|
|
1460
1404
|
*
|
|
1461
1405
|
* // With index
|
|
1462
1406
|
* const letters = ["a", "b", "c", "d"]
|
|
1463
1407
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1464
|
-
*
|
|
1408
|
+
* atEvenIndex // => Option.some("a")
|
|
1465
1409
|
*
|
|
1466
1410
|
* // Type refinement
|
|
1467
1411
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1469,17 +1413,17 @@ export const findFirst: {
|
|
|
1469
1413
|
* mixed,
|
|
1470
1414
|
* (x): x is string => typeof x === "string"
|
|
1471
1415
|
* )
|
|
1472
|
-
*
|
|
1416
|
+
* firstString // => Option.some("hello")
|
|
1473
1417
|
*
|
|
1474
1418
|
* // Transform during search
|
|
1475
1419
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1476
1420
|
* const sqrt = Math.sqrt(x)
|
|
1477
1421
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1478
1422
|
* })
|
|
1479
|
-
*
|
|
1423
|
+
* findSquareRoot // => Option.some(1)
|
|
1480
1424
|
* ```
|
|
1481
1425
|
*
|
|
1482
|
-
* @category
|
|
1426
|
+
* @category searching
|
|
1483
1427
|
* @since 2.0.0
|
|
1484
1428
|
*/
|
|
1485
1429
|
<A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option<B>
|
|
@@ -1489,20 +1433,20 @@ export const findFirst: {
|
|
|
1489
1433
|
*
|
|
1490
1434
|
* **Example** (Finding the first match)
|
|
1491
1435
|
*
|
|
1492
|
-
* ```ts
|
|
1436
|
+
* ```ts import.meta.vitest
|
|
1493
1437
|
* import { Iterable, Option } from "effect"
|
|
1494
1438
|
*
|
|
1495
1439
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1496
1440
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1497
|
-
*
|
|
1441
|
+
* firstEven // => Option.some(4)
|
|
1498
1442
|
*
|
|
1499
1443
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1500
|
-
*
|
|
1444
|
+
* firstGreaterThan10 // => Option.none()
|
|
1501
1445
|
*
|
|
1502
1446
|
* // With index
|
|
1503
1447
|
* const letters = ["a", "b", "c", "d"]
|
|
1504
1448
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1505
|
-
*
|
|
1449
|
+
* atEvenIndex // => Option.some("a")
|
|
1506
1450
|
*
|
|
1507
1451
|
* // Type refinement
|
|
1508
1452
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1510,17 +1454,17 @@ export const findFirst: {
|
|
|
1510
1454
|
* mixed,
|
|
1511
1455
|
* (x): x is string => typeof x === "string"
|
|
1512
1456
|
* )
|
|
1513
|
-
*
|
|
1457
|
+
* firstString // => Option.some("hello")
|
|
1514
1458
|
*
|
|
1515
1459
|
* // Transform during search
|
|
1516
1460
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1517
1461
|
* const sqrt = Math.sqrt(x)
|
|
1518
1462
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1519
1463
|
* })
|
|
1520
|
-
*
|
|
1464
|
+
* findSquareRoot // => Option.some(1)
|
|
1521
1465
|
* ```
|
|
1522
1466
|
*
|
|
1523
|
-
* @category
|
|
1467
|
+
* @category searching
|
|
1524
1468
|
* @since 2.0.0
|
|
1525
1469
|
*/
|
|
1526
1470
|
<A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<A>
|
|
@@ -1530,20 +1474,20 @@ export const findFirst: {
|
|
|
1530
1474
|
*
|
|
1531
1475
|
* **Example** (Finding the first match)
|
|
1532
1476
|
*
|
|
1533
|
-
* ```ts
|
|
1477
|
+
* ```ts import.meta.vitest
|
|
1534
1478
|
* import { Iterable, Option } from "effect"
|
|
1535
1479
|
*
|
|
1536
1480
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1537
1481
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1538
|
-
*
|
|
1482
|
+
* firstEven // => Option.some(4)
|
|
1539
1483
|
*
|
|
1540
1484
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1541
|
-
*
|
|
1485
|
+
* firstGreaterThan10 // => Option.none()
|
|
1542
1486
|
*
|
|
1543
1487
|
* // With index
|
|
1544
1488
|
* const letters = ["a", "b", "c", "d"]
|
|
1545
1489
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1546
|
-
*
|
|
1490
|
+
* atEvenIndex // => Option.some("a")
|
|
1547
1491
|
*
|
|
1548
1492
|
* // Type refinement
|
|
1549
1493
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1551,17 +1495,17 @@ export const findFirst: {
|
|
|
1551
1495
|
* mixed,
|
|
1552
1496
|
* (x): x is string => typeof x === "string"
|
|
1553
1497
|
* )
|
|
1554
|
-
*
|
|
1498
|
+
* firstString // => Option.some("hello")
|
|
1555
1499
|
*
|
|
1556
1500
|
* // Transform during search
|
|
1557
1501
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1558
1502
|
* const sqrt = Math.sqrt(x)
|
|
1559
1503
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1560
1504
|
* })
|
|
1561
|
-
*
|
|
1505
|
+
* findSquareRoot // => Option.some(1)
|
|
1562
1506
|
* ```
|
|
1563
1507
|
*
|
|
1564
|
-
* @category
|
|
1508
|
+
* @category searching
|
|
1565
1509
|
* @since 2.0.0
|
|
1566
1510
|
*/
|
|
1567
1511
|
<A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Option<B>
|
|
@@ -1571,20 +1515,20 @@ export const findFirst: {
|
|
|
1571
1515
|
*
|
|
1572
1516
|
* **Example** (Finding the first match)
|
|
1573
1517
|
*
|
|
1574
|
-
* ```ts
|
|
1518
|
+
* ```ts import.meta.vitest
|
|
1575
1519
|
* import { Iterable, Option } from "effect"
|
|
1576
1520
|
*
|
|
1577
1521
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1578
1522
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1579
|
-
*
|
|
1523
|
+
* firstEven // => Option.some(4)
|
|
1580
1524
|
*
|
|
1581
1525
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1582
|
-
*
|
|
1526
|
+
* firstGreaterThan10 // => Option.none()
|
|
1583
1527
|
*
|
|
1584
1528
|
* // With index
|
|
1585
1529
|
* const letters = ["a", "b", "c", "d"]
|
|
1586
1530
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1587
|
-
*
|
|
1531
|
+
* atEvenIndex // => Option.some("a")
|
|
1588
1532
|
*
|
|
1589
1533
|
* // Type refinement
|
|
1590
1534
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1592,17 +1536,17 @@ export const findFirst: {
|
|
|
1592
1536
|
* mixed,
|
|
1593
1537
|
* (x): x is string => typeof x === "string"
|
|
1594
1538
|
* )
|
|
1595
|
-
*
|
|
1539
|
+
* firstString // => Option.some("hello")
|
|
1596
1540
|
*
|
|
1597
1541
|
* // Transform during search
|
|
1598
1542
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1599
1543
|
* const sqrt = Math.sqrt(x)
|
|
1600
1544
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1601
1545
|
* })
|
|
1602
|
-
*
|
|
1546
|
+
* findSquareRoot // => Option.some(1)
|
|
1603
1547
|
* ```
|
|
1604
1548
|
*
|
|
1605
|
-
* @category
|
|
1549
|
+
* @category searching
|
|
1606
1550
|
* @since 2.0.0
|
|
1607
1551
|
*/
|
|
1608
1552
|
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option<B>
|
|
@@ -1612,20 +1556,20 @@ export const findFirst: {
|
|
|
1612
1556
|
*
|
|
1613
1557
|
* **Example** (Finding the first match)
|
|
1614
1558
|
*
|
|
1615
|
-
* ```ts
|
|
1559
|
+
* ```ts import.meta.vitest
|
|
1616
1560
|
* import { Iterable, Option } from "effect"
|
|
1617
1561
|
*
|
|
1618
1562
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1619
1563
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1620
|
-
*
|
|
1564
|
+
* firstEven // => Option.some(4)
|
|
1621
1565
|
*
|
|
1622
1566
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1623
|
-
*
|
|
1567
|
+
* firstGreaterThan10 // => Option.none()
|
|
1624
1568
|
*
|
|
1625
1569
|
* // With index
|
|
1626
1570
|
* const letters = ["a", "b", "c", "d"]
|
|
1627
1571
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1628
|
-
*
|
|
1572
|
+
* atEvenIndex // => Option.some("a")
|
|
1629
1573
|
*
|
|
1630
1574
|
* // Type refinement
|
|
1631
1575
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1633,17 +1577,17 @@ export const findFirst: {
|
|
|
1633
1577
|
* mixed,
|
|
1634
1578
|
* (x): x is string => typeof x === "string"
|
|
1635
1579
|
* )
|
|
1636
|
-
*
|
|
1580
|
+
* firstString // => Option.some("hello")
|
|
1637
1581
|
*
|
|
1638
1582
|
* // Transform during search
|
|
1639
1583
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1640
1584
|
* const sqrt = Math.sqrt(x)
|
|
1641
1585
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1642
1586
|
* })
|
|
1643
|
-
*
|
|
1587
|
+
* findSquareRoot // => Option.some(1)
|
|
1644
1588
|
* ```
|
|
1645
1589
|
*
|
|
1646
|
-
* @category
|
|
1590
|
+
* @category searching
|
|
1647
1591
|
* @since 2.0.0
|
|
1648
1592
|
*/
|
|
1649
1593
|
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<A>
|
|
@@ -1673,20 +1617,20 @@ export const findFirst: {
|
|
|
1673
1617
|
*
|
|
1674
1618
|
* **Example** (Finding the last match)
|
|
1675
1619
|
*
|
|
1676
|
-
* ```ts
|
|
1677
|
-
* import { Iterable } from "effect"
|
|
1620
|
+
* ```ts import.meta.vitest
|
|
1621
|
+
* import { Iterable, Option } from "effect"
|
|
1678
1622
|
*
|
|
1679
1623
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1680
1624
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1681
|
-
*
|
|
1625
|
+
* lastEven // => Option.some(2)
|
|
1682
1626
|
*
|
|
1683
1627
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1684
|
-
*
|
|
1628
|
+
* lastGreaterThan10 // => Option.none()
|
|
1685
1629
|
*
|
|
1686
1630
|
* // With index
|
|
1687
1631
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1688
1632
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1689
|
-
*
|
|
1633
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1690
1634
|
*
|
|
1691
1635
|
* // Type refinement
|
|
1692
1636
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1694,10 +1638,10 @@ export const findFirst: {
|
|
|
1694
1638
|
* mixed,
|
|
1695
1639
|
* (x): x is string => typeof x === "string"
|
|
1696
1640
|
* )
|
|
1697
|
-
*
|
|
1641
|
+
* lastString // => Option.some("world")
|
|
1698
1642
|
* ```
|
|
1699
1643
|
*
|
|
1700
|
-
* @category
|
|
1644
|
+
* @category searching
|
|
1701
1645
|
* @since 2.0.0
|
|
1702
1646
|
*/
|
|
1703
1647
|
export const findLast: {
|
|
@@ -1706,20 +1650,20 @@ export const findLast: {
|
|
|
1706
1650
|
*
|
|
1707
1651
|
* **Example** (Finding the last match)
|
|
1708
1652
|
*
|
|
1709
|
-
* ```ts
|
|
1710
|
-
* import { Iterable } from "effect"
|
|
1653
|
+
* ```ts import.meta.vitest
|
|
1654
|
+
* import { Iterable, Option } from "effect"
|
|
1711
1655
|
*
|
|
1712
1656
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1713
1657
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1714
|
-
*
|
|
1658
|
+
* lastEven // => Option.some(2)
|
|
1715
1659
|
*
|
|
1716
1660
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1717
|
-
*
|
|
1661
|
+
* lastGreaterThan10 // => Option.none()
|
|
1718
1662
|
*
|
|
1719
1663
|
* // With index
|
|
1720
1664
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1721
1665
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1722
|
-
*
|
|
1666
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1723
1667
|
*
|
|
1724
1668
|
* // Type refinement
|
|
1725
1669
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1727,10 +1671,10 @@ export const findLast: {
|
|
|
1727
1671
|
* mixed,
|
|
1728
1672
|
* (x): x is string => typeof x === "string"
|
|
1729
1673
|
* )
|
|
1730
|
-
*
|
|
1674
|
+
* lastString // => Option.some("world")
|
|
1731
1675
|
* ```
|
|
1732
1676
|
*
|
|
1733
|
-
* @category
|
|
1677
|
+
* @category searching
|
|
1734
1678
|
* @since 2.0.0
|
|
1735
1679
|
*/
|
|
1736
1680
|
<A, B>(f: (a: NoInfer<A>, i: number) => Option<B>): (self: Iterable<A>) => Option<B>
|
|
@@ -1739,20 +1683,20 @@ export const findLast: {
|
|
|
1739
1683
|
*
|
|
1740
1684
|
* **Example** (Finding the last match)
|
|
1741
1685
|
*
|
|
1742
|
-
* ```ts
|
|
1743
|
-
* import { Iterable } from "effect"
|
|
1686
|
+
* ```ts import.meta.vitest
|
|
1687
|
+
* import { Iterable, Option } from "effect"
|
|
1744
1688
|
*
|
|
1745
1689
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1746
1690
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1747
|
-
*
|
|
1691
|
+
* lastEven // => Option.some(2)
|
|
1748
1692
|
*
|
|
1749
1693
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1750
|
-
*
|
|
1694
|
+
* lastGreaterThan10 // => Option.none()
|
|
1751
1695
|
*
|
|
1752
1696
|
* // With index
|
|
1753
1697
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1754
1698
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1755
|
-
*
|
|
1699
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1756
1700
|
*
|
|
1757
1701
|
* // Type refinement
|
|
1758
1702
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1760,10 +1704,10 @@ export const findLast: {
|
|
|
1760
1704
|
* mixed,
|
|
1761
1705
|
* (x): x is string => typeof x === "string"
|
|
1762
1706
|
* )
|
|
1763
|
-
*
|
|
1707
|
+
* lastString // => Option.some("world")
|
|
1764
1708
|
* ```
|
|
1765
1709
|
*
|
|
1766
|
-
* @category
|
|
1710
|
+
* @category searching
|
|
1767
1711
|
* @since 2.0.0
|
|
1768
1712
|
*/
|
|
1769
1713
|
<A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option<B>
|
|
@@ -1772,20 +1716,20 @@ export const findLast: {
|
|
|
1772
1716
|
*
|
|
1773
1717
|
* **Example** (Finding the last match)
|
|
1774
1718
|
*
|
|
1775
|
-
* ```ts
|
|
1776
|
-
* import { Iterable } from "effect"
|
|
1719
|
+
* ```ts import.meta.vitest
|
|
1720
|
+
* import { Iterable, Option } from "effect"
|
|
1777
1721
|
*
|
|
1778
1722
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1779
1723
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1780
|
-
*
|
|
1724
|
+
* lastEven // => Option.some(2)
|
|
1781
1725
|
*
|
|
1782
1726
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1783
|
-
*
|
|
1727
|
+
* lastGreaterThan10 // => Option.none()
|
|
1784
1728
|
*
|
|
1785
1729
|
* // With index
|
|
1786
1730
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1787
1731
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1788
|
-
*
|
|
1732
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1789
1733
|
*
|
|
1790
1734
|
* // Type refinement
|
|
1791
1735
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1793,10 +1737,10 @@ export const findLast: {
|
|
|
1793
1737
|
* mixed,
|
|
1794
1738
|
* (x): x is string => typeof x === "string"
|
|
1795
1739
|
* )
|
|
1796
|
-
*
|
|
1740
|
+
* lastString // => Option.some("world")
|
|
1797
1741
|
* ```
|
|
1798
1742
|
*
|
|
1799
|
-
* @category
|
|
1743
|
+
* @category searching
|
|
1800
1744
|
* @since 2.0.0
|
|
1801
1745
|
*/
|
|
1802
1746
|
<A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<A>
|
|
@@ -1805,20 +1749,20 @@ export const findLast: {
|
|
|
1805
1749
|
*
|
|
1806
1750
|
* **Example** (Finding the last match)
|
|
1807
1751
|
*
|
|
1808
|
-
* ```ts
|
|
1809
|
-
* import { Iterable } from "effect"
|
|
1752
|
+
* ```ts import.meta.vitest
|
|
1753
|
+
* import { Iterable, Option } from "effect"
|
|
1810
1754
|
*
|
|
1811
1755
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1812
1756
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1813
|
-
*
|
|
1757
|
+
* lastEven // => Option.some(2)
|
|
1814
1758
|
*
|
|
1815
1759
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1816
|
-
*
|
|
1760
|
+
* lastGreaterThan10 // => Option.none()
|
|
1817
1761
|
*
|
|
1818
1762
|
* // With index
|
|
1819
1763
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1820
1764
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1821
|
-
*
|
|
1765
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1822
1766
|
*
|
|
1823
1767
|
* // Type refinement
|
|
1824
1768
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1826,10 +1770,10 @@ export const findLast: {
|
|
|
1826
1770
|
* mixed,
|
|
1827
1771
|
* (x): x is string => typeof x === "string"
|
|
1828
1772
|
* )
|
|
1829
|
-
*
|
|
1773
|
+
* lastString // => Option.some("world")
|
|
1830
1774
|
* ```
|
|
1831
1775
|
*
|
|
1832
|
-
* @category
|
|
1776
|
+
* @category searching
|
|
1833
1777
|
* @since 2.0.0
|
|
1834
1778
|
*/
|
|
1835
1779
|
<A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Option<B>
|
|
@@ -1838,20 +1782,20 @@ export const findLast: {
|
|
|
1838
1782
|
*
|
|
1839
1783
|
* **Example** (Finding the last match)
|
|
1840
1784
|
*
|
|
1841
|
-
* ```ts
|
|
1842
|
-
* import { Iterable } from "effect"
|
|
1785
|
+
* ```ts import.meta.vitest
|
|
1786
|
+
* import { Iterable, Option } from "effect"
|
|
1843
1787
|
*
|
|
1844
1788
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1845
1789
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1846
|
-
*
|
|
1790
|
+
* lastEven // => Option.some(2)
|
|
1847
1791
|
*
|
|
1848
1792
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1849
|
-
*
|
|
1793
|
+
* lastGreaterThan10 // => Option.none()
|
|
1850
1794
|
*
|
|
1851
1795
|
* // With index
|
|
1852
1796
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1853
1797
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1854
|
-
*
|
|
1798
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1855
1799
|
*
|
|
1856
1800
|
* // Type refinement
|
|
1857
1801
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1859,10 +1803,10 @@ export const findLast: {
|
|
|
1859
1803
|
* mixed,
|
|
1860
1804
|
* (x): x is string => typeof x === "string"
|
|
1861
1805
|
* )
|
|
1862
|
-
*
|
|
1806
|
+
* lastString // => Option.some("world")
|
|
1863
1807
|
* ```
|
|
1864
1808
|
*
|
|
1865
|
-
* @category
|
|
1809
|
+
* @category searching
|
|
1866
1810
|
* @since 2.0.0
|
|
1867
1811
|
*/
|
|
1868
1812
|
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option<B>
|
|
@@ -1871,20 +1815,20 @@ export const findLast: {
|
|
|
1871
1815
|
*
|
|
1872
1816
|
* **Example** (Finding the last match)
|
|
1873
1817
|
*
|
|
1874
|
-
* ```ts
|
|
1875
|
-
* import { Iterable } from "effect"
|
|
1818
|
+
* ```ts import.meta.vitest
|
|
1819
|
+
* import { Iterable, Option } from "effect"
|
|
1876
1820
|
*
|
|
1877
1821
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1878
1822
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1879
|
-
*
|
|
1823
|
+
* lastEven // => Option.some(2)
|
|
1880
1824
|
*
|
|
1881
1825
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1882
|
-
*
|
|
1826
|
+
* lastGreaterThan10 // => Option.none()
|
|
1883
1827
|
*
|
|
1884
1828
|
* // With index
|
|
1885
1829
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1886
1830
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1887
|
-
*
|
|
1831
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1888
1832
|
*
|
|
1889
1833
|
* // Type refinement
|
|
1890
1834
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1892,10 +1836,10 @@ export const findLast: {
|
|
|
1892
1836
|
* mixed,
|
|
1893
1837
|
* (x): x is string => typeof x === "string"
|
|
1894
1838
|
* )
|
|
1895
|
-
*
|
|
1839
|
+
* lastString // => Option.some("world")
|
|
1896
1840
|
* ```
|
|
1897
1841
|
*
|
|
1898
|
-
* @category
|
|
1842
|
+
* @category searching
|
|
1899
1843
|
* @since 2.0.0
|
|
1900
1844
|
*/
|
|
1901
1845
|
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<A>
|
|
@@ -1926,31 +1870,31 @@ export const findLast: {
|
|
|
1926
1870
|
*
|
|
1927
1871
|
* **Example** (Zipping iterables)
|
|
1928
1872
|
*
|
|
1929
|
-
* ```ts
|
|
1873
|
+
* ```ts import.meta.vitest
|
|
1930
1874
|
* import { Iterable } from "effect"
|
|
1931
1875
|
*
|
|
1932
1876
|
* const numbers = [1, 2, 3]
|
|
1933
1877
|
* const letters = ["a", "b", "c"]
|
|
1934
1878
|
* const zipped = Iterable.zip(numbers, letters)
|
|
1935
|
-
*
|
|
1879
|
+
* Array.from(zipped) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1936
1880
|
*
|
|
1937
1881
|
* // Different lengths - shorter one determines result length
|
|
1938
1882
|
* const short = [1, 2]
|
|
1939
1883
|
* const long = ["a", "b", "c", "d"]
|
|
1940
1884
|
* const partial = Iterable.zip(short, long)
|
|
1941
|
-
*
|
|
1885
|
+
* Array.from(partial) // => [[1, "a"], [2, "b"]]
|
|
1942
1886
|
*
|
|
1943
1887
|
* // Works with any iterables
|
|
1944
1888
|
* const range = Iterable.range(1, 3)
|
|
1945
1889
|
* const word = "abc"
|
|
1946
1890
|
* const mixed = Iterable.zip(range, word)
|
|
1947
|
-
*
|
|
1891
|
+
* Array.from(mixed) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1948
1892
|
*
|
|
1949
1893
|
* // Create indexed pairs
|
|
1950
1894
|
* const values = ["apple", "banana", "cherry"]
|
|
1951
1895
|
* const indices = Iterable.range(0, 2)
|
|
1952
1896
|
* const indexed = Iterable.zip(indices, values)
|
|
1953
|
-
*
|
|
1897
|
+
* Array.from(indexed) // => [[0, "apple"], [1, "banana"], [2, "cherry"]]
|
|
1954
1898
|
* ```
|
|
1955
1899
|
*
|
|
1956
1900
|
* @category zipping
|
|
@@ -1962,31 +1906,31 @@ export const zip: {
|
|
|
1962
1906
|
*
|
|
1963
1907
|
* **Example** (Zipping iterables)
|
|
1964
1908
|
*
|
|
1965
|
-
* ```ts
|
|
1909
|
+
* ```ts import.meta.vitest
|
|
1966
1910
|
* import { Iterable } from "effect"
|
|
1967
1911
|
*
|
|
1968
1912
|
* const numbers = [1, 2, 3]
|
|
1969
1913
|
* const letters = ["a", "b", "c"]
|
|
1970
1914
|
* const zipped = Iterable.zip(numbers, letters)
|
|
1971
|
-
*
|
|
1915
|
+
* Array.from(zipped) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1972
1916
|
*
|
|
1973
1917
|
* // Different lengths - shorter one determines result length
|
|
1974
1918
|
* const short = [1, 2]
|
|
1975
1919
|
* const long = ["a", "b", "c", "d"]
|
|
1976
1920
|
* const partial = Iterable.zip(short, long)
|
|
1977
|
-
*
|
|
1921
|
+
* Array.from(partial) // => [[1, "a"], [2, "b"]]
|
|
1978
1922
|
*
|
|
1979
1923
|
* // Works with any iterables
|
|
1980
1924
|
* const range = Iterable.range(1, 3)
|
|
1981
1925
|
* const word = "abc"
|
|
1982
1926
|
* const mixed = Iterable.zip(range, word)
|
|
1983
|
-
*
|
|
1927
|
+
* Array.from(mixed) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1984
1928
|
*
|
|
1985
1929
|
* // Create indexed pairs
|
|
1986
1930
|
* const values = ["apple", "banana", "cherry"]
|
|
1987
1931
|
* const indices = Iterable.range(0, 2)
|
|
1988
1932
|
* const indexed = Iterable.zip(indices, values)
|
|
1989
|
-
*
|
|
1933
|
+
* Array.from(indexed) // => [[0, "apple"], [1, "banana"], [2, "cherry"]]
|
|
1990
1934
|
* ```
|
|
1991
1935
|
*
|
|
1992
1936
|
* @category zipping
|
|
@@ -1998,31 +1942,31 @@ export const zip: {
|
|
|
1998
1942
|
*
|
|
1999
1943
|
* **Example** (Zipping iterables)
|
|
2000
1944
|
*
|
|
2001
|
-
* ```ts
|
|
1945
|
+
* ```ts import.meta.vitest
|
|
2002
1946
|
* import { Iterable } from "effect"
|
|
2003
1947
|
*
|
|
2004
1948
|
* const numbers = [1, 2, 3]
|
|
2005
1949
|
* const letters = ["a", "b", "c"]
|
|
2006
1950
|
* const zipped = Iterable.zip(numbers, letters)
|
|
2007
|
-
*
|
|
1951
|
+
* Array.from(zipped) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
2008
1952
|
*
|
|
2009
1953
|
* // Different lengths - shorter one determines result length
|
|
2010
1954
|
* const short = [1, 2]
|
|
2011
1955
|
* const long = ["a", "b", "c", "d"]
|
|
2012
1956
|
* const partial = Iterable.zip(short, long)
|
|
2013
|
-
*
|
|
1957
|
+
* Array.from(partial) // => [[1, "a"], [2, "b"]]
|
|
2014
1958
|
*
|
|
2015
1959
|
* // Works with any iterables
|
|
2016
1960
|
* const range = Iterable.range(1, 3)
|
|
2017
1961
|
* const word = "abc"
|
|
2018
1962
|
* const mixed = Iterable.zip(range, word)
|
|
2019
|
-
*
|
|
1963
|
+
* Array.from(mixed) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
2020
1964
|
*
|
|
2021
1965
|
* // Create indexed pairs
|
|
2022
1966
|
* const values = ["apple", "banana", "cherry"]
|
|
2023
1967
|
* const indices = Iterable.range(0, 2)
|
|
2024
1968
|
* const indexed = Iterable.zip(indices, values)
|
|
2025
|
-
*
|
|
1969
|
+
* Array.from(indexed) // => [[0, "apple"], [1, "banana"], [2, "cherry"]]
|
|
2026
1970
|
* ```
|
|
2027
1971
|
*
|
|
2028
1972
|
* @category zipping
|
|
@@ -2040,14 +1984,14 @@ export const zip: {
|
|
|
2040
1984
|
*
|
|
2041
1985
|
* **Example** (Zipping with a combining function)
|
|
2042
1986
|
*
|
|
2043
|
-
* ```ts
|
|
1987
|
+
* ```ts import.meta.vitest
|
|
2044
1988
|
* import { Iterable } from "effect"
|
|
2045
1989
|
*
|
|
2046
1990
|
* // Add corresponding elements
|
|
2047
1991
|
* const a = [1, 2, 3, 4]
|
|
2048
1992
|
* const b = [10, 20, 30, 40]
|
|
2049
1993
|
* const sums = Iterable.zipWith(a, b, (x, y) => x + y)
|
|
2050
|
-
*
|
|
1994
|
+
* Array.from(sums) // => [11, 22, 33, 44]
|
|
2051
1995
|
*
|
|
2052
1996
|
* // Combine strings
|
|
2053
1997
|
* const firstNames = ["John", "Jane", "Bob"]
|
|
@@ -2057,7 +2001,7 @@ export const zip: {
|
|
|
2057
2001
|
* lastNames,
|
|
2058
2002
|
* (first, last) => `${first} ${last}`
|
|
2059
2003
|
* )
|
|
2060
|
-
*
|
|
2004
|
+
* Array.from(fullNames) // => ["John Doe", "Jane Smith", "Bob Johnson"]
|
|
2061
2005
|
*
|
|
2062
2006
|
* // Different lengths - stops at shorter
|
|
2063
2007
|
* const short = [1, 2]
|
|
@@ -2067,7 +2011,7 @@ export const zip: {
|
|
|
2067
2011
|
* long,
|
|
2068
2012
|
* (num, letter) => `${num}${letter}`
|
|
2069
2013
|
* )
|
|
2070
|
-
*
|
|
2014
|
+
* Array.from(combined) // => ["1a", "2b"]
|
|
2071
2015
|
*
|
|
2072
2016
|
* // Complex transformations
|
|
2073
2017
|
* const prices = [10.99, 25.50, 5.00]
|
|
@@ -2075,7 +2019,7 @@ export const zip: {
|
|
|
2075
2019
|
* const totals = Iterable.zipWith(prices, quantities, (price, qty) => {
|
|
2076
2020
|
* return Math.round(price * qty * 100) / 100 // round to 2 decimal places
|
|
2077
2021
|
* })
|
|
2078
|
-
*
|
|
2022
|
+
* Array.from(totals) // => [21.98, 25.5, 15]
|
|
2079
2023
|
* ```
|
|
2080
2024
|
*
|
|
2081
2025
|
* @category zipping
|
|
@@ -2088,14 +2032,14 @@ export const zipWith: {
|
|
|
2088
2032
|
*
|
|
2089
2033
|
* **Example** (Zipping with a combining function)
|
|
2090
2034
|
*
|
|
2091
|
-
* ```ts
|
|
2035
|
+
* ```ts import.meta.vitest
|
|
2092
2036
|
* import { Iterable } from "effect"
|
|
2093
2037
|
*
|
|
2094
2038
|
* // Add corresponding elements
|
|
2095
2039
|
* const a = [1, 2, 3, 4]
|
|
2096
2040
|
* const b = [10, 20, 30, 40]
|
|
2097
2041
|
* const sums = Iterable.zipWith(a, b, (x, y) => x + y)
|
|
2098
|
-
*
|
|
2042
|
+
* Array.from(sums) // => [11, 22, 33, 44]
|
|
2099
2043
|
*
|
|
2100
2044
|
* // Combine strings
|
|
2101
2045
|
* const firstNames = ["John", "Jane", "Bob"]
|
|
@@ -2105,7 +2049,7 @@ export const zipWith: {
|
|
|
2105
2049
|
* lastNames,
|
|
2106
2050
|
* (first, last) => `${first} ${last}`
|
|
2107
2051
|
* )
|
|
2108
|
-
*
|
|
2052
|
+
* Array.from(fullNames) // => ["John Doe", "Jane Smith", "Bob Johnson"]
|
|
2109
2053
|
*
|
|
2110
2054
|
* // Different lengths - stops at shorter
|
|
2111
2055
|
* const short = [1, 2]
|
|
@@ -2115,7 +2059,7 @@ export const zipWith: {
|
|
|
2115
2059
|
* long,
|
|
2116
2060
|
* (num, letter) => `${num}${letter}`
|
|
2117
2061
|
* )
|
|
2118
|
-
*
|
|
2062
|
+
* Array.from(combined) // => ["1a", "2b"]
|
|
2119
2063
|
*
|
|
2120
2064
|
* // Complex transformations
|
|
2121
2065
|
* const prices = [10.99, 25.50, 5.00]
|
|
@@ -2123,7 +2067,7 @@ export const zipWith: {
|
|
|
2123
2067
|
* const totals = Iterable.zipWith(prices, quantities, (price, qty) => {
|
|
2124
2068
|
* return Math.round(price * qty * 100) / 100 // round to 2 decimal places
|
|
2125
2069
|
* })
|
|
2126
|
-
*
|
|
2070
|
+
* Array.from(totals) // => [21.98, 25.5, 15]
|
|
2127
2071
|
* ```
|
|
2128
2072
|
*
|
|
2129
2073
|
* @category zipping
|
|
@@ -2136,14 +2080,14 @@ export const zipWith: {
|
|
|
2136
2080
|
*
|
|
2137
2081
|
* **Example** (Zipping with a combining function)
|
|
2138
2082
|
*
|
|
2139
|
-
* ```ts
|
|
2083
|
+
* ```ts import.meta.vitest
|
|
2140
2084
|
* import { Iterable } from "effect"
|
|
2141
2085
|
*
|
|
2142
2086
|
* // Add corresponding elements
|
|
2143
2087
|
* const a = [1, 2, 3, 4]
|
|
2144
2088
|
* const b = [10, 20, 30, 40]
|
|
2145
2089
|
* const sums = Iterable.zipWith(a, b, (x, y) => x + y)
|
|
2146
|
-
*
|
|
2090
|
+
* Array.from(sums) // => [11, 22, 33, 44]
|
|
2147
2091
|
*
|
|
2148
2092
|
* // Combine strings
|
|
2149
2093
|
* const firstNames = ["John", "Jane", "Bob"]
|
|
@@ -2153,7 +2097,7 @@ export const zipWith: {
|
|
|
2153
2097
|
* lastNames,
|
|
2154
2098
|
* (first, last) => `${first} ${last}`
|
|
2155
2099
|
* )
|
|
2156
|
-
*
|
|
2100
|
+
* Array.from(fullNames) // => ["John Doe", "Jane Smith", "Bob Johnson"]
|
|
2157
2101
|
*
|
|
2158
2102
|
* // Different lengths - stops at shorter
|
|
2159
2103
|
* const short = [1, 2]
|
|
@@ -2163,7 +2107,7 @@ export const zipWith: {
|
|
|
2163
2107
|
* long,
|
|
2164
2108
|
* (num, letter) => `${num}${letter}`
|
|
2165
2109
|
* )
|
|
2166
|
-
*
|
|
2110
|
+
* Array.from(combined) // => ["1a", "2b"]
|
|
2167
2111
|
*
|
|
2168
2112
|
* // Complex transformations
|
|
2169
2113
|
* const prices = [10.99, 25.50, 5.00]
|
|
@@ -2171,7 +2115,7 @@ export const zipWith: {
|
|
|
2171
2115
|
* const totals = Iterable.zipWith(prices, quantities, (price, qty) => {
|
|
2172
2116
|
* return Math.round(price * qty * 100) / 100 // round to 2 decimal places
|
|
2173
2117
|
* })
|
|
2174
|
-
*
|
|
2118
|
+
* Array.from(totals) // => [21.98, 25.5, 15]
|
|
2175
2119
|
* ```
|
|
2176
2120
|
*
|
|
2177
2121
|
* @category zipping
|
|
@@ -2208,33 +2152,33 @@ export const zipWith: {
|
|
|
2208
2152
|
*
|
|
2209
2153
|
* **Example** (Interspersing separators)
|
|
2210
2154
|
*
|
|
2211
|
-
* ```ts
|
|
2155
|
+
* ```ts import.meta.vitest
|
|
2212
2156
|
* import { Iterable } from "effect"
|
|
2213
2157
|
*
|
|
2214
2158
|
* // Join numbers with separator
|
|
2215
2159
|
* const numbers = [1, 2, 3, 4]
|
|
2216
2160
|
* const withCommas = Iterable.intersperse(numbers, ",")
|
|
2217
|
-
*
|
|
2161
|
+
* Array.from(withCommas) // => [1, ",", 2, ",", 3, ",", 4]
|
|
2218
2162
|
*
|
|
2219
2163
|
* // Join words with spaces
|
|
2220
2164
|
* const words = ["hello", "world", "from", "effect"]
|
|
2221
2165
|
* const sentence = Iterable.intersperse(words, " ")
|
|
2222
|
-
*
|
|
2166
|
+
* Array.from(sentence).join("") // => "hello world from effect"
|
|
2223
2167
|
*
|
|
2224
2168
|
* // Empty iterable remains empty
|
|
2225
2169
|
* const empty = Iterable.empty<string>()
|
|
2226
2170
|
* const stillEmpty = Iterable.intersperse(empty, "-")
|
|
2227
|
-
*
|
|
2171
|
+
* Array.from(stillEmpty) // => []
|
|
2228
2172
|
*
|
|
2229
2173
|
* // Single element has no separators added
|
|
2230
2174
|
* const single = [42]
|
|
2231
2175
|
* const noSeparator = Iterable.intersperse(single, "|")
|
|
2232
|
-
*
|
|
2176
|
+
* Array.from(noSeparator) // => [42]
|
|
2233
2177
|
*
|
|
2234
2178
|
* // Build CSS-like strings
|
|
2235
2179
|
* const styles = ["color: red", "font-size: 14px", "margin: 10px"]
|
|
2236
2180
|
* const css = Iterable.intersperse(styles, "; ")
|
|
2237
|
-
*
|
|
2181
|
+
* Array.from(css).join("") // => "color: red; font-size: 14px; margin: 10px"
|
|
2238
2182
|
* ```
|
|
2239
2183
|
*
|
|
2240
2184
|
* @category combining
|
|
@@ -2254,33 +2198,33 @@ export const intersperse: {
|
|
|
2254
2198
|
*
|
|
2255
2199
|
* **Example** (Interspersing separators)
|
|
2256
2200
|
*
|
|
2257
|
-
* ```ts
|
|
2201
|
+
* ```ts import.meta.vitest
|
|
2258
2202
|
* import { Iterable } from "effect"
|
|
2259
2203
|
*
|
|
2260
2204
|
* // Join numbers with separator
|
|
2261
2205
|
* const numbers = [1, 2, 3, 4]
|
|
2262
2206
|
* const withCommas = Iterable.intersperse(numbers, ",")
|
|
2263
|
-
*
|
|
2207
|
+
* Array.from(withCommas) // => [1, ",", 2, ",", 3, ",", 4]
|
|
2264
2208
|
*
|
|
2265
2209
|
* // Join words with spaces
|
|
2266
2210
|
* const words = ["hello", "world", "from", "effect"]
|
|
2267
2211
|
* const sentence = Iterable.intersperse(words, " ")
|
|
2268
|
-
*
|
|
2212
|
+
* Array.from(sentence).join("") // => "hello world from effect"
|
|
2269
2213
|
*
|
|
2270
2214
|
* // Empty iterable remains empty
|
|
2271
2215
|
* const empty = Iterable.empty<string>()
|
|
2272
2216
|
* const stillEmpty = Iterable.intersperse(empty, "-")
|
|
2273
|
-
*
|
|
2217
|
+
* Array.from(stillEmpty) // => []
|
|
2274
2218
|
*
|
|
2275
2219
|
* // Single element has no separators added
|
|
2276
2220
|
* const single = [42]
|
|
2277
2221
|
* const noSeparator = Iterable.intersperse(single, "|")
|
|
2278
|
-
*
|
|
2222
|
+
* Array.from(noSeparator) // => [42]
|
|
2279
2223
|
*
|
|
2280
2224
|
* // Build CSS-like strings
|
|
2281
2225
|
* const styles = ["color: red", "font-size: 14px", "margin: 10px"]
|
|
2282
2226
|
* const css = Iterable.intersperse(styles, "; ")
|
|
2283
|
-
*
|
|
2227
|
+
* Array.from(css).join("") // => "color: red; font-size: 14px; margin: 10px"
|
|
2284
2228
|
* ```
|
|
2285
2229
|
*
|
|
2286
2230
|
* @category combining
|
|
@@ -2300,33 +2244,33 @@ export const intersperse: {
|
|
|
2300
2244
|
*
|
|
2301
2245
|
* **Example** (Interspersing separators)
|
|
2302
2246
|
*
|
|
2303
|
-
* ```ts
|
|
2247
|
+
* ```ts import.meta.vitest
|
|
2304
2248
|
* import { Iterable } from "effect"
|
|
2305
2249
|
*
|
|
2306
2250
|
* // Join numbers with separator
|
|
2307
2251
|
* const numbers = [1, 2, 3, 4]
|
|
2308
2252
|
* const withCommas = Iterable.intersperse(numbers, ",")
|
|
2309
|
-
*
|
|
2253
|
+
* Array.from(withCommas) // => [1, ",", 2, ",", 3, ",", 4]
|
|
2310
2254
|
*
|
|
2311
2255
|
* // Join words with spaces
|
|
2312
2256
|
* const words = ["hello", "world", "from", "effect"]
|
|
2313
2257
|
* const sentence = Iterable.intersperse(words, " ")
|
|
2314
|
-
*
|
|
2258
|
+
* Array.from(sentence).join("") // => "hello world from effect"
|
|
2315
2259
|
*
|
|
2316
2260
|
* // Empty iterable remains empty
|
|
2317
2261
|
* const empty = Iterable.empty<string>()
|
|
2318
2262
|
* const stillEmpty = Iterable.intersperse(empty, "-")
|
|
2319
|
-
*
|
|
2263
|
+
* Array.from(stillEmpty) // => []
|
|
2320
2264
|
*
|
|
2321
2265
|
* // Single element has no separators added
|
|
2322
2266
|
* const single = [42]
|
|
2323
2267
|
* const noSeparator = Iterable.intersperse(single, "|")
|
|
2324
|
-
*
|
|
2268
|
+
* Array.from(noSeparator) // => [42]
|
|
2325
2269
|
*
|
|
2326
2270
|
* // Build CSS-like strings
|
|
2327
2271
|
* const styles = ["color: red", "font-size: 14px", "margin: 10px"]
|
|
2328
2272
|
* const css = Iterable.intersperse(styles, "; ")
|
|
2329
|
-
*
|
|
2273
|
+
* Array.from(css).join("") // => "color: red; font-size: 14px; margin: 10px"
|
|
2330
2274
|
* ```
|
|
2331
2275
|
*
|
|
2332
2276
|
* @category combining
|
|
@@ -2360,7 +2304,7 @@ export const intersperse: {
|
|
|
2360
2304
|
*
|
|
2361
2305
|
* **Example** (Checking membership with custom equivalence)
|
|
2362
2306
|
*
|
|
2363
|
-
* ```ts
|
|
2307
|
+
* ```ts import.meta.vitest
|
|
2364
2308
|
* import { Iterable } from "effect"
|
|
2365
2309
|
*
|
|
2366
2310
|
* // Custom equivalence for objects
|
|
@@ -2369,7 +2313,7 @@ export const intersperse: {
|
|
|
2369
2313
|
*
|
|
2370
2314
|
* const users = [{ id: 1 }, { id: 2 }]
|
|
2371
2315
|
* const hasUser1 = containsById(users, { id: 1 })
|
|
2372
|
-
*
|
|
2316
|
+
* hasUser1 // => true
|
|
2373
2317
|
*
|
|
2374
2318
|
* // Case-insensitive string comparison
|
|
2375
2319
|
* const caseInsensitive = (a: string, b: string) =>
|
|
@@ -2378,7 +2322,7 @@ export const intersperse: {
|
|
|
2378
2322
|
*
|
|
2379
2323
|
* const words = ["Hello", "World"]
|
|
2380
2324
|
* const hasHello = containsCaseInsensitive(words, "hello")
|
|
2381
|
-
*
|
|
2325
|
+
* hasHello // => true
|
|
2382
2326
|
*
|
|
2383
2327
|
* // Approximate number comparison
|
|
2384
2328
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
@@ -2386,10 +2330,10 @@ export const intersperse: {
|
|
|
2386
2330
|
*
|
|
2387
2331
|
* const values = [1.0, 2.0, 3.0]
|
|
2388
2332
|
* const hasAlmostTwo = containsApprox(values, 2.05)
|
|
2389
|
-
*
|
|
2333
|
+
* hasAlmostTwo // => true
|
|
2390
2334
|
* ```
|
|
2391
2335
|
*
|
|
2392
|
-
* @category
|
|
2336
|
+
* @category predicates
|
|
2393
2337
|
* @since 2.0.0
|
|
2394
2338
|
*/
|
|
2395
2339
|
export const containsWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
|
|
@@ -2416,29 +2360,29 @@ export const containsWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
|
|
|
2416
2360
|
*
|
|
2417
2361
|
* **Example** (Checking membership)
|
|
2418
2362
|
*
|
|
2419
|
-
* ```ts
|
|
2363
|
+
* ```ts import.meta.vitest
|
|
2420
2364
|
* import { Iterable } from "effect"
|
|
2421
2365
|
*
|
|
2422
2366
|
* const numbers = [1, 2, 3, 4, 5]
|
|
2423
|
-
*
|
|
2424
|
-
*
|
|
2367
|
+
* Iterable.contains(numbers, 3) // => true
|
|
2368
|
+
* Iterable.contains(numbers, 6) // => false
|
|
2425
2369
|
*
|
|
2426
2370
|
* const letters = "hello"
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
2371
|
+
* Iterable.contains(letters, "l") // => true
|
|
2372
|
+
* Iterable.contains(letters, "x") // => false
|
|
2429
2373
|
*
|
|
2430
2374
|
* // Works with any iterable
|
|
2431
2375
|
* const range = Iterable.range(1, 100)
|
|
2432
|
-
*
|
|
2433
|
-
*
|
|
2376
|
+
* Iterable.contains(range, 50) // => true
|
|
2377
|
+
* Iterable.contains(range, 150) // => false
|
|
2434
2378
|
*
|
|
2435
2379
|
* // Curried version
|
|
2436
2380
|
* const containsThree = Iterable.contains(3)
|
|
2437
|
-
*
|
|
2438
|
-
*
|
|
2381
|
+
* containsThree([1, 2, 3]) // => true
|
|
2382
|
+
* containsThree([4, 5, 6]) // => false
|
|
2439
2383
|
* ```
|
|
2440
2384
|
*
|
|
2441
|
-
* @category
|
|
2385
|
+
* @category predicates
|
|
2442
2386
|
* @since 2.0.0
|
|
2443
2387
|
*/
|
|
2444
2388
|
export const contains: {
|
|
@@ -2453,29 +2397,29 @@ export const contains: {
|
|
|
2453
2397
|
*
|
|
2454
2398
|
* **Example** (Checking membership)
|
|
2455
2399
|
*
|
|
2456
|
-
* ```ts
|
|
2400
|
+
* ```ts import.meta.vitest
|
|
2457
2401
|
* import { Iterable } from "effect"
|
|
2458
2402
|
*
|
|
2459
2403
|
* const numbers = [1, 2, 3, 4, 5]
|
|
2460
|
-
*
|
|
2461
|
-
*
|
|
2404
|
+
* Iterable.contains(numbers, 3) // => true
|
|
2405
|
+
* Iterable.contains(numbers, 6) // => false
|
|
2462
2406
|
*
|
|
2463
2407
|
* const letters = "hello"
|
|
2464
|
-
*
|
|
2465
|
-
*
|
|
2408
|
+
* Iterable.contains(letters, "l") // => true
|
|
2409
|
+
* Iterable.contains(letters, "x") // => false
|
|
2466
2410
|
*
|
|
2467
2411
|
* // Works with any iterable
|
|
2468
2412
|
* const range = Iterable.range(1, 100)
|
|
2469
|
-
*
|
|
2470
|
-
*
|
|
2413
|
+
* Iterable.contains(range, 50) // => true
|
|
2414
|
+
* Iterable.contains(range, 150) // => false
|
|
2471
2415
|
*
|
|
2472
2416
|
* // Curried version
|
|
2473
2417
|
* const containsThree = Iterable.contains(3)
|
|
2474
|
-
*
|
|
2475
|
-
*
|
|
2418
|
+
* containsThree([1, 2, 3]) // => true
|
|
2419
|
+
* containsThree([4, 5, 6]) // => false
|
|
2476
2420
|
* ```
|
|
2477
2421
|
*
|
|
2478
|
-
* @category
|
|
2422
|
+
* @category predicates
|
|
2479
2423
|
* @since 2.0.0
|
|
2480
2424
|
*/
|
|
2481
2425
|
<A>(a: A): (self: Iterable<A>) => boolean
|
|
@@ -2490,29 +2434,29 @@ export const contains: {
|
|
|
2490
2434
|
*
|
|
2491
2435
|
* **Example** (Checking membership)
|
|
2492
2436
|
*
|
|
2493
|
-
* ```ts
|
|
2437
|
+
* ```ts import.meta.vitest
|
|
2494
2438
|
* import { Iterable } from "effect"
|
|
2495
2439
|
*
|
|
2496
2440
|
* const numbers = [1, 2, 3, 4, 5]
|
|
2497
|
-
*
|
|
2498
|
-
*
|
|
2441
|
+
* Iterable.contains(numbers, 3) // => true
|
|
2442
|
+
* Iterable.contains(numbers, 6) // => false
|
|
2499
2443
|
*
|
|
2500
2444
|
* const letters = "hello"
|
|
2501
|
-
*
|
|
2502
|
-
*
|
|
2445
|
+
* Iterable.contains(letters, "l") // => true
|
|
2446
|
+
* Iterable.contains(letters, "x") // => false
|
|
2503
2447
|
*
|
|
2504
2448
|
* // Works with any iterable
|
|
2505
2449
|
* const range = Iterable.range(1, 100)
|
|
2506
|
-
*
|
|
2507
|
-
*
|
|
2450
|
+
* Iterable.contains(range, 50) // => true
|
|
2451
|
+
* Iterable.contains(range, 150) // => false
|
|
2508
2452
|
*
|
|
2509
2453
|
* // Curried version
|
|
2510
2454
|
* const containsThree = Iterable.contains(3)
|
|
2511
|
-
*
|
|
2512
|
-
*
|
|
2455
|
+
* containsThree([1, 2, 3]) // => true
|
|
2456
|
+
* containsThree([4, 5, 6]) // => false
|
|
2513
2457
|
* ```
|
|
2514
2458
|
*
|
|
2515
|
-
* @category
|
|
2459
|
+
* @category predicates
|
|
2516
2460
|
* @since 2.0.0
|
|
2517
2461
|
*/
|
|
2518
2462
|
<A>(self: Iterable<A>, a: A): boolean
|
|
@@ -2524,25 +2468,22 @@ export const contains: {
|
|
|
2524
2468
|
*
|
|
2525
2469
|
* **Example** (Chunking an iterable)
|
|
2526
2470
|
*
|
|
2527
|
-
* ```ts
|
|
2471
|
+
* ```ts import.meta.vitest
|
|
2528
2472
|
* import { Iterable } from "effect"
|
|
2529
2473
|
*
|
|
2530
2474
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
2531
2475
|
* const chunks = Iterable.chunksOf(numbers, 3)
|
|
2532
|
-
*
|
|
2533
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2476
|
+
* Array.from(chunks) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2534
2477
|
*
|
|
2535
2478
|
* // Last chunk can be shorter
|
|
2536
2479
|
* const uneven = [1, 2, 3, 4, 5, 6, 7]
|
|
2537
2480
|
* const chunks2 = Iterable.chunksOf(uneven, 3)
|
|
2538
|
-
*
|
|
2539
|
-
* // [[1, 2, 3], [4, 5, 6], [7]]
|
|
2481
|
+
* Array.from(chunks2) // => [[1, 2, 3], [4, 5, 6], [7]]
|
|
2540
2482
|
*
|
|
2541
2483
|
* // Chunk size larger than iterable
|
|
2542
2484
|
* const small = [1, 2]
|
|
2543
2485
|
* const chunks3 = Iterable.chunksOf(small, 5)
|
|
2544
|
-
*
|
|
2545
|
-
* // [[1, 2]]
|
|
2486
|
+
* Array.from(chunks3) // => [[1, 2]]
|
|
2546
2487
|
*
|
|
2547
2488
|
* // Process data in batches
|
|
2548
2489
|
* const data = Iterable.range(1, 100)
|
|
@@ -2551,7 +2492,7 @@ export const contains: {
|
|
|
2551
2492
|
* batches,
|
|
2552
2493
|
* (batch) => Iterable.reduce(batch, 0, (sum, n) => sum + n)
|
|
2553
2494
|
* )
|
|
2554
|
-
*
|
|
2495
|
+
* Array.from(Iterable.take(batchSums, 3)) // => [55, 155, 255]
|
|
2555
2496
|
* ```
|
|
2556
2497
|
*
|
|
2557
2498
|
* @category splitting
|
|
@@ -2564,25 +2505,22 @@ export const chunksOf: {
|
|
|
2564
2505
|
*
|
|
2565
2506
|
* **Example** (Chunking an iterable)
|
|
2566
2507
|
*
|
|
2567
|
-
* ```ts
|
|
2508
|
+
* ```ts import.meta.vitest
|
|
2568
2509
|
* import { Iterable } from "effect"
|
|
2569
2510
|
*
|
|
2570
2511
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
2571
2512
|
* const chunks = Iterable.chunksOf(numbers, 3)
|
|
2572
|
-
*
|
|
2573
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2513
|
+
* Array.from(chunks) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2574
2514
|
*
|
|
2575
2515
|
* // Last chunk can be shorter
|
|
2576
2516
|
* const uneven = [1, 2, 3, 4, 5, 6, 7]
|
|
2577
2517
|
* const chunks2 = Iterable.chunksOf(uneven, 3)
|
|
2578
|
-
*
|
|
2579
|
-
* // [[1, 2, 3], [4, 5, 6], [7]]
|
|
2518
|
+
* Array.from(chunks2) // => [[1, 2, 3], [4, 5, 6], [7]]
|
|
2580
2519
|
*
|
|
2581
2520
|
* // Chunk size larger than iterable
|
|
2582
2521
|
* const small = [1, 2]
|
|
2583
2522
|
* const chunks3 = Iterable.chunksOf(small, 5)
|
|
2584
|
-
*
|
|
2585
|
-
* // [[1, 2]]
|
|
2523
|
+
* Array.from(chunks3) // => [[1, 2]]
|
|
2586
2524
|
*
|
|
2587
2525
|
* // Process data in batches
|
|
2588
2526
|
* const data = Iterable.range(1, 100)
|
|
@@ -2591,7 +2529,7 @@ export const chunksOf: {
|
|
|
2591
2529
|
* batches,
|
|
2592
2530
|
* (batch) => Iterable.reduce(batch, 0, (sum, n) => sum + n)
|
|
2593
2531
|
* )
|
|
2594
|
-
*
|
|
2532
|
+
* Array.from(Iterable.take(batchSums, 3)) // => [55, 155, 255]
|
|
2595
2533
|
* ```
|
|
2596
2534
|
*
|
|
2597
2535
|
* @category splitting
|
|
@@ -2604,25 +2542,22 @@ export const chunksOf: {
|
|
|
2604
2542
|
*
|
|
2605
2543
|
* **Example** (Chunking an iterable)
|
|
2606
2544
|
*
|
|
2607
|
-
* ```ts
|
|
2545
|
+
* ```ts import.meta.vitest
|
|
2608
2546
|
* import { Iterable } from "effect"
|
|
2609
2547
|
*
|
|
2610
2548
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
2611
2549
|
* const chunks = Iterable.chunksOf(numbers, 3)
|
|
2612
|
-
*
|
|
2613
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2550
|
+
* Array.from(chunks) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2614
2551
|
*
|
|
2615
2552
|
* // Last chunk can be shorter
|
|
2616
2553
|
* const uneven = [1, 2, 3, 4, 5, 6, 7]
|
|
2617
2554
|
* const chunks2 = Iterable.chunksOf(uneven, 3)
|
|
2618
|
-
*
|
|
2619
|
-
* // [[1, 2, 3], [4, 5, 6], [7]]
|
|
2555
|
+
* Array.from(chunks2) // => [[1, 2, 3], [4, 5, 6], [7]]
|
|
2620
2556
|
*
|
|
2621
2557
|
* // Chunk size larger than iterable
|
|
2622
2558
|
* const small = [1, 2]
|
|
2623
2559
|
* const chunks3 = Iterable.chunksOf(small, 5)
|
|
2624
|
-
*
|
|
2625
|
-
* // [[1, 2]]
|
|
2560
|
+
* Array.from(chunks3) // => [[1, 2]]
|
|
2626
2561
|
*
|
|
2627
2562
|
* // Process data in batches
|
|
2628
2563
|
* const data = Iterable.range(1, 100)
|
|
@@ -2631,7 +2566,7 @@ export const chunksOf: {
|
|
|
2631
2566
|
* batches,
|
|
2632
2567
|
* (batch) => Iterable.reduce(batch, 0, (sum, n) => sum + n)
|
|
2633
2568
|
* )
|
|
2634
|
-
*
|
|
2569
|
+
* Array.from(Iterable.take(batchSums, 3)) // => [55, 155, 255]
|
|
2635
2570
|
* ```
|
|
2636
2571
|
*
|
|
2637
2572
|
* @category splitting
|
|
@@ -2671,35 +2606,31 @@ export const chunksOf: {
|
|
|
2671
2606
|
*
|
|
2672
2607
|
* **Example** (Grouping consecutive elements with custom equivalence)
|
|
2673
2608
|
*
|
|
2674
|
-
* ```ts
|
|
2609
|
+
* ```ts import.meta.vitest
|
|
2675
2610
|
* import { Iterable } from "effect"
|
|
2676
2611
|
*
|
|
2677
2612
|
* // Group consecutive equal numbers
|
|
2678
2613
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2679
2614
|
* const grouped = Iterable.groupWith(numbers, (a, b) => a === b)
|
|
2680
|
-
*
|
|
2681
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2615
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2682
2616
|
*
|
|
2683
2617
|
* // Case-insensitive grouping of strings
|
|
2684
2618
|
* const words = ["Apple", "APPLE", "banana", "Banana", "cherry"]
|
|
2685
2619
|
* const caseInsensitive = (a: string, b: string) =>
|
|
2686
2620
|
* a.toLowerCase() === b.toLowerCase()
|
|
2687
2621
|
* const groupedWords = Iterable.groupWith(words, caseInsensitive)
|
|
2688
|
-
*
|
|
2689
|
-
* // [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2622
|
+
* Array.from(groupedWords) // => [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2690
2623
|
*
|
|
2691
2624
|
* // Group by approximate equality
|
|
2692
2625
|
* const floats = [1.1, 1.12, 1.9, 2.01, 2.05, 3.5]
|
|
2693
2626
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.2
|
|
2694
2627
|
* const groupedFloats = Iterable.groupWith(floats, approxEqual)
|
|
2695
|
-
*
|
|
2696
|
-
* // [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2628
|
+
* Array.from(groupedFloats) // => [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2697
2629
|
*
|
|
2698
2630
|
* // Only groups consecutive elements
|
|
2699
2631
|
* const scattered = [1, 2, 1, 2, 1]
|
|
2700
2632
|
* const scatteredGroups = Iterable.groupWith(scattered, (a, b) => a === b)
|
|
2701
|
-
*
|
|
2702
|
-
* // [[1], [2], [1], [2], [1]] (no grouping since none are consecutive)
|
|
2633
|
+
* Array.from(scatteredGroups) // => [[1], [2], [1], [2], [1]]
|
|
2703
2634
|
* ```
|
|
2704
2635
|
*
|
|
2705
2636
|
* @category grouping
|
|
@@ -2711,35 +2642,31 @@ export const groupWith: {
|
|
|
2711
2642
|
*
|
|
2712
2643
|
* **Example** (Grouping consecutive elements with custom equivalence)
|
|
2713
2644
|
*
|
|
2714
|
-
* ```ts
|
|
2645
|
+
* ```ts import.meta.vitest
|
|
2715
2646
|
* import { Iterable } from "effect"
|
|
2716
2647
|
*
|
|
2717
2648
|
* // Group consecutive equal numbers
|
|
2718
2649
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2719
2650
|
* const grouped = Iterable.groupWith(numbers, (a, b) => a === b)
|
|
2720
|
-
*
|
|
2721
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2651
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2722
2652
|
*
|
|
2723
2653
|
* // Case-insensitive grouping of strings
|
|
2724
2654
|
* const words = ["Apple", "APPLE", "banana", "Banana", "cherry"]
|
|
2725
2655
|
* const caseInsensitive = (a: string, b: string) =>
|
|
2726
2656
|
* a.toLowerCase() === b.toLowerCase()
|
|
2727
2657
|
* const groupedWords = Iterable.groupWith(words, caseInsensitive)
|
|
2728
|
-
*
|
|
2729
|
-
* // [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2658
|
+
* Array.from(groupedWords) // => [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2730
2659
|
*
|
|
2731
2660
|
* // Group by approximate equality
|
|
2732
2661
|
* const floats = [1.1, 1.12, 1.9, 2.01, 2.05, 3.5]
|
|
2733
2662
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.2
|
|
2734
2663
|
* const groupedFloats = Iterable.groupWith(floats, approxEqual)
|
|
2735
|
-
*
|
|
2736
|
-
* // [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2664
|
+
* Array.from(groupedFloats) // => [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2737
2665
|
*
|
|
2738
2666
|
* // Only groups consecutive elements
|
|
2739
2667
|
* const scattered = [1, 2, 1, 2, 1]
|
|
2740
2668
|
* const scatteredGroups = Iterable.groupWith(scattered, (a, b) => a === b)
|
|
2741
|
-
*
|
|
2742
|
-
* // [[1], [2], [1], [2], [1]] (no grouping since none are consecutive)
|
|
2669
|
+
* Array.from(scatteredGroups) // => [[1], [2], [1], [2], [1]]
|
|
2743
2670
|
* ```
|
|
2744
2671
|
*
|
|
2745
2672
|
* @category grouping
|
|
@@ -2751,35 +2678,31 @@ export const groupWith: {
|
|
|
2751
2678
|
*
|
|
2752
2679
|
* **Example** (Grouping consecutive elements with custom equivalence)
|
|
2753
2680
|
*
|
|
2754
|
-
* ```ts
|
|
2681
|
+
* ```ts import.meta.vitest
|
|
2755
2682
|
* import { Iterable } from "effect"
|
|
2756
2683
|
*
|
|
2757
2684
|
* // Group consecutive equal numbers
|
|
2758
2685
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2759
2686
|
* const grouped = Iterable.groupWith(numbers, (a, b) => a === b)
|
|
2760
|
-
*
|
|
2761
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2687
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2762
2688
|
*
|
|
2763
2689
|
* // Case-insensitive grouping of strings
|
|
2764
2690
|
* const words = ["Apple", "APPLE", "banana", "Banana", "cherry"]
|
|
2765
2691
|
* const caseInsensitive = (a: string, b: string) =>
|
|
2766
2692
|
* a.toLowerCase() === b.toLowerCase()
|
|
2767
2693
|
* const groupedWords = Iterable.groupWith(words, caseInsensitive)
|
|
2768
|
-
*
|
|
2769
|
-
* // [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2694
|
+
* Array.from(groupedWords) // => [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2770
2695
|
*
|
|
2771
2696
|
* // Group by approximate equality
|
|
2772
2697
|
* const floats = [1.1, 1.12, 1.9, 2.01, 2.05, 3.5]
|
|
2773
2698
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.2
|
|
2774
2699
|
* const groupedFloats = Iterable.groupWith(floats, approxEqual)
|
|
2775
|
-
*
|
|
2776
|
-
* // [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2700
|
+
* Array.from(groupedFloats) // => [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2777
2701
|
*
|
|
2778
2702
|
* // Only groups consecutive elements
|
|
2779
2703
|
* const scattered = [1, 2, 1, 2, 1]
|
|
2780
2704
|
* const scatteredGroups = Iterable.groupWith(scattered, (a, b) => a === b)
|
|
2781
|
-
*
|
|
2782
|
-
* // [[1], [2], [1], [2], [1]] (no grouping since none are consecutive)
|
|
2705
|
+
* Array.from(scatteredGroups) // => [[1], [2], [1], [2], [1]]
|
|
2783
2706
|
* ```
|
|
2784
2707
|
*
|
|
2785
2708
|
* @category grouping
|
|
@@ -2828,18 +2751,16 @@ export const groupWith: {
|
|
|
2828
2751
|
*
|
|
2829
2752
|
* **Example** (Grouping consecutive elements)
|
|
2830
2753
|
*
|
|
2831
|
-
* ```ts
|
|
2754
|
+
* ```ts import.meta.vitest
|
|
2832
2755
|
* import { Iterable } from "effect"
|
|
2833
2756
|
*
|
|
2834
2757
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2835
2758
|
* const grouped = Iterable.group(numbers)
|
|
2836
|
-
*
|
|
2837
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2759
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2838
2760
|
*
|
|
2839
2761
|
* const letters = "aabbccaa"
|
|
2840
2762
|
* const groupedLetters = Iterable.group(letters)
|
|
2841
|
-
*
|
|
2842
|
-
* // [["a", "a"], ["b", "b"], ["c", "c"], ["a", "a"]]
|
|
2763
|
+
* Array.from(groupedLetters) // => [["a", "a"], ["b", "b"], ["c", "c"], ["a", "a"]]
|
|
2843
2764
|
*
|
|
2844
2765
|
* // Works with objects using deep equality
|
|
2845
2766
|
* const objects = [
|
|
@@ -2849,7 +2770,7 @@ export const groupWith: {
|
|
|
2849
2770
|
* { type: "A", value: 1 }
|
|
2850
2771
|
* ]
|
|
2851
2772
|
* const groupedObjects = Iterable.group(objects)
|
|
2852
|
-
*
|
|
2773
|
+
* Array.from(groupedObjects).length // => 3
|
|
2853
2774
|
* // Note: Only consecutive equal objects are grouped together
|
|
2854
2775
|
* ```
|
|
2855
2776
|
*
|
|
@@ -2871,20 +2792,18 @@ export const group: <A>(self: Iterable<A>) => Iterable<NonEmptyArray<A>> = group
|
|
|
2871
2792
|
*
|
|
2872
2793
|
* **Example** (Grouping by a key)
|
|
2873
2794
|
*
|
|
2874
|
-
* ```ts
|
|
2795
|
+
* ```ts import.meta.vitest
|
|
2875
2796
|
* import { Iterable } from "effect"
|
|
2876
2797
|
*
|
|
2877
2798
|
* // Group by string length
|
|
2878
2799
|
* const words = ["a", "bb", "ccc", "dd", "eee", "f"]
|
|
2879
2800
|
* const byLength = Iterable.groupBy(words, (word) => word.length.toString())
|
|
2880
|
-
*
|
|
2881
|
-
* // { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2801
|
+
* byLength // => { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2882
2802
|
*
|
|
2883
2803
|
* // Group by first letter
|
|
2884
2804
|
* const names = ["Alice", "Bob", "Charlie", "David", "Anna", "Betty"]
|
|
2885
2805
|
* const byFirstLetter = Iterable.groupBy(names, (name) => name[0])
|
|
2886
|
-
*
|
|
2887
|
-
* // { "A": ["Alice", "Anna"], "B": ["Bob", "Betty"], "C": ["Charlie"], "D": ["David"] }
|
|
2806
|
+
* byFirstLetter // => { A: ["Alice", "Anna"], B: ["Bob", "Betty"], C: ["Charlie"], D: ["David"] }
|
|
2888
2807
|
*
|
|
2889
2808
|
* // Group by category
|
|
2890
2809
|
* const items = [
|
|
@@ -2894,17 +2813,12 @@ export const group: <A>(self: Iterable<A>) => Iterable<NonEmptyArray<A>> = group
|
|
|
2894
2813
|
* { name: "broccoli", category: "vegetable" }
|
|
2895
2814
|
* ]
|
|
2896
2815
|
* const byCategory = Iterable.groupBy(items, (item) => item.category)
|
|
2897
|
-
*
|
|
2898
|
-
* // {
|
|
2899
|
-
* // "fruit": [{ name: "apple", category: "fruit" }, { name: "banana", category: "fruit" }],
|
|
2900
|
-
* // "vegetable": [{ name: "carrot", category: "vegetable" }, { name: "broccoli", category: "vegetable" }]
|
|
2901
|
-
* // }
|
|
2816
|
+
* Object.keys(byCategory) // => ["fruit", "vegetable"]
|
|
2902
2817
|
*
|
|
2903
2818
|
* // Group numbers by even/odd
|
|
2904
2819
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
2905
2820
|
* const evenOdd = Iterable.groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd")
|
|
2906
|
-
*
|
|
2907
|
-
* // { "odd": [1, 3, 5], "even": [2, 4, 6] }
|
|
2821
|
+
* evenOdd // => { odd: [1, 3, 5], even: [2, 4, 6] }
|
|
2908
2822
|
* ```
|
|
2909
2823
|
*
|
|
2910
2824
|
* @category grouping
|
|
@@ -2922,20 +2836,18 @@ export const groupBy: {
|
|
|
2922
2836
|
*
|
|
2923
2837
|
* **Example** (Grouping by a key)
|
|
2924
2838
|
*
|
|
2925
|
-
* ```ts
|
|
2839
|
+
* ```ts import.meta.vitest
|
|
2926
2840
|
* import { Iterable } from "effect"
|
|
2927
2841
|
*
|
|
2928
2842
|
* // Group by string length
|
|
2929
2843
|
* const words = ["a", "bb", "ccc", "dd", "eee", "f"]
|
|
2930
2844
|
* const byLength = Iterable.groupBy(words, (word) => word.length.toString())
|
|
2931
|
-
*
|
|
2932
|
-
* // { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2845
|
+
* byLength // => { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2933
2846
|
*
|
|
2934
2847
|
* // Group by first letter
|
|
2935
2848
|
* const names = ["Alice", "Bob", "Charlie", "David", "Anna", "Betty"]
|
|
2936
2849
|
* const byFirstLetter = Iterable.groupBy(names, (name) => name[0])
|
|
2937
|
-
*
|
|
2938
|
-
* // { "A": ["Alice", "Anna"], "B": ["Bob", "Betty"], "C": ["Charlie"], "D": ["David"] }
|
|
2850
|
+
* byFirstLetter // => { A: ["Alice", "Anna"], B: ["Bob", "Betty"], C: ["Charlie"], D: ["David"] }
|
|
2939
2851
|
*
|
|
2940
2852
|
* // Group by category
|
|
2941
2853
|
* const items = [
|
|
@@ -2945,17 +2857,12 @@ export const groupBy: {
|
|
|
2945
2857
|
* { name: "broccoli", category: "vegetable" }
|
|
2946
2858
|
* ]
|
|
2947
2859
|
* const byCategory = Iterable.groupBy(items, (item) => item.category)
|
|
2948
|
-
*
|
|
2949
|
-
* // {
|
|
2950
|
-
* // "fruit": [{ name: "apple", category: "fruit" }, { name: "banana", category: "fruit" }],
|
|
2951
|
-
* // "vegetable": [{ name: "carrot", category: "vegetable" }, { name: "broccoli", category: "vegetable" }]
|
|
2952
|
-
* // }
|
|
2860
|
+
* Object.keys(byCategory) // => ["fruit", "vegetable"]
|
|
2953
2861
|
*
|
|
2954
2862
|
* // Group numbers by even/odd
|
|
2955
2863
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
2956
2864
|
* const evenOdd = Iterable.groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd")
|
|
2957
|
-
*
|
|
2958
|
-
* // { "odd": [1, 3, 5], "even": [2, 4, 6] }
|
|
2865
|
+
* evenOdd // => { odd: [1, 3, 5], even: [2, 4, 6] }
|
|
2959
2866
|
* ```
|
|
2960
2867
|
*
|
|
2961
2868
|
* @category grouping
|
|
@@ -2973,20 +2880,18 @@ export const groupBy: {
|
|
|
2973
2880
|
*
|
|
2974
2881
|
* **Example** (Grouping by a key)
|
|
2975
2882
|
*
|
|
2976
|
-
* ```ts
|
|
2883
|
+
* ```ts import.meta.vitest
|
|
2977
2884
|
* import { Iterable } from "effect"
|
|
2978
2885
|
*
|
|
2979
2886
|
* // Group by string length
|
|
2980
2887
|
* const words = ["a", "bb", "ccc", "dd", "eee", "f"]
|
|
2981
2888
|
* const byLength = Iterable.groupBy(words, (word) => word.length.toString())
|
|
2982
|
-
*
|
|
2983
|
-
* // { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2889
|
+
* byLength // => { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2984
2890
|
*
|
|
2985
2891
|
* // Group by first letter
|
|
2986
2892
|
* const names = ["Alice", "Bob", "Charlie", "David", "Anna", "Betty"]
|
|
2987
2893
|
* const byFirstLetter = Iterable.groupBy(names, (name) => name[0])
|
|
2988
|
-
*
|
|
2989
|
-
* // { "A": ["Alice", "Anna"], "B": ["Bob", "Betty"], "C": ["Charlie"], "D": ["David"] }
|
|
2894
|
+
* byFirstLetter // => { A: ["Alice", "Anna"], B: ["Bob", "Betty"], C: ["Charlie"], D: ["David"] }
|
|
2990
2895
|
*
|
|
2991
2896
|
* // Group by category
|
|
2992
2897
|
* const items = [
|
|
@@ -2996,17 +2901,12 @@ export const groupBy: {
|
|
|
2996
2901
|
* { name: "broccoli", category: "vegetable" }
|
|
2997
2902
|
* ]
|
|
2998
2903
|
* const byCategory = Iterable.groupBy(items, (item) => item.category)
|
|
2999
|
-
*
|
|
3000
|
-
* // {
|
|
3001
|
-
* // "fruit": [{ name: "apple", category: "fruit" }, { name: "banana", category: "fruit" }],
|
|
3002
|
-
* // "vegetable": [{ name: "carrot", category: "vegetable" }, { name: "broccoli", category: "vegetable" }]
|
|
3003
|
-
* // }
|
|
2904
|
+
* Object.keys(byCategory) // => ["fruit", "vegetable"]
|
|
3004
2905
|
*
|
|
3005
2906
|
* // Group numbers by even/odd
|
|
3006
2907
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3007
2908
|
* const evenOdd = Iterable.groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd")
|
|
3008
|
-
*
|
|
3009
|
-
* // { "odd": [1, 3, 5], "even": [2, 4, 6] }
|
|
2909
|
+
* evenOdd // => { odd: [1, 3, 5], even: [2, 4, 6] }
|
|
3010
2910
|
* ```
|
|
3011
2911
|
*
|
|
3012
2912
|
* @category grouping
|
|
@@ -3023,7 +2923,7 @@ export const groupBy: {
|
|
|
3023
2923
|
if (Object.hasOwn(out, k)) {
|
|
3024
2924
|
out[k].push(a)
|
|
3025
2925
|
} else {
|
|
3026
|
-
out
|
|
2926
|
+
InternalRecord.assignProperty(out, k, [a])
|
|
3027
2927
|
}
|
|
3028
2928
|
}
|
|
3029
2929
|
return out
|
|
@@ -3050,18 +2950,10 @@ const constEmptyIterator: Iterator<never> = {
|
|
|
3050
2950
|
*
|
|
3051
2951
|
* **Example** (Creating an empty iterable)
|
|
3052
2952
|
*
|
|
3053
|
-
* ```ts
|
|
2953
|
+
* ```ts import.meta.vitest
|
|
3054
2954
|
* import { Iterable } from "effect"
|
|
3055
2955
|
*
|
|
3056
|
-
*
|
|
3057
|
-
* console.log(Array.from(empty)) // []
|
|
3058
|
-
* console.log(Iterable.isEmpty(empty)) // true
|
|
3059
|
-
*
|
|
3060
|
-
* // Useful as base case for reductions
|
|
3061
|
-
* const hasData = true
|
|
3062
|
-
* const result = hasData
|
|
3063
|
-
* ? Iterable.range(1, 5)
|
|
3064
|
-
* : Iterable.empty<number>()
|
|
2956
|
+
* Array.from(Iterable.empty<string>()) // => []
|
|
3065
2957
|
* ```
|
|
3066
2958
|
*
|
|
3067
2959
|
* @category constructors
|
|
@@ -3079,11 +2971,11 @@ export const empty = <A = never>(): Iterable<A> => constEmpty
|
|
|
3079
2971
|
*
|
|
3080
2972
|
* **Example** (Wrapping a single value)
|
|
3081
2973
|
*
|
|
3082
|
-
* ```ts
|
|
2974
|
+
* ```ts import.meta.vitest
|
|
3083
2975
|
* import { Iterable } from "effect"
|
|
3084
2976
|
*
|
|
3085
2977
|
* const single = Iterable.of(42)
|
|
3086
|
-
*
|
|
2978
|
+
* Array.from(single) // => [42]
|
|
3087
2979
|
*
|
|
3088
2980
|
* // Useful for creating homogeneous sequences
|
|
3089
2981
|
* const sequences = [
|
|
@@ -3098,7 +2990,7 @@ export const empty = <A = never>(): Iterable<A> => constEmpty
|
|
|
3098
2990
|
* numbers,
|
|
3099
2991
|
* (n) => n % 2 === 0 ? Iterable.of(n) : Iterable.empty()
|
|
3100
2992
|
* )
|
|
3101
|
-
*
|
|
2993
|
+
* Array.from(evensOnly) // => [2, 4]
|
|
3102
2994
|
* ```
|
|
3103
2995
|
*
|
|
3104
2996
|
* @category constructors
|
|
@@ -3118,24 +3010,22 @@ export const of = <A>(a: A): Iterable<A> => [a]
|
|
|
3118
3010
|
*
|
|
3119
3011
|
* **Example** (Mapping elements)
|
|
3120
3012
|
*
|
|
3121
|
-
* ```ts
|
|
3013
|
+
* ```ts import.meta.vitest
|
|
3122
3014
|
* import { Iterable } from "effect"
|
|
3123
3015
|
*
|
|
3124
3016
|
* // Transform numbers to their squares
|
|
3125
3017
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3126
3018
|
* const squares = Iterable.map(numbers, (x) => x * x)
|
|
3127
|
-
*
|
|
3019
|
+
* Array.from(squares) // => [1, 4, 9, 16, 25]
|
|
3128
3020
|
*
|
|
3129
3021
|
* // Use index in transformation
|
|
3130
3022
|
* const indexed = Iterable.map(["a", "b", "c"], (char, i) => `${i}: ${char}`)
|
|
3131
|
-
*
|
|
3023
|
+
* Array.from(indexed) // => ["0: a", "1: b", "2: c"]
|
|
3132
3024
|
*
|
|
3133
|
-
*
|
|
3134
|
-
* const result = Iterable.map(
|
|
3025
|
+
* Array.from(Iterable.map(
|
|
3135
3026
|
* Iterable.map([1, 2, 3], (x) => x * 2),
|
|
3136
3027
|
* (x) => x + 1
|
|
3137
|
-
* )
|
|
3138
|
-
* console.log(Array.from(result)) // [3, 5, 7]
|
|
3028
|
+
* )) // => [3, 5, 7]
|
|
3139
3029
|
* ```
|
|
3140
3030
|
*
|
|
3141
3031
|
* @category mapping
|
|
@@ -3154,24 +3044,22 @@ export const map: {
|
|
|
3154
3044
|
*
|
|
3155
3045
|
* **Example** (Mapping elements)
|
|
3156
3046
|
*
|
|
3157
|
-
* ```ts
|
|
3047
|
+
* ```ts import.meta.vitest
|
|
3158
3048
|
* import { Iterable } from "effect"
|
|
3159
3049
|
*
|
|
3160
3050
|
* // Transform numbers to their squares
|
|
3161
3051
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3162
3052
|
* const squares = Iterable.map(numbers, (x) => x * x)
|
|
3163
|
-
*
|
|
3053
|
+
* Array.from(squares) // => [1, 4, 9, 16, 25]
|
|
3164
3054
|
*
|
|
3165
3055
|
* // Use index in transformation
|
|
3166
3056
|
* const indexed = Iterable.map(["a", "b", "c"], (char, i) => `${i}: ${char}`)
|
|
3167
|
-
*
|
|
3057
|
+
* Array.from(indexed) // => ["0: a", "1: b", "2: c"]
|
|
3168
3058
|
*
|
|
3169
|
-
*
|
|
3170
|
-
* const result = Iterable.map(
|
|
3059
|
+
* Array.from(Iterable.map(
|
|
3171
3060
|
* Iterable.map([1, 2, 3], (x) => x * 2),
|
|
3172
3061
|
* (x) => x + 1
|
|
3173
|
-
* )
|
|
3174
|
-
* console.log(Array.from(result)) // [3, 5, 7]
|
|
3062
|
+
* )) // => [3, 5, 7]
|
|
3175
3063
|
* ```
|
|
3176
3064
|
*
|
|
3177
3065
|
* @category mapping
|
|
@@ -3190,24 +3078,22 @@ export const map: {
|
|
|
3190
3078
|
*
|
|
3191
3079
|
* **Example** (Mapping elements)
|
|
3192
3080
|
*
|
|
3193
|
-
* ```ts
|
|
3081
|
+
* ```ts import.meta.vitest
|
|
3194
3082
|
* import { Iterable } from "effect"
|
|
3195
3083
|
*
|
|
3196
3084
|
* // Transform numbers to their squares
|
|
3197
3085
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3198
3086
|
* const squares = Iterable.map(numbers, (x) => x * x)
|
|
3199
|
-
*
|
|
3087
|
+
* Array.from(squares) // => [1, 4, 9, 16, 25]
|
|
3200
3088
|
*
|
|
3201
3089
|
* // Use index in transformation
|
|
3202
3090
|
* const indexed = Iterable.map(["a", "b", "c"], (char, i) => `${i}: ${char}`)
|
|
3203
|
-
*
|
|
3091
|
+
* Array.from(indexed) // => ["0: a", "1: b", "2: c"]
|
|
3204
3092
|
*
|
|
3205
|
-
*
|
|
3206
|
-
* const result = Iterable.map(
|
|
3093
|
+
* Array.from(Iterable.map(
|
|
3207
3094
|
* Iterable.map([1, 2, 3], (x) => x * 2),
|
|
3208
3095
|
* (x) => x + 1
|
|
3209
|
-
* )
|
|
3210
|
-
* console.log(Array.from(result)) // [3, 5, 7]
|
|
3096
|
+
* )) // => [3, 5, 7]
|
|
3211
3097
|
* ```
|
|
3212
3098
|
*
|
|
3213
3099
|
* @category mapping
|
|
@@ -3235,18 +3121,18 @@ export const map: {
|
|
|
3235
3121
|
*
|
|
3236
3122
|
* **Example** (Flat mapping iterables)
|
|
3237
3123
|
*
|
|
3238
|
-
* ```ts
|
|
3124
|
+
* ```ts import.meta.vitest
|
|
3239
3125
|
* import { Iterable } from "effect"
|
|
3240
3126
|
*
|
|
3241
3127
|
* // Expand each number to a range
|
|
3242
3128
|
* const numbers = [1, 2, 3]
|
|
3243
3129
|
* const expanded = Iterable.flatMap(numbers, (n) => Iterable.range(1, n))
|
|
3244
|
-
*
|
|
3130
|
+
* Array.from(expanded) // => [1, 1, 2, 1, 2, 3]
|
|
3245
3131
|
*
|
|
3246
3132
|
* // Split strings into characters
|
|
3247
3133
|
* const words = ["hi", "bye"]
|
|
3248
3134
|
* const chars = Iterable.flatMap(words, (word) => word)
|
|
3249
|
-
*
|
|
3135
|
+
* Array.from(chars) // => ["h", "i", "b", "y", "e"]
|
|
3250
3136
|
*
|
|
3251
3137
|
* // Conditional expansion with empty iterables
|
|
3252
3138
|
* const values = [1, 2, 3, 4, 5]
|
|
@@ -3254,7 +3140,7 @@ export const map: {
|
|
|
3254
3140
|
* values,
|
|
3255
3141
|
* (n) => n % 2 === 0 ? [n, n * 2, n * 3] : []
|
|
3256
3142
|
* )
|
|
3257
|
-
*
|
|
3143
|
+
* Array.from(evenMultiples) // => [2, 4, 6, 4, 8, 12]
|
|
3258
3144
|
*
|
|
3259
3145
|
* // Use index in transformation
|
|
3260
3146
|
* const letters = ["a", "b", "c"]
|
|
@@ -3262,7 +3148,7 @@ export const map: {
|
|
|
3262
3148
|
* letters,
|
|
3263
3149
|
* (letter, i) => Iterable.replicate(letter, i + 1)
|
|
3264
3150
|
* )
|
|
3265
|
-
*
|
|
3151
|
+
* Array.from(indexed) // => ["a", "b", "b", "c", "c", "c"]
|
|
3266
3152
|
* ```
|
|
3267
3153
|
*
|
|
3268
3154
|
* @category sequencing
|
|
@@ -3274,18 +3160,18 @@ export const flatMap: {
|
|
|
3274
3160
|
*
|
|
3275
3161
|
* **Example** (Flat mapping iterables)
|
|
3276
3162
|
*
|
|
3277
|
-
* ```ts
|
|
3163
|
+
* ```ts import.meta.vitest
|
|
3278
3164
|
* import { Iterable } from "effect"
|
|
3279
3165
|
*
|
|
3280
3166
|
* // Expand each number to a range
|
|
3281
3167
|
* const numbers = [1, 2, 3]
|
|
3282
3168
|
* const expanded = Iterable.flatMap(numbers, (n) => Iterable.range(1, n))
|
|
3283
|
-
*
|
|
3169
|
+
* Array.from(expanded) // => [1, 1, 2, 1, 2, 3]
|
|
3284
3170
|
*
|
|
3285
3171
|
* // Split strings into characters
|
|
3286
3172
|
* const words = ["hi", "bye"]
|
|
3287
3173
|
* const chars = Iterable.flatMap(words, (word) => word)
|
|
3288
|
-
*
|
|
3174
|
+
* Array.from(chars) // => ["h", "i", "b", "y", "e"]
|
|
3289
3175
|
*
|
|
3290
3176
|
* // Conditional expansion with empty iterables
|
|
3291
3177
|
* const values = [1, 2, 3, 4, 5]
|
|
@@ -3293,7 +3179,7 @@ export const flatMap: {
|
|
|
3293
3179
|
* values,
|
|
3294
3180
|
* (n) => n % 2 === 0 ? [n, n * 2, n * 3] : []
|
|
3295
3181
|
* )
|
|
3296
|
-
*
|
|
3182
|
+
* Array.from(evenMultiples) // => [2, 4, 6, 4, 8, 12]
|
|
3297
3183
|
*
|
|
3298
3184
|
* // Use index in transformation
|
|
3299
3185
|
* const letters = ["a", "b", "c"]
|
|
@@ -3301,7 +3187,7 @@ export const flatMap: {
|
|
|
3301
3187
|
* letters,
|
|
3302
3188
|
* (letter, i) => Iterable.replicate(letter, i + 1)
|
|
3303
3189
|
* )
|
|
3304
|
-
*
|
|
3190
|
+
* Array.from(indexed) // => ["a", "b", "b", "c", "c", "c"]
|
|
3305
3191
|
* ```
|
|
3306
3192
|
*
|
|
3307
3193
|
* @category sequencing
|
|
@@ -3313,18 +3199,18 @@ export const flatMap: {
|
|
|
3313
3199
|
*
|
|
3314
3200
|
* **Example** (Flat mapping iterables)
|
|
3315
3201
|
*
|
|
3316
|
-
* ```ts
|
|
3202
|
+
* ```ts import.meta.vitest
|
|
3317
3203
|
* import { Iterable } from "effect"
|
|
3318
3204
|
*
|
|
3319
3205
|
* // Expand each number to a range
|
|
3320
3206
|
* const numbers = [1, 2, 3]
|
|
3321
3207
|
* const expanded = Iterable.flatMap(numbers, (n) => Iterable.range(1, n))
|
|
3322
|
-
*
|
|
3208
|
+
* Array.from(expanded) // => [1, 1, 2, 1, 2, 3]
|
|
3323
3209
|
*
|
|
3324
3210
|
* // Split strings into characters
|
|
3325
3211
|
* const words = ["hi", "bye"]
|
|
3326
3212
|
* const chars = Iterable.flatMap(words, (word) => word)
|
|
3327
|
-
*
|
|
3213
|
+
* Array.from(chars) // => ["h", "i", "b", "y", "e"]
|
|
3328
3214
|
*
|
|
3329
3215
|
* // Conditional expansion with empty iterables
|
|
3330
3216
|
* const values = [1, 2, 3, 4, 5]
|
|
@@ -3332,7 +3218,7 @@ export const flatMap: {
|
|
|
3332
3218
|
* values,
|
|
3333
3219
|
* (n) => n % 2 === 0 ? [n, n * 2, n * 3] : []
|
|
3334
3220
|
* )
|
|
3335
|
-
*
|
|
3221
|
+
* Array.from(evenMultiples) // => [2, 4, 6, 4, 8, 12]
|
|
3336
3222
|
*
|
|
3337
3223
|
* // Use index in transformation
|
|
3338
3224
|
* const letters = ["a", "b", "c"]
|
|
@@ -3340,7 +3226,7 @@ export const flatMap: {
|
|
|
3340
3226
|
* letters,
|
|
3341
3227
|
* (letter, i) => Iterable.replicate(letter, i + 1)
|
|
3342
3228
|
* )
|
|
3343
|
-
*
|
|
3229
|
+
* Array.from(indexed) // => ["a", "b", "b", "c", "c", "c"]
|
|
3344
3230
|
* ```
|
|
3345
3231
|
*
|
|
3346
3232
|
* @category sequencing
|
|
@@ -3357,29 +3243,29 @@ export const flatMap: {
|
|
|
3357
3243
|
*
|
|
3358
3244
|
* **Example** (Flattening nested iterables)
|
|
3359
3245
|
*
|
|
3360
|
-
* ```ts
|
|
3246
|
+
* ```ts import.meta.vitest
|
|
3361
3247
|
* import { Iterable } from "effect"
|
|
3362
3248
|
*
|
|
3363
3249
|
* // Flatten nested arrays
|
|
3364
3250
|
* const nested = [[1, 2], [3, 4], [5, 6]]
|
|
3365
3251
|
* const flat = Iterable.flatten(nested)
|
|
3366
|
-
*
|
|
3252
|
+
* Array.from(flat) // => [1, 2, 3, 4, 5, 6]
|
|
3367
3253
|
*
|
|
3368
3254
|
* // Flatten different iterable types
|
|
3369
3255
|
* const mixed: Array<Iterable<string>> = ["ab", "cd"]
|
|
3370
3256
|
* const flatMixed = Iterable.flatten(mixed)
|
|
3371
|
-
*
|
|
3257
|
+
* Array.from(flatMixed) // => ["a", "b", "c", "d"]
|
|
3372
3258
|
*
|
|
3373
3259
|
* // Flatten deeply nested (only one level)
|
|
3374
3260
|
* const deepNested = [[[1, 2]], [[3, 4]]]
|
|
3375
3261
|
* const oneLevelFlat = Iterable.flatten(deepNested)
|
|
3376
|
-
*
|
|
3262
|
+
* Array.from(oneLevelFlat) // => [[1, 2], [3, 4]]
|
|
3377
3263
|
* // [[1, 2], [3, 4]] (still contains arrays)
|
|
3378
3264
|
*
|
|
3379
3265
|
* // Empty iterables are handled correctly
|
|
3380
3266
|
* const withEmpty = [[1, 2], [], [3, 4], []]
|
|
3381
3267
|
* const flatWithEmpty = Iterable.flatten(withEmpty)
|
|
3382
|
-
*
|
|
3268
|
+
* Array.from(flatWithEmpty) // => [1, 2, 3, 4]
|
|
3383
3269
|
* ```
|
|
3384
3270
|
*
|
|
3385
3271
|
* @category sequencing
|
|
@@ -3419,7 +3305,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3419
3305
|
*
|
|
3420
3306
|
* **Example** (Filtering and transforming Result values)
|
|
3421
3307
|
*
|
|
3422
|
-
* ```ts
|
|
3308
|
+
* ```ts import.meta.vitest
|
|
3423
3309
|
* import { Iterable, Result } from "effect"
|
|
3424
3310
|
*
|
|
3425
3311
|
* // Parse strings to numbers, keeping only valid ones
|
|
@@ -3428,7 +3314,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3428
3314
|
* const num = parseInt(s)
|
|
3429
3315
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3430
3316
|
* })
|
|
3431
|
-
*
|
|
3317
|
+
* Array.from(numbers) // => [1, 2, 4]
|
|
3432
3318
|
*
|
|
3433
3319
|
* // Extract specific properties from objects
|
|
3434
3320
|
* const users = [
|
|
@@ -3442,7 +3328,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3442
3328
|
* (user) =>
|
|
3443
3329
|
* user.age >= 18 && user.email ? Result.succeed(user.email) : Result.failVoid
|
|
3444
3330
|
* )
|
|
3445
|
-
*
|
|
3331
|
+
* Array.from(adultEmails) // => ["alice@example.com", "charlie@example.com"]
|
|
3446
3332
|
*
|
|
3447
3333
|
* // Use index in transformation
|
|
3448
3334
|
* const items = ["a", "b", "c", "d", "e"]
|
|
@@ -3450,7 +3336,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3450
3336
|
* items,
|
|
3451
3337
|
* (item, i) => i % 2 === 0 ? Result.succeed(`${i}: ${item}`) : Result.failVoid
|
|
3452
3338
|
* )
|
|
3453
|
-
*
|
|
3339
|
+
* Array.from(evenIndexItems) // => ["0: a", "2: c", "4: e"]
|
|
3454
3340
|
* ```
|
|
3455
3341
|
*
|
|
3456
3342
|
* @category filtering
|
|
@@ -3468,7 +3354,7 @@ export const filterMap: {
|
|
|
3468
3354
|
*
|
|
3469
3355
|
* **Example** (Filtering and transforming Result values)
|
|
3470
3356
|
*
|
|
3471
|
-
* ```ts
|
|
3357
|
+
* ```ts import.meta.vitest
|
|
3472
3358
|
* import { Iterable, Result } from "effect"
|
|
3473
3359
|
*
|
|
3474
3360
|
* // Parse strings to numbers, keeping only valid ones
|
|
@@ -3477,7 +3363,7 @@ export const filterMap: {
|
|
|
3477
3363
|
* const num = parseInt(s)
|
|
3478
3364
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3479
3365
|
* })
|
|
3480
|
-
*
|
|
3366
|
+
* Array.from(numbers) // => [1, 2, 4]
|
|
3481
3367
|
*
|
|
3482
3368
|
* // Extract specific properties from objects
|
|
3483
3369
|
* const users = [
|
|
@@ -3491,7 +3377,7 @@ export const filterMap: {
|
|
|
3491
3377
|
* (user) =>
|
|
3492
3378
|
* user.age >= 18 && user.email ? Result.succeed(user.email) : Result.failVoid
|
|
3493
3379
|
* )
|
|
3494
|
-
*
|
|
3380
|
+
* Array.from(adultEmails) // => ["alice@example.com", "charlie@example.com"]
|
|
3495
3381
|
*
|
|
3496
3382
|
* // Use index in transformation
|
|
3497
3383
|
* const items = ["a", "b", "c", "d", "e"]
|
|
@@ -3499,7 +3385,7 @@ export const filterMap: {
|
|
|
3499
3385
|
* items,
|
|
3500
3386
|
* (item, i) => i % 2 === 0 ? Result.succeed(`${i}: ${item}`) : Result.failVoid
|
|
3501
3387
|
* )
|
|
3502
|
-
*
|
|
3388
|
+
* Array.from(evenIndexItems) // => ["0: a", "2: c", "4: e"]
|
|
3503
3389
|
* ```
|
|
3504
3390
|
*
|
|
3505
3391
|
* @category filtering
|
|
@@ -3517,7 +3403,7 @@ export const filterMap: {
|
|
|
3517
3403
|
*
|
|
3518
3404
|
* **Example** (Filtering and transforming Result values)
|
|
3519
3405
|
*
|
|
3520
|
-
* ```ts
|
|
3406
|
+
* ```ts import.meta.vitest
|
|
3521
3407
|
* import { Iterable, Result } from "effect"
|
|
3522
3408
|
*
|
|
3523
3409
|
* // Parse strings to numbers, keeping only valid ones
|
|
@@ -3526,7 +3412,7 @@ export const filterMap: {
|
|
|
3526
3412
|
* const num = parseInt(s)
|
|
3527
3413
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3528
3414
|
* })
|
|
3529
|
-
*
|
|
3415
|
+
* Array.from(numbers) // => [1, 2, 4]
|
|
3530
3416
|
*
|
|
3531
3417
|
* // Extract specific properties from objects
|
|
3532
3418
|
* const users = [
|
|
@@ -3540,7 +3426,7 @@ export const filterMap: {
|
|
|
3540
3426
|
* (user) =>
|
|
3541
3427
|
* user.age >= 18 && user.email ? Result.succeed(user.email) : Result.failVoid
|
|
3542
3428
|
* )
|
|
3543
|
-
*
|
|
3429
|
+
* Array.from(adultEmails) // => ["alice@example.com", "charlie@example.com"]
|
|
3544
3430
|
*
|
|
3545
3431
|
* // Use index in transformation
|
|
3546
3432
|
* const items = ["a", "b", "c", "d", "e"]
|
|
@@ -3548,7 +3434,7 @@ export const filterMap: {
|
|
|
3548
3434
|
* items,
|
|
3549
3435
|
* (item, i) => i % 2 === 0 ? Result.succeed(`${i}: ${item}`) : Result.failVoid
|
|
3550
3436
|
* )
|
|
3551
|
-
*
|
|
3437
|
+
* Array.from(evenIndexItems) // => ["0: a", "2: c", "4: e"]
|
|
3552
3438
|
* ```
|
|
3553
3439
|
*
|
|
3554
3440
|
* @category filtering
|
|
@@ -3583,7 +3469,7 @@ export const filterMap: {
|
|
|
3583
3469
|
*
|
|
3584
3470
|
* **Example** (Filtering and transforming until failure)
|
|
3585
3471
|
*
|
|
3586
|
-
* ```ts
|
|
3472
|
+
* ```ts import.meta.vitest
|
|
3587
3473
|
* import { Iterable, Result } from "effect"
|
|
3588
3474
|
*
|
|
3589
3475
|
* // Parse numbers until we hit an invalid one
|
|
@@ -3592,7 +3478,7 @@ export const filterMap: {
|
|
|
3592
3478
|
* const num = parseInt(s)
|
|
3593
3479
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3594
3480
|
* })
|
|
3595
|
-
*
|
|
3481
|
+
* Array.from(numbers) // => [1, 2, 3]
|
|
3596
3482
|
*
|
|
3597
3483
|
* // Take elements while they meet a condition and transform them
|
|
3598
3484
|
* const values = [2, 4, 6, 7, 8, 10]
|
|
@@ -3600,7 +3486,7 @@ export const filterMap: {
|
|
|
3600
3486
|
* values,
|
|
3601
3487
|
* (n) => n % 2 === 0 ? Result.succeed(n * 2) : Result.failVoid
|
|
3602
3488
|
* )
|
|
3603
|
-
*
|
|
3489
|
+
* Array.from(doubledEvens) // => [4, 8, 12]
|
|
3604
3490
|
*
|
|
3605
3491
|
* // Process with index until condition fails
|
|
3606
3492
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
@@ -3608,7 +3494,7 @@ export const filterMap: {
|
|
|
3608
3494
|
* letters,
|
|
3609
3495
|
* (letter, i) => letter !== "c" ? Result.succeed(`${i}: ${letter}`) : Result.failVoid
|
|
3610
3496
|
* )
|
|
3611
|
-
*
|
|
3497
|
+
* Array.from(indexedUntilC) // => ["0: a", "1: b"]
|
|
3612
3498
|
* ```
|
|
3613
3499
|
*
|
|
3614
3500
|
* @category filtering
|
|
@@ -3620,7 +3506,7 @@ export const filterMapWhile: {
|
|
|
3620
3506
|
*
|
|
3621
3507
|
* **Example** (Filtering and transforming until failure)
|
|
3622
3508
|
*
|
|
3623
|
-
* ```ts
|
|
3509
|
+
* ```ts import.meta.vitest
|
|
3624
3510
|
* import { Iterable, Result } from "effect"
|
|
3625
3511
|
*
|
|
3626
3512
|
* // Parse numbers until we hit an invalid one
|
|
@@ -3629,7 +3515,7 @@ export const filterMapWhile: {
|
|
|
3629
3515
|
* const num = parseInt(s)
|
|
3630
3516
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3631
3517
|
* })
|
|
3632
|
-
*
|
|
3518
|
+
* Array.from(numbers) // => [1, 2, 3]
|
|
3633
3519
|
*
|
|
3634
3520
|
* // Take elements while they meet a condition and transform them
|
|
3635
3521
|
* const values = [2, 4, 6, 7, 8, 10]
|
|
@@ -3637,7 +3523,7 @@ export const filterMapWhile: {
|
|
|
3637
3523
|
* values,
|
|
3638
3524
|
* (n) => n % 2 === 0 ? Result.succeed(n * 2) : Result.failVoid
|
|
3639
3525
|
* )
|
|
3640
|
-
*
|
|
3526
|
+
* Array.from(doubledEvens) // => [4, 8, 12]
|
|
3641
3527
|
*
|
|
3642
3528
|
* // Process with index until condition fails
|
|
3643
3529
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
@@ -3645,7 +3531,7 @@ export const filterMapWhile: {
|
|
|
3645
3531
|
* letters,
|
|
3646
3532
|
* (letter, i) => letter !== "c" ? Result.succeed(`${i}: ${letter}`) : Result.failVoid
|
|
3647
3533
|
* )
|
|
3648
|
-
*
|
|
3534
|
+
* Array.from(indexedUntilC) // => ["0: a", "1: b"]
|
|
3649
3535
|
* ```
|
|
3650
3536
|
*
|
|
3651
3537
|
* @category filtering
|
|
@@ -3657,7 +3543,7 @@ export const filterMapWhile: {
|
|
|
3657
3543
|
*
|
|
3658
3544
|
* **Example** (Filtering and transforming until failure)
|
|
3659
3545
|
*
|
|
3660
|
-
* ```ts
|
|
3546
|
+
* ```ts import.meta.vitest
|
|
3661
3547
|
* import { Iterable, Result } from "effect"
|
|
3662
3548
|
*
|
|
3663
3549
|
* // Parse numbers until we hit an invalid one
|
|
@@ -3666,7 +3552,7 @@ export const filterMapWhile: {
|
|
|
3666
3552
|
* const num = parseInt(s)
|
|
3667
3553
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3668
3554
|
* })
|
|
3669
|
-
*
|
|
3555
|
+
* Array.from(numbers) // => [1, 2, 3]
|
|
3670
3556
|
*
|
|
3671
3557
|
* // Take elements while they meet a condition and transform them
|
|
3672
3558
|
* const values = [2, 4, 6, 7, 8, 10]
|
|
@@ -3674,7 +3560,7 @@ export const filterMapWhile: {
|
|
|
3674
3560
|
* values,
|
|
3675
3561
|
* (n) => n % 2 === 0 ? Result.succeed(n * 2) : Result.failVoid
|
|
3676
3562
|
* )
|
|
3677
|
-
*
|
|
3563
|
+
* Array.from(doubledEvens) // => [4, 8, 12]
|
|
3678
3564
|
*
|
|
3679
3565
|
* // Process with index until condition fails
|
|
3680
3566
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
@@ -3682,7 +3568,7 @@ export const filterMapWhile: {
|
|
|
3682
3568
|
* letters,
|
|
3683
3569
|
* (letter, i) => letter !== "c" ? Result.succeed(`${i}: ${letter}`) : Result.failVoid
|
|
3684
3570
|
* )
|
|
3685
|
-
*
|
|
3571
|
+
* Array.from(indexedUntilC) // => ["0: a", "1: b"]
|
|
3686
3572
|
* ```
|
|
3687
3573
|
*
|
|
3688
3574
|
* @category filtering
|
|
@@ -3714,16 +3600,10 @@ export const filterMapWhile: {
|
|
|
3714
3600
|
*
|
|
3715
3601
|
* **Example** (Extracting Some values)
|
|
3716
3602
|
*
|
|
3717
|
-
* ```ts
|
|
3603
|
+
* ```ts import.meta.vitest
|
|
3718
3604
|
* import { Iterable, Option } from "effect"
|
|
3719
|
-
* import * as assert from "node:assert"
|
|
3720
3605
|
*
|
|
3721
|
-
*
|
|
3722
|
-
* Array.from(
|
|
3723
|
-
* Iterable.getSomes([Option.some(1), Option.none(), Option.some(2)])
|
|
3724
|
-
* ),
|
|
3725
|
-
* [1, 2]
|
|
3726
|
-
* )
|
|
3606
|
+
* Array.from(Iterable.getSomes([Option.some(1), Option.none(), Option.some(2)])) // => [1, 2]
|
|
3727
3607
|
* ```
|
|
3728
3608
|
*
|
|
3729
3609
|
* @category filtering
|
|
@@ -3755,20 +3635,14 @@ export const getSomes = <A>(self: Iterable<Option<A>>): Iterable<A> => {
|
|
|
3755
3635
|
*
|
|
3756
3636
|
* **Example** (Extracting failures)
|
|
3757
3637
|
*
|
|
3758
|
-
* ```ts
|
|
3638
|
+
* ```ts import.meta.vitest
|
|
3759
3639
|
* import { Iterable, Result } from "effect"
|
|
3760
|
-
*
|
|
3761
|
-
*
|
|
3762
|
-
*
|
|
3763
|
-
*
|
|
3764
|
-
*
|
|
3765
|
-
*
|
|
3766
|
-
* Result.fail("err"),
|
|
3767
|
-
* Result.succeed(2)
|
|
3768
|
-
* ])
|
|
3769
|
-
* ),
|
|
3770
|
-
* ["err"]
|
|
3771
|
-
* )
|
|
3640
|
+
*
|
|
3641
|
+
* Array.from(Iterable.getFailures([
|
|
3642
|
+
* Result.succeed(1),
|
|
3643
|
+
* Result.fail("err"),
|
|
3644
|
+
* Result.succeed(2)
|
|
3645
|
+
* ])) // => ["err"]
|
|
3772
3646
|
* ```
|
|
3773
3647
|
*
|
|
3774
3648
|
* @category filtering
|
|
@@ -3800,20 +3674,14 @@ export const getFailures = <R0, L>(self: Iterable<Result<R0, L>>): Iterable<L> =
|
|
|
3800
3674
|
*
|
|
3801
3675
|
* **Example** (Extracting successes)
|
|
3802
3676
|
*
|
|
3803
|
-
* ```ts
|
|
3677
|
+
* ```ts import.meta.vitest
|
|
3804
3678
|
* import { Iterable, Result } from "effect"
|
|
3805
|
-
*
|
|
3806
|
-
*
|
|
3807
|
-
*
|
|
3808
|
-
*
|
|
3809
|
-
*
|
|
3810
|
-
*
|
|
3811
|
-
* Result.fail("err"),
|
|
3812
|
-
* Result.succeed(2)
|
|
3813
|
-
* ])
|
|
3814
|
-
* ),
|
|
3815
|
-
* [1, 2]
|
|
3816
|
-
* )
|
|
3679
|
+
*
|
|
3680
|
+
* Array.from(Iterable.getSuccesses([
|
|
3681
|
+
* Result.succeed(1),
|
|
3682
|
+
* Result.fail("err"),
|
|
3683
|
+
* Result.succeed(2)
|
|
3684
|
+
* ])) // => [1, 2]
|
|
3817
3685
|
* ```
|
|
3818
3686
|
*
|
|
3819
3687
|
* @category filtering
|
|
@@ -3850,18 +3718,18 @@ export const getSuccesses = <R0, L>(self: Iterable<Result<R0, L>>): Iterable<R0>
|
|
|
3850
3718
|
*
|
|
3851
3719
|
* **Example** (Filtering elements)
|
|
3852
3720
|
*
|
|
3853
|
-
* ```ts
|
|
3721
|
+
* ```ts import.meta.vitest
|
|
3854
3722
|
* import { Iterable } from "effect"
|
|
3855
3723
|
*
|
|
3856
3724
|
* // Filter even numbers
|
|
3857
3725
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3858
3726
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3859
|
-
*
|
|
3727
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3860
3728
|
*
|
|
3861
3729
|
* // Filter with index
|
|
3862
3730
|
* const items = ["a", "b", "c", "d"]
|
|
3863
3731
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3864
|
-
*
|
|
3732
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3865
3733
|
*
|
|
3866
3734
|
* // Type refinement
|
|
3867
3735
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -3869,14 +3737,14 @@ export const getSuccesses = <R0, L>(self: Iterable<Result<R0, L>>): Iterable<R0>
|
|
|
3869
3737
|
* mixed,
|
|
3870
3738
|
* (x): x is string => typeof x === "string"
|
|
3871
3739
|
* )
|
|
3872
|
-
*
|
|
3740
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
3873
3741
|
*
|
|
3874
3742
|
* // Combine with map
|
|
3875
3743
|
* const processed = Iterable.map(
|
|
3876
3744
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
3877
3745
|
* (x) => x * 10
|
|
3878
3746
|
* )
|
|
3879
|
-
*
|
|
3747
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
3880
3748
|
* ```
|
|
3881
3749
|
*
|
|
3882
3750
|
* @category filtering
|
|
@@ -3894,18 +3762,18 @@ export const filter: {
|
|
|
3894
3762
|
*
|
|
3895
3763
|
* **Example** (Filtering elements)
|
|
3896
3764
|
*
|
|
3897
|
-
* ```ts
|
|
3765
|
+
* ```ts import.meta.vitest
|
|
3898
3766
|
* import { Iterable } from "effect"
|
|
3899
3767
|
*
|
|
3900
3768
|
* // Filter even numbers
|
|
3901
3769
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3902
3770
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3903
|
-
*
|
|
3771
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3904
3772
|
*
|
|
3905
3773
|
* // Filter with index
|
|
3906
3774
|
* const items = ["a", "b", "c", "d"]
|
|
3907
3775
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3908
|
-
*
|
|
3776
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3909
3777
|
*
|
|
3910
3778
|
* // Type refinement
|
|
3911
3779
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -3913,14 +3781,14 @@ export const filter: {
|
|
|
3913
3781
|
* mixed,
|
|
3914
3782
|
* (x): x is string => typeof x === "string"
|
|
3915
3783
|
* )
|
|
3916
|
-
*
|
|
3784
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
3917
3785
|
*
|
|
3918
3786
|
* // Combine with map
|
|
3919
3787
|
* const processed = Iterable.map(
|
|
3920
3788
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
3921
3789
|
* (x) => x * 10
|
|
3922
3790
|
* )
|
|
3923
|
-
*
|
|
3791
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
3924
3792
|
* ```
|
|
3925
3793
|
*
|
|
3926
3794
|
* @category filtering
|
|
@@ -3938,18 +3806,18 @@ export const filter: {
|
|
|
3938
3806
|
*
|
|
3939
3807
|
* **Example** (Filtering elements)
|
|
3940
3808
|
*
|
|
3941
|
-
* ```ts
|
|
3809
|
+
* ```ts import.meta.vitest
|
|
3942
3810
|
* import { Iterable } from "effect"
|
|
3943
3811
|
*
|
|
3944
3812
|
* // Filter even numbers
|
|
3945
3813
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3946
3814
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3947
|
-
*
|
|
3815
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3948
3816
|
*
|
|
3949
3817
|
* // Filter with index
|
|
3950
3818
|
* const items = ["a", "b", "c", "d"]
|
|
3951
3819
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3952
|
-
*
|
|
3820
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3953
3821
|
*
|
|
3954
3822
|
* // Type refinement
|
|
3955
3823
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -3957,14 +3825,14 @@ export const filter: {
|
|
|
3957
3825
|
* mixed,
|
|
3958
3826
|
* (x): x is string => typeof x === "string"
|
|
3959
3827
|
* )
|
|
3960
|
-
*
|
|
3828
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
3961
3829
|
*
|
|
3962
3830
|
* // Combine with map
|
|
3963
3831
|
* const processed = Iterable.map(
|
|
3964
3832
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
3965
3833
|
* (x) => x * 10
|
|
3966
3834
|
* )
|
|
3967
|
-
*
|
|
3835
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
3968
3836
|
* ```
|
|
3969
3837
|
*
|
|
3970
3838
|
* @category filtering
|
|
@@ -3982,18 +3850,18 @@ export const filter: {
|
|
|
3982
3850
|
*
|
|
3983
3851
|
* **Example** (Filtering elements)
|
|
3984
3852
|
*
|
|
3985
|
-
* ```ts
|
|
3853
|
+
* ```ts import.meta.vitest
|
|
3986
3854
|
* import { Iterable } from "effect"
|
|
3987
3855
|
*
|
|
3988
3856
|
* // Filter even numbers
|
|
3989
3857
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3990
3858
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3991
|
-
*
|
|
3859
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3992
3860
|
*
|
|
3993
3861
|
* // Filter with index
|
|
3994
3862
|
* const items = ["a", "b", "c", "d"]
|
|
3995
3863
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3996
|
-
*
|
|
3864
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3997
3865
|
*
|
|
3998
3866
|
* // Type refinement
|
|
3999
3867
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -4001,14 +3869,14 @@ export const filter: {
|
|
|
4001
3869
|
* mixed,
|
|
4002
3870
|
* (x): x is string => typeof x === "string"
|
|
4003
3871
|
* )
|
|
4004
|
-
*
|
|
3872
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
4005
3873
|
*
|
|
4006
3874
|
* // Combine with map
|
|
4007
3875
|
* const processed = Iterable.map(
|
|
4008
3876
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
4009
3877
|
* (x) => x * 10
|
|
4010
3878
|
* )
|
|
4011
|
-
*
|
|
3879
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
4012
3880
|
* ```
|
|
4013
3881
|
*
|
|
4014
3882
|
* @category filtering
|
|
@@ -4026,18 +3894,18 @@ export const filter: {
|
|
|
4026
3894
|
*
|
|
4027
3895
|
* **Example** (Filtering elements)
|
|
4028
3896
|
*
|
|
4029
|
-
* ```ts
|
|
3897
|
+
* ```ts import.meta.vitest
|
|
4030
3898
|
* import { Iterable } from "effect"
|
|
4031
3899
|
*
|
|
4032
3900
|
* // Filter even numbers
|
|
4033
3901
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
4034
3902
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
4035
|
-
*
|
|
3903
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
4036
3904
|
*
|
|
4037
3905
|
* // Filter with index
|
|
4038
3906
|
* const items = ["a", "b", "c", "d"]
|
|
4039
3907
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
4040
|
-
*
|
|
3908
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
4041
3909
|
*
|
|
4042
3910
|
* // Type refinement
|
|
4043
3911
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -4045,14 +3913,14 @@ export const filter: {
|
|
|
4045
3913
|
* mixed,
|
|
4046
3914
|
* (x): x is string => typeof x === "string"
|
|
4047
3915
|
* )
|
|
4048
|
-
*
|
|
3916
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
4049
3917
|
*
|
|
4050
3918
|
* // Combine with map
|
|
4051
3919
|
* const processed = Iterable.map(
|
|
4052
3920
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
4053
3921
|
* (x) => x * 10
|
|
4054
3922
|
* )
|
|
4055
|
-
*
|
|
3923
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
4056
3924
|
* ```
|
|
4057
3925
|
*
|
|
4058
3926
|
* @category filtering
|
|
@@ -4091,7 +3959,7 @@ export const filter: {
|
|
|
4091
3959
|
*
|
|
4092
3960
|
* **Example** (Flat mapping nullable results)
|
|
4093
3961
|
*
|
|
4094
|
-
* ```ts
|
|
3962
|
+
* ```ts import.meta.vitest
|
|
4095
3963
|
* import { Iterable } from "effect"
|
|
4096
3964
|
*
|
|
4097
3965
|
* // Extract valid elements from nullable function results
|
|
@@ -4100,7 +3968,7 @@ export const filter: {
|
|
|
4100
3968
|
* const num = parseInt(s)
|
|
4101
3969
|
* return isNaN(num) ? null : num * 2
|
|
4102
3970
|
* })
|
|
4103
|
-
*
|
|
3971
|
+
* Array.from(parsed) // => [2, 4, 8]
|
|
4104
3972
|
*
|
|
4105
3973
|
* // Safe property access
|
|
4106
3974
|
* const objects = [
|
|
@@ -4110,7 +3978,7 @@ export const filter: {
|
|
|
4110
3978
|
* {}
|
|
4111
3979
|
* ]
|
|
4112
3980
|
* const values = Iterable.flatMapNullishOr(objects, (obj) => obj.nested?.value)
|
|
4113
|
-
*
|
|
3981
|
+
* Array.from(values) // => [10, 20]
|
|
4114
3982
|
*
|
|
4115
3983
|
* // Working with Map.get (returns undefined for missing keys)
|
|
4116
3984
|
* const map = new Map([
|
|
@@ -4120,7 +3988,7 @@ export const filter: {
|
|
|
4120
3988
|
* ])
|
|
4121
3989
|
* const keys = ["a", "x", "b", "y", "c"]
|
|
4122
3990
|
* const foundValues = Iterable.flatMapNullishOr(keys, (key) => map.get(key))
|
|
4123
|
-
*
|
|
3991
|
+
* Array.from(foundValues) // => [1, 2, 3]
|
|
4124
3992
|
* ```
|
|
4125
3993
|
*
|
|
4126
3994
|
* @category sequencing
|
|
@@ -4137,7 +4005,7 @@ export const flatMapNullishOr: {
|
|
|
4137
4005
|
*
|
|
4138
4006
|
* **Example** (Flat mapping nullable results)
|
|
4139
4007
|
*
|
|
4140
|
-
* ```ts
|
|
4008
|
+
* ```ts import.meta.vitest
|
|
4141
4009
|
* import { Iterable } from "effect"
|
|
4142
4010
|
*
|
|
4143
4011
|
* // Extract valid elements from nullable function results
|
|
@@ -4146,7 +4014,7 @@ export const flatMapNullishOr: {
|
|
|
4146
4014
|
* const num = parseInt(s)
|
|
4147
4015
|
* return isNaN(num) ? null : num * 2
|
|
4148
4016
|
* })
|
|
4149
|
-
*
|
|
4017
|
+
* Array.from(parsed) // => [2, 4, 8]
|
|
4150
4018
|
*
|
|
4151
4019
|
* // Safe property access
|
|
4152
4020
|
* const objects = [
|
|
@@ -4156,7 +4024,7 @@ export const flatMapNullishOr: {
|
|
|
4156
4024
|
* {}
|
|
4157
4025
|
* ]
|
|
4158
4026
|
* const values = Iterable.flatMapNullishOr(objects, (obj) => obj.nested?.value)
|
|
4159
|
-
*
|
|
4027
|
+
* Array.from(values) // => [10, 20]
|
|
4160
4028
|
*
|
|
4161
4029
|
* // Working with Map.get (returns undefined for missing keys)
|
|
4162
4030
|
* const map = new Map([
|
|
@@ -4166,7 +4034,7 @@ export const flatMapNullishOr: {
|
|
|
4166
4034
|
* ])
|
|
4167
4035
|
* const keys = ["a", "x", "b", "y", "c"]
|
|
4168
4036
|
* const foundValues = Iterable.flatMapNullishOr(keys, (key) => map.get(key))
|
|
4169
|
-
*
|
|
4037
|
+
* Array.from(foundValues) // => [1, 2, 3]
|
|
4170
4038
|
* ```
|
|
4171
4039
|
*
|
|
4172
4040
|
* @category sequencing
|
|
@@ -4183,7 +4051,7 @@ export const flatMapNullishOr: {
|
|
|
4183
4051
|
*
|
|
4184
4052
|
* **Example** (Flat mapping nullable results)
|
|
4185
4053
|
*
|
|
4186
|
-
* ```ts
|
|
4054
|
+
* ```ts import.meta.vitest
|
|
4187
4055
|
* import { Iterable } from "effect"
|
|
4188
4056
|
*
|
|
4189
4057
|
* // Extract valid elements from nullable function results
|
|
@@ -4192,7 +4060,7 @@ export const flatMapNullishOr: {
|
|
|
4192
4060
|
* const num = parseInt(s)
|
|
4193
4061
|
* return isNaN(num) ? null : num * 2
|
|
4194
4062
|
* })
|
|
4195
|
-
*
|
|
4063
|
+
* Array.from(parsed) // => [2, 4, 8]
|
|
4196
4064
|
*
|
|
4197
4065
|
* // Safe property access
|
|
4198
4066
|
* const objects = [
|
|
@@ -4202,7 +4070,7 @@ export const flatMapNullishOr: {
|
|
|
4202
4070
|
* {}
|
|
4203
4071
|
* ]
|
|
4204
4072
|
* const values = Iterable.flatMapNullishOr(objects, (obj) => obj.nested?.value)
|
|
4205
|
-
*
|
|
4073
|
+
* Array.from(values) // => [10, 20]
|
|
4206
4074
|
*
|
|
4207
4075
|
* // Working with Map.get (returns undefined for missing keys)
|
|
4208
4076
|
* const map = new Map([
|
|
@@ -4212,7 +4080,7 @@ export const flatMapNullishOr: {
|
|
|
4212
4080
|
* ])
|
|
4213
4081
|
* const keys = ["a", "x", "b", "y", "c"]
|
|
4214
4082
|
* const foundValues = Iterable.flatMapNullishOr(keys, (key) => map.get(key))
|
|
4215
|
-
*
|
|
4083
|
+
* Array.from(foundValues) // => [1, 2, 3]
|
|
4216
4084
|
* ```
|
|
4217
4085
|
*
|
|
4218
4086
|
* @category sequencing
|
|
@@ -4233,21 +4101,21 @@ export const flatMapNullishOr: {
|
|
|
4233
4101
|
*
|
|
4234
4102
|
* **Example** (Checking whether some element matches)
|
|
4235
4103
|
*
|
|
4236
|
-
* ```ts
|
|
4104
|
+
* ```ts import.meta.vitest
|
|
4237
4105
|
* import { Iterable } from "effect"
|
|
4238
4106
|
*
|
|
4239
4107
|
* const numbers = [1, 3, 5, 7, 8]
|
|
4240
4108
|
* const hasEven = Iterable.some(numbers, (x) => x % 2 === 0)
|
|
4241
|
-
*
|
|
4109
|
+
* hasEven // => true
|
|
4242
4110
|
*
|
|
4243
4111
|
* const allOdd = [1, 3, 5, 7]
|
|
4244
4112
|
* const hasEvenInAllOdd = Iterable.some(allOdd, (x) => x % 2 === 0)
|
|
4245
|
-
*
|
|
4113
|
+
* hasEvenInAllOdd // => false
|
|
4246
4114
|
*
|
|
4247
4115
|
* // With index
|
|
4248
4116
|
* const letters = ["a", "b", "c"]
|
|
4249
4117
|
* const hasElementAtIndex2 = Iterable.some(letters, (_, i) => i === 2)
|
|
4250
|
-
*
|
|
4118
|
+
* hasElementAtIndex2 // => true
|
|
4251
4119
|
*
|
|
4252
4120
|
* // Early termination - stops at first match
|
|
4253
4121
|
* const infiniteOdds = Iterable.filter(Iterable.range(1), (x) => x % 2 === 1)
|
|
@@ -4255,7 +4123,7 @@ export const flatMapNullishOr: {
|
|
|
4255
4123
|
* Iterable.take(infiniteOdds, 1000),
|
|
4256
4124
|
* (x) => x % 2 === 0
|
|
4257
4125
|
* )
|
|
4258
|
-
*
|
|
4126
|
+
* hasEvenInInfiniteOdds // => false
|
|
4259
4127
|
*
|
|
4260
4128
|
* // Type guard usage
|
|
4261
4129
|
* const mixed: Array<string | number> = [1, 2, "hello"]
|
|
@@ -4263,10 +4131,10 @@ export const flatMapNullishOr: {
|
|
|
4263
4131
|
* mixed,
|
|
4264
4132
|
* (x): x is string => typeof x === "string"
|
|
4265
4133
|
* )
|
|
4266
|
-
*
|
|
4134
|
+
* hasString // => true
|
|
4267
4135
|
* ```
|
|
4268
4136
|
*
|
|
4269
|
-
* @category
|
|
4137
|
+
* @category predicates
|
|
4270
4138
|
* @since 2.0.0
|
|
4271
4139
|
*/
|
|
4272
4140
|
export const some: {
|
|
@@ -4275,21 +4143,21 @@ export const some: {
|
|
|
4275
4143
|
*
|
|
4276
4144
|
* **Example** (Checking whether some element matches)
|
|
4277
4145
|
*
|
|
4278
|
-
* ```ts
|
|
4146
|
+
* ```ts import.meta.vitest
|
|
4279
4147
|
* import { Iterable } from "effect"
|
|
4280
4148
|
*
|
|
4281
4149
|
* const numbers = [1, 3, 5, 7, 8]
|
|
4282
4150
|
* const hasEven = Iterable.some(numbers, (x) => x % 2 === 0)
|
|
4283
|
-
*
|
|
4151
|
+
* hasEven // => true
|
|
4284
4152
|
*
|
|
4285
4153
|
* const allOdd = [1, 3, 5, 7]
|
|
4286
4154
|
* const hasEvenInAllOdd = Iterable.some(allOdd, (x) => x % 2 === 0)
|
|
4287
|
-
*
|
|
4155
|
+
* hasEvenInAllOdd // => false
|
|
4288
4156
|
*
|
|
4289
4157
|
* // With index
|
|
4290
4158
|
* const letters = ["a", "b", "c"]
|
|
4291
4159
|
* const hasElementAtIndex2 = Iterable.some(letters, (_, i) => i === 2)
|
|
4292
|
-
*
|
|
4160
|
+
* hasElementAtIndex2 // => true
|
|
4293
4161
|
*
|
|
4294
4162
|
* // Early termination - stops at first match
|
|
4295
4163
|
* const infiniteOdds = Iterable.filter(Iterable.range(1), (x) => x % 2 === 1)
|
|
@@ -4297,7 +4165,7 @@ export const some: {
|
|
|
4297
4165
|
* Iterable.take(infiniteOdds, 1000),
|
|
4298
4166
|
* (x) => x % 2 === 0
|
|
4299
4167
|
* )
|
|
4300
|
-
*
|
|
4168
|
+
* hasEvenInInfiniteOdds // => false
|
|
4301
4169
|
*
|
|
4302
4170
|
* // Type guard usage
|
|
4303
4171
|
* const mixed: Array<string | number> = [1, 2, "hello"]
|
|
@@ -4305,10 +4173,10 @@ export const some: {
|
|
|
4305
4173
|
* mixed,
|
|
4306
4174
|
* (x): x is string => typeof x === "string"
|
|
4307
4175
|
* )
|
|
4308
|
-
*
|
|
4176
|
+
* hasString // => true
|
|
4309
4177
|
* ```
|
|
4310
4178
|
*
|
|
4311
|
-
* @category
|
|
4179
|
+
* @category predicates
|
|
4312
4180
|
* @since 2.0.0
|
|
4313
4181
|
*/
|
|
4314
4182
|
<A>(predicate: (a: A, i: number) => boolean): (self: Iterable<A>) => boolean
|
|
@@ -4317,21 +4185,21 @@ export const some: {
|
|
|
4317
4185
|
*
|
|
4318
4186
|
* **Example** (Checking whether some element matches)
|
|
4319
4187
|
*
|
|
4320
|
-
* ```ts
|
|
4188
|
+
* ```ts import.meta.vitest
|
|
4321
4189
|
* import { Iterable } from "effect"
|
|
4322
4190
|
*
|
|
4323
4191
|
* const numbers = [1, 3, 5, 7, 8]
|
|
4324
4192
|
* const hasEven = Iterable.some(numbers, (x) => x % 2 === 0)
|
|
4325
|
-
*
|
|
4193
|
+
* hasEven // => true
|
|
4326
4194
|
*
|
|
4327
4195
|
* const allOdd = [1, 3, 5, 7]
|
|
4328
4196
|
* const hasEvenInAllOdd = Iterable.some(allOdd, (x) => x % 2 === 0)
|
|
4329
|
-
*
|
|
4197
|
+
* hasEvenInAllOdd // => false
|
|
4330
4198
|
*
|
|
4331
4199
|
* // With index
|
|
4332
4200
|
* const letters = ["a", "b", "c"]
|
|
4333
4201
|
* const hasElementAtIndex2 = Iterable.some(letters, (_, i) => i === 2)
|
|
4334
|
-
*
|
|
4202
|
+
* hasElementAtIndex2 // => true
|
|
4335
4203
|
*
|
|
4336
4204
|
* // Early termination - stops at first match
|
|
4337
4205
|
* const infiniteOdds = Iterable.filter(Iterable.range(1), (x) => x % 2 === 1)
|
|
@@ -4339,7 +4207,7 @@ export const some: {
|
|
|
4339
4207
|
* Iterable.take(infiniteOdds, 1000),
|
|
4340
4208
|
* (x) => x % 2 === 0
|
|
4341
4209
|
* )
|
|
4342
|
-
*
|
|
4210
|
+
* hasEvenInInfiniteOdds // => false
|
|
4343
4211
|
*
|
|
4344
4212
|
* // Type guard usage
|
|
4345
4213
|
* const mixed: Array<string | number> = [1, 2, "hello"]
|
|
@@ -4347,10 +4215,10 @@ export const some: {
|
|
|
4347
4215
|
* mixed,
|
|
4348
4216
|
* (x): x is string => typeof x === "string"
|
|
4349
4217
|
* )
|
|
4350
|
-
*
|
|
4218
|
+
* hasString // => true
|
|
4351
4219
|
* ```
|
|
4352
4220
|
*
|
|
4353
|
-
* @category
|
|
4221
|
+
* @category predicates
|
|
4354
4222
|
* @since 2.0.0
|
|
4355
4223
|
*/
|
|
4356
4224
|
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): boolean
|
|
@@ -4379,21 +4247,21 @@ export const some: {
|
|
|
4379
4247
|
*
|
|
4380
4248
|
* **Example** (Unfolding state into values)
|
|
4381
4249
|
*
|
|
4382
|
-
* ```ts
|
|
4250
|
+
* ```ts import.meta.vitest
|
|
4383
4251
|
* import { Iterable, Option } from "effect"
|
|
4384
4252
|
*
|
|
4385
4253
|
* // Generate Fibonacci sequence
|
|
4386
4254
|
* const fibonacci = Iterable.unfold([0, 1], ([a, b]) => Option.some([a, [b, a + b]]))
|
|
4387
4255
|
* const first10Fib = Iterable.take(fibonacci, 10)
|
|
4388
|
-
*
|
|
4256
|
+
* Array.from(first10Fib) // => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
|
4389
4257
|
*
|
|
4390
4258
|
* // Generate powers of 2 up to a limit
|
|
4391
4259
|
* const powersOf2 = Iterable.unfold(1, (n) => n <= 1000 ? Option.some([n, n * 2]) : Option.none())
|
|
4392
|
-
*
|
|
4260
|
+
* Array.from(powersOf2) // => [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
|
|
4393
4261
|
*
|
|
4394
4262
|
* // Generate countdown
|
|
4395
4263
|
* const countdown = Iterable.unfold(5, (n) => n > 0 ? Option.some([n, n - 1]) : Option.none())
|
|
4396
|
-
*
|
|
4264
|
+
* Array.from(countdown) // => [5, 4, 3, 2, 1]
|
|
4397
4265
|
*
|
|
4398
4266
|
* // Generate collatz sequence
|
|
4399
4267
|
* const collatz = Iterable.unfold(7, (n) => {
|
|
@@ -4401,7 +4269,7 @@ export const some: {
|
|
|
4401
4269
|
* const next = n % 2 === 0 ? n / 2 : n * 3 + 1
|
|
4402
4270
|
* return Option.some([n, next])
|
|
4403
4271
|
* })
|
|
4404
|
-
*
|
|
4272
|
+
* Array.from(collatz) // => [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]
|
|
4405
4273
|
* ```
|
|
4406
4274
|
*
|
|
4407
4275
|
* @category constructors
|
|
@@ -4429,37 +4297,40 @@ export const unfold = <B, A>(b: B, f: (b: B) => Option<readonly [A, B]>): Iterab
|
|
|
4429
4297
|
*
|
|
4430
4298
|
* **Example** (Iterating with side effects)
|
|
4431
4299
|
*
|
|
4432
|
-
* ```ts
|
|
4300
|
+
* ```ts import.meta.vitest
|
|
4433
4301
|
* import { Iterable } from "effect"
|
|
4434
4302
|
*
|
|
4435
|
-
* //
|
|
4303
|
+
* // Collect each visited element
|
|
4436
4304
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4437
|
-
*
|
|
4438
|
-
*
|
|
4305
|
+
* const visited: Array<number> = []
|
|
4306
|
+
* Iterable.forEach(numbers, (n) => visited.push(n))
|
|
4307
|
+
* visited // => [1, 2, 3, 4, 5]
|
|
4439
4308
|
*
|
|
4440
4309
|
* // Use index in the callback
|
|
4441
4310
|
* const letters = ["a", "b", "c"]
|
|
4311
|
+
* const indexed: Array<string> = []
|
|
4442
4312
|
* Iterable.forEach(letters, (letter, i) => {
|
|
4443
|
-
*
|
|
4313
|
+
* indexed.push(`${i}: ${letter}`)
|
|
4444
4314
|
* })
|
|
4445
|
-
* //
|
|
4315
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4446
4316
|
*
|
|
4447
4317
|
* // Side effects with any iterable
|
|
4448
4318
|
* const results: Array<number> = []
|
|
4449
4319
|
* Iterable.forEach(Iterable.range(1, 5), (n) => {
|
|
4450
4320
|
* results.push(n * n)
|
|
4451
4321
|
* })
|
|
4452
|
-
*
|
|
4322
|
+
* results // => [1, 4, 9, 16, 25]
|
|
4453
4323
|
*
|
|
4454
4324
|
* // Process in chunks
|
|
4455
4325
|
* const data = Iterable.chunksOf([1, 2, 3, 4, 5, 6], 2)
|
|
4326
|
+
* const processed: Array<Array<number>> = []
|
|
4456
4327
|
* Iterable.forEach(data, (chunk) => {
|
|
4457
|
-
*
|
|
4328
|
+
* processed.push(Array.from(chunk))
|
|
4458
4329
|
* })
|
|
4459
|
-
* //
|
|
4330
|
+
* processed // => [[1, 2], [3, 4], [5, 6]]
|
|
4460
4331
|
* ```
|
|
4461
4332
|
*
|
|
4462
|
-
* @category
|
|
4333
|
+
* @category traversing
|
|
4463
4334
|
* @since 2.0.0
|
|
4464
4335
|
*/
|
|
4465
4336
|
export const forEach: {
|
|
@@ -4468,37 +4339,40 @@ export const forEach: {
|
|
|
4468
4339
|
*
|
|
4469
4340
|
* **Example** (Iterating with side effects)
|
|
4470
4341
|
*
|
|
4471
|
-
* ```ts
|
|
4342
|
+
* ```ts import.meta.vitest
|
|
4472
4343
|
* import { Iterable } from "effect"
|
|
4473
4344
|
*
|
|
4474
|
-
* //
|
|
4345
|
+
* // Collect each visited element
|
|
4475
4346
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4476
|
-
*
|
|
4477
|
-
*
|
|
4347
|
+
* const visited: Array<number> = []
|
|
4348
|
+
* Iterable.forEach(numbers, (n) => visited.push(n))
|
|
4349
|
+
* visited // => [1, 2, 3, 4, 5]
|
|
4478
4350
|
*
|
|
4479
4351
|
* // Use index in the callback
|
|
4480
4352
|
* const letters = ["a", "b", "c"]
|
|
4353
|
+
* const indexed: Array<string> = []
|
|
4481
4354
|
* Iterable.forEach(letters, (letter, i) => {
|
|
4482
|
-
*
|
|
4355
|
+
* indexed.push(`${i}: ${letter}`)
|
|
4483
4356
|
* })
|
|
4484
|
-
* //
|
|
4357
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4485
4358
|
*
|
|
4486
4359
|
* // Side effects with any iterable
|
|
4487
4360
|
* const results: Array<number> = []
|
|
4488
4361
|
* Iterable.forEach(Iterable.range(1, 5), (n) => {
|
|
4489
4362
|
* results.push(n * n)
|
|
4490
4363
|
* })
|
|
4491
|
-
*
|
|
4364
|
+
* results // => [1, 4, 9, 16, 25]
|
|
4492
4365
|
*
|
|
4493
4366
|
* // Process in chunks
|
|
4494
4367
|
* const data = Iterable.chunksOf([1, 2, 3, 4, 5, 6], 2)
|
|
4368
|
+
* const processed: Array<Array<number>> = []
|
|
4495
4369
|
* Iterable.forEach(data, (chunk) => {
|
|
4496
|
-
*
|
|
4370
|
+
* processed.push(Array.from(chunk))
|
|
4497
4371
|
* })
|
|
4498
|
-
* //
|
|
4372
|
+
* processed // => [[1, 2], [3, 4], [5, 6]]
|
|
4499
4373
|
* ```
|
|
4500
4374
|
*
|
|
4501
|
-
* @category
|
|
4375
|
+
* @category traversing
|
|
4502
4376
|
* @since 2.0.0
|
|
4503
4377
|
*/
|
|
4504
4378
|
<A>(f: (a: A, i: number) => void): (self: Iterable<A>) => void
|
|
@@ -4507,37 +4381,40 @@ export const forEach: {
|
|
|
4507
4381
|
*
|
|
4508
4382
|
* **Example** (Iterating with side effects)
|
|
4509
4383
|
*
|
|
4510
|
-
* ```ts
|
|
4384
|
+
* ```ts import.meta.vitest
|
|
4511
4385
|
* import { Iterable } from "effect"
|
|
4512
4386
|
*
|
|
4513
|
-
* //
|
|
4387
|
+
* // Collect each visited element
|
|
4514
4388
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4515
|
-
*
|
|
4516
|
-
*
|
|
4389
|
+
* const visited: Array<number> = []
|
|
4390
|
+
* Iterable.forEach(numbers, (n) => visited.push(n))
|
|
4391
|
+
* visited // => [1, 2, 3, 4, 5]
|
|
4517
4392
|
*
|
|
4518
4393
|
* // Use index in the callback
|
|
4519
4394
|
* const letters = ["a", "b", "c"]
|
|
4395
|
+
* const indexed: Array<string> = []
|
|
4520
4396
|
* Iterable.forEach(letters, (letter, i) => {
|
|
4521
|
-
*
|
|
4397
|
+
* indexed.push(`${i}: ${letter}`)
|
|
4522
4398
|
* })
|
|
4523
|
-
* //
|
|
4399
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4524
4400
|
*
|
|
4525
4401
|
* // Side effects with any iterable
|
|
4526
4402
|
* const results: Array<number> = []
|
|
4527
4403
|
* Iterable.forEach(Iterable.range(1, 5), (n) => {
|
|
4528
4404
|
* results.push(n * n)
|
|
4529
4405
|
* })
|
|
4530
|
-
*
|
|
4406
|
+
* results // => [1, 4, 9, 16, 25]
|
|
4531
4407
|
*
|
|
4532
4408
|
* // Process in chunks
|
|
4533
4409
|
* const data = Iterable.chunksOf([1, 2, 3, 4, 5, 6], 2)
|
|
4410
|
+
* const processed: Array<Array<number>> = []
|
|
4534
4411
|
* Iterable.forEach(data, (chunk) => {
|
|
4535
|
-
*
|
|
4412
|
+
* processed.push(Array.from(chunk))
|
|
4536
4413
|
* })
|
|
4537
|
-
* //
|
|
4414
|
+
* processed // => [[1, 2], [3, 4], [5, 6]]
|
|
4538
4415
|
* ```
|
|
4539
4416
|
*
|
|
4540
|
-
* @category
|
|
4417
|
+
* @category traversing
|
|
4541
4418
|
* @since 2.0.0
|
|
4542
4419
|
*/
|
|
4543
4420
|
<A>(self: Iterable<A>, f: (a: A, i: number) => void): void
|
|
@@ -4558,18 +4435,17 @@ export const forEach: {
|
|
|
4558
4435
|
*
|
|
4559
4436
|
* **Example** (Reducing an iterable)
|
|
4560
4437
|
*
|
|
4561
|
-
* ```ts
|
|
4438
|
+
* ```ts import.meta.vitest
|
|
4562
4439
|
* import { Iterable } from "effect"
|
|
4563
4440
|
*
|
|
4564
4441
|
* // Sum all numbers
|
|
4565
4442
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4566
4443
|
* const sum = Iterable.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4567
|
-
*
|
|
4444
|
+
* sum // => 15
|
|
4568
4445
|
*
|
|
4569
4446
|
* // Find maximum value
|
|
4570
4447
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
4571
|
-
*
|
|
4572
|
-
* console.log(max) // 9
|
|
4448
|
+
* Iterable.reduce(values, -Infinity, (max, value) => Math.max(max, value)) // => 9
|
|
4573
4449
|
*
|
|
4574
4450
|
* // Build an object from key-value pairs
|
|
4575
4451
|
* const pairs = [["a", 1], ["b", 2], ["c", 3]] as const
|
|
@@ -4581,7 +4457,7 @@ export const forEach: {
|
|
|
4581
4457
|
* return acc
|
|
4582
4458
|
* }
|
|
4583
4459
|
* )
|
|
4584
|
-
*
|
|
4460
|
+
* obj // => { a: 1, b: 2, c: 3 }
|
|
4585
4461
|
*
|
|
4586
4462
|
* // Use index in the reducer
|
|
4587
4463
|
* const letters = ["a", "b", "c"]
|
|
@@ -4593,7 +4469,7 @@ export const forEach: {
|
|
|
4593
4469
|
* return acc
|
|
4594
4470
|
* }
|
|
4595
4471
|
* )
|
|
4596
|
-
*
|
|
4472
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4597
4473
|
* ```
|
|
4598
4474
|
*
|
|
4599
4475
|
* @category folding
|
|
@@ -4610,18 +4486,17 @@ export const reduce: {
|
|
|
4610
4486
|
*
|
|
4611
4487
|
* **Example** (Reducing an iterable)
|
|
4612
4488
|
*
|
|
4613
|
-
* ```ts
|
|
4489
|
+
* ```ts import.meta.vitest
|
|
4614
4490
|
* import { Iterable } from "effect"
|
|
4615
4491
|
*
|
|
4616
4492
|
* // Sum all numbers
|
|
4617
4493
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4618
4494
|
* const sum = Iterable.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4619
|
-
*
|
|
4495
|
+
* sum // => 15
|
|
4620
4496
|
*
|
|
4621
4497
|
* // Find maximum value
|
|
4622
4498
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
4623
|
-
*
|
|
4624
|
-
* console.log(max) // 9
|
|
4499
|
+
* Iterable.reduce(values, -Infinity, (max, value) => Math.max(max, value)) // => 9
|
|
4625
4500
|
*
|
|
4626
4501
|
* // Build an object from key-value pairs
|
|
4627
4502
|
* const pairs = [["a", 1], ["b", 2], ["c", 3]] as const
|
|
@@ -4633,7 +4508,7 @@ export const reduce: {
|
|
|
4633
4508
|
* return acc
|
|
4634
4509
|
* }
|
|
4635
4510
|
* )
|
|
4636
|
-
*
|
|
4511
|
+
* obj // => { a: 1, b: 2, c: 3 }
|
|
4637
4512
|
*
|
|
4638
4513
|
* // Use index in the reducer
|
|
4639
4514
|
* const letters = ["a", "b", "c"]
|
|
@@ -4645,7 +4520,7 @@ export const reduce: {
|
|
|
4645
4520
|
* return acc
|
|
4646
4521
|
* }
|
|
4647
4522
|
* )
|
|
4648
|
-
*
|
|
4523
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4649
4524
|
* ```
|
|
4650
4525
|
*
|
|
4651
4526
|
* @category folding
|
|
@@ -4662,18 +4537,17 @@ export const reduce: {
|
|
|
4662
4537
|
*
|
|
4663
4538
|
* **Example** (Reducing an iterable)
|
|
4664
4539
|
*
|
|
4665
|
-
* ```ts
|
|
4540
|
+
* ```ts import.meta.vitest
|
|
4666
4541
|
* import { Iterable } from "effect"
|
|
4667
4542
|
*
|
|
4668
4543
|
* // Sum all numbers
|
|
4669
4544
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4670
4545
|
* const sum = Iterable.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4671
|
-
*
|
|
4546
|
+
* sum // => 15
|
|
4672
4547
|
*
|
|
4673
4548
|
* // Find maximum value
|
|
4674
4549
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
4675
|
-
*
|
|
4676
|
-
* console.log(max) // 9
|
|
4550
|
+
* Iterable.reduce(values, -Infinity, (max, value) => Math.max(max, value)) // => 9
|
|
4677
4551
|
*
|
|
4678
4552
|
* // Build an object from key-value pairs
|
|
4679
4553
|
* const pairs = [["a", 1], ["b", 2], ["c", 3]] as const
|
|
@@ -4685,7 +4559,7 @@ export const reduce: {
|
|
|
4685
4559
|
* return acc
|
|
4686
4560
|
* }
|
|
4687
4561
|
* )
|
|
4688
|
-
*
|
|
4562
|
+
* obj // => { a: 1, b: 2, c: 3 }
|
|
4689
4563
|
*
|
|
4690
4564
|
* // Use index in the reducer
|
|
4691
4565
|
* const letters = ["a", "b", "c"]
|
|
@@ -4697,7 +4571,7 @@ export const reduce: {
|
|
|
4697
4571
|
* return acc
|
|
4698
4572
|
* }
|
|
4699
4573
|
* )
|
|
4700
|
-
*
|
|
4574
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4701
4575
|
* ```
|
|
4702
4576
|
*
|
|
4703
4577
|
* @category folding
|
|
@@ -4721,20 +4595,20 @@ export const reduce: {
|
|
|
4721
4595
|
*
|
|
4722
4596
|
* **Example** (Deduplicating adjacent elements with custom equivalence)
|
|
4723
4597
|
*
|
|
4724
|
-
* ```ts
|
|
4598
|
+
* ```ts import.meta.vitest
|
|
4725
4599
|
* import { Iterable } from "effect"
|
|
4726
4600
|
*
|
|
4727
4601
|
* // Remove adjacent duplicates with custom equality
|
|
4728
4602
|
* const numbers = [1, 1, 2, 2, 3, 1, 1]
|
|
4729
4603
|
* const dedupedNumbers = Iterable.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
4730
|
-
*
|
|
4604
|
+
* Array.from(dedupedNumbers) // => [1, 2, 3, 1]
|
|
4731
4605
|
*
|
|
4732
4606
|
* // Case-insensitive deduplication
|
|
4733
4607
|
* const words = ["Hello", "HELLO", "world", "World", "test"]
|
|
4734
4608
|
* const caseInsensitive = (a: string, b: string) =>
|
|
4735
4609
|
* a.toLowerCase() === b.toLowerCase()
|
|
4736
4610
|
* const dedupedWords = Iterable.dedupeAdjacentWith(words, caseInsensitive)
|
|
4737
|
-
*
|
|
4611
|
+
* Array.from(dedupedWords) // => ["Hello", "world", "test"]
|
|
4738
4612
|
*
|
|
4739
4613
|
* // Deduplication by object property
|
|
4740
4614
|
* const users = [
|
|
@@ -4746,13 +4620,13 @@ export const reduce: {
|
|
|
4746
4620
|
* ]
|
|
4747
4621
|
* const byId = (a: typeof users[0], b: typeof users[0]) => a.id === b.id
|
|
4748
4622
|
* const dedupedUsers = Iterable.dedupeAdjacentWith(users, byId)
|
|
4749
|
-
*
|
|
4623
|
+
* Array.from(dedupedUsers, (user) => user.id) // => [1, 2, 3]
|
|
4750
4624
|
*
|
|
4751
4625
|
* // Approximate numeric equality
|
|
4752
4626
|
* const floats = [1.0, 1.01, 1.02, 2.0, 2.01, 3.0]
|
|
4753
4627
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
4754
4628
|
* const dedupedFloats = Iterable.dedupeAdjacentWith(floats, approxEqual)
|
|
4755
|
-
*
|
|
4629
|
+
* Array.from(dedupedFloats) // => [1, 2, 3]
|
|
4756
4630
|
* ```
|
|
4757
4631
|
*
|
|
4758
4632
|
* @category filtering
|
|
@@ -4764,20 +4638,20 @@ export const dedupeAdjacentWith: {
|
|
|
4764
4638
|
*
|
|
4765
4639
|
* **Example** (Deduplicating adjacent elements with custom equivalence)
|
|
4766
4640
|
*
|
|
4767
|
-
* ```ts
|
|
4641
|
+
* ```ts import.meta.vitest
|
|
4768
4642
|
* import { Iterable } from "effect"
|
|
4769
4643
|
*
|
|
4770
4644
|
* // Remove adjacent duplicates with custom equality
|
|
4771
4645
|
* const numbers = [1, 1, 2, 2, 3, 1, 1]
|
|
4772
4646
|
* const dedupedNumbers = Iterable.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
4773
|
-
*
|
|
4647
|
+
* Array.from(dedupedNumbers) // => [1, 2, 3, 1]
|
|
4774
4648
|
*
|
|
4775
4649
|
* // Case-insensitive deduplication
|
|
4776
4650
|
* const words = ["Hello", "HELLO", "world", "World", "test"]
|
|
4777
4651
|
* const caseInsensitive = (a: string, b: string) =>
|
|
4778
4652
|
* a.toLowerCase() === b.toLowerCase()
|
|
4779
4653
|
* const dedupedWords = Iterable.dedupeAdjacentWith(words, caseInsensitive)
|
|
4780
|
-
*
|
|
4654
|
+
* Array.from(dedupedWords) // => ["Hello", "world", "test"]
|
|
4781
4655
|
*
|
|
4782
4656
|
* // Deduplication by object property
|
|
4783
4657
|
* const users = [
|
|
@@ -4789,13 +4663,13 @@ export const dedupeAdjacentWith: {
|
|
|
4789
4663
|
* ]
|
|
4790
4664
|
* const byId = (a: typeof users[0], b: typeof users[0]) => a.id === b.id
|
|
4791
4665
|
* const dedupedUsers = Iterable.dedupeAdjacentWith(users, byId)
|
|
4792
|
-
*
|
|
4666
|
+
* Array.from(dedupedUsers, (user) => user.id) // => [1, 2, 3]
|
|
4793
4667
|
*
|
|
4794
4668
|
* // Approximate numeric equality
|
|
4795
4669
|
* const floats = [1.0, 1.01, 1.02, 2.0, 2.01, 3.0]
|
|
4796
4670
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
4797
4671
|
* const dedupedFloats = Iterable.dedupeAdjacentWith(floats, approxEqual)
|
|
4798
|
-
*
|
|
4672
|
+
* Array.from(dedupedFloats) // => [1, 2, 3]
|
|
4799
4673
|
* ```
|
|
4800
4674
|
*
|
|
4801
4675
|
* @category filtering
|
|
@@ -4807,20 +4681,20 @@ export const dedupeAdjacentWith: {
|
|
|
4807
4681
|
*
|
|
4808
4682
|
* **Example** (Deduplicating adjacent elements with custom equivalence)
|
|
4809
4683
|
*
|
|
4810
|
-
* ```ts
|
|
4684
|
+
* ```ts import.meta.vitest
|
|
4811
4685
|
* import { Iterable } from "effect"
|
|
4812
4686
|
*
|
|
4813
4687
|
* // Remove adjacent duplicates with custom equality
|
|
4814
4688
|
* const numbers = [1, 1, 2, 2, 3, 1, 1]
|
|
4815
4689
|
* const dedupedNumbers = Iterable.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
4816
|
-
*
|
|
4690
|
+
* Array.from(dedupedNumbers) // => [1, 2, 3, 1]
|
|
4817
4691
|
*
|
|
4818
4692
|
* // Case-insensitive deduplication
|
|
4819
4693
|
* const words = ["Hello", "HELLO", "world", "World", "test"]
|
|
4820
4694
|
* const caseInsensitive = (a: string, b: string) =>
|
|
4821
4695
|
* a.toLowerCase() === b.toLowerCase()
|
|
4822
4696
|
* const dedupedWords = Iterable.dedupeAdjacentWith(words, caseInsensitive)
|
|
4823
|
-
*
|
|
4697
|
+
* Array.from(dedupedWords) // => ["Hello", "world", "test"]
|
|
4824
4698
|
*
|
|
4825
4699
|
* // Deduplication by object property
|
|
4826
4700
|
* const users = [
|
|
@@ -4832,13 +4706,13 @@ export const dedupeAdjacentWith: {
|
|
|
4832
4706
|
* ]
|
|
4833
4707
|
* const byId = (a: typeof users[0], b: typeof users[0]) => a.id === b.id
|
|
4834
4708
|
* const dedupedUsers = Iterable.dedupeAdjacentWith(users, byId)
|
|
4835
|
-
*
|
|
4709
|
+
* Array.from(dedupedUsers, (user) => user.id) // => [1, 2, 3]
|
|
4836
4710
|
*
|
|
4837
4711
|
* // Approximate numeric equality
|
|
4838
4712
|
* const floats = [1.0, 1.01, 1.02, 2.0, 2.01, 3.0]
|
|
4839
4713
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
4840
4714
|
* const dedupedFloats = Iterable.dedupeAdjacentWith(floats, approxEqual)
|
|
4841
|
-
*
|
|
4715
|
+
* Array.from(dedupedFloats) // => [1, 2, 3]
|
|
4842
4716
|
* ```
|
|
4843
4717
|
*
|
|
4844
4718
|
* @category filtering
|
|
@@ -4876,18 +4750,18 @@ export const dedupeAdjacentWith: {
|
|
|
4876
4750
|
*
|
|
4877
4751
|
* **Example** (Deduplicating adjacent elements)
|
|
4878
4752
|
*
|
|
4879
|
-
* ```ts
|
|
4753
|
+
* ```ts import.meta.vitest
|
|
4880
4754
|
* import { Iterable } from "effect"
|
|
4881
4755
|
*
|
|
4882
4756
|
* // Remove adjacent duplicate numbers
|
|
4883
4757
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
4884
4758
|
* const deduped = Iterable.dedupeAdjacent(numbers)
|
|
4885
|
-
*
|
|
4759
|
+
* Array.from(deduped) // => [1, 2, 3, 1]
|
|
4886
4760
|
*
|
|
4887
4761
|
* // Remove adjacent duplicate characters
|
|
4888
4762
|
* const letters = "aabbccaa"
|
|
4889
4763
|
* const dedupedLetters = Iterable.dedupeAdjacent(letters)
|
|
4890
|
-
*
|
|
4764
|
+
* Array.from(dedupedLetters) // => ["a", "b", "c", "a"]
|
|
4891
4765
|
*
|
|
4892
4766
|
* // Works with objects using deep equality
|
|
4893
4767
|
* const objects = [
|
|
@@ -4898,12 +4772,12 @@ export const dedupeAdjacentWith: {
|
|
|
4898
4772
|
* { type: "A" }
|
|
4899
4773
|
* ]
|
|
4900
4774
|
* const dedupedObjects = Iterable.dedupeAdjacent(objects)
|
|
4901
|
-
*
|
|
4775
|
+
* Array.from(dedupedObjects, (object) => object.type) // => ["A", "B", "A"]
|
|
4902
4776
|
*
|
|
4903
4777
|
* // Clean up streaming data
|
|
4904
4778
|
* const sensorData = [100, 100, 100, 101, 101, 102, 102, 102, 100]
|
|
4905
4779
|
* const cleanedData = Iterable.dedupeAdjacent(sensorData)
|
|
4906
|
-
*
|
|
4780
|
+
* Array.from(cleanedData) // => [100, 101, 102, 100]
|
|
4907
4781
|
* ```
|
|
4908
4782
|
*
|
|
4909
4783
|
* @category filtering
|
|
@@ -4916,14 +4790,14 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Iterable<A> = dedupeAdjac
|
|
|
4916
4790
|
*
|
|
4917
4791
|
* **Example** (Combining cartesian products)
|
|
4918
4792
|
*
|
|
4919
|
-
* ```ts
|
|
4793
|
+
* ```ts import.meta.vitest
|
|
4920
4794
|
* import { Iterable } from "effect"
|
|
4921
4795
|
*
|
|
4922
4796
|
* // Create coordinate pairs
|
|
4923
4797
|
* const xs = [1, 2]
|
|
4924
4798
|
* const ys = ["a", "b", "c"]
|
|
4925
4799
|
* const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
|
|
4926
|
-
*
|
|
4800
|
+
* Array.from(coordinates) // => ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
|
|
4927
4801
|
*
|
|
4928
4802
|
* // Generate all combinations of options
|
|
4929
4803
|
* const sizes = ["S", "M", "L"]
|
|
@@ -4933,18 +4807,13 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Iterable<A> = dedupeAdjac
|
|
|
4933
4807
|
* colors,
|
|
4934
4808
|
* (size, color) => ({ size, color })
|
|
4935
4809
|
* )
|
|
4936
|
-
*
|
|
4937
|
-
* // [
|
|
4938
|
-
* // { size: "S", color: "red" }, { size: "S", color: "blue" },
|
|
4939
|
-
* // { size: "M", color: "red" }, { size: "M", color: "blue" },
|
|
4940
|
-
* // { size: "L", color: "red" }, { size: "L", color: "blue" }
|
|
4941
|
-
* // ]
|
|
4810
|
+
* Array.from(products, ({ color, size }) => `${size}:${color}`) // => ["S:red", "S:blue", "M:red", "M:blue", "L:red", "L:blue"]
|
|
4942
4811
|
*
|
|
4943
4812
|
* // Mathematical operations on all pairs
|
|
4944
4813
|
* const a = [1, 2, 3]
|
|
4945
4814
|
* const b = [10, 20]
|
|
4946
4815
|
* const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
|
|
4947
|
-
*
|
|
4816
|
+
* Array.from(mathProducts) // => [10, 20, 20, 40, 30, 60]
|
|
4948
4817
|
*
|
|
4949
4818
|
* // Create test data combinations
|
|
4950
4819
|
* const userTypes = ["admin", "user"]
|
|
@@ -4954,11 +4823,10 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Iterable<A> = dedupeAdjac
|
|
|
4954
4823
|
* features,
|
|
4955
4824
|
* (user, feature) => `${user}_can_${feature}`
|
|
4956
4825
|
* )
|
|
4957
|
-
*
|
|
4958
|
-
* // ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4826
|
+
* Array.from(testCases) // => ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4959
4827
|
* ```
|
|
4960
4828
|
*
|
|
4961
|
-
* @category
|
|
4829
|
+
* @category combining
|
|
4962
4830
|
* @since 2.0.0
|
|
4963
4831
|
*/
|
|
4964
4832
|
export const cartesianWith: {
|
|
@@ -4967,14 +4835,14 @@ export const cartesianWith: {
|
|
|
4967
4835
|
*
|
|
4968
4836
|
* **Example** (Combining cartesian products)
|
|
4969
4837
|
*
|
|
4970
|
-
* ```ts
|
|
4838
|
+
* ```ts import.meta.vitest
|
|
4971
4839
|
* import { Iterable } from "effect"
|
|
4972
4840
|
*
|
|
4973
4841
|
* // Create coordinate pairs
|
|
4974
4842
|
* const xs = [1, 2]
|
|
4975
4843
|
* const ys = ["a", "b", "c"]
|
|
4976
4844
|
* const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
|
|
4977
|
-
*
|
|
4845
|
+
* Array.from(coordinates) // => ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
|
|
4978
4846
|
*
|
|
4979
4847
|
* // Generate all combinations of options
|
|
4980
4848
|
* const sizes = ["S", "M", "L"]
|
|
@@ -4984,18 +4852,13 @@ export const cartesianWith: {
|
|
|
4984
4852
|
* colors,
|
|
4985
4853
|
* (size, color) => ({ size, color })
|
|
4986
4854
|
* )
|
|
4987
|
-
*
|
|
4988
|
-
* // [
|
|
4989
|
-
* // { size: "S", color: "red" }, { size: "S", color: "blue" },
|
|
4990
|
-
* // { size: "M", color: "red" }, { size: "M", color: "blue" },
|
|
4991
|
-
* // { size: "L", color: "red" }, { size: "L", color: "blue" }
|
|
4992
|
-
* // ]
|
|
4855
|
+
* Array.from(products, ({ color, size }) => `${size}:${color}`) // => ["S:red", "S:blue", "M:red", "M:blue", "L:red", "L:blue"]
|
|
4993
4856
|
*
|
|
4994
4857
|
* // Mathematical operations on all pairs
|
|
4995
4858
|
* const a = [1, 2, 3]
|
|
4996
4859
|
* const b = [10, 20]
|
|
4997
4860
|
* const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
|
|
4998
|
-
*
|
|
4861
|
+
* Array.from(mathProducts) // => [10, 20, 20, 40, 30, 60]
|
|
4999
4862
|
*
|
|
5000
4863
|
* // Create test data combinations
|
|
5001
4864
|
* const userTypes = ["admin", "user"]
|
|
@@ -5005,11 +4868,10 @@ export const cartesianWith: {
|
|
|
5005
4868
|
* features,
|
|
5006
4869
|
* (user, feature) => `${user}_can_${feature}`
|
|
5007
4870
|
* )
|
|
5008
|
-
*
|
|
5009
|
-
* // ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4871
|
+
* Array.from(testCases) // => ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
5010
4872
|
* ```
|
|
5011
4873
|
*
|
|
5012
|
-
* @category
|
|
4874
|
+
* @category combining
|
|
5013
4875
|
* @since 2.0.0
|
|
5014
4876
|
*/
|
|
5015
4877
|
<A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>
|
|
@@ -5018,14 +4880,14 @@ export const cartesianWith: {
|
|
|
5018
4880
|
*
|
|
5019
4881
|
* **Example** (Combining cartesian products)
|
|
5020
4882
|
*
|
|
5021
|
-
* ```ts
|
|
4883
|
+
* ```ts import.meta.vitest
|
|
5022
4884
|
* import { Iterable } from "effect"
|
|
5023
4885
|
*
|
|
5024
4886
|
* // Create coordinate pairs
|
|
5025
4887
|
* const xs = [1, 2]
|
|
5026
4888
|
* const ys = ["a", "b", "c"]
|
|
5027
4889
|
* const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
|
|
5028
|
-
*
|
|
4890
|
+
* Array.from(coordinates) // => ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
|
|
5029
4891
|
*
|
|
5030
4892
|
* // Generate all combinations of options
|
|
5031
4893
|
* const sizes = ["S", "M", "L"]
|
|
@@ -5035,18 +4897,13 @@ export const cartesianWith: {
|
|
|
5035
4897
|
* colors,
|
|
5036
4898
|
* (size, color) => ({ size, color })
|
|
5037
4899
|
* )
|
|
5038
|
-
*
|
|
5039
|
-
* // [
|
|
5040
|
-
* // { size: "S", color: "red" }, { size: "S", color: "blue" },
|
|
5041
|
-
* // { size: "M", color: "red" }, { size: "M", color: "blue" },
|
|
5042
|
-
* // { size: "L", color: "red" }, { size: "L", color: "blue" }
|
|
5043
|
-
* // ]
|
|
4900
|
+
* Array.from(products, ({ color, size }) => `${size}:${color}`) // => ["S:red", "S:blue", "M:red", "M:blue", "L:red", "L:blue"]
|
|
5044
4901
|
*
|
|
5045
4902
|
* // Mathematical operations on all pairs
|
|
5046
4903
|
* const a = [1, 2, 3]
|
|
5047
4904
|
* const b = [10, 20]
|
|
5048
4905
|
* const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
|
|
5049
|
-
*
|
|
4906
|
+
* Array.from(mathProducts) // => [10, 20, 20, 40, 30, 60]
|
|
5050
4907
|
*
|
|
5051
4908
|
* // Create test data combinations
|
|
5052
4909
|
* const userTypes = ["admin", "user"]
|
|
@@ -5056,11 +4913,10 @@ export const cartesianWith: {
|
|
|
5056
4913
|
* features,
|
|
5057
4914
|
* (user, feature) => `${user}_can_${feature}`
|
|
5058
4915
|
* )
|
|
5059
|
-
*
|
|
5060
|
-
* // ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4916
|
+
* Array.from(testCases) // => ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
5061
4917
|
* ```
|
|
5062
4918
|
*
|
|
5063
|
-
* @category
|
|
4919
|
+
* @category combining
|
|
5064
4920
|
* @since 2.0.0
|
|
5065
4921
|
*/
|
|
5066
4922
|
<A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>
|
|
@@ -5105,40 +4961,34 @@ export const cartesianWith: {
|
|
|
5105
4961
|
*
|
|
5106
4962
|
* **Example** (Generating cartesian pairs)
|
|
5107
4963
|
*
|
|
5108
|
-
* ```ts
|
|
4964
|
+
* ```ts import.meta.vitest
|
|
5109
4965
|
* import { Iterable } from "effect"
|
|
5110
4966
|
*
|
|
5111
4967
|
* // All pairs of numbers and letters
|
|
5112
4968
|
* const numbers = [1, 2, 3]
|
|
5113
4969
|
* const letters = ["a", "b"]
|
|
5114
4970
|
* const pairs = Iterable.cartesian(numbers, letters)
|
|
5115
|
-
*
|
|
5116
|
-
* // [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
4971
|
+
* Array.from(pairs) // => [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5117
4972
|
*
|
|
5118
4973
|
* // Generate coordinate grid
|
|
5119
4974
|
* const x = [0, 1, 2]
|
|
5120
4975
|
* const y = [0, 1]
|
|
5121
4976
|
* const grid = Iterable.cartesian(x, y)
|
|
5122
|
-
*
|
|
5123
|
-
* // [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
4977
|
+
* Array.from(grid) // => [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5124
4978
|
*
|
|
5125
4979
|
* // All combinations for testing
|
|
5126
4980
|
* const browsers = ["chrome", "firefox"]
|
|
5127
4981
|
* const devices = ["desktop", "mobile", "tablet"]
|
|
5128
4982
|
* const testMatrix = Iterable.cartesian(browsers, devices)
|
|
5129
|
-
*
|
|
5130
|
-
* // [
|
|
5131
|
-
* // ["chrome", "desktop"], ["chrome", "mobile"], ["chrome", "tablet"],
|
|
5132
|
-
* // ["firefox", "desktop"], ["firefox", "mobile"], ["firefox", "tablet"]
|
|
5133
|
-
* // ]
|
|
4983
|
+
* Array.from(testMatrix, ([browser, device]) => `${browser}:${device}`) // => ["chrome:desktop", "chrome:mobile", "chrome:tablet", "firefox:desktop", "firefox:mobile", "firefox:tablet"]
|
|
5134
4984
|
*
|
|
5135
4985
|
* // Empty iterable results in empty cartesian product
|
|
5136
4986
|
* const empty = Iterable.empty<number>()
|
|
5137
4987
|
* const withEmpty = Iterable.cartesian([1, 2], empty)
|
|
5138
|
-
*
|
|
4988
|
+
* Array.from(withEmpty) // => []
|
|
5139
4989
|
* ```
|
|
5140
4990
|
*
|
|
5141
|
-
* @category
|
|
4991
|
+
* @category combining
|
|
5142
4992
|
* @since 2.0.0
|
|
5143
4993
|
*/
|
|
5144
4994
|
export const cartesian: {
|
|
@@ -5147,40 +4997,34 @@ export const cartesian: {
|
|
|
5147
4997
|
*
|
|
5148
4998
|
* **Example** (Generating cartesian pairs)
|
|
5149
4999
|
*
|
|
5150
|
-
* ```ts
|
|
5000
|
+
* ```ts import.meta.vitest
|
|
5151
5001
|
* import { Iterable } from "effect"
|
|
5152
5002
|
*
|
|
5153
5003
|
* // All pairs of numbers and letters
|
|
5154
5004
|
* const numbers = [1, 2, 3]
|
|
5155
5005
|
* const letters = ["a", "b"]
|
|
5156
5006
|
* const pairs = Iterable.cartesian(numbers, letters)
|
|
5157
|
-
*
|
|
5158
|
-
* // [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5007
|
+
* Array.from(pairs) // => [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5159
5008
|
*
|
|
5160
5009
|
* // Generate coordinate grid
|
|
5161
5010
|
* const x = [0, 1, 2]
|
|
5162
5011
|
* const y = [0, 1]
|
|
5163
5012
|
* const grid = Iterable.cartesian(x, y)
|
|
5164
|
-
*
|
|
5165
|
-
* // [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5013
|
+
* Array.from(grid) // => [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5166
5014
|
*
|
|
5167
5015
|
* // All combinations for testing
|
|
5168
5016
|
* const browsers = ["chrome", "firefox"]
|
|
5169
5017
|
* const devices = ["desktop", "mobile", "tablet"]
|
|
5170
5018
|
* const testMatrix = Iterable.cartesian(browsers, devices)
|
|
5171
|
-
*
|
|
5172
|
-
* // [
|
|
5173
|
-
* // ["chrome", "desktop"], ["chrome", "mobile"], ["chrome", "tablet"],
|
|
5174
|
-
* // ["firefox", "desktop"], ["firefox", "mobile"], ["firefox", "tablet"]
|
|
5175
|
-
* // ]
|
|
5019
|
+
* Array.from(testMatrix, ([browser, device]) => `${browser}:${device}`) // => ["chrome:desktop", "chrome:mobile", "chrome:tablet", "firefox:desktop", "firefox:mobile", "firefox:tablet"]
|
|
5176
5020
|
*
|
|
5177
5021
|
* // Empty iterable results in empty cartesian product
|
|
5178
5022
|
* const empty = Iterable.empty<number>()
|
|
5179
5023
|
* const withEmpty = Iterable.cartesian([1, 2], empty)
|
|
5180
|
-
*
|
|
5024
|
+
* Array.from(withEmpty) // => []
|
|
5181
5025
|
* ```
|
|
5182
5026
|
*
|
|
5183
|
-
* @category
|
|
5027
|
+
* @category combining
|
|
5184
5028
|
* @since 2.0.0
|
|
5185
5029
|
*/
|
|
5186
5030
|
<B>(that: Iterable<B>): <A>(self: Iterable<A>) => Iterable<[A, B]>
|
|
@@ -5189,40 +5033,34 @@ export const cartesian: {
|
|
|
5189
5033
|
*
|
|
5190
5034
|
* **Example** (Generating cartesian pairs)
|
|
5191
5035
|
*
|
|
5192
|
-
* ```ts
|
|
5036
|
+
* ```ts import.meta.vitest
|
|
5193
5037
|
* import { Iterable } from "effect"
|
|
5194
5038
|
*
|
|
5195
5039
|
* // All pairs of numbers and letters
|
|
5196
5040
|
* const numbers = [1, 2, 3]
|
|
5197
5041
|
* const letters = ["a", "b"]
|
|
5198
5042
|
* const pairs = Iterable.cartesian(numbers, letters)
|
|
5199
|
-
*
|
|
5200
|
-
* // [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5043
|
+
* Array.from(pairs) // => [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5201
5044
|
*
|
|
5202
5045
|
* // Generate coordinate grid
|
|
5203
5046
|
* const x = [0, 1, 2]
|
|
5204
5047
|
* const y = [0, 1]
|
|
5205
5048
|
* const grid = Iterable.cartesian(x, y)
|
|
5206
|
-
*
|
|
5207
|
-
* // [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5049
|
+
* Array.from(grid) // => [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5208
5050
|
*
|
|
5209
5051
|
* // All combinations for testing
|
|
5210
5052
|
* const browsers = ["chrome", "firefox"]
|
|
5211
5053
|
* const devices = ["desktop", "mobile", "tablet"]
|
|
5212
5054
|
* const testMatrix = Iterable.cartesian(browsers, devices)
|
|
5213
|
-
*
|
|
5214
|
-
* // [
|
|
5215
|
-
* // ["chrome", "desktop"], ["chrome", "mobile"], ["chrome", "tablet"],
|
|
5216
|
-
* // ["firefox", "desktop"], ["firefox", "mobile"], ["firefox", "tablet"]
|
|
5217
|
-
* // ]
|
|
5055
|
+
* Array.from(testMatrix, ([browser, device]) => `${browser}:${device}`) // => ["chrome:desktop", "chrome:mobile", "chrome:tablet", "firefox:desktop", "firefox:mobile", "firefox:tablet"]
|
|
5218
5056
|
*
|
|
5219
5057
|
* // Empty iterable results in empty cartesian product
|
|
5220
5058
|
* const empty = Iterable.empty<number>()
|
|
5221
5059
|
* const withEmpty = Iterable.cartesian([1, 2], empty)
|
|
5222
|
-
*
|
|
5060
|
+
* Array.from(withEmpty) // => []
|
|
5223
5061
|
* ```
|
|
5224
5062
|
*
|
|
5225
|
-
* @category
|
|
5063
|
+
* @category combining
|
|
5226
5064
|
* @since 2.0.0
|
|
5227
5065
|
*/
|
|
5228
5066
|
<A, B>(self: Iterable<A>, that: Iterable<B>): Iterable<[A, B]>
|
|
@@ -5236,11 +5074,10 @@ export const cartesian: {
|
|
|
5236
5074
|
*
|
|
5237
5075
|
* **Example** (Counting matching elements)
|
|
5238
5076
|
*
|
|
5239
|
-
* ```ts
|
|
5077
|
+
* ```ts import.meta.vitest
|
|
5240
5078
|
* import { Iterable } from "effect"
|
|
5241
5079
|
*
|
|
5242
|
-
*
|
|
5243
|
-
* console.log(result) // 2
|
|
5080
|
+
* Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
5244
5081
|
* ```
|
|
5245
5082
|
*
|
|
5246
5083
|
* @category folding
|
|
@@ -5252,11 +5089,10 @@ export const countBy: {
|
|
|
5252
5089
|
*
|
|
5253
5090
|
* **Example** (Counting matching elements)
|
|
5254
5091
|
*
|
|
5255
|
-
* ```ts
|
|
5092
|
+
* ```ts import.meta.vitest
|
|
5256
5093
|
* import { Iterable } from "effect"
|
|
5257
5094
|
*
|
|
5258
|
-
*
|
|
5259
|
-
* console.log(result) // 2
|
|
5095
|
+
* Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
5260
5096
|
* ```
|
|
5261
5097
|
*
|
|
5262
5098
|
* @category folding
|
|
@@ -5268,11 +5104,10 @@ export const countBy: {
|
|
|
5268
5104
|
*
|
|
5269
5105
|
* **Example** (Counting matching elements)
|
|
5270
5106
|
*
|
|
5271
|
-
* ```ts
|
|
5107
|
+
* ```ts import.meta.vitest
|
|
5272
5108
|
* import { Iterable } from "effect"
|
|
5273
5109
|
*
|
|
5274
|
-
*
|
|
5275
|
-
* console.log(result) // 2
|
|
5110
|
+
* Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
5276
5111
|
* ```
|
|
5277
5112
|
*
|
|
5278
5113
|
* @category folding
|