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/dist/Channel.js
CHANGED
|
@@ -23,6 +23,7 @@ import { addSpanStackTrace } from "./internal/tracer.js";
|
|
|
23
23
|
import * as Iterable from "./Iterable.js";
|
|
24
24
|
import * as Latch from "./Latch.js";
|
|
25
25
|
import * as Layer from "./Layer.js";
|
|
26
|
+
import * as MutableRef from "./MutableRef.js";
|
|
26
27
|
import * as Option from "./Option.js";
|
|
27
28
|
import { pipeArguments } from "./Pipeable.js";
|
|
28
29
|
import { hasProperty, isTagged } from "./Predicate.js";
|
|
@@ -50,12 +51,12 @@ export const TypeId = "~effect/Channel";
|
|
|
50
51
|
*
|
|
51
52
|
* **Example** (Checking for channels)
|
|
52
53
|
*
|
|
53
|
-
* ```ts
|
|
54
|
+
* ```ts import.meta.vitest
|
|
54
55
|
* import { Channel } from "effect"
|
|
55
56
|
*
|
|
56
57
|
* const channel = Channel.succeed(42)
|
|
57
|
-
*
|
|
58
|
-
*
|
|
58
|
+
* Channel.isChannel(channel) // => true
|
|
59
|
+
* Channel.isChannel("not a channel") // => false
|
|
59
60
|
* ```
|
|
60
61
|
*
|
|
61
62
|
* @category guards
|
|
@@ -82,12 +83,13 @@ const ChannelProto = {
|
|
|
82
83
|
*
|
|
83
84
|
* **Example** (Creating channels from transforms)
|
|
84
85
|
*
|
|
85
|
-
* ```ts
|
|
86
|
+
* ```ts import.meta.vitest
|
|
86
87
|
* import { Channel, Effect } from "effect"
|
|
87
88
|
*
|
|
88
89
|
* const channel = Channel.fromTransform((upstream, scope) =>
|
|
89
90
|
* Effect.succeed(upstream)
|
|
90
91
|
* )
|
|
92
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => []
|
|
91
93
|
* ```
|
|
92
94
|
*
|
|
93
95
|
* @category constructors
|
|
@@ -103,7 +105,7 @@ export const fromTransform = transform => {
|
|
|
103
105
|
*
|
|
104
106
|
* **Example** (Transforming pull behavior)
|
|
105
107
|
*
|
|
106
|
-
* ```ts
|
|
108
|
+
* ```ts import.meta.vitest
|
|
107
109
|
* import { Channel, Effect } from "effect"
|
|
108
110
|
*
|
|
109
111
|
* // Transform a channel by modifying its pull behavior
|
|
@@ -116,7 +118,7 @@ export const fromTransform = transform => {
|
|
|
116
118
|
* Effect.map(pull, (value) => value * 2)
|
|
117
119
|
* )
|
|
118
120
|
* )
|
|
119
|
-
* //
|
|
121
|
+
* await Effect.runPromise(Channel.runCollect(transformedChannel)) // => [2, 4, 6]
|
|
120
122
|
* ```
|
|
121
123
|
*
|
|
122
124
|
* @category constructors
|
|
@@ -128,12 +130,18 @@ export const transformPull = (self, f) => fromTransform((upstream, scope) => Eff
|
|
|
128
130
|
*
|
|
129
131
|
* **Example** (Creating channels from pulls)
|
|
130
132
|
*
|
|
131
|
-
* ```ts
|
|
132
|
-
* import { Channel, Effect } from "effect"
|
|
133
|
+
* ```ts import.meta.vitest
|
|
134
|
+
* import { Cause, Channel, Effect } from "effect"
|
|
133
135
|
*
|
|
134
|
-
* const channel = Channel.fromPull(
|
|
135
|
-
*
|
|
136
|
-
* )
|
|
136
|
+
* const channel = Channel.fromPull(Effect.sync(() => {
|
|
137
|
+
* let emitted = false
|
|
138
|
+
* return Effect.suspend(() => {
|
|
139
|
+
* if (emitted) return Cause.done()
|
|
140
|
+
* emitted = true
|
|
141
|
+
* return Effect.succeed(42)
|
|
142
|
+
* })
|
|
143
|
+
* }))
|
|
144
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [42]
|
|
137
145
|
* ```
|
|
138
146
|
*
|
|
139
147
|
* @category constructors
|
|
@@ -166,12 +174,13 @@ export const fromTransformBracket = f => fromTransform(Effect.fnUntraced(functio
|
|
|
166
174
|
*
|
|
167
175
|
* **Example** (Extracting channel transforms)
|
|
168
176
|
*
|
|
169
|
-
* ```ts
|
|
170
|
-
* import { Channel } from "effect"
|
|
177
|
+
* ```ts import.meta.vitest
|
|
178
|
+
* import { Channel, Effect } from "effect"
|
|
171
179
|
*
|
|
172
180
|
* const channel = Channel.succeed(42)
|
|
173
181
|
* const transform = Channel.toTransform(channel)
|
|
174
|
-
*
|
|
182
|
+
* typeof transform // => "function"
|
|
183
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [42]
|
|
175
184
|
* ```
|
|
176
185
|
*
|
|
177
186
|
* @category destructors
|
|
@@ -183,10 +192,10 @@ export const toTransform = channel => channel.transform;
|
|
|
183
192
|
*
|
|
184
193
|
* **Example** (Reading the default chunk size)
|
|
185
194
|
*
|
|
186
|
-
* ```ts
|
|
195
|
+
* ```ts import.meta.vitest
|
|
187
196
|
* import { Channel } from "effect"
|
|
188
197
|
*
|
|
189
|
-
*
|
|
198
|
+
* Channel.DefaultChunkSize // => 4096
|
|
190
199
|
* ```
|
|
191
200
|
*
|
|
192
201
|
* @category constants
|
|
@@ -202,7 +211,7 @@ const asyncQueue = (scope, f, options) => Queue.make({
|
|
|
202
211
|
*
|
|
203
212
|
* **Example** (Creating channels from callbacks)
|
|
204
213
|
*
|
|
205
|
-
* ```ts
|
|
214
|
+
* ```ts import.meta.vitest
|
|
206
215
|
* import { Channel, Effect, Queue } from "effect"
|
|
207
216
|
*
|
|
208
217
|
* const channel = Channel.callback<number>((queue) =>
|
|
@@ -210,8 +219,10 @@ const asyncQueue = (scope, f, options) => Queue.make({
|
|
|
210
219
|
* yield* Queue.offer(queue, 1)
|
|
211
220
|
* yield* Queue.offer(queue, 2)
|
|
212
221
|
* yield* Queue.offer(queue, 3)
|
|
222
|
+
* yield* Queue.end(queue)
|
|
213
223
|
* })
|
|
214
224
|
* )
|
|
225
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [1, 2, 3]
|
|
215
226
|
* ```
|
|
216
227
|
*
|
|
217
228
|
* @category constructors
|
|
@@ -223,14 +234,15 @@ export const callback = (f, options) => fromTransform((_, scope) => Effect.map(a
|
|
|
223
234
|
*
|
|
224
235
|
* **Example** (Creating array channels from callbacks)
|
|
225
236
|
*
|
|
226
|
-
* ```ts
|
|
237
|
+
* ```ts import.meta.vitest
|
|
227
238
|
* import { Channel, Effect, Queue } from "effect"
|
|
228
239
|
*
|
|
229
240
|
* const channel = Channel.callbackArray<number>(Effect.fn(function*(queue) {
|
|
230
241
|
* yield* Queue.offer(queue, 1)
|
|
231
242
|
* yield* Queue.offer(queue, 2)
|
|
243
|
+
* yield* Queue.end(queue)
|
|
232
244
|
* }))
|
|
233
|
-
*
|
|
245
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [[1, 2]]
|
|
234
246
|
* ```
|
|
235
247
|
*
|
|
236
248
|
* @category constructors
|
|
@@ -242,11 +254,11 @@ export const callbackArray = (f, options) => fromTransform((_, scope) => Effect.
|
|
|
242
254
|
*
|
|
243
255
|
* **Example** (Suspending channel creation)
|
|
244
256
|
*
|
|
245
|
-
* ```ts
|
|
246
|
-
* import { Channel } from "effect"
|
|
257
|
+
* ```ts import.meta.vitest
|
|
258
|
+
* import { Channel, Effect } from "effect"
|
|
247
259
|
*
|
|
248
260
|
* const channel = Channel.suspend(() => Channel.succeed(42))
|
|
249
|
-
*
|
|
261
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [42]
|
|
250
262
|
* ```
|
|
251
263
|
*
|
|
252
264
|
* @category constructors
|
|
@@ -265,14 +277,16 @@ export const suspend = evaluate => fromTransform((upstream, scope) => Effect.sus
|
|
|
265
277
|
*
|
|
266
278
|
* **Example** (Managing resources with acquire-use-release)
|
|
267
279
|
*
|
|
268
|
-
* ```ts
|
|
280
|
+
* ```ts import.meta.vitest
|
|
269
281
|
* import { Channel, Effect } from "effect"
|
|
270
282
|
*
|
|
283
|
+
* const released: Array<string> = []
|
|
271
284
|
* const channel = Channel.acquireUseRelease(
|
|
272
285
|
* Effect.succeed("resource"),
|
|
273
286
|
* (resource) => Channel.succeed(resource.toUpperCase()),
|
|
274
|
-
* (resource, exit) => Effect.
|
|
287
|
+
* (resource, exit) => Effect.sync(() => released.push(resource))
|
|
275
288
|
* )
|
|
289
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["RESOURCE"], ["resource"]]
|
|
276
290
|
* ```
|
|
277
291
|
*
|
|
278
292
|
* @category constructors
|
|
@@ -297,13 +311,15 @@ export const acquireUseRelease = (acquire, use, release) => fromTransformBracket
|
|
|
297
311
|
*
|
|
298
312
|
* **Example** (Managing resources with acquire-release)
|
|
299
313
|
*
|
|
300
|
-
* ```ts
|
|
314
|
+
* ```ts import.meta.vitest
|
|
301
315
|
* import { Channel, Effect } from "effect"
|
|
302
316
|
*
|
|
317
|
+
* const released: Array<string> = []
|
|
303
318
|
* const channel = Channel.acquireRelease(
|
|
304
319
|
* Effect.succeed("resource"),
|
|
305
|
-
* (resource, exit) => Effect.
|
|
320
|
+
* (resource, exit) => Effect.sync(() => released.push(resource))
|
|
306
321
|
* )
|
|
322
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channel)), released] // => [["resource"], ["resource"]]
|
|
307
323
|
* ```
|
|
308
324
|
*
|
|
309
325
|
* @category constructors
|
|
@@ -315,12 +331,12 @@ export const acquireRelease = /*#__PURE__*/dual(2, (self, release) => unwrap(Eff
|
|
|
315
331
|
*
|
|
316
332
|
* **Example** (Creating channels from iterators)
|
|
317
333
|
*
|
|
318
|
-
* ```ts
|
|
319
|
-
* import { Channel } from "effect"
|
|
334
|
+
* ```ts import.meta.vitest
|
|
335
|
+
* import { Channel, Effect } from "effect"
|
|
320
336
|
*
|
|
321
337
|
* const numbers = [1, 2, 3, 4, 5]
|
|
322
338
|
* const channel = Channel.fromIterator(() => numbers[Symbol.iterator]())
|
|
323
|
-
* //
|
|
339
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3, 4, 5]
|
|
324
340
|
* ```
|
|
325
341
|
*
|
|
326
342
|
* @category constructors
|
|
@@ -338,11 +354,11 @@ export const fromIterator = iterator => fromPull(Effect.sync(() => {
|
|
|
338
354
|
*
|
|
339
355
|
* **Example** (Creating channels from arrays)
|
|
340
356
|
*
|
|
341
|
-
* ```ts
|
|
342
|
-
* import { Channel } from "effect"
|
|
357
|
+
* ```ts import.meta.vitest
|
|
358
|
+
* import { Channel, Effect } from "effect"
|
|
343
359
|
*
|
|
344
360
|
* const channel = Channel.fromArray([1, 2, 3, 4, 5])
|
|
345
|
-
* //
|
|
361
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3, 4, 5]
|
|
346
362
|
* ```
|
|
347
363
|
*
|
|
348
364
|
* @category constructors
|
|
@@ -357,12 +373,12 @@ export const fromArray = array => fromPull(Effect.sync(() => {
|
|
|
357
373
|
*
|
|
358
374
|
* **Example** (Creating channels from chunks)
|
|
359
375
|
*
|
|
360
|
-
* ```ts
|
|
361
|
-
* import { Channel, Chunk } from "effect"
|
|
376
|
+
* ```ts import.meta.vitest
|
|
377
|
+
* import { Channel, Chunk, Effect } from "effect"
|
|
362
378
|
*
|
|
363
379
|
* const chunk = Chunk.make(1, 2, 3)
|
|
364
380
|
* const channel = Channel.fromChunk(chunk)
|
|
365
|
-
* //
|
|
381
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3]
|
|
366
382
|
* ```
|
|
367
383
|
*
|
|
368
384
|
* @category constructors
|
|
@@ -374,8 +390,8 @@ export const fromChunk = chunk => fromArray(Chunk.toReadonlyArray(chunk));
|
|
|
374
390
|
*
|
|
375
391
|
* **Example** (Batching iterator output)
|
|
376
392
|
*
|
|
377
|
-
* ```ts
|
|
378
|
-
* import { Channel } from "effect"
|
|
393
|
+
* ```ts import.meta.vitest
|
|
394
|
+
* import { Channel, Effect } from "effect"
|
|
379
395
|
*
|
|
380
396
|
* // Create a channel from a simple iterator
|
|
381
397
|
* const numberIterator = (): Iterator<number, string> => {
|
|
@@ -391,13 +407,13 @@ export const fromChunk = chunk => fromArray(Chunk.toReadonlyArray(chunk));
|
|
|
391
407
|
* }
|
|
392
408
|
*
|
|
393
409
|
* const channel = Channel.fromIteratorArray(() => numberIterator(), 2)
|
|
394
|
-
* //
|
|
410
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [[0, 1], [2]]
|
|
395
411
|
* ```
|
|
396
412
|
*
|
|
397
413
|
* **Example** (Batching generator output)
|
|
398
414
|
*
|
|
399
|
-
* ```ts
|
|
400
|
-
* import { Channel } from "effect"
|
|
415
|
+
* ```ts import.meta.vitest
|
|
416
|
+
* import { Channel, Effect } from "effect"
|
|
401
417
|
*
|
|
402
418
|
* // Create channel from a generator function
|
|
403
419
|
* function* fibonacci(): Generator<number, void, unknown> {
|
|
@@ -409,7 +425,7 @@ export const fromChunk = chunk => fromArray(Chunk.toReadonlyArray(chunk));
|
|
|
409
425
|
* }
|
|
410
426
|
*
|
|
411
427
|
* const fibChannel = Channel.fromIteratorArray(() => fibonacci(), 3)
|
|
412
|
-
* //
|
|
428
|
+
* Effect.runSync(Channel.runCollect(fibChannel)) // => [[0, 1, 1], [2, 3]]
|
|
413
429
|
* ```
|
|
414
430
|
*
|
|
415
431
|
* @category constructors
|
|
@@ -440,12 +456,12 @@ export const fromIteratorArray = (iterator, chunkSize = DefaultChunkSize) => fro
|
|
|
440
456
|
*
|
|
441
457
|
* **Example** (Creating channels from iterables)
|
|
442
458
|
*
|
|
443
|
-
* ```ts
|
|
444
|
-
* import { Channel } from "effect"
|
|
459
|
+
* ```ts import.meta.vitest
|
|
460
|
+
* import { Channel, Effect } from "effect"
|
|
445
461
|
*
|
|
446
462
|
* const set = new Set([1, 2, 3])
|
|
447
463
|
* const channel = Channel.fromIterable(set)
|
|
448
|
-
* //
|
|
464
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [1, 2, 3]
|
|
449
465
|
* ```
|
|
450
466
|
*
|
|
451
467
|
* @category constructors
|
|
@@ -457,12 +473,12 @@ export const fromIterable = iterable => fromIterator(() => iterable[Symbol.itera
|
|
|
457
473
|
*
|
|
458
474
|
* **Example** (Batching iterable output)
|
|
459
475
|
*
|
|
460
|
-
* ```ts
|
|
461
|
-
* import { Channel } from "effect"
|
|
476
|
+
* ```ts import.meta.vitest
|
|
477
|
+
* import { Channel, Effect } from "effect"
|
|
462
478
|
*
|
|
463
479
|
* const numbers = [1, 2, 3, 4, 5]
|
|
464
|
-
* const channel = Channel.fromIterableArray(numbers)
|
|
465
|
-
* //
|
|
480
|
+
* const channel = Channel.fromIterableArray(numbers, 4)
|
|
481
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [[1, 2, 3, 4], [5]]
|
|
466
482
|
* ```
|
|
467
483
|
*
|
|
468
484
|
* @category constructors
|
|
@@ -474,11 +490,11 @@ export const fromIterableArray = (iterable, chunkSize = DefaultChunkSize) => fro
|
|
|
474
490
|
*
|
|
475
491
|
* **Example** (Creating channels that succeed)
|
|
476
492
|
*
|
|
477
|
-
* ```ts
|
|
478
|
-
* import { Channel } from "effect"
|
|
493
|
+
* ```ts import.meta.vitest
|
|
494
|
+
* import { Channel, Effect } from "effect"
|
|
479
495
|
*
|
|
480
496
|
* const channel = Channel.succeed(42)
|
|
481
|
-
* //
|
|
497
|
+
* Effect.runSync(Channel.runCollect(channel)) // => [42]
|
|
482
498
|
* ```
|
|
483
499
|
*
|
|
484
500
|
* @category constructors
|
|
@@ -490,11 +506,11 @@ export const succeed = value => fromEffect(Effect.succeed(value));
|
|
|
490
506
|
*
|
|
491
507
|
* **Example** (Ending with a value)
|
|
492
508
|
*
|
|
493
|
-
* ```ts
|
|
494
|
-
* import { Channel } from "effect"
|
|
509
|
+
* ```ts import.meta.vitest
|
|
510
|
+
* import { Channel, Effect } from "effect"
|
|
495
511
|
*
|
|
496
512
|
* const channel = Channel.end("done")
|
|
497
|
-
* //
|
|
513
|
+
* Effect.runSync(Channel.runCollect(channel)) // => []
|
|
498
514
|
* ```
|
|
499
515
|
*
|
|
500
516
|
* @category constructors
|
|
@@ -513,8 +529,8 @@ export const endSync = evaluate => fromPull(Effect.sync(() => Cause.done(evaluat
|
|
|
513
529
|
*
|
|
514
530
|
* **Example** (Computing values lazily)
|
|
515
531
|
*
|
|
516
|
-
* ```ts
|
|
517
|
-
* import { Channel } from "effect"
|
|
532
|
+
* ```ts import.meta.vitest
|
|
533
|
+
* import { Channel, Effect } from "effect"
|
|
518
534
|
*
|
|
519
535
|
* let requests = 0
|
|
520
536
|
*
|
|
@@ -522,7 +538,7 @@ export const endSync = evaluate => fromPull(Effect.sync(() => Cause.done(evaluat
|
|
|
522
538
|
* requests += 1
|
|
523
539
|
* return `request-${requests}`
|
|
524
540
|
* })
|
|
525
|
-
* //
|
|
541
|
+
* Effect.runSync(Channel.runCollect(channel)) // => ["request-1"]
|
|
526
542
|
* ```
|
|
527
543
|
*
|
|
528
544
|
* @category constructors
|
|
@@ -534,8 +550,8 @@ export const sync = evaluate => fromEffect(Effect.sync(evaluate));
|
|
|
534
550
|
*
|
|
535
551
|
* **Example** (Creating empty channels)
|
|
536
552
|
*
|
|
537
|
-
* ```ts
|
|
538
|
-
* import { Channel } from "effect"
|
|
553
|
+
* ```ts import.meta.vitest
|
|
554
|
+
* import { Channel, Effect } from "effect"
|
|
539
555
|
*
|
|
540
556
|
* // Create an empty channel
|
|
541
557
|
* const emptyChannel = Channel.empty
|
|
@@ -547,6 +563,8 @@ export const sync = evaluate => fromEffect(Effect.sync(evaluate));
|
|
|
547
563
|
* // Empty channel can be used as a no-op in conditional logic
|
|
548
564
|
* const conditionalChannel = (shouldEmit: boolean) =>
|
|
549
565
|
* shouldEmit ? Channel.succeed("data") : Channel.empty
|
|
566
|
+
*
|
|
567
|
+
* Effect.runSync(Channel.runCollect(conditionalChannel(true))) // => ["data"]
|
|
550
568
|
* ```
|
|
551
569
|
*
|
|
552
570
|
* @category constructors
|
|
@@ -558,7 +576,7 @@ export const empty = /*#__PURE__*/fromPull(/*#__PURE__*/Effect.succeed(/*#__PURE
|
|
|
558
576
|
*
|
|
559
577
|
* **Example** (Creating non-terminating channels)
|
|
560
578
|
*
|
|
561
|
-
* ```ts
|
|
579
|
+
* ```ts import.meta.vitest
|
|
562
580
|
* import { Channel } from "effect"
|
|
563
581
|
*
|
|
564
582
|
* // Create a channel that never completes
|
|
@@ -573,6 +591,8 @@ export const empty = /*#__PURE__*/fromPull(/*#__PURE__*/Effect.succeed(/*#__PURE
|
|
|
573
591
|
* // Never channel is useful for testing or as a placeholder
|
|
574
592
|
* const conditionalChannel = (shouldComplete: boolean) =>
|
|
575
593
|
* shouldComplete ? Channel.succeed("done") : Channel.never
|
|
594
|
+
*
|
|
595
|
+
* Channel.isChannel(conditionalChannel(false)) // => true
|
|
576
596
|
* ```
|
|
577
597
|
*
|
|
578
598
|
* @category constructors
|
|
@@ -584,26 +604,11 @@ export const never = /*#__PURE__*/fromPull(/*#__PURE__*/Effect.succeed(Effect.ne
|
|
|
584
604
|
*
|
|
585
605
|
* **Example** (Failing with an error)
|
|
586
606
|
*
|
|
587
|
-
* ```ts
|
|
588
|
-
* import { Channel } from "effect"
|
|
607
|
+
* ```ts import.meta.vitest
|
|
608
|
+
* import { Channel, Effect, Exit } from "effect"
|
|
589
609
|
*
|
|
590
|
-
* // Create a channel that fails with a string error
|
|
591
610
|
* const failedChannel = Channel.fail("Something went wrong")
|
|
592
|
-
*
|
|
593
|
-
* // Create a channel that fails with a custom error
|
|
594
|
-
* class CustomError extends Error {
|
|
595
|
-
* constructor(message: string) {
|
|
596
|
-
* super(message)
|
|
597
|
-
* this.name = "CustomError"
|
|
598
|
-
* }
|
|
599
|
-
* }
|
|
600
|
-
* const customErrorChannel = Channel.fail(new CustomError("Custom error"))
|
|
601
|
-
*
|
|
602
|
-
* // Use in error handling by piping to another channel
|
|
603
|
-
* const channelWithFallback = Channel.concatWith(
|
|
604
|
-
* failedChannel,
|
|
605
|
-
* () => Channel.succeed("fallback value")
|
|
606
|
-
* )
|
|
611
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(failedChannel))) // => Exit.fail("Something went wrong")
|
|
607
612
|
* ```
|
|
608
613
|
*
|
|
609
614
|
* @category constructors
|
|
@@ -621,27 +626,18 @@ export const fail = error => fromPull(Effect.succeed(Effect.fail(error)));
|
|
|
621
626
|
*
|
|
622
627
|
* **Example** (Failing with a lazy error)
|
|
623
628
|
*
|
|
624
|
-
* ```ts
|
|
625
|
-
* import { Channel } from "effect"
|
|
626
|
-
*
|
|
627
|
-
* // Create a channel that fails with a lazily computed error
|
|
628
|
-
* const failedChannel = Channel.failSync(() => {
|
|
629
|
-
* console.log("Computing error...")
|
|
630
|
-
* return new Error("Computed at runtime")
|
|
631
|
-
* })
|
|
629
|
+
* ```ts import.meta.vitest
|
|
630
|
+
* import { Channel, Effect, Exit } from "effect"
|
|
632
631
|
*
|
|
633
|
-
* // The error computation is deferred until the channel runs
|
|
634
632
|
* let attempts = 0
|
|
635
633
|
* const conditionalError = Channel.failSync(() => {
|
|
636
634
|
* attempts += 1
|
|
637
635
|
* return `Error after attempt ${attempts}`
|
|
638
636
|
* })
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
* return new Error(`Failed while processing ${requestId}`)
|
|
644
|
-
* })
|
|
637
|
+
* const observed = [
|
|
638
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(conditionalError))),
|
|
639
|
+
* attempts
|
|
640
|
+
* ] // => [Exit.fail("Error after attempt 1"), 1]
|
|
645
641
|
* ```
|
|
646
642
|
*
|
|
647
643
|
* @category constructors
|
|
@@ -658,20 +654,12 @@ export const failSync = evaluate => fromPull(Effect.failSync(evaluate));
|
|
|
658
654
|
*
|
|
659
655
|
* **Example** (Failing with causes)
|
|
660
656
|
*
|
|
661
|
-
* ```ts
|
|
662
|
-
* import { Cause, Channel } from "effect"
|
|
657
|
+
* ```ts import.meta.vitest
|
|
658
|
+
* import { Cause, Channel, Effect, Exit } from "effect"
|
|
663
659
|
*
|
|
664
|
-
* // Create a channel that fails with a simple cause
|
|
665
660
|
* const simpleCause = Cause.fail("Simple error")
|
|
666
661
|
* const failedChannel = Channel.failCause(simpleCause)
|
|
667
|
-
*
|
|
668
|
-
* // Create a channel with a die cause
|
|
669
|
-
* const dieCause = Cause.die(new Error("System error"))
|
|
670
|
-
* const dieFailure = Channel.failCause(dieCause)
|
|
671
|
-
*
|
|
672
|
-
* // Create a channel with a simple fail cause
|
|
673
|
-
* const failCause = Cause.fail("Simple error")
|
|
674
|
-
* const simpleFail = Channel.failCause(failCause)
|
|
662
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(failedChannel))) // => Exit.failCause(simpleCause)
|
|
675
663
|
* ```
|
|
676
664
|
*
|
|
677
665
|
* @category constructors
|
|
@@ -684,8 +672,8 @@ export const failCause = cause => fromPull(Effect.failCause(cause));
|
|
|
684
672
|
*
|
|
685
673
|
* **Example** (Failing with lazy causes)
|
|
686
674
|
*
|
|
687
|
-
* ```ts
|
|
688
|
-
* import { Cause, Channel } from "effect"
|
|
675
|
+
* ```ts import.meta.vitest
|
|
676
|
+
* import { Cause, Channel, Effect, Exit } from "effect"
|
|
689
677
|
*
|
|
690
678
|
* // Create a channel that fails with a lazily computed cause
|
|
691
679
|
* let attempts = 0
|
|
@@ -694,11 +682,10 @@ export const failCause = cause => fromPull(Effect.failCause(cause));
|
|
|
694
682
|
* return Cause.fail(`Runtime error after attempt ${attempts}`)
|
|
695
683
|
* })
|
|
696
684
|
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
* })
|
|
685
|
+
* const observed = [
|
|
686
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(failedChannel))),
|
|
687
|
+
* attempts
|
|
688
|
+
* ] // => [Exit.fail("Runtime error after attempt 1"), 1]
|
|
702
689
|
* ```
|
|
703
690
|
*
|
|
704
691
|
* @category constructors
|
|
@@ -710,20 +697,12 @@ export const failCauseSync = evaluate => fromPull(Effect.failCauseSync(evaluate)
|
|
|
710
697
|
*
|
|
711
698
|
* **Example** (Dying with defects)
|
|
712
699
|
*
|
|
713
|
-
* ```ts
|
|
714
|
-
* import { Channel } from "effect"
|
|
715
|
-
*
|
|
716
|
-
* // Create a channel that dies with a string defect
|
|
717
|
-
* const diedChannel = Channel.die("Unrecoverable error")
|
|
718
|
-
*
|
|
719
|
-
* // Create a channel that dies with an Error object
|
|
720
|
-
* const errorDefect = Channel.die(new Error("System failure"))
|
|
700
|
+
* ```ts import.meta.vitest
|
|
701
|
+
* import { Cause, Channel, Effect, Exit } from "effect"
|
|
721
702
|
*
|
|
722
|
-
*
|
|
723
|
-
* const
|
|
724
|
-
*
|
|
725
|
-
* details: "Critical system component failed"
|
|
726
|
-
* })
|
|
703
|
+
* const defect = "Unrecoverable error"
|
|
704
|
+
* const diedChannel = Channel.die(defect)
|
|
705
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(diedChannel))) // => Exit.failCause(Cause.die(defect))
|
|
727
706
|
* ```
|
|
728
707
|
*
|
|
729
708
|
* @category constructors
|
|
@@ -735,33 +714,13 @@ export const die = defect => failCause(Cause.die(defect));
|
|
|
735
714
|
*
|
|
736
715
|
* **Example** (Creating channels from effects)
|
|
737
716
|
*
|
|
738
|
-
* ```ts
|
|
739
|
-
* import { Channel,
|
|
740
|
-
*
|
|
741
|
-
* class DatabaseError extends Data.TaggedError("DatabaseError")<{
|
|
742
|
-
* readonly message: string
|
|
743
|
-
* }> {}
|
|
717
|
+
* ```ts import.meta.vitest
|
|
718
|
+
* import { Channel, Effect } from "effect"
|
|
744
719
|
*
|
|
745
|
-
* // Create a channel from a successful effect
|
|
746
720
|
* const successChannel = Channel.fromEffect(
|
|
747
721
|
* Effect.succeed("Hello from effect!")
|
|
748
722
|
* )
|
|
749
|
-
*
|
|
750
|
-
* // Create a channel from an effect that might fail
|
|
751
|
-
* const fetchUserChannel = Channel.fromEffect(
|
|
752
|
-
* Effect.tryPromise({
|
|
753
|
-
* try: () => fetch("/api/user").then((res) => res.json()),
|
|
754
|
-
* catch: (error) => new DatabaseError({ message: String(error) })
|
|
755
|
-
* })
|
|
756
|
-
* )
|
|
757
|
-
*
|
|
758
|
-
* // Channel from effect with async computation
|
|
759
|
-
* const asyncChannel = Channel.fromEffect(
|
|
760
|
-
* Effect.gen(function*() {
|
|
761
|
-
* yield* Effect.sleep("100 millis")
|
|
762
|
-
* return "Async result"
|
|
763
|
-
* })
|
|
764
|
-
* )
|
|
723
|
+
* Effect.runSync(Channel.runCollect(successChannel)) // => ["Hello from effect!"]
|
|
765
724
|
* ```
|
|
766
725
|
*
|
|
767
726
|
* @category constructors
|
|
@@ -812,35 +771,17 @@ export const fromEffectTake = effect => fromPull(Effect.succeed(Effect.flatMap(e
|
|
|
812
771
|
*
|
|
813
772
|
* **Example** (Creating channels from queues)
|
|
814
773
|
*
|
|
815
|
-
* ```ts
|
|
816
|
-
* import {
|
|
817
|
-
*
|
|
818
|
-
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
819
|
-
* readonly reason: string
|
|
820
|
-
* }> {}
|
|
774
|
+
* ```ts import.meta.vitest
|
|
775
|
+
* import { Cause, Channel, Effect, Queue } from "effect"
|
|
821
776
|
*
|
|
822
777
|
* const program = Effect.gen(function*() {
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
* // Add some items to the queue
|
|
827
|
-
* yield* Queue.offer(queue, "item1")
|
|
828
|
-
* yield* Queue.offer(queue, "item2")
|
|
829
|
-
* yield* Queue.offer(queue, "item3")
|
|
830
|
-
*
|
|
831
|
-
* // Create a channel from the queue
|
|
778
|
+
* const queue = yield* Queue.bounded<string, Cause.Done>(3)
|
|
779
|
+
* yield* Queue.offerAll(queue, ["item1", "item2", "item3"])
|
|
780
|
+
* yield* Queue.end(queue)
|
|
832
781
|
* const channel = Channel.fromQueue(queue)
|
|
833
|
-
*
|
|
834
|
-
* // The channel will read items from the queue one by one
|
|
835
|
-
* return channel
|
|
836
|
-
* })
|
|
837
|
-
*
|
|
838
|
-
* // Sliding queue example
|
|
839
|
-
* const slidingProgram = Effect.gen(function*() {
|
|
840
|
-
* const slidingQueue = yield* Queue.sliding<number, QueueError>(5)
|
|
841
|
-
* yield* Queue.offerAll(slidingQueue, [1, 2, 3, 4, 5, 6])
|
|
842
|
-
* return Channel.fromQueue(slidingQueue)
|
|
782
|
+
* return yield* Channel.runCollect(channel)
|
|
843
783
|
* })
|
|
784
|
+
* await Effect.runPromise(program) // => ["item1", "item2", "item3"]
|
|
844
785
|
* ```
|
|
845
786
|
*
|
|
846
787
|
* @category constructors
|
|
@@ -852,39 +793,17 @@ export const fromQueue = queue => fromPull(Effect.succeed(Queue.take(queue)));
|
|
|
852
793
|
*
|
|
853
794
|
* **Example** (Creating batched channels from queues)
|
|
854
795
|
*
|
|
855
|
-
* ```ts
|
|
856
|
-
* import {
|
|
857
|
-
*
|
|
858
|
-
* class ProcessingError extends Data.TaggedError("ProcessingError")<{
|
|
859
|
-
* readonly stage: string
|
|
860
|
-
* }> {}
|
|
796
|
+
* ```ts import.meta.vitest
|
|
797
|
+
* import { Cause, Channel, Effect, Queue } from "effect"
|
|
861
798
|
*
|
|
862
799
|
* const program = Effect.gen(function*() {
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
*
|
|
866
|
-
* // Fill queue with data
|
|
867
|
-
* yield* Queue.offerAll(queue, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
|
868
|
-
*
|
|
869
|
-
* // Create a channel that reads arrays from the queue
|
|
800
|
+
* const queue = yield* Queue.bounded<number, Cause.Done>(4)
|
|
801
|
+
* yield* Queue.offerAll(queue, [1, 2, 3, 4])
|
|
802
|
+
* yield* Queue.end(queue)
|
|
870
803
|
* const arrayChannel = Channel.fromQueueArray(queue)
|
|
871
|
-
*
|
|
872
|
-
* // This will emit non-empty arrays of elements instead of individual items
|
|
873
|
-
* // Useful for batch processing scenarios
|
|
874
|
-
* return arrayChannel
|
|
875
|
-
* })
|
|
876
|
-
*
|
|
877
|
-
* // High-throughput processing example
|
|
878
|
-
* const batchProcessor = Effect.gen(function*() {
|
|
879
|
-
* const dataQueue = yield* Queue.dropping<string, ProcessingError>(1000)
|
|
880
|
-
* const batchChannel = Channel.fromQueueArray(dataQueue)
|
|
881
|
-
*
|
|
882
|
-
* // Process data in batches for better performance
|
|
883
|
-
* return Channel.map(
|
|
884
|
-
* batchChannel,
|
|
885
|
-
* (batch) => batch.map((item) => item.toUpperCase())
|
|
886
|
-
* )
|
|
804
|
+
* return yield* Channel.runCollect(arrayChannel)
|
|
887
805
|
* })
|
|
806
|
+
* await Effect.runPromise(program) // => [[1, 2, 3, 4]]
|
|
888
807
|
* ```
|
|
889
808
|
*
|
|
890
809
|
* @category constructors
|
|
@@ -904,8 +823,8 @@ export const identity = () => fromTransform((upstream, _scope) => Effect.succeed
|
|
|
904
823
|
*
|
|
905
824
|
* **Example** (Creating channels from subscriptions)
|
|
906
825
|
*
|
|
907
|
-
* ```ts
|
|
908
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
826
|
+
* ```ts import.meta.vitest
|
|
827
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
909
828
|
*
|
|
910
829
|
* class SubscriptionError extends Data.TaggedError("SubscriptionError")<{
|
|
911
830
|
* readonly reason: string
|
|
@@ -930,6 +849,8 @@ export const identity = () => fromTransform((upstream, _scope) => Effect.succeed
|
|
|
930
849
|
* // The channel will receive all published messages
|
|
931
850
|
* return channel
|
|
932
851
|
* })
|
|
852
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
853
|
+
* await Effect.runPromise(result) // => Option.some("Hello")
|
|
933
854
|
*
|
|
934
855
|
* // Real-time notifications example
|
|
935
856
|
* const notificationChannel = Effect.gen(function*() {
|
|
@@ -955,8 +876,8 @@ export const fromSubscription = subscription => fromPull(Effect.succeed(Effect.o
|
|
|
955
876
|
*
|
|
956
877
|
* **Example** (Batching subscription values)
|
|
957
878
|
*
|
|
958
|
-
* ```ts
|
|
959
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
879
|
+
* ```ts import.meta.vitest
|
|
880
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
960
881
|
*
|
|
961
882
|
* class StreamError extends Data.TaggedError("StreamError")<{
|
|
962
883
|
* readonly message: string
|
|
@@ -978,12 +899,14 @@ export const fromSubscription = subscription => fromPull(Effect.succeed(Effect.o
|
|
|
978
899
|
* // The channel will output arrays like [1, 2, 3] and [4]
|
|
979
900
|
* return channel
|
|
980
901
|
* })
|
|
902
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
903
|
+
* await Effect.runPromise(result) // => Option.some([1, 2, 3, 4])
|
|
981
904
|
* ```
|
|
982
905
|
*
|
|
983
906
|
* **Example** (Processing subscription values in batches)
|
|
984
907
|
*
|
|
985
|
-
* ```ts
|
|
986
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
908
|
+
* ```ts import.meta.vitest
|
|
909
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
987
910
|
*
|
|
988
911
|
* class BatchProcessingError extends Data.TaggedError("BatchProcessingError")<{
|
|
989
912
|
* readonly reason: string
|
|
@@ -997,19 +920,21 @@ export const fromSubscription = subscription => fromPull(Effect.succeed(Effect.o
|
|
|
997
920
|
* const batchChannel = Channel.fromSubscriptionArray(subscription)
|
|
998
921
|
*
|
|
999
922
|
* // Transform to process each batch
|
|
1000
|
-
* const processedChannel = Channel.map(batchChannel, (batch) =>
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
* })
|
|
923
|
+
* const processedChannel = Channel.map(batchChannel, (batch) =>
|
|
924
|
+
* batch.map((item) => item.toUpperCase())
|
|
925
|
+
* )
|
|
1004
926
|
*
|
|
927
|
+
* yield* PubSub.publishAll(pubsub, ["one", "two"])
|
|
1005
928
|
* return processedChannel
|
|
1006
929
|
* })
|
|
930
|
+
* const batch = Effect.scoped(Effect.flatMap(batchProcessor, Channel.runHead))
|
|
931
|
+
* await Effect.runPromise(batch) // => Option.some(["ONE", "TWO"])
|
|
1007
932
|
* ```
|
|
1008
933
|
*
|
|
1009
934
|
* **Example** (Aggregating subscription metrics)
|
|
1010
935
|
*
|
|
1011
|
-
* ```ts
|
|
1012
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
936
|
+
* ```ts import.meta.vitest
|
|
937
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1013
938
|
*
|
|
1014
939
|
* const metricsAggregator = Effect.gen(function*() {
|
|
1015
940
|
* const metricsPubSub = yield* PubSub.bounded<
|
|
@@ -1039,8 +964,12 @@ export const fromSubscription = subscription => fromPull(Effect.succeed(Effect.o
|
|
|
1039
964
|
* }
|
|
1040
965
|
* })
|
|
1041
966
|
*
|
|
967
|
+
* yield* PubSub.publish(metricsPubSub, { timestamp: 1, value: 10 })
|
|
1042
968
|
* return aggregatedChannel
|
|
1043
969
|
* })
|
|
970
|
+
* const metric = Effect.scoped(Effect.flatMap(metricsAggregator, Channel.runHead))
|
|
971
|
+
* const result = await Effect.runPromise(metric)
|
|
972
|
+
* 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 })
|
|
1044
973
|
* ```
|
|
1045
974
|
*
|
|
1046
975
|
* @category constructors
|
|
@@ -1058,15 +987,15 @@ export const fromSubscriptionArray = subscription => fromPull(Effect.succeed(Eff
|
|
|
1058
987
|
*
|
|
1059
988
|
* **Example** (Creating channels from PubSubs)
|
|
1060
989
|
*
|
|
1061
|
-
* ```ts
|
|
1062
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
990
|
+
* ```ts import.meta.vitest
|
|
991
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1063
992
|
*
|
|
1064
993
|
* class StreamError extends Data.TaggedError("StreamError")<{
|
|
1065
994
|
* readonly message: string
|
|
1066
995
|
* }> {}
|
|
1067
996
|
*
|
|
1068
997
|
* const program = Effect.gen(function*() {
|
|
1069
|
-
* const pubsub = yield* PubSub.
|
|
998
|
+
* const pubsub = yield* PubSub.unbounded<number>({ replay: 3 })
|
|
1070
999
|
*
|
|
1071
1000
|
* // Create a channel that reads individual values
|
|
1072
1001
|
* const channel = Channel.fromPubSub(pubsub)
|
|
@@ -1079,15 +1008,17 @@ export const fromSubscriptionArray = subscription => fromPull(Effect.succeed(Eff
|
|
|
1079
1008
|
* // The channel will output: 1, 2, 3 (individual values)
|
|
1080
1009
|
* return channel
|
|
1081
1010
|
* })
|
|
1011
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
1012
|
+
* await Effect.runPromise(result) // => Option.some(1)
|
|
1082
1013
|
* ```
|
|
1083
1014
|
*
|
|
1084
1015
|
* **Example** (Streaming PubSub notifications)
|
|
1085
1016
|
*
|
|
1086
|
-
* ```ts
|
|
1087
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1017
|
+
* ```ts import.meta.vitest
|
|
1018
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1088
1019
|
*
|
|
1089
1020
|
* const notificationService = Effect.gen(function*() {
|
|
1090
|
-
* const notificationPubSub = yield* PubSub.
|
|
1021
|
+
* const notificationPubSub = yield* PubSub.unbounded<string>({ replay: 1 })
|
|
1091
1022
|
*
|
|
1092
1023
|
* // Create a channel for real-time notifications
|
|
1093
1024
|
* const notificationChannel = Channel.fromPubSub(notificationPubSub)
|
|
@@ -1100,14 +1031,17 @@ export const fromSubscriptionArray = subscription => fromPull(Effect.succeed(Eff
|
|
|
1100
1031
|
* id: `notification:${message}`
|
|
1101
1032
|
* }))
|
|
1102
1033
|
*
|
|
1034
|
+
* yield* PubSub.publish(notificationPubSub, "ready")
|
|
1103
1035
|
* return timestampedChannel
|
|
1104
1036
|
* })
|
|
1037
|
+
* const notification = Effect.scoped(Effect.flatMap(notificationService, Channel.runHead))
|
|
1038
|
+
* await Effect.runPromise(notification) // => Option.some({ message: "ready", receivedAt: "2024-01-01T00:00:00.000Z", id: "notification:ready" })
|
|
1105
1039
|
* ```
|
|
1106
1040
|
*
|
|
1107
1041
|
* **Example** (Processing PubSub events)
|
|
1108
1042
|
*
|
|
1109
|
-
* ```ts
|
|
1110
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1043
|
+
* ```ts import.meta.vitest
|
|
1044
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1111
1045
|
*
|
|
1112
1046
|
* interface DomainEvent {
|
|
1113
1047
|
* readonly type: string
|
|
@@ -1116,7 +1050,7 @@ export const fromSubscriptionArray = subscription => fromPull(Effect.succeed(Eff
|
|
|
1116
1050
|
* }
|
|
1117
1051
|
*
|
|
1118
1052
|
* const eventProcessor = Effect.gen(function*() {
|
|
1119
|
-
* const eventPubSub = yield* PubSub.
|
|
1053
|
+
* const eventPubSub = yield* PubSub.unbounded<DomainEvent>({ replay: 1 })
|
|
1120
1054
|
*
|
|
1121
1055
|
* // Create a channel for processing domain events
|
|
1122
1056
|
* const eventChannel = Channel.fromPubSub(eventPubSub)
|
|
@@ -1133,8 +1067,11 @@ export const fromSubscriptionArray = subscription => fromPull(Effect.succeed(Eff
|
|
|
1133
1067
|
* return event
|
|
1134
1068
|
* })
|
|
1135
1069
|
*
|
|
1070
|
+
* yield* PubSub.publish(eventPubSub, { type: "user.created", payload: {}, timestamp: 1 })
|
|
1136
1071
|
* return processedChannel
|
|
1137
1072
|
* })
|
|
1073
|
+
* const event = Effect.scoped(Effect.flatMap(eventProcessor, Channel.runHead))
|
|
1074
|
+
* const result = await Effect.runPromise(event) // => Option.some({ type: "user.created", payload: {}, timestamp: 1, processed: true, processedAt: 2 })
|
|
1138
1075
|
* ```
|
|
1139
1076
|
*
|
|
1140
1077
|
* @category constructors
|
|
@@ -1152,15 +1089,15 @@ export const fromPubSub = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsub),
|
|
|
1152
1089
|
*
|
|
1153
1090
|
* **Example** (Batching PubSub values)
|
|
1154
1091
|
*
|
|
1155
|
-
* ```ts
|
|
1156
|
-
* import { Channel, Data, Effect, PubSub } from "effect"
|
|
1092
|
+
* ```ts import.meta.vitest
|
|
1093
|
+
* import { Channel, Data, Effect, Option, PubSub } from "effect"
|
|
1157
1094
|
*
|
|
1158
1095
|
* class BatchError extends Data.TaggedError("BatchError")<{
|
|
1159
1096
|
* readonly message: string
|
|
1160
1097
|
* }> {}
|
|
1161
1098
|
*
|
|
1162
1099
|
* const program = Effect.gen(function*() {
|
|
1163
|
-
* const pubsub = yield* PubSub.
|
|
1100
|
+
* const pubsub = yield* PubSub.unbounded<number>({ replay: 4 })
|
|
1164
1101
|
*
|
|
1165
1102
|
* // Create a channel that reads arrays of values
|
|
1166
1103
|
* const channel = Channel.fromPubSubArray(pubsub)
|
|
@@ -1174,12 +1111,14 @@ export const fromPubSub = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsub),
|
|
|
1174
1111
|
* // The channel will output arrays like [1, 2, 3] and [4]
|
|
1175
1112
|
* return channel
|
|
1176
1113
|
* })
|
|
1114
|
+
* const result = Effect.scoped(Effect.flatMap(program, Channel.runHead))
|
|
1115
|
+
* await Effect.runPromise(result) // => Option.some([1, 2, 3, 4])
|
|
1177
1116
|
* ```
|
|
1178
1117
|
*
|
|
1179
1118
|
* **Example** (Processing PubSub orders in batches)
|
|
1180
1119
|
*
|
|
1181
|
-
* ```ts
|
|
1182
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1120
|
+
* ```ts import.meta.vitest
|
|
1121
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1183
1122
|
*
|
|
1184
1123
|
* interface Order {
|
|
1185
1124
|
* readonly id: string
|
|
@@ -1190,7 +1129,7 @@ export const fromPubSub = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsub),
|
|
|
1190
1129
|
* }
|
|
1191
1130
|
*
|
|
1192
1131
|
* const orderBatchProcessor = Effect.gen(function*() {
|
|
1193
|
-
* const orderPubSub = yield* PubSub.
|
|
1132
|
+
* const orderPubSub = yield* PubSub.unbounded<Order>({ replay: 1 })
|
|
1194
1133
|
*
|
|
1195
1134
|
* // Create a channel that processes orders in batches
|
|
1196
1135
|
* const orderChannel = Channel.fromPubSubArray(orderPubSub)
|
|
@@ -1211,14 +1150,20 @@ export const fromPubSub = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsub),
|
|
|
1211
1150
|
* }
|
|
1212
1151
|
* })
|
|
1213
1152
|
*
|
|
1153
|
+
* yield* PubSub.publish(orderPubSub, {
|
|
1154
|
+
* id: "1", customerId: "a", items: ["book"], total: 10, submittedAt: 1
|
|
1155
|
+
* })
|
|
1214
1156
|
* return processedChannel
|
|
1215
1157
|
* })
|
|
1158
|
+
* const order = Effect.scoped(Effect.flatMap(orderBatchProcessor, Channel.runHead))
|
|
1159
|
+
* const result = await Effect.runPromise(order)
|
|
1160
|
+
* Option.map(result, (batch) => [batch.batchSize, batch.totalRevenue, batch.uniqueCustomers]) // => Option.some([1, 10, 1])
|
|
1216
1161
|
* ```
|
|
1217
1162
|
*
|
|
1218
1163
|
* **Example** (Processing PubSub logs in batches)
|
|
1219
1164
|
*
|
|
1220
|
-
* ```ts
|
|
1221
|
-
* import { Channel, Effect, PubSub } from "effect"
|
|
1165
|
+
* ```ts import.meta.vitest
|
|
1166
|
+
* import { Channel, Effect, Option, PubSub } from "effect"
|
|
1222
1167
|
*
|
|
1223
1168
|
* interface LogEntry {
|
|
1224
1169
|
* readonly timestamp: number
|
|
@@ -1228,7 +1173,7 @@ export const fromPubSub = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsub),
|
|
|
1228
1173
|
* }
|
|
1229
1174
|
*
|
|
1230
1175
|
* const logAggregator = Effect.gen(function*() {
|
|
1231
|
-
* const logPubSub = yield* PubSub.
|
|
1176
|
+
* const logPubSub = yield* PubSub.unbounded<LogEntry>({ replay: 1 })
|
|
1232
1177
|
*
|
|
1233
1178
|
* // Create a channel that collects logs in batches
|
|
1234
1179
|
* const logChannel = Channel.fromPubSubArray(logPubSub)
|
|
@@ -1255,8 +1200,17 @@ export const fromPubSub = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsub),
|
|
|
1255
1200
|
* }
|
|
1256
1201
|
* })
|
|
1257
1202
|
*
|
|
1203
|
+
* yield* PubSub.publish(logPubSub, {
|
|
1204
|
+
* timestamp: 1,
|
|
1205
|
+
* level: "info",
|
|
1206
|
+
* message: "ready",
|
|
1207
|
+
* source: "app"
|
|
1208
|
+
* } satisfies LogEntry)
|
|
1258
1209
|
* return analysisChannel
|
|
1259
1210
|
* })
|
|
1211
|
+
* const log = Effect.scoped(Effect.flatMap(logAggregator, Channel.runHead))
|
|
1212
|
+
* const result = await Effect.runPromise(log)
|
|
1213
|
+
* Option.map(result, (batch) => [batch.batchId, batch.totalEntries, batch.infoCount]) // => Option.some(["1-1", 1, 1])
|
|
1260
1214
|
* ```
|
|
1261
1215
|
*
|
|
1262
1216
|
* @category constructors
|
|
@@ -1282,6 +1236,162 @@ export const fromPubSubTake = pubsub => unwrap(Effect.map(PubSub.subscribe(pubsu
|
|
|
1282
1236
|
* @since 4.0.0
|
|
1283
1237
|
*/
|
|
1284
1238
|
export const fromSchedule = schedule => fromPull(Effect.map(Schedule.toStepWithSleep(schedule), step => step(void 0)));
|
|
1239
|
+
/**
|
|
1240
|
+
* Creates a channel from a lazily supplied Web `ReadableStream`.
|
|
1241
|
+
*
|
|
1242
|
+
* **Example** (Reading from a Web stream)
|
|
1243
|
+
*
|
|
1244
|
+
* ```ts import.meta.vitest
|
|
1245
|
+
* import { Channel, Effect } from "effect"
|
|
1246
|
+
*
|
|
1247
|
+
* const channel = Channel.fromReadableStream({
|
|
1248
|
+
* evaluate: () => new ReadableStream({
|
|
1249
|
+
* start(controller) {
|
|
1250
|
+
* controller.enqueue(1)
|
|
1251
|
+
* controller.close()
|
|
1252
|
+
* }
|
|
1253
|
+
* }),
|
|
1254
|
+
* onError: (cause) => new Error(String(cause))
|
|
1255
|
+
* })
|
|
1256
|
+
*
|
|
1257
|
+
* await Effect.runPromise(Channel.runCollect(channel)) // => [[1]]
|
|
1258
|
+
* ```
|
|
1259
|
+
*
|
|
1260
|
+
* @category constructors
|
|
1261
|
+
* @since 4.0.0
|
|
1262
|
+
*/
|
|
1263
|
+
export const fromReadableStream = options => fromTransform((_, scope) => readableStreamToPullUnsafe({
|
|
1264
|
+
scope,
|
|
1265
|
+
readable: options.evaluate(),
|
|
1266
|
+
onError: options.onError,
|
|
1267
|
+
releaseLockOnEnd: options.releaseLockOnEnd
|
|
1268
|
+
}));
|
|
1269
|
+
/** @internal */
|
|
1270
|
+
export const pullIntoWritableStream = options => Effect.acquireUseRelease(Effect.sync(() => options.writable.getWriter()), writer => {
|
|
1271
|
+
const loop = options.pull.pipe(Effect.flatMap(chunk => Effect.forEach(chunk, value => Effect.tryPromise({
|
|
1272
|
+
try: () => writer.ready.then(() => writer.write(value)),
|
|
1273
|
+
catch: options.onError
|
|
1274
|
+
}), {
|
|
1275
|
+
discard: true
|
|
1276
|
+
})), Effect.forever({
|
|
1277
|
+
disableYield: true
|
|
1278
|
+
}));
|
|
1279
|
+
const withClose = options.closeOnDone !== false ? Pull.catchDone(loop, done => Effect.andThen(Effect.tryPromise({
|
|
1280
|
+
try: () => writer.close(),
|
|
1281
|
+
catch: options.onError
|
|
1282
|
+
}), Cause.done(done))) : loop;
|
|
1283
|
+
return Effect.onError(withClose, cause => Pull.isDoneCause(cause) ? Effect.void : Effect.promise(() => writer.abort(cause).catch(constVoid)));
|
|
1284
|
+
}, writer => Effect.sync(() => writer.releaseLock()));
|
|
1285
|
+
/**
|
|
1286
|
+
* Creates a channel that writes upstream values to a lazily supplied Web
|
|
1287
|
+
* `WritableStream`.
|
|
1288
|
+
*
|
|
1289
|
+
* **Example** (Writing channel input)
|
|
1290
|
+
*
|
|
1291
|
+
* ```ts import.meta.vitest
|
|
1292
|
+
* import { Channel, Effect } from "effect"
|
|
1293
|
+
*
|
|
1294
|
+
* const written: Array<number> = []
|
|
1295
|
+
* const sink = Channel.fromWritableStream<never, Error, number>({
|
|
1296
|
+
* evaluate: () => new WritableStream({
|
|
1297
|
+
* write(value) {
|
|
1298
|
+
* written.push(value)
|
|
1299
|
+
* }
|
|
1300
|
+
* }),
|
|
1301
|
+
* onError: (cause) => new Error(String(cause))
|
|
1302
|
+
* })
|
|
1303
|
+
*
|
|
1304
|
+
* const program = Channel.fromArray([[1, 2] as [number, number]]).pipe(
|
|
1305
|
+
* Channel.pipeTo(sink),
|
|
1306
|
+
* Channel.runDrain
|
|
1307
|
+
* )
|
|
1308
|
+
*
|
|
1309
|
+
* await Effect.runPromise(program)
|
|
1310
|
+
* written // => [1, 2]
|
|
1311
|
+
* ```
|
|
1312
|
+
*
|
|
1313
|
+
* @category constructors
|
|
1314
|
+
* @since 4.0.0
|
|
1315
|
+
*/
|
|
1316
|
+
export const fromWritableStream = options => fromTransform(pull => {
|
|
1317
|
+
const writable = options.evaluate();
|
|
1318
|
+
return Effect.succeed(pullIntoWritableStream({
|
|
1319
|
+
...options,
|
|
1320
|
+
writable,
|
|
1321
|
+
pull
|
|
1322
|
+
}));
|
|
1323
|
+
});
|
|
1324
|
+
/**
|
|
1325
|
+
* Creates a channel backed by a Web `TransformStream`, writing upstream values
|
|
1326
|
+
* while emitting transformed values from its readable side.
|
|
1327
|
+
*
|
|
1328
|
+
* **Example** (Transforming channel input)
|
|
1329
|
+
*
|
|
1330
|
+
* ```ts import.meta.vitest
|
|
1331
|
+
* import { Channel, Effect } from "effect"
|
|
1332
|
+
*
|
|
1333
|
+
* const transform = Channel.fromTransformStream<never, number, number, Error>({
|
|
1334
|
+
* evaluate: () => new TransformStream({
|
|
1335
|
+
* transform(value, controller) {
|
|
1336
|
+
* controller.enqueue(value * 2)
|
|
1337
|
+
* }
|
|
1338
|
+
* }),
|
|
1339
|
+
* onError: (cause) => new Error(String(cause))
|
|
1340
|
+
* })
|
|
1341
|
+
*
|
|
1342
|
+
* const program = Channel.fromArray([[1, 2] as [number, number]]).pipe(
|
|
1343
|
+
* Channel.pipeTo(transform),
|
|
1344
|
+
* Channel.runCollect
|
|
1345
|
+
* )
|
|
1346
|
+
*
|
|
1347
|
+
* await Effect.runPromise(program) // => [[2], [4]]
|
|
1348
|
+
* ```
|
|
1349
|
+
*
|
|
1350
|
+
* @category constructors
|
|
1351
|
+
* @since 4.0.0
|
|
1352
|
+
*/
|
|
1353
|
+
export const fromTransformStream = options => fromTransform((upstream, scope) => {
|
|
1354
|
+
const transform = options.evaluate();
|
|
1355
|
+
const exit = MutableRef.make(undefined);
|
|
1356
|
+
return pullIntoWritableStream({
|
|
1357
|
+
pull: upstream,
|
|
1358
|
+
writable: transform.writable,
|
|
1359
|
+
onError: options.onError,
|
|
1360
|
+
closeOnDone: options.closeOnDone
|
|
1361
|
+
}).pipe(Effect.catchCause(cause => {
|
|
1362
|
+
if (!Pull.isDoneCause(cause)) {
|
|
1363
|
+
exit.current = Exit.failCause(cause);
|
|
1364
|
+
}
|
|
1365
|
+
return Effect.void;
|
|
1366
|
+
}), Effect.forkIn(scope), Effect.flatMap(() => readableStreamToPullUnsafe({
|
|
1367
|
+
scope,
|
|
1368
|
+
exit,
|
|
1369
|
+
readable: transform.readable,
|
|
1370
|
+
onError: options.onError,
|
|
1371
|
+
releaseLockOnEnd: options.releaseLockOnEnd
|
|
1372
|
+
})));
|
|
1373
|
+
});
|
|
1374
|
+
const readableStreamToPullUnsafe = options => {
|
|
1375
|
+
const reader = options.readable.getReader();
|
|
1376
|
+
const exit = options.exit ?? MutableRef.make(undefined);
|
|
1377
|
+
const pull = Effect.suspend(() => {
|
|
1378
|
+
if (exit.current) return exit.current;
|
|
1379
|
+
return Effect.matchCauseEffect(Effect.tryPromise({
|
|
1380
|
+
try: () => reader.read(),
|
|
1381
|
+
catch: options.onError
|
|
1382
|
+
}), {
|
|
1383
|
+
onFailure: cause => exit.current ?? Effect.failCause(cause),
|
|
1384
|
+
onSuccess: ({
|
|
1385
|
+
done,
|
|
1386
|
+
value
|
|
1387
|
+
}) => {
|
|
1388
|
+
if (exit.current) return exit.current;
|
|
1389
|
+
return done ? Cause.done() : Effect.succeed(Arr.of(value));
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
});
|
|
1393
|
+
return Effect.as(Scope.addFinalizer(options.scope, options.releaseLockOnEnd ? Effect.sync(() => reader.releaseLock()) : Effect.promise(() => reader.cancel().catch(constVoid))), pull);
|
|
1394
|
+
};
|
|
1285
1395
|
/**
|
|
1286
1396
|
* Creates a channel that pulls values from an `AsyncIterable`.
|
|
1287
1397
|
*
|
|
@@ -1324,8 +1434,8 @@ export const fromAsyncIterableArray = (iterable, onError) => map(fromAsyncIterab
|
|
|
1324
1434
|
*
|
|
1325
1435
|
* **Example** (Mapping channel output)
|
|
1326
1436
|
*
|
|
1327
|
-
* ```ts
|
|
1328
|
-
* import { Channel, Data } from "effect"
|
|
1437
|
+
* ```ts import.meta.vitest
|
|
1438
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1329
1439
|
*
|
|
1330
1440
|
* class TransformError extends Data.TaggedError("TransformError")<{
|
|
1331
1441
|
* readonly reason: string
|
|
@@ -1334,12 +1444,12 @@ export const fromAsyncIterableArray = (iterable, onError) => map(fromAsyncIterab
|
|
|
1334
1444
|
* // Basic mapping of channel values
|
|
1335
1445
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
1336
1446
|
* const doubledChannel = Channel.map(numbersChannel, (n) => n * 2)
|
|
1337
|
-
* //
|
|
1447
|
+
* Effect.runSync(Channel.runCollect(doubledChannel)) // => [2, 4, 6, 8, 10]
|
|
1338
1448
|
*
|
|
1339
1449
|
* // Transform string data
|
|
1340
1450
|
* const wordsChannel = Channel.fromIterable(["hello", "world", "effect"])
|
|
1341
1451
|
* const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase())
|
|
1342
|
-
* //
|
|
1452
|
+
* Effect.runSync(Channel.runCollect(upperCaseChannel)) // => ["HELLO", "WORLD", "EFFECT"]
|
|
1343
1453
|
*
|
|
1344
1454
|
* // Complex object transformation
|
|
1345
1455
|
* type User = { id: number; name: string }
|
|
@@ -1353,6 +1463,7 @@ export const fromAsyncIterableArray = (iterable, onError) => map(fromAsyncIterab
|
|
|
1353
1463
|
* displayName: `User: ${user.name}`,
|
|
1354
1464
|
* isActive: true
|
|
1355
1465
|
* }))
|
|
1466
|
+
* Effect.runSync(Channel.runCollect(displayChannel)) // => [{ displayName: "User: Alice", isActive: true }, { displayName: "User: Bob", isActive: true }]
|
|
1356
1467
|
* ```
|
|
1357
1468
|
*
|
|
1358
1469
|
* @category sequencing
|
|
@@ -1400,40 +1511,15 @@ const concurrencyIsSequential = concurrency => concurrency === undefined || conc
|
|
|
1400
1511
|
*
|
|
1401
1512
|
* **Example** (Mapping channel output with effects)
|
|
1402
1513
|
*
|
|
1403
|
-
* ```ts
|
|
1404
|
-
* import { Channel,
|
|
1405
|
-
*
|
|
1406
|
-
* class NetworkError extends Data.TaggedError("NetworkError")<{
|
|
1407
|
-
* readonly url: string
|
|
1408
|
-
* }> {}
|
|
1409
|
-
*
|
|
1410
|
-
* // Transform values using effectful operations
|
|
1411
|
-
* const urlsChannel = Channel.fromIterable([
|
|
1412
|
-
* "/api/users/1",
|
|
1413
|
-
* "/api/users/2",
|
|
1414
|
-
* "/api/users/3"
|
|
1415
|
-
* ])
|
|
1416
|
-
*
|
|
1417
|
-
* const fetchDataChannel = Channel.mapEffect(
|
|
1418
|
-
* urlsChannel,
|
|
1419
|
-
* (url) =>
|
|
1420
|
-
* Effect.tryPromise({
|
|
1421
|
-
* try: () => fetch(url).then((res) => res.json()),
|
|
1422
|
-
* catch: () => new NetworkError({ url })
|
|
1423
|
-
* })
|
|
1424
|
-
* )
|
|
1514
|
+
* ```ts import.meta.vitest
|
|
1515
|
+
* import { Channel, Effect } from "effect"
|
|
1425
1516
|
*
|
|
1426
|
-
* // Concurrent processing with options
|
|
1427
1517
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
1428
1518
|
* const processedChannel = Channel.mapEffect(
|
|
1429
1519
|
* numbersChannel,
|
|
1430
|
-
* (n) =>
|
|
1431
|
-
* Effect.gen(function*() {
|
|
1432
|
-
* yield* Effect.sleep("100 millis") // Simulate async work
|
|
1433
|
-
* return n * n
|
|
1434
|
-
* }),
|
|
1435
|
-
* { concurrency: 3, unordered: true }
|
|
1520
|
+
* (n) => Effect.succeed(n * n)
|
|
1436
1521
|
* )
|
|
1522
|
+
* await Effect.runPromise(Channel.runCollect(processedChannel)) // => [1, 4, 9, 16, 25]
|
|
1437
1523
|
* ```
|
|
1438
1524
|
*
|
|
1439
1525
|
* @category sequencing
|
|
@@ -1523,8 +1609,8 @@ export const mapInputError = /*#__PURE__*/dual(2, (self, f) => fromTransform((up
|
|
|
1523
1609
|
*
|
|
1524
1610
|
* **Example** (Tapping channel output)
|
|
1525
1611
|
*
|
|
1526
|
-
* ```ts
|
|
1527
|
-
* import { Channel,
|
|
1612
|
+
* ```ts import.meta.vitest
|
|
1613
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1528
1614
|
*
|
|
1529
1615
|
* class LogError extends Data.TaggedError("LogError")<{
|
|
1530
1616
|
* readonly message: string
|
|
@@ -1534,13 +1620,13 @@ export const mapInputError = /*#__PURE__*/dual(2, (self, f) => fromTransform((up
|
|
|
1534
1620
|
* const numberChannel = Channel.fromIterable([1, 2, 3])
|
|
1535
1621
|
*
|
|
1536
1622
|
* // Tap into each output element to perform side effects
|
|
1623
|
+
* const processed: Array<number> = []
|
|
1537
1624
|
* const tappedChannel = Channel.tap(
|
|
1538
1625
|
* numberChannel,
|
|
1539
|
-
* (n) =>
|
|
1626
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
1540
1627
|
* )
|
|
1541
1628
|
*
|
|
1542
|
-
*
|
|
1543
|
-
* // Outputs: 1, 2, 3 (while logging each)
|
|
1629
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(tappedChannel)), processed] // => [[1, 2, 3], [1, 2, 3]]
|
|
1544
1630
|
* ```
|
|
1545
1631
|
*
|
|
1546
1632
|
* @category sequencing
|
|
@@ -1560,8 +1646,8 @@ export const tap = /*#__PURE__*/dual(args => isChannel(args[0]), (self, f, optio
|
|
|
1560
1646
|
*
|
|
1561
1647
|
* **Example** (Flat mapping channel output)
|
|
1562
1648
|
*
|
|
1563
|
-
* ```ts
|
|
1564
|
-
* import { Channel, Data } from "effect"
|
|
1649
|
+
* ```ts import.meta.vitest
|
|
1650
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1565
1651
|
*
|
|
1566
1652
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
1567
1653
|
* readonly cause: string
|
|
@@ -1577,8 +1663,7 @@ export const tap = /*#__PURE__*/dual(args => isChannel(args[0]), (self, f, optio
|
|
|
1577
1663
|
* Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`))
|
|
1578
1664
|
* )
|
|
1579
1665
|
*
|
|
1580
|
-
* //
|
|
1581
|
-
* // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"
|
|
1666
|
+
* Effect.runSync(Channel.runCollect(flatMappedChannel)) // => ["item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2"]
|
|
1582
1667
|
* ```
|
|
1583
1668
|
*
|
|
1584
1669
|
* @category sequencing
|
|
@@ -1614,8 +1699,8 @@ const flatMapConcurrent = (self, f, options) => self.pipe(map(f), mergeAll(optio
|
|
|
1614
1699
|
*
|
|
1615
1700
|
* **Example** (Concatenating with completion values)
|
|
1616
1701
|
*
|
|
1617
|
-
* ```ts
|
|
1618
|
-
* import { Channel, Data } from "effect"
|
|
1702
|
+
* ```ts import.meta.vitest
|
|
1703
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1619
1704
|
*
|
|
1620
1705
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
1621
1706
|
* readonly reason: string
|
|
@@ -1626,8 +1711,7 @@ const flatMapConcurrent = (self, f, options) => self.pipe(map(f), mergeAll(optio
|
|
|
1626
1711
|
* Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`))
|
|
1627
1712
|
* )
|
|
1628
1713
|
*
|
|
1629
|
-
* //
|
|
1630
|
-
* // Outputs: 1, 2, 3, then "Completed processing"
|
|
1714
|
+
* Effect.runSync(Channel.runCollect(numberChannel)) // => [1, 2, 3, "Completed processing"]
|
|
1631
1715
|
* ```
|
|
1632
1716
|
*
|
|
1633
1717
|
* @category sequencing
|
|
@@ -1653,8 +1737,8 @@ export const concatWith = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstr
|
|
|
1653
1737
|
*
|
|
1654
1738
|
* **Example** (Concatenating channels)
|
|
1655
1739
|
*
|
|
1656
|
-
* ```ts
|
|
1657
|
-
* import { Channel, Data } from "effect"
|
|
1740
|
+
* ```ts import.meta.vitest
|
|
1741
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1658
1742
|
*
|
|
1659
1743
|
* class ConcatError extends Data.TaggedError("ConcatError")<{
|
|
1660
1744
|
* readonly reason: string
|
|
@@ -1667,7 +1751,7 @@ export const concatWith = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstr
|
|
|
1667
1751
|
* // Concatenate them
|
|
1668
1752
|
* const concatenatedChannel = Channel.concat(firstChannel, secondChannel)
|
|
1669
1753
|
*
|
|
1670
|
-
* //
|
|
1754
|
+
* Effect.runSync(Channel.runCollect(concatenatedChannel)) // => [1, 2, 3, "a", "b", "c"]
|
|
1671
1755
|
* ```
|
|
1672
1756
|
*
|
|
1673
1757
|
* @category sequencing
|
|
@@ -1737,8 +1821,8 @@ export const orElseIfEmpty = /*#__PURE__*/dual(2, (self, f) => fromTransform((up
|
|
|
1737
1821
|
*
|
|
1738
1822
|
* **Example** (Flattening nested channels)
|
|
1739
1823
|
*
|
|
1740
|
-
* ```ts
|
|
1741
|
-
* import { Channel, Data } from "effect"
|
|
1824
|
+
* ```ts import.meta.vitest
|
|
1825
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1742
1826
|
*
|
|
1743
1827
|
* class FlattenError extends Data.TaggedError("FlattenError")<{
|
|
1744
1828
|
* readonly cause: string
|
|
@@ -1754,7 +1838,7 @@ export const orElseIfEmpty = /*#__PURE__*/dual(2, (self, f) => fromTransform((up
|
|
|
1754
1838
|
* // Flatten the nested channels
|
|
1755
1839
|
* const flattenedChannel = Channel.flatten(nestedChannels)
|
|
1756
1840
|
*
|
|
1757
|
-
* //
|
|
1841
|
+
* Effect.runSync(Channel.runCollect(flattenedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
1758
1842
|
* ```
|
|
1759
1843
|
*
|
|
1760
1844
|
* @category constructors
|
|
@@ -1766,8 +1850,8 @@ export const flatten = channels => flatMap(channels, identity_);
|
|
|
1766
1850
|
*
|
|
1767
1851
|
* **Example** (Flattening arrays of channel output)
|
|
1768
1852
|
*
|
|
1769
|
-
* ```ts
|
|
1770
|
-
* import { Channel, Data } from "effect"
|
|
1853
|
+
* ```ts import.meta.vitest
|
|
1854
|
+
* import { Channel, Data, Effect } from "effect"
|
|
1771
1855
|
*
|
|
1772
1856
|
* class FlattenError extends Data.TaggedError("FlattenError")<{
|
|
1773
1857
|
* readonly message: string
|
|
@@ -1783,7 +1867,7 @@ export const flatten = channels => flatMap(channels, identity_);
|
|
|
1783
1867
|
* // Flatten the arrays into individual elements
|
|
1784
1868
|
* const flattenedChannel = Channel.flattenArray(arrayChannel)
|
|
1785
1869
|
*
|
|
1786
|
-
* //
|
|
1870
|
+
* Effect.runSync(Channel.runCollect(flattenedChannel)) // => [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
1787
1871
|
* ```
|
|
1788
1872
|
*
|
|
1789
1873
|
* @category transforming
|
|
@@ -1836,8 +1920,8 @@ export const flattenTake = self => mapEffectSequential(self, Take.toPull);
|
|
|
1836
1920
|
*
|
|
1837
1921
|
* **Example** (Draining channel output)
|
|
1838
1922
|
*
|
|
1839
|
-
* ```ts
|
|
1840
|
-
* import { Channel } from "effect"
|
|
1923
|
+
* ```ts import.meta.vitest
|
|
1924
|
+
* import { Channel, Effect } from "effect"
|
|
1841
1925
|
*
|
|
1842
1926
|
* // Create a channel that outputs values
|
|
1843
1927
|
* const sourceChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
@@ -1845,8 +1929,7 @@ export const flattenTake = self => mapEffectSequential(self, Take.toPull);
|
|
|
1845
1929
|
* // Drain all output, keeping only the completion
|
|
1846
1930
|
* const drainedChannel = Channel.drain(sourceChannel)
|
|
1847
1931
|
*
|
|
1848
|
-
* //
|
|
1849
|
-
* // Useful for consuming side effects without collecting output
|
|
1932
|
+
* Effect.runSync(Channel.runCollect(drainedChannel)) // => []
|
|
1850
1933
|
* ```
|
|
1851
1934
|
*
|
|
1852
1935
|
* @category constructors
|
|
@@ -1900,15 +1983,15 @@ export const schedule = /*#__PURE__*/dual(2, (self, schedule) => transformPull(s
|
|
|
1900
1983
|
*
|
|
1901
1984
|
* **Example** (Filtering channel output)
|
|
1902
1985
|
*
|
|
1903
|
-
* ```ts
|
|
1904
|
-
* import { Channel } from "effect"
|
|
1986
|
+
* ```ts import.meta.vitest
|
|
1987
|
+
* import { Channel, Effect } from "effect"
|
|
1905
1988
|
*
|
|
1906
1989
|
* // Create a channel with mixed numbers
|
|
1907
1990
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8])
|
|
1908
1991
|
*
|
|
1909
1992
|
* // Filter to keep only even numbers
|
|
1910
1993
|
* const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0)
|
|
1911
|
-
* //
|
|
1994
|
+
* Effect.runSync(Channel.runCollect(evenChannel)) // => [2, 4, 6, 8]
|
|
1912
1995
|
*
|
|
1913
1996
|
* // Filter with type refinement
|
|
1914
1997
|
* const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3])
|
|
@@ -1916,7 +1999,7 @@ export const schedule = /*#__PURE__*/dual(2, (self, schedule) => transformPull(s
|
|
|
1916
1999
|
* mixedChannel,
|
|
1917
2000
|
* (value): value is number => typeof value === "number"
|
|
1918
2001
|
* )
|
|
1919
|
-
* //
|
|
2002
|
+
* Effect.runSync(Channel.runCollect(numbersOnlyChannel)) // => [1, 2, 3]
|
|
1920
2003
|
* ```
|
|
1921
2004
|
*
|
|
1922
2005
|
* @category filtering
|
|
@@ -2001,8 +2084,8 @@ export const filterMapEffect = /*#__PURE__*/dual(2, (self, filter) => fromTransf
|
|
|
2001
2084
|
*
|
|
2002
2085
|
* **Example** (Filtering array output)
|
|
2003
2086
|
*
|
|
2004
|
-
* ```ts
|
|
2005
|
-
* import { Array, Channel } from "effect"
|
|
2087
|
+
* ```ts import.meta.vitest
|
|
2088
|
+
* import { Array, Channel, Effect } from "effect"
|
|
2006
2089
|
*
|
|
2007
2090
|
* const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
|
|
2008
2091
|
*
|
|
@@ -2015,7 +2098,7 @@ export const filterMapEffect = /*#__PURE__*/dual(2, (self, filter) => fromTransf
|
|
|
2015
2098
|
*
|
|
2016
2099
|
* // Filter arrays to keep only even numbers
|
|
2017
2100
|
* const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
|
|
2018
|
-
* //
|
|
2101
|
+
* Effect.runSync(Channel.runCollect(evenArraysChannel)) // => [[2, 4], [6, 8, 10], [12, 14]]
|
|
2019
2102
|
* // Note: Only non-empty filtered arrays are emitted
|
|
2020
2103
|
*
|
|
2021
2104
|
* // Arrays that would become empty after filtering are discarded entirely
|
|
@@ -2025,7 +2108,7 @@ export const filterMapEffect = /*#__PURE__*/dual(2, (self, filter) => fromTransf
|
|
|
2025
2108
|
* Array.make(7, 9)
|
|
2026
2109
|
* ]).pipe(Channel.filter(nonEmptyArrayPredicate))
|
|
2027
2110
|
* const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
|
|
2028
|
-
* //
|
|
2111
|
+
* Effect.runSync(Channel.runCollect(filteredOddChannel)) // => [[2, 4]]
|
|
2029
2112
|
* ```
|
|
2030
2113
|
*
|
|
2031
2114
|
* @category filtering
|
|
@@ -2112,7 +2195,7 @@ export const filterMapArrayEffect = /*#__PURE__*/dual(2, (self, filter) => trans
|
|
|
2112
2195
|
*
|
|
2113
2196
|
* **Example** (Mapping with accumulated state)
|
|
2114
2197
|
*
|
|
2115
|
-
* ```ts
|
|
2198
|
+
* ```ts import.meta.vitest
|
|
2116
2199
|
* import { Channel, Effect } from "effect"
|
|
2117
2200
|
*
|
|
2118
2201
|
* // Create a channel with numbers
|
|
@@ -2128,8 +2211,6 @@ export const filterMapArrayEffect = /*#__PURE__*/dual(2, (self, filter) => trans
|
|
|
2128
2211
|
* return [newSum, [current, newSum]] as const
|
|
2129
2212
|
* }
|
|
2130
2213
|
* )
|
|
2131
|
-
* // Outputs: 1, 1, 2, 3, 3, 6, 4, 10
|
|
2132
|
-
*
|
|
2133
2214
|
* // Using with Effect for async processing
|
|
2134
2215
|
* const asyncMapAccum = Channel.mapAccum(
|
|
2135
2216
|
* numbersChannel,
|
|
@@ -2140,6 +2221,8 @@ export const filterMapArrayEffect = /*#__PURE__*/dual(2, (self, filter) => trans
|
|
|
2140
2221
|
* return [newAcc, [`${value}-processed`, newAcc]] as const
|
|
2141
2222
|
* })
|
|
2142
2223
|
* )
|
|
2224
|
+
* Effect.runSync(Channel.runCollect(runningSum)) // => [1, 1, 2, 3, 3, 6, 4, 10]
|
|
2225
|
+
* Effect.runSync(Channel.runCollect(asyncMapAccum)) // => ["1-processed", "1", "2-processed", "12", "3-processed", "123", "4-processed", "1234"]
|
|
2143
2226
|
* ```
|
|
2144
2227
|
*
|
|
2145
2228
|
* @category sequencing
|
|
@@ -2190,15 +2273,15 @@ export const mapAccum = /*#__PURE__*/dual(args => isChannel(args[0]), (self, ini
|
|
|
2190
2273
|
*
|
|
2191
2274
|
* **Example** (Scanning channel output)
|
|
2192
2275
|
*
|
|
2193
|
-
* ```ts
|
|
2194
|
-
* import { Channel } from "effect"
|
|
2276
|
+
* ```ts import.meta.vitest
|
|
2277
|
+
* import { Channel, Effect } from "effect"
|
|
2195
2278
|
*
|
|
2196
2279
|
* // Create a channel with numbers
|
|
2197
2280
|
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
2198
2281
|
*
|
|
2199
2282
|
* // Scan to create running sum
|
|
2200
2283
|
* const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n)
|
|
2201
|
-
* //
|
|
2284
|
+
* Effect.runSync(Channel.runCollect(runningSumChannel)) // => [0, 1, 3, 6, 10, 15]
|
|
2202
2285
|
* // Note: emits the initial value and each intermediate result
|
|
2203
2286
|
*
|
|
2204
2287
|
* // Scan with string concatenation
|
|
@@ -2208,7 +2291,7 @@ export const mapAccum = /*#__PURE__*/dual(args => isChannel(args[0]), (self, ini
|
|
|
2208
2291
|
* "",
|
|
2209
2292
|
* (sentence, word) => sentence === "" ? word : `${sentence} ${word}`
|
|
2210
2293
|
* )
|
|
2211
|
-
* //
|
|
2294
|
+
* Effect.runSync(Channel.runCollect(sentenceChannel)) // => ["", "hello", "hello world", "hello world from", "hello world from effect"]
|
|
2212
2295
|
* ```
|
|
2213
2296
|
*
|
|
2214
2297
|
* @category sequencing
|
|
@@ -2226,7 +2309,7 @@ export const scan = /*#__PURE__*/dual(3, (self, initial, f) => scanEffect(self,
|
|
|
2226
2309
|
*
|
|
2227
2310
|
* **Example** (Scanning channel output with effects)
|
|
2228
2311
|
*
|
|
2229
|
-
* ```ts
|
|
2312
|
+
* ```ts import.meta.vitest
|
|
2230
2313
|
* import { Channel, Data, Effect } from "effect"
|
|
2231
2314
|
*
|
|
2232
2315
|
* class ScanError extends Data.TaggedError("ScanError")<{
|
|
@@ -2242,12 +2325,10 @@ export const scan = /*#__PURE__*/dual(3, (self, initial, f) => scanEffect(self,
|
|
|
2242
2325
|
* "",
|
|
2243
2326
|
* (acc, value) =>
|
|
2244
2327
|
* Effect.gen(function*() {
|
|
2245
|
-
* // Simulate async work
|
|
2246
|
-
* yield* Effect.sleep("10 millis")
|
|
2247
2328
|
* return acc + value.toString()
|
|
2248
2329
|
* })
|
|
2249
2330
|
* )
|
|
2250
|
-
* //
|
|
2331
|
+
* await Effect.runPromise(Channel.runCollect(asyncScanChannel)) // => ["", "1", "12", "123", "1234"]
|
|
2251
2332
|
*
|
|
2252
2333
|
* // Scan with error handling
|
|
2253
2334
|
* const errorHandlingScan = Channel.scanEffect(
|
|
@@ -2260,6 +2341,7 @@ export const scan = /*#__PURE__*/dual(3, (self, initial, f) => scanEffect(self,
|
|
|
2260
2341
|
* return Effect.succeed(sum + n)
|
|
2261
2342
|
* }
|
|
2262
2343
|
* )
|
|
2344
|
+
* await Effect.runPromise(Channel.runCollect(errorHandlingScan)) // => [0, 1, 3, 6, 10]
|
|
2263
2345
|
* ```
|
|
2264
2346
|
*
|
|
2265
2347
|
* @category sequencing
|
|
@@ -2285,8 +2367,8 @@ export const scanEffect = /*#__PURE__*/dual(3, (self, initial, f) => fromTransfo
|
|
|
2285
2367
|
*
|
|
2286
2368
|
* **Example** (Recovering from failure causes)
|
|
2287
2369
|
*
|
|
2288
|
-
* ```ts
|
|
2289
|
-
* import { Cause, Channel, Data } from "effect"
|
|
2370
|
+
* ```ts import.meta.vitest
|
|
2371
|
+
* import { Cause, Channel, Data, Effect } from "effect"
|
|
2290
2372
|
*
|
|
2291
2373
|
* class ProcessError extends Data.TaggedError("ProcessError")<{
|
|
2292
2374
|
* readonly reason: string
|
|
@@ -2309,7 +2391,7 @@ export const scanEffect = /*#__PURE__*/dual(3, (self, initial, f) => fromTransfo
|
|
|
2309
2391
|
* return Channel.succeed("Recovered from interruption")
|
|
2310
2392
|
* })
|
|
2311
2393
|
*
|
|
2312
|
-
* //
|
|
2394
|
+
* Effect.runSync(Channel.runCollect(recoveredChannel)) // => ["Recovered from failure"]
|
|
2313
2395
|
* ```
|
|
2314
2396
|
*
|
|
2315
2397
|
* @category error handling
|
|
@@ -2494,8 +2576,8 @@ export const catchTag = /*#__PURE__*/dual(args => isChannel(args[0]), (self, k,
|
|
|
2494
2576
|
*
|
|
2495
2577
|
* **Example** (Recovering from nested reasons)
|
|
2496
2578
|
*
|
|
2497
|
-
* ```ts
|
|
2498
|
-
* import { Channel, Data } from "effect"
|
|
2579
|
+
* ```ts import.meta.vitest
|
|
2580
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2499
2581
|
*
|
|
2500
2582
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
2501
2583
|
* retryAfter: number
|
|
@@ -2509,15 +2591,15 @@ export const catchTag = /*#__PURE__*/dual(args => isChannel(args[0]), (self, k,
|
|
|
2509
2591
|
* reason: RateLimitError | QuotaExceededError
|
|
2510
2592
|
* }> {}
|
|
2511
2593
|
*
|
|
2512
|
-
* const
|
|
2513
|
-
*
|
|
2514
|
-
* )
|
|
2594
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
2595
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
2515
2596
|
*
|
|
2516
2597
|
* const recovered = channel.pipe(
|
|
2517
2598
|
* Channel.catchReason("AiError", "RateLimitError", (reason) =>
|
|
2518
2599
|
* Channel.succeed(`retry: ${reason.retryAfter}`)
|
|
2519
2600
|
* )
|
|
2520
2601
|
* )
|
|
2602
|
+
* Effect.runSync(Channel.runCollect(recovered)) // => ["retry: 60"]
|
|
2521
2603
|
* ```
|
|
2522
2604
|
*
|
|
2523
2605
|
* @category error handling
|
|
@@ -2558,8 +2640,8 @@ export const catchReasons = /*#__PURE__*/dual(args => isChannel(args[0]), (self,
|
|
|
2558
2640
|
*
|
|
2559
2641
|
* **Example** (Promoting nested reasons)
|
|
2560
2642
|
*
|
|
2561
|
-
* ```ts
|
|
2562
|
-
* import { Channel, Data } from "effect"
|
|
2643
|
+
* ```ts import.meta.vitest
|
|
2644
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
2563
2645
|
*
|
|
2564
2646
|
* class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
2565
2647
|
* retryAfter: number
|
|
@@ -2573,11 +2655,11 @@ export const catchReasons = /*#__PURE__*/dual(args => isChannel(args[0]), (self,
|
|
|
2573
2655
|
* reason: RateLimitError | QuotaExceededError
|
|
2574
2656
|
* }> {}
|
|
2575
2657
|
*
|
|
2576
|
-
* const
|
|
2577
|
-
*
|
|
2578
|
-
* )
|
|
2658
|
+
* const reason = new RateLimitError({ retryAfter: 60 })
|
|
2659
|
+
* const channel = Channel.fail(new AiError({ reason }))
|
|
2579
2660
|
*
|
|
2580
2661
|
* const unwrapped = channel.pipe(Channel.unwrapReason("AiError"))
|
|
2662
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(unwrapped))) // => Exit.fail(reason)
|
|
2581
2663
|
* ```
|
|
2582
2664
|
*
|
|
2583
2665
|
* @category error handling
|
|
@@ -2599,20 +2681,21 @@ export const mapError = /*#__PURE__*/dual(2, (self, f) => catch_(self, err => fa
|
|
|
2599
2681
|
*
|
|
2600
2682
|
* **Example** (Converting failures to defects)
|
|
2601
2683
|
*
|
|
2602
|
-
* ```ts
|
|
2603
|
-
* import { Channel, Data } from "effect"
|
|
2684
|
+
* ```ts import.meta.vitest
|
|
2685
|
+
* import { Cause, Channel, Data, Effect, Exit } from "effect"
|
|
2604
2686
|
*
|
|
2605
2687
|
* class ValidationError extends Data.TaggedError("ValidationError")<{
|
|
2606
2688
|
* readonly field: string
|
|
2607
2689
|
* }> {}
|
|
2608
2690
|
*
|
|
2609
2691
|
* // Create a channel that might fail
|
|
2610
|
-
* const
|
|
2692
|
+
* const error = new ValidationError({ field: "email" })
|
|
2693
|
+
* const failingChannel = Channel.fail(error)
|
|
2611
2694
|
*
|
|
2612
2695
|
* // Convert failures to defects
|
|
2613
2696
|
* const fatalChannel = Channel.orDie(failingChannel)
|
|
2614
2697
|
*
|
|
2615
|
-
* //
|
|
2698
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(fatalChannel))) // => Exit.failCause(Cause.die(error))
|
|
2616
2699
|
* ```
|
|
2617
2700
|
*
|
|
2618
2701
|
* @category error handling
|
|
@@ -2694,8 +2777,8 @@ export const retry = /*#__PURE__*/dual(2, (self, schedule) => suspend(() => {
|
|
|
2694
2777
|
*
|
|
2695
2778
|
* **Example** (Switching mapped channels)
|
|
2696
2779
|
*
|
|
2697
|
-
* ```ts
|
|
2698
|
-
* import { Channel, Data } from "effect"
|
|
2780
|
+
* ```ts import.meta.vitest
|
|
2781
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2699
2782
|
*
|
|
2700
2783
|
* class SwitchError extends Data.TaggedError("SwitchError")<{
|
|
2701
2784
|
* readonly reason: string
|
|
@@ -2710,7 +2793,7 @@ export const retry = /*#__PURE__*/dual(2, (self, schedule) => suspend(() => {
|
|
|
2710
2793
|
* (n) => Channel.fromIterable([`value-${n}`])
|
|
2711
2794
|
* )
|
|
2712
2795
|
*
|
|
2713
|
-
*
|
|
2796
|
+
* await Effect.runPromise(Channel.runCollect(switchedChannel)) // => ["value-3"]
|
|
2714
2797
|
* ```
|
|
2715
2798
|
*
|
|
2716
2799
|
* @category sequencing
|
|
@@ -2731,8 +2814,8 @@ export const switchMap = /*#__PURE__*/dual(args => isChannel(args[0]), (self, f,
|
|
|
2731
2814
|
*
|
|
2732
2815
|
* **Example** (Merging nested channels)
|
|
2733
2816
|
*
|
|
2734
|
-
* ```ts
|
|
2735
|
-
* import { Channel, Data } from "effect"
|
|
2817
|
+
* ```ts import.meta.vitest
|
|
2818
|
+
* import { Channel, Data, Effect } from "effect"
|
|
2736
2819
|
*
|
|
2737
2820
|
* class MergeAllError extends Data.TaggedError("MergeAllError")<{
|
|
2738
2821
|
* readonly reason: string
|
|
@@ -2747,11 +2830,11 @@ export const switchMap = /*#__PURE__*/dual(args => isChannel(args[0]), (self, f,
|
|
|
2747
2830
|
*
|
|
2748
2831
|
* // Merge all channels with bounded concurrency
|
|
2749
2832
|
* const mergedChannel = Channel.mergeAll({
|
|
2750
|
-
* concurrency:
|
|
2833
|
+
* concurrency: 1,
|
|
2751
2834
|
* bufferSize: 16
|
|
2752
2835
|
* })(nestedChannels)
|
|
2753
2836
|
*
|
|
2754
|
-
* //
|
|
2837
|
+
* await Effect.runPromise(Channel.runCollect(mergedChannel)) // => [1, 2, 3, 4, 5, 6]
|
|
2755
2838
|
* ```
|
|
2756
2839
|
*
|
|
2757
2840
|
* @category combining
|
|
@@ -2771,8 +2854,16 @@ export const mergeAll = /*#__PURE__*/dual(2, (channels, {
|
|
|
2771
2854
|
const pull = yield* toTransform(channels)(upstream, scope);
|
|
2772
2855
|
yield* Effect.gen(function* () {
|
|
2773
2856
|
while (true) {
|
|
2774
|
-
|
|
2775
|
-
|
|
2857
|
+
let pullFiber;
|
|
2858
|
+
if (semaphore) {
|
|
2859
|
+
if (fibers.size < concurrencyN) {
|
|
2860
|
+
yield* semaphore.take(1);
|
|
2861
|
+
} else {
|
|
2862
|
+
pullFiber = yield* Effect.forkChild(pull);
|
|
2863
|
+
yield* Effect.raceFirst(semaphore.take(1), Effect.andThen(Fiber.join(pullFiber), Effect.never));
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
const channel = pullFiber === undefined ? yield* pull : yield* Fiber.join(pullFiber);
|
|
2776
2867
|
const childScope = Scope.forkUnsafe(forkedScope);
|
|
2777
2868
|
const childPull = yield* toTransform(channel)(upstream, childScope);
|
|
2778
2869
|
while (fibers.size >= concurrencyN) {
|
|
@@ -2796,7 +2887,13 @@ export const mergeAll = /*#__PURE__*/dual(2, (channels, {
|
|
|
2796
2887
|
doneLatch.closeUnsafe();
|
|
2797
2888
|
fibers.add(fiber);
|
|
2798
2889
|
}
|
|
2799
|
-
}).pipe(Effect.catchCause(cause =>
|
|
2890
|
+
}).pipe(Effect.catchCause(cause => {
|
|
2891
|
+
const halt = Pull.filterDone(cause);
|
|
2892
|
+
if (Result.isSuccess(halt)) {
|
|
2893
|
+
return doneLatch.whenOpen(Queue.failCause(queue, cause));
|
|
2894
|
+
}
|
|
2895
|
+
return Queue.failCause(queue, cause);
|
|
2896
|
+
}), Effect.forkIn(forkedScope));
|
|
2800
2897
|
return Queue.take(queue);
|
|
2801
2898
|
})));
|
|
2802
2899
|
/**
|
|
@@ -2805,24 +2902,18 @@ export const mergeAll = /*#__PURE__*/dual(2, (channels, {
|
|
|
2805
2902
|
*
|
|
2806
2903
|
* **Example** (Merging channels)
|
|
2807
2904
|
*
|
|
2808
|
-
* ```ts
|
|
2809
|
-
* import { Channel,
|
|
2810
|
-
*
|
|
2811
|
-
* class MergeError extends Data.TaggedError("MergeError")<{
|
|
2812
|
-
* readonly source: string
|
|
2813
|
-
* }> {}
|
|
2905
|
+
* ```ts import.meta.vitest
|
|
2906
|
+
* import { Channel, Effect } from "effect"
|
|
2814
2907
|
*
|
|
2815
2908
|
* // Create two channels
|
|
2816
2909
|
* const leftChannel = Channel.fromIterable([1, 2, 3])
|
|
2817
2910
|
* const rightChannel = Channel.fromIterable(["a", "b", "c"])
|
|
2818
2911
|
*
|
|
2819
|
-
* //
|
|
2820
|
-
* const mergedChannel = Channel.merge(leftChannel, rightChannel
|
|
2821
|
-
* haltStrategy: "either"
|
|
2822
|
-
* })
|
|
2912
|
+
* // The default "both" strategy waits for both channels to complete
|
|
2913
|
+
* const mergedChannel = Channel.merge(leftChannel, rightChannel)
|
|
2823
2914
|
*
|
|
2824
|
-
*
|
|
2825
|
-
* //
|
|
2915
|
+
* const values = await Effect.runPromise(Channel.runCollect(mergedChannel))
|
|
2916
|
+
* values.map(String).sort() // => ["1", "2", "3", "a", "b", "c"]
|
|
2826
2917
|
* ```
|
|
2827
2918
|
*
|
|
2828
2919
|
* @category combining
|
|
@@ -2893,19 +2984,16 @@ export const mergeEffect = /*#__PURE__*/dual(2, (self, effect) => merge(self, fr
|
|
|
2893
2984
|
*
|
|
2894
2985
|
* **Example** (Splitting string chunks into lines)
|
|
2895
2986
|
*
|
|
2896
|
-
* ```ts
|
|
2987
|
+
* ```ts import.meta.vitest
|
|
2897
2988
|
* import { Effect, Stream } from "effect"
|
|
2898
2989
|
*
|
|
2899
|
-
* Effect.runPromise(
|
|
2900
|
-
*
|
|
2901
|
-
*
|
|
2902
|
-
*
|
|
2903
|
-
* console.log(result)
|
|
2904
|
-
* // [ 'hello', 'world' ]
|
|
2905
|
-
* }))
|
|
2990
|
+
* const result = await Effect.runPromise(Stream.runCollect(
|
|
2991
|
+
* Stream.splitLines(Stream.make("hel", "lo\r\nwor", "ld\n"))
|
|
2992
|
+
* ))
|
|
2993
|
+
* result // => ["hello", "world"]
|
|
2906
2994
|
* ```
|
|
2907
2995
|
*
|
|
2908
|
-
* @category
|
|
2996
|
+
* @category splitting
|
|
2909
2997
|
* @since 2.0.0
|
|
2910
2998
|
*/
|
|
2911
2999
|
export const splitLines = () => fromTransform((upstream, _scope) => Effect.sync(() => {
|
|
@@ -3002,7 +3090,7 @@ export const splitLines = () => fromTransform((upstream, _scope) => Effect.sync(
|
|
|
3002
3090
|
* span `Uint8Array` boundaries. The optional `encoding` and `options` are
|
|
3003
3091
|
* passed to `TextDecoder`.
|
|
3004
3092
|
*
|
|
3005
|
-
* @category
|
|
3093
|
+
* @category decoding
|
|
3006
3094
|
* @since 4.0.0
|
|
3007
3095
|
*/
|
|
3008
3096
|
export const decodeText = (encoding, options) => fromTransform((upstream, _scope) => Effect.sync(() => {
|
|
@@ -3019,7 +3107,7 @@ export const decodeText = (encoding, options) => fromTransform((upstream, _scope
|
|
|
3019
3107
|
*
|
|
3020
3108
|
* Each string inside an emitted array is encoded independently.
|
|
3021
3109
|
*
|
|
3022
|
-
* @category
|
|
3110
|
+
* @category encoding
|
|
3023
3111
|
* @since 4.0.0
|
|
3024
3112
|
*/
|
|
3025
3113
|
export const encodeText = () => fromTransform((upstream, _scope) => Effect.sync(() => {
|
|
@@ -3034,8 +3122,8 @@ export const encodeText = () => fromTransform((upstream, _scope) => Effect.sync(
|
|
|
3034
3122
|
*
|
|
3035
3123
|
* **Example** (Piping one channel into another)
|
|
3036
3124
|
*
|
|
3037
|
-
* ```ts
|
|
3038
|
-
* import { Channel, Data } from "effect"
|
|
3125
|
+
* ```ts import.meta.vitest
|
|
3126
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3039
3127
|
*
|
|
3040
3128
|
* class PipeError extends Data.TaggedError("PipeError")<{
|
|
3041
3129
|
* readonly stage: string
|
|
@@ -3048,7 +3136,7 @@ export const encodeText = () => fromTransform((upstream, _scope) => Effect.sync(
|
|
|
3048
3136
|
* // Pipe the source into the transform
|
|
3049
3137
|
* const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel)
|
|
3050
3138
|
*
|
|
3051
|
-
* //
|
|
3139
|
+
* Effect.runSync(Channel.runCollect(pipedChannel)) // => [2, 4, 6]
|
|
3052
3140
|
* ```
|
|
3053
3141
|
*
|
|
3054
3142
|
* @category sequencing
|
|
@@ -3062,21 +3150,22 @@ export const pipeTo = /*#__PURE__*/dual(2, (self, that) => fromTransform((upstre
|
|
|
3062
3150
|
*
|
|
3063
3151
|
* **Example** (Piping while preserving failures)
|
|
3064
3152
|
*
|
|
3065
|
-
* ```ts
|
|
3066
|
-
* import { Channel, Data } from "effect"
|
|
3153
|
+
* ```ts import.meta.vitest
|
|
3154
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
3067
3155
|
*
|
|
3068
3156
|
* class SourceError extends Data.TaggedError("SourceError")<{
|
|
3069
3157
|
* readonly code: number
|
|
3070
3158
|
* }> {}
|
|
3071
3159
|
*
|
|
3072
3160
|
* // Create a failing source channel
|
|
3073
|
-
* const
|
|
3074
|
-
* const
|
|
3161
|
+
* const error = new SourceError({ code: 404 })
|
|
3162
|
+
* const failingSource = Channel.fail(error)
|
|
3163
|
+
* const safeTransform = Channel.identity<never, never, never>()
|
|
3075
3164
|
*
|
|
3076
3165
|
* // Pipe while preserving source failures
|
|
3077
3166
|
* const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform)
|
|
3078
3167
|
*
|
|
3079
|
-
* //
|
|
3168
|
+
* Effect.runSync(Effect.exit(Channel.runCollect(safePipedChannel))) // => Exit.fail(error)
|
|
3080
3169
|
* ```
|
|
3081
3170
|
*
|
|
3082
3171
|
* @category sequencing
|
|
@@ -3092,7 +3181,7 @@ export const pipeToOrFail = /*#__PURE__*/dual(2, (self, that) => fromTransform((
|
|
|
3092
3181
|
*
|
|
3093
3182
|
* **Example** (Unwrapping channel effects)
|
|
3094
3183
|
*
|
|
3095
|
-
* ```ts
|
|
3184
|
+
* ```ts import.meta.vitest
|
|
3096
3185
|
* import { Channel, Data, Effect } from "effect"
|
|
3097
3186
|
*
|
|
3098
3187
|
* class UnwrapError extends Data.TaggedError("UnwrapError")<{
|
|
@@ -3107,7 +3196,7 @@ export const pipeToOrFail = /*#__PURE__*/dual(2, (self, that) => fromTransform((
|
|
|
3107
3196
|
* // Unwrap the effect to get the channel
|
|
3108
3197
|
* const unwrappedChannel = Channel.unwrap(channelEffect)
|
|
3109
3198
|
*
|
|
3110
|
-
* //
|
|
3199
|
+
* Effect.runSync(Channel.runCollect(unwrappedChannel)) // => [1, 2, 3]
|
|
3111
3200
|
* ```
|
|
3112
3201
|
*
|
|
3113
3202
|
* @category constructors
|
|
@@ -3139,7 +3228,7 @@ export const scoped = self => fromTransformBracket((upstream, scope, forkedScope
|
|
|
3139
3228
|
*
|
|
3140
3229
|
* **Example** (Embedding custom input handling)
|
|
3141
3230
|
*
|
|
3142
|
-
* ```ts
|
|
3231
|
+
* ```ts import.meta.vitest
|
|
3143
3232
|
* import { Channel, Effect } from "effect"
|
|
3144
3233
|
*
|
|
3145
3234
|
* // Create a base channel
|
|
@@ -3150,13 +3239,11 @@ export const scoped = self => fromTransformBracket((upstream, scope, forkedScope
|
|
|
3150
3239
|
* baseChannel,
|
|
3151
3240
|
* (upstream) =>
|
|
3152
3241
|
* upstream.pipe(
|
|
3153
|
-
* Effect.tap((message) =>
|
|
3154
|
-
* Effect.sync(() => console.log(message))
|
|
3155
|
-
* ),
|
|
3156
3242
|
* Effect.forever,
|
|
3157
3243
|
* Effect.ignore
|
|
3158
3244
|
* )
|
|
3159
3245
|
* )
|
|
3246
|
+
* await Effect.runPromise(Channel.runCollect(embeddedChannel)) // => [1, 2, 3]
|
|
3160
3247
|
* ```
|
|
3161
3248
|
*
|
|
3162
3249
|
* @category sequencing
|
|
@@ -3185,7 +3272,7 @@ export const embedInput = /*#__PURE__*/dual(2, (self, input) => fromTransformBra
|
|
|
3185
3272
|
*
|
|
3186
3273
|
* @see {@link bufferArray} for buffering elements from array outputs
|
|
3187
3274
|
*
|
|
3188
|
-
* @category
|
|
3275
|
+
* @category buffering
|
|
3189
3276
|
* @since 2.0.0
|
|
3190
3277
|
*/
|
|
3191
3278
|
export const buffer = /*#__PURE__*/dual(2, (self, options) => fromTransform(Effect.fnUntraced(function* (upstream, scope) {
|
|
@@ -3224,7 +3311,7 @@ export const buffer = /*#__PURE__*/dual(2, (self, options) => fromTransform(Effe
|
|
|
3224
3311
|
*
|
|
3225
3312
|
* @see {@link buffer} for buffering output elements without flattening arrays
|
|
3226
3313
|
*
|
|
3227
|
-
* @category
|
|
3314
|
+
* @category buffering
|
|
3228
3315
|
* @since 4.0.0
|
|
3229
3316
|
*/
|
|
3230
3317
|
export const bufferArray = /*#__PURE__*/dual(2, (self, options) => fromTransform(Effect.fnUntraced(function* (upstream, scope) {
|
|
@@ -3274,12 +3361,16 @@ export const interruptWhen = /*#__PURE__*/dual(2, (self, effect) => merge(self,
|
|
|
3274
3361
|
*/
|
|
3275
3362
|
export const haltWhen = /*#__PURE__*/dual(2, (self, effect) => fromTransformBracket(Effect.fnUntraced(function* (upstream, scope, forkedScope) {
|
|
3276
3363
|
const pull = yield* toTransform(self)(upstream, scope);
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3364
|
+
const fiber = yield* Effect.forkIn(effect, forkedScope, {
|
|
3365
|
+
startImmediately: true
|
|
3366
|
+
});
|
|
3367
|
+
return Effect.suspend(() => {
|
|
3368
|
+
const exit = fiber.pollUnsafe();
|
|
3369
|
+
return exit === undefined ? pull : Exit.match(exit, {
|
|
3370
|
+
onFailure: Effect.failCause,
|
|
3371
|
+
onSuccess: Cause.done
|
|
3372
|
+
});
|
|
3373
|
+
});
|
|
3283
3374
|
})));
|
|
3284
3375
|
/**
|
|
3285
3376
|
* Attaches a finalizer that runs only when the channel exits with failure.
|
|
@@ -3299,8 +3390,8 @@ export const onError = /*#__PURE__*/dual(2, (self, finalizer) => onExit(self, ex
|
|
|
3299
3390
|
*
|
|
3300
3391
|
* **Example** (Running exit finalizers)
|
|
3301
3392
|
*
|
|
3302
|
-
* ```ts
|
|
3303
|
-
* import { Channel,
|
|
3393
|
+
* ```ts import.meta.vitest
|
|
3394
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
3304
3395
|
*
|
|
3305
3396
|
* class ExitError extends Data.TaggedError("ExitError")<{
|
|
3306
3397
|
* readonly stage: string
|
|
@@ -3310,13 +3401,12 @@ export const onError = /*#__PURE__*/dual(2, (self, finalizer) => onExit(self, ex
|
|
|
3310
3401
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
3311
3402
|
*
|
|
3312
3403
|
* // Attach exit handler
|
|
3404
|
+
* const exits: Array<Exit.Exit<void, ExitError>> = []
|
|
3313
3405
|
* const channelWithExit = Channel.onExit(dataChannel, (exit) => {
|
|
3314
|
-
*
|
|
3315
|
-
*
|
|
3316
|
-
* } else {
|
|
3317
|
-
* return Console.log(`Channel failed with: ${exit.cause}`)
|
|
3318
|
-
* }
|
|
3406
|
+
* exits.push(exit)
|
|
3407
|
+
* return Effect.void
|
|
3319
3408
|
* })
|
|
3409
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithExit)), exits] // => [[1, 2, 3], [Exit.void]]
|
|
3320
3410
|
* ```
|
|
3321
3411
|
*
|
|
3322
3412
|
* @category resource management
|
|
@@ -3379,8 +3469,8 @@ export const onEnd = /*#__PURE__*/dual(2, (self, onEnd) => transformPull(self, p
|
|
|
3379
3469
|
*
|
|
3380
3470
|
* **Example** (Ensuring cleanup runs)
|
|
3381
3471
|
*
|
|
3382
|
-
* ```ts
|
|
3383
|
-
* import { Channel,
|
|
3472
|
+
* ```ts import.meta.vitest
|
|
3473
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3384
3474
|
*
|
|
3385
3475
|
* class EnsureError extends Data.TaggedError("EnsureError")<{
|
|
3386
3476
|
* readonly operation: string
|
|
@@ -3390,10 +3480,12 @@ export const onEnd = /*#__PURE__*/dual(2, (self, onEnd) => transformPull(self, p
|
|
|
3390
3480
|
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
3391
3481
|
*
|
|
3392
3482
|
* // Ensure cleanup always runs
|
|
3483
|
+
* const events: Array<string> = []
|
|
3393
3484
|
* const channelWithCleanup = Channel.ensuring(
|
|
3394
3485
|
* dataChannel,
|
|
3395
|
-
*
|
|
3486
|
+
* Effect.sync(() => events.push("cleanup"))
|
|
3396
3487
|
* )
|
|
3488
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithCleanup)), events] // => [[1, 2, 3], ["cleanup"]]
|
|
3397
3489
|
* ```
|
|
3398
3490
|
*
|
|
3399
3491
|
* @category resource management
|
|
@@ -3408,7 +3500,7 @@ const runWith = (self, f, onHalt) => Effect.suspend(() => {
|
|
|
3408
3500
|
/**
|
|
3409
3501
|
* Creates a channel from the specified services.
|
|
3410
3502
|
*
|
|
3411
|
-
* @category
|
|
3503
|
+
* @category accessors
|
|
3412
3504
|
* @since 2.0.0
|
|
3413
3505
|
*/
|
|
3414
3506
|
export const contextWith = f => fromTransform((upstream, scope) => Effect.contextWith(context => toTransform(f(context))(upstream, scope)));
|
|
@@ -3416,7 +3508,7 @@ export const contextWith = f => fromTransform((upstream, scope) => Effect.contex
|
|
|
3416
3508
|
* Provides a `Context` to the channel, removing the corresponding service
|
|
3417
3509
|
* requirements from the returned channel.
|
|
3418
3510
|
*
|
|
3419
|
-
* @category services
|
|
3511
|
+
* @category providing services
|
|
3420
3512
|
* @since 2.0.0
|
|
3421
3513
|
*/
|
|
3422
3514
|
export const provideContext = /*#__PURE__*/dual(2, (self, context) => fromTransform((upstream, scope) => Effect.map(Effect.provideContext(toTransform(self)(upstream, scope), context), Effect.provideContext(context))));
|
|
@@ -3424,7 +3516,7 @@ export const provideContext = /*#__PURE__*/dual(2, (self, context) => fromTransf
|
|
|
3424
3516
|
* Provides a concrete service for a context key, removing that service
|
|
3425
3517
|
* requirement from the returned channel.
|
|
3426
3518
|
*
|
|
3427
|
-
* @category services
|
|
3519
|
+
* @category providing services
|
|
3428
3520
|
* @since 2.0.0
|
|
3429
3521
|
*/
|
|
3430
3522
|
export const provideService = /*#__PURE__*/dual(3, (self, key, service) => fromTransform((upstream, scope) => Effect.map(Effect.provideService(toTransform(self)(upstream, scope), key, service), Effect.provideService(key, service))));
|
|
@@ -3441,7 +3533,7 @@ export const provideService = /*#__PURE__*/dual(3, (self, key, service) => fromT
|
|
|
3441
3533
|
* If the service effect fails, the returned channel fails. The provided service
|
|
3442
3534
|
* removes the corresponding service requirement from the returned channel.
|
|
3443
3535
|
*
|
|
3444
|
-
* @category services
|
|
3536
|
+
* @category providing services
|
|
3445
3537
|
* @since 4.0.0
|
|
3446
3538
|
*/
|
|
3447
3539
|
export const provideServiceEffect = /*#__PURE__*/dual(3, (self, key, service) => fromTransform((upstream, scope) => Effect.flatMap(service, s => toTransform(provideService(self, key, s))(upstream, scope))));
|
|
@@ -3455,7 +3547,7 @@ export const provideServiceEffect = /*#__PURE__*/dual(3, (self, key, service) =>
|
|
|
3455
3547
|
* builds the layer in the channel scope. Use `options.local` to build a fresh
|
|
3456
3548
|
* layer instance for this provision.
|
|
3457
3549
|
*
|
|
3458
|
-
* @category services
|
|
3550
|
+
* @category providing services
|
|
3459
3551
|
* @since 4.0.0
|
|
3460
3552
|
*/
|
|
3461
3553
|
export const provide = /*#__PURE__*/dual(args => isChannel(args[0]), (self, layer, options) => Context.isContext(layer) ? provideContext(self, layer) : fromTransform((upstream, scope) => Effect.flatMap(options?.local ? Layer.buildWithMemoMap(layer, Layer.makeMemoMapUnsafe(), scope) : Layer.buildWithScope(layer, scope), context => Effect.map(Effect.provideContext(toTransform(self)(upstream, scope), context), Effect.provideContext(context)))));
|
|
@@ -3468,7 +3560,7 @@ export const provide = /*#__PURE__*/dual(args => isChannel(args[0]), (self, laye
|
|
|
3468
3560
|
* provide to the channel. The returned channel requires the services needed to
|
|
3469
3561
|
* build that context.
|
|
3470
3562
|
*
|
|
3471
|
-
* @category services
|
|
3563
|
+
* @category providing services
|
|
3472
3564
|
* @since 4.0.0
|
|
3473
3565
|
*/
|
|
3474
3566
|
export const updateContext = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstream, scope) => Effect.contextWith(context => {
|
|
@@ -3483,7 +3575,7 @@ export const updateContext = /*#__PURE__*/dual(2, (self, f) => fromTransform((up
|
|
|
3483
3575
|
* The existing service is read from the context. The updated service is
|
|
3484
3576
|
* provided to the channel under the same key.
|
|
3485
3577
|
*
|
|
3486
|
-
* @category services
|
|
3578
|
+
* @category providing services
|
|
3487
3579
|
* @since 2.0.0
|
|
3488
3580
|
*/
|
|
3489
3581
|
export const updateService = /*#__PURE__*/dual(3, (self, service, f) => updateContext(self, context => Context.add(context, service, f(Context.get(context, service)))));
|
|
@@ -3516,7 +3608,7 @@ const withSpanImpl = (self, name, options) => acquireUseRelease(Effect.makeSpan(
|
|
|
3516
3608
|
/**
|
|
3517
3609
|
* The starting channel for Do notation, emitting an empty object.
|
|
3518
3610
|
*
|
|
3519
|
-
* @category
|
|
3611
|
+
* @category constructors
|
|
3520
3612
|
* @since 4.0.0
|
|
3521
3613
|
*/
|
|
3522
3614
|
export const Do = /*#__PURE__*/succeed({});
|
|
@@ -3528,7 +3620,7 @@ export {
|
|
|
3528
3620
|
/**
|
|
3529
3621
|
* Adds a computed field to each object emitted by a channel.
|
|
3530
3622
|
*
|
|
3531
|
-
* @category
|
|
3623
|
+
* @category mapping
|
|
3532
3624
|
* @since 4.0.0
|
|
3533
3625
|
*/
|
|
3534
3626
|
let_ as let };
|
|
@@ -3542,7 +3634,7 @@ let_ as let };
|
|
|
3542
3634
|
* channel's output becomes the value of the new field. `options.concurrency`
|
|
3543
3635
|
* and `options.bufferSize` control how derived channels are flattened.
|
|
3544
3636
|
*
|
|
3545
|
-
* @category
|
|
3637
|
+
* @category sequencing
|
|
3546
3638
|
* @since 4.0.0
|
|
3547
3639
|
*/
|
|
3548
3640
|
export const bind = /*#__PURE__*/dual(args => isChannel(args[0]), (self, name, f, options) => flatMap(self, elem => map(f(elem), b => ({
|
|
@@ -3561,7 +3653,7 @@ export const bind = /*#__PURE__*/dual(args => isChannel(args[0]), (self, name, f
|
|
|
3561
3653
|
* @see {@link bind} for adding a field produced by another channel
|
|
3562
3654
|
* @see {@link let_ let} for adding a computed field
|
|
3563
3655
|
*
|
|
3564
|
-
* @category
|
|
3656
|
+
* @category mapping
|
|
3565
3657
|
* @since 4.0.0
|
|
3566
3658
|
*/
|
|
3567
3659
|
export const bindTo = /*#__PURE__*/dual(2, (self, name) => map(self, elem => ({
|
|
@@ -3572,8 +3664,8 @@ export const bindTo = /*#__PURE__*/dual(2, (self, name) => map(self, elem => ({
|
|
|
3572
3664
|
*
|
|
3573
3665
|
* **Example** (Counting channel output)
|
|
3574
3666
|
*
|
|
3575
|
-
* ```ts
|
|
3576
|
-
* import { Channel, Data } from "effect"
|
|
3667
|
+
* ```ts import.meta.vitest
|
|
3668
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3577
3669
|
*
|
|
3578
3670
|
* class CountError extends Data.TaggedError("CountError")<{
|
|
3579
3671
|
* readonly reason: string
|
|
@@ -3585,10 +3677,10 @@ export const bindTo = /*#__PURE__*/dual(2, (self, name) => map(self, elem => ({
|
|
|
3585
3677
|
* // Count the elements
|
|
3586
3678
|
* const countEffect = Channel.runCount(numbersChannel)
|
|
3587
3679
|
*
|
|
3588
|
-
*
|
|
3680
|
+
* Effect.runSync(countEffect) // => 5
|
|
3589
3681
|
* ```
|
|
3590
3682
|
*
|
|
3591
|
-
* @category
|
|
3683
|
+
* @category running
|
|
3592
3684
|
* @since 4.0.0
|
|
3593
3685
|
*/
|
|
3594
3686
|
export const runCount = self => runFold(self, () => 0, acc => acc + 1);
|
|
@@ -3597,8 +3689,8 @@ export const runCount = self => runFold(self, () => 0, acc => acc + 1);
|
|
|
3597
3689
|
*
|
|
3598
3690
|
* **Example** (Draining channel output at runtime)
|
|
3599
3691
|
*
|
|
3600
|
-
* ```ts
|
|
3601
|
-
* import { Channel, Data } from "effect"
|
|
3692
|
+
* ```ts import.meta.vitest
|
|
3693
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3602
3694
|
*
|
|
3603
3695
|
* class DrainError extends Data.TaggedError("DrainError")<{
|
|
3604
3696
|
* readonly stage: string
|
|
@@ -3606,18 +3698,15 @@ export const runCount = self => runFold(self, () => 0, acc => acc + 1);
|
|
|
3606
3698
|
*
|
|
3607
3699
|
* // Create a channel that outputs elements and completes with a result
|
|
3608
3700
|
* const resultChannel = Channel.fromIterable([1, 2, 3])
|
|
3609
|
-
* const completedChannel = Channel.
|
|
3610
|
-
* resultChannel,
|
|
3611
|
-
* () => Channel.succeed("completed")
|
|
3612
|
-
* )
|
|
3701
|
+
* const completedChannel = Channel.concat(resultChannel, Channel.end("completed"))
|
|
3613
3702
|
*
|
|
3614
3703
|
* // Drain all elements and get only the final result
|
|
3615
3704
|
* const drainEffect = Channel.runDrain(completedChannel)
|
|
3616
3705
|
*
|
|
3617
|
-
*
|
|
3706
|
+
* Effect.runSync(drainEffect) // => "completed"
|
|
3618
3707
|
* ```
|
|
3619
3708
|
*
|
|
3620
|
-
* @category
|
|
3709
|
+
* @category running
|
|
3621
3710
|
* @since 2.0.0
|
|
3622
3711
|
*/
|
|
3623
3712
|
export const runDrain = self => runWith(self, pull => Effect.forever(pull, {
|
|
@@ -3628,8 +3717,8 @@ export const runDrain = self => runWith(self, pull => Effect.forever(pull, {
|
|
|
3628
3717
|
*
|
|
3629
3718
|
* **Example** (Running effects for each output)
|
|
3630
3719
|
*
|
|
3631
|
-
* ```ts
|
|
3632
|
-
* import { Channel,
|
|
3720
|
+
* ```ts import.meta.vitest
|
|
3721
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3633
3722
|
*
|
|
3634
3723
|
* class ForEachError extends Data.TaggedError("ForEachError")<{
|
|
3635
3724
|
* readonly element: unknown
|
|
@@ -3638,16 +3727,18 @@ export const runDrain = self => runWith(self, pull => Effect.forever(pull, {
|
|
|
3638
3727
|
* // Create a channel with numbers
|
|
3639
3728
|
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
3640
3729
|
*
|
|
3641
|
-
* // Run forEach to
|
|
3730
|
+
* // Run forEach to process each element
|
|
3731
|
+
* const processed: Array<number> = []
|
|
3642
3732
|
* const forEachEffect = Channel.runForEach(
|
|
3643
3733
|
* numbersChannel,
|
|
3644
|
-
* (n) =>
|
|
3734
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
3645
3735
|
* )
|
|
3646
3736
|
*
|
|
3647
|
-
*
|
|
3737
|
+
* await Effect.runPromise(forEachEffect)
|
|
3738
|
+
* processed // => [1, 2, 3]
|
|
3648
3739
|
* ```
|
|
3649
3740
|
*
|
|
3650
|
-
* @category
|
|
3741
|
+
* @category running
|
|
3651
3742
|
* @since 4.0.0
|
|
3652
3743
|
*/
|
|
3653
3744
|
export const runForEach = /*#__PURE__*/dual(2, (self, f) => runWith(self, pull => Effect.forever(Effect.flatMap(pull, f), {
|
|
@@ -3662,7 +3753,7 @@ export const runForEach = /*#__PURE__*/dual(2, (self, f) => runWith(self, pull =
|
|
|
3662
3753
|
* Returning `true` continues consuming the channel. Returning `false` stops
|
|
3663
3754
|
* consumption early. The returned effect completes with `void`.
|
|
3664
3755
|
*
|
|
3665
|
-
* @category
|
|
3756
|
+
* @category running
|
|
3666
3757
|
* @since 4.0.0
|
|
3667
3758
|
*/
|
|
3668
3759
|
export const runForEachWhile = /*#__PURE__*/dual(2, (self, f) => runWith(self, pull => pull.pipe(Effect.flatMap(f), Effect.flatMap(cont => cont ? Effect.void : Cause.done()), Effect.forever({
|
|
@@ -3673,8 +3764,8 @@ export const runForEachWhile = /*#__PURE__*/dual(2, (self, f) => runWith(self, p
|
|
|
3673
3764
|
*
|
|
3674
3765
|
* **Example** (Collecting channel output)
|
|
3675
3766
|
*
|
|
3676
|
-
* ```ts
|
|
3677
|
-
* import { Channel, Data } from "effect"
|
|
3767
|
+
* ```ts import.meta.vitest
|
|
3768
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3678
3769
|
*
|
|
3679
3770
|
* class CollectError extends Data.TaggedError("CollectError")<{
|
|
3680
3771
|
* readonly reason: string
|
|
@@ -3686,10 +3777,10 @@ export const runForEachWhile = /*#__PURE__*/dual(2, (self, f) => runWith(self, p
|
|
|
3686
3777
|
* // Collect all elements into an array
|
|
3687
3778
|
* const collectEffect = Channel.runCollect(numbersChannel)
|
|
3688
3779
|
*
|
|
3689
|
-
*
|
|
3780
|
+
* Effect.runSync(collectEffect) // => [1, 2, 3, 4, 5]
|
|
3690
3781
|
* ```
|
|
3691
3782
|
*
|
|
3692
|
-
* @category
|
|
3783
|
+
* @category running
|
|
3693
3784
|
* @since 2.0.0
|
|
3694
3785
|
*/
|
|
3695
3786
|
export const runCollect = self => runFold(self, () => [], (acc, o) => {
|
|
@@ -3699,7 +3790,7 @@ export const runCollect = self => runFold(self, () => [], (acc, o) => {
|
|
|
3699
3790
|
/**
|
|
3700
3791
|
* Runs a channel and outputs the done value.
|
|
3701
3792
|
*
|
|
3702
|
-
* @category
|
|
3793
|
+
* @category running
|
|
3703
3794
|
* @since 4.0.0
|
|
3704
3795
|
*/
|
|
3705
3796
|
export const runDone = self => runWith(self, identity_, Effect.succeed);
|
|
@@ -3712,7 +3803,7 @@ export const runDone = self => runWith(self, identity_, Effect.succeed);
|
|
|
3712
3803
|
* Returns `Option.some` with the first output element, or `Option.none` if the
|
|
3713
3804
|
* channel completes without emitting output.
|
|
3714
3805
|
*
|
|
3715
|
-
* @category
|
|
3806
|
+
* @category running
|
|
3716
3807
|
* @since 4.0.0
|
|
3717
3808
|
*/
|
|
3718
3809
|
export const runHead = self => Effect.suspend(() => {
|
|
@@ -3731,7 +3822,7 @@ export const runHead = self => Effect.suspend(() => {
|
|
|
3731
3822
|
* Returns `Option.some` with the last emitted element, or `Option.none` if the
|
|
3732
3823
|
* channel completes without emitting output.
|
|
3733
3824
|
*
|
|
3734
|
-
* @category
|
|
3825
|
+
* @category running
|
|
3735
3826
|
* @since 4.0.0
|
|
3736
3827
|
*/
|
|
3737
3828
|
export const runLast = self => Effect.suspend(() => {
|
|
@@ -3749,8 +3840,8 @@ export const runLast = self => Effect.suspend(() => {
|
|
|
3749
3840
|
*
|
|
3750
3841
|
* **Example** (Folding channel output)
|
|
3751
3842
|
*
|
|
3752
|
-
* ```ts
|
|
3753
|
-
* import { Channel, Data } from "effect"
|
|
3843
|
+
* ```ts import.meta.vitest
|
|
3844
|
+
* import { Channel, Data, Effect } from "effect"
|
|
3754
3845
|
*
|
|
3755
3846
|
* class FoldError extends Data.TaggedError("FoldError")<{
|
|
3756
3847
|
* readonly operation: string
|
|
@@ -3762,10 +3853,10 @@ export const runLast = self => Effect.suspend(() => {
|
|
|
3762
3853
|
* // Fold to calculate sum
|
|
3763
3854
|
* const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n)
|
|
3764
3855
|
*
|
|
3765
|
-
*
|
|
3856
|
+
* Effect.runSync(sumEffect) // => 15
|
|
3766
3857
|
* ```
|
|
3767
3858
|
*
|
|
3768
|
-
* @category
|
|
3859
|
+
* @category running
|
|
3769
3860
|
* @since 4.0.0
|
|
3770
3861
|
*/
|
|
3771
3862
|
export const runFold = /*#__PURE__*/dual(3, (self, initial, f) => Effect.suspend(() => {
|
|
@@ -3792,7 +3883,7 @@ export const runFold = /*#__PURE__*/dual(3, (self, initial, f) => Effect.suspend
|
|
|
3792
3883
|
* the effectful accumulator function. The returned effect succeeds with the
|
|
3793
3884
|
* final accumulator value.
|
|
3794
3885
|
*
|
|
3795
|
-
* @category
|
|
3886
|
+
* @category running
|
|
3796
3887
|
* @since 4.0.0
|
|
3797
3888
|
*/
|
|
3798
3889
|
export const runFoldEffect = /*#__PURE__*/dual(3, (self, initial, f) => Effect.suspend(() => {
|
|
@@ -3816,7 +3907,7 @@ export const runFoldEffect = /*#__PURE__*/dual(3, (self, initial, f) => Effect.s
|
|
|
3816
3907
|
*
|
|
3817
3908
|
* **Example** (Converting channels to pulls)
|
|
3818
3909
|
*
|
|
3819
|
-
* ```ts
|
|
3910
|
+
* ```ts import.meta.vitest
|
|
3820
3911
|
* import { Channel, Data, Effect } from "effect"
|
|
3821
3912
|
*
|
|
3822
3913
|
* class PullError extends Data.TaggedError("PullError")<{
|
|
@@ -3826,12 +3917,11 @@ export const runFoldEffect = /*#__PURE__*/dual(3, (self, initial, f) => Effect.s
|
|
|
3826
3917
|
* // Create a channel
|
|
3827
3918
|
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
3828
3919
|
*
|
|
3829
|
-
*
|
|
3830
|
-
*
|
|
3831
|
-
*
|
|
3832
|
-
* )
|
|
3833
|
-
*
|
|
3834
|
-
* // Use the Pull to manually consume elements
|
|
3920
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
3921
|
+
* const pull = yield* Channel.toPull(numbersChannel)
|
|
3922
|
+
* return [yield* pull, yield* pull, yield* pull]
|
|
3923
|
+
* }))
|
|
3924
|
+
* await Effect.runPromise(program) // => [1, 2, 3]
|
|
3835
3925
|
* ```
|
|
3836
3926
|
*
|
|
3837
3927
|
* @category destructors
|
|
@@ -3852,7 +3942,7 @@ Effect.catchCause(cause => Effect.succeed(Effect.failCause(cause))));
|
|
|
3852
3942
|
*
|
|
3853
3943
|
* **Example** (Converting channels to scoped pulls)
|
|
3854
3944
|
*
|
|
3855
|
-
* ```ts
|
|
3945
|
+
* ```ts import.meta.vitest
|
|
3856
3946
|
* import { Channel, Data, Effect, Scope } from "effect"
|
|
3857
3947
|
*
|
|
3858
3948
|
* class ScopedPullError extends Data.TaggedError("ScopedPullError")<{
|
|
@@ -3864,10 +3954,11 @@ Effect.catchCause(cause => Effect.succeed(Effect.failCause(cause))));
|
|
|
3864
3954
|
*
|
|
3865
3955
|
* // Convert to Pull with explicit scope
|
|
3866
3956
|
* const scopedPullEffect = Effect.gen(function*() {
|
|
3867
|
-
* const scope = yield*
|
|
3957
|
+
* const scope = yield* Effect.scope
|
|
3868
3958
|
* const pull = yield* Channel.toPullScoped(numbersChannel, scope)
|
|
3869
|
-
* return pull
|
|
3959
|
+
* return [yield* pull, yield* pull, yield* pull]
|
|
3870
3960
|
* })
|
|
3961
|
+
* await Effect.runPromise(Effect.scoped(scopedPullEffect)) // => [1, 2, 3]
|
|
3871
3962
|
* ```
|
|
3872
3963
|
*
|
|
3873
3964
|
* @category destructors
|
|
@@ -3927,8 +4018,8 @@ export const runIntoQueueArray = /*#__PURE__*/dual(args => isChannel(args[0]), (
|
|
|
3927
4018
|
*
|
|
3928
4019
|
* **Example** (Converting channels to queues)
|
|
3929
4020
|
*
|
|
3930
|
-
* ```ts
|
|
3931
|
-
* import { Channel, Data } from "effect"
|
|
4021
|
+
* ```ts import.meta.vitest
|
|
4022
|
+
* import { Channel, Data, Effect, Queue } from "effect"
|
|
3932
4023
|
*
|
|
3933
4024
|
* class QueueError extends Data.TaggedError("QueueError")<{
|
|
3934
4025
|
* readonly operation: string
|
|
@@ -3938,10 +4029,11 @@ export const runIntoQueueArray = /*#__PURE__*/dual(args => isChannel(args[0]), (
|
|
|
3938
4029
|
* const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
3939
4030
|
*
|
|
3940
4031
|
* // Convert to queue for concurrent processing
|
|
3941
|
-
* const
|
|
3942
|
-
*
|
|
3943
|
-
*
|
|
3944
|
-
*
|
|
4032
|
+
* const program = Effect.scoped(Effect.gen(function*() {
|
|
4033
|
+
* const queue = yield* Channel.toQueue(dataChannel, { capacity: 32 })
|
|
4034
|
+
* return yield* Queue.takeBetween(queue, 5, 5)
|
|
4035
|
+
* }))
|
|
4036
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
3945
4037
|
* ```
|
|
3946
4038
|
*
|
|
3947
4039
|
* @category destructors
|