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