effect 4.0.0-beta.101 → 4.0.0-beta.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +971 -1037
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +462 -412
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +433 -756
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +200 -325
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +207 -267
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +107 -135
- package/dist/BigInt.js.map +1 -1
- package/dist/Boolean.d.ts +146 -188
- package/dist/Boolean.d.ts.map +1 -1
- package/dist/Boolean.js +64 -84
- package/dist/Boolean.js.map +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +405 -254
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +166 -101
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +167 -277
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +122 -176
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +729 -768
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +541 -449
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +834 -1173
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +326 -439
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +180 -49
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +96 -31
- package/dist/Clock.js.map +1 -1
- package/dist/Combiner.d.ts +20 -33
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +18 -30
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +226 -174
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +339 -267
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +194 -68
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +122 -87
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +233 -33
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js +232 -32
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +151 -274
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +171 -214
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +68 -77
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +57 -66
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +13 -15
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +9 -10
- package/dist/Crypto.js.map +1 -1
- package/dist/Data.d.ts +60 -80
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +18 -24
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +562 -660
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +307 -362
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +253 -256
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +104 -96
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +216 -308
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +132 -186
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +2897 -3342
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1383 -1580
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +22 -40
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +22 -40
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +33 -37
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +29 -21
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +103 -105
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +77 -79
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +51 -27
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +50 -26
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +13 -55
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +7 -28
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +116 -192
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +82 -130
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +82 -146
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +48 -87
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +152 -105
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +109 -75
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +213 -168
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +114 -89
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +123 -81
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +85 -59
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +153 -264
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +42 -147
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +61 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +26 -15
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +25 -33
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +48 -49
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +76 -145
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +40 -57
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +360 -714
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +168 -297
- package/dist/Graph.js.map +1 -1
- package/dist/HKT.d.ts +12 -6
- package/dist/HKT.d.ts.map +1 -1
- package/dist/Hash.d.ts +47 -83
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +46 -68
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +319 -411
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +122 -166
- package/dist/HashMap.js.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +1 -0
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +177 -284
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js +68 -109
- package/dist/HashSet.js.map +1 -1
- package/dist/Inspectable.d.ts +12 -12
- package/dist/Inspectable.js +8 -8
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +620 -786
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +230 -307
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts +11 -13
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +46 -103
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +8 -8
- package/dist/JsonPointer.js +8 -8
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +98 -44
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +300 -239
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +23 -35
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +16 -28
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +359 -260
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +195 -175
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +42 -29
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +31 -21
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +6 -2
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +6 -2
- package/dist/LayerRef.js.map +1 -1
- package/dist/LogLevel.d.ts +114 -214
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +41 -76
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +218 -467
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +207 -452
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +16 -5
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +10 -5
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +217 -252
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +150 -183
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +442 -993
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +202 -645
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +144 -173
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +68 -79
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +84 -89
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +44 -47
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +71 -370
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +59 -284
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts +420 -243
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +209 -120
- package/dist/MutableRef.js.map +1 -1
- package/dist/Newtype.d.ts +21 -14
- package/dist/Newtype.d.ts.map +1 -1
- package/dist/Newtype.js +15 -13
- package/dist/Newtype.js.map +1 -1
- package/dist/NonEmptyIterable.d.ts +7 -137
- package/dist/NonEmptyIterable.d.ts.map +1 -1
- package/dist/NonEmptyIterable.js +5 -93
- package/dist/NonEmptyIterable.js.map +1 -1
- package/dist/Number.d.ts +196 -233
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +90 -109
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +97 -189
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +190 -292
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +447 -812
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +213 -393
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +109 -109
- package/dist/Order.js +91 -91
- package/dist/Order.js.map +1 -1
- package/dist/Ordering.d.ts +20 -23
- package/dist/Ordering.d.ts.map +1 -1
- package/dist/Ordering.js +8 -9
- package/dist/Ordering.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -4
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +38 -41
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +3 -4
- package/dist/Path.js.map +1 -1
- package/dist/Pipeable.d.ts +6 -5
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +2 -2
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +4 -4
- package/dist/PlatformError.js +3 -3
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +4 -2
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +4 -2
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +200 -181
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +100 -108
- package/dist/Predicate.js.map +1 -1
- package/dist/PrimaryKey.d.ts +7 -7
- package/dist/PrimaryKey.js +5 -5
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +425 -494
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +373 -362
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts +24 -18
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +11 -9
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +200 -159
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +162 -132
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +49 -74
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +35 -54
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +121 -63
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +42 -21
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +24 -13
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/RcRef.js +15 -9
- package/dist/RcRef.js.map +1 -1
- package/dist/Record.d.ts +361 -466
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +163 -216
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +6 -2
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +7 -2
- package/dist/Redactable.js.map +1 -1
- package/dist/Redacted.d.ts +25 -25
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +19 -20
- package/dist/Redacted.js.map +1 -1
- package/dist/Reducer.d.ts +8 -15
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +6 -12
- package/dist/Reducer.js.map +1 -1
- package/dist/Ref.d.ts +95 -165
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +75 -122
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +102 -213
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +102 -213
- package/dist/References.js.map +1 -1
- package/dist/RegExp.d.ts +10 -14
- package/dist/RegExp.d.ts.map +1 -1
- package/dist/RegExp.js +10 -14
- package/dist/RegExp.js.map +1 -1
- package/dist/Request.d.ts +31 -21
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +25 -19
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +201 -90
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +87 -41
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +302 -470
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +135 -218
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +50 -75
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +39 -60
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +290 -1636
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +162 -803
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +5 -5
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +18 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +1835 -1060
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2708 -1050
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +29 -52
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +537 -391
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +7 -6
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +8 -7
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +230 -185
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +252 -209
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +62 -190
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +74 -266
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +2 -2
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +123 -86
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +398 -1513
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +290 -2854
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +116 -76
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +123 -88
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +123 -151
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +72 -92
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/ScopedRef.d.ts +3 -3
- package/dist/ScopedRef.js +2 -2
- package/dist/ScopedRef.js.map +1 -1
- package/dist/Semaphore.d.ts +101 -13
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +78 -39
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +117 -107
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +107 -100
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +1 -1
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +2430 -2958
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1124 -1397
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +262 -308
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +184 -215
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +109 -114
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +46 -54
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +282 -250
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +104 -92
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Symbol.d.ts +3 -3
- package/dist/Symbol.js +3 -3
- package/dist/Symbol.js.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Take.js.map +1 -1
- package/dist/Terminal.d.ts +2 -2
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +100 -54
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +41 -24
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +287 -679
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +109 -251
- package/dist/Trie.js.map +1 -1
- package/dist/Tuple.d.ts +92 -127
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js +42 -57
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +201 -121
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +85 -56
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +62 -46
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +30 -22
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +631 -779
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +268 -330
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +297 -236
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +130 -100
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +126 -95
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +74 -56
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +101 -88
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +87 -66
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +200 -180
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +160 -136
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +97 -66
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +67 -45
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +51 -32
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +23 -15
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +129 -95
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +85 -70
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +97 -70
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +44 -34
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +127 -70
- package/dist/Types.d.ts.map +1 -1
- package/dist/UndefinedOr.js.map +1 -1
- package/dist/Unify.d.ts +45 -65
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js +6 -9
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +23 -16
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +3 -7
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/array.js.map +1 -1
- package/dist/internal/core.js +3 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +4 -0
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/doNotation.js.map +1 -1
- package/dist/internal/effect.js +141 -61
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/persistence.d.ts +2 -0
- package/dist/internal/persistence.d.ts.map +1 -0
- package/dist/internal/persistence.js +3 -0
- package/dist/internal/persistence.js.map +1 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/record.d.ts +0 -3
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +10 -5
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/redacted.js.map +1 -1
- package/dist/internal/references.js +3 -4
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js +12 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/cause.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +745 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/fromRepresentation.d.ts +2 -0
- package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/fromRepresentation.js +245 -0
- package/dist/internal/schema/fromRepresentation.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +14 -0
- package/dist/internal/schema/parser.d.ts.map +1 -0
- package/dist/internal/schema/parser.js +13 -0
- package/dist/internal/schema/parser.js.map +1 -0
- package/dist/internal/schema/schema.js +28 -40
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
- package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
- package/dist/internal/schema/toArbitrary.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.d.ts +2 -0
- package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +438 -0
- package/dist/internal/schema/toCodeDocument.js.map +1 -0
- package/dist/internal/schema/toEquivalence.d.ts +2 -0
- package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
- package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
- package/dist/internal/schema/toEquivalence.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +508 -0
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/toRepresentation.d.ts +2 -0
- package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/toRepresentation.js +349 -0
- package/dist/internal/schema/toRepresentation.js.map +1 -0
- package/dist/internal/stackTraceLimit.js +3 -6
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +13 -9
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/FastCheck.d.ts +8 -7
- package/dist/testing/FastCheck.d.ts.map +1 -1
- package/dist/testing/FastCheck.js +8 -7
- package/dist/testing/FastCheck.js.map +1 -1
- package/dist/testing/TestClock.d.ts +57 -28
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +54 -19
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +32 -31
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +24 -22
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +29 -29
- package/dist/testing/TestSchema.js +25 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +121 -144
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +99 -121
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +22 -7
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +87 -317
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +132 -97
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +55 -51
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts +32 -28
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +26 -21
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +111 -68
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +123 -81
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpProtocol.d.ts +30 -0
- package/dist/unstable/ai/McpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/McpProtocol.js +20 -0
- package/dist/unstable/ai/McpProtocol.js.map +1 -0
- package/dist/unstable/ai/McpSchema.d.ts +316 -250
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +71 -63
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +71 -62
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +765 -245
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +8 -19
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +9 -20
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +33 -11
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +194 -378
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +112 -38
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +53 -17
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +47 -33
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +23 -18
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts +46 -13
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +18 -7
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +14 -3
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +10 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +63 -44
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +59 -42
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +35 -9
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +32 -14
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +15 -12
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/mcpProtocol.d.ts +21 -0
- package/dist/unstable/ai/internal/mcpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocol.js +22 -0
- package/dist/unstable/ai/internal/mcpProtocol.js.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts +2 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js +32 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js.map +1 -0
- package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
- package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +315 -0
- package/dist/unstable/ai/internal/structured-output.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +273 -69
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +111 -33
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliConfig.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +105 -74
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +98 -63
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +35 -54
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -42
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +705 -107
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +252 -47
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +418 -138
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +197 -71
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +1 -1
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +12 -4
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +292 -78
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +131 -49
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +370 -149
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +345 -137
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -14
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +23 -14
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/auto-suggest.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +3 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +11 -4
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +0 -48
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +8 -10
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/lexer.js +17 -7
- package/dist/unstable/cli/internal/lexer.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +2 -2
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterMetrics.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +8 -8
- package/dist/unstable/cluster/ClusterSchema.js +8 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +6 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +10 -10
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +9 -9
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityId.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts +4 -2
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +4 -2
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/EntityType.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +5 -4
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts +2 -2
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +6 -4
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/MachineId.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +9 -9
- package/dist/unstable/cluster/Message.js +6 -6
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +15 -15
- package/dist/unstable/cluster/MessageStorage.js +5 -5
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +5 -5
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +1 -1
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +2 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +16 -16
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +2 -2
- package/dist/unstable/cluster/RunnerStorage.js +1 -1
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +6 -6
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +19 -10
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +128 -26
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +13 -5
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +3 -3
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/ShardingRegistrationEvent.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js +2 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/Singleton.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +1 -1
- package/dist/unstable/cluster/SingletonAddress.js +1 -1
- package/dist/unstable/cluster/SingletonAddress.js.map +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts +8 -8
- package/dist/unstable/cluster/Snowflake.js +8 -8
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +56 -25
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +127 -65
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/TestRunner.js.map +1 -1
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +24 -12
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/hash.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
- package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/shardLock.js +4 -0
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
- package/dist/unstable/devtools/DevTools.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +8 -5
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/devtools/DevToolsServer.js.map +1 -1
- package/dist/unstable/devtools/index.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +6 -8
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +72 -8
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +58 -8
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +20 -20
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +4 -4
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +16 -16
- package/dist/unstable/eventlog/EventJournal.js +14 -14
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +3 -3
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +18 -14
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +2 -2
- package/dist/unstable/eventlog/EventLogEncryption.js +2 -2
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +6 -6
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +9 -4
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/eventlog/EventLogRemote.js +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +11 -2
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +45 -21
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +4 -4
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +13 -5
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +5 -5
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +14 -6
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +2 -2
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +54 -40
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +1 -1
- package/dist/unstable/http/Etag.js +1 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +2 -2
- package/dist/unstable/http/Headers.js +10 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +5 -3
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +11 -5
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +51 -44
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +46 -17
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +16 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +4 -4
- package/dist/unstable/http/HttpClientResponse.js +2 -2
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +6 -6
- package/dist/unstable/http/HttpEffect.js +3 -3
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +6 -9
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +6 -9
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +75 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +164 -39
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +76 -0
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +32 -0
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +88 -89
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +78 -79
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +13 -13
- package/dist/unstable/http/HttpServer.js +6 -6
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -2
- package/dist/unstable/http/HttpServerError.js +2 -2
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +4 -4
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +9 -8
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +22 -0
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +10 -0
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +35 -7
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +35 -7
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +6 -6
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +22 -20
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +33 -63
- package/dist/unstable/http/Url.d.ts.map +1 -1
- package/dist/unstable/http/Url.js +14 -28
- package/dist/unstable/http/Url.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +10 -18
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +26 -31
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.d.ts +2 -0
- package/dist/unstable/http/internal/compression.d.ts.map +1 -0
- package/dist/unstable/http/internal/compression.js +155 -0
- package/dist/unstable/http/internal/compression.js.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +3 -3
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +10 -11
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -5
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +16 -18
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +42 -42
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +13 -13
- package/dist/unstable/httpapi/HttpApiError.js +13 -13
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +15 -15
- package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +71 -24
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +57 -10
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +0 -12
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +6 -6
- package/dist/unstable/httpapi/HttpApiSchema.js +4 -4
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +13 -13
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +50 -37
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/index.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -1
- package/dist/unstable/observability/Otlp.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +70 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +84 -6
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +2 -2
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +11 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +5 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts +16 -7
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +21 -12
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +2 -2
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +13 -4
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +10 -3
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/index.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +3 -0
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +8 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +22 -13
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +8 -8
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +2 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +6 -6
- package/dist/unstable/persistence/PersistedQueue.js +6 -6
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +3 -3
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +91 -15
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +28 -17
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +26 -15
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +2 -2
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +3 -3
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/persistence/index.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +64 -21
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +14 -5
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +21 -10
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +4 -2
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/process/index.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +8 -8
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +14 -13
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +105 -19
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +44 -12
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +4 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRef.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +25 -4
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +4 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +1 -1
- package/dist/unstable/reactivity/Hydration.js +1 -1
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +35 -33
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -2
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +12 -12
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +14 -12
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +8 -8
- package/dist/unstable/rpc/RpcGroup.js +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +31 -30
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +6 -6
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +10 -10
- package/dist/unstable/rpc/RpcMiddleware.js +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +4 -4
- package/dist/unstable/rpc/RpcSchema.js +3 -3
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +58 -7
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +175 -96
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +13 -13
- package/dist/unstable/rpc/RpcServer.js +17 -13
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcTest.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +5 -5
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/rpc/index.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +52 -50
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +35 -33
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +6 -7
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +15 -12
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/schema/index.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +12 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +10 -5
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/socket/index.js.map +1 -1
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +2 -2
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.js +2 -2
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.js +2 -2
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +5 -5
- package/dist/unstable/sql/SqlResolver.js +2 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/SqlStream.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +6 -6
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +22 -21
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/sql/index.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +2 -2
- package/dist/unstable/workers/Worker.js +2 -2
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +7 -7
- package/dist/unstable/workers/WorkerError.js +6 -6
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workers/WorkerRunner.d.ts +1 -1
- package/dist/unstable/workers/WorkerRunner.js +1 -1
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workers/index.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.js +2 -2
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +10 -10
- package/dist/unstable/workflow/DurableDeferred.js +5 -5
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +22 -20
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +22 -20
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +21 -21
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +13 -14
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +4 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/dist/unstable/workflow/index.js.map +1 -1
- package/dist/unstable/workflow/internal/crypto.js.map +1 -1
- package/package.json +5 -6
- package/src/Array.ts +1068 -1070
- package/src/BigDecimal.ts +433 -756
- package/src/BigInt.ts +213 -269
- package/src/Boolean.ts +146 -188
- package/src/Cache.ts +409 -255
- package/src/Cause.ts +167 -277
- package/src/Channel.ts +923 -830
- package/src/ChannelSchema.ts +1 -1
- package/src/Chunk.ts +841 -1181
- package/src/Clock.ts +181 -49
- package/src/Combiner.ts +20 -33
- package/src/Config.ts +618 -334
- package/src/ConfigProvider.ts +221 -127
- package/src/Console.ts +289 -39
- package/src/Context.ts +319 -378
- package/src/Cron.ts +68 -77
- package/src/Crypto.ts +13 -15
- package/src/Data.ts +63 -82
- package/src/DateTime.ts +564 -660
- package/src/Deferred.ts +253 -256
- package/src/Duration.ts +216 -308
- package/src/Effect.ts +2958 -3390
- package/src/Encoding.ts +22 -40
- package/src/Equal.ts +49 -39
- package/src/Equivalence.ts +103 -105
- package/src/ErrorReporter.ts +51 -27
- package/src/ExecutionPlan.ts +13 -55
- package/src/Exit.ts +116 -192
- package/src/Fiber.ts +81 -148
- package/src/FiberHandle.ts +155 -107
- package/src/FiberMap.ts +225 -174
- package/src/FiberSet.ts +124 -82
- package/src/FileSystem.ts +155 -263
- package/src/Filter.ts +61 -33
- package/src/Formatter.ts +54 -56
- package/src/Function.ts +76 -145
- package/src/Graph.ts +416 -770
- package/src/HKT.ts +12 -6
- package/src/Hash.ts +52 -83
- package/src/HashMap.ts +319 -411
- package/src/HashRing.ts +1 -0
- package/src/HashSet.ts +177 -284
- package/src/Inspectable.ts +12 -12
- package/src/Iterable.ts +622 -787
- package/src/JsonPatch.ts +60 -113
- package/src/JsonPointer.ts +8 -8
- package/src/JsonSchema.ts +405 -249
- package/src/Latch.ts +23 -35
- package/src/Layer.ts +359 -260
- package/src/LayerMap.ts +49 -29
- package/src/LayerRef.ts +6 -2
- package/src/LogLevel.ts +114 -214
- package/src/Logger.ts +347 -699
- package/src/ManagedRuntime.ts +20 -5
- package/src/Match.ts +217 -252
- package/src/Metric.ts +520 -1092
- package/src/MutableHashMap.ts +218 -255
- package/src/MutableHashSet.ts +84 -89
- package/src/MutableList.ts +73 -370
- package/src/MutableRef.ts +420 -243
- package/src/Newtype.ts +21 -14
- package/src/NonEmptyIterable.ts +7 -137
- package/src/Number.ts +196 -233
- package/src/Optic.ts +246 -385
- package/src/Option.ts +449 -813
- package/src/Order.ts +109 -109
- package/src/Ordering.ts +20 -23
- package/src/PartitionedSemaphore.ts +1 -4
- package/src/Path.ts +38 -41
- package/src/Pipeable.ts +6 -5
- package/src/PlatformError.ts +4 -4
- package/src/Pool.ts +4 -2
- package/src/Predicate.ts +200 -181
- package/src/PrimaryKey.ts +7 -7
- package/src/PubSub.ts +526 -552
- package/src/Pull.ts +24 -18
- package/src/Queue.ts +200 -159
- package/src/Random.ts +49 -74
- package/src/RcMap.ts +121 -63
- package/src/RcRef.ts +24 -13
- package/src/Record.ts +387 -487
- package/src/Redactable.ts +10 -3
- package/src/Redacted.ts +25 -25
- package/src/Reducer.ts +8 -15
- package/src/Ref.ts +221 -361
- package/src/References.ts +102 -214
- package/src/RegExp.ts +10 -14
- package/src/Request.ts +36 -28
- package/src/RequestResolver.ts +202 -91
- package/src/Result.ts +314 -485
- package/src/Runtime.ts +50 -75
- package/src/Schedule.ts +308 -1734
- package/src/Scheduler.ts +20 -7
- package/src/Schema.ts +3156 -1634
- package/src/SchemaAST.ts +676 -489
- package/src/SchemaError.ts +8 -7
- package/src/SchemaGetter.ts +277 -218
- package/src/SchemaIssue.ts +90 -276
- package/src/SchemaParser.ts +179 -116
- package/src/SchemaRepresentation.ts +698 -3417
- package/src/SchemaTransformation.ts +132 -91
- package/src/Scope.ts +123 -151
- package/src/ScopedRef.ts +4 -4
- package/src/Semaphore.ts +157 -54
- package/src/Sink.ts +128 -113
- package/src/Stdio.ts +1 -1
- package/src/Stream.ts +2665 -3142
- package/src/String.ts +275 -312
- package/src/Struct.ts +114 -118
- package/src/SubscriptionRef.ts +284 -252
- package/src/Symbol.ts +3 -3
- package/src/Terminal.ts +2 -2
- package/src/Tracer.ts +102 -55
- package/src/Trie.ts +287 -679
- package/src/Tuple.ts +92 -127
- package/src/TxChunk.ts +201 -121
- package/src/TxDeferred.ts +62 -46
- package/src/TxHashMap.ts +645 -799
- package/src/TxHashSet.ts +443 -356
- package/src/TxPriorityQueue.ts +130 -98
- package/src/TxPubSub.ts +107 -80
- package/src/TxQueue.ts +214 -183
- package/src/TxReentrantLock.ts +97 -66
- package/src/TxRef.ts +51 -32
- package/src/TxSemaphore.ts +129 -95
- package/src/TxSubscriptionRef.ts +97 -70
- package/src/Types.ts +127 -70
- package/src/Unify.ts +45 -65
- package/src/Utils.ts +23 -16
- package/src/index.ts +0 -5
- package/src/internal/core.ts +5 -4
- package/src/internal/dateTime.ts +6 -0
- package/src/internal/effect.ts +160 -79
- package/src/internal/matcher.ts +1 -1
- package/src/internal/persistence.ts +2 -0
- package/src/internal/record.ts +11 -7
- package/src/internal/references.ts +3 -7
- package/src/internal/schema/annotations.ts +44 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +959 -0
- package/src/internal/schema/fromRepresentation.ts +339 -0
- package/src/internal/schema/parser.ts +22 -0
- package/src/internal/schema/schema.ts +45 -46
- package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
- package/src/internal/schema/toCodeDocument.ts +572 -0
- package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
- package/src/internal/schema/toJsonSchemaDocument.ts +529 -0
- package/src/internal/schema/toRepresentation.ts +386 -0
- package/src/internal/stackTraceLimit.ts +3 -7
- package/src/internal/trie.ts +10 -11
- package/src/testing/FastCheck.ts +8 -7
- package/src/testing/TestClock.ts +73 -31
- package/src/testing/TestConsole.ts +32 -31
- package/src/testing/TestSchema.ts +29 -29
- package/src/unstable/ai/AiError.ts +100 -122
- package/src/unstable/ai/AnthropicStructuredOutput.ts +103 -334
- package/src/unstable/ai/Chat.ts +132 -97
- package/src/unstable/ai/EmbeddingModel.ts +1 -1
- package/src/unstable/ai/IdGenerator.ts +32 -28
- package/src/unstable/ai/LanguageModel.ts +137 -95
- package/src/unstable/ai/McpProtocol.ts +48 -0
- package/src/unstable/ai/McpSchema.ts +75 -65
- package/src/unstable/ai/McpServer.ts +1045 -303
- package/src/unstable/ai/Model.ts +9 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +231 -396
- package/src/unstable/ai/Prompt.ts +145 -43
- package/src/unstable/ai/Response.ts +52 -38
- package/src/unstable/ai/Telemetry.ts +46 -13
- package/src/unstable/ai/Tokenizer.ts +14 -3
- package/src/unstable/ai/Tool.ts +81 -48
- package/src/unstable/ai/Toolkit.ts +45 -15
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/ai/internal/codec-transformer.ts +13 -7
- package/src/unstable/ai/internal/mcpProtocol.ts +85 -0
- package/src/unstable/ai/internal/mcpProtocolRegistry.ts +70 -0
- package/src/unstable/ai/internal/structured-output.ts +453 -0
- package/src/unstable/cli/Argument.ts +273 -69
- package/src/unstable/cli/CliError.ts +116 -77
- package/src/unstable/cli/CliOutput.ts +44 -58
- package/src/unstable/cli/Command.ts +709 -111
- package/src/unstable/cli/Flag.ts +418 -138
- package/src/unstable/cli/GlobalFlag.ts +1 -1
- package/src/unstable/cli/HelpDoc.ts +12 -4
- package/src/unstable/cli/Param.ts +295 -81
- package/src/unstable/cli/Primitive.ts +371 -150
- package/src/unstable/cli/Prompt.ts +28 -14
- package/src/unstable/cli/internal/command.ts +13 -5
- package/src/unstable/cli/internal/config.ts +8 -10
- package/src/unstable/cli/internal/lexer.ts +8 -2
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +8 -8
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +8 -4
- package/src/unstable/cluster/Entity.ts +16 -17
- package/src/unstable/cluster/EntityProxy.ts +4 -2
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/Envelope.ts +5 -4
- package/src/unstable/cluster/HttpRunner.ts +6 -4
- package/src/unstable/cluster/Message.ts +9 -9
- package/src/unstable/cluster/MessageStorage.ts +15 -15
- package/src/unstable/cluster/Reply.ts +5 -7
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerHealth.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +41 -8
- package/src/unstable/cluster/RunnerStorage.ts +2 -2
- package/src/unstable/cluster/Runners.ts +23 -12
- package/src/unstable/cluster/ShardId.ts +1 -1
- package/src/unstable/cluster/Sharding.ts +168 -42
- package/src/unstable/cluster/ShardingConfig.ts +8 -4
- package/src/unstable/cluster/SingleRunner.ts +4 -2
- package/src/unstable/cluster/SingletonAddress.ts +1 -1
- package/src/unstable/cluster/Snowflake.ts +8 -8
- package/src/unstable/cluster/SqlMessageStorage.ts +84 -36
- package/src/unstable/cluster/SqlRunnerStorage.ts +205 -119
- package/src/unstable/cluster/internal/entityManager.ts +42 -25
- package/src/unstable/cluster/internal/shardLock.ts +9 -0
- package/src/unstable/devtools/DevToolsSchema.ts +10 -5
- package/src/unstable/encoding/Msgpack.ts +6 -8
- package/src/unstable/encoding/Sse.ts +98 -16
- package/src/unstable/eventlog/Event.ts +20 -20
- package/src/unstable/eventlog/EventGroup.ts +4 -4
- package/src/unstable/eventlog/EventJournal.ts +16 -16
- package/src/unstable/eventlog/EventLog.ts +24 -14
- package/src/unstable/eventlog/EventLogEncryption.ts +2 -2
- package/src/unstable/eventlog/EventLogMessage.ts +12 -5
- package/src/unstable/eventlog/EventLogRemote.ts +1 -1
- package/src/unstable/eventlog/EventLogServer.ts +41 -7
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +13 -5
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +14 -6
- package/src/unstable/eventlog/EventLogSessionAuth.ts +1 -1
- package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
- package/src/unstable/http/Cookies.ts +64 -45
- package/src/unstable/http/Etag.ts +1 -1
- package/src/unstable/http/FetchHttpClient.ts +3 -1
- package/src/unstable/http/Headers.ts +10 -10
- package/src/unstable/http/HttpBody.ts +20 -5
- package/src/unstable/http/HttpClient.ts +83 -55
- package/src/unstable/http/HttpClientRequest.ts +59 -0
- package/src/unstable/http/HttpClientResponse.ts +4 -4
- package/src/unstable/http/HttpEffect.ts +8 -8
- package/src/unstable/http/HttpMethod.ts +6 -9
- package/src/unstable/http/HttpMiddleware.ts +202 -39
- package/src/unstable/http/HttpPlatform.ts +95 -0
- package/src/unstable/http/HttpRouter.ts +102 -98
- package/src/unstable/http/HttpServer.ts +13 -13
- package/src/unstable/http/HttpServerError.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +9 -8
- package/src/unstable/http/HttpServerResponse.ts +30 -0
- package/src/unstable/http/HttpStaticServer.ts +35 -7
- package/src/unstable/http/Multipart.ts +22 -19
- package/src/unstable/http/Template.ts +1 -1
- package/src/unstable/http/Url.ts +33 -63
- package/src/unstable/http/UrlParams.ts +27 -32
- package/src/unstable/http/internal/compression.ts +196 -0
- package/src/unstable/httpapi/HttpApi.ts +3 -3
- package/src/unstable/httpapi/HttpApiBuilder.ts +10 -9
- package/src/unstable/httpapi/HttpApiClient.ts +19 -19
- package/src/unstable/httpapi/HttpApiEndpoint.ts +42 -42
- package/src/unstable/httpapi/HttpApiError.ts +13 -13
- package/src/unstable/httpapi/HttpApiGroup.ts +16 -16
- package/src/unstable/httpapi/HttpApiMiddleware.ts +71 -24
- package/src/unstable/httpapi/HttpApiScalar.ts +0 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +6 -6
- package/src/unstable/httpapi/OpenApi.ts +65 -41
- package/src/unstable/observability/OtlpExporter.ts +126 -10
- package/src/unstable/observability/OtlpLogger.ts +5 -5
- package/src/unstable/observability/OtlpMetrics.ts +12 -5
- package/src/unstable/observability/OtlpResource.ts +26 -17
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/observability/PrometheusMetrics.ts +13 -4
- package/src/unstable/observability/internal/otlpEnv.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +3 -0
- package/src/unstable/persistence/KeyValueStore.ts +72 -49
- package/src/unstable/persistence/Persistable.ts +11 -10
- package/src/unstable/persistence/PersistedQueue.ts +6 -6
- package/src/unstable/persistence/Persistence.ts +126 -19
- package/src/unstable/persistence/RateLimiter.ts +28 -17
- package/src/unstable/persistence/Redis.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +64 -21
- package/src/unstable/process/ChildProcessSpawner.ts +22 -11
- package/src/unstable/reactivity/AsyncResult.ts +16 -16
- package/src/unstable/reactivity/Atom.ts +117 -22
- package/src/unstable/reactivity/AtomHttpApi.ts +5 -4
- package/src/unstable/reactivity/AtomRegistry.ts +25 -4
- package/src/unstable/reactivity/AtomRpc.ts +5 -4
- package/src/unstable/reactivity/Hydration.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +35 -33
- package/src/unstable/rpc/RpcClient.ts +18 -16
- package/src/unstable/rpc/RpcGroup.ts +8 -8
- package/src/unstable/rpc/RpcMessage.ts +31 -30
- package/src/unstable/rpc/RpcMiddleware.ts +10 -10
- package/src/unstable/rpc/RpcSchema.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +167 -68
- package/src/unstable/rpc/RpcServer.ts +18 -15
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/schema/Model.ts +52 -50
- package/src/unstable/schema/VariantSchema.ts +19 -29
- package/src/unstable/socket/Socket.ts +18 -5
- package/src/unstable/sql/SqlClient.ts +5 -6
- package/src/unstable/sql/SqlError.ts +2 -2
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +5 -5
- package/src/unstable/sql/Statement.ts +31 -29
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +2 -2
- package/src/unstable/workers/WorkerError.ts +7 -7
- package/src/unstable/workers/WorkerRunner.ts +1 -1
- package/src/unstable/workflow/Activity.ts +2 -2
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +10 -10
- package/src/unstable/workflow/DurableQueue.ts +22 -20
- package/src/unstable/workflow/Workflow.ts +23 -23
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
- package/src/unstable/workflow/WorkflowProxy.ts +4 -2
- package/dist/SchemaUtils.d.ts +0 -28
- package/dist/SchemaUtils.d.ts.map +0 -1
- package/dist/SchemaUtils.js +0 -45
- package/dist/SchemaUtils.js.map +0 -1
- package/dist/internal/schema/arbitrary.d.ts.map +0 -1
- package/dist/internal/schema/arbitrary.js.map +0 -1
- package/dist/internal/schema/equivalence.d.ts +0 -2
- package/dist/internal/schema/equivalence.d.ts.map +0 -1
- package/dist/internal/schema/equivalence.js.map +0 -1
- package/dist/internal/schema/representation.d.ts +0 -2
- package/dist/internal/schema/representation.d.ts.map +0 -1
- package/dist/internal/schema/representation.js +0 -865
- package/dist/internal/schema/representation.js.map +0 -1
- package/dist/internal/version.d.ts +0 -3
- package/dist/internal/version.d.ts.map +0 -1
- package/dist/internal/version.js +0 -2
- package/dist/internal/version.js.map +0 -1
- package/src/SchemaUtils.ts +0 -51
- package/src/internal/schema/representation.ts +0 -795
- package/src/internal/version.ts +0 -2
package/src/Channel.ts
CHANGED
|
@@ -26,6 +26,7 @@ import * as Iterable from "./Iterable.ts"
|
|
|
26
26
|
import * as Latch from "./Latch.ts"
|
|
27
27
|
import * as Layer from "./Layer.ts"
|
|
28
28
|
import type { Severity } from "./LogLevel.ts"
|
|
29
|
+
import * as MutableRef from "./MutableRef.ts"
|
|
29
30
|
import * as Option from "./Option.ts"
|
|
30
31
|
import type { Pipeable } from "./Pipeable.ts"
|
|
31
32
|
import { pipeArguments } from "./Pipeable.ts"
|
|
@@ -67,12 +68,12 @@ export const TypeId: TypeId = "~effect/Channel"
|
|
|
67
68
|
*
|
|
68
69
|
* **Example** (Checking for channels)
|
|
69
70
|
*
|
|
70
|
-
* ```ts
|
|
71
|
+
* ```ts import.meta.vitest
|
|
71
72
|
* import { Channel } from "effect"
|
|
72
73
|
*
|
|
73
74
|
* const channel = Channel.succeed(42)
|
|
74
|
-
*
|
|
75
|
-
*
|
|
75
|
+
* Channel.isChannel(channel) // => true
|
|
76
|
+
* Channel.isChannel("not a channel") // => false
|
|
76
77
|
* ```
|
|
77
78
|
*
|
|
78
79
|
* @category guards
|
|
@@ -109,8 +110,8 @@ export const isChannel = (
|
|
|
109
110
|
*
|
|
110
111
|
* **Example** (Typing channels)
|
|
111
112
|
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* import
|
|
113
|
+
* ```ts import.meta.vitest
|
|
114
|
+
* import { Channel, Effect } from "effect"
|
|
114
115
|
*
|
|
115
116
|
* // A channel that outputs numbers and requires no environment
|
|
116
117
|
* type NumberChannel = Channel.Channel<number>
|
|
@@ -128,6 +129,9 @@ export const isChannel = (
|
|
|
128
129
|
* boolean, // InDone - input completion
|
|
129
130
|
* { db: string } // Env - required environment
|
|
130
131
|
* >
|
|
132
|
+
*
|
|
133
|
+
* const channel: NumberChannel = Channel.succeed(1)
|
|
134
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1]
|
|
131
135
|
* ```
|
|
132
136
|
*
|
|
133
137
|
* @category models
|
|
@@ -264,12 +268,13 @@ const ChannelProto = {
|
|
|
264
268
|
*
|
|
265
269
|
* **Example** (Creating channels from transforms)
|
|
266
270
|
*
|
|
267
|
-
* ```ts
|
|
271
|
+
* ```ts import.meta.vitest
|
|
268
272
|
* import { Channel, Effect } from "effect"
|
|
269
273
|
*
|
|
270
274
|
* const channel = Channel.fromTransform((upstream, scope) =>
|
|
271
275
|
* Effect.succeed(upstream)
|
|
272
276
|
* )
|
|
277
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => []
|
|
273
278
|
* ```
|
|
274
279
|
*
|
|
275
280
|
* @category constructors
|
|
@@ -300,7 +305,7 @@ export const fromTransform = <OutElem, OutErr, OutDone, InElem, InErr, InDone, E
|
|
|
300
305
|
*
|
|
301
306
|
* **Example** (Transforming pull behavior)
|
|
302
307
|
*
|
|
303
|
-
* ```ts
|
|
308
|
+
* ```ts import.meta.vitest
|
|
304
309
|
* import { Channel, Effect } from "effect"
|
|
305
310
|
*
|
|
306
311
|
* // Transform a channel by modifying its pull behavior
|
|
@@ -313,7 +318,7 @@ export const fromTransform = <OutElem, OutErr, OutDone, InElem, InErr, InDone, E
|
|
|
313
318
|
* Effect.map(pull, (value) => value * 2)
|
|
314
319
|
* )
|
|
315
320
|
* )
|
|
316
|
-
* //
|
|
321
|
+
* await Effect.runPromise(Channel.runCollect(transformedChannel)) // => [2, 4, 6]
|
|
317
322
|
* ```
|
|
318
323
|
*
|
|
319
324
|
* @category constructors
|
|
@@ -354,12 +359,18 @@ export const transformPull = <
|
|
|
354
359
|
*
|
|
355
360
|
* **Example** (Creating channels from pulls)
|
|
356
361
|
*
|
|
357
|
-
* ```ts
|
|
358
|
-
* import { Channel, Effect } from "effect"
|
|
362
|
+
* ```ts import.meta.vitest
|
|
363
|
+
* import { Cause, Channel, Effect } from "effect"
|
|
359
364
|
*
|
|
360
|
-
* const channel = Channel.fromPull(
|
|
361
|
-
*
|
|
362
|
-
* )
|
|
365
|
+
* const channel = Channel.fromPull(Effect.sync(() => {
|
|
366
|
+
* let emitted = false
|
|
367
|
+
* return Effect.suspend(() => {
|
|
368
|
+
* if (emitted) return Cause.done()
|
|
369
|
+
* emitted = true
|
|
370
|
+
* return Effect.succeed(42)
|
|
371
|
+
* })
|
|
372
|
+
* }))
|
|
373
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [42]
|
|
363
374
|
* ```
|
|
364
375
|
*
|
|
365
376
|
* @category constructors
|
|
@@ -410,12 +421,13 @@ export const fromTransformBracket = <OutElem, OutErr, OutDone, InElem, InErr, In
|
|
|
410
421
|
*
|
|
411
422
|
* **Example** (Extracting channel transforms)
|
|
412
423
|
*
|
|
413
|
-
* ```ts
|
|
414
|
-
* import { Channel } from "effect"
|
|
424
|
+
* ```ts import.meta.vitest
|
|
425
|
+
* import { Channel, Effect } from "effect"
|
|
415
426
|
*
|
|
416
427
|
* const channel = Channel.succeed(42)
|
|
417
428
|
* const transform = Channel.toTransform(channel)
|
|
418
|
-
*
|
|
429
|
+
* typeof transform // => "function"
|
|
430
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [42]
|
|
419
431
|
* ```
|
|
420
432
|
*
|
|
421
433
|
* @category destructors
|
|
@@ -433,10 +445,10 @@ export const toTransform = <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env
|
|
|
433
445
|
*
|
|
434
446
|
* **Example** (Reading the default chunk size)
|
|
435
447
|
*
|
|
436
|
-
* ```ts
|
|
448
|
+
* ```ts import.meta.vitest
|
|
437
449
|
* import { Channel } from "effect"
|
|
438
450
|
*
|
|
439
|
-
*
|
|
451
|
+
* Channel.DefaultChunkSize // => 4096
|
|
440
452
|
* ```
|
|
441
453
|
*
|
|
442
454
|
* @category constants
|
|
@@ -465,7 +477,7 @@ const asyncQueue = <A, E = never, R = never>(
|
|
|
465
477
|
*
|
|
466
478
|
* **Example** (Creating channels from callbacks)
|
|
467
479
|
*
|
|
468
|
-
* ```ts
|
|
480
|
+
* ```ts import.meta.vitest
|
|
469
481
|
* import { Channel, Effect, Queue } from "effect"
|
|
470
482
|
*
|
|
471
483
|
* const channel = Channel.callback<number>((queue) =>
|
|
@@ -473,8 +485,10 @@ const asyncQueue = <A, E = never, R = never>(
|
|
|
473
485
|
* yield* Queue.offer(queue, 1)
|
|
474
486
|
* yield* Queue.offer(queue, 2)
|
|
475
487
|
* yield* Queue.offer(queue, 3)
|
|
488
|
+
* yield* Queue.end(queue)
|
|
476
489
|
* })
|
|
477
490
|
* )
|
|
491
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [1, 2, 3]
|
|
478
492
|
* ```
|
|
479
493
|
*
|
|
480
494
|
* @category constructors
|
|
@@ -494,14 +508,15 @@ export const callback = <A, E = never, R = never>(
|
|
|
494
508
|
*
|
|
495
509
|
* **Example** (Creating array channels from callbacks)
|
|
496
510
|
*
|
|
497
|
-
* ```ts
|
|
511
|
+
* ```ts import.meta.vitest
|
|
498
512
|
* import { Channel, Effect, Queue } from "effect"
|
|
499
513
|
*
|
|
500
514
|
* const channel = Channel.callbackArray<number>(Effect.fn(function*(queue) {
|
|
501
515
|
* yield* Queue.offer(queue, 1)
|
|
502
516
|
* yield* Queue.offer(queue, 2)
|
|
517
|
+
* yield* Queue.end(queue)
|
|
503
518
|
* }))
|
|
504
|
-
*
|
|
519
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [[1, 2]]
|
|
505
520
|
* ```
|
|
506
521
|
*
|
|
507
522
|
* @category constructors
|
|
@@ -521,11 +536,11 @@ export const callbackArray = <A, E = never, R = never>(
|
|
|
521
536
|
*
|
|
522
537
|
* **Example** (Suspending channel creation)
|
|
523
538
|
*
|
|
524
|
-
* ```ts
|
|
525
|
-
* import { Channel } from "effect"
|
|
539
|
+
* ```ts import.meta.vitest
|
|
540
|
+
* import { Channel, Effect } from "effect"
|
|
526
541
|
*
|
|
527
542
|
* const channel = Channel.suspend(() => Channel.succeed(42))
|
|
528
|
-
*
|
|
543
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [42]
|
|
529
544
|
* ```
|
|
530
545
|
*
|
|
531
546
|
* @category constructors
|
|
@@ -548,14 +563,16 @@ export const suspend = <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
|
548
563
|
*
|
|
549
564
|
* **Example** (Managing resources with acquire-use-release)
|
|
550
565
|
*
|
|
551
|
-
* ```ts
|
|
566
|
+
* ```ts import.meta.vitest
|
|
552
567
|
* import { Channel, Effect } from "effect"
|
|
553
568
|
*
|
|
569
|
+
* const released: Array<string> = []
|
|
554
570
|
* const channel = Channel.acquireUseRelease(
|
|
555
571
|
* Effect.succeed("resource"),
|
|
556
572
|
* (resource) => Channel.succeed(resource.toUpperCase()),
|
|
557
|
-
* (resource, exit) => Effect.
|
|
573
|
+
* (resource, exit) => Effect.sync(() => released.push(resource))
|
|
558
574
|
* )
|
|
575
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["RESOURCE"], ["resource"]]
|
|
559
576
|
* ```
|
|
560
577
|
*
|
|
561
578
|
* @category constructors
|
|
@@ -591,13 +608,15 @@ export const acquireUseRelease = <A, E, R, OutElem, OutErr, OutDone, InElem, InE
|
|
|
591
608
|
*
|
|
592
609
|
* **Example** (Managing resources with acquire-release)
|
|
593
610
|
*
|
|
594
|
-
* ```ts
|
|
611
|
+
* ```ts import.meta.vitest
|
|
595
612
|
* import { Channel, Effect } from "effect"
|
|
596
613
|
*
|
|
614
|
+
* const released: Array<string> = []
|
|
597
615
|
* const channel = Channel.acquireRelease(
|
|
598
616
|
* Effect.succeed("resource"),
|
|
599
|
-
* (resource, exit) => Effect.
|
|
617
|
+
* (resource, exit) => Effect.sync(() => released.push(resource))
|
|
600
618
|
* )
|
|
619
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
601
620
|
* ```
|
|
602
621
|
*
|
|
603
622
|
* @category constructors
|
|
@@ -616,13 +635,15 @@ export const acquireRelease: {
|
|
|
616
635
|
*
|
|
617
636
|
* **Example** (Managing resources with acquire-release)
|
|
618
637
|
*
|
|
619
|
-
* ```ts
|
|
638
|
+
* ```ts import.meta.vitest
|
|
620
639
|
* import { Channel, Effect } from "effect"
|
|
621
640
|
*
|
|
641
|
+
* const released: Array<string> = []
|
|
622
642
|
* const channel = Channel.acquireRelease(
|
|
623
643
|
* Effect.succeed("resource"),
|
|
624
|
-
* (resource, exit) => Effect.
|
|
644
|
+
* (resource, exit) => Effect.sync(() => released.push(resource))
|
|
625
645
|
* )
|
|
646
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
626
647
|
* ```
|
|
627
648
|
*
|
|
628
649
|
* @category constructors
|
|
@@ -641,13 +662,15 @@ export const acquireRelease: {
|
|
|
641
662
|
*
|
|
642
663
|
* **Example** (Managing resources with acquire-release)
|
|
643
664
|
*
|
|
644
|
-
* ```ts
|
|
665
|
+
* ```ts import.meta.vitest
|
|
645
666
|
* import { Channel, Effect } from "effect"
|
|
646
667
|
*
|
|
668
|
+
* const released: Array<string> = []
|
|
647
669
|
* const channel = Channel.acquireRelease(
|
|
648
670
|
* Effect.succeed("resource"),
|
|
649
|
-
* (resource, exit) => Effect.
|
|
671
|
+
* (resource, exit) => Effect.sync(() => released.push(resource))
|
|
650
672
|
* )
|
|
673
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
651
674
|
* ```
|
|
652
675
|
*
|
|
653
676
|
* @category constructors
|
|
@@ -671,12 +694,12 @@ export const acquireRelease: {
|
|
|
671
694
|
*
|
|
672
695
|
* **Example** (Creating channels from iterators)
|
|
673
696
|
*
|
|
674
|
-
* ```ts
|
|
675
|
-
* import { Channel } from "effect"
|
|
697
|
+
* ```ts import.meta.vitest
|
|
698
|
+
* import { Channel, Effect } from "effect"
|
|
676
699
|
*
|
|
677
700
|
* const numbers = [1, 2, 3, 4, 5]
|
|
678
701
|
* const channel = Channel.fromIterator(() => numbers[Symbol.iterator]())
|
|
679
|
-
* //
|
|
702
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3, 4, 5]
|
|
680
703
|
* ```
|
|
681
704
|
*
|
|
682
705
|
* @category constructors
|
|
@@ -698,11 +721,11 @@ export const fromIterator = <A, L>(iterator: LazyArg<Iterator<A, L>>): Channel<A
|
|
|
698
721
|
*
|
|
699
722
|
* **Example** (Creating channels from arrays)
|
|
700
723
|
*
|
|
701
|
-
* ```ts
|
|
702
|
-
* import { Channel } from "effect"
|
|
724
|
+
* ```ts import.meta.vitest
|
|
725
|
+
* import { Channel, Effect } from "effect"
|
|
703
726
|
*
|
|
704
727
|
* const channel = Channel.fromArray([1, 2, 3, 4, 5])
|
|
705
|
-
* //
|
|
728
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3, 4, 5]
|
|
706
729
|
* ```
|
|
707
730
|
*
|
|
708
731
|
* @category constructors
|
|
@@ -719,12 +742,12 @@ export const fromArray = <A>(array: ReadonlyArray<A>): Channel<A> =>
|
|
|
719
742
|
*
|
|
720
743
|
* **Example** (Creating channels from chunks)
|
|
721
744
|
*
|
|
722
|
-
* ```ts
|
|
723
|
-
* import { Channel, Chunk } from "effect"
|
|
745
|
+
* ```ts import.meta.vitest
|
|
746
|
+
* import { Channel, Chunk, Effect } from "effect"
|
|
724
747
|
*
|
|
725
748
|
* const chunk = Chunk.make(1, 2, 3)
|
|
726
749
|
* const channel = Channel.fromChunk(chunk)
|
|
727
|
-
* //
|
|
750
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3]
|
|
728
751
|
* ```
|
|
729
752
|
*
|
|
730
753
|
* @category constructors
|
|
@@ -737,8 +760,8 @@ export const fromChunk = <A>(chunk: Chunk.Chunk<A>): Channel<A> => fromArray(Chu
|
|
|
737
760
|
*
|
|
738
761
|
* **Example** (Batching iterator output)
|
|
739
762
|
*
|
|
740
|
-
* ```ts
|
|
741
|
-
* import { Channel } from "effect"
|
|
763
|
+
* ```ts import.meta.vitest
|
|
764
|
+
* import { Channel, Effect } from "effect"
|
|
742
765
|
*
|
|
743
766
|
* // Create a channel from a simple iterator
|
|
744
767
|
* const numberIterator = (): Iterator<number, string> => {
|
|
@@ -754,13 +777,13 @@ export const fromChunk = <A>(chunk: Chunk.Chunk<A>): Channel<A> => fromArray(Chu
|
|
|
754
777
|
* }
|
|
755
778
|
*
|
|
756
779
|
* const channel = Channel.fromIteratorArray(() => numberIterator(), 2)
|
|
757
|
-
* //
|
|
780
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [[0, 1], [2]]
|
|
758
781
|
* ```
|
|
759
782
|
*
|
|
760
783
|
* **Example** (Batching generator output)
|
|
761
784
|
*
|
|
762
|
-
* ```ts
|
|
763
|
-
* import { Channel } from "effect"
|
|
785
|
+
* ```ts import.meta.vitest
|
|
786
|
+
* import { Channel, Effect } from "effect"
|
|
764
787
|
*
|
|
765
788
|
* // Create channel from a generator function
|
|
766
789
|
* function* fibonacci(): Generator<number, void, unknown> {
|
|
@@ -772,7 +795,7 @@ export const fromChunk = <A>(chunk: Chunk.Chunk<A>): Channel<A> => fromArray(Chu
|
|
|
772
795
|
* }
|
|
773
796
|
*
|
|
774
797
|
* const fibChannel = Channel.fromIteratorArray(() => fibonacci(), 3)
|
|
775
|
-
* //
|
|
798
|
+
* Effect.runSync(Channel.runCollect(fibChannel)) // => [[0, 1, 1], [2, 3]]
|
|
776
799
|
* ```
|
|
777
800
|
*
|
|
778
801
|
* @category constructors
|
|
@@ -810,12 +833,12 @@ export const fromIteratorArray = <A, L>(
|
|
|
810
833
|
*
|
|
811
834
|
* **Example** (Creating channels from iterables)
|
|
812
835
|
*
|
|
813
|
-
* ```ts
|
|
814
|
-
* import { Channel } from "effect"
|
|
836
|
+
* ```ts import.meta.vitest
|
|
837
|
+
* import { Channel, Effect } from "effect"
|
|
815
838
|
*
|
|
816
839
|
* const set = new Set([1, 2, 3])
|
|
817
840
|
* const channel = Channel.fromIterable(set)
|
|
818
|
-
* //
|
|
841
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3]
|
|
819
842
|
* ```
|
|
820
843
|
*
|
|
821
844
|
* @category constructors
|
|
@@ -829,12 +852,12 @@ export const fromIterable = <A, L>(iterable: Iterable<A, L>): Channel<A, never,
|
|
|
829
852
|
*
|
|
830
853
|
* **Example** (Batching iterable output)
|
|
831
854
|
*
|
|
832
|
-
* ```ts
|
|
833
|
-
* import { Channel } from "effect"
|
|
855
|
+
* ```ts import.meta.vitest
|
|
856
|
+
* import { Channel, Effect } from "effect"
|
|
834
857
|
*
|
|
835
858
|
* const numbers = [1, 2, 3, 4, 5]
|
|
836
|
-
* const channel = Channel.fromIterableArray(numbers)
|
|
837
|
-
* //
|
|
859
|
+
* const channel = Channel.fromIterableArray(numbers, 4)
|
|
860
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [[1, 2, 3, 4], [5]]
|
|
838
861
|
* ```
|
|
839
862
|
*
|
|
840
863
|
* @category constructors
|
|
@@ -850,11 +873,11 @@ export const fromIterableArray = <A, L>(
|
|
|
850
873
|
*
|
|
851
874
|
* **Example** (Creating channels that succeed)
|
|
852
875
|
*
|
|
853
|
-
* ```ts
|
|
854
|
-
* import { Channel } from "effect"
|
|
876
|
+
* ```ts import.meta.vitest
|
|
877
|
+
* import { Channel, Effect } from "effect"
|
|
855
878
|
*
|
|
856
879
|
* const channel = Channel.succeed(42)
|
|
857
|
-
* //
|
|
880
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [42]
|
|
858
881
|
* ```
|
|
859
882
|
*
|
|
860
883
|
* @category constructors
|
|
@@ -867,11 +890,11 @@ export const succeed = <A>(value: A): Channel<A> => fromEffect(Effect.succeed(va
|
|
|
867
890
|
*
|
|
868
891
|
* **Example** (Ending with a value)
|
|
869
892
|
*
|
|
870
|
-
* ```ts
|
|
871
|
-
* import { Channel } from "effect"
|
|
893
|
+
* ```ts import.meta.vitest
|
|
894
|
+
* import { Channel, Effect } from "effect"
|
|
872
895
|
*
|
|
873
896
|
* const channel = Channel.end("done")
|
|
874
|
-
* //
|
|
897
|
+
* Effect.runSync(Channel.runCollect(channel)) // => []
|
|
875
898
|
* ```
|
|
876
899
|
*
|
|
877
900
|
* @category constructors
|
|
@@ -893,8 +916,8 @@ export const endSync = <A>(evaluate: LazyArg<A>): Channel<never, never, A> =>
|
|
|
893
916
|
*
|
|
894
917
|
* **Example** (Computing values lazily)
|
|
895
918
|
*
|
|
896
|
-
* ```ts
|
|
897
|
-
* import { Channel } from "effect"
|
|
919
|
+
* ```ts import.meta.vitest
|
|
920
|
+
* import { Channel, Effect } from "effect"
|
|
898
921
|
*
|
|
899
922
|
* let requests = 0
|
|
900
923
|
*
|
|
@@ -902,7 +925,7 @@ export const endSync = <A>(evaluate: LazyArg<A>): Channel<never, never, A> =>
|
|
|
902
925
|
* requests += 1
|
|
903
926
|
* return `request-${requests}`
|
|
904
927
|
* })
|
|
905
|
-
* //
|
|
928
|
+
* Effect.runSync(Channel.runCollect(channel)) // => ["request-1"]
|
|
906
929
|
* ```
|
|
907
930
|
*
|
|
908
931
|
* @category constructors
|
|
@@ -915,8 +938,8 @@ export const sync = <A>(evaluate: LazyArg<A>): Channel<A> => fromEffect(Effect.s
|
|
|
915
938
|
*
|
|
916
939
|
* **Example** (Creating empty channels)
|
|
917
940
|
*
|
|
918
|
-
* ```ts
|
|
919
|
-
* import { Channel } from "effect"
|
|
941
|
+
* ```ts import.meta.vitest
|
|
942
|
+
* import { Channel, Effect } from "effect"
|
|
920
943
|
*
|
|
921
944
|
* // Create an empty channel
|
|
922
945
|
* const emptyChannel = Channel.empty
|
|
@@ -928,6 +951,8 @@ export const sync = <A>(evaluate: LazyArg<A>): Channel<A> => fromEffect(Effect.s
|
|
|
928
951
|
* // Empty channel can be used as a no-op in conditional logic
|
|
929
952
|
* const conditionalChannel = (shouldEmit: boolean) =>
|
|
930
953
|
* shouldEmit ? Channel.succeed("data") : Channel.empty
|
|
954
|
+
*
|
|
955
|
+
* Effect.runSync(Channel.runCollect(conditionalChannel(true))) // => ["data"]
|
|
931
956
|
* ```
|
|
932
957
|
*
|
|
933
958
|
* @category constructors
|
|
@@ -940,7 +965,7 @@ export const empty: Channel<never> = fromPull(Effect.succeed(Cause.done()))
|
|
|
940
965
|
*
|
|
941
966
|
* **Example** (Creating non-terminating channels)
|
|
942
967
|
*
|
|
943
|
-
* ```ts
|
|
968
|
+
* ```ts import.meta.vitest
|
|
944
969
|
* import { Channel } from "effect"
|
|
945
970
|
*
|
|
946
971
|
* // Create a channel that never completes
|
|
@@ -955,6 +980,8 @@ export const empty: Channel<never> = fromPull(Effect.succeed(Cause.done()))
|
|
|
955
980
|
* // Never channel is useful for testing or as a placeholder
|
|
956
981
|
* const conditionalChannel = (shouldComplete: boolean) =>
|
|
957
982
|
* shouldComplete ? Channel.succeed("done") : Channel.never
|
|
983
|
+
*
|
|
984
|
+
* Channel.isChannel(conditionalChannel(false)) // => true
|
|
958
985
|
* ```
|
|
959
986
|
*
|
|
960
987
|
* @category constructors
|
|
@@ -967,26 +994,11 @@ export const never: Channel<never, never, never> = fromPull(Effect.succeed(Effec
|
|
|
967
994
|
*
|
|
968
995
|
* **Example** (Failing with an error)
|
|
969
996
|
*
|
|
970
|
-
* ```ts
|
|
971
|
-
* import { Channel } from "effect"
|
|
997
|
+
* ```ts import.meta.vitest
|
|
998
|
+
* import { Channel, Effect, Exit } from "effect"
|
|
972
999
|
*
|
|
973
|
-
* // Create a channel that fails with a string error
|
|
974
1000
|
* const failedChannel = Channel.fail("Something went wrong")
|
|
975
|
-
*
|
|
976
|
-
* // Create a channel that fails with a custom error
|
|
977
|
-
* class CustomError extends Error {
|
|
978
|
-
* constructor(message: string) {
|
|
979
|
-
* super(message)
|
|
980
|
-
* this.name = "CustomError"
|
|
981
|
-
* }
|
|
982
|
-
* }
|
|
983
|
-
* const customErrorChannel = Channel.fail(new CustomError("Custom error"))
|
|
984
|
-
*
|
|
985
|
-
* // Use in error handling by piping to another channel
|
|
986
|
-
* const channelWithFallback = Channel.concatWith(
|
|
987
|
-
* failedChannel,
|
|
988
|
-
* () => Channel.succeed("fallback value")
|
|
989
|
-
* )
|
|
1001
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(failedChannel))) // => Exit.fail("Something went wrong")
|
|
990
1002
|
* ```
|
|
991
1003
|
*
|
|
992
1004
|
* @category constructors
|
|
@@ -1005,27 +1017,18 @@ export const fail = <E>(error: E): Channel<never, E, never> => fromPull(Effect.s
|
|
|
1005
1017
|
*
|
|
1006
1018
|
* **Example** (Failing with a lazy error)
|
|
1007
1019
|
*
|
|
1008
|
-
* ```ts
|
|
1009
|
-
* import { Channel } from "effect"
|
|
1020
|
+
* ```ts import.meta.vitest
|
|
1021
|
+
* import { Channel, Effect, Exit } from "effect"
|
|
1010
1022
|
*
|
|
1011
|
-
* // Create a channel that fails with a lazily computed error
|
|
1012
|
-
* const failedChannel = Channel.failSync(() => {
|
|
1013
|
-
* console.log("Computing error...")
|
|
1014
|
-
* return new Error("Computed at runtime")
|
|
1015
|
-
* })
|
|
1016
|
-
*
|
|
1017
|
-
* // The error computation is deferred until the channel runs
|
|
1018
1023
|
* let attempts = 0
|
|
1019
1024
|
* const conditionalError = Channel.failSync(() => {
|
|
1020
1025
|
* attempts += 1
|
|
1021
1026
|
* return `Error after attempt ${attempts}`
|
|
1022
1027
|
* })
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
* return new Error(`Failed while processing ${requestId}`)
|
|
1028
|
-
* })
|
|
1028
|
+
* const observed = [
|
|
1029
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(conditionalError))),
|
|
1030
|
+
* attempts
|
|
1031
|
+
* ] // => [Exit.fail("Error after attempt 1"), 1]
|
|
1029
1032
|
* ```
|
|
1030
1033
|
*
|
|
1031
1034
|
* @category constructors
|
|
@@ -1043,20 +1046,12 @@ export const failSync = <E>(evaluate: LazyArg<E>): Channel<never, E, never> => f
|
|
|
1043
1046
|
*
|
|
1044
1047
|
* **Example** (Failing with causes)
|
|
1045
1048
|
*
|
|
1046
|
-
* ```ts
|
|
1047
|
-
* import { Cause, Channel } from "effect"
|
|
1049
|
+
* ```ts import.meta.vitest
|
|
1050
|
+
* import { Cause, Channel, Effect, Exit } from "effect"
|
|
1048
1051
|
*
|
|
1049
|
-
* // Create a channel that fails with a simple cause
|
|
1050
1052
|
* const simpleCause = Cause.fail("Simple error")
|
|
1051
1053
|
* const failedChannel = Channel.failCause(simpleCause)
|
|
1052
|
-
*
|
|
1053
|
-
* // Create a channel with a die cause
|
|
1054
|
-
* const dieCause = Cause.die(new Error("System error"))
|
|
1055
|
-
* const dieFailure = Channel.failCause(dieCause)
|
|
1056
|
-
*
|
|
1057
|
-
* // Create a channel with a simple fail cause
|
|
1058
|
-
* const failCause = Cause.fail("Simple error")
|
|
1059
|
-
* const simpleFail = Channel.failCause(failCause)
|
|
1054
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(failedChannel))) // => Exit.failCause(simpleCause)
|
|
1060
1055
|
* ```
|
|
1061
1056
|
*
|
|
1062
1057
|
* @category constructors
|
|
@@ -1070,8 +1065,8 @@ export const failCause = <E>(cause: Cause.Cause<E>): Channel<never, E, never> =>
|
|
|
1070
1065
|
*
|
|
1071
1066
|
* **Example** (Failing with lazy causes)
|
|
1072
1067
|
*
|
|
1073
|
-
* ```ts
|
|
1074
|
-
* import { Cause, Channel } from "effect"
|
|
1068
|
+
* ```ts import.meta.vitest
|
|
1069
|
+
* import { Cause, Channel, Effect, Exit } from "effect"
|
|
1075
1070
|
*
|
|
1076
1071
|
* // Create a channel that fails with a lazily computed cause
|
|
1077
1072
|
* let attempts = 0
|
|
@@ -1080,11 +1075,10 @@ export const failCause = <E>(cause: Cause.Cause<E>): Channel<never, E, never> =>
|
|
|
1080
1075
|
* return Cause.fail(`Runtime error after attempt ${attempts}`)
|
|
1081
1076
|
* })
|
|
1082
1077
|
*
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
* })
|
|
1078
|
+
* const observed = [
|
|
1079
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(failedChannel))),
|
|
1080
|
+
* attempts
|
|
1081
|
+
* ] // => [Exit.fail("Runtime error after attempt 1"), 1]
|
|
1088
1082
|
* ```
|
|
1089
1083
|
*
|
|
1090
1084
|
* @category constructors
|
|
@@ -1099,20 +1093,12 @@ export const failCauseSync = <E>(
|
|
|
1099
1093
|
*
|
|
1100
1094
|
* **Example** (Dying with defects)
|
|
1101
1095
|
*
|
|
1102
|
-
* ```ts
|
|
1103
|
-
* import { Channel } from "effect"
|
|
1104
|
-
*
|
|
1105
|
-
* // Create a channel that dies with a string defect
|
|
1106
|
-
* const diedChannel = Channel.die("Unrecoverable error")
|
|
1096
|
+
* ```ts import.meta.vitest
|
|
1097
|
+
* import { Cause, Channel, Effect, Exit } from "effect"
|
|
1107
1098
|
*
|
|
1108
|
-
*
|
|
1109
|
-
* const
|
|
1110
|
-
*
|
|
1111
|
-
* // Die with any value as a defect
|
|
1112
|
-
* const objectDefect = Channel.die({
|
|
1113
|
-
* code: "SYSTEM_FAILURE",
|
|
1114
|
-
* details: "Critical system component failed"
|
|
1115
|
-
* })
|
|
1099
|
+
* const defect = "Unrecoverable error"
|
|
1100
|
+
* const diedChannel = Channel.die(defect)
|
|
1101
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(diedChannel))) // => Exit.failCause(Cause.die(defect))
|
|
1116
1102
|
* ```
|
|
1117
1103
|
*
|
|
1118
1104
|
* @category constructors
|
|
@@ -1125,33 +1111,13 @@ export const die = (defect: unknown): Channel<never, never, never> => failCause(
|
|
|
1125
1111
|
*
|
|
1126
1112
|
* **Example** (Creating channels from effects)
|
|
1127
1113
|
*
|
|
1128
|
-
* ```ts
|
|
1129
|
-
* import { Channel,
|
|
1130
|
-
*
|
|
1131
|
-
* class DatabaseError extends Data.TaggedError("DatabaseError")<{
|
|
1132
|
-
* readonly message: string
|
|
1133
|
-
* }> {}
|
|
1114
|
+
* ```ts import.meta.vitest
|
|
1115
|
+
* import { Channel, Effect } from "effect"
|
|
1134
1116
|
*
|
|
1135
|
-
* // Create a channel from a successful effect
|
|
1136
1117
|
* const successChannel = Channel.fromEffect(
|
|
1137
1118
|
* Effect.succeed("Hello from effect!")
|
|
1138
1119
|
* )
|
|
1139
|
-
*
|
|
1140
|
-
* // Create a channel from an effect that might fail
|
|
1141
|
-
* const fetchUserChannel = Channel.fromEffect(
|
|
1142
|
-
* Effect.tryPromise({
|
|
1143
|
-
* try: () => fetch("/api/user").then((res) => res.json()),
|
|
1144
|
-
* catch: (error) => new DatabaseError({ message: String(error) })
|
|
1145
|
-
* })
|
|
1146
|
-
* )
|
|
1147
|
-
*
|
|
1148
|
-
* // Channel from effect with async computation
|
|
1149
|
-
* const asyncChannel = Channel.fromEffect(
|
|
1150
|
-
* Effect.gen(function*() {
|
|
1151
|
-
* yield* Effect.sleep("100 millis")
|
|
1152
|
-
* return "Async result"
|
|
1153
|
-
* })
|
|
1154
|
-
* )
|
|
1120
|
+
* Effect.runSync(Channel.runCollect(successChannel)) // => ["Hello from effect!"]
|
|
1155
1121
|
* ```
|
|
1156
1122
|
*
|
|
1157
1123
|
* @category constructors
|
|
@@ -1219,35 +1185,17 @@ export const fromEffectTake = <A, E, Done, E2, R>(
|
|
|
1219
1185
|
*
|
|
1220
1186
|
* **Example** (Creating channels from queues)
|
|
1221
1187
|
*
|
|
1222
|
-
* ```ts
|
|
1223
|
-
* import {
|
|
1224
|
-
*
|
|
1225
|
-
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
1226
|
-
* readonly reason: string
|
|
1227
|
-
* }> {}
|
|
1188
|
+
* ```ts import.meta.vitest
|
|
1189
|
+
* import { Cause, Channel, Effect, Queue } from "effect"
|
|
1228
1190
|
*
|
|
1229
1191
|
* const program = Effect.gen(function*() {
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
* // Add some items to the queue
|
|
1234
|
-
* yield* Queue.offer(queue, "item1")
|
|
1235
|
-
* yield* Queue.offer(queue, "item2")
|
|
1236
|
-
* yield* Queue.offer(queue, "item3")
|
|
1237
|
-
*
|
|
1238
|
-
* // Create a channel from the queue
|
|
1192
|
+
* const queue = yield* Queue.bounded<string, Cause.Done>(3)
|
|
1193
|
+
* yield* Queue.offerAll(queue, ["item1", "item2", "item3"])
|
|
1194
|
+
* yield* Queue.end(queue)
|
|
1239
1195
|
* const channel = Channel.fromQueue(queue)
|
|
1240
|
-
*
|
|
1241
|
-
* // The channel will read items from the queue one by one
|
|
1242
|
-
* return channel
|
|
1243
|
-
* })
|
|
1244
|
-
*
|
|
1245
|
-
* // Sliding queue example
|
|
1246
|
-
* const slidingProgram = Effect.gen(function*() {
|
|
1247
|
-
* const slidingQueue = yield* Queue.sliding<number, QueueError>(5)
|
|
1248
|
-
* yield* Queue.offerAll(slidingQueue, [1, 2, 3, 4, 5, 6])
|
|
1249
|
-
* return Channel.fromQueue(slidingQueue)
|
|
1196
|
+
* return yield* Channel.runCollect(channel)
|
|
1250
1197
|
* })
|
|
1198
|
+
* await Effect.runPromise(program) // => ["item1", "item2", "item3"]
|
|
1251
1199
|
* ```
|
|
1252
1200
|
*
|
|
1253
1201
|
* @category constructors
|
|
@@ -1262,39 +1210,17 @@ export const fromQueue = <A, E>(
|
|
|
1262
1210
|
*
|
|
1263
1211
|
* **Example** (Creating batched channels from queues)
|
|
1264
1212
|
*
|
|
1265
|
-
* ```ts
|
|
1266
|
-
* import {
|
|
1267
|
-
*
|
|
1268
|
-
* class ProcessingError extends Data.TaggedError("ProcessingError")<{
|
|
1269
|
-
* readonly stage: string
|
|
1270
|
-
* }> {}
|
|
1213
|
+
* ```ts import.meta.vitest
|
|
1214
|
+
* import { Cause, Channel, Effect, Queue } from "effect"
|
|
1271
1215
|
*
|
|
1272
1216
|
* const program = Effect.gen(function*() {
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1275
|
-
*
|
|
1276
|
-
* // Fill queue with data
|
|
1277
|
-
* yield* Queue.offerAll(queue, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
|
1278
|
-
*
|
|
1279
|
-
* // Create a channel that reads arrays from the queue
|
|
1217
|
+
* const queue = yield* Queue.bounded<number, Cause.Done>(4)
|
|
1218
|
+
* yield* Queue.offerAll(queue, [1, 2, 3, 4])
|
|
1219
|
+
* yield* Queue.end(queue)
|
|
1280
1220
|
* const arrayChannel = Channel.fromQueueArray(queue)
|
|
1281
|
-
*
|
|
1282
|
-
* // This will emit non-empty arrays of elements instead of individual items
|
|
1283
|
-
* // Useful for batch processing scenarios
|
|
1284
|
-
* return arrayChannel
|
|
1285
|
-
* })
|
|
1286
|
-
*
|
|
1287
|
-
* // High-throughput processing example
|
|
1288
|
-
* const batchProcessor = Effect.gen(function*() {
|
|
1289
|
-
* const dataQueue = yield* Queue.dropping<string, ProcessingError>(1000)
|
|
1290
|
-
* const batchChannel = Channel.fromQueueArray(dataQueue)
|
|
1291
|
-
*
|
|
1292
|
-
* // Process data in batches for better performance
|
|
1293
|
-
* return Channel.map(
|
|
1294
|
-
* batchChannel,
|
|
1295
|
-
* (batch) => batch.map((item) => item.toUpperCase())
|
|
1296
|
-
* )
|
|
1221
|
+
* return yield* Channel.runCollect(arrayChannel)
|
|
1297
1222
|
* })
|
|
1223
|
+
* await Effect.runPromise(program) // => [[1, 2, 3, 4]]
|
|
1298
1224
|
* ```
|
|
1299
1225
|
*
|
|
1300
1226
|
* @category constructors
|
|
@@ -1319,8 +1245,8 @@ export const identity = <Elem, Err, Done>(): Channel<Elem, Err, Done, Elem, Err,
|
|
|
1319
1245
|
*
|
|
1320
1246
|
* **Example** (Creating channels from subscriptions)
|
|
1321
1247
|
*
|
|
1322
|
-
* ```ts
|
|
1323
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
1248
|
+
* ```ts import.meta.vitest
|
|
1249
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1324
1250
|
*
|
|
1325
1251
|
* class SubscriptionError extends Data.TaggedError("SubscriptionError")<{
|
|
1326
1252
|
* readonly reason: string
|
|
@@ -1345,6 +1271,8 @@ export const identity = <Elem, Err, Done>(): Channel<Elem, Err, Done, Elem, Err,
|
|
|
1345
1271
|
* // The channel will receive all published messages
|
|
1346
1272
|
* return channel
|
|
1347
1273
|
* })
|
|
1274
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
1275
|
+
* await Effect.runPromise(result) // => Option.some("Hello")
|
|
1348
1276
|
*
|
|
1349
1277
|
* // Real-time notifications example
|
|
1350
1278
|
* const notificationChannel = Effect.gen(function*() {
|
|
@@ -1373,8 +1301,8 @@ export const fromSubscription = <A>(
|
|
|
1373
1301
|
*
|
|
1374
1302
|
* **Example** (Batching subscription values)
|
|
1375
1303
|
*
|
|
1376
|
-
* ```ts
|
|
1377
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
1304
|
+
* ```ts import.meta.vitest
|
|
1305
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1378
1306
|
*
|
|
1379
1307
|
* class StreamError extends Data.TaggedError("StreamError")<{
|
|
1380
1308
|
* readonly message: string
|
|
@@ -1396,12 +1324,14 @@ export const fromSubscription = <A>(
|
|
|
1396
1324
|
* // The channel will output arrays like [1, 2, 3] and [4]
|
|
1397
1325
|
* return channel
|
|
1398
1326
|
* })
|
|
1327
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
1328
|
+
* await Effect.runPromise(result) // => Option.some([1, 2, 3, 4])
|
|
1399
1329
|
* ```
|
|
1400
1330
|
*
|
|
1401
1331
|
* **Example** (Processing subscription values in batches)
|
|
1402
1332
|
*
|
|
1403
|
-
* ```ts
|
|
1404
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
1333
|
+
* ```ts import.meta.vitest
|
|
1334
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1405
1335
|
*
|
|
1406
1336
|
* class BatchProcessingError extends Data.TaggedError("BatchProcessingError")<{
|
|
1407
1337
|
* readonly reason: string
|
|
@@ -1415,19 +1345,21 @@ export const fromSubscription = <A>(
|
|
|
1415
1345
|
* const batchChannel = Channel.fromSubscriptionArray(subscription)
|
|
1416
1346
|
*
|
|
1417
1347
|
* // Transform to process each batch
|
|
1418
|
-
* const processedChannel = Channel.map(batchChannel, (batch) =>
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
* })
|
|
1348
|
+
* const processedChannel = Channel.map(batchChannel, (batch) =>
|
|
1349
|
+
* batch.map((item) => item.toUpperCase())
|
|
1350
|
+
* )
|
|
1422
1351
|
*
|
|
1352
|
+
* yield* PubSub.publishAll(pubsub, ["one", "two"])
|
|
1423
1353
|
* return processedChannel
|
|
1424
1354
|
* })
|
|
1355
|
+
* const batch = Effect.scoped(Effect.flatMap(batchProcessor, Channel.runHead))
|
|
1356
|
+
* await Effect.runPromise(batch) // => Option.some(["ONE", "TWO"])
|
|
1425
1357
|
* ```
|
|
1426
1358
|
*
|
|
1427
1359
|
* **Example** (Aggregating subscription metrics)
|
|
1428
1360
|
*
|
|
1429
|
-
* ```ts
|
|
1430
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1361
|
+
* ```ts import.meta.vitest
|
|
1362
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1431
1363
|
*
|
|
1432
1364
|
* const metricsAggregator = Effect.gen(function*() {
|
|
1433
1365
|
* const metricsPubSub = yield* PubSub.bounded<
|
|
@@ -1457,8 +1389,12 @@ export const fromSubscription = <A>(
|
|
|
1457
1389
|
* }
|
|
1458
1390
|
* })
|
|
1459
1391
|
*
|
|
1392
|
+
* yield* PubSub.publish(metricsPubSub, { timestamp: 1, value: 10 })
|
|
1460
1393
|
* return aggregatedChannel
|
|
1461
1394
|
* })
|
|
1395
|
+
* const metric = Effect.scoped(Effect.flatMap(metricsAggregator, Channel.runHead))
|
|
1396
|
+
* const result = await Effect.runPromise(metric)
|
|
1397
|
+
* Option.map(result, ({ count, sum, average, min, max }) => ({ count, sum, average, min, max })) // => Option.some({ count: 1, sum: 10, average: 10, min: 10, max: 10 })
|
|
1462
1398
|
* ```
|
|
1463
1399
|
*
|
|
1464
1400
|
* @category constructors
|
|
@@ -1480,15 +1416,15 @@ export const fromSubscriptionArray = <A>(
|
|
|
1480
1416
|
*
|
|
1481
1417
|
* **Example** (Creating channels from PubSubs)
|
|
1482
1418
|
*
|
|
1483
|
-
* ```ts
|
|
1484
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
1419
|
+
* ```ts import.meta.vitest
|
|
1420
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1485
1421
|
*
|
|
1486
1422
|
* class StreamError extends Data.TaggedError("StreamError")<{
|
|
1487
1423
|
* readonly message: string
|
|
1488
1424
|
* }> {}
|
|
1489
1425
|
*
|
|
1490
1426
|
* const program = Effect.gen(function*() {
|
|
1491
|
-
* const pubsub = yield* PubSub.
|
|
1427
|
+
* const pubsub = yield* PubSub.unbounded<number>({ replay: 3 })
|
|
1492
1428
|
*
|
|
1493
1429
|
* // Create a channel that reads individual values
|
|
1494
1430
|
* const channel = Channel.fromPubSub(pubsub)
|
|
@@ -1501,15 +1437,17 @@ export const fromSubscriptionArray = <A>(
|
|
|
1501
1437
|
* // The channel will output: 1, 2, 3 (individual values)
|
|
1502
1438
|
* return channel
|
|
1503
1439
|
* })
|
|
1440
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
1441
|
+
* await Effect.runPromise(result) // => Option.some(1)
|
|
1504
1442
|
* ```
|
|
1505
1443
|
*
|
|
1506
1444
|
* **Example** (Streaming PubSub notifications)
|
|
1507
1445
|
*
|
|
1508
|
-
* ```ts
|
|
1509
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1446
|
+
* ```ts import.meta.vitest
|
|
1447
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1510
1448
|
*
|
|
1511
1449
|
* const notificationService = Effect.gen(function*() {
|
|
1512
|
-
* const notificationPubSub = yield* PubSub.
|
|
1450
|
+
* const notificationPubSub = yield* PubSub.unbounded<string>({ replay: 1 })
|
|
1513
1451
|
*
|
|
1514
1452
|
* // Create a channel for real-time notifications
|
|
1515
1453
|
* const notificationChannel = Channel.fromPubSub(notificationPubSub)
|
|
@@ -1522,14 +1460,17 @@ export const fromSubscriptionArray = <A>(
|
|
|
1522
1460
|
* id: `notification:${message}`
|
|
1523
1461
|
* }))
|
|
1524
1462
|
*
|
|
1463
|
+
* yield* PubSub.publish(notificationPubSub, "ready")
|
|
1525
1464
|
* return timestampedChannel
|
|
1526
1465
|
* })
|
|
1466
|
+
* const notification = Effect.scoped(Effect.flatMap(notificationService, Channel.runHead))
|
|
1467
|
+
* await Effect.runPromise(notification) // => Option.some({ message: "ready", receivedAt: "2024-01-01T00:00:00.000Z", id: "notification:ready" })
|
|
1527
1468
|
* ```
|
|
1528
1469
|
*
|
|
1529
1470
|
* **Example** (Processing PubSub events)
|
|
1530
1471
|
*
|
|
1531
|
-
* ```ts
|
|
1532
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1472
|
+
* ```ts import.meta.vitest
|
|
1473
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1533
1474
|
*
|
|
1534
1475
|
* interface DomainEvent {
|
|
1535
1476
|
* readonly type: string
|
|
@@ -1538,7 +1479,7 @@ export const fromSubscriptionArray = <A>(
|
|
|
1538
1479
|
* }
|
|
1539
1480
|
*
|
|
1540
1481
|
* const eventProcessor = Effect.gen(function*() {
|
|
1541
|
-
* const eventPubSub = yield* PubSub.
|
|
1482
|
+
* const eventPubSub = yield* PubSub.unbounded<DomainEvent>({ replay: 1 })
|
|
1542
1483
|
*
|
|
1543
1484
|
* // Create a channel for processing domain events
|
|
1544
1485
|
* const eventChannel = Channel.fromPubSub(eventPubSub)
|
|
@@ -1555,8 +1496,11 @@ export const fromSubscriptionArray = <A>(
|
|
|
1555
1496
|
* return event
|
|
1556
1497
|
* })
|
|
1557
1498
|
*
|
|
1499
|
+
* yield* PubSub.publish(eventPubSub, { type: "user.created", payload: {}, timestamp: 1 })
|
|
1558
1500
|
* return processedChannel
|
|
1559
1501
|
* })
|
|
1502
|
+
* const event = Effect.scoped(Effect.flatMap(eventProcessor, Channel.runHead))
|
|
1503
|
+
* const result = await Effect.runPromise(event) // => Option.some({ type: "user.created", payload: {}, timestamp: 1, processed: true, processedAt: 2 })
|
|
1560
1504
|
* ```
|
|
1561
1505
|
*
|
|
1562
1506
|
* @category constructors
|
|
@@ -1577,15 +1521,15 @@ export const fromPubSub = <A>(
|
|
|
1577
1521
|
*
|
|
1578
1522
|
* **Example** (Batching PubSub values)
|
|
1579
1523
|
*
|
|
1580
|
-
* ```ts
|
|
1581
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
1524
|
+
* ```ts import.meta.vitest
|
|
1525
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1582
1526
|
*
|
|
1583
1527
|
* class BatchError extends Data.TaggedError("BatchError")<{
|
|
1584
1528
|
* readonly message: string
|
|
1585
1529
|
* }> {}
|
|
1586
1530
|
*
|
|
1587
1531
|
* const program = Effect.gen(function*() {
|
|
1588
|
-
* const pubsub = yield* PubSub.
|
|
1532
|
+
* const pubsub = yield* PubSub.unbounded<number>({ replay: 4 })
|
|
1589
1533
|
*
|
|
1590
1534
|
* // Create a channel that reads arrays of values
|
|
1591
1535
|
* const channel = Channel.fromPubSubArray(pubsub)
|
|
@@ -1599,12 +1543,14 @@ export const fromPubSub = <A>(
|
|
|
1599
1543
|
* // The channel will output arrays like [1, 2, 3] and [4]
|
|
1600
1544
|
* return channel
|
|
1601
1545
|
* })
|
|
1546
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
1547
|
+
* await Effect.runPromise(result) // => Option.some([1, 2, 3, 4])
|
|
1602
1548
|
* ```
|
|
1603
1549
|
*
|
|
1604
1550
|
* **Example** (Processing PubSub orders in batches)
|
|
1605
1551
|
*
|
|
1606
|
-
* ```ts
|
|
1607
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1552
|
+
* ```ts import.meta.vitest
|
|
1553
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1608
1554
|
*
|
|
1609
1555
|
* interface Order {
|
|
1610
1556
|
* readonly id: string
|
|
@@ -1615,7 +1561,7 @@ export const fromPubSub = <A>(
|
|
|
1615
1561
|
* }
|
|
1616
1562
|
*
|
|
1617
1563
|
* const orderBatchProcessor = Effect.gen(function*() {
|
|
1618
|
-
* const orderPubSub = yield* PubSub.
|
|
1564
|
+
* const orderPubSub = yield* PubSub.unbounded<Order>({ replay: 1 })
|
|
1619
1565
|
*
|
|
1620
1566
|
* // Create a channel that processes orders in batches
|
|
1621
1567
|
* const orderChannel = Channel.fromPubSubArray(orderPubSub)
|
|
@@ -1636,14 +1582,20 @@ export const fromPubSub = <A>(
|
|
|
1636
1582
|
* }
|
|
1637
1583
|
* })
|
|
1638
1584
|
*
|
|
1585
|
+
* yield* PubSub.publish(orderPubSub, {
|
|
1586
|
+
* id: "1", customerId: "a", items: ["book"], total: 10, submittedAt: 1
|
|
1587
|
+
* })
|
|
1639
1588
|
* return processedChannel
|
|
1640
1589
|
* })
|
|
1590
|
+
* const order = Effect.scoped(Effect.flatMap(orderBatchProcessor, Channel.runHead))
|
|
1591
|
+
* const result = await Effect.runPromise(order)
|
|
1592
|
+
* Option.map(result, (batch) => [batch.batchSize, batch.totalRevenue, batch.uniqueCustomers]) // => Option.some([1, 10, 1])
|
|
1641
1593
|
* ```
|
|
1642
1594
|
*
|
|
1643
1595
|
* **Example** (Processing PubSub logs in batches)
|
|
1644
1596
|
*
|
|
1645
|
-
* ```ts
|
|
1646
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1597
|
+
* ```ts import.meta.vitest
|
|
1598
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1647
1599
|
*
|
|
1648
1600
|
* interface LogEntry {
|
|
1649
1601
|
* readonly timestamp: number
|
|
@@ -1653,7 +1605,7 @@ export const fromPubSub = <A>(
|
|
|
1653
1605
|
* }
|
|
1654
1606
|
*
|
|
1655
1607
|
* const logAggregator = Effect.gen(function*() {
|
|
1656
|
-
* const logPubSub = yield* PubSub.
|
|
1608
|
+
* const logPubSub = yield* PubSub.unbounded<LogEntry>({ replay: 1 })
|
|
1657
1609
|
*
|
|
1658
1610
|
* // Create a channel that collects logs in batches
|
|
1659
1611
|
* const logChannel = Channel.fromPubSubArray(logPubSub)
|
|
@@ -1680,8 +1632,17 @@ export const fromPubSub = <A>(
|
|
|
1680
1632
|
* }
|
|
1681
1633
|
* })
|
|
1682
1634
|
*
|
|
1635
|
+
* yield* PubSub.publish(logPubSub, {
|
|
1636
|
+
* timestamp: 1,
|
|
1637
|
+
* level: "info",
|
|
1638
|
+
* message: "ready",
|
|
1639
|
+
* source: "app"
|
|
1640
|
+
* } satisfies LogEntry)
|
|
1683
1641
|
* return analysisChannel
|
|
1684
1642
|
* })
|
|
1643
|
+
* const log = Effect.scoped(Effect.flatMap(logAggregator, Channel.runHead))
|
|
1644
|
+
* const result = await Effect.runPromise(log)
|
|
1645
|
+
* Option.map(result, (batch) => [batch.batchId, batch.totalEntries, batch.infoCount]) // => Option.some(["1-1", 1, 1])
|
|
1685
1646
|
* ```
|
|
1686
1647
|
*
|
|
1687
1648
|
* @category constructors
|
|
@@ -1717,6 +1678,229 @@ export const fromSchedule = <O, E, R>(
|
|
|
1717
1678
|
): Channel<O, E, O, unknown, unknown, unknown, R> =>
|
|
1718
1679
|
fromPull(Effect.map(Schedule.toStepWithSleep(schedule), (step) => step(void 0)))
|
|
1719
1680
|
|
|
1681
|
+
/**
|
|
1682
|
+
* Creates a channel from a lazily supplied Web `ReadableStream`.
|
|
1683
|
+
*
|
|
1684
|
+
* **Example** (Reading from a Web stream)
|
|
1685
|
+
*
|
|
1686
|
+
* ```ts import.meta.vitest
|
|
1687
|
+
* import { Channel, Effect } from "effect"
|
|
1688
|
+
*
|
|
1689
|
+
* const channel = Channel.fromReadableStream({
|
|
1690
|
+
* evaluate: () => new ReadableStream({
|
|
1691
|
+
* start(controller) {
|
|
1692
|
+
* controller.enqueue(1)
|
|
1693
|
+
* controller.close()
|
|
1694
|
+
* }
|
|
1695
|
+
* }),
|
|
1696
|
+
* onError: (cause) => new Error(String(cause))
|
|
1697
|
+
* })
|
|
1698
|
+
*
|
|
1699
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [[1]]
|
|
1700
|
+
* ```
|
|
1701
|
+
*
|
|
1702
|
+
* @category constructors
|
|
1703
|
+
* @since 4.0.0
|
|
1704
|
+
*/
|
|
1705
|
+
export const fromReadableStream = <A, E>(options: {
|
|
1706
|
+
readonly evaluate: LazyArg<ReadableStream<A>>
|
|
1707
|
+
readonly onError: (error: unknown) => E
|
|
1708
|
+
readonly releaseLockOnEnd?: boolean | undefined
|
|
1709
|
+
}): Channel<Arr.NonEmptyReadonlyArray<A>, E> =>
|
|
1710
|
+
fromTransform((_, scope) =>
|
|
1711
|
+
readableStreamToPullUnsafe({
|
|
1712
|
+
scope,
|
|
1713
|
+
readable: options.evaluate(),
|
|
1714
|
+
onError: options.onError,
|
|
1715
|
+
releaseLockOnEnd: options.releaseLockOnEnd
|
|
1716
|
+
})
|
|
1717
|
+
)
|
|
1718
|
+
|
|
1719
|
+
/** @internal */
|
|
1720
|
+
export const pullIntoWritableStream = <A, IE, E>(options: {
|
|
1721
|
+
readonly pull: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, IE, unknown>
|
|
1722
|
+
readonly writable: WritableStream<A>
|
|
1723
|
+
readonly onError: (error: unknown) => E
|
|
1724
|
+
readonly closeOnDone?: boolean | undefined
|
|
1725
|
+
}): Pull.Pull<never, IE | E, unknown> =>
|
|
1726
|
+
Effect.acquireUseRelease(
|
|
1727
|
+
Effect.sync(() => options.writable.getWriter()),
|
|
1728
|
+
(writer) => {
|
|
1729
|
+
const loop = options.pull.pipe(
|
|
1730
|
+
Effect.flatMap((chunk) =>
|
|
1731
|
+
Effect.forEach(
|
|
1732
|
+
chunk,
|
|
1733
|
+
(value) =>
|
|
1734
|
+
Effect.tryPromise({
|
|
1735
|
+
try: () => writer.ready.then(() => writer.write(value)),
|
|
1736
|
+
catch: options.onError
|
|
1737
|
+
}),
|
|
1738
|
+
{ discard: true }
|
|
1739
|
+
)
|
|
1740
|
+
),
|
|
1741
|
+
Effect.forever({ disableYield: true })
|
|
1742
|
+
)
|
|
1743
|
+
const withClose = options.closeOnDone !== false
|
|
1744
|
+
? Pull.catchDone(loop, (done) =>
|
|
1745
|
+
Effect.andThen(
|
|
1746
|
+
Effect.tryPromise({
|
|
1747
|
+
try: () => writer.close(),
|
|
1748
|
+
catch: options.onError
|
|
1749
|
+
}),
|
|
1750
|
+
Cause.done(done)
|
|
1751
|
+
))
|
|
1752
|
+
: loop
|
|
1753
|
+
return Effect.onError(
|
|
1754
|
+
withClose,
|
|
1755
|
+
(cause) =>
|
|
1756
|
+
Pull.isDoneCause(cause)
|
|
1757
|
+
? Effect.void
|
|
1758
|
+
: Effect.promise(() => writer.abort(cause).catch(constVoid))
|
|
1759
|
+
)
|
|
1760
|
+
},
|
|
1761
|
+
(writer) => Effect.sync(() => writer.releaseLock())
|
|
1762
|
+
)
|
|
1763
|
+
|
|
1764
|
+
/**
|
|
1765
|
+
* Creates a channel that writes upstream values to a lazily supplied Web
|
|
1766
|
+
* `WritableStream`.
|
|
1767
|
+
*
|
|
1768
|
+
* **Example** (Writing channel input)
|
|
1769
|
+
*
|
|
1770
|
+
* ```ts import.meta.vitest
|
|
1771
|
+
* import { Channel, Effect } from "effect"
|
|
1772
|
+
*
|
|
1773
|
+
* const written: Array<number> = []
|
|
1774
|
+
* const sink = Channel.fromWritableStream<never, Error, number>({
|
|
1775
|
+
* evaluate: () => new WritableStream({
|
|
1776
|
+
* write(value) {
|
|
1777
|
+
* written.push(value)
|
|
1778
|
+
* }
|
|
1779
|
+
* }),
|
|
1780
|
+
* onError: (cause) => new Error(String(cause))
|
|
1781
|
+
* })
|
|
1782
|
+
*
|
|
1783
|
+
* const program = Channel.fromArray([[1, 2] as [number, number]]).pipe(
|
|
1784
|
+
* Channel.pipeTo(sink),
|
|
1785
|
+
* Channel.runDrain
|
|
1786
|
+
* )
|
|
1787
|
+
*
|
|
1788
|
+
* await Effect.runPromise(program)
|
|
1789
|
+
* written // => [1, 2]
|
|
1790
|
+
* ```
|
|
1791
|
+
*
|
|
1792
|
+
* @category constructors
|
|
1793
|
+
* @since 4.0.0
|
|
1794
|
+
*/
|
|
1795
|
+
export const fromWritableStream = <IE, E, A>(options: {
|
|
1796
|
+
readonly evaluate: LazyArg<WritableStream<A>>
|
|
1797
|
+
readonly onError: (error: unknown) => E
|
|
1798
|
+
readonly closeOnDone?: boolean | undefined
|
|
1799
|
+
}): Channel<never, IE | E, void, Arr.NonEmptyReadonlyArray<A>, IE> =>
|
|
1800
|
+
fromTransform((pull: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, IE, unknown>) => {
|
|
1801
|
+
const writable = options.evaluate()
|
|
1802
|
+
return Effect.succeed(pullIntoWritableStream({ ...options, writable, pull }))
|
|
1803
|
+
})
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* Creates a channel backed by a Web `TransformStream`, writing upstream values
|
|
1807
|
+
* while emitting transformed values from its readable side.
|
|
1808
|
+
*
|
|
1809
|
+
* **Example** (Transforming channel input)
|
|
1810
|
+
*
|
|
1811
|
+
* ```ts import.meta.vitest
|
|
1812
|
+
* import { Channel, Effect } from "effect"
|
|
1813
|
+
*
|
|
1814
|
+
* const transform = Channel.fromTransformStream<never, number, number, Error>({
|
|
1815
|
+
* evaluate: () => new TransformStream({
|
|
1816
|
+
* transform(value, controller) {
|
|
1817
|
+
* controller.enqueue(value * 2)
|
|
1818
|
+
* }
|
|
1819
|
+
* }),
|
|
1820
|
+
* onError: (cause) => new Error(String(cause))
|
|
1821
|
+
* })
|
|
1822
|
+
*
|
|
1823
|
+
* const program = Channel.fromArray([[1, 2] as [number, number]]).pipe(
|
|
1824
|
+
* Channel.pipeTo(transform),
|
|
1825
|
+
* Channel.runCollect
|
|
1826
|
+
* )
|
|
1827
|
+
*
|
|
1828
|
+
* await Effect.runPromise(program) // => [[2], [4]]
|
|
1829
|
+
* ```
|
|
1830
|
+
*
|
|
1831
|
+
* @category constructors
|
|
1832
|
+
* @since 4.0.0
|
|
1833
|
+
*/
|
|
1834
|
+
export const fromTransformStream = <IE, I, O, E>(options: {
|
|
1835
|
+
readonly evaluate: LazyArg<TransformStream<I, O>>
|
|
1836
|
+
readonly onError: (error: unknown) => E
|
|
1837
|
+
readonly closeOnDone?: boolean | undefined
|
|
1838
|
+
readonly releaseLockOnEnd?: boolean | undefined
|
|
1839
|
+
}): Channel<Arr.NonEmptyReadonlyArray<O>, IE | E, void, Arr.NonEmptyReadonlyArray<I>, IE> =>
|
|
1840
|
+
fromTransform((upstream, scope) => {
|
|
1841
|
+
const transform = options.evaluate()
|
|
1842
|
+
const exit = MutableRef.make<Exit.Exit<never, IE | E | Cause.Done> | undefined>(undefined)
|
|
1843
|
+
return pullIntoWritableStream({
|
|
1844
|
+
pull: upstream,
|
|
1845
|
+
writable: transform.writable,
|
|
1846
|
+
onError: options.onError,
|
|
1847
|
+
closeOnDone: options.closeOnDone
|
|
1848
|
+
}).pipe(
|
|
1849
|
+
Effect.catchCause((cause) => {
|
|
1850
|
+
if (!Pull.isDoneCause(cause)) {
|
|
1851
|
+
exit.current = Exit.failCause(cause as Cause.Cause<IE | E | Cause.Done>)
|
|
1852
|
+
}
|
|
1853
|
+
return Effect.void
|
|
1854
|
+
}),
|
|
1855
|
+
Effect.forkIn(scope),
|
|
1856
|
+
Effect.flatMap(() =>
|
|
1857
|
+
readableStreamToPullUnsafe({
|
|
1858
|
+
scope,
|
|
1859
|
+
exit,
|
|
1860
|
+
readable: transform.readable,
|
|
1861
|
+
onError: options.onError,
|
|
1862
|
+
releaseLockOnEnd: options.releaseLockOnEnd
|
|
1863
|
+
})
|
|
1864
|
+
)
|
|
1865
|
+
)
|
|
1866
|
+
})
|
|
1867
|
+
|
|
1868
|
+
const readableStreamToPullUnsafe = <A, E, E2 = never>(options: {
|
|
1869
|
+
readonly scope: Scope.Scope
|
|
1870
|
+
readonly exit?: MutableRef.MutableRef<Exit.Exit<never, E | E2 | Cause.Done> | undefined> | undefined
|
|
1871
|
+
readonly readable: ReadableStream<A>
|
|
1872
|
+
readonly onError: (error: unknown) => E
|
|
1873
|
+
readonly releaseLockOnEnd?: boolean | undefined
|
|
1874
|
+
}): Effect.Effect<Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E | E2>, never> => {
|
|
1875
|
+
const reader = options.readable.getReader()
|
|
1876
|
+
const exit = options.exit ?? MutableRef.make(undefined)
|
|
1877
|
+
const pull = Effect.suspend(() => {
|
|
1878
|
+
if (exit.current) return exit.current
|
|
1879
|
+
return Effect.matchCauseEffect(
|
|
1880
|
+
Effect.tryPromise({
|
|
1881
|
+
try: () => reader.read(),
|
|
1882
|
+
catch: options.onError
|
|
1883
|
+
}),
|
|
1884
|
+
{
|
|
1885
|
+
onFailure: (cause) => exit.current ?? Effect.failCause(cause),
|
|
1886
|
+
onSuccess: ({ done, value }) => {
|
|
1887
|
+
if (exit.current) return exit.current
|
|
1888
|
+
return done ? Cause.done() : Effect.succeed(Arr.of(value))
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
)
|
|
1892
|
+
})
|
|
1893
|
+
return Effect.as(
|
|
1894
|
+
Scope.addFinalizer(
|
|
1895
|
+
options.scope,
|
|
1896
|
+
options.releaseLockOnEnd
|
|
1897
|
+
? Effect.sync(() => reader.releaseLock())
|
|
1898
|
+
: Effect.promise(() => reader.cancel().catch(constVoid))
|
|
1899
|
+
),
|
|
1900
|
+
pull
|
|
1901
|
+
)
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1720
1904
|
/**
|
|
1721
1905
|
* Creates a channel that pulls values from an `AsyncIterable`.
|
|
1722
1906
|
*
|
|
@@ -1771,8 +1955,8 @@ export const fromAsyncIterableArray = <A, D, E>(
|
|
|
1771
1955
|
*
|
|
1772
1956
|
* **Example** (Mapping channel output)
|
|
1773
1957
|
*
|
|
1774
|
-
* ```ts
|
|
1775
|
-
* import { Channel, Data } from "effect"
|
|
1958
|
+
* ```ts import.meta.vitest
|
|
1959
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1776
1960
|
*
|
|
1777
1961
|
* class TransformError extends Data.TaggedError("TransformError")<{
|
|
1778
1962
|
* readonly reason: string
|
|
@@ -1781,12 +1965,12 @@ export const fromAsyncIterableArray = <A, D, E>(
|
|
|
1781
1965
|
* // Basic mapping of channel values
|
|
1782
1966
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
1783
1967
|
* const doubledChannel = Channel.map(numbersChannel, (n) => n * 2)
|
|
1784
|
-
* //
|
|
1968
|
+
* Effect.runSync(Channel.runCollect(doubledChannel)) // => [2, 4, 6, 8, 10]
|
|
1785
1969
|
*
|
|
1786
1970
|
* // Transform string data
|
|
1787
1971
|
* const wordsChannel = Channel.fromIterable(["hello", "world", "effect"])
|
|
1788
1972
|
* const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase())
|
|
1789
|
-
* //
|
|
1973
|
+
* Effect.runSync(Channel.runCollect(upperCaseChannel)) // => ["HELLO", "WORLD", "EFFECT"]
|
|
1790
1974
|
*
|
|
1791
1975
|
* // Complex object transformation
|
|
1792
1976
|
* type User = { id: number; name: string }
|
|
@@ -1800,6 +1984,7 @@ export const fromAsyncIterableArray = <A, D, E>(
|
|
|
1800
1984
|
* displayName: `User: ${user.name}`,
|
|
1801
1985
|
* isActive: true
|
|
1802
1986
|
* }))
|
|
1987
|
+
* Effect.runSync(Channel.runCollect(displayChannel)) // => [{ displayName: "User: Alice", isActive: true }, { displayName: "User: Bob", isActive: true }]
|
|
1803
1988
|
* ```
|
|
1804
1989
|
*
|
|
1805
1990
|
* @category sequencing
|
|
@@ -1811,8 +1996,8 @@ export const map: {
|
|
|
1811
1996
|
*
|
|
1812
1997
|
* **Example** (Mapping channel output)
|
|
1813
1998
|
*
|
|
1814
|
-
* ```ts
|
|
1815
|
-
* import { Channel, Data } from "effect"
|
|
1999
|
+
* ```ts import.meta.vitest
|
|
2000
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1816
2001
|
*
|
|
1817
2002
|
* class TransformError extends Data.TaggedError("TransformError")<{
|
|
1818
2003
|
* readonly reason: string
|
|
@@ -1821,12 +2006,12 @@ export const map: {
|
|
|
1821
2006
|
* // Basic mapping of channel values
|
|
1822
2007
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
1823
2008
|
* const doubledChannel = Channel.map(numbersChannel, (n) => n * 2)
|
|
1824
|
-
* //
|
|
2009
|
+
* Effect.runSync(Channel.runCollect(doubledChannel)) // => [2, 4, 6, 8, 10]
|
|
1825
2010
|
*
|
|
1826
2011
|
* // Transform string data
|
|
1827
2012
|
* const wordsChannel = Channel.fromIterable(["hello", "world", "effect"])
|
|
1828
2013
|
* const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase())
|
|
1829
|
-
* //
|
|
2014
|
+
* Effect.runSync(Channel.runCollect(upperCaseChannel)) // => ["HELLO", "WORLD", "EFFECT"]
|
|
1830
2015
|
*
|
|
1831
2016
|
* // Complex object transformation
|
|
1832
2017
|
* type User = { id: number; name: string }
|
|
@@ -1840,6 +2025,7 @@ export const map: {
|
|
|
1840
2025
|
* displayName: `User: ${user.name}`,
|
|
1841
2026
|
* isActive: true
|
|
1842
2027
|
* }))
|
|
2028
|
+
* Effect.runSync(Channel.runCollect(displayChannel)) // => [{ displayName: "User: Alice", isActive: true }, { displayName: "User: Bob", isActive: true }]
|
|
1843
2029
|
* ```
|
|
1844
2030
|
*
|
|
1845
2031
|
* @category sequencing
|
|
@@ -1853,8 +2039,8 @@ export const map: {
|
|
|
1853
2039
|
*
|
|
1854
2040
|
* **Example** (Mapping channel output)
|
|
1855
2041
|
*
|
|
1856
|
-
* ```ts
|
|
1857
|
-
* import { Channel, Data } from "effect"
|
|
2042
|
+
* ```ts import.meta.vitest
|
|
2043
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1858
2044
|
*
|
|
1859
2045
|
* class TransformError extends Data.TaggedError("TransformError")<{
|
|
1860
2046
|
* readonly reason: string
|
|
@@ -1863,12 +2049,12 @@ export const map: {
|
|
|
1863
2049
|
* // Basic mapping of channel values
|
|
1864
2050
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
1865
2051
|
* const doubledChannel = Channel.map(numbersChannel, (n) => n * 2)
|
|
1866
|
-
* //
|
|
2052
|
+
* Effect.runSync(Channel.runCollect(doubledChannel)) // => [2, 4, 6, 8, 10]
|
|
1867
2053
|
*
|
|
1868
2054
|
* // Transform string data
|
|
1869
2055
|
* const wordsChannel = Channel.fromIterable(["hello", "world", "effect"])
|
|
1870
2056
|
* const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase())
|
|
1871
|
-
* //
|
|
2057
|
+
* Effect.runSync(Channel.runCollect(upperCaseChannel)) // => ["HELLO", "WORLD", "EFFECT"]
|
|
1872
2058
|
*
|
|
1873
2059
|
* // Complex object transformation
|
|
1874
2060
|
* type User = { id: number; name: string }
|
|
@@ -1882,6 +2068,7 @@ export const map: {
|
|
|
1882
2068
|
* displayName: `User: ${user.name}`,
|
|
1883
2069
|
* isActive: true
|
|
1884
2070
|
* }))
|
|
2071
|
+
* Effect.runSync(Channel.runCollect(displayChannel)) // => [{ displayName: "User: Alice", isActive: true }, { displayName: "User: Bob", isActive: true }]
|
|
1885
2072
|
* ```
|
|
1886
2073
|
*
|
|
1887
2074
|
* @category sequencing
|
|
@@ -2014,40 +2201,15 @@ const concurrencyIsSequential = (
|
|
|
2014
2201
|
*
|
|
2015
2202
|
* **Example** (Mapping channel output with effects)
|
|
2016
2203
|
*
|
|
2017
|
-
* ```ts
|
|
2018
|
-
* import { Channel,
|
|
2019
|
-
*
|
|
2020
|
-
* class NetworkError extends Data.TaggedError("NetworkError")<{
|
|
2021
|
-
* readonly url: string
|
|
2022
|
-
* }> {}
|
|
2023
|
-
*
|
|
2024
|
-
* // Transform values using effectful operations
|
|
2025
|
-
* const urlsChannel = Channel.fromIterable([
|
|
2026
|
-
* "/api/users/1",
|
|
2027
|
-
* "/api/users/2",
|
|
2028
|
-
* "/api/users/3"
|
|
2029
|
-
* ])
|
|
2030
|
-
*
|
|
2031
|
-
* const fetchDataChannel = Channel.mapEffect(
|
|
2032
|
-
* urlsChannel,
|
|
2033
|
-
* (url) =>
|
|
2034
|
-
* Effect.tryPromise({
|
|
2035
|
-
* try: () => fetch(url).then((res) => res.json()),
|
|
2036
|
-
* catch: () => new NetworkError({ url })
|
|
2037
|
-
* })
|
|
2038
|
-
* )
|
|
2204
|
+
* ```ts import.meta.vitest
|
|
2205
|
+
* import { Channel, Effect } from "effect"
|
|
2039
2206
|
*
|
|
2040
|
-
* // Concurrent processing with options
|
|
2041
2207
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
2042
2208
|
* const processedChannel = Channel.mapEffect(
|
|
2043
2209
|
* numbersChannel,
|
|
2044
|
-
* (n) =>
|
|
2045
|
-
* Effect.gen(function*() {
|
|
2046
|
-
* yield* Effect.sleep("100 millis") // Simulate async work
|
|
2047
|
-
* return n * n
|
|
2048
|
-
* }),
|
|
2049
|
-
* { concurrency: 3, unordered: true }
|
|
2210
|
+
* (n) => Effect.succeed(n * n)
|
|
2050
2211
|
* )
|
|
2212
|
+
* await Effect.runPromise(Channel.runCollect(processedChannel)) // => [1, 4, 9, 16, 25]
|
|
2051
2213
|
* ```
|
|
2052
2214
|
*
|
|
2053
2215
|
* @category sequencing
|
|
@@ -2072,40 +2234,15 @@ export const mapEffect: {
|
|
|
2072
2234
|
*
|
|
2073
2235
|
* **Example** (Mapping channel output with effects)
|
|
2074
2236
|
*
|
|
2075
|
-
* ```ts
|
|
2076
|
-
* import { Channel,
|
|
2077
|
-
*
|
|
2078
|
-
* class NetworkError extends Data.TaggedError("NetworkError")<{
|
|
2079
|
-
* readonly url: string
|
|
2080
|
-
* }> {}
|
|
2081
|
-
*
|
|
2082
|
-
* // Transform values using effectful operations
|
|
2083
|
-
* const urlsChannel = Channel.fromIterable([
|
|
2084
|
-
* "/api/users/1",
|
|
2085
|
-
* "/api/users/2",
|
|
2086
|
-
* "/api/users/3"
|
|
2087
|
-
* ])
|
|
2088
|
-
*
|
|
2089
|
-
* const fetchDataChannel = Channel.mapEffect(
|
|
2090
|
-
* urlsChannel,
|
|
2091
|
-
* (url) =>
|
|
2092
|
-
* Effect.tryPromise({
|
|
2093
|
-
* try: () => fetch(url).then((res) => res.json()),
|
|
2094
|
-
* catch: () => new NetworkError({ url })
|
|
2095
|
-
* })
|
|
2096
|
-
* )
|
|
2237
|
+
* ```ts import.meta.vitest
|
|
2238
|
+
* import { Channel, Effect } from "effect"
|
|
2097
2239
|
*
|
|
2098
|
-
* // Concurrent processing with options
|
|
2099
2240
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
2100
2241
|
* const processedChannel = Channel.mapEffect(
|
|
2101
2242
|
* numbersChannel,
|
|
2102
|
-
* (n) =>
|
|
2103
|
-
* Effect.gen(function*() {
|
|
2104
|
-
* yield* Effect.sleep("100 millis") // Simulate async work
|
|
2105
|
-
* return n * n
|
|
2106
|
-
* }),
|
|
2107
|
-
* { concurrency: 3, unordered: true }
|
|
2243
|
+
* (n) => Effect.succeed(n * n)
|
|
2108
2244
|
* )
|
|
2245
|
+
* await Effect.runPromise(Channel.runCollect(processedChannel)) // => [1, 4, 9, 16, 25]
|
|
2109
2246
|
* ```
|
|
2110
2247
|
*
|
|
2111
2248
|
* @category sequencing
|
|
@@ -2138,40 +2275,15 @@ export const mapEffect: {
|
|
|
2138
2275
|
*
|
|
2139
2276
|
* **Example** (Mapping channel output with effects)
|
|
2140
2277
|
*
|
|
2141
|
-
* ```ts
|
|
2142
|
-
* import { Channel,
|
|
2143
|
-
*
|
|
2144
|
-
* class NetworkError extends Data.TaggedError("NetworkError")<{
|
|
2145
|
-
* readonly url: string
|
|
2146
|
-
* }> {}
|
|
2147
|
-
*
|
|
2148
|
-
* // Transform values using effectful operations
|
|
2149
|
-
* const urlsChannel = Channel.fromIterable([
|
|
2150
|
-
* "/api/users/1",
|
|
2151
|
-
* "/api/users/2",
|
|
2152
|
-
* "/api/users/3"
|
|
2153
|
-
* ])
|
|
2154
|
-
*
|
|
2155
|
-
* const fetchDataChannel = Channel.mapEffect(
|
|
2156
|
-
* urlsChannel,
|
|
2157
|
-
* (url) =>
|
|
2158
|
-
* Effect.tryPromise({
|
|
2159
|
-
* try: () => fetch(url).then((res) => res.json()),
|
|
2160
|
-
* catch: () => new NetworkError({ url })
|
|
2161
|
-
* })
|
|
2162
|
-
* )
|
|
2278
|
+
* ```ts import.meta.vitest
|
|
2279
|
+
* import { Channel, Effect } from "effect"
|
|
2163
2280
|
*
|
|
2164
|
-
* // Concurrent processing with options
|
|
2165
2281
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
2166
2282
|
* const processedChannel = Channel.mapEffect(
|
|
2167
2283
|
* numbersChannel,
|
|
2168
|
-
* (n) =>
|
|
2169
|
-
* Effect.gen(function*() {
|
|
2170
|
-
* yield* Effect.sleep("100 millis") // Simulate async work
|
|
2171
|
-
* return n * n
|
|
2172
|
-
* }),
|
|
2173
|
-
* { concurrency: 3, unordered: true }
|
|
2284
|
+
* (n) => Effect.succeed(n * n)
|
|
2174
2285
|
* )
|
|
2286
|
+
* await Effect.runPromise(Channel.runCollect(processedChannel)) // => [1, 4, 9, 16, 25]
|
|
2175
2287
|
* ```
|
|
2176
2288
|
*
|
|
2177
2289
|
* @category sequencing
|
|
@@ -2414,8 +2526,8 @@ export const mapInputError: {
|
|
|
2414
2526
|
*
|
|
2415
2527
|
* **Example** (Tapping channel output)
|
|
2416
2528
|
*
|
|
2417
|
-
* ```ts
|
|
2418
|
-
* import { Channel,
|
|
2529
|
+
* ```ts import.meta.vitest
|
|
2530
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2419
2531
|
*
|
|
2420
2532
|
* class LogError extends Data.TaggedError("LogError")<{
|
|
2421
2533
|
* readonly message: string
|
|
@@ -2425,13 +2537,13 @@ export const mapInputError: {
|
|
|
2425
2537
|
* const numberChannel = Channel.fromIterable([1, 2, 3])
|
|
2426
2538
|
*
|
|
2427
2539
|
* // Tap into each output element to perform side effects
|
|
2540
|
+
* const processed: Array<number> = []
|
|
2428
2541
|
* const tappedChannel = Channel.tap(
|
|
2429
2542
|
* numberChannel,
|
|
2430
|
-
* (n) =>
|
|
2543
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
2431
2544
|
* )
|
|
2432
2545
|
*
|
|
2433
|
-
*
|
|
2434
|
-
* // Outputs: 1, 2, 3 (while logging each)
|
|
2546
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(tappedChannel)), processed] // => [[1, 2, 3], [1, 2, 3]]
|
|
2435
2547
|
* ```
|
|
2436
2548
|
*
|
|
2437
2549
|
* @category sequencing
|
|
@@ -2450,8 +2562,8 @@ export const tap: {
|
|
|
2450
2562
|
*
|
|
2451
2563
|
* **Example** (Tapping channel output)
|
|
2452
2564
|
*
|
|
2453
|
-
* ```ts
|
|
2454
|
-
* import { Channel,
|
|
2565
|
+
* ```ts import.meta.vitest
|
|
2566
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2455
2567
|
*
|
|
2456
2568
|
* class LogError extends Data.TaggedError("LogError")<{
|
|
2457
2569
|
* readonly message: string
|
|
@@ -2461,13 +2573,13 @@ export const tap: {
|
|
|
2461
2573
|
* const numberChannel = Channel.fromIterable([1, 2, 3])
|
|
2462
2574
|
*
|
|
2463
2575
|
* // Tap into each output element to perform side effects
|
|
2576
|
+
* const processed: Array<number> = []
|
|
2464
2577
|
* const tappedChannel = Channel.tap(
|
|
2465
2578
|
* numberChannel,
|
|
2466
|
-
* (n) =>
|
|
2579
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
2467
2580
|
* )
|
|
2468
2581
|
*
|
|
2469
|
-
*
|
|
2470
|
-
* // Outputs: 1, 2, 3 (while logging each)
|
|
2582
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(tappedChannel)), processed] // => [[1, 2, 3], [1, 2, 3]]
|
|
2471
2583
|
* ```
|
|
2472
2584
|
*
|
|
2473
2585
|
* @category sequencing
|
|
@@ -2493,8 +2605,8 @@ export const tap: {
|
|
|
2493
2605
|
*
|
|
2494
2606
|
* **Example** (Tapping channel output)
|
|
2495
2607
|
*
|
|
2496
|
-
* ```ts
|
|
2497
|
-
* import { Channel,
|
|
2608
|
+
* ```ts import.meta.vitest
|
|
2609
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2498
2610
|
*
|
|
2499
2611
|
* class LogError extends Data.TaggedError("LogError")<{
|
|
2500
2612
|
* readonly message: string
|
|
@@ -2504,13 +2616,13 @@ export const tap: {
|
|
|
2504
2616
|
* const numberChannel = Channel.fromIterable([1, 2, 3])
|
|
2505
2617
|
*
|
|
2506
2618
|
* // Tap into each output element to perform side effects
|
|
2619
|
+
* const processed: Array<number> = []
|
|
2507
2620
|
* const tappedChannel = Channel.tap(
|
|
2508
2621
|
* numberChannel,
|
|
2509
|
-
* (n) =>
|
|
2622
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
2510
2623
|
* )
|
|
2511
2624
|
*
|
|
2512
|
-
*
|
|
2513
|
-
* // Outputs: 1, 2, 3 (while logging each)
|
|
2625
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(tappedChannel)), processed] // => [[1, 2, 3], [1, 2, 3]]
|
|
2514
2626
|
* ```
|
|
2515
2627
|
*
|
|
2516
2628
|
* @category sequencing
|
|
@@ -2548,8 +2660,8 @@ export const tap: {
|
|
|
2548
2660
|
*
|
|
2549
2661
|
* **Example** (Flat mapping channel output)
|
|
2550
2662
|
*
|
|
2551
|
-
* ```ts
|
|
2552
|
-
* import { Channel, Data } from "effect"
|
|
2663
|
+
* ```ts import.meta.vitest
|
|
2664
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2553
2665
|
*
|
|
2554
2666
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
2555
2667
|
* readonly cause: string
|
|
@@ -2565,8 +2677,7 @@ export const tap: {
|
|
|
2565
2677
|
* Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`))
|
|
2566
2678
|
* )
|
|
2567
2679
|
*
|
|
2568
|
-
* //
|
|
2569
|
-
* // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"
|
|
2680
|
+
* Effect.runSync(Channel.runCollect(flatMappedChannel)) // => ["item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"]
|
|
2570
2681
|
* ```
|
|
2571
2682
|
*
|
|
2572
2683
|
* @category sequencing
|
|
@@ -2586,8 +2697,8 @@ export const flatMap: {
|
|
|
2586
2697
|
*
|
|
2587
2698
|
* **Example** (Flat mapping channel output)
|
|
2588
2699
|
*
|
|
2589
|
-
* ```ts
|
|
2590
|
-
* import { Channel, Data } from "effect"
|
|
2700
|
+
* ```ts import.meta.vitest
|
|
2701
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2591
2702
|
*
|
|
2592
2703
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
2593
2704
|
* readonly cause: string
|
|
@@ -2603,8 +2714,7 @@ export const flatMap: {
|
|
|
2603
2714
|
* Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`))
|
|
2604
2715
|
* )
|
|
2605
2716
|
*
|
|
2606
|
-
* //
|
|
2607
|
-
* // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"
|
|
2717
|
+
* Effect.runSync(Channel.runCollect(flatMappedChannel)) // => ["item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"]
|
|
2608
2718
|
* ```
|
|
2609
2719
|
*
|
|
2610
2720
|
* @category sequencing
|
|
@@ -2640,8 +2750,8 @@ export const flatMap: {
|
|
|
2640
2750
|
*
|
|
2641
2751
|
* **Example** (Flat mapping channel output)
|
|
2642
2752
|
*
|
|
2643
|
-
* ```ts
|
|
2644
|
-
* import { Channel, Data } from "effect"
|
|
2753
|
+
* ```ts import.meta.vitest
|
|
2754
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2645
2755
|
*
|
|
2646
2756
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
2647
2757
|
* readonly cause: string
|
|
@@ -2657,8 +2767,7 @@ export const flatMap: {
|
|
|
2657
2767
|
* Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`))
|
|
2658
2768
|
* )
|
|
2659
2769
|
*
|
|
2660
|
-
* //
|
|
2661
|
-
* // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"
|
|
2770
|
+
* Effect.runSync(Channel.runCollect(flatMappedChannel)) // => ["item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"]
|
|
2662
2771
|
* ```
|
|
2663
2772
|
*
|
|
2664
2773
|
* @category sequencing
|
|
@@ -2828,8 +2937,8 @@ const flatMapConcurrent = <
|
|
|
2828
2937
|
*
|
|
2829
2938
|
* **Example** (Concatenating with completion values)
|
|
2830
2939
|
*
|
|
2831
|
-
* ```ts
|
|
2832
|
-
* import { Channel, Data } from "effect"
|
|
2940
|
+
* ```ts import.meta.vitest
|
|
2941
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2833
2942
|
*
|
|
2834
2943
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
2835
2944
|
* readonly reason: string
|
|
@@ -2840,8 +2949,7 @@ const flatMapConcurrent = <
|
|
|
2840
2949
|
* Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`))
|
|
2841
2950
|
* )
|
|
2842
2951
|
*
|
|
2843
|
-
* //
|
|
2844
|
-
* // Outputs: 1, 2, 3, then "Completed processing"
|
|
2952
|
+
* Effect.runSync(Channel.runCollect(numberChannel)) // => [1, 2, 3, "Completed processing"]
|
|
2845
2953
|
* ```
|
|
2846
2954
|
*
|
|
2847
2955
|
* @category sequencing
|
|
@@ -2854,8 +2962,8 @@ export const concatWith: {
|
|
|
2854
2962
|
*
|
|
2855
2963
|
* **Example** (Concatenating with completion values)
|
|
2856
2964
|
*
|
|
2857
|
-
* ```ts
|
|
2858
|
-
* import { Channel, Data } from "effect"
|
|
2965
|
+
* ```ts import.meta.vitest
|
|
2966
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2859
2967
|
*
|
|
2860
2968
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
2861
2969
|
* readonly reason: string
|
|
@@ -2866,8 +2974,7 @@ export const concatWith: {
|
|
|
2866
2974
|
* Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`))
|
|
2867
2975
|
* )
|
|
2868
2976
|
*
|
|
2869
|
-
* //
|
|
2870
|
-
* // Outputs: 1, 2, 3, then "Completed processing"
|
|
2977
|
+
* Effect.runSync(Channel.runCollect(numberChannel)) // => [1, 2, 3, "Completed processing"]
|
|
2871
2978
|
* ```
|
|
2872
2979
|
*
|
|
2873
2980
|
* @category sequencing
|
|
@@ -2892,8 +2999,8 @@ export const concatWith: {
|
|
|
2892
2999
|
*
|
|
2893
3000
|
* **Example** (Concatenating with completion values)
|
|
2894
3001
|
*
|
|
2895
|
-
* ```ts
|
|
2896
|
-
* import { Channel, Data } from "effect"
|
|
3002
|
+
* ```ts import.meta.vitest
|
|
3003
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2897
3004
|
*
|
|
2898
3005
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
2899
3006
|
* readonly reason: string
|
|
@@ -2904,8 +3011,7 @@ export const concatWith: {
|
|
|
2904
3011
|
* Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`))
|
|
2905
3012
|
* )
|
|
2906
3013
|
*
|
|
2907
|
-
* //
|
|
2908
|
-
* // Outputs: 1, 2, 3, then "Completed processing"
|
|
3014
|
+
* Effect.runSync(Channel.runCollect(numberChannel)) // => [1, 2, 3, "Completed processing"]
|
|
2909
3015
|
* ```
|
|
2910
3016
|
*
|
|
2911
3017
|
* @category sequencing
|
|
@@ -2991,8 +3097,8 @@ export const concatWith: {
|
|
|
2991
3097
|
*
|
|
2992
3098
|
* **Example** (Concatenating channels)
|
|
2993
3099
|
*
|
|
2994
|
-
* ```ts
|
|
2995
|
-
* import { Channel, Data } from "effect"
|
|
3100
|
+
* ```ts import.meta.vitest
|
|
3101
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2996
3102
|
*
|
|
2997
3103
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
2998
3104
|
* readonly reason: string
|
|
@@ -3005,7 +3111,7 @@ export const concatWith: {
|
|
|
3005
3111
|
* // Concatenate them
|
|
3006
3112
|
* const concatenatedChannel = Channel.concat(firstChannel, secondChannel)
|
|
3007
3113
|
*
|
|
3008
|
-
* //
|
|
3114
|
+
* Effect.runSync(Channel.runCollect(concatenatedChannel)) // => [1, 2, 3, "a", "b", "c"]
|
|
3009
3115
|
* ```
|
|
3010
3116
|
*
|
|
3011
3117
|
* @category sequencing
|
|
@@ -3018,8 +3124,8 @@ export const concat: {
|
|
|
3018
3124
|
*
|
|
3019
3125
|
* **Example** (Concatenating channels)
|
|
3020
3126
|
*
|
|
3021
|
-
* ```ts
|
|
3022
|
-
* import { Channel, Data } from "effect"
|
|
3127
|
+
* ```ts import.meta.vitest
|
|
3128
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3023
3129
|
*
|
|
3024
3130
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
3025
3131
|
* readonly reason: string
|
|
@@ -3032,7 +3138,7 @@ export const concat: {
|
|
|
3032
3138
|
* // Concatenate them
|
|
3033
3139
|
* const concatenatedChannel = Channel.concat(firstChannel, secondChannel)
|
|
3034
3140
|
*
|
|
3035
|
-
* //
|
|
3141
|
+
* Effect.runSync(Channel.runCollect(concatenatedChannel)) // => [1, 2, 3, "a", "b", "c"]
|
|
3036
3142
|
* ```
|
|
3037
3143
|
*
|
|
3038
3144
|
* @category sequencing
|
|
@@ -3055,8 +3161,8 @@ export const concat: {
|
|
|
3055
3161
|
*
|
|
3056
3162
|
* **Example** (Concatenating channels)
|
|
3057
3163
|
*
|
|
3058
|
-
* ```ts
|
|
3059
|
-
* import { Channel, Data } from "effect"
|
|
3164
|
+
* ```ts import.meta.vitest
|
|
3165
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3060
3166
|
*
|
|
3061
3167
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
3062
3168
|
* readonly reason: string
|
|
@@ -3069,7 +3175,7 @@ export const concat: {
|
|
|
3069
3175
|
* // Concatenate them
|
|
3070
3176
|
* const concatenatedChannel = Channel.concat(firstChannel, secondChannel)
|
|
3071
3177
|
*
|
|
3072
|
-
* //
|
|
3178
|
+
* Effect.runSync(Channel.runCollect(concatenatedChannel)) // => [1, 2, 3, "a", "b", "c"]
|
|
3073
3179
|
* ```
|
|
3074
3180
|
*
|
|
3075
3181
|
* @category sequencing
|
|
@@ -3425,8 +3531,8 @@ export const orElseIfEmpty: {
|
|
|
3425
3531
|
*
|
|
3426
3532
|
* **Example** (Flattening nested channels)
|
|
3427
3533
|
*
|
|
3428
|
-
* ```ts
|
|
3429
|
-
* import { Channel, Data } from "effect"
|
|
3534
|
+
* ```ts import.meta.vitest
|
|
3535
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3430
3536
|
*
|
|
3431
3537
|
* class FlattenError extends Data.TaggedError("FlattenError")<{
|
|
3432
3538
|
* readonly cause: string
|
|
@@ -3442,7 +3548,7 @@ export const orElseIfEmpty: {
|
|
|
3442
3548
|
* // Flatten the nested channels
|
|
3443
3549
|
* const flattenedChannel = Channel.flatten(nestedChannels)
|
|
3444
3550
|
*
|
|
3445
|
-
* //
|
|
3551
|
+
* Effect.runSync(Channel.runCollect(flattenedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
3446
3552
|
* ```
|
|
3447
3553
|
*
|
|
3448
3554
|
* @category constructors
|
|
@@ -3480,8 +3586,8 @@ export const flatten = <
|
|
|
3480
3586
|
*
|
|
3481
3587
|
* **Example** (Flattening arrays of channel output)
|
|
3482
3588
|
*
|
|
3483
|
-
* ```ts
|
|
3484
|
-
* import { Channel, Data } from "effect"
|
|
3589
|
+
* ```ts import.meta.vitest
|
|
3590
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3485
3591
|
*
|
|
3486
3592
|
* class FlattenError extends Data.TaggedError("FlattenError")<{
|
|
3487
3593
|
* readonly message: string
|
|
@@ -3497,7 +3603,7 @@ export const flatten = <
|
|
|
3497
3603
|
* // Flatten the arrays into individual elements
|
|
3498
3604
|
* const flattenedChannel = Channel.flattenArray(arrayChannel)
|
|
3499
3605
|
*
|
|
3500
|
-
* //
|
|
3606
|
+
* Effect.runSync(Channel.runCollect(flattenedChannel)) // => [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
3501
3607
|
* ```
|
|
3502
3608
|
*
|
|
3503
3609
|
* @category transforming
|
|
@@ -3575,8 +3681,8 @@ export const flattenTake = <
|
|
|
3575
3681
|
*
|
|
3576
3682
|
* **Example** (Draining channel output)
|
|
3577
3683
|
*
|
|
3578
|
-
* ```ts
|
|
3579
|
-
* import { Channel } from "effect"
|
|
3684
|
+
* ```ts import.meta.vitest
|
|
3685
|
+
* import { Channel, Effect } from "effect"
|
|
3580
3686
|
*
|
|
3581
3687
|
* // Create a channel that outputs values
|
|
3582
3688
|
* const sourceChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
@@ -3584,8 +3690,7 @@ export const flattenTake = <
|
|
|
3584
3690
|
* // Drain all output, keeping only the completion
|
|
3585
3691
|
* const drainedChannel = Channel.drain(sourceChannel)
|
|
3586
3692
|
*
|
|
3587
|
-
* //
|
|
3588
|
-
* // Useful for consuming side effects without collecting output
|
|
3693
|
+
* Effect.runSync(Channel.runCollect(drainedChannel)) // => []
|
|
3589
3694
|
* ```
|
|
3590
3695
|
*
|
|
3591
3696
|
* @category constructors
|
|
@@ -3771,15 +3876,15 @@ export const schedule: {
|
|
|
3771
3876
|
*
|
|
3772
3877
|
* **Example** (Filtering channel output)
|
|
3773
3878
|
*
|
|
3774
|
-
* ```ts
|
|
3775
|
-
* import { Channel } from "effect"
|
|
3879
|
+
* ```ts import.meta.vitest
|
|
3880
|
+
* import { Channel, Effect } from "effect"
|
|
3776
3881
|
*
|
|
3777
3882
|
* // Create a channel with mixed numbers
|
|
3778
3883
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8])
|
|
3779
3884
|
*
|
|
3780
3885
|
* // Filter to keep only even numbers
|
|
3781
3886
|
* const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0)
|
|
3782
|
-
* //
|
|
3887
|
+
* Effect.runSync(Channel.runCollect(evenChannel)) // => [2, 4, 6, 8]
|
|
3783
3888
|
*
|
|
3784
3889
|
* // Filter with type refinement
|
|
3785
3890
|
* const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3])
|
|
@@ -3787,7 +3892,7 @@ export const schedule: {
|
|
|
3787
3892
|
* mixedChannel,
|
|
3788
3893
|
* (value): value is number => typeof value === "number"
|
|
3789
3894
|
* )
|
|
3790
|
-
* //
|
|
3895
|
+
* Effect.runSync(Channel.runCollect(numbersOnlyChannel)) // => [1, 2, 3]
|
|
3791
3896
|
* ```
|
|
3792
3897
|
*
|
|
3793
3898
|
* @category filtering
|
|
@@ -3800,15 +3905,15 @@ export const filter: {
|
|
|
3800
3905
|
*
|
|
3801
3906
|
* **Example** (Filtering channel output)
|
|
3802
3907
|
*
|
|
3803
|
-
* ```ts
|
|
3804
|
-
* import { Channel } from "effect"
|
|
3908
|
+
* ```ts import.meta.vitest
|
|
3909
|
+
* import { Channel, Effect } from "effect"
|
|
3805
3910
|
*
|
|
3806
3911
|
* // Create a channel with mixed numbers
|
|
3807
3912
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8])
|
|
3808
3913
|
*
|
|
3809
3914
|
* // Filter to keep only even numbers
|
|
3810
3915
|
* const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0)
|
|
3811
|
-
* //
|
|
3916
|
+
* Effect.runSync(Channel.runCollect(evenChannel)) // => [2, 4, 6, 8]
|
|
3812
3917
|
*
|
|
3813
3918
|
* // Filter with type refinement
|
|
3814
3919
|
* const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3])
|
|
@@ -3816,7 +3921,7 @@ export const filter: {
|
|
|
3816
3921
|
* mixedChannel,
|
|
3817
3922
|
* (value): value is number => typeof value === "number"
|
|
3818
3923
|
* )
|
|
3819
|
-
* //
|
|
3924
|
+
* Effect.runSync(Channel.runCollect(numbersOnlyChannel)) // => [1, 2, 3]
|
|
3820
3925
|
* ```
|
|
3821
3926
|
*
|
|
3822
3927
|
* @category filtering
|
|
@@ -3831,15 +3936,15 @@ export const filter: {
|
|
|
3831
3936
|
*
|
|
3832
3937
|
* **Example** (Filtering channel output)
|
|
3833
3938
|
*
|
|
3834
|
-
* ```ts
|
|
3835
|
-
* import { Channel } from "effect"
|
|
3939
|
+
* ```ts import.meta.vitest
|
|
3940
|
+
* import { Channel, Effect } from "effect"
|
|
3836
3941
|
*
|
|
3837
3942
|
* // Create a channel with mixed numbers
|
|
3838
3943
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8])
|
|
3839
3944
|
*
|
|
3840
3945
|
* // Filter to keep only even numbers
|
|
3841
3946
|
* const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0)
|
|
3842
|
-
* //
|
|
3947
|
+
* Effect.runSync(Channel.runCollect(evenChannel)) // => [2, 4, 6, 8]
|
|
3843
3948
|
*
|
|
3844
3949
|
* // Filter with type refinement
|
|
3845
3950
|
* const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3])
|
|
@@ -3847,7 +3952,7 @@ export const filter: {
|
|
|
3847
3952
|
* mixedChannel,
|
|
3848
3953
|
* (value): value is number => typeof value === "number"
|
|
3849
3954
|
* )
|
|
3850
|
-
* //
|
|
3955
|
+
* Effect.runSync(Channel.runCollect(numbersOnlyChannel)) // => [1, 2, 3]
|
|
3851
3956
|
* ```
|
|
3852
3957
|
*
|
|
3853
3958
|
* @category filtering
|
|
@@ -3862,15 +3967,15 @@ export const filter: {
|
|
|
3862
3967
|
*
|
|
3863
3968
|
* **Example** (Filtering channel output)
|
|
3864
3969
|
*
|
|
3865
|
-
* ```ts
|
|
3866
|
-
* import { Channel } from "effect"
|
|
3970
|
+
* ```ts import.meta.vitest
|
|
3971
|
+
* import { Channel, Effect } from "effect"
|
|
3867
3972
|
*
|
|
3868
3973
|
* // Create a channel with mixed numbers
|
|
3869
3974
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8])
|
|
3870
3975
|
*
|
|
3871
3976
|
* // Filter to keep only even numbers
|
|
3872
3977
|
* const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0)
|
|
3873
|
-
* //
|
|
3978
|
+
* Effect.runSync(Channel.runCollect(evenChannel)) // => [2, 4, 6, 8]
|
|
3874
3979
|
*
|
|
3875
3980
|
* // Filter with type refinement
|
|
3876
3981
|
* const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3])
|
|
@@ -3878,7 +3983,7 @@ export const filter: {
|
|
|
3878
3983
|
* mixedChannel,
|
|
3879
3984
|
* (value): value is number => typeof value === "number"
|
|
3880
3985
|
* )
|
|
3881
|
-
* //
|
|
3986
|
+
* Effect.runSync(Channel.runCollect(numbersOnlyChannel)) // => [1, 2, 3]
|
|
3882
3987
|
* ```
|
|
3883
3988
|
*
|
|
3884
3989
|
* @category filtering
|
|
@@ -3894,15 +3999,15 @@ export const filter: {
|
|
|
3894
3999
|
*
|
|
3895
4000
|
* **Example** (Filtering channel output)
|
|
3896
4001
|
*
|
|
3897
|
-
* ```ts
|
|
3898
|
-
* import { Channel } from "effect"
|
|
4002
|
+
* ```ts import.meta.vitest
|
|
4003
|
+
* import { Channel, Effect } from "effect"
|
|
3899
4004
|
*
|
|
3900
4005
|
* // Create a channel with mixed numbers
|
|
3901
4006
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8])
|
|
3902
4007
|
*
|
|
3903
4008
|
* // Filter to keep only even numbers
|
|
3904
4009
|
* const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0)
|
|
3905
|
-
* //
|
|
4010
|
+
* Effect.runSync(Channel.runCollect(evenChannel)) // => [2, 4, 6, 8]
|
|
3906
4011
|
*
|
|
3907
4012
|
* // Filter with type refinement
|
|
3908
4013
|
* const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3])
|
|
@@ -3910,7 +4015,7 @@ export const filter: {
|
|
|
3910
4015
|
* mixedChannel,
|
|
3911
4016
|
* (value): value is number => typeof value === "number"
|
|
3912
4017
|
* )
|
|
3913
|
-
* //
|
|
4018
|
+
* Effect.runSync(Channel.runCollect(numbersOnlyChannel)) // => [1, 2, 3]
|
|
3914
4019
|
* ```
|
|
3915
4020
|
*
|
|
3916
4021
|
* @category filtering
|
|
@@ -4203,8 +4308,8 @@ export const filterMapEffect: {
|
|
|
4203
4308
|
*
|
|
4204
4309
|
* **Example** (Filtering array output)
|
|
4205
4310
|
*
|
|
4206
|
-
* ```ts
|
|
4207
|
-
* import { Array, Channel } from "effect"
|
|
4311
|
+
* ```ts import.meta.vitest
|
|
4312
|
+
* import { Array, Channel, Effect } from "effect"
|
|
4208
4313
|
*
|
|
4209
4314
|
* const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
|
|
4210
4315
|
*
|
|
@@ -4217,7 +4322,7 @@ export const filterMapEffect: {
|
|
|
4217
4322
|
*
|
|
4218
4323
|
* // Filter arrays to keep only even numbers
|
|
4219
4324
|
* const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
|
|
4220
|
-
* //
|
|
4325
|
+
* Effect.runSync(Channel.runCollect(evenArraysChannel)) // => [[2, 4], [6, 8, 10], [12, 14]]
|
|
4221
4326
|
* // Note: Only non-empty filtered arrays are emitted
|
|
4222
4327
|
*
|
|
4223
4328
|
* // Arrays that would become empty after filtering are discarded entirely
|
|
@@ -4227,7 +4332,7 @@ export const filterMapEffect: {
|
|
|
4227
4332
|
* Array.make(7, 9)
|
|
4228
4333
|
* ]).pipe(Channel.filter(nonEmptyArrayPredicate))
|
|
4229
4334
|
* const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
|
|
4230
|
-
* //
|
|
4335
|
+
* Effect.runSync(Channel.runCollect(filteredOddChannel)) // => [[2, 4]]
|
|
4231
4336
|
* ```
|
|
4232
4337
|
*
|
|
4233
4338
|
* @category filtering
|
|
@@ -4240,8 +4345,8 @@ export const filterArray: {
|
|
|
4240
4345
|
*
|
|
4241
4346
|
* **Example** (Filtering array output)
|
|
4242
4347
|
*
|
|
4243
|
-
* ```ts
|
|
4244
|
-
* import { Array, Channel } from "effect"
|
|
4348
|
+
* ```ts import.meta.vitest
|
|
4349
|
+
* import { Array, Channel, Effect } from "effect"
|
|
4245
4350
|
*
|
|
4246
4351
|
* const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
|
|
4247
4352
|
*
|
|
@@ -4254,7 +4359,7 @@ export const filterArray: {
|
|
|
4254
4359
|
*
|
|
4255
4360
|
* // Filter arrays to keep only even numbers
|
|
4256
4361
|
* const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
|
|
4257
|
-
* //
|
|
4362
|
+
* Effect.runSync(Channel.runCollect(evenArraysChannel)) // => [[2, 4], [6, 8, 10], [12, 14]]
|
|
4258
4363
|
* // Note: Only non-empty filtered arrays are emitted
|
|
4259
4364
|
*
|
|
4260
4365
|
* // Arrays that would become empty after filtering are discarded entirely
|
|
@@ -4264,7 +4369,7 @@ export const filterArray: {
|
|
|
4264
4369
|
* Array.make(7, 9)
|
|
4265
4370
|
* ]).pipe(Channel.filter(nonEmptyArrayPredicate))
|
|
4266
4371
|
* const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
|
|
4267
|
-
* //
|
|
4372
|
+
* Effect.runSync(Channel.runCollect(filteredOddChannel)) // => [[2, 4]]
|
|
4268
4373
|
* ```
|
|
4269
4374
|
*
|
|
4270
4375
|
* @category filtering
|
|
@@ -4279,8 +4384,8 @@ export const filterArray: {
|
|
|
4279
4384
|
*
|
|
4280
4385
|
* **Example** (Filtering array output)
|
|
4281
4386
|
*
|
|
4282
|
-
* ```ts
|
|
4283
|
-
* import { Array, Channel } from "effect"
|
|
4387
|
+
* ```ts import.meta.vitest
|
|
4388
|
+
* import { Array, Channel, Effect } from "effect"
|
|
4284
4389
|
*
|
|
4285
4390
|
* const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
|
|
4286
4391
|
*
|
|
@@ -4293,7 +4398,7 @@ export const filterArray: {
|
|
|
4293
4398
|
*
|
|
4294
4399
|
* // Filter arrays to keep only even numbers
|
|
4295
4400
|
* const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
|
|
4296
|
-
* //
|
|
4401
|
+
* Effect.runSync(Channel.runCollect(evenArraysChannel)) // => [[2, 4], [6, 8, 10], [12, 14]]
|
|
4297
4402
|
* // Note: Only non-empty filtered arrays are emitted
|
|
4298
4403
|
*
|
|
4299
4404
|
* // Arrays that would become empty after filtering are discarded entirely
|
|
@@ -4303,7 +4408,7 @@ export const filterArray: {
|
|
|
4303
4408
|
* Array.make(7, 9)
|
|
4304
4409
|
* ]).pipe(Channel.filter(nonEmptyArrayPredicate))
|
|
4305
4410
|
* const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
|
|
4306
|
-
* //
|
|
4411
|
+
* Effect.runSync(Channel.runCollect(filteredOddChannel)) // => [[2, 4]]
|
|
4307
4412
|
* ```
|
|
4308
4413
|
*
|
|
4309
4414
|
* @category filtering
|
|
@@ -4318,8 +4423,8 @@ export const filterArray: {
|
|
|
4318
4423
|
*
|
|
4319
4424
|
* **Example** (Filtering array output)
|
|
4320
4425
|
*
|
|
4321
|
-
* ```ts
|
|
4322
|
-
* import { Array, Channel } from "effect"
|
|
4426
|
+
* ```ts import.meta.vitest
|
|
4427
|
+
* import { Array, Channel, Effect } from "effect"
|
|
4323
4428
|
*
|
|
4324
4429
|
* const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
|
|
4325
4430
|
*
|
|
@@ -4332,7 +4437,7 @@ export const filterArray: {
|
|
|
4332
4437
|
*
|
|
4333
4438
|
* // Filter arrays to keep only even numbers
|
|
4334
4439
|
* const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
|
|
4335
|
-
* //
|
|
4440
|
+
* Effect.runSync(Channel.runCollect(evenArraysChannel)) // => [[2, 4], [6, 8, 10], [12, 14]]
|
|
4336
4441
|
* // Note: Only non-empty filtered arrays are emitted
|
|
4337
4442
|
*
|
|
4338
4443
|
* // Arrays that would become empty after filtering are discarded entirely
|
|
@@ -4342,7 +4447,7 @@ export const filterArray: {
|
|
|
4342
4447
|
* Array.make(7, 9)
|
|
4343
4448
|
* ]).pipe(Channel.filter(nonEmptyArrayPredicate))
|
|
4344
4449
|
* const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
|
|
4345
|
-
* //
|
|
4450
|
+
* Effect.runSync(Channel.runCollect(filteredOddChannel)) // => [[2, 4]]
|
|
4346
4451
|
* ```
|
|
4347
4452
|
*
|
|
4348
4453
|
* @category filtering
|
|
@@ -4358,8 +4463,8 @@ export const filterArray: {
|
|
|
4358
4463
|
*
|
|
4359
4464
|
* **Example** (Filtering array output)
|
|
4360
4465
|
*
|
|
4361
|
-
* ```ts
|
|
4362
|
-
* import { Array, Channel } from "effect"
|
|
4466
|
+
* ```ts import.meta.vitest
|
|
4467
|
+
* import { Array, Channel, Effect } from "effect"
|
|
4363
4468
|
*
|
|
4364
4469
|
* const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
|
|
4365
4470
|
*
|
|
@@ -4372,7 +4477,7 @@ export const filterArray: {
|
|
|
4372
4477
|
*
|
|
4373
4478
|
* // Filter arrays to keep only even numbers
|
|
4374
4479
|
* const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
|
|
4375
|
-
* //
|
|
4480
|
+
* Effect.runSync(Channel.runCollect(evenArraysChannel)) // => [[2, 4], [6, 8, 10], [12, 14]]
|
|
4376
4481
|
* // Note: Only non-empty filtered arrays are emitted
|
|
4377
4482
|
*
|
|
4378
4483
|
* // Arrays that would become empty after filtering are discarded entirely
|
|
@@ -4382,7 +4487,7 @@ export const filterArray: {
|
|
|
4382
4487
|
* Array.make(7, 9)
|
|
4383
4488
|
* ]).pipe(Channel.filter(nonEmptyArrayPredicate))
|
|
4384
4489
|
* const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
|
|
4385
|
-
* //
|
|
4490
|
+
* Effect.runSync(Channel.runCollect(filteredOddChannel)) // => [[2, 4]]
|
|
4386
4491
|
* ```
|
|
4387
4492
|
*
|
|
4388
4493
|
* @category filtering
|
|
@@ -4640,7 +4745,7 @@ export const filterMapArrayEffect: {
|
|
|
4640
4745
|
*
|
|
4641
4746
|
* **Example** (Mapping with accumulated state)
|
|
4642
4747
|
*
|
|
4643
|
-
* ```ts
|
|
4748
|
+
* ```ts import.meta.vitest
|
|
4644
4749
|
* import { Channel, Effect } from "effect"
|
|
4645
4750
|
*
|
|
4646
4751
|
* // Create a channel with numbers
|
|
@@ -4656,8 +4761,6 @@ export const filterMapArrayEffect: {
|
|
|
4656
4761
|
* return [newSum, [current, newSum]] as const
|
|
4657
4762
|
* }
|
|
4658
4763
|
* )
|
|
4659
|
-
* // Outputs: 1, 1, 2, 3, 3, 6, 4, 10
|
|
4660
|
-
*
|
|
4661
4764
|
* // Using with Effect for async processing
|
|
4662
4765
|
* const asyncMapAccum = Channel.mapAccum(
|
|
4663
4766
|
* numbersChannel,
|
|
@@ -4668,6 +4771,8 @@ export const filterMapArrayEffect: {
|
|
|
4668
4771
|
* return [newAcc, [`${value}-processed`, newAcc]] as const
|
|
4669
4772
|
* })
|
|
4670
4773
|
* )
|
|
4774
|
+
* Effect.runSync(Channel.runCollect(runningSum)) // => [1, 1, 2, 3, 3, 6, 4, 10]
|
|
4775
|
+
* Effect.runSync(Channel.runCollect(asyncMapAccum)) // => ["1-processed", "1", "2-processed", "12", "3-processed", "123", "4-processed", "1234"]
|
|
4671
4776
|
* ```
|
|
4672
4777
|
*
|
|
4673
4778
|
* @category sequencing
|
|
@@ -4679,7 +4784,7 @@ export const mapAccum: {
|
|
|
4679
4784
|
*
|
|
4680
4785
|
* **Example** (Mapping with accumulated state)
|
|
4681
4786
|
*
|
|
4682
|
-
* ```ts
|
|
4787
|
+
* ```ts import.meta.vitest
|
|
4683
4788
|
* import { Channel, Effect } from "effect"
|
|
4684
4789
|
*
|
|
4685
4790
|
* // Create a channel with numbers
|
|
@@ -4695,8 +4800,6 @@ export const mapAccum: {
|
|
|
4695
4800
|
* return [newSum, [current, newSum]] as const
|
|
4696
4801
|
* }
|
|
4697
4802
|
* )
|
|
4698
|
-
* // Outputs: 1, 1, 2, 3, 3, 6, 4, 10
|
|
4699
|
-
*
|
|
4700
4803
|
* // Using with Effect for async processing
|
|
4701
4804
|
* const asyncMapAccum = Channel.mapAccum(
|
|
4702
4805
|
* numbersChannel,
|
|
@@ -4707,6 +4810,8 @@ export const mapAccum: {
|
|
|
4707
4810
|
* return [newAcc, [`${value}-processed`, newAcc]] as const
|
|
4708
4811
|
* })
|
|
4709
4812
|
* )
|
|
4813
|
+
* Effect.runSync(Channel.runCollect(runningSum)) // => [1, 1, 2, 3, 3, 6, 4, 10]
|
|
4814
|
+
* Effect.runSync(Channel.runCollect(asyncMapAccum)) // => ["1-processed", "1", "2-processed", "12", "3-processed", "123", "4-processed", "1234"]
|
|
4710
4815
|
* ```
|
|
4711
4816
|
*
|
|
4712
4817
|
* @category sequencing
|
|
@@ -4744,7 +4849,7 @@ export const mapAccum: {
|
|
|
4744
4849
|
*
|
|
4745
4850
|
* **Example** (Mapping with accumulated state)
|
|
4746
4851
|
*
|
|
4747
|
-
* ```ts
|
|
4852
|
+
* ```ts import.meta.vitest
|
|
4748
4853
|
* import { Channel, Effect } from "effect"
|
|
4749
4854
|
*
|
|
4750
4855
|
* // Create a channel with numbers
|
|
@@ -4760,8 +4865,6 @@ export const mapAccum: {
|
|
|
4760
4865
|
* return [newSum, [current, newSum]] as const
|
|
4761
4866
|
* }
|
|
4762
4867
|
* )
|
|
4763
|
-
* // Outputs: 1, 1, 2, 3, 3, 6, 4, 10
|
|
4764
|
-
*
|
|
4765
4868
|
* // Using with Effect for async processing
|
|
4766
4869
|
* const asyncMapAccum = Channel.mapAccum(
|
|
4767
4870
|
* numbersChannel,
|
|
@@ -4772,6 +4875,8 @@ export const mapAccum: {
|
|
|
4772
4875
|
* return [newAcc, [`${value}-processed`, newAcc]] as const
|
|
4773
4876
|
* })
|
|
4774
4877
|
* )
|
|
4878
|
+
* Effect.runSync(Channel.runCollect(runningSum)) // => [1, 1, 2, 3, 3, 6, 4, 10]
|
|
4879
|
+
* Effect.runSync(Channel.runCollect(asyncMapAccum)) // => ["1-processed", "1", "2-processed", "12", "3-processed", "123", "4-processed", "1234"]
|
|
4775
4880
|
* ```
|
|
4776
4881
|
*
|
|
4777
4882
|
* @category sequencing
|
|
@@ -4858,15 +4963,15 @@ export const mapAccum: {
|
|
|
4858
4963
|
*
|
|
4859
4964
|
* **Example** (Scanning channel output)
|
|
4860
4965
|
*
|
|
4861
|
-
* ```ts
|
|
4862
|
-
* import { Channel } from "effect"
|
|
4966
|
+
* ```ts import.meta.vitest
|
|
4967
|
+
* import { Channel, Effect } from "effect"
|
|
4863
4968
|
*
|
|
4864
4969
|
* // Create a channel with numbers
|
|
4865
4970
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
4866
4971
|
*
|
|
4867
4972
|
* // Scan to create running sum
|
|
4868
4973
|
* const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n)
|
|
4869
|
-
* //
|
|
4974
|
+
* Effect.runSync(Channel.runCollect(runningSumChannel)) // => [0, 1, 3, 6, 10, 15]
|
|
4870
4975
|
* // Note: emits the initial value and each intermediate result
|
|
4871
4976
|
*
|
|
4872
4977
|
* // Scan with string concatenation
|
|
@@ -4876,7 +4981,7 @@ export const mapAccum: {
|
|
|
4876
4981
|
* "",
|
|
4877
4982
|
* (sentence, word) => sentence === "" ? word : `${sentence} ${word}`
|
|
4878
4983
|
* )
|
|
4879
|
-
* //
|
|
4984
|
+
* Effect.runSync(Channel.runCollect(sentenceChannel)) // => ["", "hello", "hello world", "hello world from", "hello world from effect"]
|
|
4880
4985
|
* ```
|
|
4881
4986
|
*
|
|
4882
4987
|
* @category sequencing
|
|
@@ -4889,15 +4994,15 @@ export const scan: {
|
|
|
4889
4994
|
*
|
|
4890
4995
|
* **Example** (Scanning channel output)
|
|
4891
4996
|
*
|
|
4892
|
-
* ```ts
|
|
4893
|
-
* import { Channel } from "effect"
|
|
4997
|
+
* ```ts import.meta.vitest
|
|
4998
|
+
* import { Channel, Effect } from "effect"
|
|
4894
4999
|
*
|
|
4895
5000
|
* // Create a channel with numbers
|
|
4896
5001
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
4897
5002
|
*
|
|
4898
5003
|
* // Scan to create running sum
|
|
4899
5004
|
* const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n)
|
|
4900
|
-
* //
|
|
5005
|
+
* Effect.runSync(Channel.runCollect(runningSumChannel)) // => [0, 1, 3, 6, 10, 15]
|
|
4901
5006
|
* // Note: emits the initial value and each intermediate result
|
|
4902
5007
|
*
|
|
4903
5008
|
* // Scan with string concatenation
|
|
@@ -4907,7 +5012,7 @@ export const scan: {
|
|
|
4907
5012
|
* "",
|
|
4908
5013
|
* (sentence, word) => sentence === "" ? word : `${sentence} ${word}`
|
|
4909
5014
|
* )
|
|
4910
|
-
* //
|
|
5015
|
+
* Effect.runSync(Channel.runCollect(sentenceChannel)) // => ["", "hello", "hello world", "hello world from", "hello world from effect"]
|
|
4911
5016
|
* ```
|
|
4912
5017
|
*
|
|
4913
5018
|
* @category sequencing
|
|
@@ -4935,15 +5040,15 @@ export const scan: {
|
|
|
4935
5040
|
*
|
|
4936
5041
|
* **Example** (Scanning channel output)
|
|
4937
5042
|
*
|
|
4938
|
-
* ```ts
|
|
4939
|
-
* import { Channel } from "effect"
|
|
5043
|
+
* ```ts import.meta.vitest
|
|
5044
|
+
* import { Channel, Effect } from "effect"
|
|
4940
5045
|
*
|
|
4941
5046
|
* // Create a channel with numbers
|
|
4942
5047
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
4943
5048
|
*
|
|
4944
5049
|
* // Scan to create running sum
|
|
4945
5050
|
* const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n)
|
|
4946
|
-
* //
|
|
5051
|
+
* Effect.runSync(Channel.runCollect(runningSumChannel)) // => [0, 1, 3, 6, 10, 15]
|
|
4947
5052
|
* // Note: emits the initial value and each intermediate result
|
|
4948
5053
|
*
|
|
4949
5054
|
* // Scan with string concatenation
|
|
@@ -4953,7 +5058,7 @@ export const scan: {
|
|
|
4953
5058
|
* "",
|
|
4954
5059
|
* (sentence, word) => sentence === "" ? word : `${sentence} ${word}`
|
|
4955
5060
|
* )
|
|
4956
|
-
* //
|
|
5061
|
+
* Effect.runSync(Channel.runCollect(sentenceChannel)) // => ["", "hello", "hello world", "hello world from", "hello world from effect"]
|
|
4957
5062
|
* ```
|
|
4958
5063
|
*
|
|
4959
5064
|
* @category sequencing
|
|
@@ -4982,7 +5087,7 @@ export const scan: {
|
|
|
4982
5087
|
*
|
|
4983
5088
|
* **Example** (Scanning channel output with effects)
|
|
4984
5089
|
*
|
|
4985
|
-
* ```ts
|
|
5090
|
+
* ```ts import.meta.vitest
|
|
4986
5091
|
* import { Channel, Data, Effect } from "effect"
|
|
4987
5092
|
*
|
|
4988
5093
|
* class ScanError extends Data.TaggedError("ScanError")<{
|
|
@@ -4998,12 +5103,10 @@ export const scan: {
|
|
|
4998
5103
|
* "",
|
|
4999
5104
|
* (acc, value) =>
|
|
5000
5105
|
* Effect.gen(function*() {
|
|
5001
|
-
* // Simulate async work
|
|
5002
|
-
* yield* Effect.sleep("10 millis")
|
|
5003
5106
|
* return acc + value.toString()
|
|
5004
5107
|
* })
|
|
5005
5108
|
* )
|
|
5006
|
-
* //
|
|
5109
|
+
* await Effect.runPromise(Channel.runCollect(asyncScanChannel)) // => ["", "1", "12", "123", "1234"]
|
|
5007
5110
|
*
|
|
5008
5111
|
* // Scan with error handling
|
|
5009
5112
|
* const errorHandlingScan = Channel.scanEffect(
|
|
@@ -5016,6 +5119,7 @@ export const scan: {
|
|
|
5016
5119
|
* return Effect.succeed(sum + n)
|
|
5017
5120
|
* }
|
|
5018
5121
|
* )
|
|
5122
|
+
* await Effect.runPromise(Channel.runCollect(errorHandlingScan)) // => [0, 1, 3, 6, 10]
|
|
5019
5123
|
* ```
|
|
5020
5124
|
*
|
|
5021
5125
|
* @category sequencing
|
|
@@ -5033,7 +5137,7 @@ export const scanEffect: {
|
|
|
5033
5137
|
*
|
|
5034
5138
|
* **Example** (Scanning channel output with effects)
|
|
5035
5139
|
*
|
|
5036
|
-
* ```ts
|
|
5140
|
+
* ```ts import.meta.vitest
|
|
5037
5141
|
* import { Channel, Data, Effect } from "effect"
|
|
5038
5142
|
*
|
|
5039
5143
|
* class ScanError extends Data.TaggedError("ScanError")<{
|
|
@@ -5049,12 +5153,10 @@ export const scanEffect: {
|
|
|
5049
5153
|
* "",
|
|
5050
5154
|
* (acc, value) =>
|
|
5051
5155
|
* Effect.gen(function*() {
|
|
5052
|
-
* // Simulate async work
|
|
5053
|
-
* yield* Effect.sleep("10 millis")
|
|
5054
5156
|
* return acc + value.toString()
|
|
5055
5157
|
* })
|
|
5056
5158
|
* )
|
|
5057
|
-
* //
|
|
5159
|
+
* await Effect.runPromise(Channel.runCollect(asyncScanChannel)) // => ["", "1", "12", "123", "1234"]
|
|
5058
5160
|
*
|
|
5059
5161
|
* // Scan with error handling
|
|
5060
5162
|
* const errorHandlingScan = Channel.scanEffect(
|
|
@@ -5067,6 +5169,7 @@ export const scanEffect: {
|
|
|
5067
5169
|
* return Effect.succeed(sum + n)
|
|
5068
5170
|
* }
|
|
5069
5171
|
* )
|
|
5172
|
+
* await Effect.runPromise(Channel.runCollect(errorHandlingScan)) // => [0, 1, 3, 6, 10]
|
|
5070
5173
|
* ```
|
|
5071
5174
|
*
|
|
5072
5175
|
* @category sequencing
|
|
@@ -5099,7 +5202,7 @@ export const scanEffect: {
|
|
|
5099
5202
|
*
|
|
5100
5203
|
* **Example** (Scanning channel output with effects)
|
|
5101
5204
|
*
|
|
5102
|
-
* ```ts
|
|
5205
|
+
* ```ts import.meta.vitest
|
|
5103
5206
|
* import { Channel, Data, Effect } from "effect"
|
|
5104
5207
|
*
|
|
5105
5208
|
* class ScanError extends Data.TaggedError("ScanError")<{
|
|
@@ -5115,12 +5218,10 @@ export const scanEffect: {
|
|
|
5115
5218
|
* "",
|
|
5116
5219
|
* (acc, value) =>
|
|
5117
5220
|
* Effect.gen(function*() {
|
|
5118
|
-
* // Simulate async work
|
|
5119
|
-
* yield* Effect.sleep("10 millis")
|
|
5120
5221
|
* return acc + value.toString()
|
|
5121
5222
|
* })
|
|
5122
5223
|
* )
|
|
5123
|
-
* //
|
|
5224
|
+
* await Effect.runPromise(Channel.runCollect(asyncScanChannel)) // => ["", "1", "12", "123", "1234"]
|
|
5124
5225
|
*
|
|
5125
5226
|
* // Scan with error handling
|
|
5126
5227
|
* const errorHandlingScan = Channel.scanEffect(
|
|
@@ -5133,6 +5234,7 @@ export const scanEffect: {
|
|
|
5133
5234
|
* return Effect.succeed(sum + n)
|
|
5134
5235
|
* }
|
|
5135
5236
|
* )
|
|
5237
|
+
* await Effect.runPromise(Channel.runCollect(errorHandlingScan)) // => [0, 1, 3, 6, 10]
|
|
5136
5238
|
* ```
|
|
5137
5239
|
*
|
|
5138
5240
|
* @category sequencing
|
|
@@ -5174,8 +5276,8 @@ export const scanEffect: {
|
|
|
5174
5276
|
*
|
|
5175
5277
|
* **Example** (Recovering from failure causes)
|
|
5176
5278
|
*
|
|
5177
|
-
* ```ts
|
|
5178
|
-
* import { Cause, Channel, Data } from "effect"
|
|
5279
|
+
* ```ts import.meta.vitest
|
|
5280
|
+
* import { Cause, Channel, Data, Effect } from "effect"
|
|
5179
5281
|
*
|
|
5180
5282
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
5181
5283
|
* readonly reason: string
|
|
@@ -5198,7 +5300,7 @@ export const scanEffect: {
|
|
|
5198
5300
|
* return Channel.succeed("Recovered from interruption")
|
|
5199
5301
|
* })
|
|
5200
5302
|
*
|
|
5201
|
-
* //
|
|
5303
|
+
* Effect.runSync(Channel.runCollect(recoveredChannel)) // => ["Recovered from failure"]
|
|
5202
5304
|
* ```
|
|
5203
5305
|
*
|
|
5204
5306
|
* @category error handling
|
|
@@ -5211,8 +5313,8 @@ export const catchCause: {
|
|
|
5211
5313
|
*
|
|
5212
5314
|
* **Example** (Recovering from failure causes)
|
|
5213
5315
|
*
|
|
5214
|
-
* ```ts
|
|
5215
|
-
* import { Cause, Channel, Data } from "effect"
|
|
5316
|
+
* ```ts import.meta.vitest
|
|
5317
|
+
* import { Cause, Channel, Data, Effect } from "effect"
|
|
5216
5318
|
*
|
|
5217
5319
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
5218
5320
|
* readonly reason: string
|
|
@@ -5235,7 +5337,7 @@ export const catchCause: {
|
|
|
5235
5337
|
* return Channel.succeed("Recovered from interruption")
|
|
5236
5338
|
* })
|
|
5237
5339
|
*
|
|
5238
|
-
* //
|
|
5340
|
+
* Effect.runSync(Channel.runCollect(recoveredChannel)) // => ["Recovered from failure"]
|
|
5239
5341
|
* ```
|
|
5240
5342
|
*
|
|
5241
5343
|
* @category error handling
|
|
@@ -5265,8 +5367,8 @@ export const catchCause: {
|
|
|
5265
5367
|
*
|
|
5266
5368
|
* **Example** (Recovering from failure causes)
|
|
5267
5369
|
*
|
|
5268
|
-
* ```ts
|
|
5269
|
-
* import { Cause, Channel, Data } from "effect"
|
|
5370
|
+
* ```ts import.meta.vitest
|
|
5371
|
+
* import { Cause, Channel, Data, Effect } from "effect"
|
|
5270
5372
|
*
|
|
5271
5373
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
5272
5374
|
* readonly reason: string
|
|
@@ -5289,7 +5391,7 @@ export const catchCause: {
|
|
|
5289
5391
|
* return Channel.succeed("Recovered from interruption")
|
|
5290
5392
|
* })
|
|
5291
5393
|
*
|
|
5292
|
-
* //
|
|
5394
|
+
* Effect.runSync(Channel.runCollect(recoveredChannel)) // => ["Recovered from failure"]
|
|
5293
5395
|
* ```
|
|
5294
5396
|
*
|
|
5295
5397
|
* @category error handling
|
|
@@ -6762,8 +6864,8 @@ export const catchTag: {
|
|
|
6762
6864
|
*
|
|
6763
6865
|
* **Example** (Recovering from nested reasons)
|
|
6764
6866
|
*
|
|
6765
|
-
* ```ts
|
|
6766
|
-
* import { Channel, Data } from "effect"
|
|
6867
|
+
* ```ts import.meta.vitest
|
|
6868
|
+
* import { Channel, Data, Effect } from "effect"
|
|
6767
6869
|
*
|
|
6768
6870
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
6769
6871
|
* retryAfter: number
|
|
@@ -6777,15 +6879,15 @@ export const catchTag: {
|
|
|
6777
6879
|
* reason: RateLimitError | QuotaExceededError
|
|
6778
6880
|
* }> {}
|
|
6779
6881
|
*
|
|
6780
|
-
* const
|
|
6781
|
-
*
|
|
6782
|
-
* )
|
|
6882
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
6883
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
6783
6884
|
*
|
|
6784
6885
|
* const recovered = channel.pipe(
|
|
6785
6886
|
* Channel.catchReason("AiError", "RateLimitError", (reason) =>
|
|
6786
6887
|
* Channel.succeed(`retry: ${reason.retryAfter}`)
|
|
6787
6888
|
* )
|
|
6788
6889
|
* )
|
|
6890
|
+
* Effect.runSync(Channel.runCollect(recovered)) // => ["retry: 60"]
|
|
6789
6891
|
* ```
|
|
6790
6892
|
*
|
|
6791
6893
|
* @category error handling
|
|
@@ -6797,8 +6899,8 @@ export const catchReason: {
|
|
|
6797
6899
|
*
|
|
6798
6900
|
* **Example** (Recovering from nested reasons)
|
|
6799
6901
|
*
|
|
6800
|
-
* ```ts
|
|
6801
|
-
* import { Channel, Data } from "effect"
|
|
6902
|
+
* ```ts import.meta.vitest
|
|
6903
|
+
* import { Channel, Data, Effect } from "effect"
|
|
6802
6904
|
*
|
|
6803
6905
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
6804
6906
|
* retryAfter: number
|
|
@@ -6812,15 +6914,15 @@ export const catchReason: {
|
|
|
6812
6914
|
* reason: RateLimitError | QuotaExceededError
|
|
6813
6915
|
* }> {}
|
|
6814
6916
|
*
|
|
6815
|
-
* const
|
|
6816
|
-
*
|
|
6817
|
-
* )
|
|
6917
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
6918
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
6818
6919
|
*
|
|
6819
6920
|
* const recovered = channel.pipe(
|
|
6820
6921
|
* Channel.catchReason("AiError", "RateLimitError", (reason) =>
|
|
6821
6922
|
* Channel.succeed(`retry: ${reason.retryAfter}`)
|
|
6822
6923
|
* )
|
|
6823
6924
|
* )
|
|
6925
|
+
* Effect.runSync(Channel.runCollect(recovered)) // => ["retry: 60"]
|
|
6824
6926
|
* ```
|
|
6825
6927
|
*
|
|
6826
6928
|
* @category error handling
|
|
@@ -6883,8 +6985,8 @@ export const catchReason: {
|
|
|
6883
6985
|
*
|
|
6884
6986
|
* **Example** (Recovering from nested reasons)
|
|
6885
6987
|
*
|
|
6886
|
-
* ```ts
|
|
6887
|
-
* import { Channel, Data } from "effect"
|
|
6988
|
+
* ```ts import.meta.vitest
|
|
6989
|
+
* import { Channel, Data, Effect } from "effect"
|
|
6888
6990
|
*
|
|
6889
6991
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
6890
6992
|
* retryAfter: number
|
|
@@ -6898,15 +7000,15 @@ export const catchReason: {
|
|
|
6898
7000
|
* reason: RateLimitError | QuotaExceededError
|
|
6899
7001
|
* }> {}
|
|
6900
7002
|
*
|
|
6901
|
-
* const
|
|
6902
|
-
*
|
|
6903
|
-
* )
|
|
7003
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
7004
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
6904
7005
|
*
|
|
6905
7006
|
* const recovered = channel.pipe(
|
|
6906
7007
|
* Channel.catchReason("AiError", "RateLimitError", (reason) =>
|
|
6907
7008
|
* Channel.succeed(`retry: ${reason.retryAfter}`)
|
|
6908
7009
|
* )
|
|
6909
7010
|
* )
|
|
7011
|
+
* Effect.runSync(Channel.runCollect(recovered)) // => ["retry: 60"]
|
|
6910
7012
|
* ```
|
|
6911
7013
|
*
|
|
6912
7014
|
* @category error handling
|
|
@@ -7227,8 +7329,8 @@ export const catchReasons: {
|
|
|
7227
7329
|
*
|
|
7228
7330
|
* **Example** (Promoting nested reasons)
|
|
7229
7331
|
*
|
|
7230
|
-
* ```ts
|
|
7231
|
-
* import { Channel, Data } from "effect"
|
|
7332
|
+
* ```ts import.meta.vitest
|
|
7333
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
7232
7334
|
*
|
|
7233
7335
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
7234
7336
|
* retryAfter: number
|
|
@@ -7242,11 +7344,11 @@ export const catchReasons: {
|
|
|
7242
7344
|
* reason: RateLimitError | QuotaExceededError
|
|
7243
7345
|
* }> {}
|
|
7244
7346
|
*
|
|
7245
|
-
* const
|
|
7246
|
-
*
|
|
7247
|
-
* )
|
|
7347
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
7348
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
7248
7349
|
*
|
|
7249
7350
|
* const unwrapped = channel.pipe(Channel.unwrapReason("AiError"))
|
|
7351
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(unwrapped))) // => Exit.fail(reason)
|
|
7250
7352
|
* ```
|
|
7251
7353
|
*
|
|
7252
7354
|
* @category error handling
|
|
@@ -7258,8 +7360,8 @@ export const unwrapReason: {
|
|
|
7258
7360
|
*
|
|
7259
7361
|
* **Example** (Promoting nested reasons)
|
|
7260
7362
|
*
|
|
7261
|
-
* ```ts
|
|
7262
|
-
* import { Channel, Data } from "effect"
|
|
7363
|
+
* ```ts import.meta.vitest
|
|
7364
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
7263
7365
|
*
|
|
7264
7366
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
7265
7367
|
* retryAfter: number
|
|
@@ -7273,11 +7375,11 @@ export const unwrapReason: {
|
|
|
7273
7375
|
* reason: RateLimitError | QuotaExceededError
|
|
7274
7376
|
* }> {}
|
|
7275
7377
|
*
|
|
7276
|
-
* const
|
|
7277
|
-
*
|
|
7278
|
-
* )
|
|
7378
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
7379
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
7279
7380
|
*
|
|
7280
7381
|
* const unwrapped = channel.pipe(Channel.unwrapReason("AiError"))
|
|
7382
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(unwrapped))) // => Exit.fail(reason)
|
|
7281
7383
|
* ```
|
|
7282
7384
|
*
|
|
7283
7385
|
* @category error handling
|
|
@@ -7302,8 +7404,8 @@ export const unwrapReason: {
|
|
|
7302
7404
|
*
|
|
7303
7405
|
* **Example** (Promoting nested reasons)
|
|
7304
7406
|
*
|
|
7305
|
-
* ```ts
|
|
7306
|
-
* import { Channel, Data } from "effect"
|
|
7407
|
+
* ```ts import.meta.vitest
|
|
7408
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
7307
7409
|
*
|
|
7308
7410
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
7309
7411
|
* retryAfter: number
|
|
@@ -7317,11 +7419,11 @@ export const unwrapReason: {
|
|
|
7317
7419
|
* reason: RateLimitError | QuotaExceededError
|
|
7318
7420
|
* }> {}
|
|
7319
7421
|
*
|
|
7320
|
-
* const
|
|
7321
|
-
*
|
|
7322
|
-
* )
|
|
7422
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
7423
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
7323
7424
|
*
|
|
7324
7425
|
* const unwrapped = channel.pipe(Channel.unwrapReason("AiError"))
|
|
7426
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(unwrapped))) // => Exit.fail(reason)
|
|
7325
7427
|
* ```
|
|
7326
7428
|
*
|
|
7327
7429
|
* @category error handling
|
|
@@ -7419,20 +7521,21 @@ export const mapError: {
|
|
|
7419
7521
|
*
|
|
7420
7522
|
* **Example** (Converting failures to defects)
|
|
7421
7523
|
*
|
|
7422
|
-
* ```ts
|
|
7423
|
-
* import { Channel, Data } from "effect"
|
|
7524
|
+
* ```ts import.meta.vitest
|
|
7525
|
+
* import { Cause, Channel, Data, Effect, Exit } from "effect"
|
|
7424
7526
|
*
|
|
7425
7527
|
* class ValidationError extends Data.TaggedError("ValidationError")<{
|
|
7426
7528
|
* readonly field: string
|
|
7427
7529
|
* }> {}
|
|
7428
7530
|
*
|
|
7429
7531
|
* // Create a channel that might fail
|
|
7430
|
-
* const
|
|
7532
|
+
* const error = new ValidationError({ field: "email" })
|
|
7533
|
+
* const failingChannel = Channel.fail(error)
|
|
7431
7534
|
*
|
|
7432
7535
|
* // Convert failures to defects
|
|
7433
7536
|
* const fatalChannel = Channel.orDie(failingChannel)
|
|
7434
7537
|
*
|
|
7435
|
-
* //
|
|
7538
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(fatalChannel))) // => Exit.failCause(Cause.die(error))
|
|
7436
7539
|
* ```
|
|
7437
7540
|
*
|
|
7438
7541
|
* @category error handling
|
|
@@ -7647,8 +7750,8 @@ export const retry: {
|
|
|
7647
7750
|
*
|
|
7648
7751
|
* **Example** (Switching mapped channels)
|
|
7649
7752
|
*
|
|
7650
|
-
* ```ts
|
|
7651
|
-
* import { Channel, Data } from "effect"
|
|
7753
|
+
* ```ts import.meta.vitest
|
|
7754
|
+
* import { Channel, Data, Effect } from "effect"
|
|
7652
7755
|
*
|
|
7653
7756
|
* class SwitchError extends Data.TaggedError("SwitchError")<{
|
|
7654
7757
|
* readonly reason: string
|
|
@@ -7663,7 +7766,7 @@ export const retry: {
|
|
|
7663
7766
|
* (n) => Channel.fromIterable([`value-${n}`])
|
|
7664
7767
|
* )
|
|
7665
7768
|
*
|
|
7666
|
-
*
|
|
7769
|
+
* await Effect.runPromise(Channel.runCollect(switchedChannel)) // => ["value-3"]
|
|
7667
7770
|
* ```
|
|
7668
7771
|
*
|
|
7669
7772
|
* @category sequencing
|
|
@@ -7682,8 +7785,8 @@ export const switchMap: {
|
|
|
7682
7785
|
*
|
|
7683
7786
|
* **Example** (Switching mapped channels)
|
|
7684
7787
|
*
|
|
7685
|
-
* ```ts
|
|
7686
|
-
* import { Channel, Data } from "effect"
|
|
7788
|
+
* ```ts import.meta.vitest
|
|
7789
|
+
* import { Channel, Data, Effect } from "effect"
|
|
7687
7790
|
*
|
|
7688
7791
|
* class SwitchError extends Data.TaggedError("SwitchError")<{
|
|
7689
7792
|
* readonly reason: string
|
|
@@ -7698,7 +7801,7 @@ export const switchMap: {
|
|
|
7698
7801
|
* (n) => Channel.fromIterable([`value-${n}`])
|
|
7699
7802
|
* )
|
|
7700
7803
|
*
|
|
7701
|
-
*
|
|
7804
|
+
* await Effect.runPromise(Channel.runCollect(switchedChannel)) // => ["value-3"]
|
|
7702
7805
|
* ```
|
|
7703
7806
|
*
|
|
7704
7807
|
* @category sequencing
|
|
@@ -7733,8 +7836,8 @@ export const switchMap: {
|
|
|
7733
7836
|
*
|
|
7734
7837
|
* **Example** (Switching mapped channels)
|
|
7735
7838
|
*
|
|
7736
|
-
* ```ts
|
|
7737
|
-
* import { Channel, Data } from "effect"
|
|
7839
|
+
* ```ts import.meta.vitest
|
|
7840
|
+
* import { Channel, Data, Effect } from "effect"
|
|
7738
7841
|
*
|
|
7739
7842
|
* class SwitchError extends Data.TaggedError("SwitchError")<{
|
|
7740
7843
|
* readonly reason: string
|
|
@@ -7749,7 +7852,7 @@ export const switchMap: {
|
|
|
7749
7852
|
* (n) => Channel.fromIterable([`value-${n}`])
|
|
7750
7853
|
* )
|
|
7751
7854
|
*
|
|
7752
|
-
*
|
|
7855
|
+
* await Effect.runPromise(Channel.runCollect(switchedChannel)) // => ["value-3"]
|
|
7753
7856
|
* ```
|
|
7754
7857
|
*
|
|
7755
7858
|
* @category sequencing
|
|
@@ -7839,8 +7942,8 @@ export const switchMap: {
|
|
|
7839
7942
|
*
|
|
7840
7943
|
* **Example** (Merging nested channels)
|
|
7841
7944
|
*
|
|
7842
|
-
* ```ts
|
|
7843
|
-
* import { Channel, Data } from "effect"
|
|
7945
|
+
* ```ts import.meta.vitest
|
|
7946
|
+
* import { Channel, Data, Effect } from "effect"
|
|
7844
7947
|
*
|
|
7845
7948
|
* class MergeAllError extends Data.TaggedError("MergeAllError")<{
|
|
7846
7949
|
* readonly reason: string
|
|
@@ -7855,11 +7958,11 @@ export const switchMap: {
|
|
|
7855
7958
|
*
|
|
7856
7959
|
* // Merge all channels with bounded concurrency
|
|
7857
7960
|
* const mergedChannel = Channel.mergeAll({
|
|
7858
|
-
* concurrency:
|
|
7961
|
+
* concurrency: 1,
|
|
7859
7962
|
* bufferSize: 16
|
|
7860
7963
|
* })(nestedChannels)
|
|
7861
7964
|
*
|
|
7862
|
-
* //
|
|
7965
|
+
* await Effect.runPromise(Channel.runCollect(mergedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
7863
7966
|
* ```
|
|
7864
7967
|
*
|
|
7865
7968
|
* @category combining
|
|
@@ -7876,8 +7979,8 @@ export const mergeAll: {
|
|
|
7876
7979
|
*
|
|
7877
7980
|
* **Example** (Merging nested channels)
|
|
7878
7981
|
*
|
|
7879
|
-
* ```ts
|
|
7880
|
-
* import { Channel, Data } from "effect"
|
|
7982
|
+
* ```ts import.meta.vitest
|
|
7983
|
+
* import { Channel, Data, Effect } from "effect"
|
|
7881
7984
|
*
|
|
7882
7985
|
* class MergeAllError extends Data.TaggedError("MergeAllError")<{
|
|
7883
7986
|
* readonly reason: string
|
|
@@ -7892,11 +7995,11 @@ export const mergeAll: {
|
|
|
7892
7995
|
*
|
|
7893
7996
|
* // Merge all channels with bounded concurrency
|
|
7894
7997
|
* const mergedChannel = Channel.mergeAll({
|
|
7895
|
-
* concurrency:
|
|
7998
|
+
* concurrency: 1,
|
|
7896
7999
|
* bufferSize: 16
|
|
7897
8000
|
* })(nestedChannels)
|
|
7898
8001
|
*
|
|
7899
|
-
* //
|
|
8002
|
+
* await Effect.runPromise(Channel.runCollect(mergedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
7900
8003
|
* ```
|
|
7901
8004
|
*
|
|
7902
8005
|
* @category combining
|
|
@@ -7937,8 +8040,8 @@ export const mergeAll: {
|
|
|
7937
8040
|
*
|
|
7938
8041
|
* **Example** (Merging nested channels)
|
|
7939
8042
|
*
|
|
7940
|
-
* ```ts
|
|
7941
|
-
* import { Channel, Data } from "effect"
|
|
8043
|
+
* ```ts import.meta.vitest
|
|
8044
|
+
* import { Channel, Data, Effect } from "effect"
|
|
7942
8045
|
*
|
|
7943
8046
|
* class MergeAllError extends Data.TaggedError("MergeAllError")<{
|
|
7944
8047
|
* readonly reason: string
|
|
@@ -7953,11 +8056,11 @@ export const mergeAll: {
|
|
|
7953
8056
|
*
|
|
7954
8057
|
* // Merge all channels with bounded concurrency
|
|
7955
8058
|
* const mergedChannel = Channel.mergeAll({
|
|
7956
|
-
* concurrency:
|
|
8059
|
+
* concurrency: 1,
|
|
7957
8060
|
* bufferSize: 16
|
|
7958
8061
|
* })(nestedChannels)
|
|
7959
8062
|
*
|
|
7960
|
-
* //
|
|
8063
|
+
* await Effect.runPromise(Channel.runCollect(mergedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
7961
8064
|
* ```
|
|
7962
8065
|
*
|
|
7963
8066
|
* @category combining
|
|
@@ -8032,8 +8135,8 @@ export const mergeAll: {
|
|
|
8032
8135
|
*
|
|
8033
8136
|
* **Example** (Merging nested channels)
|
|
8034
8137
|
*
|
|
8035
|
-
* ```ts
|
|
8036
|
-
* import { Channel, Data } from "effect"
|
|
8138
|
+
* ```ts import.meta.vitest
|
|
8139
|
+
* import { Channel, Data, Effect } from "effect"
|
|
8037
8140
|
*
|
|
8038
8141
|
* class MergeAllError extends Data.TaggedError("MergeAllError")<{
|
|
8039
8142
|
* readonly reason: string
|
|
@@ -8048,11 +8151,11 @@ export const mergeAll: {
|
|
|
8048
8151
|
*
|
|
8049
8152
|
* // Merge all channels with bounded concurrency
|
|
8050
8153
|
* const mergedChannel = Channel.mergeAll({
|
|
8051
|
-
* concurrency:
|
|
8154
|
+
* concurrency: 1,
|
|
8052
8155
|
* bufferSize: 16
|
|
8053
8156
|
* })(nestedChannels)
|
|
8054
8157
|
*
|
|
8055
|
-
* //
|
|
8158
|
+
* await Effect.runPromise(Channel.runCollect(mergedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
8056
8159
|
* ```
|
|
8057
8160
|
*
|
|
8058
8161
|
* @category combining
|
|
@@ -8068,8 +8171,8 @@ export const mergeAll: {
|
|
|
8068
8171
|
*
|
|
8069
8172
|
* **Example** (Merging nested channels)
|
|
8070
8173
|
*
|
|
8071
|
-
* ```ts
|
|
8072
|
-
* import { Channel, Data } from "effect"
|
|
8174
|
+
* ```ts import.meta.vitest
|
|
8175
|
+
* import { Channel, Data, Effect } from "effect"
|
|
8073
8176
|
*
|
|
8074
8177
|
* class MergeAllError extends Data.TaggedError("MergeAllError")<{
|
|
8075
8178
|
* readonly reason: string
|
|
@@ -8084,11 +8187,11 @@ export const mergeAll: {
|
|
|
8084
8187
|
*
|
|
8085
8188
|
* // Merge all channels with bounded concurrency
|
|
8086
8189
|
* const mergedChannel = Channel.mergeAll({
|
|
8087
|
-
* concurrency:
|
|
8190
|
+
* concurrency: 1,
|
|
8088
8191
|
* bufferSize: 16
|
|
8089
8192
|
* })(nestedChannels)
|
|
8090
8193
|
*
|
|
8091
|
-
* //
|
|
8194
|
+
* await Effect.runPromise(Channel.runCollect(mergedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
8092
8195
|
* ```
|
|
8093
8196
|
*
|
|
8094
8197
|
* @category combining
|
|
@@ -8103,8 +8206,21 @@ export const mergeAll: {
|
|
|
8103
8206
|
|
|
8104
8207
|
yield* Effect.gen(function*() {
|
|
8105
8208
|
while (true) {
|
|
8106
|
-
|
|
8107
|
-
|
|
8209
|
+
let pullFiber: Fiber.Fiber<Pull.Success<typeof pull>, any> | undefined
|
|
8210
|
+
if (semaphore) {
|
|
8211
|
+
if (fibers.size < concurrencyN) {
|
|
8212
|
+
yield* semaphore.take(1)
|
|
8213
|
+
} else {
|
|
8214
|
+
pullFiber = yield* Effect.forkChild(pull)
|
|
8215
|
+
yield* Effect.raceFirst(
|
|
8216
|
+
semaphore.take(1),
|
|
8217
|
+
Effect.andThen(Fiber.join(pullFiber), Effect.never)
|
|
8218
|
+
)
|
|
8219
|
+
}
|
|
8220
|
+
}
|
|
8221
|
+
const channel = pullFiber === undefined
|
|
8222
|
+
? yield* pull
|
|
8223
|
+
: yield* Fiber.join(pullFiber)
|
|
8108
8224
|
const childScope = Scope.forkUnsafe(forkedScope)
|
|
8109
8225
|
const childPull = yield* toTransform(channel)(upstream, childScope)
|
|
8110
8226
|
|
|
@@ -8139,7 +8255,13 @@ export const mergeAll: {
|
|
|
8139
8255
|
fibers.add(fiber)
|
|
8140
8256
|
}
|
|
8141
8257
|
}).pipe(
|
|
8142
|
-
Effect.catchCause((cause) =>
|
|
8258
|
+
Effect.catchCause((cause) => {
|
|
8259
|
+
const halt = Pull.filterDone(cause)
|
|
8260
|
+
if (Result.isSuccess(halt)) {
|
|
8261
|
+
return doneLatch.whenOpen(Queue.failCause(queue, cause))
|
|
8262
|
+
}
|
|
8263
|
+
return Queue.failCause(queue, cause)
|
|
8264
|
+
}),
|
|
8143
8265
|
Effect.forkIn(forkedScope)
|
|
8144
8266
|
)
|
|
8145
8267
|
|
|
@@ -8153,14 +8275,11 @@ export const mergeAll: {
|
|
|
8153
8275
|
*
|
|
8154
8276
|
* **Example** (Choosing merge halt strategies)
|
|
8155
8277
|
*
|
|
8156
|
-
* ```ts
|
|
8157
|
-
* import
|
|
8278
|
+
* ```ts import.meta.vitest
|
|
8279
|
+
* import { Channel } from "effect"
|
|
8158
8280
|
*
|
|
8159
8281
|
* // Different halt strategies for channel merging
|
|
8160
|
-
* const
|
|
8161
|
-
* const rightFirst: Channel.HaltStrategy = "right" // Stop when right channel halts
|
|
8162
|
-
* const both: Channel.HaltStrategy = "both" // Stop when both channels halt
|
|
8163
|
-
* const either: Channel.HaltStrategy = "either" // Stop when either channel halts
|
|
8282
|
+
* const strategies: Array<Channel.HaltStrategy> = ["left", "right", "both", "either"] // => ["left", "right", "both", "either"]
|
|
8164
8283
|
* ```
|
|
8165
8284
|
*
|
|
8166
8285
|
* @category models
|
|
@@ -8174,24 +8293,18 @@ export type HaltStrategy = "left" | "right" | "both" | "either"
|
|
|
8174
8293
|
*
|
|
8175
8294
|
* **Example** (Merging channels)
|
|
8176
8295
|
*
|
|
8177
|
-
* ```ts
|
|
8178
|
-
* import { Channel,
|
|
8179
|
-
*
|
|
8180
|
-
* class MergeError extends Data.TaggedError("MergeError")<{
|
|
8181
|
-
* readonly source: string
|
|
8182
|
-
* }> {}
|
|
8296
|
+
* ```ts import.meta.vitest
|
|
8297
|
+
* import { Channel, Effect } from "effect"
|
|
8183
8298
|
*
|
|
8184
8299
|
* // Create two channels
|
|
8185
8300
|
* const leftChannel = Channel.fromIterable([1, 2, 3])
|
|
8186
8301
|
* const rightChannel = Channel.fromIterable(["a", "b", "c"])
|
|
8187
8302
|
*
|
|
8188
|
-
* //
|
|
8189
|
-
* const mergedChannel = Channel.merge(leftChannel, rightChannel
|
|
8190
|
-
* haltStrategy: "either"
|
|
8191
|
-
* })
|
|
8303
|
+
* // The default "both" strategy waits for both channels to complete
|
|
8304
|
+
* const mergedChannel = Channel.merge(leftChannel, rightChannel)
|
|
8192
8305
|
*
|
|
8193
|
-
*
|
|
8194
|
-
* //
|
|
8306
|
+
* const values = await Effect.runPromise(Channel.runCollect(mergedChannel))
|
|
8307
|
+
* values.map(String).sort() // => ["1", "2", "3", "a", "b", "c"]
|
|
8195
8308
|
* ```
|
|
8196
8309
|
*
|
|
8197
8310
|
* @category combining
|
|
@@ -8204,24 +8317,18 @@ export const merge: {
|
|
|
8204
8317
|
*
|
|
8205
8318
|
* **Example** (Merging channels)
|
|
8206
8319
|
*
|
|
8207
|
-
* ```ts
|
|
8208
|
-
* import { Channel,
|
|
8209
|
-
*
|
|
8210
|
-
* class MergeError extends Data.TaggedError("MergeError")<{
|
|
8211
|
-
* readonly source: string
|
|
8212
|
-
* }> {}
|
|
8320
|
+
* ```ts import.meta.vitest
|
|
8321
|
+
* import { Channel, Effect } from "effect"
|
|
8213
8322
|
*
|
|
8214
8323
|
* // Create two channels
|
|
8215
8324
|
* const leftChannel = Channel.fromIterable([1, 2, 3])
|
|
8216
8325
|
* const rightChannel = Channel.fromIterable(["a", "b", "c"])
|
|
8217
8326
|
*
|
|
8218
|
-
* //
|
|
8219
|
-
* const mergedChannel = Channel.merge(leftChannel, rightChannel
|
|
8220
|
-
* haltStrategy: "either"
|
|
8221
|
-
* })
|
|
8327
|
+
* // The default "both" strategy waits for both channels to complete
|
|
8328
|
+
* const mergedChannel = Channel.merge(leftChannel, rightChannel)
|
|
8222
8329
|
*
|
|
8223
|
-
*
|
|
8224
|
-
* //
|
|
8330
|
+
* const values = await Effect.runPromise(Channel.runCollect(mergedChannel))
|
|
8331
|
+
* values.map(String).sort() // => ["1", "2", "3", "a", "b", "c"]
|
|
8225
8332
|
* ```
|
|
8226
8333
|
*
|
|
8227
8334
|
* @category combining
|
|
@@ -8249,24 +8356,18 @@ export const merge: {
|
|
|
8249
8356
|
*
|
|
8250
8357
|
* **Example** (Merging channels)
|
|
8251
8358
|
*
|
|
8252
|
-
* ```ts
|
|
8253
|
-
* import { Channel,
|
|
8254
|
-
*
|
|
8255
|
-
* class MergeError extends Data.TaggedError("MergeError")<{
|
|
8256
|
-
* readonly source: string
|
|
8257
|
-
* }> {}
|
|
8359
|
+
* ```ts import.meta.vitest
|
|
8360
|
+
* import { Channel, Effect } from "effect"
|
|
8258
8361
|
*
|
|
8259
8362
|
* // Create two channels
|
|
8260
8363
|
* const leftChannel = Channel.fromIterable([1, 2, 3])
|
|
8261
8364
|
* const rightChannel = Channel.fromIterable(["a", "b", "c"])
|
|
8262
8365
|
*
|
|
8263
|
-
* //
|
|
8264
|
-
* const mergedChannel = Channel.merge(leftChannel, rightChannel
|
|
8265
|
-
* haltStrategy: "either"
|
|
8266
|
-
* })
|
|
8366
|
+
* // The default "both" strategy waits for both channels to complete
|
|
8367
|
+
* const mergedChannel = Channel.merge(leftChannel, rightChannel)
|
|
8267
8368
|
*
|
|
8268
|
-
*
|
|
8269
|
-
* //
|
|
8369
|
+
* const values = await Effect.runPromise(Channel.runCollect(mergedChannel))
|
|
8370
|
+
* values.map(String).sort() // => ["1", "2", "3", "a", "b", "c"]
|
|
8270
8371
|
* ```
|
|
8271
8372
|
*
|
|
8272
8373
|
* @category combining
|
|
@@ -8340,24 +8441,18 @@ export const merge: {
|
|
|
8340
8441
|
*
|
|
8341
8442
|
* **Example** (Merging channels)
|
|
8342
8443
|
*
|
|
8343
|
-
* ```ts
|
|
8344
|
-
* import { Channel,
|
|
8345
|
-
*
|
|
8346
|
-
* class MergeError extends Data.TaggedError("MergeError")<{
|
|
8347
|
-
* readonly source: string
|
|
8348
|
-
* }> {}
|
|
8444
|
+
* ```ts import.meta.vitest
|
|
8445
|
+
* import { Channel, Effect } from "effect"
|
|
8349
8446
|
*
|
|
8350
8447
|
* // Create two channels
|
|
8351
8448
|
* const leftChannel = Channel.fromIterable([1, 2, 3])
|
|
8352
8449
|
* const rightChannel = Channel.fromIterable(["a", "b", "c"])
|
|
8353
8450
|
*
|
|
8354
|
-
* //
|
|
8355
|
-
* const mergedChannel = Channel.merge(leftChannel, rightChannel
|
|
8356
|
-
* haltStrategy: "either"
|
|
8357
|
-
* })
|
|
8451
|
+
* // The default "both" strategy waits for both channels to complete
|
|
8452
|
+
* const mergedChannel = Channel.merge(leftChannel, rightChannel)
|
|
8358
8453
|
*
|
|
8359
|
-
*
|
|
8360
|
-
* //
|
|
8454
|
+
* const values = await Effect.runPromise(Channel.runCollect(mergedChannel))
|
|
8455
|
+
* values.map(String).sort() // => ["1", "2", "3", "a", "b", "c"]
|
|
8361
8456
|
* ```
|
|
8362
8457
|
*
|
|
8363
8458
|
* @category combining
|
|
@@ -8369,24 +8464,18 @@ export const merge: {
|
|
|
8369
8464
|
*
|
|
8370
8465
|
* **Example** (Merging channels)
|
|
8371
8466
|
*
|
|
8372
|
-
* ```ts
|
|
8373
|
-
* import { Channel,
|
|
8374
|
-
*
|
|
8375
|
-
* class MergeError extends Data.TaggedError("MergeError")<{
|
|
8376
|
-
* readonly source: string
|
|
8377
|
-
* }> {}
|
|
8467
|
+
* ```ts import.meta.vitest
|
|
8468
|
+
* import { Channel, Effect } from "effect"
|
|
8378
8469
|
*
|
|
8379
8470
|
* // Create two channels
|
|
8380
8471
|
* const leftChannel = Channel.fromIterable([1, 2, 3])
|
|
8381
8472
|
* const rightChannel = Channel.fromIterable(["a", "b", "c"])
|
|
8382
8473
|
*
|
|
8383
|
-
* //
|
|
8384
|
-
* const mergedChannel = Channel.merge(leftChannel, rightChannel
|
|
8385
|
-
* haltStrategy: "either"
|
|
8386
|
-
* })
|
|
8474
|
+
* // The default "both" strategy waits for both channels to complete
|
|
8475
|
+
* const mergedChannel = Channel.merge(leftChannel, rightChannel)
|
|
8387
8476
|
*
|
|
8388
|
-
*
|
|
8389
|
-
* //
|
|
8477
|
+
* const values = await Effect.runPromise(Channel.runCollect(mergedChannel))
|
|
8478
|
+
* values.map(String).sort() // => ["1", "2", "3", "a", "b", "c"]
|
|
8390
8479
|
* ```
|
|
8391
8480
|
*
|
|
8392
8481
|
* @category combining
|
|
@@ -8532,19 +8621,16 @@ export const mergeEffect: {
|
|
|
8532
8621
|
*
|
|
8533
8622
|
* **Example** (Splitting string chunks into lines)
|
|
8534
8623
|
*
|
|
8535
|
-
* ```ts
|
|
8624
|
+
* ```ts import.meta.vitest
|
|
8536
8625
|
* import { Effect, Stream } from "effect"
|
|
8537
8626
|
*
|
|
8538
|
-
* Effect.runPromise(
|
|
8539
|
-
*
|
|
8540
|
-
*
|
|
8541
|
-
*
|
|
8542
|
-
* console.log(result)
|
|
8543
|
-
* // [ 'hello', 'world' ]
|
|
8544
|
-
* }))
|
|
8627
|
+
* const result = await Effect.runPromise(Stream.runCollect(
|
|
8628
|
+
* Stream.splitLines(Stream.make("hel", "lo\r\nwor", "ld\n"))
|
|
8629
|
+
* ))
|
|
8630
|
+
* result // => ["hello", "world"]
|
|
8545
8631
|
* ```
|
|
8546
8632
|
*
|
|
8547
|
-
* @category
|
|
8633
|
+
* @category splitting
|
|
8548
8634
|
* @since 2.0.0
|
|
8549
8635
|
*/
|
|
8550
8636
|
export const splitLines = <Err, Done>(): Channel<
|
|
@@ -8658,7 +8744,7 @@ export const splitLines = <Err, Done>(): Channel<
|
|
|
8658
8744
|
* span `Uint8Array` boundaries. The optional `encoding` and `options` are
|
|
8659
8745
|
* passed to `TextDecoder`.
|
|
8660
8746
|
*
|
|
8661
|
-
* @category
|
|
8747
|
+
* @category decoding
|
|
8662
8748
|
* @since 4.0.0
|
|
8663
8749
|
*/
|
|
8664
8750
|
export const decodeText = <Err, Done>(encoding?: string, options?: TextDecoderOptions): Channel<
|
|
@@ -8684,7 +8770,7 @@ export const decodeText = <Err, Done>(encoding?: string, options?: TextDecoderOp
|
|
|
8684
8770
|
*
|
|
8685
8771
|
* Each string inside an emitted array is encoded independently.
|
|
8686
8772
|
*
|
|
8687
|
-
* @category
|
|
8773
|
+
* @category encoding
|
|
8688
8774
|
* @since 4.0.0
|
|
8689
8775
|
*/
|
|
8690
8776
|
export const encodeText = <Err, Done>(): Channel<
|
|
@@ -8710,8 +8796,8 @@ export const encodeText = <Err, Done>(): Channel<
|
|
|
8710
8796
|
*
|
|
8711
8797
|
* **Example** (Piping one channel into another)
|
|
8712
8798
|
*
|
|
8713
|
-
* ```ts
|
|
8714
|
-
* import { Channel, Data } from "effect"
|
|
8799
|
+
* ```ts import.meta.vitest
|
|
8800
|
+
* import { Channel, Data, Effect } from "effect"
|
|
8715
8801
|
*
|
|
8716
8802
|
* class PipeError extends Data.TaggedError("PipeError")<{
|
|
8717
8803
|
* readonly stage: string
|
|
@@ -8724,7 +8810,7 @@ export const encodeText = <Err, Done>(): Channel<
|
|
|
8724
8810
|
* // Pipe the source into the transform
|
|
8725
8811
|
* const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel)
|
|
8726
8812
|
*
|
|
8727
|
-
* //
|
|
8813
|
+
* Effect.runSync(Channel.runCollect(pipedChannel)) // => [2, 4, 6]
|
|
8728
8814
|
* ```
|
|
8729
8815
|
*
|
|
8730
8816
|
* @category sequencing
|
|
@@ -8739,8 +8825,8 @@ export const pipeTo: {
|
|
|
8739
8825
|
*
|
|
8740
8826
|
* **Example** (Piping one channel into another)
|
|
8741
8827
|
*
|
|
8742
|
-
* ```ts
|
|
8743
|
-
* import { Channel, Data } from "effect"
|
|
8828
|
+
* ```ts import.meta.vitest
|
|
8829
|
+
* import { Channel, Data, Effect } from "effect"
|
|
8744
8830
|
*
|
|
8745
8831
|
* class PipeError extends Data.TaggedError("PipeError")<{
|
|
8746
8832
|
* readonly stage: string
|
|
@@ -8753,7 +8839,7 @@ export const pipeTo: {
|
|
|
8753
8839
|
* // Pipe the source into the transform
|
|
8754
8840
|
* const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel)
|
|
8755
8841
|
*
|
|
8756
|
-
* //
|
|
8842
|
+
* Effect.runSync(Channel.runCollect(pipedChannel)) // => [2, 4, 6]
|
|
8757
8843
|
* ```
|
|
8758
8844
|
*
|
|
8759
8845
|
* @category sequencing
|
|
@@ -8770,8 +8856,8 @@ export const pipeTo: {
|
|
|
8770
8856
|
*
|
|
8771
8857
|
* **Example** (Piping one channel into another)
|
|
8772
8858
|
*
|
|
8773
|
-
* ```ts
|
|
8774
|
-
* import { Channel, Data } from "effect"
|
|
8859
|
+
* ```ts import.meta.vitest
|
|
8860
|
+
* import { Channel, Data, Effect } from "effect"
|
|
8775
8861
|
*
|
|
8776
8862
|
* class PipeError extends Data.TaggedError("PipeError")<{
|
|
8777
8863
|
* readonly stage: string
|
|
@@ -8784,7 +8870,7 @@ export const pipeTo: {
|
|
|
8784
8870
|
* // Pipe the source into the transform
|
|
8785
8871
|
* const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel)
|
|
8786
8872
|
*
|
|
8787
|
-
* //
|
|
8873
|
+
* Effect.runSync(Channel.runCollect(pipedChannel)) // => [2, 4, 6]
|
|
8788
8874
|
* ```
|
|
8789
8875
|
*
|
|
8790
8876
|
* @category sequencing
|
|
@@ -8812,21 +8898,22 @@ export const pipeTo: {
|
|
|
8812
8898
|
*
|
|
8813
8899
|
* **Example** (Piping while preserving failures)
|
|
8814
8900
|
*
|
|
8815
|
-
* ```ts
|
|
8816
|
-
* import { Channel, Data } from "effect"
|
|
8901
|
+
* ```ts import.meta.vitest
|
|
8902
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
8817
8903
|
*
|
|
8818
8904
|
* class SourceError extends Data.TaggedError("SourceError")<{
|
|
8819
8905
|
* readonly code: number
|
|
8820
8906
|
* }> {}
|
|
8821
8907
|
*
|
|
8822
8908
|
* // Create a failing source channel
|
|
8823
|
-
* const
|
|
8824
|
-
* const
|
|
8909
|
+
* const error = new SourceError({ code: 404 })
|
|
8910
|
+
* const failingSource = Channel.fail(error)
|
|
8911
|
+
* const safeTransform = Channel.identity<never, never, never>()
|
|
8825
8912
|
*
|
|
8826
8913
|
* // Pipe while preserving source failures
|
|
8827
8914
|
* const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform)
|
|
8828
8915
|
*
|
|
8829
|
-
* //
|
|
8916
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(safePipedChannel))) // => Exit.fail(error)
|
|
8830
8917
|
* ```
|
|
8831
8918
|
*
|
|
8832
8919
|
* @category sequencing
|
|
@@ -8840,21 +8927,22 @@ export const pipeToOrFail: {
|
|
|
8840
8927
|
*
|
|
8841
8928
|
* **Example** (Piping while preserving failures)
|
|
8842
8929
|
*
|
|
8843
|
-
* ```ts
|
|
8844
|
-
* import { Channel, Data } from "effect"
|
|
8930
|
+
* ```ts import.meta.vitest
|
|
8931
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
8845
8932
|
*
|
|
8846
8933
|
* class SourceError extends Data.TaggedError("SourceError")<{
|
|
8847
8934
|
* readonly code: number
|
|
8848
8935
|
* }> {}
|
|
8849
8936
|
*
|
|
8850
8937
|
* // Create a failing source channel
|
|
8851
|
-
* const
|
|
8852
|
-
* const
|
|
8938
|
+
* const error = new SourceError({ code: 404 })
|
|
8939
|
+
* const failingSource = Channel.fail(error)
|
|
8940
|
+
* const safeTransform = Channel.identity<never, never, never>()
|
|
8853
8941
|
*
|
|
8854
8942
|
* // Pipe while preserving source failures
|
|
8855
8943
|
* const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform)
|
|
8856
8944
|
*
|
|
8857
|
-
* //
|
|
8945
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(safePipedChannel))) // => Exit.fail(error)
|
|
8858
8946
|
* ```
|
|
8859
8947
|
*
|
|
8860
8948
|
* @category sequencing
|
|
@@ -8870,21 +8958,22 @@ export const pipeToOrFail: {
|
|
|
8870
8958
|
*
|
|
8871
8959
|
* **Example** (Piping while preserving failures)
|
|
8872
8960
|
*
|
|
8873
|
-
* ```ts
|
|
8874
|
-
* import { Channel, Data } from "effect"
|
|
8961
|
+
* ```ts import.meta.vitest
|
|
8962
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
8875
8963
|
*
|
|
8876
8964
|
* class SourceError extends Data.TaggedError("SourceError")<{
|
|
8877
8965
|
* readonly code: number
|
|
8878
8966
|
* }> {}
|
|
8879
8967
|
*
|
|
8880
8968
|
* // Create a failing source channel
|
|
8881
|
-
* const
|
|
8882
|
-
* const
|
|
8969
|
+
* const error = new SourceError({ code: 404 })
|
|
8970
|
+
* const failingSource = Channel.fail(error)
|
|
8971
|
+
* const safeTransform = Channel.identity<never, never, never>()
|
|
8883
8972
|
*
|
|
8884
8973
|
* // Pipe while preserving source failures
|
|
8885
8974
|
* const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform)
|
|
8886
8975
|
*
|
|
8887
|
-
* //
|
|
8976
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(safePipedChannel))) // => Exit.fail(error)
|
|
8888
8977
|
* ```
|
|
8889
8978
|
*
|
|
8890
8979
|
* @category sequencing
|
|
@@ -8926,7 +9015,7 @@ export const pipeToOrFail: {
|
|
|
8926
9015
|
*
|
|
8927
9016
|
* **Example** (Unwrapping channel effects)
|
|
8928
9017
|
*
|
|
8929
|
-
* ```ts
|
|
9018
|
+
* ```ts import.meta.vitest
|
|
8930
9019
|
* import { Channel, Data, Effect } from "effect"
|
|
8931
9020
|
*
|
|
8932
9021
|
* class UnwrapError extends Data.TaggedError("UnwrapError")<{
|
|
@@ -8941,7 +9030,7 @@ export const pipeToOrFail: {
|
|
|
8941
9030
|
* // Unwrap the effect to get the channel
|
|
8942
9031
|
* const unwrappedChannel = Channel.unwrap(channelEffect)
|
|
8943
9032
|
*
|
|
8944
|
-
* //
|
|
9033
|
+
* Effect.runSync(Channel.runCollect(unwrappedChannel)) // => [1, 2, 3]
|
|
8945
9034
|
* ```
|
|
8946
9035
|
*
|
|
8947
9036
|
* @category constructors
|
|
@@ -8990,7 +9079,7 @@ export const scoped = <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
|
8990
9079
|
*
|
|
8991
9080
|
* **Example** (Embedding custom input handling)
|
|
8992
9081
|
*
|
|
8993
|
-
* ```ts
|
|
9082
|
+
* ```ts import.meta.vitest
|
|
8994
9083
|
* import { Channel, Effect } from "effect"
|
|
8995
9084
|
*
|
|
8996
9085
|
* // Create a base channel
|
|
@@ -9001,13 +9090,11 @@ export const scoped = <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
|
9001
9090
|
* baseChannel,
|
|
9002
9091
|
* (upstream) =>
|
|
9003
9092
|
* upstream.pipe(
|
|
9004
|
-
* Effect.tap((message) =>
|
|
9005
|
-
* Effect.sync(() => console.log(message))
|
|
9006
|
-
* ),
|
|
9007
9093
|
* Effect.forever,
|
|
9008
9094
|
* Effect.ignore
|
|
9009
9095
|
* )
|
|
9010
9096
|
* )
|
|
9097
|
+
* await Effect.runPromise(Channel.runCollect(embeddedChannel)) // => [1, 2, 3]
|
|
9011
9098
|
* ```
|
|
9012
9099
|
*
|
|
9013
9100
|
* @category sequencing
|
|
@@ -9025,7 +9112,7 @@ export const embedInput: {
|
|
|
9025
9112
|
*
|
|
9026
9113
|
* **Example** (Embedding custom input handling)
|
|
9027
9114
|
*
|
|
9028
|
-
* ```ts
|
|
9115
|
+
* ```ts import.meta.vitest
|
|
9029
9116
|
* import { Channel, Effect } from "effect"
|
|
9030
9117
|
*
|
|
9031
9118
|
* // Create a base channel
|
|
@@ -9036,13 +9123,11 @@ export const embedInput: {
|
|
|
9036
9123
|
* baseChannel,
|
|
9037
9124
|
* (upstream) =>
|
|
9038
9125
|
* upstream.pipe(
|
|
9039
|
-
* Effect.tap((message) =>
|
|
9040
|
-
* Effect.sync(() => console.log(message))
|
|
9041
|
-
* ),
|
|
9042
9126
|
* Effect.forever,
|
|
9043
9127
|
* Effect.ignore
|
|
9044
9128
|
* )
|
|
9045
9129
|
* )
|
|
9130
|
+
* await Effect.runPromise(Channel.runCollect(embeddedChannel)) // => [1, 2, 3]
|
|
9046
9131
|
* ```
|
|
9047
9132
|
*
|
|
9048
9133
|
* @category sequencing
|
|
@@ -9066,7 +9151,7 @@ export const embedInput: {
|
|
|
9066
9151
|
*
|
|
9067
9152
|
* **Example** (Embedding custom input handling)
|
|
9068
9153
|
*
|
|
9069
|
-
* ```ts
|
|
9154
|
+
* ```ts import.meta.vitest
|
|
9070
9155
|
* import { Channel, Effect } from "effect"
|
|
9071
9156
|
*
|
|
9072
9157
|
* // Create a base channel
|
|
@@ -9077,13 +9162,11 @@ export const embedInput: {
|
|
|
9077
9162
|
* baseChannel,
|
|
9078
9163
|
* (upstream) =>
|
|
9079
9164
|
* upstream.pipe(
|
|
9080
|
-
* Effect.tap((message) =>
|
|
9081
|
-
* Effect.sync(() => console.log(message))
|
|
9082
|
-
* ),
|
|
9083
9165
|
* Effect.forever,
|
|
9084
9166
|
* Effect.ignore
|
|
9085
9167
|
* )
|
|
9086
9168
|
* )
|
|
9169
|
+
* await Effect.runPromise(Channel.runCollect(embeddedChannel)) // => [1, 2, 3]
|
|
9087
9170
|
* ```
|
|
9088
9171
|
*
|
|
9089
9172
|
* @category sequencing
|
|
@@ -9133,7 +9216,7 @@ export const embedInput: {
|
|
|
9133
9216
|
*
|
|
9134
9217
|
* @see {@link bufferArray} for buffering elements from array outputs
|
|
9135
9218
|
*
|
|
9136
|
-
* @category
|
|
9219
|
+
* @category buffering
|
|
9137
9220
|
* @since 2.0.0
|
|
9138
9221
|
*/
|
|
9139
9222
|
export const buffer: {
|
|
@@ -9159,7 +9242,7 @@ export const buffer: {
|
|
|
9159
9242
|
*
|
|
9160
9243
|
* @see {@link bufferArray} for buffering elements from array outputs
|
|
9161
9244
|
*
|
|
9162
|
-
* @category
|
|
9245
|
+
* @category buffering
|
|
9163
9246
|
* @since 2.0.0
|
|
9164
9247
|
*/
|
|
9165
9248
|
(
|
|
@@ -9192,7 +9275,7 @@ export const buffer: {
|
|
|
9192
9275
|
*
|
|
9193
9276
|
* @see {@link bufferArray} for buffering elements from array outputs
|
|
9194
9277
|
*
|
|
9195
|
-
* @category
|
|
9278
|
+
* @category buffering
|
|
9196
9279
|
* @since 2.0.0
|
|
9197
9280
|
*/
|
|
9198
9281
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -9233,7 +9316,7 @@ export const buffer: {
|
|
|
9233
9316
|
*
|
|
9234
9317
|
* @see {@link bufferArray} for buffering elements from array outputs
|
|
9235
9318
|
*
|
|
9236
|
-
* @category
|
|
9319
|
+
* @category buffering
|
|
9237
9320
|
* @since 2.0.0
|
|
9238
9321
|
*/
|
|
9239
9322
|
OutElem, /**
|
|
@@ -9258,7 +9341,7 @@ export const buffer: {
|
|
|
9258
9341
|
*
|
|
9259
9342
|
* @see {@link bufferArray} for buffering elements from array outputs
|
|
9260
9343
|
*
|
|
9261
|
-
* @category
|
|
9344
|
+
* @category buffering
|
|
9262
9345
|
* @since 2.0.0
|
|
9263
9346
|
*/
|
|
9264
9347
|
OutErr | Cause.Done<OutDone>>({
|
|
@@ -9299,7 +9382,7 @@ export const buffer: {
|
|
|
9299
9382
|
*
|
|
9300
9383
|
* @see {@link buffer} for buffering output elements without flattening arrays
|
|
9301
9384
|
*
|
|
9302
|
-
* @category
|
|
9385
|
+
* @category buffering
|
|
9303
9386
|
* @since 4.0.0
|
|
9304
9387
|
*/
|
|
9305
9388
|
export const bufferArray: {
|
|
@@ -9327,7 +9410,7 @@ export const bufferArray: {
|
|
|
9327
9410
|
*
|
|
9328
9411
|
* @see {@link buffer} for buffering output elements without flattening arrays
|
|
9329
9412
|
*
|
|
9330
|
-
* @category
|
|
9413
|
+
* @category buffering
|
|
9331
9414
|
* @since 4.0.0
|
|
9332
9415
|
*/
|
|
9333
9416
|
(
|
|
@@ -9362,7 +9445,7 @@ export const bufferArray: {
|
|
|
9362
9445
|
*
|
|
9363
9446
|
* @see {@link buffer} for buffering output elements without flattening arrays
|
|
9364
9447
|
*
|
|
9365
|
-
* @category
|
|
9448
|
+
* @category buffering
|
|
9366
9449
|
* @since 4.0.0
|
|
9367
9450
|
*/
|
|
9368
9451
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -9405,7 +9488,7 @@ export const bufferArray: {
|
|
|
9405
9488
|
*
|
|
9406
9489
|
* @see {@link buffer} for buffering output elements without flattening arrays
|
|
9407
9490
|
*
|
|
9408
|
-
* @category
|
|
9491
|
+
* @category buffering
|
|
9409
9492
|
* @since 4.0.0
|
|
9410
9493
|
*/
|
|
9411
9494
|
OutElem, /**
|
|
@@ -9432,7 +9515,7 @@ export const bufferArray: {
|
|
|
9432
9515
|
*
|
|
9433
9516
|
* @see {@link buffer} for buffering output elements without flattening arrays
|
|
9434
9517
|
*
|
|
9435
|
-
* @category
|
|
9518
|
+
* @category buffering
|
|
9436
9519
|
* @since 4.0.0
|
|
9437
9520
|
*/
|
|
9438
9521
|
OutErr | Cause.Done<OutDone>>({
|
|
@@ -9571,17 +9654,16 @@ export const haltWhen: {
|
|
|
9571
9654
|
): Channel<OutElem, OutErr | OutErr2, OutDone | OutDone2, InElem, InErr, InDone, Env2 | Env> =>
|
|
9572
9655
|
fromTransformBracket(Effect.fnUntraced(function*(upstream, scope, forkedScope) {
|
|
9573
9656
|
const pull = yield* toTransform(self)(upstream, scope)
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
)
|
|
9657
|
+
const fiber = yield* Effect.forkIn(effect, forkedScope, { startImmediately: true })
|
|
9658
|
+
return Effect.suspend((): Pull.Pull<OutElem, OutErr | OutErr2, OutDone | OutDone2> => {
|
|
9659
|
+
const exit = fiber.pollUnsafe()
|
|
9660
|
+
return exit === undefined
|
|
9661
|
+
? pull
|
|
9662
|
+
: Exit.match(exit, {
|
|
9663
|
+
onFailure: Effect.failCause,
|
|
9664
|
+
onSuccess: Cause.done
|
|
9665
|
+
})
|
|
9666
|
+
})
|
|
9585
9667
|
})))
|
|
9586
9668
|
|
|
9587
9669
|
/**
|
|
@@ -9639,8 +9721,8 @@ export const onError: {
|
|
|
9639
9721
|
*
|
|
9640
9722
|
* **Example** (Running exit finalizers)
|
|
9641
9723
|
*
|
|
9642
|
-
* ```ts
|
|
9643
|
-
* import { Channel,
|
|
9724
|
+
* ```ts import.meta.vitest
|
|
9725
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
9644
9726
|
*
|
|
9645
9727
|
* class ExitError extends Data.TaggedError("ExitError")<{
|
|
9646
9728
|
* readonly stage: string
|
|
@@ -9650,13 +9732,12 @@ export const onError: {
|
|
|
9650
9732
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
9651
9733
|
*
|
|
9652
9734
|
* // Attach exit handler
|
|
9735
|
+
* const exits: Array<Exit.Exit<void, ExitError>> = []
|
|
9653
9736
|
* const channelWithExit = Channel.onExit(dataChannel, (exit) => {
|
|
9654
|
-
*
|
|
9655
|
-
*
|
|
9656
|
-
* } else {
|
|
9657
|
-
* return Console.log(`Channel failed with: ${exit.cause}`)
|
|
9658
|
-
* }
|
|
9737
|
+
* exits.push(exit)
|
|
9738
|
+
* return Effect.void
|
|
9659
9739
|
* })
|
|
9740
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithExit)), exits] // => [[1, 2, 3], [Exit.void]]
|
|
9660
9741
|
* ```
|
|
9661
9742
|
*
|
|
9662
9743
|
* @category resource management
|
|
@@ -9669,8 +9750,8 @@ export const onExit: {
|
|
|
9669
9750
|
*
|
|
9670
9751
|
* **Example** (Running exit finalizers)
|
|
9671
9752
|
*
|
|
9672
|
-
* ```ts
|
|
9673
|
-
* import { Channel,
|
|
9753
|
+
* ```ts import.meta.vitest
|
|
9754
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
9674
9755
|
*
|
|
9675
9756
|
* class ExitError extends Data.TaggedError("ExitError")<{
|
|
9676
9757
|
* readonly stage: string
|
|
@@ -9680,13 +9761,12 @@ export const onExit: {
|
|
|
9680
9761
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
9681
9762
|
*
|
|
9682
9763
|
* // Attach exit handler
|
|
9764
|
+
* const exits: Array<Exit.Exit<void, ExitError>> = []
|
|
9683
9765
|
* const channelWithExit = Channel.onExit(dataChannel, (exit) => {
|
|
9684
|
-
*
|
|
9685
|
-
*
|
|
9686
|
-
* } else {
|
|
9687
|
-
* return Console.log(`Channel failed with: ${exit.cause}`)
|
|
9688
|
-
* }
|
|
9766
|
+
* exits.push(exit)
|
|
9767
|
+
* return Effect.void
|
|
9689
9768
|
* })
|
|
9769
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithExit)), exits] // => [[1, 2, 3], [Exit.void]]
|
|
9690
9770
|
* ```
|
|
9691
9771
|
*
|
|
9692
9772
|
* @category resource management
|
|
@@ -9703,8 +9783,8 @@ export const onExit: {
|
|
|
9703
9783
|
*
|
|
9704
9784
|
* **Example** (Running exit finalizers)
|
|
9705
9785
|
*
|
|
9706
|
-
* ```ts
|
|
9707
|
-
* import { Channel,
|
|
9786
|
+
* ```ts import.meta.vitest
|
|
9787
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
9708
9788
|
*
|
|
9709
9789
|
* class ExitError extends Data.TaggedError("ExitError")<{
|
|
9710
9790
|
* readonly stage: string
|
|
@@ -9714,13 +9794,12 @@ export const onExit: {
|
|
|
9714
9794
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
9715
9795
|
*
|
|
9716
9796
|
* // Attach exit handler
|
|
9797
|
+
* const exits: Array<Exit.Exit<void, ExitError>> = []
|
|
9717
9798
|
* const channelWithExit = Channel.onExit(dataChannel, (exit) => {
|
|
9718
|
-
*
|
|
9719
|
-
*
|
|
9720
|
-
* } else {
|
|
9721
|
-
* return Console.log(`Channel failed with: ${exit.cause}`)
|
|
9722
|
-
* }
|
|
9799
|
+
* exits.push(exit)
|
|
9800
|
+
* return Effect.void
|
|
9723
9801
|
* })
|
|
9802
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithExit)), exits] // => [[1, 2, 3], [Exit.void]]
|
|
9724
9803
|
* ```
|
|
9725
9804
|
*
|
|
9726
9805
|
* @category resource management
|
|
@@ -9919,8 +9998,8 @@ export const onEnd: {
|
|
|
9919
9998
|
*
|
|
9920
9999
|
* **Example** (Ensuring cleanup runs)
|
|
9921
10000
|
*
|
|
9922
|
-
* ```ts
|
|
9923
|
-
* import { Channel,
|
|
10001
|
+
* ```ts import.meta.vitest
|
|
10002
|
+
* import { Channel, Data, Effect } from "effect"
|
|
9924
10003
|
*
|
|
9925
10004
|
* class EnsureError extends Data.TaggedError("EnsureError")<{
|
|
9926
10005
|
* readonly operation: string
|
|
@@ -9930,10 +10009,12 @@ export const onEnd: {
|
|
|
9930
10009
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
9931
10010
|
*
|
|
9932
10011
|
* // Ensure cleanup always runs
|
|
10012
|
+
* const events: Array<string> = []
|
|
9933
10013
|
* const channelWithCleanup = Channel.ensuring(
|
|
9934
10014
|
* dataChannel,
|
|
9935
|
-
*
|
|
10015
|
+
* Effect.sync(() => events.push("cleanup"))
|
|
9936
10016
|
* )
|
|
10017
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithCleanup)), events] // => [[1, 2, 3], ["cleanup"]]
|
|
9937
10018
|
* ```
|
|
9938
10019
|
*
|
|
9939
10020
|
* @category resource management
|
|
@@ -9946,8 +10027,8 @@ export const ensuring: {
|
|
|
9946
10027
|
*
|
|
9947
10028
|
* **Example** (Ensuring cleanup runs)
|
|
9948
10029
|
*
|
|
9949
|
-
* ```ts
|
|
9950
|
-
* import { Channel,
|
|
10030
|
+
* ```ts import.meta.vitest
|
|
10031
|
+
* import { Channel, Data, Effect } from "effect"
|
|
9951
10032
|
*
|
|
9952
10033
|
* class EnsureError extends Data.TaggedError("EnsureError")<{
|
|
9953
10034
|
* readonly operation: string
|
|
@@ -9957,10 +10038,12 @@ export const ensuring: {
|
|
|
9957
10038
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
9958
10039
|
*
|
|
9959
10040
|
* // Ensure cleanup always runs
|
|
10041
|
+
* const events: Array<string> = []
|
|
9960
10042
|
* const channelWithCleanup = Channel.ensuring(
|
|
9961
10043
|
* dataChannel,
|
|
9962
|
-
*
|
|
10044
|
+
* Effect.sync(() => events.push("cleanup"))
|
|
9963
10045
|
* )
|
|
10046
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithCleanup)), events] // => [[1, 2, 3], ["cleanup"]]
|
|
9964
10047
|
* ```
|
|
9965
10048
|
*
|
|
9966
10049
|
* @category resource management
|
|
@@ -9975,8 +10058,8 @@ export const ensuring: {
|
|
|
9975
10058
|
*
|
|
9976
10059
|
* **Example** (Ensuring cleanup runs)
|
|
9977
10060
|
*
|
|
9978
|
-
* ```ts
|
|
9979
|
-
* import { Channel,
|
|
10061
|
+
* ```ts import.meta.vitest
|
|
10062
|
+
* import { Channel, Data, Effect } from "effect"
|
|
9980
10063
|
*
|
|
9981
10064
|
* class EnsureError extends Data.TaggedError("EnsureError")<{
|
|
9982
10065
|
* readonly operation: string
|
|
@@ -9986,10 +10069,12 @@ export const ensuring: {
|
|
|
9986
10069
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
9987
10070
|
*
|
|
9988
10071
|
* // Ensure cleanup always runs
|
|
10072
|
+
* const events: Array<string> = []
|
|
9989
10073
|
* const channelWithCleanup = Channel.ensuring(
|
|
9990
10074
|
* dataChannel,
|
|
9991
|
-
*
|
|
10075
|
+
* Effect.sync(() => events.push("cleanup"))
|
|
9992
10076
|
* )
|
|
10077
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithCleanup)), events] // => [[1, 2, 3], ["cleanup"]]
|
|
9993
10078
|
* ```
|
|
9994
10079
|
*
|
|
9995
10080
|
* @category resource management
|
|
@@ -10030,7 +10115,7 @@ const runWith = <
|
|
|
10030
10115
|
/**
|
|
10031
10116
|
* Creates a channel from the specified services.
|
|
10032
10117
|
*
|
|
10033
|
-
* @category
|
|
10118
|
+
* @category accessors
|
|
10034
10119
|
* @since 2.0.0
|
|
10035
10120
|
*/
|
|
10036
10121
|
export const contextWith = <Env, OutElem, OutErr, OutDone, InElem, InErr, InDone, Env2>(
|
|
@@ -10044,7 +10129,7 @@ export const contextWith = <Env, OutElem, OutErr, OutDone, InElem, InErr, InDone
|
|
|
10044
10129
|
* Provides a `Context` to the channel, removing the corresponding service
|
|
10045
10130
|
* requirements from the returned channel.
|
|
10046
10131
|
*
|
|
10047
|
-
* @category services
|
|
10132
|
+
* @category providing services
|
|
10048
10133
|
* @since 2.0.0
|
|
10049
10134
|
*/
|
|
10050
10135
|
export const provideContext: {
|
|
@@ -10052,7 +10137,7 @@ export const provideContext: {
|
|
|
10052
10137
|
* Provides a `Context` to the channel, removing the corresponding service
|
|
10053
10138
|
* requirements from the returned channel.
|
|
10054
10139
|
*
|
|
10055
|
-
* @category services
|
|
10140
|
+
* @category providing services
|
|
10056
10141
|
* @since 2.0.0
|
|
10057
10142
|
*/
|
|
10058
10143
|
<R2>(context: Context.Context<R2>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -10062,7 +10147,7 @@ export const provideContext: {
|
|
|
10062
10147
|
* Provides a `Context` to the channel, removing the corresponding service
|
|
10063
10148
|
* requirements from the returned channel.
|
|
10064
10149
|
*
|
|
10065
|
-
* @category services
|
|
10150
|
+
* @category providing services
|
|
10066
10151
|
* @since 2.0.0
|
|
10067
10152
|
*/
|
|
10068
10153
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, R2>(
|
|
@@ -10084,7 +10169,7 @@ export const provideContext: {
|
|
|
10084
10169
|
* Provides a concrete service for a context key, removing that service
|
|
10085
10170
|
* requirement from the returned channel.
|
|
10086
10171
|
*
|
|
10087
|
-
* @category services
|
|
10172
|
+
* @category providing services
|
|
10088
10173
|
* @since 2.0.0
|
|
10089
10174
|
*/
|
|
10090
10175
|
export const provideService: {
|
|
@@ -10092,7 +10177,7 @@ export const provideService: {
|
|
|
10092
10177
|
* Provides a concrete service for a context key, removing that service
|
|
10093
10178
|
* requirement from the returned channel.
|
|
10094
10179
|
*
|
|
10095
|
-
* @category services
|
|
10180
|
+
* @category providing services
|
|
10096
10181
|
* @since 2.0.0
|
|
10097
10182
|
*/
|
|
10098
10183
|
<I, S>(key: Context.Key<I, S>, service: NoInfer<S>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -10102,7 +10187,7 @@ export const provideService: {
|
|
|
10102
10187
|
* Provides a concrete service for a context key, removing that service
|
|
10103
10188
|
* requirement from the returned channel.
|
|
10104
10189
|
*
|
|
10105
|
-
* @category services
|
|
10190
|
+
* @category providing services
|
|
10106
10191
|
* @since 2.0.0
|
|
10107
10192
|
*/
|
|
10108
10193
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
|
|
@@ -10135,7 +10220,7 @@ export const provideService: {
|
|
|
10135
10220
|
* If the service effect fails, the returned channel fails. The provided service
|
|
10136
10221
|
* removes the corresponding service requirement from the returned channel.
|
|
10137
10222
|
*
|
|
10138
|
-
* @category services
|
|
10223
|
+
* @category providing services
|
|
10139
10224
|
* @since 4.0.0
|
|
10140
10225
|
*/
|
|
10141
10226
|
export const provideServiceEffect: {
|
|
@@ -10152,7 +10237,7 @@ export const provideServiceEffect: {
|
|
|
10152
10237
|
* If the service effect fails, the returned channel fails. The provided service
|
|
10153
10238
|
* removes the corresponding service requirement from the returned channel.
|
|
10154
10239
|
*
|
|
10155
|
-
* @category services
|
|
10240
|
+
* @category providing services
|
|
10156
10241
|
* @since 4.0.0
|
|
10157
10242
|
*/
|
|
10158
10243
|
<I, S, ES, RS>(key: Context.Key<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -10171,7 +10256,7 @@ export const provideServiceEffect: {
|
|
|
10171
10256
|
* If the service effect fails, the returned channel fails. The provided service
|
|
10172
10257
|
* removes the corresponding service requirement from the returned channel.
|
|
10173
10258
|
*
|
|
10174
|
-
* @category services
|
|
10259
|
+
* @category providing services
|
|
10175
10260
|
* @since 4.0.0
|
|
10176
10261
|
*/
|
|
10177
10262
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S, ES, RS>(
|
|
@@ -10201,7 +10286,7 @@ export const provideServiceEffect: {
|
|
|
10201
10286
|
* builds the layer in the channel scope. Use `options.local` to build a fresh
|
|
10202
10287
|
* layer instance for this provision.
|
|
10203
10288
|
*
|
|
10204
|
-
* @category services
|
|
10289
|
+
* @category providing services
|
|
10205
10290
|
* @since 4.0.0
|
|
10206
10291
|
*/
|
|
10207
10292
|
export const provide: {
|
|
@@ -10215,7 +10300,7 @@ export const provide: {
|
|
|
10215
10300
|
* builds the layer in the channel scope. Use `options.local` to build a fresh
|
|
10216
10301
|
* layer instance for this provision.
|
|
10217
10302
|
*
|
|
10218
|
-
* @category services
|
|
10303
|
+
* @category providing services
|
|
10219
10304
|
* @since 4.0.0
|
|
10220
10305
|
*/
|
|
10221
10306
|
<A, E = never, R = never>(
|
|
@@ -10236,7 +10321,7 @@ export const provide: {
|
|
|
10236
10321
|
* builds the layer in the channel scope. Use `options.local` to build a fresh
|
|
10237
10322
|
* layer instance for this provision.
|
|
10238
10323
|
*
|
|
10239
|
-
* @category services
|
|
10324
|
+
* @category providing services
|
|
10240
10325
|
* @since 4.0.0
|
|
10241
10326
|
*/
|
|
10242
10327
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, A, E = never, R = never>(
|
|
@@ -10275,7 +10360,7 @@ export const provide: {
|
|
|
10275
10360
|
* provide to the channel. The returned channel requires the services needed to
|
|
10276
10361
|
* build that context.
|
|
10277
10362
|
*
|
|
10278
|
-
* @category services
|
|
10363
|
+
* @category providing services
|
|
10279
10364
|
* @since 4.0.0
|
|
10280
10365
|
*/
|
|
10281
10366
|
export const updateContext: {
|
|
@@ -10288,7 +10373,7 @@ export const updateContext: {
|
|
|
10288
10373
|
* provide to the channel. The returned channel requires the services needed to
|
|
10289
10374
|
* build that context.
|
|
10290
10375
|
*
|
|
10291
|
-
* @category services
|
|
10376
|
+
* @category providing services
|
|
10292
10377
|
* @since 4.0.0
|
|
10293
10378
|
*/
|
|
10294
10379
|
<Env, R2>(f: (context: Context.Context<R2>) => Context.Context<Env>): <OutElem, OutErr, OutDone, InElem, InErr, InDone>(
|
|
@@ -10303,7 +10388,7 @@ export const updateContext: {
|
|
|
10303
10388
|
* provide to the channel. The returned channel requires the services needed to
|
|
10304
10389
|
* build that context.
|
|
10305
10390
|
*
|
|
10306
|
-
* @category services
|
|
10391
|
+
* @category providing services
|
|
10307
10392
|
* @since 4.0.0
|
|
10308
10393
|
*/
|
|
10309
10394
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, R2>(
|
|
@@ -10329,7 +10414,7 @@ export const updateContext: {
|
|
|
10329
10414
|
* The existing service is read from the context. The updated service is
|
|
10330
10415
|
* provided to the channel under the same key.
|
|
10331
10416
|
*
|
|
10332
|
-
* @category services
|
|
10417
|
+
* @category providing services
|
|
10333
10418
|
* @since 2.0.0
|
|
10334
10419
|
*/
|
|
10335
10420
|
export const updateService: {
|
|
@@ -10341,7 +10426,7 @@ export const updateService: {
|
|
|
10341
10426
|
* The existing service is read from the context. The updated service is
|
|
10342
10427
|
* provided to the channel under the same key.
|
|
10343
10428
|
*
|
|
10344
|
-
* @category services
|
|
10429
|
+
* @category providing services
|
|
10345
10430
|
* @since 2.0.0
|
|
10346
10431
|
*/
|
|
10347
10432
|
<I, S>(key: Context.Key<I, S>, f: (service: NoInfer<S>) => S): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -10355,7 +10440,7 @@ export const updateService: {
|
|
|
10355
10440
|
* The existing service is read from the context. The updated service is
|
|
10356
10441
|
* provided to the channel under the same key.
|
|
10357
10442
|
*
|
|
10358
|
-
* @category services
|
|
10443
|
+
* @category providing services
|
|
10359
10444
|
* @since 2.0.0
|
|
10360
10445
|
*/
|
|
10361
10446
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
|
|
@@ -10447,7 +10532,7 @@ const withSpanImpl = <OutElem, OutErr, OutDone, InElem, InErr, InDone, R>(
|
|
|
10447
10532
|
/**
|
|
10448
10533
|
* The starting channel for Do notation, emitting an empty object.
|
|
10449
10534
|
*
|
|
10450
|
-
* @category
|
|
10535
|
+
* @category constructors
|
|
10451
10536
|
* @since 4.0.0
|
|
10452
10537
|
*/
|
|
10453
10538
|
export const Do: Channel<{}> = succeed({})
|
|
@@ -10501,7 +10586,7 @@ export {
|
|
|
10501
10586
|
/**
|
|
10502
10587
|
* Adds a computed field to each object emitted by a channel.
|
|
10503
10588
|
*
|
|
10504
|
-
* @category
|
|
10589
|
+
* @category mapping
|
|
10505
10590
|
* @since 4.0.0
|
|
10506
10591
|
*/
|
|
10507
10592
|
let_ as let
|
|
@@ -10517,7 +10602,7 @@ export {
|
|
|
10517
10602
|
* channel's output becomes the value of the new field. `options.concurrency`
|
|
10518
10603
|
* and `options.bufferSize` control how derived channels are flattened.
|
|
10519
10604
|
*
|
|
10520
|
-
* @category
|
|
10605
|
+
* @category sequencing
|
|
10521
10606
|
* @since 4.0.0
|
|
10522
10607
|
*/
|
|
10523
10608
|
export const bind: {
|
|
@@ -10531,7 +10616,7 @@ export const bind: {
|
|
|
10531
10616
|
* channel's output becomes the value of the new field. `options.concurrency`
|
|
10532
10617
|
* and `options.bufferSize` control how derived channels are flattened.
|
|
10533
10618
|
*
|
|
10534
|
-
* @category
|
|
10619
|
+
* @category sequencing
|
|
10535
10620
|
* @since 4.0.0
|
|
10536
10621
|
*/
|
|
10537
10622
|
<N extends string, OutElem extends object, B, OutErr2, OutDone2, InElem2, InErr2, InDone2, Env2>(
|
|
@@ -10562,7 +10647,7 @@ export const bind: {
|
|
|
10562
10647
|
* channel's output becomes the value of the new field. `options.concurrency`
|
|
10563
10648
|
* and `options.bufferSize` control how derived channels are flattened.
|
|
10564
10649
|
*
|
|
10565
|
-
* @category
|
|
10650
|
+
* @category sequencing
|
|
10566
10651
|
* @since 4.0.0
|
|
10567
10652
|
*/
|
|
10568
10653
|
<
|
|
@@ -10649,7 +10734,7 @@ export const bind: {
|
|
|
10649
10734
|
* @see {@link bind} for adding a field produced by another channel
|
|
10650
10735
|
* @see {@link let_ let} for adding a computed field
|
|
10651
10736
|
*
|
|
10652
|
-
* @category
|
|
10737
|
+
* @category mapping
|
|
10653
10738
|
* @since 4.0.0
|
|
10654
10739
|
*/
|
|
10655
10740
|
export const bindTo: {
|
|
@@ -10665,7 +10750,7 @@ export const bindTo: {
|
|
|
10665
10750
|
* @see {@link bind} for adding a field produced by another channel
|
|
10666
10751
|
* @see {@link let_ let} for adding a computed field
|
|
10667
10752
|
*
|
|
10668
|
-
* @category
|
|
10753
|
+
* @category mapping
|
|
10669
10754
|
* @since 4.0.0
|
|
10670
10755
|
*/
|
|
10671
10756
|
<N extends string>(name: N): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
|
|
@@ -10691,7 +10776,7 @@ export const bindTo: {
|
|
|
10691
10776
|
* @see {@link bind} for adding a field produced by another channel
|
|
10692
10777
|
* @see {@link let_ let} for adding a computed field
|
|
10693
10778
|
*
|
|
10694
|
-
* @category
|
|
10779
|
+
* @category mapping
|
|
10695
10780
|
* @since 4.0.0
|
|
10696
10781
|
*/
|
|
10697
10782
|
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, N extends string>(
|
|
@@ -10724,8 +10809,8 @@ export const bindTo: {
|
|
|
10724
10809
|
*
|
|
10725
10810
|
* **Example** (Counting channel output)
|
|
10726
10811
|
*
|
|
10727
|
-
* ```ts
|
|
10728
|
-
* import { Channel, Data } from "effect"
|
|
10812
|
+
* ```ts import.meta.vitest
|
|
10813
|
+
* import { Channel, Data, Effect } from "effect"
|
|
10729
10814
|
*
|
|
10730
10815
|
* class CountError extends Data.TaggedError("CountError")<{
|
|
10731
10816
|
* readonly reason: string
|
|
@@ -10737,10 +10822,10 @@ export const bindTo: {
|
|
|
10737
10822
|
* // Count the elements
|
|
10738
10823
|
* const countEffect = Channel.runCount(numbersChannel)
|
|
10739
10824
|
*
|
|
10740
|
-
*
|
|
10825
|
+
* Effect.runSync(countEffect) // => 5
|
|
10741
10826
|
* ```
|
|
10742
10827
|
*
|
|
10743
|
-
* @category
|
|
10828
|
+
* @category running
|
|
10744
10829
|
* @since 4.0.0
|
|
10745
10830
|
*/
|
|
10746
10831
|
export const runCount = <OutElem, OutErr, OutDone, Env>(
|
|
@@ -10752,8 +10837,8 @@ export const runCount = <OutElem, OutErr, OutDone, Env>(
|
|
|
10752
10837
|
*
|
|
10753
10838
|
* **Example** (Draining channel output at runtime)
|
|
10754
10839
|
*
|
|
10755
|
-
* ```ts
|
|
10756
|
-
* import { Channel, Data } from "effect"
|
|
10840
|
+
* ```ts import.meta.vitest
|
|
10841
|
+
* import { Channel, Data, Effect } from "effect"
|
|
10757
10842
|
*
|
|
10758
10843
|
* class DrainError extends Data.TaggedError("DrainError")<{
|
|
10759
10844
|
* readonly stage: string
|
|
@@ -10761,18 +10846,15 @@ export const runCount = <OutElem, OutErr, OutDone, Env>(
|
|
|
10761
10846
|
*
|
|
10762
10847
|
* // Create a channel that outputs elements and completes with a result
|
|
10763
10848
|
* const resultChannel = Channel.fromIterable([1, 2, 3])
|
|
10764
|
-
* const completedChannel = Channel.
|
|
10765
|
-
* resultChannel,
|
|
10766
|
-
* () => Channel.succeed("completed")
|
|
10767
|
-
* )
|
|
10849
|
+
* const completedChannel = Channel.concat(resultChannel, Channel.end("completed"))
|
|
10768
10850
|
*
|
|
10769
10851
|
* // Drain all elements and get only the final result
|
|
10770
10852
|
* const drainEffect = Channel.runDrain(completedChannel)
|
|
10771
10853
|
*
|
|
10772
|
-
*
|
|
10854
|
+
* Effect.runSync(drainEffect) // => "completed"
|
|
10773
10855
|
* ```
|
|
10774
10856
|
*
|
|
10775
|
-
* @category
|
|
10857
|
+
* @category running
|
|
10776
10858
|
* @since 2.0.0
|
|
10777
10859
|
*/
|
|
10778
10860
|
export const runDrain = <OutElem, OutErr, OutDone, Env>(
|
|
@@ -10784,8 +10866,8 @@ export const runDrain = <OutElem, OutErr, OutDone, Env>(
|
|
|
10784
10866
|
*
|
|
10785
10867
|
* **Example** (Running effects for each output)
|
|
10786
10868
|
*
|
|
10787
|
-
* ```ts
|
|
10788
|
-
* import { Channel,
|
|
10869
|
+
* ```ts import.meta.vitest
|
|
10870
|
+
* import { Channel, Data, Effect } from "effect"
|
|
10789
10871
|
*
|
|
10790
10872
|
* class ForEachError extends Data.TaggedError("ForEachError")<{
|
|
10791
10873
|
* readonly element: unknown
|
|
@@ -10794,16 +10876,18 @@ export const runDrain = <OutElem, OutErr, OutDone, Env>(
|
|
|
10794
10876
|
* // Create a channel with numbers
|
|
10795
10877
|
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
10796
10878
|
*
|
|
10797
|
-
* // Run forEach to
|
|
10879
|
+
* // Run forEach to process each element
|
|
10880
|
+
* const processed: Array<number> = []
|
|
10798
10881
|
* const forEachEffect = Channel.runForEach(
|
|
10799
10882
|
* numbersChannel,
|
|
10800
|
-
* (n) =>
|
|
10883
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
10801
10884
|
* )
|
|
10802
10885
|
*
|
|
10803
|
-
*
|
|
10886
|
+
* await Effect.runPromise(forEachEffect)
|
|
10887
|
+
* processed // => [1, 2, 3]
|
|
10804
10888
|
* ```
|
|
10805
10889
|
*
|
|
10806
|
-
* @category
|
|
10890
|
+
* @category running
|
|
10807
10891
|
* @since 4.0.0
|
|
10808
10892
|
*/
|
|
10809
10893
|
export const runForEach: {
|
|
@@ -10812,8 +10896,8 @@ export const runForEach: {
|
|
|
10812
10896
|
*
|
|
10813
10897
|
* **Example** (Running effects for each output)
|
|
10814
10898
|
*
|
|
10815
|
-
* ```ts
|
|
10816
|
-
* import { Channel,
|
|
10899
|
+
* ```ts import.meta.vitest
|
|
10900
|
+
* import { Channel, Data, Effect } from "effect"
|
|
10817
10901
|
*
|
|
10818
10902
|
* class ForEachError extends Data.TaggedError("ForEachError")<{
|
|
10819
10903
|
* readonly element: unknown
|
|
@@ -10822,16 +10906,18 @@ export const runForEach: {
|
|
|
10822
10906
|
* // Create a channel with numbers
|
|
10823
10907
|
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
10824
10908
|
*
|
|
10825
|
-
* // Run forEach to
|
|
10909
|
+
* // Run forEach to process each element
|
|
10910
|
+
* const processed: Array<number> = []
|
|
10826
10911
|
* const forEachEffect = Channel.runForEach(
|
|
10827
10912
|
* numbersChannel,
|
|
10828
|
-
* (n) =>
|
|
10913
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
10829
10914
|
* )
|
|
10830
10915
|
*
|
|
10831
|
-
*
|
|
10916
|
+
* await Effect.runPromise(forEachEffect)
|
|
10917
|
+
* processed // => [1, 2, 3]
|
|
10832
10918
|
* ```
|
|
10833
10919
|
*
|
|
10834
|
-
* @category
|
|
10920
|
+
* @category running
|
|
10835
10921
|
* @since 4.0.0
|
|
10836
10922
|
*/
|
|
10837
10923
|
<OutElem, EX, RX>(f: (o: OutElem) => Effect.Effect<void, EX, RX>): <OutErr, OutDone, Env>(
|
|
@@ -10842,8 +10928,8 @@ export const runForEach: {
|
|
|
10842
10928
|
*
|
|
10843
10929
|
* **Example** (Running effects for each output)
|
|
10844
10930
|
*
|
|
10845
|
-
* ```ts
|
|
10846
|
-
* import { Channel,
|
|
10931
|
+
* ```ts import.meta.vitest
|
|
10932
|
+
* import { Channel, Data, Effect } from "effect"
|
|
10847
10933
|
*
|
|
10848
10934
|
* class ForEachError extends Data.TaggedError("ForEachError")<{
|
|
10849
10935
|
* readonly element: unknown
|
|
@@ -10852,16 +10938,18 @@ export const runForEach: {
|
|
|
10852
10938
|
* // Create a channel with numbers
|
|
10853
10939
|
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
10854
10940
|
*
|
|
10855
|
-
* // Run forEach to
|
|
10941
|
+
* // Run forEach to process each element
|
|
10942
|
+
* const processed: Array<number> = []
|
|
10856
10943
|
* const forEachEffect = Channel.runForEach(
|
|
10857
10944
|
* numbersChannel,
|
|
10858
|
-
* (n) =>
|
|
10945
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
10859
10946
|
* )
|
|
10860
10947
|
*
|
|
10861
|
-
*
|
|
10948
|
+
* await Effect.runPromise(forEachEffect)
|
|
10949
|
+
* processed // => [1, 2, 3]
|
|
10862
10950
|
* ```
|
|
10863
10951
|
*
|
|
10864
|
-
* @category
|
|
10952
|
+
* @category running
|
|
10865
10953
|
* @since 4.0.0
|
|
10866
10954
|
*/
|
|
10867
10955
|
<OutElem, OutErr, OutDone, Env, EX, RX>(
|
|
@@ -10886,7 +10974,7 @@ export const runForEach: {
|
|
|
10886
10974
|
* Returning `true` continues consuming the channel. Returning `false` stops
|
|
10887
10975
|
* consumption early. The returned effect completes with `void`.
|
|
10888
10976
|
*
|
|
10889
|
-
* @category
|
|
10977
|
+
* @category running
|
|
10890
10978
|
* @since 4.0.0
|
|
10891
10979
|
*/
|
|
10892
10980
|
export const runForEachWhile: {
|
|
@@ -10899,7 +10987,7 @@ export const runForEachWhile: {
|
|
|
10899
10987
|
* Returning `true` continues consuming the channel. Returning `false` stops
|
|
10900
10988
|
* consumption early. The returned effect completes with `void`.
|
|
10901
10989
|
*
|
|
10902
|
-
* @category
|
|
10990
|
+
* @category running
|
|
10903
10991
|
* @since 4.0.0
|
|
10904
10992
|
*/
|
|
10905
10993
|
<OutElem, EX, RX>(f: (o: OutElem) => Effect.Effect<boolean, EX, RX>): <OutErr, OutDone, Env>(
|
|
@@ -10914,7 +11002,7 @@ export const runForEachWhile: {
|
|
|
10914
11002
|
* Returning `true` continues consuming the channel. Returning `false` stops
|
|
10915
11003
|
* consumption early. The returned effect completes with `void`.
|
|
10916
11004
|
*
|
|
10917
|
-
* @category
|
|
11005
|
+
* @category running
|
|
10918
11006
|
* @since 4.0.0
|
|
10919
11007
|
*/
|
|
10920
11008
|
<OutElem, OutErr, OutDone, Env, EX, RX>(
|
|
@@ -10940,8 +11028,8 @@ export const runForEachWhile: {
|
|
|
10940
11028
|
*
|
|
10941
11029
|
* **Example** (Collecting channel output)
|
|
10942
11030
|
*
|
|
10943
|
-
* ```ts
|
|
10944
|
-
* import { Channel, Data } from "effect"
|
|
11031
|
+
* ```ts import.meta.vitest
|
|
11032
|
+
* import { Channel, Data, Effect } from "effect"
|
|
10945
11033
|
*
|
|
10946
11034
|
* class CollectError extends Data.TaggedError("CollectError")<{
|
|
10947
11035
|
* readonly reason: string
|
|
@@ -10953,10 +11041,10 @@ export const runForEachWhile: {
|
|
|
10953
11041
|
* // Collect all elements into an array
|
|
10954
11042
|
* const collectEffect = Channel.runCollect(numbersChannel)
|
|
10955
11043
|
*
|
|
10956
|
-
*
|
|
11044
|
+
* Effect.runSync(collectEffect) // => [1, 2, 3, 4, 5]
|
|
10957
11045
|
* ```
|
|
10958
11046
|
*
|
|
10959
|
-
* @category
|
|
11047
|
+
* @category running
|
|
10960
11048
|
* @since 2.0.0
|
|
10961
11049
|
*/
|
|
10962
11050
|
export const runCollect = <OutElem, OutErr, OutDone, Env>(
|
|
@@ -10970,7 +11058,7 @@ export const runCollect = <OutElem, OutErr, OutDone, Env>(
|
|
|
10970
11058
|
/**
|
|
10971
11059
|
* Runs a channel and outputs the done value.
|
|
10972
11060
|
*
|
|
10973
|
-
* @category
|
|
11061
|
+
* @category running
|
|
10974
11062
|
* @since 4.0.0
|
|
10975
11063
|
*/
|
|
10976
11064
|
export const runDone = <OutElem, OutErr, OutDone, Env>(
|
|
@@ -10986,7 +11074,7 @@ export const runDone = <OutElem, OutErr, OutDone, Env>(
|
|
|
10986
11074
|
* Returns `Option.some` with the first output element, or `Option.none` if the
|
|
10987
11075
|
* channel completes without emitting output.
|
|
10988
11076
|
*
|
|
10989
|
-
* @category
|
|
11077
|
+
* @category running
|
|
10990
11078
|
* @since 4.0.0
|
|
10991
11079
|
*/
|
|
10992
11080
|
export const runHead = <OutElem, OutErr, OutDone, Env>(
|
|
@@ -11013,7 +11101,7 @@ export const runHead = <OutElem, OutErr, OutDone, Env>(
|
|
|
11013
11101
|
* Returns `Option.some` with the last emitted element, or `Option.none` if the
|
|
11014
11102
|
* channel completes without emitting output.
|
|
11015
11103
|
*
|
|
11016
|
-
* @category
|
|
11104
|
+
* @category running
|
|
11017
11105
|
* @since 4.0.0
|
|
11018
11106
|
*/
|
|
11019
11107
|
export const runLast = <OutElem, OutErr, OutDone, Env>(
|
|
@@ -11041,8 +11129,8 @@ export const runLast = <OutElem, OutErr, OutDone, Env>(
|
|
|
11041
11129
|
*
|
|
11042
11130
|
* **Example** (Folding channel output)
|
|
11043
11131
|
*
|
|
11044
|
-
* ```ts
|
|
11045
|
-
* import { Channel, Data } from "effect"
|
|
11132
|
+
* ```ts import.meta.vitest
|
|
11133
|
+
* import { Channel, Data, Effect } from "effect"
|
|
11046
11134
|
*
|
|
11047
11135
|
* class FoldError extends Data.TaggedError("FoldError")<{
|
|
11048
11136
|
* readonly operation: string
|
|
@@ -11054,10 +11142,10 @@ export const runLast = <OutElem, OutErr, OutDone, Env>(
|
|
|
11054
11142
|
* // Fold to calculate sum
|
|
11055
11143
|
* const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n)
|
|
11056
11144
|
*
|
|
11057
|
-
*
|
|
11145
|
+
* Effect.runSync(sumEffect) // => 15
|
|
11058
11146
|
* ```
|
|
11059
11147
|
*
|
|
11060
|
-
* @category
|
|
11148
|
+
* @category running
|
|
11061
11149
|
* @since 4.0.0
|
|
11062
11150
|
*/
|
|
11063
11151
|
export const runFold: {
|
|
@@ -11066,8 +11154,8 @@ export const runFold: {
|
|
|
11066
11154
|
*
|
|
11067
11155
|
* **Example** (Folding channel output)
|
|
11068
11156
|
*
|
|
11069
|
-
* ```ts
|
|
11070
|
-
* import { Channel, Data } from "effect"
|
|
11157
|
+
* ```ts import.meta.vitest
|
|
11158
|
+
* import { Channel, Data, Effect } from "effect"
|
|
11071
11159
|
*
|
|
11072
11160
|
* class FoldError extends Data.TaggedError("FoldError")<{
|
|
11073
11161
|
* readonly operation: string
|
|
@@ -11079,10 +11167,10 @@ export const runFold: {
|
|
|
11079
11167
|
* // Fold to calculate sum
|
|
11080
11168
|
* const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n)
|
|
11081
11169
|
*
|
|
11082
|
-
*
|
|
11170
|
+
* Effect.runSync(sumEffect) // => 15
|
|
11083
11171
|
* ```
|
|
11084
11172
|
*
|
|
11085
|
-
* @category
|
|
11173
|
+
* @category running
|
|
11086
11174
|
* @since 4.0.0
|
|
11087
11175
|
*/
|
|
11088
11176
|
<Z, OutElem>(initial: LazyArg<Z>, f: (acc: Z, o: OutElem) => Z): <OutErr, OutDone, Env>(
|
|
@@ -11093,8 +11181,8 @@ export const runFold: {
|
|
|
11093
11181
|
*
|
|
11094
11182
|
* **Example** (Folding channel output)
|
|
11095
11183
|
*
|
|
11096
|
-
* ```ts
|
|
11097
|
-
* import { Channel, Data } from "effect"
|
|
11184
|
+
* ```ts import.meta.vitest
|
|
11185
|
+
* import { Channel, Data, Effect } from "effect"
|
|
11098
11186
|
*
|
|
11099
11187
|
* class FoldError extends Data.TaggedError("FoldError")<{
|
|
11100
11188
|
* readonly operation: string
|
|
@@ -11106,10 +11194,10 @@ export const runFold: {
|
|
|
11106
11194
|
* // Fold to calculate sum
|
|
11107
11195
|
* const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n)
|
|
11108
11196
|
*
|
|
11109
|
-
*
|
|
11197
|
+
* Effect.runSync(sumEffect) // => 15
|
|
11110
11198
|
* ```
|
|
11111
11199
|
*
|
|
11112
|
-
* @category
|
|
11200
|
+
* @category running
|
|
11113
11201
|
* @since 4.0.0
|
|
11114
11202
|
*/
|
|
11115
11203
|
<OutElem, OutErr, OutDone, Env, Z>(
|
|
@@ -11152,7 +11240,7 @@ export const runFold: {
|
|
|
11152
11240
|
* the effectful accumulator function. The returned effect succeeds with the
|
|
11153
11241
|
* final accumulator value.
|
|
11154
11242
|
*
|
|
11155
|
-
* @category
|
|
11243
|
+
* @category running
|
|
11156
11244
|
* @since 4.0.0
|
|
11157
11245
|
*/
|
|
11158
11246
|
export const runFoldEffect: {
|
|
@@ -11170,7 +11258,7 @@ export const runFoldEffect: {
|
|
|
11170
11258
|
* the effectful accumulator function. The returned effect succeeds with the
|
|
11171
11259
|
* final accumulator value.
|
|
11172
11260
|
*
|
|
11173
|
-
* @category
|
|
11261
|
+
* @category running
|
|
11174
11262
|
* @since 4.0.0
|
|
11175
11263
|
*/
|
|
11176
11264
|
<OutElem, Z, E, R>(initial: LazyArg<Z>, f: (acc: Z, o: OutElem) => Effect.Effect<Z, E, R>): <OutErr, OutDone, Env>(
|
|
@@ -11190,7 +11278,7 @@ export const runFoldEffect: {
|
|
|
11190
11278
|
* the effectful accumulator function. The returned effect succeeds with the
|
|
11191
11279
|
* final accumulator value.
|
|
11192
11280
|
*
|
|
11193
|
-
* @category
|
|
11281
|
+
* @category running
|
|
11194
11282
|
* @since 4.0.0
|
|
11195
11283
|
*/
|
|
11196
11284
|
<OutElem, OutErr, OutDone, Env, Z, E, R>(
|
|
@@ -11233,7 +11321,7 @@ export const runFoldEffect: {
|
|
|
11233
11321
|
*
|
|
11234
11322
|
* **Example** (Converting channels to pulls)
|
|
11235
11323
|
*
|
|
11236
|
-
* ```ts
|
|
11324
|
+
* ```ts import.meta.vitest
|
|
11237
11325
|
* import { Channel, Data, Effect } from "effect"
|
|
11238
11326
|
*
|
|
11239
11327
|
* class PullError extends Data.TaggedError("PullError")<{
|
|
@@ -11243,12 +11331,11 @@ export const runFoldEffect: {
|
|
|
11243
11331
|
* // Create a channel
|
|
11244
11332
|
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
11245
11333
|
*
|
|
11246
|
-
*
|
|
11247
|
-
*
|
|
11248
|
-
*
|
|
11249
|
-
* )
|
|
11250
|
-
*
|
|
11251
|
-
* // Use the Pull to manually consume elements
|
|
11334
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
11335
|
+
* const pull = yield* Channel.toPull(numbersChannel)
|
|
11336
|
+
* return [yield* pull, yield* pull, yield* pull]
|
|
11337
|
+
* }))
|
|
11338
|
+
* await Effect.runPromise(program) // => [1, 2, 3]
|
|
11252
11339
|
* ```
|
|
11253
11340
|
*
|
|
11254
11341
|
* @category destructors
|
|
@@ -11282,7 +11369,7 @@ export const toPull: <OutElem, OutErr, OutDone, Env>(
|
|
|
11282
11369
|
*
|
|
11283
11370
|
* **Example** (Converting channels to scoped pulls)
|
|
11284
11371
|
*
|
|
11285
|
-
* ```ts
|
|
11372
|
+
* ```ts import.meta.vitest
|
|
11286
11373
|
* import { Channel, Data, Effect, Scope } from "effect"
|
|
11287
11374
|
*
|
|
11288
11375
|
* class ScopedPullError extends Data.TaggedError("ScopedPullError")<{
|
|
@@ -11294,10 +11381,11 @@ export const toPull: <OutElem, OutErr, OutDone, Env>(
|
|
|
11294
11381
|
*
|
|
11295
11382
|
* // Convert to Pull with explicit scope
|
|
11296
11383
|
* const scopedPullEffect = Effect.gen(function*() {
|
|
11297
|
-
* const scope = yield*
|
|
11384
|
+
* const scope = yield* Effect.scope
|
|
11298
11385
|
* const pull = yield* Channel.toPullScoped(numbersChannel, scope)
|
|
11299
|
-
* return pull
|
|
11386
|
+
* return [yield* pull, yield* pull, yield* pull]
|
|
11300
11387
|
* })
|
|
11388
|
+
* await Effect.runPromise(Effect.scoped(scopedPullEffect)) // => [1, 2, 3]
|
|
11301
11389
|
* ```
|
|
11302
11390
|
*
|
|
11303
11391
|
* @category destructors
|
|
@@ -11455,8 +11543,8 @@ export const runIntoQueueArray: {
|
|
|
11455
11543
|
*
|
|
11456
11544
|
* **Example** (Converting channels to queues)
|
|
11457
11545
|
*
|
|
11458
|
-
* ```ts
|
|
11459
|
-
* import { Channel, Data } from "effect"
|
|
11546
|
+
* ```ts import.meta.vitest
|
|
11547
|
+
* import { Channel, Data, Effect, Queue } from "effect"
|
|
11460
11548
|
*
|
|
11461
11549
|
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
11462
11550
|
* readonly operation: string
|
|
@@ -11466,10 +11554,11 @@ export const runIntoQueueArray: {
|
|
|
11466
11554
|
* const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
11467
11555
|
*
|
|
11468
11556
|
* // Convert to queue for concurrent processing
|
|
11469
|
-
* const
|
|
11470
|
-
*
|
|
11471
|
-
*
|
|
11472
|
-
*
|
|
11557
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
11558
|
+
* const queue = yield* Channel.toQueue(dataChannel, { capacity: 32 })
|
|
11559
|
+
* return yield* Queue.takeBetween(queue, 5, 5)
|
|
11560
|
+
* }))
|
|
11561
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
11473
11562
|
* ```
|
|
11474
11563
|
*
|
|
11475
11564
|
* @category destructors
|
|
@@ -11488,8 +11577,8 @@ export const toQueue: {
|
|
|
11488
11577
|
*
|
|
11489
11578
|
* **Example** (Converting channels to queues)
|
|
11490
11579
|
*
|
|
11491
|
-
* ```ts
|
|
11492
|
-
* import { Channel, Data } from "effect"
|
|
11580
|
+
* ```ts import.meta.vitest
|
|
11581
|
+
* import { Channel, Data, Effect, Queue } from "effect"
|
|
11493
11582
|
*
|
|
11494
11583
|
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
11495
11584
|
* readonly operation: string
|
|
@@ -11499,10 +11588,11 @@ export const toQueue: {
|
|
|
11499
11588
|
* const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
11500
11589
|
*
|
|
11501
11590
|
* // Convert to queue for concurrent processing
|
|
11502
|
-
* const
|
|
11503
|
-
*
|
|
11504
|
-
*
|
|
11505
|
-
*
|
|
11591
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
11592
|
+
* const queue = yield* Channel.toQueue(dataChannel, { capacity: 32 })
|
|
11593
|
+
* return yield* Queue.takeBetween(queue, 5, 5)
|
|
11594
|
+
* }))
|
|
11595
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
11506
11596
|
* ```
|
|
11507
11597
|
*
|
|
11508
11598
|
* @category destructors
|
|
@@ -11530,8 +11620,8 @@ export const toQueue: {
|
|
|
11530
11620
|
*
|
|
11531
11621
|
* **Example** (Converting channels to queues)
|
|
11532
11622
|
*
|
|
11533
|
-
* ```ts
|
|
11534
|
-
* import { Channel, Data } from "effect"
|
|
11623
|
+
* ```ts import.meta.vitest
|
|
11624
|
+
* import { Channel, Data, Effect, Queue } from "effect"
|
|
11535
11625
|
*
|
|
11536
11626
|
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
11537
11627
|
* readonly operation: string
|
|
@@ -11541,10 +11631,11 @@ export const toQueue: {
|
|
|
11541
11631
|
* const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
11542
11632
|
*
|
|
11543
11633
|
* // Convert to queue for concurrent processing
|
|
11544
|
-
* const
|
|
11545
|
-
*
|
|
11546
|
-
*
|
|
11547
|
-
*
|
|
11634
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
11635
|
+
* const queue = yield* Channel.toQueue(dataChannel, { capacity: 32 })
|
|
11636
|
+
* return yield* Queue.takeBetween(queue, 5, 5)
|
|
11637
|
+
* }))
|
|
11638
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
11548
11639
|
* ```
|
|
11549
11640
|
*
|
|
11550
11641
|
* @category destructors
|
|
@@ -11583,8 +11674,8 @@ export const toQueue: {
|
|
|
11583
11674
|
*
|
|
11584
11675
|
* **Example** (Converting channels to queues)
|
|
11585
11676
|
*
|
|
11586
|
-
* ```ts
|
|
11587
|
-
* import { Channel, Data } from "effect"
|
|
11677
|
+
* ```ts import.meta.vitest
|
|
11678
|
+
* import { Channel, Data, Effect, Queue } from "effect"
|
|
11588
11679
|
*
|
|
11589
11680
|
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
11590
11681
|
* readonly operation: string
|
|
@@ -11594,10 +11685,11 @@ export const toQueue: {
|
|
|
11594
11685
|
* const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
11595
11686
|
*
|
|
11596
11687
|
* // Convert to queue for concurrent processing
|
|
11597
|
-
* const
|
|
11598
|
-
*
|
|
11599
|
-
*
|
|
11600
|
-
*
|
|
11688
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
11689
|
+
* const queue = yield* Channel.toQueue(dataChannel, { capacity: 32 })
|
|
11690
|
+
* return yield* Queue.takeBetween(queue, 5, 5)
|
|
11691
|
+
* }))
|
|
11692
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
11601
11693
|
* ```
|
|
11602
11694
|
*
|
|
11603
11695
|
* @category destructors
|
|
@@ -11615,8 +11707,8 @@ export const toQueue: {
|
|
|
11615
11707
|
*
|
|
11616
11708
|
* **Example** (Converting channels to queues)
|
|
11617
11709
|
*
|
|
11618
|
-
* ```ts
|
|
11619
|
-
* import { Channel, Data } from "effect"
|
|
11710
|
+
* ```ts import.meta.vitest
|
|
11711
|
+
* import { Channel, Data, Effect, Queue } from "effect"
|
|
11620
11712
|
*
|
|
11621
11713
|
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
11622
11714
|
* readonly operation: string
|
|
@@ -11626,10 +11718,11 @@ export const toQueue: {
|
|
|
11626
11718
|
* const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
11627
11719
|
*
|
|
11628
11720
|
* // Convert to queue for concurrent processing
|
|
11629
|
-
* const
|
|
11630
|
-
*
|
|
11631
|
-
*
|
|
11632
|
-
*
|
|
11721
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
11722
|
+
* const queue = yield* Channel.toQueue(dataChannel, { capacity: 32 })
|
|
11723
|
+
* return yield* Queue.takeBetween(queue, 5, 5)
|
|
11724
|
+
* }))
|
|
11725
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
11633
11726
|
* ```
|
|
11634
11727
|
*
|
|
11635
11728
|
* @category destructors
|