effect 4.0.0-beta.4 → 4.0.0-beta.40
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 +213 -385
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +149 -102
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +1 -1
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +6 -5
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +33 -2
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +19 -0
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +130 -35
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +96 -45
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +112 -304
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +56 -88
- package/dist/Chunk.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +169 -9
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +69 -11
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +11 -7
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +120 -63
- package/dist/Cron.js.map +1 -1
- package/dist/Data.d.ts +535 -366
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +132 -79
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +72 -253
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +15 -60
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +62 -32
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +108 -78
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +1224 -951
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +398 -338
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +124 -48
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +60 -3
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +70 -13
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +374 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +245 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/Exit.d.ts +24 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -4
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +5 -3
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +18 -17
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +17 -13
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +34 -38
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +229 -51
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +1 -9
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +2 -10
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +65 -65
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +60 -62
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +26 -19
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +7 -5
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +50 -50
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +106 -34
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +175 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +130 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Layer.d.ts +306 -129
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +92 -47
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +9 -8
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +3 -3
- package/dist/LayerMap.js.map +1 -1
- package/dist/LogLevel.d.ts +32 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +29 -95
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +2 -2
- package/dist/ManagedRuntime.js +2 -2
- package/dist/Metric.d.ts +4 -6
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +3 -5
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +7 -0
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +8 -0
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +7 -0
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +8 -0
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/Newtype.d.ts +291 -0
- package/dist/Newtype.d.ts.map +1 -0
- package/dist/Newtype.js +161 -0
- package/dist/Newtype.js.map +1 -0
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +947 -18
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +454 -5
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +25 -16
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +15 -9
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +6 -1
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +19 -14
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +146 -15
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +174 -61
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +10 -9
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +6 -4
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +7 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +8 -6
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -10
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +9 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +7 -5
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +35 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +63 -160
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +37 -56
- package/dist/Record.js.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/References.d.ts +242 -226
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +240 -247
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +25 -45
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +10 -30
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +2 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -2
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +66 -0
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +79 -6
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +174 -291
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +160 -134
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +34 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +31 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2722 -247
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +1947 -224
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +7 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +131 -25
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +18 -18
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts +44 -54
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +55 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +46 -45
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +49 -24
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +107 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +173 -13
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +307 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/Semaphore.js +222 -0
- package/dist/Semaphore.js.map +1 -0
- package/dist/ServiceMap.d.ts +67 -31
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +39 -24
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +18 -15
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +16 -4
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +18 -0
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +284 -431
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +189 -88
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +23 -7
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +3 -3
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +85 -117
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +44 -31
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +13 -9
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +197 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +159 -140
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +51 -44
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +36 -36
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +16 -15
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +416 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +170 -10
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +23 -8
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/Types.d.ts +80 -23
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts +137 -65
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -66
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +804 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +804 -53
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +77 -71
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +281 -201
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -5
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +3 -2
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.d.ts +2 -0
- package/dist/internal/references.d.ts.map +1 -0
- package/dist/internal/references.js +51 -0
- package/dist/internal/references.js.map +1 -0
- package/dist/internal/request.js +2 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/representation.js +47 -106
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/to-codec.js +7 -10
- package/dist/internal/schema/to-codec.js.map +1 -1
- package/dist/internal/trie.js +8 -7
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +8 -7
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +6 -4
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +266 -32
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +296 -23
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +64 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +64 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +136 -54
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +28 -23
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +7 -8
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +38 -44
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
- package/dist/unstable/ai/EmbeddingModel.js +127 -0
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
- package/dist/unstable/ai/LanguageModel.d.ts +53 -45
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +265 -143
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +183 -88
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +57 -12
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +66 -13
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +193 -51
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +26 -26
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- package/dist/unstable/ai/Tool.d.ts +34 -4
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +28 -10
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +4 -11
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +22 -1
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +22 -1
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +0 -5
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +27 -60
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +25 -57
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +65 -10
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +371 -58
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +328 -67
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +16 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +23 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
- package/dist/unstable/cli/GlobalFlag.js +118 -0
- package/dist/unstable/cli/GlobalFlag.js.map +1 -0
- package/dist/unstable/cli/HelpDoc.d.ts +81 -11
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +2 -2
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +258 -84
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +8 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +8 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +40 -14
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +72 -46
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +16 -4
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +42 -0
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +33 -0
- package/dist/unstable/cli/internal/help.d.ts.map +1 -0
- package/dist/unstable/cli/internal/help.js +125 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +61 -43
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +29 -26
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +10 -8
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +14 -13
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +14 -13
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +8 -7
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.d.ts.map +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.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +11 -9
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +3 -3
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +28 -20
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +26 -25
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +24 -24
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +14 -14
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +4 -3
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +9 -2
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +9 -9
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +4 -4
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
- package/dist/unstable/eventlog/EventJournal.js +2 -2
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +3 -2
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
- package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +52 -7
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +27 -6
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +19 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +40 -11
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts +117 -15
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +191 -13
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +131 -21
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +6 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -5
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +46 -54
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +24 -32
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +22 -34
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +39 -45
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +15 -3
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +301 -7
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +236 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
- package/dist/unstable/http/HttpStaticServer.js +353 -0
- package/dist/unstable/http/HttpStaticServer.js.map +1 -0
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +3 -3
- package/dist/unstable/http/Url.d.ts +604 -0
- package/dist/unstable/http/Url.d.ts.map +1 -0
- package/dist/unstable/http/Url.js +256 -0
- package/dist/unstable/http/Url.js.map +1 -0
- package/dist/unstable/http/UrlParams.d.ts +19 -10
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +6 -7
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +8 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +8 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +40 -27
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +78 -10
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +207 -101
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +49 -43
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +31 -14
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +125 -32
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +46 -15
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +32 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- 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 +5 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +34 -26
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +3 -3
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +12 -11
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +73 -12
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +108 -25
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +17 -15
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +45 -15
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +54 -11
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +47 -21
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +5 -5
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +10 -17
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +3 -5
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +17 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +39 -11
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +6 -10
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +20 -19
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +3 -2
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +22 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +15 -0
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +6 -6
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +6 -6
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +6 -5
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +12 -9
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.js +2 -2
- 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 +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +237 -17
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +260 -4
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +17 -8
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +17 -6
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/Statement.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +8 -8
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -4
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +17 -5
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +153 -12
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +2 -2
- package/src/Array.ts +304 -447
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Brand.ts +1 -1
- package/src/Cache.ts +9 -8
- package/src/Cause.ts +37 -2
- package/src/Channel.ts +582 -154
- package/src/Chunk.ts +149 -331
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +195 -25
- package/src/Cron.ts +155 -63
- package/src/Data.ts +539 -376
- package/src/DateTime.ts +75 -256
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +122 -66
- package/src/Effect.ts +1483 -1157
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +278 -111
- package/src/Equivalence.ts +114 -52
- package/src/ErrorReporter.ts +458 -0
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +12 -3
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +34 -31
- package/src/Filter.ts +52 -63
- package/src/Formatter.ts +253 -51
- package/src/Function.ts +2 -10
- package/src/Graph.ts +131 -117
- package/src/HashMap.ts +26 -19
- package/src/Iterable.ts +117 -63
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +194 -0
- package/src/Layer.ts +393 -159
- package/src/LayerMap.ts +11 -9
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +33 -100
- package/src/ManagedRuntime.ts +2 -2
- package/src/Metric.ts +6 -8
- package/src/MutableHashMap.ts +9 -0
- package/src/MutableHashSet.ts +9 -0
- package/src/Newtype.ts +308 -0
- package/src/Number.ts +85 -26
- package/src/Optic.ts +948 -19
- package/src/Option.ts +34 -24
- package/src/Order.ts +39 -32
- package/src/PartitionedSemaphore.ts +288 -56
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +13 -11
- package/src/PubSub.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +11 -9
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +94 -199
- package/src/Reducer.ts +166 -7
- package/src/References.ts +283 -287
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +29 -49
- package/src/Resource.ts +2 -1
- package/src/Result.ts +2 -4
- package/src/Runtime.ts +102 -6
- package/src/Schedule.ts +458 -449
- package/src/Scheduler.ts +49 -126
- package/src/Schema.ts +3298 -392
- package/src/SchemaAST.ts +172 -33
- package/src/SchemaGetter.ts +19 -21
- package/src/SchemaParser.ts +92 -27
- package/src/SchemaRepresentation.ts +51 -26
- package/src/SchemaTransformation.ts +198 -13
- package/src/ScopedCache.ts +3 -3
- package/src/Semaphore.ts +444 -0
- package/src/ServiceMap.ts +133 -71
- package/src/Sink.ts +83 -28
- package/src/Stdio.ts +27 -4
- package/src/Stream.ts +687 -617
- package/src/String.ts +122 -69
- package/src/Struct.ts +33 -7
- package/src/SubscriptionRef.ts +101 -120
- package/src/SynchronizedRef.ts +3 -2
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +44 -31
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +409 -343
- package/src/TxHashSet.ts +113 -118
- package/src/TxPriorityQueue.ts +766 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +217 -44
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/Types.ts +73 -19
- package/src/Utils.ts +137 -111
- package/src/index.ts +814 -54
- package/src/internal/core.ts +12 -5
- package/src/internal/dateTime.ts +91 -96
- package/src/internal/effect.ts +841 -432
- package/src/internal/hashMap.ts +12 -10
- package/src/internal/option.ts +7 -0
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +4 -3
- package/src/internal/references.ts +72 -0
- package/src/internal/request.ts +2 -2
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/representation.ts +45 -94
- package/src/internal/schema/schema.ts +1 -0
- package/src/internal/schema/to-codec.ts +7 -17
- package/src/internal/trie.ts +21 -15
- package/src/testing/TestClock.ts +13 -11
- package/src/testing/TestSchema.ts +332 -35
- package/src/testing/index.ts +64 -1
- package/src/unstable/ai/AiError.ts +111 -54
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +62 -74
- package/src/unstable/ai/EmbeddingModel.ts +209 -0
- package/src/unstable/ai/LanguageModel.ts +544 -230
- package/src/unstable/ai/McpSchema.ts +73 -13
- package/src/unstable/ai/McpServer.ts +271 -61
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Prompt.ts +37 -37
- package/src/unstable/ai/Response.ts +25 -25
- package/src/unstable/ai/ResponseIdTracker.ts +97 -0
- package/src/unstable/ai/Tool.ts +42 -16
- package/src/unstable/ai/Toolkit.ts +5 -14
- package/src/unstable/ai/index.ts +24 -1
- package/src/unstable/ai/internal/codec-transformer.ts +0 -7
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliError.ts +47 -59
- package/src/unstable/cli/CliOutput.ts +85 -13
- package/src/unstable/cli/Command.ts +801 -192
- package/src/unstable/cli/Completions.ts +36 -0
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/GlobalFlag.ts +242 -0
- package/src/unstable/cli/HelpDoc.ts +91 -11
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +2 -2
- package/src/unstable/cli/Prompt.ts +262 -100
- package/src/unstable/cli/index.ts +10 -0
- package/src/unstable/cli/internal/command.ts +109 -63
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +10 -4
- package/src/unstable/cli/internal/config.ts +49 -0
- package/src/unstable/cli/internal/help.ts +171 -0
- package/src/unstable/cli/internal/parser.ts +71 -63
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +40 -34
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/cluster/Entity.ts +24 -22
- package/src/unstable/cluster/EntityAddress.ts +1 -1
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/K8sHttpClient.ts +5 -5
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +29 -30
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +14 -12
- package/src/unstable/cluster/ShardId.ts +2 -2
- package/src/unstable/cluster/Sharding.ts +36 -27
- package/src/unstable/cluster/ShardingConfig.ts +36 -37
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +36 -29
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/devtools/DevToolsClient.ts +23 -18
- package/src/unstable/devtools/DevToolsSchema.ts +16 -3
- package/src/unstable/encoding/Ndjson.ts +17 -17
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/EventJournal.ts +2 -2
- package/src/unstable/eventlog/EventLog.ts +3 -2
- package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
- package/src/unstable/http/Cookies.ts +94 -11
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +68 -18
- package/src/unstable/http/HttpClient.ts +376 -34
- package/src/unstable/http/HttpClientRequest.ts +151 -39
- package/src/unstable/http/HttpClientResponse.ts +12 -6
- package/src/unstable/http/HttpEffect.ts +54 -68
- package/src/unstable/http/HttpIncomingMessage.ts +3 -2
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +25 -39
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +45 -47
- package/src/unstable/http/HttpServerRequest.ts +407 -16
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +345 -7
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/Url.ts +650 -0
- package/src/unstable/http/UrlParams.ts +31 -19
- package/src/unstable/http/index.ts +10 -0
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +6 -6
- package/src/unstable/httpapi/HttpApiBuilder.ts +106 -41
- package/src/unstable/httpapi/HttpApiClient.ts +180 -28
- package/src/unstable/httpapi/HttpApiEndpoint.ts +216 -104
- package/src/unstable/httpapi/HttpApiError.ts +108 -30
- package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +83 -22
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/httpapi/HttpApiSchema.ts +20 -2
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +43 -29
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +8 -5
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +12 -8
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/Persistable.ts +3 -3
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +25 -24
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +75 -14
- package/src/unstable/reactivity/Atom.ts +212 -54
- package/src/unstable/reactivity/AtomHttpApi.ts +81 -41
- package/src/unstable/reactivity/AtomRegistry.ts +66 -12
- package/src/unstable/reactivity/AtomRpc.ts +51 -20
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/Rpc.ts +11 -12
- package/src/unstable/rpc/RpcClient.ts +22 -63
- package/src/unstable/rpc/RpcGroup.ts +7 -7
- package/src/unstable/rpc/RpcMiddleware.ts +15 -9
- package/src/unstable/rpc/RpcSchema.ts +23 -5
- package/src/unstable/rpc/RpcSerialization.ts +49 -11
- package/src/unstable/rpc/RpcServer.ts +31 -35
- package/src/unstable/rpc/Utils.ts +3 -2
- package/src/unstable/schema/Model.ts +31 -0
- package/src/unstable/schema/VariantSchema.ts +10 -10
- package/src/unstable/socket/Socket.ts +31 -27
- package/src/unstable/sql/Migrator.ts +7 -5
- package/src/unstable/sql/SqlClient.ts +6 -4
- package/src/unstable/sql/SqlError.ts +365 -11
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlResolver.ts +17 -7
- package/src/unstable/sql/SqlSchema.ts +42 -26
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/DurableClock.ts +8 -8
- package/src/unstable/workflow/DurableDeferred.ts +8 -8
- package/src/unstable/workflow/Workflow.ts +7 -3
- package/src/unstable/workflow/WorkflowEngine.ts +211 -19
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/dist/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/src/NullOr.ts +0 -204
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/Effect.ts
CHANGED
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* import { Effect } from "effect"
|
|
43
|
+
* import { Data, Effect } from "effect"
|
|
44
|
+
*
|
|
45
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
44
46
|
*
|
|
45
47
|
* // Effect that may fail
|
|
46
48
|
* const divide = (a: number, b: number) =>
|
|
47
49
|
* b === 0
|
|
48
|
-
* ? Effect.fail(new
|
|
50
|
+
* ? Effect.fail(new DiscountRateError())
|
|
49
51
|
* : Effect.succeed(a / b)
|
|
50
52
|
*
|
|
51
53
|
* // Error handling
|
|
@@ -84,7 +86,7 @@ import * as internalRequest from "./internal/request.ts"
|
|
|
84
86
|
import * as internalSchedule from "./internal/schedule.ts"
|
|
85
87
|
import type * as Layer from "./Layer.ts"
|
|
86
88
|
import type { Logger } from "./Logger.ts"
|
|
87
|
-
import type {
|
|
89
|
+
import type { Severity } from "./LogLevel.ts"
|
|
88
90
|
import * as Metric from "./Metric.ts"
|
|
89
91
|
import type { Option } from "./Option.ts"
|
|
90
92
|
import type { Pipeable } from "./Pipeable.ts"
|
|
@@ -116,9 +118,12 @@ import type {
|
|
|
116
118
|
ExcludeTag,
|
|
117
119
|
ExtractReason,
|
|
118
120
|
ExtractTag,
|
|
121
|
+
NarrowReason,
|
|
119
122
|
NoInfer,
|
|
123
|
+
OmitReason,
|
|
120
124
|
ReasonOf,
|
|
121
125
|
ReasonTags,
|
|
126
|
+
Simplify,
|
|
122
127
|
Tags,
|
|
123
128
|
unassigned
|
|
124
129
|
} from "./Types.ts"
|
|
@@ -143,13 +148,15 @@ const TypeId = core.EffectTypeId
|
|
|
143
148
|
*
|
|
144
149
|
* @example
|
|
145
150
|
* ```ts
|
|
146
|
-
* import { Effect } from "effect"
|
|
151
|
+
* import { Data, Effect } from "effect"
|
|
152
|
+
*
|
|
153
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
147
154
|
*
|
|
148
155
|
* // A simple effect that succeeds with a value
|
|
149
156
|
* const success = Effect.succeed(42)
|
|
150
157
|
*
|
|
151
|
-
* // An effect that
|
|
152
|
-
* const risky = Effect.fail(new
|
|
158
|
+
* // An effect that will always fail
|
|
159
|
+
* const risky = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
153
160
|
*
|
|
154
161
|
* // Effects can be composed using generator functions
|
|
155
162
|
* const program = Effect.gen(function*() {
|
|
@@ -166,7 +173,7 @@ export interface Effect<out A, out E = never, out R = never> extends Pipeable, Y
|
|
|
166
173
|
readonly [TypeId]: Variance<A, E, R>
|
|
167
174
|
[Unify.typeSymbol]?: unknown
|
|
168
175
|
[Unify.unifySymbol]?: EffectUnify<this>
|
|
169
|
-
[Unify.ignoreSymbol]?:
|
|
176
|
+
[Unify.ignoreSymbol]?: {}
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
/**
|
|
@@ -235,21 +242,6 @@ export interface EffectUnify<A extends { [Unify.typeSymbol]?: any }> {
|
|
|
235
242
|
: never
|
|
236
243
|
}
|
|
237
244
|
|
|
238
|
-
/**
|
|
239
|
-
* @category Models
|
|
240
|
-
* @since 2.0.0
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* import type { Effect } from "effect"
|
|
244
|
-
*
|
|
245
|
-
* // EffectUnifyIgnore is used internally to control type unification
|
|
246
|
-
* // It prevents certain types from being unified with Effect types
|
|
247
|
-
* declare const ignored: Effect.EffectUnifyIgnore
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
export interface EffectUnifyIgnore {
|
|
251
|
-
Effect?: true
|
|
252
|
-
}
|
|
253
245
|
/**
|
|
254
246
|
* @category Type Lambdas
|
|
255
247
|
* @since 2.0.0
|
|
@@ -365,7 +357,7 @@ export declare namespace Yieldable {
|
|
|
365
357
|
* @since 2.0.0
|
|
366
358
|
* @category Guards
|
|
367
359
|
*/
|
|
368
|
-
export const isEffect
|
|
360
|
+
export const isEffect: (u: unknown) => u is Effect<any, any, any> = core.isEffect
|
|
369
361
|
|
|
370
362
|
/**
|
|
371
363
|
* Iterator interface for Effect generators, enabling Effect values to work with generator functions.
|
|
@@ -430,13 +422,15 @@ export declare namespace All {
|
|
|
430
422
|
* @category Models
|
|
431
423
|
* @example
|
|
432
424
|
* ```ts
|
|
433
|
-
* import { Effect } from "effect"
|
|
425
|
+
* import { Data, Effect } from "effect"
|
|
426
|
+
*
|
|
427
|
+
* class OopsError extends Data.TaggedError("OopsError")<{}> {}
|
|
434
428
|
*
|
|
435
429
|
* // EffectAny represents an Effect with any type parameters
|
|
436
430
|
* const effects: Array<Effect.All.EffectAny> = [
|
|
437
431
|
* Effect.succeed(42),
|
|
438
432
|
* Effect.succeed("hello"),
|
|
439
|
-
* Effect.fail(new
|
|
433
|
+
* Effect.fail(new OopsError())
|
|
440
434
|
* ]
|
|
441
435
|
* ```
|
|
442
436
|
*/
|
|
@@ -740,7 +734,6 @@ export declare namespace All {
|
|
|
740
734
|
* ```
|
|
741
735
|
*
|
|
742
736
|
* @see {@link forEach} for iterating over elements and applying an effect.
|
|
743
|
-
* @see {@link allWith} for a data-last version of this function.
|
|
744
737
|
*
|
|
745
738
|
* @since 2.0.0
|
|
746
739
|
* @category Collecting
|
|
@@ -852,6 +845,316 @@ export const partition: {
|
|
|
852
845
|
): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
|
|
853
846
|
} = internal.partition
|
|
854
847
|
|
|
848
|
+
/**
|
|
849
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
850
|
+
*
|
|
851
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
852
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
853
|
+
* If all effects succeed, it returns all collected successes.
|
|
854
|
+
*
|
|
855
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
856
|
+
* elements.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```ts
|
|
860
|
+
* import { Effect } from "effect"
|
|
861
|
+
*
|
|
862
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
863
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
864
|
+
* )
|
|
865
|
+
*
|
|
866
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
867
|
+
* // {
|
|
868
|
+
* // _id: 'Exit',
|
|
869
|
+
* // _tag: 'Failure',
|
|
870
|
+
* // cause: {
|
|
871
|
+
* // _id: 'Cause',
|
|
872
|
+
* // reasons: [
|
|
873
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
874
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
875
|
+
* // ]
|
|
876
|
+
* // }
|
|
877
|
+
* // }
|
|
878
|
+
* ```
|
|
879
|
+
*
|
|
880
|
+
* @since 4.0.0
|
|
881
|
+
* @category Error Accumulation
|
|
882
|
+
*/
|
|
883
|
+
export const validate: {
|
|
884
|
+
/**
|
|
885
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
886
|
+
*
|
|
887
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
888
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
889
|
+
* If all effects succeed, it returns all collected successes.
|
|
890
|
+
*
|
|
891
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
892
|
+
* elements.
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* ```ts
|
|
896
|
+
* import { Effect } from "effect"
|
|
897
|
+
*
|
|
898
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
899
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
900
|
+
* )
|
|
901
|
+
*
|
|
902
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
903
|
+
* // {
|
|
904
|
+
* // _id: 'Exit',
|
|
905
|
+
* // _tag: 'Failure',
|
|
906
|
+
* // cause: {
|
|
907
|
+
* // _id: 'Cause',
|
|
908
|
+
* // reasons: [
|
|
909
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
910
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
911
|
+
* // ]
|
|
912
|
+
* // }
|
|
913
|
+
* // }
|
|
914
|
+
* ```
|
|
915
|
+
*
|
|
916
|
+
* @since 4.0.0
|
|
917
|
+
* @category Error Accumulation
|
|
918
|
+
*/
|
|
919
|
+
<A, B, E, R>(
|
|
920
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
921
|
+
options?: {
|
|
922
|
+
readonly concurrency?: Concurrency | undefined
|
|
923
|
+
readonly discard?: false | undefined
|
|
924
|
+
} | undefined
|
|
925
|
+
): (elements: Iterable<A>) => Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
926
|
+
/**
|
|
927
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
928
|
+
*
|
|
929
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
930
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
931
|
+
* If all effects succeed, it returns all collected successes.
|
|
932
|
+
*
|
|
933
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
934
|
+
* elements.
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* ```ts
|
|
938
|
+
* import { Effect } from "effect"
|
|
939
|
+
*
|
|
940
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
941
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
942
|
+
* )
|
|
943
|
+
*
|
|
944
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
945
|
+
* // {
|
|
946
|
+
* // _id: 'Exit',
|
|
947
|
+
* // _tag: 'Failure',
|
|
948
|
+
* // cause: {
|
|
949
|
+
* // _id: 'Cause',
|
|
950
|
+
* // reasons: [
|
|
951
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
952
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
953
|
+
* // ]
|
|
954
|
+
* // }
|
|
955
|
+
* // }
|
|
956
|
+
* ```
|
|
957
|
+
*
|
|
958
|
+
* @since 4.0.0
|
|
959
|
+
* @category Error Accumulation
|
|
960
|
+
*/
|
|
961
|
+
<A, B, E, R>(
|
|
962
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
963
|
+
options: {
|
|
964
|
+
readonly concurrency?: Concurrency | undefined
|
|
965
|
+
readonly discard: true
|
|
966
|
+
}
|
|
967
|
+
): (elements: Iterable<A>) => Effect<void, Arr.NonEmptyArray<E>, R>
|
|
968
|
+
/**
|
|
969
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
970
|
+
*
|
|
971
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
972
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
973
|
+
* If all effects succeed, it returns all collected successes.
|
|
974
|
+
*
|
|
975
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
976
|
+
* elements.
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```ts
|
|
980
|
+
* import { Effect } from "effect"
|
|
981
|
+
*
|
|
982
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
983
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
984
|
+
* )
|
|
985
|
+
*
|
|
986
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
987
|
+
* // {
|
|
988
|
+
* // _id: 'Exit',
|
|
989
|
+
* // _tag: 'Failure',
|
|
990
|
+
* // cause: {
|
|
991
|
+
* // _id: 'Cause',
|
|
992
|
+
* // reasons: [
|
|
993
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
994
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
995
|
+
* // ]
|
|
996
|
+
* // }
|
|
997
|
+
* // }
|
|
998
|
+
* ```
|
|
999
|
+
*
|
|
1000
|
+
* @since 4.0.0
|
|
1001
|
+
* @category Error Accumulation
|
|
1002
|
+
*/
|
|
1003
|
+
<A, B, E, R>(
|
|
1004
|
+
elements: Iterable<A>,
|
|
1005
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1006
|
+
options?: {
|
|
1007
|
+
readonly concurrency?: Concurrency | undefined
|
|
1008
|
+
readonly discard?: false | undefined
|
|
1009
|
+
} | undefined
|
|
1010
|
+
): Effect<Array<B>, Arr.NonEmptyArray<E>, R>
|
|
1011
|
+
/**
|
|
1012
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
1013
|
+
*
|
|
1014
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
1015
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
1016
|
+
* If all effects succeed, it returns all collected successes.
|
|
1017
|
+
*
|
|
1018
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
1019
|
+
* elements.
|
|
1020
|
+
*
|
|
1021
|
+
* @example
|
|
1022
|
+
* ```ts
|
|
1023
|
+
* import { Effect } from "effect"
|
|
1024
|
+
*
|
|
1025
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
1026
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
1027
|
+
* )
|
|
1028
|
+
*
|
|
1029
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
1030
|
+
* // {
|
|
1031
|
+
* // _id: 'Exit',
|
|
1032
|
+
* // _tag: 'Failure',
|
|
1033
|
+
* // cause: {
|
|
1034
|
+
* // _id: 'Cause',
|
|
1035
|
+
* // reasons: [
|
|
1036
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
1037
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
1038
|
+
* // ]
|
|
1039
|
+
* // }
|
|
1040
|
+
* // }
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
* @since 4.0.0
|
|
1044
|
+
* @category Error Accumulation
|
|
1045
|
+
*/
|
|
1046
|
+
<A, B, E, R>(
|
|
1047
|
+
elements: Iterable<A>,
|
|
1048
|
+
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1049
|
+
options: {
|
|
1050
|
+
readonly concurrency?: Concurrency | undefined
|
|
1051
|
+
readonly discard: true
|
|
1052
|
+
}
|
|
1053
|
+
): Effect<void, Arr.NonEmptyArray<E>, R>
|
|
1054
|
+
} = internal.validate
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
1058
|
+
*
|
|
1059
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
1060
|
+
* as soon as an element matches.
|
|
1061
|
+
*
|
|
1062
|
+
* @example
|
|
1063
|
+
* ```ts
|
|
1064
|
+
* import { Effect } from "effect"
|
|
1065
|
+
*
|
|
1066
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
1067
|
+
*
|
|
1068
|
+
* Effect.runPromise(program).then(console.log)
|
|
1069
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
1070
|
+
* ```
|
|
1071
|
+
*
|
|
1072
|
+
* @since 2.0.0
|
|
1073
|
+
* @category Collecting
|
|
1074
|
+
*/
|
|
1075
|
+
export const findFirst: {
|
|
1076
|
+
/**
|
|
1077
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
1078
|
+
*
|
|
1079
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
1080
|
+
* as soon as an element matches.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```ts
|
|
1084
|
+
* import { Effect } from "effect"
|
|
1085
|
+
*
|
|
1086
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
1087
|
+
*
|
|
1088
|
+
* Effect.runPromise(program).then(console.log)
|
|
1089
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
1090
|
+
* ```
|
|
1091
|
+
*
|
|
1092
|
+
* @since 2.0.0
|
|
1093
|
+
* @category Collecting
|
|
1094
|
+
*/
|
|
1095
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): (elements: Iterable<A>) => Effect<Option<A>, E, R>
|
|
1096
|
+
/**
|
|
1097
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
1098
|
+
*
|
|
1099
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
1100
|
+
* as soon as an element matches.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```ts
|
|
1104
|
+
* import { Effect } from "effect"
|
|
1105
|
+
*
|
|
1106
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
1107
|
+
*
|
|
1108
|
+
* Effect.runPromise(program).then(console.log)
|
|
1109
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
1110
|
+
* ```
|
|
1111
|
+
*
|
|
1112
|
+
* @since 2.0.0
|
|
1113
|
+
* @category Collecting
|
|
1114
|
+
*/
|
|
1115
|
+
<A, E, R>(
|
|
1116
|
+
elements: Iterable<A>,
|
|
1117
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>
|
|
1118
|
+
): Effect<Option<A>, E, R>
|
|
1119
|
+
} = internal.findFirst
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1123
|
+
*
|
|
1124
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1125
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1126
|
+
*
|
|
1127
|
+
* @since 4.0.0
|
|
1128
|
+
* @category Collecting
|
|
1129
|
+
*/
|
|
1130
|
+
export const findFirstFilter: {
|
|
1131
|
+
/**
|
|
1132
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1133
|
+
*
|
|
1134
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1135
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1136
|
+
*
|
|
1137
|
+
* @since 4.0.0
|
|
1138
|
+
* @category Collecting
|
|
1139
|
+
*/
|
|
1140
|
+
<A, B, X, E, R>(
|
|
1141
|
+
filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>
|
|
1142
|
+
): (elements: Iterable<A>) => Effect<Option<B>, E, R>
|
|
1143
|
+
/**
|
|
1144
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1145
|
+
*
|
|
1146
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1147
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1148
|
+
*
|
|
1149
|
+
* @since 4.0.0
|
|
1150
|
+
* @category Collecting
|
|
1151
|
+
*/
|
|
1152
|
+
<A, B, X, E, R>(
|
|
1153
|
+
elements: Iterable<A>,
|
|
1154
|
+
filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>
|
|
1155
|
+
): Effect<Option<B>, E, R>
|
|
1156
|
+
} = internal.findFirstFilter
|
|
1157
|
+
|
|
855
1158
|
/**
|
|
856
1159
|
* Executes an effectful operation for each element in an `Iterable`.
|
|
857
1160
|
*
|
|
@@ -1206,16 +1509,18 @@ export const promise: <A>(
|
|
|
1206
1509
|
*
|
|
1207
1510
|
* @example Custom Error Handling
|
|
1208
1511
|
* ```ts
|
|
1209
|
-
* import { Effect } from "effect"
|
|
1512
|
+
* import { Data, Effect } from "effect"
|
|
1513
|
+
*
|
|
1514
|
+
* class TodoFetchError extends Data.TaggedError("TodoFetchError")<{ readonly cause: unknown }> {}
|
|
1210
1515
|
*
|
|
1211
1516
|
* const getTodo = (id: number) =>
|
|
1212
1517
|
* Effect.tryPromise({
|
|
1213
1518
|
* try: () => fetch(`https://jsonplaceholder.typicode.com/todos/${id}`),
|
|
1214
1519
|
* // remap the error
|
|
1215
|
-
* catch: (
|
|
1520
|
+
* catch: (cause) => new TodoFetchError({ cause })
|
|
1216
1521
|
* })
|
|
1217
1522
|
*
|
|
1218
|
-
* // ┌─── Effect<Response,
|
|
1523
|
+
* // ┌─── Effect<Response, TodoFetchError, never>
|
|
1219
1524
|
* // ▼
|
|
1220
1525
|
* const program = getTodo(1)
|
|
1221
1526
|
* ```
|
|
@@ -1458,8 +1763,13 @@ export {
|
|
|
1458
1763
|
*
|
|
1459
1764
|
* **When to Use**
|
|
1460
1765
|
*
|
|
1461
|
-
* Use `Effect.
|
|
1766
|
+
* Use `Effect.callback` when dealing with APIs that use callback-style instead of
|
|
1462
1767
|
* `async/await` or `Promise`.
|
|
1768
|
+
* * **Previously Known As**
|
|
1769
|
+
*
|
|
1770
|
+
* This API replaces the following from Effect 3.x:
|
|
1771
|
+
*
|
|
1772
|
+
* - `Effect.async`
|
|
1463
1773
|
*
|
|
1464
1774
|
* @example
|
|
1465
1775
|
* ```ts
|
|
@@ -1512,35 +1822,134 @@ export const callback: <A, E = never, R = never>(
|
|
|
1512
1822
|
export const never: Effect<never> = internal.never
|
|
1513
1823
|
|
|
1514
1824
|
/**
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
*
|
|
1518
|
-
* **When to Use**
|
|
1519
|
-
*
|
|
1520
|
-
* `gen` allows you to write code that looks and behaves like synchronous
|
|
1521
|
-
* code, but it can handle asynchronous tasks, errors, and complex control flow
|
|
1522
|
-
* (like loops and conditions). It helps make asynchronous code more readable
|
|
1523
|
-
* and easier to manage.
|
|
1524
|
-
*
|
|
1525
|
-
* The generator functions work similarly to `async/await` but with more
|
|
1526
|
-
* explicit control over the execution of effects. You can `yield*` values from
|
|
1527
|
-
* effects and return the final result at the end.
|
|
1825
|
+
* An `Effect` containing an empty record `{}`, used as the starting point for
|
|
1826
|
+
* do notation chains.
|
|
1528
1827
|
*
|
|
1529
1828
|
* @example
|
|
1530
1829
|
* ```ts
|
|
1531
1830
|
* import { Effect } from "effect"
|
|
1831
|
+
* import { pipe } from "effect/Function"
|
|
1532
1832
|
*
|
|
1533
|
-
* const
|
|
1833
|
+
* const program = pipe(
|
|
1834
|
+
* Effect.Do,
|
|
1835
|
+
* Effect.bind("x", () => Effect.succeed(2)),
|
|
1836
|
+
* Effect.bind("y", ({ x }) => Effect.succeed(x + 1)),
|
|
1837
|
+
* Effect.let("sum", ({ x, y }) => x + y)
|
|
1838
|
+
* )
|
|
1839
|
+
* ```
|
|
1534
1840
|
*
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
*
|
|
1841
|
+
* @since 4.0.0
|
|
1842
|
+
* @category Do notation
|
|
1843
|
+
*/
|
|
1844
|
+
export const Do: Effect<{}> = internal.Do
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1848
|
+
* record used in do notation pipelines.
|
|
1542
1849
|
*
|
|
1543
|
-
*
|
|
1850
|
+
* @since 4.0.0
|
|
1851
|
+
* @category Do notation
|
|
1852
|
+
*/
|
|
1853
|
+
export const bindTo: {
|
|
1854
|
+
/**
|
|
1855
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1856
|
+
* record used in do notation pipelines.
|
|
1857
|
+
*
|
|
1858
|
+
* @since 4.0.0
|
|
1859
|
+
* @category Do notation
|
|
1860
|
+
*/
|
|
1861
|
+
<N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{ [K in N]: A }, E, R>
|
|
1862
|
+
/**
|
|
1863
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1864
|
+
* record used in do notation pipelines.
|
|
1865
|
+
*
|
|
1866
|
+
* @since 4.0.0
|
|
1867
|
+
* @category Do notation
|
|
1868
|
+
*/
|
|
1869
|
+
<A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{ [K in N]: A }, E, R>
|
|
1870
|
+
} = internal.bindTo
|
|
1871
|
+
|
|
1872
|
+
const let_: {
|
|
1873
|
+
<N extends string, A extends Record<string, any>, B>(
|
|
1874
|
+
name: N,
|
|
1875
|
+
f: (a: NoInfer<A>) => B
|
|
1876
|
+
): <E, R>(
|
|
1877
|
+
self: Effect<A, E, R>
|
|
1878
|
+
) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>
|
|
1879
|
+
<A extends Record<string, any>, E, R, B, N extends string>(
|
|
1880
|
+
self: Effect<A, E, R>,
|
|
1881
|
+
name: N,
|
|
1882
|
+
f: (a: NoInfer<A>) => B
|
|
1883
|
+
): Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>
|
|
1884
|
+
} = internal.let
|
|
1885
|
+
|
|
1886
|
+
export {
|
|
1887
|
+
/**
|
|
1888
|
+
* Adds a computed plain value to the do notation record.
|
|
1889
|
+
*
|
|
1890
|
+
* @since 4.0.0
|
|
1891
|
+
* @category Do notation
|
|
1892
|
+
*/
|
|
1893
|
+
let_ as let
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1898
|
+
*
|
|
1899
|
+
* @since 4.0.0
|
|
1900
|
+
* @category Do notation
|
|
1901
|
+
*/
|
|
1902
|
+
export const bind: {
|
|
1903
|
+
/**
|
|
1904
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1905
|
+
*
|
|
1906
|
+
* @since 4.0.0
|
|
1907
|
+
* @category Do notation
|
|
1908
|
+
*/
|
|
1909
|
+
<N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): <E, R>(
|
|
1910
|
+
self: Effect<A, E, R>
|
|
1911
|
+
) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>
|
|
1912
|
+
/**
|
|
1913
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1914
|
+
*
|
|
1915
|
+
* @since 4.0.0
|
|
1916
|
+
* @category Do notation
|
|
1917
|
+
*/
|
|
1918
|
+
<A extends Record<string, any>, E, R, B, E2, R2, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>
|
|
1919
|
+
} = internal.bind
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Provides a way to write effectful code using generator functions, simplifying
|
|
1923
|
+
* control flow and error handling.
|
|
1924
|
+
*
|
|
1925
|
+
* **When to Use**
|
|
1926
|
+
*
|
|
1927
|
+
* `gen` allows you to write code that looks and behaves like synchronous
|
|
1928
|
+
* code, but it can handle asynchronous tasks, errors, and complex control flow
|
|
1929
|
+
* (like loops and conditions). It helps make asynchronous code more readable
|
|
1930
|
+
* and easier to manage.
|
|
1931
|
+
*
|
|
1932
|
+
* The generator functions work similarly to `async/await` but with more
|
|
1933
|
+
* explicit control over the execution of effects. You can `yield*` values from
|
|
1934
|
+
* effects and return the final result at the end.
|
|
1935
|
+
*
|
|
1936
|
+
* @example
|
|
1937
|
+
* ```ts
|
|
1938
|
+
* import { Data, Effect } from "effect"
|
|
1939
|
+
*
|
|
1940
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1941
|
+
*
|
|
1942
|
+
* const addServiceCharge = (amount: number) => amount + 1
|
|
1943
|
+
*
|
|
1944
|
+
* const applyDiscount = (
|
|
1945
|
+
* total: number,
|
|
1946
|
+
* discountRate: number
|
|
1947
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1948
|
+
* discountRate === 0
|
|
1949
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1950
|
+
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1951
|
+
*
|
|
1952
|
+
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
1544
1953
|
*
|
|
1545
1954
|
* const fetchDiscountRate = Effect.promise(() => Promise.resolve(5))
|
|
1546
1955
|
*
|
|
@@ -1577,16 +1986,18 @@ export const gen: {
|
|
|
1577
1986
|
*
|
|
1578
1987
|
* @example
|
|
1579
1988
|
* ```ts
|
|
1580
|
-
* import { Effect } from "effect"
|
|
1989
|
+
* import { Data, Effect } from "effect"
|
|
1990
|
+
*
|
|
1991
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1581
1992
|
*
|
|
1582
1993
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1583
1994
|
*
|
|
1584
1995
|
* const applyDiscount = (
|
|
1585
1996
|
* total: number,
|
|
1586
1997
|
* discountRate: number
|
|
1587
|
-
* ): Effect.Effect<number,
|
|
1998
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1588
1999
|
* discountRate === 0
|
|
1589
|
-
* ? Effect.fail(new
|
|
2000
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1590
2001
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1591
2002
|
*
|
|
1592
2003
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1634,16 +2045,18 @@ export const gen: {
|
|
|
1634
2045
|
*
|
|
1635
2046
|
* @example
|
|
1636
2047
|
* ```ts
|
|
1637
|
-
* import { Effect } from "effect"
|
|
2048
|
+
* import { Data, Effect } from "effect"
|
|
2049
|
+
*
|
|
2050
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1638
2051
|
*
|
|
1639
2052
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1640
2053
|
*
|
|
1641
2054
|
* const applyDiscount = (
|
|
1642
2055
|
* total: number,
|
|
1643
2056
|
* discountRate: number
|
|
1644
|
-
* ): Effect.Effect<number,
|
|
2057
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1645
2058
|
* discountRate === 0
|
|
1646
|
-
* ? Effect.fail(new
|
|
2059
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1647
2060
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1648
2061
|
*
|
|
1649
2062
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1707,12 +2120,14 @@ export namespace gen {
|
|
|
1707
2120
|
* @example
|
|
1708
2121
|
* ```ts
|
|
1709
2122
|
* // Title: Creating a Failed Effect
|
|
1710
|
-
* import { Effect } from "effect"
|
|
2123
|
+
* import { Data, Effect } from "effect"
|
|
1711
2124
|
*
|
|
1712
|
-
*
|
|
2125
|
+
* class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
|
|
2126
|
+
*
|
|
2127
|
+
* // ┌─── Effect<never, OperationFailedError, never>
|
|
1713
2128
|
* // ▼
|
|
1714
2129
|
* const failure = Effect.fail(
|
|
1715
|
-
* new
|
|
2130
|
+
* new OperationFailedError()
|
|
1716
2131
|
* )
|
|
1717
2132
|
* ```
|
|
1718
2133
|
*
|
|
@@ -1729,9 +2144,11 @@ export const fail: <E>(error: E) => Effect<never, E> = internal.fail
|
|
|
1729
2144
|
*
|
|
1730
2145
|
* @example
|
|
1731
2146
|
* ```ts
|
|
1732
|
-
* import { Effect } from "effect"
|
|
2147
|
+
* import { Data, Effect } from "effect"
|
|
2148
|
+
*
|
|
2149
|
+
* class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}
|
|
1733
2150
|
*
|
|
1734
|
-
* const program = Effect.failSync(() => new
|
|
2151
|
+
* const program = Effect.failSync(() => new ProgramError({ failedAt: new Date() }))
|
|
1735
2152
|
*
|
|
1736
2153
|
* Effect.runPromiseExit(program).then(console.log)
|
|
1737
2154
|
* // Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
|
|
@@ -1885,12 +2302,14 @@ export {
|
|
|
1885
2302
|
*
|
|
1886
2303
|
* @example Custom Error Handling
|
|
1887
2304
|
* ```ts
|
|
1888
|
-
* import { Effect } from "effect"
|
|
2305
|
+
* import { Data, Effect } from "effect"
|
|
2306
|
+
*
|
|
2307
|
+
* class JsonParsingError extends Data.TaggedError("JsonParsingError")<{ readonly cause: unknown }> {}
|
|
1889
2308
|
*
|
|
1890
2309
|
* const parseJSON = (input: string) =>
|
|
1891
2310
|
* Effect.try({
|
|
1892
2311
|
* try: () => JSON.parse(input),
|
|
1893
|
-
* catch: (
|
|
2312
|
+
* catch: (cause) => new JsonParsingError({ cause })
|
|
1894
2313
|
* })
|
|
1895
2314
|
*
|
|
1896
2315
|
* Effect.runPromiseExit(parseJSON("invalid json")).then(console.log)
|
|
@@ -2027,17 +2446,17 @@ export const fromOption: <A>(
|
|
|
2027
2446
|
* ```ts
|
|
2028
2447
|
* import { Console, Effect } from "effect"
|
|
2029
2448
|
*
|
|
2030
|
-
* const input: string | null
|
|
2031
|
-
*
|
|
2032
|
-
* const program = Effect.gen(function*() {
|
|
2449
|
+
* const program = Effect.fn(function*(input: string | null) {
|
|
2033
2450
|
* const value = yield* Effect.fromNullishOr(input)
|
|
2034
2451
|
* yield* Console.log(value)
|
|
2035
|
-
* }
|
|
2452
|
+
* },
|
|
2036
2453
|
* Effect.catch(() => Console.log("missing"))
|
|
2037
2454
|
* )
|
|
2038
2455
|
*
|
|
2039
|
-
* Effect.runPromise(program)
|
|
2456
|
+
* Effect.runPromise(program(null))
|
|
2040
2457
|
* // Output: missing
|
|
2458
|
+
* Effect.runPromise(program("hello"))
|
|
2459
|
+
* // Output: hello
|
|
2041
2460
|
* ```
|
|
2042
2461
|
*
|
|
2043
2462
|
* @since 4.0.0
|
|
@@ -2106,15 +2525,17 @@ export const fromYieldable: <Self extends Yieldable.Any, A, E, R>(
|
|
|
2106
2525
|
*
|
|
2107
2526
|
* @example
|
|
2108
2527
|
* ```ts
|
|
2109
|
-
* import { Effect, pipe } from "effect"
|
|
2528
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2529
|
+
*
|
|
2530
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2110
2531
|
*
|
|
2111
2532
|
* // Function to apply a discount safely to a transaction amount
|
|
2112
2533
|
* const applyDiscount = (
|
|
2113
2534
|
* total: number,
|
|
2114
2535
|
* discountRate: number
|
|
2115
|
-
* ): Effect.Effect<number,
|
|
2536
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2116
2537
|
* discountRate === 0
|
|
2117
|
-
* ? Effect.fail(new
|
|
2538
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2118
2539
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2119
2540
|
*
|
|
2120
2541
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2172,15 +2593,17 @@ export const flatMap: {
|
|
|
2172
2593
|
*
|
|
2173
2594
|
* @example
|
|
2174
2595
|
* ```ts
|
|
2175
|
-
* import { Effect, pipe } from "effect"
|
|
2596
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2597
|
+
*
|
|
2598
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2176
2599
|
*
|
|
2177
2600
|
* // Function to apply a discount safely to a transaction amount
|
|
2178
2601
|
* const applyDiscount = (
|
|
2179
2602
|
* total: number,
|
|
2180
2603
|
* discountRate: number
|
|
2181
|
-
* ): Effect.Effect<number,
|
|
2604
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2182
2605
|
* discountRate === 0
|
|
2183
|
-
* ? Effect.fail(new
|
|
2606
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2184
2607
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2185
2608
|
*
|
|
2186
2609
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2238,15 +2661,17 @@ export const flatMap: {
|
|
|
2238
2661
|
*
|
|
2239
2662
|
* @example
|
|
2240
2663
|
* ```ts
|
|
2241
|
-
* import { Effect, pipe } from "effect"
|
|
2664
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2665
|
+
*
|
|
2666
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2242
2667
|
*
|
|
2243
2668
|
* // Function to apply a discount safely to a transaction amount
|
|
2244
2669
|
* const applyDiscount = (
|
|
2245
2670
|
* total: number,
|
|
2246
2671
|
* discountRate: number
|
|
2247
|
-
* ): Effect.Effect<number,
|
|
2672
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2248
2673
|
* discountRate === 0
|
|
2249
|
-
* ? Effect.fail(new
|
|
2674
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2250
2675
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2251
2676
|
*
|
|
2252
2677
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2334,15 +2759,17 @@ export const flatten: <A, E, R, E2, R2>(self: Effect<Effect<A, E, R>, E2, R2>) =
|
|
|
2334
2759
|
*
|
|
2335
2760
|
* @example Applying a Discount Based on Fetched Amount
|
|
2336
2761
|
* ```ts
|
|
2337
|
-
* import { Effect, pipe } from "effect"
|
|
2762
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2763
|
+
*
|
|
2764
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2338
2765
|
*
|
|
2339
2766
|
* // Function to apply a discount safely to a transaction amount
|
|
2340
2767
|
* const applyDiscount = (
|
|
2341
2768
|
* total: number,
|
|
2342
2769
|
* discountRate: number
|
|
2343
|
-
* ): Effect.Effect<number,
|
|
2770
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2344
2771
|
* discountRate === 0
|
|
2345
|
-
* ? Effect.fail(new
|
|
2772
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2346
2773
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2347
2774
|
*
|
|
2348
2775
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2415,15 +2842,17 @@ export const andThen: {
|
|
|
2415
2842
|
*
|
|
2416
2843
|
* @example Applying a Discount Based on Fetched Amount
|
|
2417
2844
|
* ```ts
|
|
2418
|
-
* import { Effect, pipe } from "effect"
|
|
2845
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2846
|
+
*
|
|
2847
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2419
2848
|
*
|
|
2420
2849
|
* // Function to apply a discount safely to a transaction amount
|
|
2421
2850
|
* const applyDiscount = (
|
|
2422
2851
|
* total: number,
|
|
2423
2852
|
* discountRate: number
|
|
2424
|
-
* ): Effect.Effect<number,
|
|
2853
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2425
2854
|
* discountRate === 0
|
|
2426
|
-
* ? Effect.fail(new
|
|
2855
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2427
2856
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2428
2857
|
*
|
|
2429
2858
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2496,15 +2925,17 @@ export const andThen: {
|
|
|
2496
2925
|
*
|
|
2497
2926
|
* @example Applying a Discount Based on Fetched Amount
|
|
2498
2927
|
* ```ts
|
|
2499
|
-
* import { Effect, pipe } from "effect"
|
|
2928
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2929
|
+
*
|
|
2930
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2500
2931
|
*
|
|
2501
2932
|
* // Function to apply a discount safely to a transaction amount
|
|
2502
2933
|
* const applyDiscount = (
|
|
2503
2934
|
* total: number,
|
|
2504
2935
|
* discountRate: number
|
|
2505
|
-
* ): Effect.Effect<number,
|
|
2936
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2506
2937
|
* discountRate === 0
|
|
2507
|
-
* ? Effect.fail(new
|
|
2938
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2508
2939
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2509
2940
|
*
|
|
2510
2941
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2577,15 +3008,17 @@ export const andThen: {
|
|
|
2577
3008
|
*
|
|
2578
3009
|
* @example Applying a Discount Based on Fetched Amount
|
|
2579
3010
|
* ```ts
|
|
2580
|
-
* import { Effect, pipe } from "effect"
|
|
3011
|
+
* import { Data, Effect, pipe } from "effect"
|
|
3012
|
+
*
|
|
3013
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2581
3014
|
*
|
|
2582
3015
|
* // Function to apply a discount safely to a transaction amount
|
|
2583
3016
|
* const applyDiscount = (
|
|
2584
3017
|
* total: number,
|
|
2585
3018
|
* discountRate: number
|
|
2586
|
-
* ): Effect.Effect<number,
|
|
3019
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2587
3020
|
* discountRate === 0
|
|
2588
|
-
* ? Effect.fail(new
|
|
3021
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2589
3022
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2590
3023
|
*
|
|
2591
3024
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2658,15 +3091,17 @@ export const andThen: {
|
|
|
2658
3091
|
*
|
|
2659
3092
|
* @example Applying a Discount Based on Fetched Amount
|
|
2660
3093
|
* ```ts
|
|
2661
|
-
* import { Effect, pipe } from "effect"
|
|
3094
|
+
* import { Data, Effect, pipe } from "effect"
|
|
3095
|
+
*
|
|
3096
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2662
3097
|
*
|
|
2663
3098
|
* // Function to apply a discount safely to a transaction amount
|
|
2664
3099
|
* const applyDiscount = (
|
|
2665
3100
|
* total: number,
|
|
2666
3101
|
* discountRate: number
|
|
2667
|
-
* ): Effect.Effect<number,
|
|
3102
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2668
3103
|
* discountRate === 0
|
|
2669
|
-
* ? Effect.fail(new
|
|
3104
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2670
3105
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2671
3106
|
*
|
|
2672
3107
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2725,16 +3160,18 @@ export const andThen: {
|
|
|
2725
3160
|
* @example
|
|
2726
3161
|
* ```ts
|
|
2727
3162
|
* // Title: Logging a step in a pipeline
|
|
2728
|
-
* import { Effect, pipe } from "effect"
|
|
3163
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2729
3164
|
* import { Console } from "effect"
|
|
2730
3165
|
*
|
|
3166
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3167
|
+
*
|
|
2731
3168
|
* // Function to apply a discount safely to a transaction amount
|
|
2732
3169
|
* const applyDiscount = (
|
|
2733
3170
|
* total: number,
|
|
2734
3171
|
* discountRate: number
|
|
2735
|
-
* ): Effect.Effect<number,
|
|
3172
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2736
3173
|
* discountRate === 0
|
|
2737
|
-
* ? Effect.fail(new
|
|
3174
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2738
3175
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2739
3176
|
*
|
|
2740
3177
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2784,16 +3221,18 @@ export const tap: {
|
|
|
2784
3221
|
* @example
|
|
2785
3222
|
* ```ts
|
|
2786
3223
|
* // Title: Logging a step in a pipeline
|
|
2787
|
-
* import { Effect, pipe } from "effect"
|
|
3224
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2788
3225
|
* import { Console } from "effect"
|
|
2789
3226
|
*
|
|
3227
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3228
|
+
*
|
|
2790
3229
|
* // Function to apply a discount safely to a transaction amount
|
|
2791
3230
|
* const applyDiscount = (
|
|
2792
3231
|
* total: number,
|
|
2793
3232
|
* discountRate: number
|
|
2794
|
-
* ): Effect.Effect<number,
|
|
3233
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2795
3234
|
* discountRate === 0
|
|
2796
|
-
* ? Effect.fail(new
|
|
3235
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2797
3236
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2798
3237
|
*
|
|
2799
3238
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2843,16 +3282,18 @@ export const tap: {
|
|
|
2843
3282
|
* @example
|
|
2844
3283
|
* ```ts
|
|
2845
3284
|
* // Title: Logging a step in a pipeline
|
|
2846
|
-
* import { Effect, pipe } from "effect"
|
|
3285
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2847
3286
|
* import { Console } from "effect"
|
|
2848
3287
|
*
|
|
3288
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3289
|
+
*
|
|
2849
3290
|
* // Function to apply a discount safely to a transaction amount
|
|
2850
3291
|
* const applyDiscount = (
|
|
2851
3292
|
* total: number,
|
|
2852
3293
|
* discountRate: number
|
|
2853
|
-
* ): Effect.Effect<number,
|
|
3294
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2854
3295
|
* discountRate === 0
|
|
2855
|
-
* ? Effect.fail(new
|
|
3296
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2856
3297
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2857
3298
|
*
|
|
2858
3299
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2902,16 +3343,18 @@ export const tap: {
|
|
|
2902
3343
|
* @example
|
|
2903
3344
|
* ```ts
|
|
2904
3345
|
* // Title: Logging a step in a pipeline
|
|
2905
|
-
* import { Effect, pipe } from "effect"
|
|
3346
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2906
3347
|
* import { Console } from "effect"
|
|
2907
3348
|
*
|
|
3349
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3350
|
+
*
|
|
2908
3351
|
* // Function to apply a discount safely to a transaction amount
|
|
2909
3352
|
* const applyDiscount = (
|
|
2910
3353
|
* total: number,
|
|
2911
3354
|
* discountRate: number
|
|
2912
|
-
* ): Effect.Effect<number,
|
|
3355
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2913
3356
|
* discountRate === 0
|
|
2914
|
-
* ? Effect.fail(new
|
|
3357
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2915
3358
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2916
3359
|
*
|
|
2917
3360
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2961,16 +3404,18 @@ export const tap: {
|
|
|
2961
3404
|
* @example
|
|
2962
3405
|
* ```ts
|
|
2963
3406
|
* // Title: Logging a step in a pipeline
|
|
2964
|
-
* import { Effect, pipe } from "effect"
|
|
3407
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2965
3408
|
* import { Console } from "effect"
|
|
2966
3409
|
*
|
|
3410
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3411
|
+
*
|
|
2967
3412
|
* // Function to apply a discount safely to a transaction amount
|
|
2968
3413
|
* const applyDiscount = (
|
|
2969
3414
|
* total: number,
|
|
2970
3415
|
* discountRate: number
|
|
2971
|
-
* ): Effect.Effect<number,
|
|
3416
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2972
3417
|
* discountRate === 0
|
|
2973
|
-
* ? Effect.fail(new
|
|
3418
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2974
3419
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2975
3420
|
*
|
|
2976
3421
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -3796,12 +4241,12 @@ export {
|
|
|
3796
4241
|
*
|
|
3797
4242
|
* **Details**
|
|
3798
4243
|
*
|
|
3799
|
-
* The `
|
|
4244
|
+
* The `catch` function catches any errors that may occur during the
|
|
3800
4245
|
* execution of an effect and allows you to handle them by specifying a fallback
|
|
3801
4246
|
* effect. This ensures that the program continues without failing by recovering
|
|
3802
4247
|
* from errors using the provided fallback logic.
|
|
3803
4248
|
*
|
|
3804
|
-
* **Note**: `
|
|
4249
|
+
* **Note**: `catch` only handles recoverable errors. It will not recover
|
|
3805
4250
|
* from unrecoverable defects.
|
|
3806
4251
|
*
|
|
3807
4252
|
* @see {@link catchCause} for a version that can recover from both recoverable and unrecoverable errors.
|
|
@@ -3985,7 +4430,8 @@ export const catchTag: {
|
|
|
3985
4430
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3986
4431
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3987
4432
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3988
|
-
* error types in a single call.
|
|
4433
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4434
|
+
* unhandled errors.
|
|
3989
4435
|
*
|
|
3990
4436
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3991
4437
|
* field is used to identify and match errors.
|
|
@@ -4027,7 +4473,8 @@ export const catchTags: {
|
|
|
4027
4473
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
4028
4474
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
4029
4475
|
* for that specific error. This allows you to catch and recover from multiple
|
|
4030
|
-
* error types in a single call.
|
|
4476
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4477
|
+
* unhandled errors.
|
|
4031
4478
|
*
|
|
4032
4479
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
4033
4480
|
* field is used to identify and match errors.
|
|
@@ -4063,19 +4510,27 @@ export const catchTags: {
|
|
|
4063
4510
|
E,
|
|
4064
4511
|
Cases extends
|
|
4065
4512
|
& { [K in Extract<E, { _tag: string }>["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => Effect<any, any, any>) }
|
|
4066
|
-
& (unknown extends E ? {} : { [K in Exclude<keyof Cases, Extract<E, { _tag: string }>["_tag"]>]: never })
|
|
4067
|
-
|
|
4513
|
+
& (unknown extends E ? {} : { [K in Exclude<keyof Cases, Extract<E, { _tag: string }>["_tag"]>]: never }),
|
|
4514
|
+
A2 = never,
|
|
4515
|
+
E2 = Exclude<E, { _tag: keyof Cases }>,
|
|
4516
|
+
R2 = never
|
|
4517
|
+
>(
|
|
4518
|
+
cases: Cases,
|
|
4519
|
+
orElse?: ((e: Exclude<E, { _tag: keyof Cases }>) => Effect<A2, E2, R2>) | undefined
|
|
4520
|
+
): <A, R>(
|
|
4068
4521
|
self: Effect<A, E, R>
|
|
4069
4522
|
) => Effect<
|
|
4070
4523
|
| A
|
|
4524
|
+
| A2
|
|
4071
4525
|
| {
|
|
4072
4526
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never
|
|
4073
4527
|
}[keyof Cases],
|
|
4074
|
-
|
|
|
4528
|
+
| E2
|
|
4075
4529
|
| {
|
|
4076
4530
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never
|
|
4077
4531
|
}[keyof Cases],
|
|
4078
4532
|
| R
|
|
4533
|
+
| R2
|
|
4079
4534
|
| {
|
|
4080
4535
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never
|
|
4081
4536
|
}[keyof Cases]
|
|
@@ -4089,7 +4544,8 @@ export const catchTags: {
|
|
|
4089
4544
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
4090
4545
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
4091
4546
|
* for that specific error. This allows you to catch and recover from multiple
|
|
4092
|
-
* error types in a single call.
|
|
4547
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4548
|
+
* unhandled errors.
|
|
4093
4549
|
*
|
|
4094
4550
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
4095
4551
|
* field is used to identify and match errors.
|
|
@@ -4127,17 +4583,26 @@ export const catchTags: {
|
|
|
4127
4583
|
A,
|
|
4128
4584
|
Cases extends
|
|
4129
4585
|
& { [K in Extract<E, { _tag: string }>["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => Effect<any, any, any>) }
|
|
4130
|
-
& (unknown extends E ? {} : { [K in Exclude<keyof Cases, Extract<E, { _tag: string }>["_tag"]>]: never })
|
|
4131
|
-
|
|
4586
|
+
& (unknown extends E ? {} : { [K in Exclude<keyof Cases, Extract<E, { _tag: string }>["_tag"]>]: never }),
|
|
4587
|
+
A2 = never,
|
|
4588
|
+
E2 = Exclude<E, { _tag: keyof Cases }>,
|
|
4589
|
+
R2 = never
|
|
4590
|
+
>(
|
|
4591
|
+
self: Effect<A, E, R>,
|
|
4592
|
+
cases: Cases,
|
|
4593
|
+
orElse?: ((e: Exclude<E, { _tag: keyof Cases }>) => Effect<A2, E2, R2>) | undefined
|
|
4594
|
+
): Effect<
|
|
4132
4595
|
| A
|
|
4596
|
+
| A2
|
|
4133
4597
|
| {
|
|
4134
4598
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never
|
|
4135
4599
|
}[keyof Cases],
|
|
4136
|
-
|
|
|
4600
|
+
| E2
|
|
4137
4601
|
| {
|
|
4138
4602
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never
|
|
4139
4603
|
}[keyof Cases],
|
|
4140
4604
|
| R
|
|
4605
|
+
| R2
|
|
4141
4606
|
| {
|
|
4142
4607
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never
|
|
4143
4608
|
}[keyof Cases]
|
|
@@ -4228,8 +4693,16 @@ export const catchReason: {
|
|
|
4228
4693
|
>(
|
|
4229
4694
|
errorTag: K,
|
|
4230
4695
|
reasonTag: RK,
|
|
4231
|
-
f: (
|
|
4232
|
-
|
|
4696
|
+
f: (
|
|
4697
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4698
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4699
|
+
) => Effect<A2, E2, R2>,
|
|
4700
|
+
orElse?:
|
|
4701
|
+
| ((
|
|
4702
|
+
reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4703
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4704
|
+
) => Effect<A3, E3, R3>)
|
|
4705
|
+
| undefined
|
|
4233
4706
|
): <A, R>(
|
|
4234
4707
|
self: Effect<A, E, R>
|
|
4235
4708
|
) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
|
|
@@ -4284,8 +4757,10 @@ export const catchReason: {
|
|
|
4284
4757
|
self: Effect<A, E, R>,
|
|
4285
4758
|
errorTag: K,
|
|
4286
4759
|
reasonTag: RK,
|
|
4287
|
-
f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>,
|
|
4288
|
-
orElse?:
|
|
4760
|
+
f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>,
|
|
4761
|
+
orElse?:
|
|
4762
|
+
| ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>)
|
|
4763
|
+
| undefined
|
|
4289
4764
|
): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>
|
|
4290
4765
|
} = internal.catchReason
|
|
4291
4766
|
|
|
@@ -4363,7 +4838,8 @@ export const catchReasons: {
|
|
|
4363
4838
|
E,
|
|
4364
4839
|
Cases extends {
|
|
4365
4840
|
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (
|
|
4366
|
-
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK
|
|
4841
|
+
reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>,
|
|
4842
|
+
error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>
|
|
4367
4843
|
) => Effect<any, any, any>
|
|
4368
4844
|
},
|
|
4369
4845
|
A2 = unassigned,
|
|
@@ -4373,7 +4849,10 @@ export const catchReasons: {
|
|
|
4373
4849
|
errorTag: K,
|
|
4374
4850
|
cases: Cases,
|
|
4375
4851
|
orElse?:
|
|
4376
|
-
| ((
|
|
4852
|
+
| ((
|
|
4853
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
4854
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
4855
|
+
) => Effect<A2, E2, R2>)
|
|
4377
4856
|
| undefined
|
|
4378
4857
|
): <A, R>(
|
|
4379
4858
|
self: Effect<A, E, R>
|
|
@@ -4434,7 +4913,10 @@ export const catchReasons: {
|
|
|
4434
4913
|
R,
|
|
4435
4914
|
K extends Tags<E>,
|
|
4436
4915
|
Cases extends {
|
|
4437
|
-
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
4916
|
+
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
4917
|
+
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
4918
|
+
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
4919
|
+
) => Effect<any, any, any>
|
|
4438
4920
|
},
|
|
4439
4921
|
A2 = unassigned,
|
|
4440
4922
|
E2 = never,
|
|
@@ -4444,7 +4926,10 @@ export const catchReasons: {
|
|
|
4444
4926
|
errorTag: K,
|
|
4445
4927
|
cases: Cases,
|
|
4446
4928
|
orElse?:
|
|
4447
|
-
| ((
|
|
4929
|
+
| ((
|
|
4930
|
+
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
4931
|
+
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
4932
|
+
) => Effect<A2, E2, R2>)
|
|
4448
4933
|
| undefined
|
|
4449
4934
|
): Effect<
|
|
4450
4935
|
| A
|
|
@@ -4870,15 +5355,14 @@ export const catchDefect: {
|
|
|
4870
5355
|
} = internal.catchDefect
|
|
4871
5356
|
|
|
4872
5357
|
/**
|
|
4873
|
-
* Recovers from specific errors using a `
|
|
4874
|
-
* `Refinement`.
|
|
5358
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4875
5359
|
*
|
|
4876
5360
|
* **When to Use**
|
|
4877
5361
|
*
|
|
4878
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4879
|
-
* `
|
|
4880
|
-
*
|
|
4881
|
-
*
|
|
5362
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5363
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5364
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5365
|
+
* interrupts are not caught.
|
|
4882
5366
|
*
|
|
4883
5367
|
* **Previously Known As**
|
|
4884
5368
|
*
|
|
@@ -4905,7 +5389,7 @@ export const catchDefect: {
|
|
|
4905
5389
|
*
|
|
4906
5390
|
* // With a Filter
|
|
4907
5391
|
* const recovered2 = program.pipe(
|
|
4908
|
-
* Effect.
|
|
5392
|
+
* Effect.catchFilter(
|
|
4909
5393
|
* Filter.tagged("NotFound"),
|
|
4910
5394
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4911
5395
|
* )
|
|
@@ -4917,15 +5401,14 @@ export const catchDefect: {
|
|
|
4917
5401
|
*/
|
|
4918
5402
|
export const catchIf: {
|
|
4919
5403
|
/**
|
|
4920
|
-
* Recovers from specific errors using a `
|
|
4921
|
-
* `Refinement`.
|
|
5404
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4922
5405
|
*
|
|
4923
5406
|
* **When to Use**
|
|
4924
5407
|
*
|
|
4925
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4926
|
-
* `
|
|
4927
|
-
*
|
|
4928
|
-
*
|
|
5408
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5409
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5410
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5411
|
+
* interrupts are not caught.
|
|
4929
5412
|
*
|
|
4930
5413
|
* **Previously Known As**
|
|
4931
5414
|
*
|
|
@@ -4952,7 +5435,7 @@ export const catchIf: {
|
|
|
4952
5435
|
*
|
|
4953
5436
|
* // With a Filter
|
|
4954
5437
|
* const recovered2 = program.pipe(
|
|
4955
|
-
* Effect.
|
|
5438
|
+
* Effect.catchFilter(
|
|
4956
5439
|
* Filter.tagged("NotFound"),
|
|
4957
5440
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4958
5441
|
* )
|
|
@@ -4968,15 +5451,14 @@ export const catchIf: {
|
|
|
4968
5451
|
orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined
|
|
4969
5452
|
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
4970
5453
|
/**
|
|
4971
|
-
* Recovers from specific errors using a `
|
|
4972
|
-
* `Refinement`.
|
|
5454
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4973
5455
|
*
|
|
4974
5456
|
* **When to Use**
|
|
4975
5457
|
*
|
|
4976
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4977
|
-
* `
|
|
4978
|
-
*
|
|
4979
|
-
*
|
|
5458
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5459
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5460
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5461
|
+
* interrupts are not caught.
|
|
4980
5462
|
*
|
|
4981
5463
|
* **Previously Known As**
|
|
4982
5464
|
*
|
|
@@ -5003,7 +5485,7 @@ export const catchIf: {
|
|
|
5003
5485
|
*
|
|
5004
5486
|
* // With a Filter
|
|
5005
5487
|
* const recovered2 = program.pipe(
|
|
5006
|
-
* Effect.
|
|
5488
|
+
* Effect.catchFilter(
|
|
5007
5489
|
* Filter.tagged("NotFound"),
|
|
5008
5490
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5009
5491
|
* )
|
|
@@ -5013,21 +5495,20 @@ export const catchIf: {
|
|
|
5013
5495
|
* @since 2.0.0
|
|
5014
5496
|
* @category Error Handling
|
|
5015
5497
|
*/
|
|
5016
|
-
<E,
|
|
5017
|
-
|
|
5018
|
-
f: (e:
|
|
5019
|
-
orElse?: ((e:
|
|
5498
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
5499
|
+
predicate: Predicate.Predicate<NoInfer<E>>,
|
|
5500
|
+
f: (e: NoInfer<E>) => Effect<A2, E2, R2>,
|
|
5501
|
+
orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined
|
|
5020
5502
|
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5021
5503
|
/**
|
|
5022
|
-
* Recovers from specific errors using a `
|
|
5023
|
-
* `Refinement`.
|
|
5504
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
5024
5505
|
*
|
|
5025
5506
|
* **When to Use**
|
|
5026
5507
|
*
|
|
5027
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
5028
|
-
* `
|
|
5029
|
-
*
|
|
5030
|
-
*
|
|
5508
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5509
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5510
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5511
|
+
* interrupts are not caught.
|
|
5031
5512
|
*
|
|
5032
5513
|
* **Previously Known As**
|
|
5033
5514
|
*
|
|
@@ -5054,7 +5535,7 @@ export const catchIf: {
|
|
|
5054
5535
|
*
|
|
5055
5536
|
* // With a Filter
|
|
5056
5537
|
* const recovered2 = program.pipe(
|
|
5057
|
-
* Effect.
|
|
5538
|
+
* Effect.catchFilter(
|
|
5058
5539
|
* Filter.tagged("NotFound"),
|
|
5059
5540
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5060
5541
|
* )
|
|
@@ -5071,15 +5552,14 @@ export const catchIf: {
|
|
|
5071
5552
|
orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined
|
|
5072
5553
|
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5073
5554
|
/**
|
|
5074
|
-
* Recovers from specific errors using a `
|
|
5075
|
-
* `Refinement`.
|
|
5555
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
5076
5556
|
*
|
|
5077
5557
|
* **When to Use**
|
|
5078
5558
|
*
|
|
5079
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
5080
|
-
* `
|
|
5081
|
-
*
|
|
5082
|
-
*
|
|
5559
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5560
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5561
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5562
|
+
* interrupts are not caught.
|
|
5083
5563
|
*
|
|
5084
5564
|
* **Previously Known As**
|
|
5085
5565
|
*
|
|
@@ -5106,7 +5586,7 @@ export const catchIf: {
|
|
|
5106
5586
|
*
|
|
5107
5587
|
* // With a Filter
|
|
5108
5588
|
* const recovered2 = program.pipe(
|
|
5109
|
-
* Effect.
|
|
5589
|
+
* Effect.catchFilter(
|
|
5110
5590
|
* Filter.tagged("NotFound"),
|
|
5111
5591
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
5112
5592
|
* )
|
|
@@ -5116,14 +5596,46 @@ export const catchIf: {
|
|
|
5116
5596
|
* @since 2.0.0
|
|
5117
5597
|
* @category Error Handling
|
|
5118
5598
|
*/
|
|
5119
|
-
<A, E, R,
|
|
5599
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(
|
|
5120
5600
|
self: Effect<A, E, R>,
|
|
5121
|
-
|
|
5122
|
-
f: (e:
|
|
5123
|
-
orElse?: ((e:
|
|
5601
|
+
predicate: Predicate.Predicate<E>,
|
|
5602
|
+
f: (e: E) => Effect<A2, E2, R2>,
|
|
5603
|
+
orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined
|
|
5124
5604
|
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5125
5605
|
} = internal.catchIf
|
|
5126
5606
|
|
|
5607
|
+
/**
|
|
5608
|
+
* Recovers from specific errors using a `Filter`.
|
|
5609
|
+
*
|
|
5610
|
+
* @since 4.0.0
|
|
5611
|
+
* @category Error Handling
|
|
5612
|
+
*/
|
|
5613
|
+
export const catchFilter: {
|
|
5614
|
+
/**
|
|
5615
|
+
* Recovers from specific errors using a `Filter`.
|
|
5616
|
+
*
|
|
5617
|
+
* @since 4.0.0
|
|
5618
|
+
* @category Error Handling
|
|
5619
|
+
*/
|
|
5620
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
5621
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
5622
|
+
f: (e: EB) => Effect<A2, E2, R2>,
|
|
5623
|
+
orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined
|
|
5624
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5625
|
+
/**
|
|
5626
|
+
* Recovers from specific errors using a `Filter`.
|
|
5627
|
+
*
|
|
5628
|
+
* @since 4.0.0
|
|
5629
|
+
* @category Error Handling
|
|
5630
|
+
*/
|
|
5631
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(
|
|
5632
|
+
self: Effect<A, E, R>,
|
|
5633
|
+
filter: Filter.Filter<NoInfer<E>, EB, X>,
|
|
5634
|
+
f: (e: EB) => Effect<A2, E2, R2>,
|
|
5635
|
+
orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined
|
|
5636
|
+
): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>
|
|
5637
|
+
} = internal.catchFilter
|
|
5638
|
+
|
|
5127
5639
|
/**
|
|
5128
5640
|
* Catches `NoSuchElementError` failures and converts them to `Option.none`.
|
|
5129
5641
|
*
|
|
@@ -5231,10 +5743,10 @@ export const catchCauseIf: {
|
|
|
5231
5743
|
* @since 4.0.0
|
|
5232
5744
|
* @category Error Handling
|
|
5233
5745
|
*/
|
|
5234
|
-
<E,
|
|
5235
|
-
|
|
5236
|
-
f: (
|
|
5237
|
-
): <A, R>(self: Effect<A, E, R>) => Effect<A | B,
|
|
5746
|
+
<E, B, E2, R2>(
|
|
5747
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
5748
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5749
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>
|
|
5238
5750
|
/**
|
|
5239
5751
|
* Recovers from specific failures based on a predicate.
|
|
5240
5752
|
*
|
|
@@ -5273,13 +5785,43 @@ export const catchCauseIf: {
|
|
|
5273
5785
|
* @since 4.0.0
|
|
5274
5786
|
* @category Error Handling
|
|
5275
5787
|
*/
|
|
5276
|
-
<A, E, R, B, E2, R2
|
|
5788
|
+
<A, E, R, B, E2, R2>(
|
|
5277
5789
|
self: Effect<A, E, R>,
|
|
5278
|
-
|
|
5279
|
-
f: (
|
|
5280
|
-
): Effect<A | B,
|
|
5790
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
5791
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5792
|
+
): Effect<A | B, E | E2, R | R2>
|
|
5281
5793
|
} = internal.catchCauseIf
|
|
5282
5794
|
|
|
5795
|
+
/**
|
|
5796
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5797
|
+
*
|
|
5798
|
+
* @since 4.0.0
|
|
5799
|
+
* @category Error Handling
|
|
5800
|
+
*/
|
|
5801
|
+
export const catchCauseFilter: {
|
|
5802
|
+
/**
|
|
5803
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5804
|
+
*
|
|
5805
|
+
* @since 4.0.0
|
|
5806
|
+
* @category Error Handling
|
|
5807
|
+
*/
|
|
5808
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
5809
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
5810
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5811
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
5812
|
+
/**
|
|
5813
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5814
|
+
*
|
|
5815
|
+
* @since 4.0.0
|
|
5816
|
+
* @category Error Handling
|
|
5817
|
+
*/
|
|
5818
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
5819
|
+
self: Effect<A, E, R>,
|
|
5820
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
5821
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5822
|
+
): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>
|
|
5823
|
+
} = internal.catchCauseFilter
|
|
5824
|
+
|
|
5283
5825
|
/**
|
|
5284
5826
|
* The `mapError` function is used to transform or modify the error
|
|
5285
5827
|
* produced by an effect, without affecting its success value.
|
|
@@ -5295,17 +5837,19 @@ export const catchCauseIf: {
|
|
|
5295
5837
|
*
|
|
5296
5838
|
* @example
|
|
5297
5839
|
* ```ts
|
|
5298
|
-
* import { Effect } from "effect"
|
|
5840
|
+
* import { Data, Effect } from "effect"
|
|
5841
|
+
*
|
|
5842
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5299
5843
|
*
|
|
5300
5844
|
* // ┌─── Effect<number, string, never>
|
|
5301
5845
|
* // ▼
|
|
5302
5846
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5303
5847
|
*
|
|
5304
|
-
* // ┌─── Effect<number,
|
|
5848
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
5305
5849
|
* // ▼
|
|
5306
5850
|
* const mapped = Effect.mapError(
|
|
5307
5851
|
* simulatedTask,
|
|
5308
|
-
* (message) => new
|
|
5852
|
+
* (message) => new TaskError({ message })
|
|
5309
5853
|
* )
|
|
5310
5854
|
* ```
|
|
5311
5855
|
*
|
|
@@ -5328,17 +5872,19 @@ export const mapError: {
|
|
|
5328
5872
|
*
|
|
5329
5873
|
* @example
|
|
5330
5874
|
* ```ts
|
|
5331
|
-
* import { Effect } from "effect"
|
|
5875
|
+
* import { Data, Effect } from "effect"
|
|
5876
|
+
*
|
|
5877
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5332
5878
|
*
|
|
5333
5879
|
* // ┌─── Effect<number, string, never>
|
|
5334
5880
|
* // ▼
|
|
5335
5881
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5336
5882
|
*
|
|
5337
|
-
* // ┌─── Effect<number,
|
|
5883
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
5338
5884
|
* // ▼
|
|
5339
5885
|
* const mapped = Effect.mapError(
|
|
5340
5886
|
* simulatedTask,
|
|
5341
|
-
* (message) => new
|
|
5887
|
+
* (message) => new TaskError({ message })
|
|
5342
5888
|
* )
|
|
5343
5889
|
* ```
|
|
5344
5890
|
*
|
|
@@ -5361,17 +5907,19 @@ export const mapError: {
|
|
|
5361
5907
|
*
|
|
5362
5908
|
* @example
|
|
5363
5909
|
* ```ts
|
|
5364
|
-
* import { Effect } from "effect"
|
|
5910
|
+
* import { Data, Effect } from "effect"
|
|
5911
|
+
*
|
|
5912
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5365
5913
|
*
|
|
5366
5914
|
* // ┌─── Effect<number, string, never>
|
|
5367
5915
|
* // ▼
|
|
5368
5916
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5369
5917
|
*
|
|
5370
|
-
* // ┌─── Effect<number,
|
|
5918
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
5371
5919
|
* // ▼
|
|
5372
5920
|
* const mapped = Effect.mapError(
|
|
5373
5921
|
* simulatedTask,
|
|
5374
|
-
* (message) => new
|
|
5922
|
+
* (message) => new TaskError({ message })
|
|
5375
5923
|
* )
|
|
5376
5924
|
* ```
|
|
5377
5925
|
*
|
|
@@ -5393,16 +5941,18 @@ export const mapError: {
|
|
|
5393
5941
|
*
|
|
5394
5942
|
* @example
|
|
5395
5943
|
* ```ts
|
|
5396
|
-
* import { Effect } from "effect"
|
|
5944
|
+
* import { Data, Effect } from "effect"
|
|
5945
|
+
*
|
|
5946
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5397
5947
|
*
|
|
5398
5948
|
* // ┌─── Effect<number, string, never>
|
|
5399
5949
|
* // ▼
|
|
5400
5950
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5401
5951
|
*
|
|
5402
|
-
* // ┌─── Effect<boolean,
|
|
5952
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5403
5953
|
* // ▼
|
|
5404
5954
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5405
|
-
* onFailure: (message) => new
|
|
5955
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5406
5956
|
* onSuccess: (n) => n > 0
|
|
5407
5957
|
* })
|
|
5408
5958
|
* ```
|
|
@@ -5426,16 +5976,18 @@ export const mapBoth: {
|
|
|
5426
5976
|
*
|
|
5427
5977
|
* @example
|
|
5428
5978
|
* ```ts
|
|
5429
|
-
* import { Effect } from "effect"
|
|
5979
|
+
* import { Data, Effect } from "effect"
|
|
5980
|
+
*
|
|
5981
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5430
5982
|
*
|
|
5431
5983
|
* // ┌─── Effect<number, string, never>
|
|
5432
5984
|
* // ▼
|
|
5433
5985
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5434
5986
|
*
|
|
5435
|
-
* // ┌─── Effect<boolean,
|
|
5987
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5436
5988
|
* // ▼
|
|
5437
5989
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5438
|
-
* onFailure: (message) => new
|
|
5990
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5439
5991
|
* onSuccess: (n) => n > 0
|
|
5440
5992
|
* })
|
|
5441
5993
|
* ```
|
|
@@ -5461,16 +6013,18 @@ export const mapBoth: {
|
|
|
5461
6013
|
*
|
|
5462
6014
|
* @example
|
|
5463
6015
|
* ```ts
|
|
5464
|
-
* import { Effect } from "effect"
|
|
6016
|
+
* import { Data, Effect } from "effect"
|
|
6017
|
+
*
|
|
6018
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5465
6019
|
*
|
|
5466
6020
|
* // ┌─── Effect<number, string, never>
|
|
5467
6021
|
* // ▼
|
|
5468
6022
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5469
6023
|
*
|
|
5470
|
-
* // ┌─── Effect<boolean,
|
|
6024
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5471
6025
|
* // ▼
|
|
5472
6026
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5473
|
-
* onFailure: (message) => new
|
|
6027
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5474
6028
|
* onSuccess: (n) => n > 0
|
|
5475
6029
|
* })
|
|
5476
6030
|
* ```
|
|
@@ -5505,11 +6059,13 @@ export const mapBoth: {
|
|
|
5505
6059
|
* @example
|
|
5506
6060
|
* ```ts
|
|
5507
6061
|
* // Title: Propagating an Error as a Defect
|
|
5508
|
-
* import { Effect } from "effect"
|
|
6062
|
+
* import { Data, Effect } from "effect"
|
|
6063
|
+
*
|
|
6064
|
+
* class DivideByZeroError extends Data.TaggedError("DivideByZeroError")<{}> {}
|
|
5509
6065
|
*
|
|
5510
6066
|
* const divide = (a: number, b: number) =>
|
|
5511
6067
|
* b === 0
|
|
5512
|
-
* ? Effect.fail(new
|
|
6068
|
+
* ? Effect.fail(new DivideByZeroError())
|
|
5513
6069
|
* : Effect.succeed(a / b)
|
|
5514
6070
|
*
|
|
5515
6071
|
* // ┌─── Effect<number, never, never>
|
|
@@ -5518,7 +6074,7 @@ export const mapBoth: {
|
|
|
5518
6074
|
*
|
|
5519
6075
|
* Effect.runPromise(program).catch(console.error)
|
|
5520
6076
|
* // Output:
|
|
5521
|
-
* // (FiberFailure)
|
|
6077
|
+
* // (FiberFailure) DivideByZeroError
|
|
5522
6078
|
* // ...stack trace...
|
|
5523
6079
|
* ```
|
|
5524
6080
|
*
|
|
@@ -5905,9 +6461,9 @@ export const tapCauseIf: {
|
|
|
5905
6461
|
* @since 4.0.0
|
|
5906
6462
|
* @category Sequencing
|
|
5907
6463
|
*/
|
|
5908
|
-
<E,
|
|
5909
|
-
|
|
5910
|
-
f: (
|
|
6464
|
+
<E, B, E2, R2>(
|
|
6465
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
6466
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5911
6467
|
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>
|
|
5912
6468
|
/**
|
|
5913
6469
|
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
@@ -5937,13 +6493,43 @@ export const tapCauseIf: {
|
|
|
5937
6493
|
* @since 4.0.0
|
|
5938
6494
|
* @category Sequencing
|
|
5939
6495
|
*/
|
|
5940
|
-
<A, E, R,
|
|
6496
|
+
<A, E, R, B, E2, R2>(
|
|
5941
6497
|
self: Effect<A, E, R>,
|
|
5942
|
-
|
|
5943
|
-
f: (
|
|
6498
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
6499
|
+
f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
5944
6500
|
): Effect<A, E | E2, R | R2>
|
|
5945
6501
|
} = internal.tapCauseIf
|
|
5946
6502
|
|
|
6503
|
+
/**
|
|
6504
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6505
|
+
*
|
|
6506
|
+
* @since 4.0.0
|
|
6507
|
+
* @category Sequencing
|
|
6508
|
+
*/
|
|
6509
|
+
export const tapCauseFilter: {
|
|
6510
|
+
/**
|
|
6511
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6512
|
+
*
|
|
6513
|
+
* @since 4.0.0
|
|
6514
|
+
* @category Sequencing
|
|
6515
|
+
*/
|
|
6516
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
6517
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
6518
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
6519
|
+
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>
|
|
6520
|
+
/**
|
|
6521
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
6522
|
+
*
|
|
6523
|
+
* @since 4.0.0
|
|
6524
|
+
* @category Sequencing
|
|
6525
|
+
*/
|
|
6526
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(
|
|
6527
|
+
self: Effect<A, E, R>,
|
|
6528
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
6529
|
+
f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>
|
|
6530
|
+
): Effect<A, E | E2, R | R2>
|
|
6531
|
+
} = internal.tapCauseFilter
|
|
6532
|
+
|
|
5947
6533
|
/**
|
|
5948
6534
|
* Inspect severe errors or defects (non-recoverable failures) in an effect.
|
|
5949
6535
|
*
|
|
@@ -6120,7 +6706,7 @@ export const tapDefect: {
|
|
|
6120
6706
|
* attempts++
|
|
6121
6707
|
* yield* Console.log(`Attempt ${attempts}`)
|
|
6122
6708
|
* if (attempts < 3) {
|
|
6123
|
-
* yield* Effect.fail("Not ready")
|
|
6709
|
+
* return yield* Effect.fail("Not ready")
|
|
6124
6710
|
* }
|
|
6125
6711
|
* return "Ready"
|
|
6126
6712
|
* })
|
|
@@ -6173,29 +6759,22 @@ export declare namespace Retry {
|
|
|
6173
6759
|
*/
|
|
6174
6760
|
export type Return<R, E, A, O extends Options<E>> = Effect<
|
|
6175
6761
|
A,
|
|
6176
|
-
| (O extends { schedule: Schedule<infer _O, infer _I, infer _E1, infer _R> } ? E
|
|
6762
|
+
| (O extends { schedule: Schedule<infer _O, infer _I, infer _E1, infer _R> } ? E
|
|
6177
6763
|
: O extends { until: Predicate.Refinement<E, infer E2> } ? E2
|
|
6764
|
+
: O extends { while: Predicate.Refinement<E, infer E2> } ? Exclude<E, E2>
|
|
6178
6765
|
: E)
|
|
6179
6766
|
| (O extends { schedule: Schedule<infer _O, infer _I, infer E, infer _R> } ? E
|
|
6180
6767
|
: never)
|
|
6181
|
-
| (O extends {
|
|
6182
|
-
while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>
|
|
6183
|
-
} ? E
|
|
6768
|
+
| (O extends { while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R> } ? E
|
|
6184
6769
|
: never)
|
|
6185
|
-
| (O extends {
|
|
6186
|
-
until: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>
|
|
6187
|
-
} ? E
|
|
6770
|
+
| (O extends { until: (...args: Array<any>) => Effect<infer _A, infer E, infer _R> } ? E
|
|
6188
6771
|
: never),
|
|
6189
6772
|
| R
|
|
6190
6773
|
| (O extends { schedule: Schedule<infer _O, infer _I, infer _E1, infer R> } ? R
|
|
6191
6774
|
: never)
|
|
6192
|
-
| (O extends {
|
|
6193
|
-
while: (...args: Array<any>) => Effect<infer _A, infer _E, infer R>
|
|
6194
|
-
} ? R
|
|
6775
|
+
| (O extends { while: (...args: Array<any>) => Effect<infer _A, infer _E, infer R> } ? R
|
|
6195
6776
|
: never)
|
|
6196
|
-
| (O extends {
|
|
6197
|
-
until: (...args: Array<any>) => Effect<infer _A, infer _E, infer R>
|
|
6198
|
-
} ? R
|
|
6777
|
+
| (O extends { until: (...args: Array<any>) => Effect<infer _A, infer _E, infer R> } ? R
|
|
6199
6778
|
: never)
|
|
6200
6779
|
> extends infer Z ? Z
|
|
6201
6780
|
: never
|
|
@@ -6247,13 +6826,15 @@ export declare namespace Retry {
|
|
|
6247
6826
|
*
|
|
6248
6827
|
* @example
|
|
6249
6828
|
* ```ts
|
|
6250
|
-
* import { Effect, Schedule } from "effect"
|
|
6829
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6830
|
+
*
|
|
6831
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6251
6832
|
*
|
|
6252
6833
|
* let attempt = 0
|
|
6253
|
-
* const task = Effect.callback<string,
|
|
6834
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6254
6835
|
* attempt++
|
|
6255
6836
|
* if (attempt <= 2) {
|
|
6256
|
-
* resume(Effect.fail(new
|
|
6837
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6257
6838
|
* } else {
|
|
6258
6839
|
* resume(Effect.succeed("Success!"))
|
|
6259
6840
|
* }
|
|
@@ -6296,13 +6877,15 @@ export const retry: {
|
|
|
6296
6877
|
*
|
|
6297
6878
|
* @example
|
|
6298
6879
|
* ```ts
|
|
6299
|
-
* import { Effect, Schedule } from "effect"
|
|
6880
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6881
|
+
*
|
|
6882
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6300
6883
|
*
|
|
6301
6884
|
* let attempt = 0
|
|
6302
|
-
* const task = Effect.callback<string,
|
|
6885
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6303
6886
|
* attempt++
|
|
6304
6887
|
* if (attempt <= 2) {
|
|
6305
|
-
* resume(Effect.fail(new
|
|
6888
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6306
6889
|
* } else {
|
|
6307
6890
|
* resume(Effect.succeed("Success!"))
|
|
6308
6891
|
* }
|
|
@@ -6345,13 +6928,15 @@ export const retry: {
|
|
|
6345
6928
|
*
|
|
6346
6929
|
* @example
|
|
6347
6930
|
* ```ts
|
|
6348
|
-
* import { Effect, Schedule } from "effect"
|
|
6931
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6932
|
+
*
|
|
6933
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6349
6934
|
*
|
|
6350
6935
|
* let attempt = 0
|
|
6351
|
-
* const task = Effect.callback<string,
|
|
6936
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6352
6937
|
* attempt++
|
|
6353
6938
|
* if (attempt <= 2) {
|
|
6354
|
-
* resume(Effect.fail(new
|
|
6939
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6355
6940
|
* } else {
|
|
6356
6941
|
* resume(Effect.succeed("Success!"))
|
|
6357
6942
|
* }
|
|
@@ -6394,13 +6979,15 @@ export const retry: {
|
|
|
6394
6979
|
*
|
|
6395
6980
|
* @example
|
|
6396
6981
|
* ```ts
|
|
6397
|
-
* import { Effect, Schedule } from "effect"
|
|
6982
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6983
|
+
*
|
|
6984
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6398
6985
|
*
|
|
6399
6986
|
* let attempt = 0
|
|
6400
|
-
* const task = Effect.callback<string,
|
|
6987
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6401
6988
|
* attempt++
|
|
6402
6989
|
* if (attempt <= 2) {
|
|
6403
|
-
* resume(Effect.fail(new
|
|
6990
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6404
6991
|
* } else {
|
|
6405
6992
|
* resume(Effect.succeed("Success!"))
|
|
6406
6993
|
* }
|
|
@@ -6447,13 +7034,15 @@ export const retry: {
|
|
|
6447
7034
|
*
|
|
6448
7035
|
* @example
|
|
6449
7036
|
* ```ts
|
|
6450
|
-
* import { Effect, Schedule } from "effect"
|
|
7037
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
7038
|
+
*
|
|
7039
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6451
7040
|
*
|
|
6452
7041
|
* let attempt = 0
|
|
6453
|
-
* const task = Effect.callback<string,
|
|
7042
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6454
7043
|
* attempt++
|
|
6455
7044
|
* if (attempt <= 2) {
|
|
6456
|
-
* resume(Effect.fail(new
|
|
7045
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6457
7046
|
* } else {
|
|
6458
7047
|
* resume(Effect.succeed("Success!"))
|
|
6459
7048
|
* }
|
|
@@ -6496,13 +7085,15 @@ export const retry: {
|
|
|
6496
7085
|
*
|
|
6497
7086
|
* @example
|
|
6498
7087
|
* ```ts
|
|
6499
|
-
* import { Effect, Schedule } from "effect"
|
|
7088
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
7089
|
+
*
|
|
7090
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6500
7091
|
*
|
|
6501
7092
|
* let attempt = 0
|
|
6502
|
-
* const task = Effect.callback<string,
|
|
7093
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6503
7094
|
* attempt++
|
|
6504
7095
|
* if (attempt <= 2) {
|
|
6505
|
-
* resume(Effect.fail(new
|
|
7096
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6506
7097
|
* } else {
|
|
6507
7098
|
* resume(Effect.succeed("Success!"))
|
|
6508
7099
|
* }
|
|
@@ -6545,13 +7136,15 @@ export const retry: {
|
|
|
6545
7136
|
*
|
|
6546
7137
|
* @example
|
|
6547
7138
|
* ```ts
|
|
6548
|
-
* import { Effect, Schedule } from "effect"
|
|
7139
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
7140
|
+
*
|
|
7141
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6549
7142
|
*
|
|
6550
7143
|
* let attempt = 0
|
|
6551
|
-
* const task = Effect.callback<string,
|
|
7144
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6552
7145
|
* attempt++
|
|
6553
7146
|
* if (attempt <= 2) {
|
|
6554
|
-
* resume(Effect.fail(new
|
|
7147
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6555
7148
|
* } else {
|
|
6556
7149
|
* resume(Effect.succeed("Success!"))
|
|
6557
7150
|
* }
|
|
@@ -6598,14 +7191,16 @@ export const retry: {
|
|
|
6598
7191
|
*
|
|
6599
7192
|
* @example
|
|
6600
7193
|
* ```ts
|
|
6601
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
7194
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
7195
|
+
*
|
|
7196
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6602
7197
|
*
|
|
6603
7198
|
* let attempt = 0
|
|
6604
7199
|
* const networkRequest = Effect.gen(function*() {
|
|
6605
7200
|
* attempt++
|
|
6606
7201
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6607
7202
|
* if (attempt < 3) {
|
|
6608
|
-
* return yield* Effect.fail(new
|
|
7203
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6609
7204
|
* }
|
|
6610
7205
|
* return "Network data"
|
|
6611
7206
|
* })
|
|
@@ -6653,14 +7248,16 @@ export const retryOrElse: {
|
|
|
6653
7248
|
*
|
|
6654
7249
|
* @example
|
|
6655
7250
|
* ```ts
|
|
6656
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
7251
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
7252
|
+
*
|
|
7253
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6657
7254
|
*
|
|
6658
7255
|
* let attempt = 0
|
|
6659
7256
|
* const networkRequest = Effect.gen(function*() {
|
|
6660
7257
|
* attempt++
|
|
6661
7258
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6662
7259
|
* if (attempt < 3) {
|
|
6663
|
-
* return yield* Effect.fail(new
|
|
7260
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6664
7261
|
* }
|
|
6665
7262
|
* return "Network data"
|
|
6666
7263
|
* })
|
|
@@ -6711,14 +7308,16 @@ export const retryOrElse: {
|
|
|
6711
7308
|
*
|
|
6712
7309
|
* @example
|
|
6713
7310
|
* ```ts
|
|
6714
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
7311
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
7312
|
+
*
|
|
7313
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6715
7314
|
*
|
|
6716
7315
|
* let attempt = 0
|
|
6717
7316
|
* const networkRequest = Effect.gen(function*() {
|
|
6718
7317
|
* attempt++
|
|
6719
7318
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6720
7319
|
* if (attempt < 3) {
|
|
6721
|
-
* return yield* Effect.fail(new
|
|
7320
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6722
7321
|
* }
|
|
6723
7322
|
* return "Network data"
|
|
6724
7323
|
* })
|
|
@@ -6799,7 +7398,8 @@ export const sandbox: <A, E, R>(
|
|
|
6799
7398
|
* it succeeds or fails. This is useful when you only care about the side
|
|
6800
7399
|
* effects of the effect and do not need to handle or process its outcome.
|
|
6801
7400
|
*
|
|
6802
|
-
* Use the `log` option to emit the full {@link Cause} when the effect fails
|
|
7401
|
+
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
7402
|
+
* and `message` to prepend a custom log message.
|
|
6803
7403
|
*
|
|
6804
7404
|
* @example
|
|
6805
7405
|
* ```ts
|
|
@@ -6823,7 +7423,7 @@ export const sandbox: <A, E, R>(
|
|
|
6823
7423
|
* const task = Effect.fail("Uh oh!")
|
|
6824
7424
|
*
|
|
6825
7425
|
* const program = task.pipe(Effect.ignore({ log: true }))
|
|
6826
|
-
* const programWarn = task.pipe(Effect.ignore({ log: "Warn" }))
|
|
7426
|
+
* const programWarn = task.pipe(Effect.ignore({ log: "Warn", message: "Ignoring task failure" }))
|
|
6827
7427
|
* ```
|
|
6828
7428
|
*
|
|
6829
7429
|
* **Previously Known As**
|
|
@@ -6837,14 +7437,17 @@ export const sandbox: <A, E, R>(
|
|
|
6837
7437
|
*/
|
|
6838
7438
|
export const ignore: <
|
|
6839
7439
|
Arg extends Effect<any, any, any> | {
|
|
6840
|
-
readonly log?: boolean |
|
|
7440
|
+
readonly log?: boolean | Severity | undefined
|
|
7441
|
+
readonly message?: string | undefined
|
|
6841
7442
|
} | undefined = {
|
|
6842
|
-
readonly log?: boolean |
|
|
7443
|
+
readonly log?: boolean | Severity | undefined
|
|
7444
|
+
readonly message?: string | undefined
|
|
6843
7445
|
}
|
|
6844
7446
|
>(
|
|
6845
7447
|
effectOrOptions?: Arg,
|
|
6846
7448
|
options?: {
|
|
6847
|
-
readonly log?: boolean |
|
|
7449
|
+
readonly log?: boolean | Severity | undefined
|
|
7450
|
+
readonly message?: string | undefined
|
|
6848
7451
|
} | undefined
|
|
6849
7452
|
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R>
|
|
6850
7453
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R> = internal.ignore
|
|
@@ -6852,7 +7455,8 @@ export const ignore: <
|
|
|
6852
7455
|
/**
|
|
6853
7456
|
* Ignores the effect's failure cause, including defects and interruptions.
|
|
6854
7457
|
*
|
|
6855
|
-
* Use the `log` option to emit the full {@link Cause} when the effect fails
|
|
7458
|
+
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
7459
|
+
* and `message` to prepend a custom log message.
|
|
6856
7460
|
*
|
|
6857
7461
|
* @example
|
|
6858
7462
|
* ```ts
|
|
@@ -6861,7 +7465,7 @@ export const ignore: <
|
|
|
6861
7465
|
* const task = Effect.fail("boom")
|
|
6862
7466
|
*
|
|
6863
7467
|
* const program = task.pipe(Effect.ignoreCause)
|
|
6864
|
-
* const programLog = task.pipe(Effect.ignoreCause({ log: true }))
|
|
7468
|
+
* const programLog = task.pipe(Effect.ignoreCause({ log: true, message: "Ignoring failure cause" }))
|
|
6865
7469
|
* ```
|
|
6866
7470
|
*
|
|
6867
7471
|
* @since 4.0.0
|
|
@@ -6869,14 +7473,17 @@ export const ignore: <
|
|
|
6869
7473
|
*/
|
|
6870
7474
|
export const ignoreCause: <
|
|
6871
7475
|
Arg extends Effect<any, any, any> | {
|
|
6872
|
-
readonly log?: boolean |
|
|
7476
|
+
readonly log?: boolean | Severity | undefined
|
|
7477
|
+
readonly message?: string | undefined
|
|
6873
7478
|
} | undefined = {
|
|
6874
|
-
readonly log?: boolean |
|
|
7479
|
+
readonly log?: boolean | Severity | undefined
|
|
7480
|
+
readonly message?: string | undefined
|
|
6875
7481
|
}
|
|
6876
7482
|
>(
|
|
6877
7483
|
effectOrOptions?: Arg,
|
|
6878
7484
|
options?: {
|
|
6879
|
-
readonly log?: boolean |
|
|
7485
|
+
readonly log?: boolean | Severity | undefined
|
|
7486
|
+
readonly message?: string | undefined
|
|
6880
7487
|
} | undefined
|
|
6881
7488
|
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R>
|
|
6882
7489
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R> = internal.ignoreCause
|
|
@@ -6897,7 +7504,10 @@ export const ignoreCause: <
|
|
|
6897
7504
|
*
|
|
6898
7505
|
* const fetchUrl = Effect.gen(function*() {
|
|
6899
7506
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6900
|
-
*
|
|
7507
|
+
* if (endpoint.url === "bad") {
|
|
7508
|
+
* return yield* Effect.fail("Unavailable")
|
|
7509
|
+
* }
|
|
7510
|
+
* return endpoint.url
|
|
6901
7511
|
* })
|
|
6902
7512
|
*
|
|
6903
7513
|
* const plan = ExecutionPlan.make(
|
|
@@ -6928,7 +7538,10 @@ export const withExecutionPlan: {
|
|
|
6928
7538
|
*
|
|
6929
7539
|
* const fetchUrl = Effect.gen(function*() {
|
|
6930
7540
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6931
|
-
*
|
|
7541
|
+
* if (endpoint.url === "bad") {
|
|
7542
|
+
* return yield* Effect.fail("Unavailable")
|
|
7543
|
+
* }
|
|
7544
|
+
* return endpoint.url
|
|
6932
7545
|
* })
|
|
6933
7546
|
*
|
|
6934
7547
|
* const plan = ExecutionPlan.make(
|
|
@@ -6963,7 +7576,10 @@ export const withExecutionPlan: {
|
|
|
6963
7576
|
*
|
|
6964
7577
|
* const fetchUrl = Effect.gen(function*() {
|
|
6965
7578
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6966
|
-
*
|
|
7579
|
+
* if (endpoint.url === "bad") {
|
|
7580
|
+
* return yield* Effect.fail("Unavailable")
|
|
7581
|
+
* }
|
|
7582
|
+
* return endpoint.url
|
|
6967
7583
|
* })
|
|
6968
7584
|
*
|
|
6969
7585
|
* const plan = ExecutionPlan.make(
|
|
@@ -6983,6 +7599,25 @@ export const withExecutionPlan: {
|
|
|
6983
7599
|
): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>
|
|
6984
7600
|
} = internalExecutionPlan.withExecutionPlan
|
|
6985
7601
|
|
|
7602
|
+
/**
|
|
7603
|
+
* Runs an effect and reports any errors to the configured `ErrorReporter`s.
|
|
7604
|
+
*
|
|
7605
|
+
* If the `defectsOnly` option is set to `true`, only defects (unrecoverable
|
|
7606
|
+
* errors) will be reported, while regular failures will be ignored.
|
|
7607
|
+
*
|
|
7608
|
+
* @since 4.0.0
|
|
7609
|
+
* @category Error Handling
|
|
7610
|
+
*/
|
|
7611
|
+
export const withErrorReporting: <
|
|
7612
|
+
Arg extends Effect<any, any, any> | { readonly defectsOnly?: boolean | undefined } | undefined = {
|
|
7613
|
+
readonly defectsOnly?: boolean | undefined
|
|
7614
|
+
}
|
|
7615
|
+
>(
|
|
7616
|
+
effectOrOptions: Arg,
|
|
7617
|
+
options?: { readonly defectsOnly?: boolean | undefined } | undefined
|
|
7618
|
+
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Arg : <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> =
|
|
7619
|
+
internal.withErrorReporting
|
|
7620
|
+
|
|
6986
7621
|
// -----------------------------------------------------------------------------
|
|
6987
7622
|
// Fallback
|
|
6988
7623
|
// -----------------------------------------------------------------------------
|
|
@@ -7224,7 +7859,7 @@ export const timeout: {
|
|
|
7224
7859
|
* @since 2.0.0
|
|
7225
7860
|
* @category Delays & Timeouts
|
|
7226
7861
|
*/
|
|
7227
|
-
(duration: Duration.
|
|
7862
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>
|
|
7228
7863
|
// -----------------------------------------------------------------------------
|
|
7229
7864
|
// Delays & timeouts
|
|
7230
7865
|
// -----------------------------------------------------------------------------
|
|
@@ -7275,7 +7910,7 @@ export const timeout: {
|
|
|
7275
7910
|
* @since 2.0.0
|
|
7276
7911
|
* @category Delays & Timeouts
|
|
7277
7912
|
*/
|
|
7278
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7913
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>
|
|
7279
7914
|
} = internal.timeout
|
|
7280
7915
|
|
|
7281
7916
|
/**
|
|
@@ -7377,7 +8012,7 @@ export const timeoutOption: {
|
|
|
7377
8012
|
* @since 3.1.0
|
|
7378
8013
|
* @category Delays & Timeouts
|
|
7379
8014
|
*/
|
|
7380
|
-
(duration: Duration.
|
|
8015
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>
|
|
7381
8016
|
/**
|
|
7382
8017
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
7383
8018
|
* or a timeout.
|
|
@@ -7427,7 +8062,7 @@ export const timeoutOption: {
|
|
|
7427
8062
|
* @since 3.1.0
|
|
7428
8063
|
* @category Delays & Timeouts
|
|
7429
8064
|
*/
|
|
7430
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
8065
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>
|
|
7431
8066
|
} = internal.timeoutOption
|
|
7432
8067
|
|
|
7433
8068
|
/**
|
|
@@ -7449,7 +8084,7 @@ export const timeoutOption: {
|
|
|
7449
8084
|
* // Use cached data as fallback when timeout is reached
|
|
7450
8085
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
7451
8086
|
* duration: "2 seconds",
|
|
7452
|
-
*
|
|
8087
|
+
* orElse: () =>
|
|
7453
8088
|
* Effect.gen(function*() {
|
|
7454
8089
|
* yield* Console.log("Query timed out, using cached data")
|
|
7455
8090
|
* return "Cached result"
|
|
@@ -7486,7 +8121,7 @@ export const timeoutOrElse: {
|
|
|
7486
8121
|
* // Use cached data as fallback when timeout is reached
|
|
7487
8122
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
7488
8123
|
* duration: "2 seconds",
|
|
7489
|
-
*
|
|
8124
|
+
* orElse: () =>
|
|
7490
8125
|
* Effect.gen(function*() {
|
|
7491
8126
|
* yield* Console.log("Query timed out, using cached data")
|
|
7492
8127
|
* return "Cached result"
|
|
@@ -7505,8 +8140,8 @@ export const timeoutOrElse: {
|
|
|
7505
8140
|
*/
|
|
7506
8141
|
<A2, E2, R2>(
|
|
7507
8142
|
options: {
|
|
7508
|
-
readonly duration: Duration.
|
|
7509
|
-
readonly
|
|
8143
|
+
readonly duration: Duration.Input
|
|
8144
|
+
readonly orElse: LazyArg<Effect<A2, E2, R2>>
|
|
7510
8145
|
}
|
|
7511
8146
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>
|
|
7512
8147
|
/**
|
|
@@ -7528,7 +8163,7 @@ export const timeoutOrElse: {
|
|
|
7528
8163
|
* // Use cached data as fallback when timeout is reached
|
|
7529
8164
|
* const program = Effect.timeoutOrElse(slowQuery, {
|
|
7530
8165
|
* duration: "2 seconds",
|
|
7531
|
-
*
|
|
8166
|
+
* orElse: () =>
|
|
7532
8167
|
* Effect.gen(function*() {
|
|
7533
8168
|
* yield* Console.log("Query timed out, using cached data")
|
|
7534
8169
|
* return "Cached result"
|
|
@@ -7548,8 +8183,8 @@ export const timeoutOrElse: {
|
|
|
7548
8183
|
<A, E, R, A2, E2, R2>(
|
|
7549
8184
|
self: Effect<A, E, R>,
|
|
7550
8185
|
options: {
|
|
7551
|
-
readonly duration: Duration.
|
|
7552
|
-
readonly
|
|
8186
|
+
readonly duration: Duration.Input
|
|
8187
|
+
readonly orElse: LazyArg<Effect<A2, E2, R2>>
|
|
7553
8188
|
}
|
|
7554
8189
|
): Effect<A | A2, E | E2, R | R2>
|
|
7555
8190
|
} = internal.timeoutOrElse
|
|
@@ -7595,7 +8230,7 @@ export const delay: {
|
|
|
7595
8230
|
* @since 2.0.0
|
|
7596
8231
|
* @category Delays & Timeouts
|
|
7597
8232
|
*/
|
|
7598
|
-
(duration: Duration.
|
|
8233
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
7599
8234
|
/**
|
|
7600
8235
|
* Returns an effect that is delayed from this effect by the specified
|
|
7601
8236
|
* `Duration`.
|
|
@@ -7616,7 +8251,7 @@ export const delay: {
|
|
|
7616
8251
|
* @since 2.0.0
|
|
7617
8252
|
* @category Delays & Timeouts
|
|
7618
8253
|
*/
|
|
7619
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
8254
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>
|
|
7620
8255
|
} = internal.delay
|
|
7621
8256
|
|
|
7622
8257
|
/**
|
|
@@ -7641,7 +8276,7 @@ export const delay: {
|
|
|
7641
8276
|
* @since 2.0.0
|
|
7642
8277
|
* @category Delays & Timeouts
|
|
7643
8278
|
*/
|
|
7644
|
-
export const sleep: (duration: Duration.
|
|
8279
|
+
export const sleep: (duration: Duration.Input) => Effect<void> = internal.sleep
|
|
7645
8280
|
|
|
7646
8281
|
/**
|
|
7647
8282
|
* Measures the runtime of an effect and returns the duration with its result.
|
|
@@ -7961,12 +8596,12 @@ export const raceFirst: {
|
|
|
7961
8596
|
// -----------------------------------------------------------------------------
|
|
7962
8597
|
|
|
7963
8598
|
/**
|
|
7964
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7965
|
-
* predicate
|
|
8599
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8600
|
+
* predicate.
|
|
7966
8601
|
*
|
|
7967
8602
|
* @example
|
|
7968
8603
|
* ```ts
|
|
7969
|
-
* import { Effect
|
|
8604
|
+
* import { Effect } from "effect"
|
|
7970
8605
|
*
|
|
7971
8606
|
* // Sync predicate
|
|
7972
8607
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7974,10 +8609,7 @@ export const raceFirst: {
|
|
|
7974
8609
|
* // Effectful predicate
|
|
7975
8610
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7976
8611
|
*
|
|
7977
|
-
* //
|
|
7978
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7979
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7980
|
-
* )
|
|
8612
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7981
8613
|
* ```
|
|
7982
8614
|
*
|
|
7983
8615
|
* @since 2.0.0
|
|
@@ -7989,12 +8621,12 @@ export const filter: {
|
|
|
7989
8621
|
// -----------------------------------------------------------------------------
|
|
7990
8622
|
|
|
7991
8623
|
/**
|
|
7992
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7993
|
-
* predicate
|
|
8624
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8625
|
+
* predicate.
|
|
7994
8626
|
*
|
|
7995
8627
|
* @example
|
|
7996
8628
|
* ```ts
|
|
7997
|
-
* import { Effect
|
|
8629
|
+
* import { Effect } from "effect"
|
|
7998
8630
|
*
|
|
7999
8631
|
* // Sync predicate
|
|
8000
8632
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8002,10 +8634,7 @@ export const filter: {
|
|
|
8002
8634
|
* // Effectful predicate
|
|
8003
8635
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8004
8636
|
*
|
|
8005
|
-
* //
|
|
8006
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8007
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8008
|
-
* )
|
|
8637
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8009
8638
|
* ```
|
|
8010
8639
|
*
|
|
8011
8640
|
* @since 2.0.0
|
|
@@ -8017,12 +8646,12 @@ export const filter: {
|
|
|
8017
8646
|
// -----------------------------------------------------------------------------
|
|
8018
8647
|
|
|
8019
8648
|
/**
|
|
8020
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8021
|
-
* predicate
|
|
8649
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8650
|
+
* predicate.
|
|
8022
8651
|
*
|
|
8023
8652
|
* @example
|
|
8024
8653
|
* ```ts
|
|
8025
|
-
* import { Effect
|
|
8654
|
+
* import { Effect } from "effect"
|
|
8026
8655
|
*
|
|
8027
8656
|
* // Sync predicate
|
|
8028
8657
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8030,10 +8659,7 @@ export const filter: {
|
|
|
8030
8659
|
* // Effectful predicate
|
|
8031
8660
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8032
8661
|
*
|
|
8033
|
-
* //
|
|
8034
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8035
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8036
|
-
* )
|
|
8662
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8037
8663
|
* ```
|
|
8038
8664
|
*
|
|
8039
8665
|
* @since 2.0.0
|
|
@@ -8045,12 +8671,12 @@ export const filter: {
|
|
|
8045
8671
|
// -----------------------------------------------------------------------------
|
|
8046
8672
|
|
|
8047
8673
|
/**
|
|
8048
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8049
|
-
* predicate
|
|
8674
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8675
|
+
* predicate.
|
|
8050
8676
|
*
|
|
8051
8677
|
* @example
|
|
8052
8678
|
* ```ts
|
|
8053
|
-
* import { Effect
|
|
8679
|
+
* import { Effect } from "effect"
|
|
8054
8680
|
*
|
|
8055
8681
|
* // Sync predicate
|
|
8056
8682
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8058,30 +8684,27 @@ export const filter: {
|
|
|
8058
8684
|
* // Effectful predicate
|
|
8059
8685
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8060
8686
|
*
|
|
8061
|
-
* //
|
|
8062
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8063
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8064
|
-
* )
|
|
8687
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8065
8688
|
* ```
|
|
8066
8689
|
*
|
|
8067
8690
|
* @since 2.0.0
|
|
8068
8691
|
* @category Filtering
|
|
8069
8692
|
*/
|
|
8070
|
-
<A,
|
|
8071
|
-
|
|
8693
|
+
<A, E, R>(
|
|
8694
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8072
8695
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8073
|
-
): (
|
|
8696
|
+
): (iterable: Iterable<A>) => Effect<Array<A>, E, R>
|
|
8074
8697
|
// -----------------------------------------------------------------------------
|
|
8075
8698
|
// Filtering
|
|
8076
8699
|
// -----------------------------------------------------------------------------
|
|
8077
8700
|
|
|
8078
8701
|
/**
|
|
8079
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8080
|
-
* predicate
|
|
8702
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8703
|
+
* predicate.
|
|
8081
8704
|
*
|
|
8082
8705
|
* @example
|
|
8083
8706
|
* ```ts
|
|
8084
|
-
* import { Effect
|
|
8707
|
+
* import { Effect } from "effect"
|
|
8085
8708
|
*
|
|
8086
8709
|
* // Sync predicate
|
|
8087
8710
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8089,30 +8712,24 @@ export const filter: {
|
|
|
8089
8712
|
* // Effectful predicate
|
|
8090
8713
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8091
8714
|
*
|
|
8092
|
-
* //
|
|
8093
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8094
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8095
|
-
* )
|
|
8715
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8096
8716
|
* ```
|
|
8097
8717
|
*
|
|
8098
8718
|
* @since 2.0.0
|
|
8099
8719
|
* @category Filtering
|
|
8100
8720
|
*/
|
|
8101
|
-
<A, B
|
|
8102
|
-
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8103
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8104
|
-
): (elements: Iterable<A>) => Effect<Array<B>, E, R>
|
|
8721
|
+
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>
|
|
8105
8722
|
// -----------------------------------------------------------------------------
|
|
8106
8723
|
// Filtering
|
|
8107
8724
|
// -----------------------------------------------------------------------------
|
|
8108
8725
|
|
|
8109
8726
|
/**
|
|
8110
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8111
|
-
* predicate
|
|
8727
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8728
|
+
* predicate.
|
|
8112
8729
|
*
|
|
8113
8730
|
* @example
|
|
8114
8731
|
* ```ts
|
|
8115
|
-
* import { Effect
|
|
8732
|
+
* import { Effect } from "effect"
|
|
8116
8733
|
*
|
|
8117
8734
|
* // Sync predicate
|
|
8118
8735
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8120,30 +8737,24 @@ export const filter: {
|
|
|
8120
8737
|
* // Effectful predicate
|
|
8121
8738
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8122
8739
|
*
|
|
8123
|
-
* //
|
|
8124
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8125
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8126
|
-
* )
|
|
8740
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8127
8741
|
* ```
|
|
8128
8742
|
*
|
|
8129
8743
|
* @since 2.0.0
|
|
8130
8744
|
* @category Filtering
|
|
8131
8745
|
*/
|
|
8132
|
-
<A
|
|
8133
|
-
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8134
|
-
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8135
|
-
): (iterable: Iterable<A>) => Effect<Array<A>, E, R>
|
|
8746
|
+
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>
|
|
8136
8747
|
// -----------------------------------------------------------------------------
|
|
8137
8748
|
// Filtering
|
|
8138
8749
|
// -----------------------------------------------------------------------------
|
|
8139
8750
|
|
|
8140
8751
|
/**
|
|
8141
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
8142
|
-
* predicate
|
|
8752
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8753
|
+
* predicate.
|
|
8143
8754
|
*
|
|
8144
8755
|
* @example
|
|
8145
8756
|
* ```ts
|
|
8146
|
-
* import { Effect
|
|
8757
|
+
* import { Effect } from "effect"
|
|
8147
8758
|
*
|
|
8148
8759
|
* // Sync predicate
|
|
8149
8760
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -8151,137 +8762,71 @@ export const filter: {
|
|
|
8151
8762
|
* // Effectful predicate
|
|
8152
8763
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8153
8764
|
*
|
|
8154
|
-
* //
|
|
8155
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8156
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8157
|
-
* )
|
|
8765
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
8158
8766
|
* ```
|
|
8159
8767
|
*
|
|
8160
8768
|
* @since 2.0.0
|
|
8161
8769
|
* @category Filtering
|
|
8162
8770
|
*/
|
|
8163
|
-
<A,
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8771
|
+
<A, E, R>(
|
|
8772
|
+
iterable: Iterable<A>,
|
|
8773
|
+
predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>,
|
|
8774
|
+
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8775
|
+
): Effect<Array<A>, E, R>
|
|
8776
|
+
} = internal.filter
|
|
8167
8777
|
|
|
8778
|
+
/**
|
|
8779
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8780
|
+
*
|
|
8781
|
+
* @since 4.0.0
|
|
8782
|
+
* @category Filtering
|
|
8783
|
+
*/
|
|
8784
|
+
export const filterMap: {
|
|
8168
8785
|
/**
|
|
8169
|
-
* Filters elements of an iterable
|
|
8170
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8786
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8171
8787
|
*
|
|
8172
|
-
* @
|
|
8173
|
-
* ```ts
|
|
8174
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8175
|
-
*
|
|
8176
|
-
* // Sync predicate
|
|
8177
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8178
|
-
*
|
|
8179
|
-
* // Effectful predicate
|
|
8180
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8181
|
-
*
|
|
8182
|
-
* // FilterEffect
|
|
8183
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8184
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8185
|
-
* )
|
|
8186
|
-
* ```
|
|
8187
|
-
*
|
|
8188
|
-
* @since 2.0.0
|
|
8788
|
+
* @since 4.0.0
|
|
8189
8789
|
* @category Filtering
|
|
8190
8790
|
*/
|
|
8191
|
-
<A>(
|
|
8192
|
-
// -----------------------------------------------------------------------------
|
|
8193
|
-
// Filtering
|
|
8194
|
-
// -----------------------------------------------------------------------------
|
|
8195
|
-
|
|
8791
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>
|
|
8196
8792
|
/**
|
|
8197
|
-
* Filters elements of an iterable
|
|
8198
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8199
|
-
*
|
|
8200
|
-
* @example
|
|
8201
|
-
* ```ts
|
|
8202
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8203
|
-
*
|
|
8204
|
-
* // Sync predicate
|
|
8205
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8206
|
-
*
|
|
8207
|
-
* // Effectful predicate
|
|
8208
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8209
|
-
*
|
|
8210
|
-
* // FilterEffect
|
|
8211
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8212
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8213
|
-
* )
|
|
8214
|
-
* ```
|
|
8793
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8215
8794
|
*
|
|
8216
|
-
* @since
|
|
8795
|
+
* @since 4.0.0
|
|
8217
8796
|
* @category Filtering
|
|
8218
8797
|
*/
|
|
8219
8798
|
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>
|
|
8220
|
-
|
|
8221
|
-
// Filtering
|
|
8222
|
-
// -----------------------------------------------------------------------------
|
|
8799
|
+
} = internal.filterMap
|
|
8223
8800
|
|
|
8801
|
+
/**
|
|
8802
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8803
|
+
*
|
|
8804
|
+
* @since 4.0.0
|
|
8805
|
+
* @category Filtering
|
|
8806
|
+
*/
|
|
8807
|
+
export const filterMapEffect: {
|
|
8224
8808
|
/**
|
|
8225
|
-
*
|
|
8226
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8227
|
-
*
|
|
8228
|
-
* @example
|
|
8229
|
-
* ```ts
|
|
8230
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8231
|
-
*
|
|
8232
|
-
* // Sync predicate
|
|
8233
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8809
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8234
8810
|
*
|
|
8235
|
-
*
|
|
8236
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8237
|
-
*
|
|
8238
|
-
* // FilterEffect
|
|
8239
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8240
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8241
|
-
* )
|
|
8242
|
-
* ```
|
|
8243
|
-
*
|
|
8244
|
-
* @since 2.0.0
|
|
8811
|
+
* @since 4.0.0
|
|
8245
8812
|
* @category Filtering
|
|
8246
8813
|
*/
|
|
8247
8814
|
<A, B, X, E, R>(
|
|
8248
|
-
elements: Iterable<A>,
|
|
8249
8815
|
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8250
8816
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8251
|
-
): Effect<Array<B>, E, R>
|
|
8252
|
-
// -----------------------------------------------------------------------------
|
|
8253
|
-
// Filtering
|
|
8254
|
-
// -----------------------------------------------------------------------------
|
|
8255
|
-
|
|
8817
|
+
): (elements: Iterable<A>) => Effect<Array<B>, E, R>
|
|
8256
8818
|
/**
|
|
8257
|
-
*
|
|
8258
|
-
* predicate, or `Filter.FilterEffect`.
|
|
8819
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8259
8820
|
*
|
|
8260
|
-
* @
|
|
8261
|
-
* ```ts
|
|
8262
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8263
|
-
*
|
|
8264
|
-
* // Sync predicate
|
|
8265
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
8266
|
-
*
|
|
8267
|
-
* // Effectful predicate
|
|
8268
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
8269
|
-
*
|
|
8270
|
-
* // FilterEffect
|
|
8271
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
8272
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
8273
|
-
* )
|
|
8274
|
-
* ```
|
|
8275
|
-
*
|
|
8276
|
-
* @since 2.0.0
|
|
8821
|
+
* @since 4.0.0
|
|
8277
8822
|
* @category Filtering
|
|
8278
8823
|
*/
|
|
8279
|
-
<A, E, R>(
|
|
8280
|
-
|
|
8281
|
-
|
|
8824
|
+
<A, B, X, E, R>(
|
|
8825
|
+
elements: Iterable<A>,
|
|
8826
|
+
filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>,
|
|
8282
8827
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
8283
|
-
): Effect<Array<
|
|
8284
|
-
} = internal.
|
|
8828
|
+
): Effect<Array<B>, E, R>
|
|
8829
|
+
} = internal.filterMapEffect
|
|
8285
8830
|
|
|
8286
8831
|
/**
|
|
8287
8832
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -8378,10 +8923,10 @@ export const filterOrElse: {
|
|
|
8378
8923
|
* @since 2.0.0
|
|
8379
8924
|
* @category Filtering
|
|
8380
8925
|
*/
|
|
8381
|
-
<A,
|
|
8382
|
-
|
|
8383
|
-
orElse: (a:
|
|
8384
|
-
): <E, R>(self: Effect<A, E, R>) => Effect<
|
|
8926
|
+
<A, C, E2, R2>(
|
|
8927
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8928
|
+
orElse: (a: NoInfer<A>) => Effect<C, E2, R2>
|
|
8929
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>
|
|
8385
8930
|
/**
|
|
8386
8931
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
8387
8932
|
*
|
|
@@ -8447,13 +8992,43 @@ export const filterOrElse: {
|
|
|
8447
8992
|
* @since 2.0.0
|
|
8448
8993
|
* @category Filtering
|
|
8449
8994
|
*/
|
|
8450
|
-
<A, E, R,
|
|
8995
|
+
<A, E, R, C, E2, R2>(
|
|
8451
8996
|
self: Effect<A, E, R>,
|
|
8452
|
-
|
|
8453
|
-
orElse: (a:
|
|
8454
|
-
): Effect<
|
|
8997
|
+
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8998
|
+
orElse: (a: NoInfer<A>) => Effect<C, E2, R2>
|
|
8999
|
+
): Effect<A | C, E | E2, R | R2>
|
|
8455
9000
|
} = internal.filterOrElse
|
|
8456
9001
|
|
|
9002
|
+
/**
|
|
9003
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
9004
|
+
*
|
|
9005
|
+
* @since 4.0.0
|
|
9006
|
+
* @category Filtering
|
|
9007
|
+
*/
|
|
9008
|
+
export const filterMapOrElse: {
|
|
9009
|
+
/**
|
|
9010
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
9011
|
+
*
|
|
9012
|
+
* @since 4.0.0
|
|
9013
|
+
* @category Filtering
|
|
9014
|
+
*/
|
|
9015
|
+
<A, B, X, C, E2, R2>(
|
|
9016
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
9017
|
+
orElse: (x: X) => Effect<C, E2, R2>
|
|
9018
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>
|
|
9019
|
+
/**
|
|
9020
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
9021
|
+
*
|
|
9022
|
+
* @since 4.0.0
|
|
9023
|
+
* @category Filtering
|
|
9024
|
+
*/
|
|
9025
|
+
<A, E, R, B, X, C, E2, R2>(
|
|
9026
|
+
self: Effect<A, E, R>,
|
|
9027
|
+
filter: Filter.Filter<NoInfer<A>, B, X>,
|
|
9028
|
+
orElse: (x: X) => Effect<C, E2, R2>
|
|
9029
|
+
): Effect<B | C, E | E2, R | R2>
|
|
9030
|
+
} = internal.filterMapOrElse
|
|
9031
|
+
|
|
8457
9032
|
/**
|
|
8458
9033
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8459
9034
|
*
|
|
@@ -8550,36 +9125,6 @@ export const filterOrFail: {
|
|
|
8550
9125
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8551
9126
|
orFailWith: (a: NoInfer<A>) => E2
|
|
8552
9127
|
): <E, R>(self: Effect<A, E, R>) => Effect<A, E2 | E, R>
|
|
8553
|
-
/**
|
|
8554
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8555
|
-
*
|
|
8556
|
-
* **Details**
|
|
8557
|
-
*
|
|
8558
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8559
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8560
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8561
|
-
*
|
|
8562
|
-
* @example
|
|
8563
|
-
* ```ts
|
|
8564
|
-
* import { Effect } from "effect"
|
|
8565
|
-
*
|
|
8566
|
-
* // An effect that produces a number
|
|
8567
|
-
* const program = Effect.succeed(5)
|
|
8568
|
-
*
|
|
8569
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8570
|
-
* const filtered = Effect.filterOrFail(
|
|
8571
|
-
* program,
|
|
8572
|
-
* (n) => n % 2 === 0,
|
|
8573
|
-
* (n) => `Expected even number, got ${n}`
|
|
8574
|
-
* )
|
|
8575
|
-
*
|
|
8576
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8577
|
-
* ```
|
|
8578
|
-
*
|
|
8579
|
-
* @since 2.0.0
|
|
8580
|
-
* @category Filtering
|
|
8581
|
-
*/
|
|
8582
|
-
<A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>
|
|
8583
9128
|
/**
|
|
8584
9129
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8585
9130
|
*
|
|
@@ -8640,36 +9185,6 @@ export const filterOrFail: {
|
|
|
8640
9185
|
* @category Filtering
|
|
8641
9186
|
*/
|
|
8642
9187
|
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>
|
|
8643
|
-
/**
|
|
8644
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8645
|
-
*
|
|
8646
|
-
* **Details**
|
|
8647
|
-
*
|
|
8648
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8649
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8650
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8651
|
-
*
|
|
8652
|
-
* @example
|
|
8653
|
-
* ```ts
|
|
8654
|
-
* import { Effect } from "effect"
|
|
8655
|
-
*
|
|
8656
|
-
* // An effect that produces a number
|
|
8657
|
-
* const program = Effect.succeed(5)
|
|
8658
|
-
*
|
|
8659
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8660
|
-
* const filtered = Effect.filterOrFail(
|
|
8661
|
-
* program,
|
|
8662
|
-
* (n) => n % 2 === 0,
|
|
8663
|
-
* (n) => `Expected even number, got ${n}`
|
|
8664
|
-
* )
|
|
8665
|
-
*
|
|
8666
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8667
|
-
* ```
|
|
8668
|
-
*
|
|
8669
|
-
* @since 2.0.0
|
|
8670
|
-
* @category Filtering
|
|
8671
|
-
*/
|
|
8672
|
-
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>
|
|
8673
9188
|
/**
|
|
8674
9189
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8675
9190
|
*
|
|
@@ -8738,40 +9253,6 @@ export const filterOrFail: {
|
|
|
8738
9253
|
predicate: Predicate.Predicate<NoInfer<A>>,
|
|
8739
9254
|
orFailWith: (a: NoInfer<A>) => E2
|
|
8740
9255
|
): Effect<A, E2 | E, R>
|
|
8741
|
-
/**
|
|
8742
|
-
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8743
|
-
*
|
|
8744
|
-
* **Details**
|
|
8745
|
-
*
|
|
8746
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8747
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8748
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8749
|
-
*
|
|
8750
|
-
* @example
|
|
8751
|
-
* ```ts
|
|
8752
|
-
* import { Effect } from "effect"
|
|
8753
|
-
*
|
|
8754
|
-
* // An effect that produces a number
|
|
8755
|
-
* const program = Effect.succeed(5)
|
|
8756
|
-
*
|
|
8757
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8758
|
-
* const filtered = Effect.filterOrFail(
|
|
8759
|
-
* program,
|
|
8760
|
-
* (n) => n % 2 === 0,
|
|
8761
|
-
* (n) => `Expected even number, got ${n}`
|
|
8762
|
-
* )
|
|
8763
|
-
*
|
|
8764
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8765
|
-
* ```
|
|
8766
|
-
*
|
|
8767
|
-
* @since 2.0.0
|
|
8768
|
-
* @category Filtering
|
|
8769
|
-
*/
|
|
8770
|
-
<A, E, R, B, X, E2>(
|
|
8771
|
-
self: Effect<A, E, R>,
|
|
8772
|
-
filter: Filter.Filter<A, B, X>,
|
|
8773
|
-
orFailWith: (x: X) => E2
|
|
8774
|
-
): Effect<B, E2 | E, R>
|
|
8775
9256
|
/**
|
|
8776
9257
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8777
9258
|
*
|
|
@@ -8832,37 +9313,48 @@ export const filterOrFail: {
|
|
|
8832
9313
|
* @category Filtering
|
|
8833
9314
|
*/
|
|
8834
9315
|
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>
|
|
9316
|
+
} = internal.filterOrFail
|
|
9317
|
+
|
|
9318
|
+
/**
|
|
9319
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
9320
|
+
*
|
|
9321
|
+
* @since 4.0.0
|
|
9322
|
+
* @category Filtering
|
|
9323
|
+
*/
|
|
9324
|
+
export const filterMapOrFail: {
|
|
8835
9325
|
/**
|
|
8836
|
-
* Filters an effect
|
|
9326
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8837
9327
|
*
|
|
8838
|
-
*
|
|
8839
|
-
*
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
*
|
|
8844
|
-
* @example
|
|
8845
|
-
* ```ts
|
|
8846
|
-
* import { Effect } from "effect"
|
|
8847
|
-
*
|
|
8848
|
-
* // An effect that produces a number
|
|
8849
|
-
* const program = Effect.succeed(5)
|
|
8850
|
-
*
|
|
8851
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8852
|
-
* const filtered = Effect.filterOrFail(
|
|
8853
|
-
* program,
|
|
8854
|
-
* (n) => n % 2 === 0,
|
|
8855
|
-
* (n) => `Expected even number, got ${n}`
|
|
8856
|
-
* )
|
|
9328
|
+
* @since 4.0.0
|
|
9329
|
+
* @category Filtering
|
|
9330
|
+
*/
|
|
9331
|
+
<A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>
|
|
9332
|
+
/**
|
|
9333
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8857
9334
|
*
|
|
8858
|
-
*
|
|
8859
|
-
*
|
|
9335
|
+
* @since 4.0.0
|
|
9336
|
+
* @category Filtering
|
|
9337
|
+
*/
|
|
9338
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>
|
|
9339
|
+
/**
|
|
9340
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8860
9341
|
*
|
|
8861
|
-
* @since
|
|
9342
|
+
* @since 4.0.0
|
|
8862
9343
|
* @category Filtering
|
|
8863
9344
|
*/
|
|
8864
|
-
<A, E, R, B, X
|
|
8865
|
-
|
|
9345
|
+
<A, E, R, B, X, E2>(
|
|
9346
|
+
self: Effect<A, E, R>,
|
|
9347
|
+
filter: Filter.Filter<A, B, X>,
|
|
9348
|
+
orFailWith: (x: X) => E2
|
|
9349
|
+
): Effect<B, E2 | E, R>
|
|
9350
|
+
/**
|
|
9351
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
9352
|
+
*
|
|
9353
|
+
* @since 4.0.0
|
|
9354
|
+
* @category Filtering
|
|
9355
|
+
*/
|
|
9356
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>
|
|
9357
|
+
} = internal.filterMapOrFail
|
|
8866
9358
|
|
|
8867
9359
|
// -----------------------------------------------------------------------------
|
|
8868
9360
|
// Conditional Operators
|
|
@@ -9020,9 +9512,11 @@ export const when: {
|
|
|
9020
9512
|
* @example
|
|
9021
9513
|
* ```ts
|
|
9022
9514
|
* // Title: Handling Both Success and Failure Cases
|
|
9023
|
-
* import { Effect } from "effect"
|
|
9515
|
+
* import { Data, Effect } from "effect"
|
|
9024
9516
|
*
|
|
9025
|
-
*
|
|
9517
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9518
|
+
*
|
|
9519
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9026
9520
|
*
|
|
9027
9521
|
* const program1 = Effect.match(success, {
|
|
9028
9522
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -9033,8 +9527,8 @@ export const when: {
|
|
|
9033
9527
|
* Effect.runPromise(program1).then(console.log)
|
|
9034
9528
|
* // Output: "success: 42"
|
|
9035
9529
|
*
|
|
9036
|
-
* const failure: Effect.Effect<number,
|
|
9037
|
-
* new
|
|
9530
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9531
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9038
9532
|
* )
|
|
9039
9533
|
*
|
|
9040
9534
|
* const program2 = Effect.match(failure, {
|
|
@@ -9076,9 +9570,11 @@ export const match: {
|
|
|
9076
9570
|
* @example
|
|
9077
9571
|
* ```ts
|
|
9078
9572
|
* // Title: Handling Both Success and Failure Cases
|
|
9079
|
-
* import { Effect } from "effect"
|
|
9573
|
+
* import { Data, Effect } from "effect"
|
|
9574
|
+
*
|
|
9575
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9080
9576
|
*
|
|
9081
|
-
* const success: Effect.Effect<number,
|
|
9577
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9082
9578
|
*
|
|
9083
9579
|
* const program1 = Effect.match(success, {
|
|
9084
9580
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -9089,8 +9585,8 @@ export const match: {
|
|
|
9089
9585
|
* Effect.runPromise(program1).then(console.log)
|
|
9090
9586
|
* // Output: "success: 42"
|
|
9091
9587
|
*
|
|
9092
|
-
* const failure: Effect.Effect<number,
|
|
9093
|
-
* new
|
|
9588
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9589
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9094
9590
|
* )
|
|
9095
9591
|
*
|
|
9096
9592
|
* const program2 = Effect.match(failure, {
|
|
@@ -9137,9 +9633,11 @@ export const match: {
|
|
|
9137
9633
|
* @example
|
|
9138
9634
|
* ```ts
|
|
9139
9635
|
* // Title: Handling Both Success and Failure Cases
|
|
9140
|
-
* import { Effect } from "effect"
|
|
9636
|
+
* import { Data, Effect } from "effect"
|
|
9141
9637
|
*
|
|
9142
|
-
*
|
|
9638
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9639
|
+
*
|
|
9640
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9143
9641
|
*
|
|
9144
9642
|
* const program1 = Effect.match(success, {
|
|
9145
9643
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -9150,8 +9648,8 @@ export const match: {
|
|
|
9150
9648
|
* Effect.runPromise(program1).then(console.log)
|
|
9151
9649
|
* // Output: "success: 42"
|
|
9152
9650
|
*
|
|
9153
|
-
* const failure: Effect.Effect<number,
|
|
9154
|
-
* new
|
|
9651
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9652
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9155
9653
|
* )
|
|
9156
9654
|
*
|
|
9157
9655
|
* const program2 = Effect.match(failure, {
|
|
@@ -9581,9 +10079,11 @@ export const matchCauseEffectEager: {
|
|
|
9581
10079
|
*
|
|
9582
10080
|
* @example
|
|
9583
10081
|
* ```ts
|
|
9584
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
10082
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
10083
|
+
*
|
|
10084
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9585
10085
|
*
|
|
9586
|
-
* const task = Effect.fail(new
|
|
10086
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
9587
10087
|
*
|
|
9588
10088
|
* const program = Effect.matchCauseEffect(task, {
|
|
9589
10089
|
* onFailure: (cause) =>
|
|
@@ -9633,9 +10133,11 @@ export const matchCauseEffect: {
|
|
|
9633
10133
|
*
|
|
9634
10134
|
* @example
|
|
9635
10135
|
* ```ts
|
|
9636
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
10136
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9637
10137
|
*
|
|
9638
|
-
*
|
|
10138
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
10139
|
+
*
|
|
10140
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
9639
10141
|
*
|
|
9640
10142
|
* const program = Effect.matchCauseEffect(task, {
|
|
9641
10143
|
* onFailure: (cause) =>
|
|
@@ -9690,9 +10192,11 @@ export const matchCauseEffect: {
|
|
|
9690
10192
|
*
|
|
9691
10193
|
* @example
|
|
9692
10194
|
* ```ts
|
|
9693
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
10195
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
10196
|
+
*
|
|
10197
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9694
10198
|
*
|
|
9695
|
-
* const task = Effect.fail(new
|
|
10199
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
9696
10200
|
*
|
|
9697
10201
|
* const program = Effect.matchCauseEffect(task, {
|
|
9698
10202
|
* onFailure: (cause) =>
|
|
@@ -9756,11 +10260,13 @@ export const matchCauseEffect: {
|
|
|
9756
10260
|
* @example
|
|
9757
10261
|
* ```ts
|
|
9758
10262
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9759
|
-
* import { Effect } from "effect"
|
|
10263
|
+
* import { Data, Effect } from "effect"
|
|
9760
10264
|
*
|
|
9761
|
-
*
|
|
9762
|
-
*
|
|
9763
|
-
*
|
|
10265
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
10266
|
+
*
|
|
10267
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
10268
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
10269
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9764
10270
|
* )
|
|
9765
10271
|
*
|
|
9766
10272
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9816,11 +10322,13 @@ export const matchEffect: {
|
|
|
9816
10322
|
* @example
|
|
9817
10323
|
* ```ts
|
|
9818
10324
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9819
|
-
* import { Effect } from "effect"
|
|
10325
|
+
* import { Data, Effect } from "effect"
|
|
10326
|
+
*
|
|
10327
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9820
10328
|
*
|
|
9821
|
-
* const success: Effect.Effect<number,
|
|
9822
|
-
* const failure: Effect.Effect<number,
|
|
9823
|
-
* new
|
|
10329
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
10330
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
10331
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9824
10332
|
* )
|
|
9825
10333
|
*
|
|
9826
10334
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9881,11 +10389,13 @@ export const matchEffect: {
|
|
|
9881
10389
|
* @example
|
|
9882
10390
|
* ```ts
|
|
9883
10391
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9884
|
-
* import { Effect } from "effect"
|
|
10392
|
+
* import { Data, Effect } from "effect"
|
|
9885
10393
|
*
|
|
9886
|
-
*
|
|
9887
|
-
*
|
|
9888
|
-
*
|
|
10394
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
10395
|
+
*
|
|
10396
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
10397
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
10398
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9889
10399
|
* )
|
|
9890
10400
|
*
|
|
9891
10401
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -10028,7 +10538,7 @@ export const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boolean, neve
|
|
|
10028
10538
|
* @since 2.0.0
|
|
10029
10539
|
* @category Environment
|
|
10030
10540
|
*/
|
|
10031
|
-
export const services: <R>() => Effect<ServiceMap.ServiceMap<R>, never, R> = internal.services
|
|
10541
|
+
export const services: <R = never>() => Effect<ServiceMap.ServiceMap<R>, never, R> = internal.services
|
|
10032
10542
|
|
|
10033
10543
|
/**
|
|
10034
10544
|
* Transforms the current service map using the provided function.
|
|
@@ -10094,7 +10604,7 @@ export const servicesWith: <R, A, E, R2>(
|
|
|
10094
10604
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10095
10605
|
*
|
|
10096
10606
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10097
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10607
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10098
10608
|
* })
|
|
10099
10609
|
*
|
|
10100
10610
|
* const program = Effect.gen(function*() {
|
|
@@ -10128,7 +10638,7 @@ export const provide: {
|
|
|
10128
10638
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10129
10639
|
*
|
|
10130
10640
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10131
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10641
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10132
10642
|
* })
|
|
10133
10643
|
*
|
|
10134
10644
|
* const program = Effect.gen(function*() {
|
|
@@ -10173,7 +10683,7 @@ export const provide: {
|
|
|
10173
10683
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10174
10684
|
*
|
|
10175
10685
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10176
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10686
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10177
10687
|
* })
|
|
10178
10688
|
*
|
|
10179
10689
|
* const program = Effect.gen(function*() {
|
|
@@ -10214,7 +10724,7 @@ export const provide: {
|
|
|
10214
10724
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10215
10725
|
*
|
|
10216
10726
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10217
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10727
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10218
10728
|
* })
|
|
10219
10729
|
*
|
|
10220
10730
|
* const program = Effect.gen(function*() {
|
|
@@ -10248,7 +10758,7 @@ export const provide: {
|
|
|
10248
10758
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10249
10759
|
*
|
|
10250
10760
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10251
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10761
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10252
10762
|
* })
|
|
10253
10763
|
*
|
|
10254
10764
|
* const program = Effect.gen(function*() {
|
|
@@ -10292,7 +10802,7 @@ export const provide: {
|
|
|
10292
10802
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10293
10803
|
*
|
|
10294
10804
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10295
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10805
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10296
10806
|
* })
|
|
10297
10807
|
*
|
|
10298
10808
|
* const program = Effect.gen(function*() {
|
|
@@ -10332,7 +10842,7 @@ export const provide: {
|
|
|
10332
10842
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
10333
10843
|
*
|
|
10334
10844
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
10335
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10845
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
10336
10846
|
* })
|
|
10337
10847
|
*
|
|
10338
10848
|
* const program = Effect.gen(function*() {
|
|
@@ -10496,7 +11006,7 @@ export const provideServices: {
|
|
|
10496
11006
|
* @since 4.0.0
|
|
10497
11007
|
* @category ServiceMap
|
|
10498
11008
|
*/
|
|
10499
|
-
export const service: <I, S>(service: ServiceMap.
|
|
11009
|
+
export const service: <I, S>(service: ServiceMap.Key<I, S>) => Effect<S, never, I> = internal.service
|
|
10500
11010
|
|
|
10501
11011
|
/**
|
|
10502
11012
|
* Optionally accesses a service from the environment.
|
|
@@ -10532,7 +11042,7 @@ export const service: <I, S>(service: ServiceMap.Service<I, S>) => Effect<S, nev
|
|
|
10532
11042
|
* @since 2.0.0
|
|
10533
11043
|
* @category ServiceMap
|
|
10534
11044
|
*/
|
|
10535
|
-
export const serviceOption: <I, S>(key: ServiceMap.
|
|
11045
|
+
export const serviceOption: <I, S>(key: ServiceMap.Key<I, S>) => Effect<Option<S>> = internal.serviceOption
|
|
10536
11046
|
|
|
10537
11047
|
/**
|
|
10538
11048
|
* Provides part of the required context while leaving the rest unchanged.
|
|
@@ -10721,7 +11231,7 @@ export const updateService: {
|
|
|
10721
11231
|
* @since 2.0.0
|
|
10722
11232
|
* @category ServiceMap
|
|
10723
11233
|
*/
|
|
10724
|
-
<I, A>(service: ServiceMap.
|
|
11234
|
+
<I, A>(service: ServiceMap.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>
|
|
10725
11235
|
/**
|
|
10726
11236
|
* Updates the service with the required service entry.
|
|
10727
11237
|
*
|
|
@@ -10750,11 +11260,7 @@ export const updateService: {
|
|
|
10750
11260
|
* @since 2.0.0
|
|
10751
11261
|
* @category ServiceMap
|
|
10752
11262
|
*/
|
|
10753
|
-
<XA, E, R, I, A>(
|
|
10754
|
-
self: Effect<XA, E, R>,
|
|
10755
|
-
service: ServiceMap.Service<I, A>,
|
|
10756
|
-
f: (value: A) => A
|
|
10757
|
-
): Effect<XA, E, R | I>
|
|
11263
|
+
<XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.Key<I, A>, f: (value: A) => A): Effect<XA, E, R | I>
|
|
10758
11264
|
} = internal.updateService
|
|
10759
11265
|
|
|
10760
11266
|
/**
|
|
@@ -10848,7 +11354,7 @@ export const provideService: {
|
|
|
10848
11354
|
* @since 2.0.0
|
|
10849
11355
|
* @category ServiceMap
|
|
10850
11356
|
*/
|
|
10851
|
-
<I, S>(service: ServiceMap.
|
|
11357
|
+
<I, S>(service: ServiceMap.Key<I, S>): {
|
|
10852
11358
|
/**
|
|
10853
11359
|
* The `provideService` function is used to provide an actual
|
|
10854
11360
|
* implementation for a service in the context of an effect.
|
|
@@ -10987,7 +11493,7 @@ export const provideService: {
|
|
|
10987
11493
|
* @since 2.0.0
|
|
10988
11494
|
* @category ServiceMap
|
|
10989
11495
|
*/
|
|
10990
|
-
<I, S>(service: ServiceMap.
|
|
11496
|
+
<I, S>(service: ServiceMap.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>
|
|
10991
11497
|
/**
|
|
10992
11498
|
* The `provideService` function is used to provide an actual
|
|
10993
11499
|
* implementation for a service in the context of an effect.
|
|
@@ -11033,11 +11539,7 @@ export const provideService: {
|
|
|
11033
11539
|
* @since 2.0.0
|
|
11034
11540
|
* @category ServiceMap
|
|
11035
11541
|
*/
|
|
11036
|
-
<A, E, R, I, S>(
|
|
11037
|
-
self: Effect<A, E, R>,
|
|
11038
|
-
service: ServiceMap.Service<I, S>,
|
|
11039
|
-
implementation: S
|
|
11040
|
-
): Effect<A, E, Exclude<R, I>>
|
|
11542
|
+
<A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>
|
|
11041
11543
|
} = internal.provideService
|
|
11042
11544
|
|
|
11043
11545
|
/**
|
|
@@ -11145,7 +11647,7 @@ export const provideServiceEffect: {
|
|
|
11145
11647
|
* @since 2.0.0
|
|
11146
11648
|
* @category ServiceMap
|
|
11147
11649
|
*/
|
|
11148
|
-
<I, S, E2, R2>(service: ServiceMap.
|
|
11650
|
+
<I, S, E2, R2>(service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>
|
|
11149
11651
|
/**
|
|
11150
11652
|
* Provides the effect with the single service it requires. If the effect
|
|
11151
11653
|
* requires more than one service use `provide` instead.
|
|
@@ -11200,7 +11702,7 @@ export const provideServiceEffect: {
|
|
|
11200
11702
|
*/
|
|
11201
11703
|
<A, E, R, I, S, E2, R2>(
|
|
11202
11704
|
self: Effect<A, E, R>,
|
|
11203
|
-
service: ServiceMap.
|
|
11705
|
+
service: ServiceMap.Key<I, S>,
|
|
11204
11706
|
acquire: Effect<S, E2, R2>
|
|
11205
11707
|
): Effect<A, E | E2, Exclude<R, I> | R2>
|
|
11206
11708
|
} = internal.provideServiceEffect
|
|
@@ -11482,10 +11984,11 @@ export const scopedWith: <A, E, R>(
|
|
|
11482
11984
|
* @since 2.0.0
|
|
11483
11985
|
* @category Resource Management & Finalization
|
|
11484
11986
|
*/
|
|
11485
|
-
export const acquireRelease: <A, E, R>(
|
|
11987
|
+
export const acquireRelease: <A, E, R, R2>(
|
|
11486
11988
|
acquire: Effect<A, E, R>,
|
|
11487
|
-
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown
|
|
11488
|
-
|
|
11989
|
+
release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown, never, R2>,
|
|
11990
|
+
options?: { readonly interruptible?: boolean }
|
|
11991
|
+
) => Effect<A, E, R | R2 | Scope> = internal.acquireRelease
|
|
11489
11992
|
|
|
11490
11993
|
/**
|
|
11491
11994
|
* This function is used to ensure that an `Effect` value that represents the
|
|
@@ -11737,9 +12240,11 @@ export const ensuring: {
|
|
|
11737
12240
|
*
|
|
11738
12241
|
* @example
|
|
11739
12242
|
* ```ts
|
|
11740
|
-
* import { Cause, Console, Effect } from "effect"
|
|
12243
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
12244
|
+
*
|
|
12245
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11741
12246
|
*
|
|
11742
|
-
* const task = Effect.fail(new
|
|
12247
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
11743
12248
|
*
|
|
11744
12249
|
* const program = Effect.onError(
|
|
11745
12250
|
* task,
|
|
@@ -11748,8 +12253,8 @@ export const ensuring: {
|
|
|
11748
12253
|
*
|
|
11749
12254
|
* Effect.runPromise(program).catch(console.error)
|
|
11750
12255
|
* // Output:
|
|
11751
|
-
* // Cleanup on error:
|
|
11752
|
-
* //
|
|
12256
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
12257
|
+
* // TaskError: Something went wrong
|
|
11753
12258
|
* ```
|
|
11754
12259
|
*
|
|
11755
12260
|
* @since 2.0.0
|
|
@@ -11762,9 +12267,11 @@ export const onError: {
|
|
|
11762
12267
|
*
|
|
11763
12268
|
* @example
|
|
11764
12269
|
* ```ts
|
|
11765
|
-
* import { Cause, Console, Effect } from "effect"
|
|
12270
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
12271
|
+
*
|
|
12272
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11766
12273
|
*
|
|
11767
|
-
* const task = Effect.fail(new
|
|
12274
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
11768
12275
|
*
|
|
11769
12276
|
* const program = Effect.onError(
|
|
11770
12277
|
* task,
|
|
@@ -11773,8 +12280,8 @@ export const onError: {
|
|
|
11773
12280
|
*
|
|
11774
12281
|
* Effect.runPromise(program).catch(console.error)
|
|
11775
12282
|
* // Output:
|
|
11776
|
-
* // Cleanup on error:
|
|
11777
|
-
* //
|
|
12283
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
12284
|
+
* // TaskError: Something went wrong
|
|
11778
12285
|
* ```
|
|
11779
12286
|
*
|
|
11780
12287
|
* @since 2.0.0
|
|
@@ -11787,9 +12294,11 @@ export const onError: {
|
|
|
11787
12294
|
*
|
|
11788
12295
|
* @example
|
|
11789
12296
|
* ```ts
|
|
11790
|
-
* import { Cause, Console, Effect } from "effect"
|
|
12297
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
12298
|
+
*
|
|
12299
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11791
12300
|
*
|
|
11792
|
-
* const task = Effect.fail(new
|
|
12301
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
11793
12302
|
*
|
|
11794
12303
|
* const program = Effect.onError(
|
|
11795
12304
|
* task,
|
|
@@ -11798,8 +12307,8 @@ export const onError: {
|
|
|
11798
12307
|
*
|
|
11799
12308
|
* Effect.runPromise(program).catch(console.error)
|
|
11800
12309
|
* // Output:
|
|
11801
|
-
* // Cleanup on error:
|
|
11802
|
-
* //
|
|
12310
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
12311
|
+
* // TaskError: Something went wrong
|
|
11803
12312
|
* ```
|
|
11804
12313
|
*
|
|
11805
12314
|
* @since 2.0.0
|
|
@@ -11813,7 +12322,7 @@ export const onError: {
|
|
|
11813
12322
|
|
|
11814
12323
|
/**
|
|
11815
12324
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11816
|
-
*
|
|
12325
|
+
* provided predicate.
|
|
11817
12326
|
*
|
|
11818
12327
|
* @example
|
|
11819
12328
|
* ```ts
|
|
@@ -11837,7 +12346,7 @@ export const onError: {
|
|
|
11837
12346
|
export const onErrorIf: {
|
|
11838
12347
|
/**
|
|
11839
12348
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11840
|
-
*
|
|
12349
|
+
* provided predicate.
|
|
11841
12350
|
*
|
|
11842
12351
|
* @example
|
|
11843
12352
|
* ```ts
|
|
@@ -11858,13 +12367,13 @@ export const onErrorIf: {
|
|
|
11858
12367
|
* @since 4.0.0
|
|
11859
12368
|
* @category Resource Management & Finalization
|
|
11860
12369
|
*/
|
|
11861
|
-
<E,
|
|
11862
|
-
|
|
11863
|
-
f: (
|
|
12370
|
+
<E, XE, XR>(
|
|
12371
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
12372
|
+
f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
11864
12373
|
): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
11865
12374
|
/**
|
|
11866
12375
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11867
|
-
*
|
|
12376
|
+
* provided predicate.
|
|
11868
12377
|
*
|
|
11869
12378
|
* @example
|
|
11870
12379
|
* ```ts
|
|
@@ -11885,13 +12394,43 @@ export const onErrorIf: {
|
|
|
11885
12394
|
* @since 4.0.0
|
|
11886
12395
|
* @category Resource Management & Finalization
|
|
11887
12396
|
*/
|
|
11888
|
-
<A, E, R, XE, XR
|
|
12397
|
+
<A, E, R, XE, XR>(
|
|
11889
12398
|
self: Effect<A, E, R>,
|
|
11890
|
-
|
|
11891
|
-
f: (
|
|
12399
|
+
predicate: Predicate.Predicate<Cause.Cause<E>>,
|
|
12400
|
+
f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
11892
12401
|
): Effect<A, E | XE, R | XR>
|
|
11893
12402
|
} = internal.onErrorIf
|
|
11894
12403
|
|
|
12404
|
+
/**
|
|
12405
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12406
|
+
*
|
|
12407
|
+
* @since 4.0.0
|
|
12408
|
+
* @category Resource Management & Finalization
|
|
12409
|
+
*/
|
|
12410
|
+
export const onErrorFilter: {
|
|
12411
|
+
/**
|
|
12412
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12413
|
+
*
|
|
12414
|
+
* @since 4.0.0
|
|
12415
|
+
* @category Resource Management & Finalization
|
|
12416
|
+
*/
|
|
12417
|
+
<A, E, EB, X, XE, XR>(
|
|
12418
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
12419
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
12420
|
+
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12421
|
+
/**
|
|
12422
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
12423
|
+
*
|
|
12424
|
+
* @since 4.0.0
|
|
12425
|
+
* @category Resource Management & Finalization
|
|
12426
|
+
*/
|
|
12427
|
+
<A, E, R, EB, X, XE, XR>(
|
|
12428
|
+
self: Effect<A, E, R>,
|
|
12429
|
+
filter: Filter.Filter<Cause.Cause<E>, EB, X>,
|
|
12430
|
+
f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>
|
|
12431
|
+
): Effect<A, E | XE, R | XR>
|
|
12432
|
+
} = internal.onErrorFilter
|
|
12433
|
+
|
|
11895
12434
|
/**
|
|
11896
12435
|
* The low level primitive that powers `onExit`.
|
|
11897
12436
|
* function is used to run a finalizer when the effect exits, regardless of the
|
|
@@ -11990,20 +12529,20 @@ export const onExit: {
|
|
|
11990
12529
|
} = internal.onExit
|
|
11991
12530
|
|
|
11992
12531
|
/**
|
|
11993
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11994
|
-
*
|
|
11995
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12532
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12533
|
+
* predicate.
|
|
11996
12534
|
*
|
|
11997
12535
|
* @example
|
|
11998
12536
|
* ```ts
|
|
11999
|
-
* import { Console, Effect, Exit
|
|
12000
|
-
*
|
|
12001
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12537
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12002
12538
|
*
|
|
12003
12539
|
* const program = Effect.onExitIf(
|
|
12004
12540
|
* Effect.succeed(42),
|
|
12005
|
-
*
|
|
12006
|
-
* (
|
|
12541
|
+
* Exit.isSuccess,
|
|
12542
|
+
* (exit) =>
|
|
12543
|
+
* Exit.isSuccess(exit)
|
|
12544
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12545
|
+
* : Effect.void
|
|
12007
12546
|
* )
|
|
12008
12547
|
* ```
|
|
12009
12548
|
*
|
|
@@ -12012,64 +12551,88 @@ export const onExit: {
|
|
|
12012
12551
|
*/
|
|
12013
12552
|
export const onExitIf: {
|
|
12014
12553
|
/**
|
|
12015
|
-
* Runs the cleanup effect only when the `Exit`
|
|
12016
|
-
*
|
|
12017
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12554
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12555
|
+
* predicate.
|
|
12018
12556
|
*
|
|
12019
12557
|
* @example
|
|
12020
12558
|
* ```ts
|
|
12021
|
-
* import { Console, Effect, Exit
|
|
12022
|
-
*
|
|
12023
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12559
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12024
12560
|
*
|
|
12025
12561
|
* const program = Effect.onExitIf(
|
|
12026
12562
|
* Effect.succeed(42),
|
|
12027
|
-
*
|
|
12028
|
-
* (
|
|
12563
|
+
* Exit.isSuccess,
|
|
12564
|
+
* (exit) =>
|
|
12565
|
+
* Exit.isSuccess(exit)
|
|
12566
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12567
|
+
* : Effect.void
|
|
12029
12568
|
* )
|
|
12030
12569
|
* ```
|
|
12031
12570
|
*
|
|
12032
12571
|
* @since 4.0.0
|
|
12033
12572
|
* @category Resource Management & Finalization
|
|
12034
12573
|
*/
|
|
12035
|
-
<A, E, XE, XR
|
|
12036
|
-
|
|
12037
|
-
f: (
|
|
12038
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
12039
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
12040
|
-
) => Effect<void, XE, XR>
|
|
12574
|
+
<A, E, XE, XR>(
|
|
12575
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
12576
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12041
12577
|
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12042
12578
|
/**
|
|
12043
|
-
* Runs the cleanup effect only when the `Exit`
|
|
12044
|
-
*
|
|
12045
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
12579
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
12580
|
+
* predicate.
|
|
12046
12581
|
*
|
|
12047
12582
|
* @example
|
|
12048
12583
|
* ```ts
|
|
12049
|
-
* import { Console, Effect, Exit
|
|
12050
|
-
*
|
|
12051
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
12584
|
+
* import { Console, Effect, Exit } from "effect"
|
|
12052
12585
|
*
|
|
12053
12586
|
* const program = Effect.onExitIf(
|
|
12054
12587
|
* Effect.succeed(42),
|
|
12055
|
-
*
|
|
12056
|
-
* (
|
|
12588
|
+
* Exit.isSuccess,
|
|
12589
|
+
* (exit) =>
|
|
12590
|
+
* Exit.isSuccess(exit)
|
|
12591
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
12592
|
+
* : Effect.void
|
|
12057
12593
|
* )
|
|
12058
12594
|
* ```
|
|
12059
12595
|
*
|
|
12060
12596
|
* @since 4.0.0
|
|
12061
12597
|
* @category Resource Management & Finalization
|
|
12062
12598
|
*/
|
|
12063
|
-
<A, E, R, XE, XR
|
|
12599
|
+
<A, E, R, XE, XR>(
|
|
12064
12600
|
self: Effect<A, E, R>,
|
|
12065
|
-
|
|
12066
|
-
f: (
|
|
12067
|
-
pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>,
|
|
12068
|
-
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
|
|
12069
|
-
) => Effect<void, XE, XR>
|
|
12601
|
+
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
|
|
12602
|
+
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12070
12603
|
): Effect<A, E | XE, R | XR>
|
|
12071
12604
|
} = internal.onExitIf
|
|
12072
12605
|
|
|
12606
|
+
/**
|
|
12607
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12608
|
+
*
|
|
12609
|
+
* @since 4.0.0
|
|
12610
|
+
* @category Resource Management & Finalization
|
|
12611
|
+
*/
|
|
12612
|
+
export const onExitFilter: {
|
|
12613
|
+
/**
|
|
12614
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12615
|
+
*
|
|
12616
|
+
* @since 4.0.0
|
|
12617
|
+
* @category Resource Management & Finalization
|
|
12618
|
+
*/
|
|
12619
|
+
<A, E, XE, XR, B, X>(
|
|
12620
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
12621
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12622
|
+
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
|
|
12623
|
+
/**
|
|
12624
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
12625
|
+
*
|
|
12626
|
+
* @since 4.0.0
|
|
12627
|
+
* @category Resource Management & Finalization
|
|
12628
|
+
*/
|
|
12629
|
+
<A, E, R, XE, XR, B, X>(
|
|
12630
|
+
self: Effect<A, E, R>,
|
|
12631
|
+
filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>,
|
|
12632
|
+
f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
|
|
12633
|
+
): Effect<A, E | XE, R | XR>
|
|
12634
|
+
} = internal.onExitFilter
|
|
12635
|
+
|
|
12073
12636
|
// -----------------------------------------------------------------------------
|
|
12074
12637
|
// Caching
|
|
12075
12638
|
// -----------------------------------------------------------------------------
|
|
@@ -12272,7 +12835,7 @@ export const cachedWithTTL: {
|
|
|
12272
12835
|
* @since 2.0.0
|
|
12273
12836
|
* @category Caching
|
|
12274
12837
|
*/
|
|
12275
|
-
(timeToLive: Duration.
|
|
12838
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
12276
12839
|
/**
|
|
12277
12840
|
* Returns an effect that caches its result for a specified `Duration`,
|
|
12278
12841
|
* known as "timeToLive" (TTL).
|
|
@@ -12339,7 +12902,7 @@ export const cachedWithTTL: {
|
|
|
12339
12902
|
* @since 2.0.0
|
|
12340
12903
|
* @category Caching
|
|
12341
12904
|
*/
|
|
12342
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12905
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>
|
|
12343
12906
|
} = internal.cachedWithTTL
|
|
12344
12907
|
|
|
12345
12908
|
/**
|
|
@@ -12481,7 +13044,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
12481
13044
|
* @since 2.0.0
|
|
12482
13045
|
* @category Caching
|
|
12483
13046
|
*/
|
|
12484
|
-
(timeToLive: Duration.
|
|
13047
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>
|
|
12485
13048
|
/**
|
|
12486
13049
|
* Caches an effect's result for a specified duration and allows manual
|
|
12487
13050
|
* invalidation before expiration.
|
|
@@ -12551,7 +13114,7 @@ export const cachedInvalidateWithTTL: {
|
|
|
12551
13114
|
* @since 2.0.0
|
|
12552
13115
|
* @category Caching
|
|
12553
13116
|
*/
|
|
12554
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
13117
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>
|
|
12555
13118
|
} = internal.cachedInvalidateWithTTL
|
|
12556
13119
|
|
|
12557
13120
|
// -----------------------------------------------------------------------------
|
|
@@ -12566,8 +13129,8 @@ export const cachedInvalidateWithTTL: {
|
|
|
12566
13129
|
* import { Effect } from "effect"
|
|
12567
13130
|
*
|
|
12568
13131
|
* const program = Effect.gen(function*() {
|
|
12569
|
-
* yield* Effect.interrupt
|
|
12570
|
-
* yield* Effect.succeed("This won't execute")
|
|
13132
|
+
* return yield* Effect.interrupt
|
|
13133
|
+
* yield* Effect.succeed("This won't execute and is unreachable")
|
|
12571
13134
|
* })
|
|
12572
13135
|
*
|
|
12573
13136
|
* Effect.runPromise(program).catch(console.error)
|
|
@@ -12670,358 +13233,112 @@ export const onInterrupt: {
|
|
|
12670
13233
|
* // Output: Task was interrupted, cleaning up...
|
|
12671
13234
|
* ```
|
|
12672
13235
|
*
|
|
12673
|
-
* @since 2.0.0
|
|
12674
|
-
* @category Interruption
|
|
12675
|
-
*/
|
|
12676
|
-
<A, E, R, XE, XR>(
|
|
12677
|
-
self: Effect<A, E, R>,
|
|
12678
|
-
finalizer: (interruptors: ReadonlySet<number>) => Effect<void, XE, XR>
|
|
12679
|
-
): Effect<A, E | XE, R | XR>
|
|
12680
|
-
} = internal.onInterrupt
|
|
12681
|
-
|
|
12682
|
-
/**
|
|
12683
|
-
* Returns a new effect that disables interruption for the given effect.
|
|
12684
|
-
*
|
|
12685
|
-
* @example
|
|
12686
|
-
* ```ts
|
|
12687
|
-
* import { Console, Effect, Fiber } from "effect"
|
|
12688
|
-
*
|
|
12689
|
-
* const criticalTask = Effect.gen(function*() {
|
|
12690
|
-
* yield* Console.log("Starting critical section...")
|
|
12691
|
-
* yield* Effect.sleep("2 seconds")
|
|
12692
|
-
* yield* Console.log("Critical section completed")
|
|
12693
|
-
* })
|
|
12694
|
-
*
|
|
12695
|
-
* const program = Effect.uninterruptible(criticalTask)
|
|
12696
|
-
*
|
|
12697
|
-
* const fiber = Effect.runFork(program)
|
|
12698
|
-
* // Even if interrupted, the critical task will complete
|
|
12699
|
-
* Effect.runPromise(Fiber.interrupt(fiber))
|
|
12700
|
-
* ```
|
|
12701
|
-
*
|
|
12702
|
-
* @since 2.0.0
|
|
12703
|
-
* @category Interruption
|
|
12704
|
-
*/
|
|
12705
|
-
export const uninterruptible: <A, E, R>(
|
|
12706
|
-
self: Effect<A, E, R>
|
|
12707
|
-
) => Effect<A, E, R> = internal.uninterruptible
|
|
12708
|
-
|
|
12709
|
-
/**
|
|
12710
|
-
* Disables interruption and provides a restore function to restore the
|
|
12711
|
-
* interruptible state within the effect.
|
|
12712
|
-
*
|
|
12713
|
-
* @example
|
|
12714
|
-
* ```ts
|
|
12715
|
-
* import { Console, Effect } from "effect"
|
|
12716
|
-
*
|
|
12717
|
-
* const program = Effect.uninterruptibleMask((restore) =>
|
|
12718
|
-
* Effect.gen(function*() {
|
|
12719
|
-
* yield* Console.log("Uninterruptible phase...")
|
|
12720
|
-
* yield* Effect.sleep("1 second")
|
|
12721
|
-
*
|
|
12722
|
-
* // Restore interruptibility for this part
|
|
12723
|
-
* yield* restore(
|
|
12724
|
-
* Effect.gen(function*() {
|
|
12725
|
-
* yield* Console.log("Interruptible phase...")
|
|
12726
|
-
* yield* Effect.sleep("2 seconds")
|
|
12727
|
-
* })
|
|
12728
|
-
* )
|
|
12729
|
-
*
|
|
12730
|
-
* yield* Console.log("Back to uninterruptible")
|
|
12731
|
-
* })
|
|
12732
|
-
* )
|
|
12733
|
-
* ```
|
|
12734
|
-
*
|
|
12735
|
-
* @since 2.0.0
|
|
12736
|
-
* @category Interruption
|
|
12737
|
-
*/
|
|
12738
|
-
export const uninterruptibleMask: <A, E, R>(
|
|
12739
|
-
f: (
|
|
12740
|
-
restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>
|
|
12741
|
-
) => Effect<A, E, R>
|
|
12742
|
-
) => Effect<A, E, R> = internal.uninterruptibleMask
|
|
12743
|
-
|
|
12744
|
-
/**
|
|
12745
|
-
* This function behaves like {@link interruptible}, but it also provides a
|
|
12746
|
-
* `restore` function. This function can be used to restore the interruptibility
|
|
12747
|
-
* of any specific region of code.
|
|
12748
|
-
*
|
|
12749
|
-
* @example
|
|
12750
|
-
* ```ts
|
|
12751
|
-
* import { Console, Effect } from "effect"
|
|
12752
|
-
*
|
|
12753
|
-
* const program = Effect.interruptibleMask((restore) =>
|
|
12754
|
-
* Effect.gen(function*() {
|
|
12755
|
-
* yield* Console.log("Interruptible phase...")
|
|
12756
|
-
* yield* Effect.sleep("1 second")
|
|
12757
|
-
*
|
|
12758
|
-
* // Make this part uninterruptible
|
|
12759
|
-
* yield* restore(
|
|
12760
|
-
* Effect.gen(function*() {
|
|
12761
|
-
* yield* Console.log("Uninterruptible phase...")
|
|
12762
|
-
* yield* Effect.sleep("2 seconds")
|
|
12763
|
-
* })
|
|
12764
|
-
* )
|
|
12765
|
-
*
|
|
12766
|
-
* yield* Console.log("Back to interruptible")
|
|
12767
|
-
* })
|
|
12768
|
-
* )
|
|
12769
|
-
* ```
|
|
12770
|
-
*
|
|
12771
|
-
* @since 2.0.0
|
|
12772
|
-
* @category Interruption
|
|
12773
|
-
*/
|
|
12774
|
-
export const interruptibleMask: <A, E, R>(
|
|
12775
|
-
f: (
|
|
12776
|
-
restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>
|
|
12777
|
-
) => Effect<A, E, R>
|
|
12778
|
-
) => Effect<A, E, R> = internal.interruptibleMask
|
|
12779
|
-
|
|
12780
|
-
// -----------------------------------------------------------------------------
|
|
12781
|
-
// Semaphore
|
|
12782
|
-
// -----------------------------------------------------------------------------
|
|
12783
|
-
|
|
12784
|
-
/**
|
|
12785
|
-
* @category Semaphore
|
|
12786
|
-
* @since 2.0.0
|
|
12787
|
-
* @example
|
|
12788
|
-
* ```ts
|
|
12789
|
-
* import { Effect } from "effect"
|
|
12790
|
-
*
|
|
12791
|
-
* // Create and use a semaphore for controlling concurrent access
|
|
12792
|
-
* const program = Effect.gen(function*() {
|
|
12793
|
-
* const semaphore = yield* Effect.makeSemaphore(2)
|
|
12794
|
-
*
|
|
12795
|
-
* return yield* semaphore.withPermits(1)(
|
|
12796
|
-
* Effect.succeed("Resource accessed")
|
|
12797
|
-
* )
|
|
12798
|
-
* })
|
|
12799
|
-
* ```
|
|
12800
|
-
*/
|
|
12801
|
-
export interface Semaphore {
|
|
12802
|
-
/**
|
|
12803
|
-
* Adjusts the number of permits available in the semaphore.
|
|
12804
|
-
*/
|
|
12805
|
-
resize(permits: number): Effect<void>
|
|
12806
|
-
|
|
12807
|
-
/**
|
|
12808
|
-
* Runs an effect with the given number of permits and releases the permits
|
|
12809
|
-
* when the effect completes.
|
|
12810
|
-
*
|
|
12811
|
-
* **Details**
|
|
12812
|
-
*
|
|
12813
|
-
* This function acquires the specified number of permits before executing
|
|
12814
|
-
* the provided effect. Once the effect finishes, the permits are released.
|
|
12815
|
-
* If insufficient permits are available, the function will wait until they
|
|
12816
|
-
* are released by other tasks.
|
|
12817
|
-
*/
|
|
12818
|
-
withPermits(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
12819
|
-
|
|
12820
|
-
/**
|
|
12821
|
-
* Runs an effect with the given number of permits and releases the permits
|
|
12822
|
-
* when the effect completes.
|
|
12823
|
-
*
|
|
12824
|
-
* **Details**
|
|
12825
|
-
*
|
|
12826
|
-
* This function acquires the specified number of permits before executing
|
|
12827
|
-
* the provided effect. Once the effect finishes, the permits are released.
|
|
12828
|
-
* If insufficient permits are available, the function will wait until they
|
|
12829
|
-
* are released by other tasks.
|
|
12830
|
-
*/
|
|
12831
|
-
withPermit<A, E, R>(self: Effect<A, E, R>): Effect<A, E, R>
|
|
12832
|
-
|
|
12833
|
-
/**
|
|
12834
|
-
* Runs an effect only if the specified number of permits are immediately
|
|
12835
|
-
* available.
|
|
12836
|
-
*
|
|
12837
|
-
* **Details**
|
|
12838
|
-
*
|
|
12839
|
-
* This function attempts to acquire the specified number of permits. If they
|
|
12840
|
-
* are available, it runs the effect and releases the permits after the effect
|
|
12841
|
-
* completes. If permits are not available, the effect does not execute, and
|
|
12842
|
-
* the result is `Option.none`.
|
|
12843
|
-
*/
|
|
12844
|
-
withPermitsIfAvailable(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>
|
|
12845
|
-
|
|
12846
|
-
/**
|
|
12847
|
-
* Acquires the specified number of permits and returns the resulting
|
|
12848
|
-
* available permits, suspending the task if they are not yet available.
|
|
12849
|
-
* Concurrent pending `take` calls are processed in a first-in, first-out manner.
|
|
12850
|
-
*/
|
|
12851
|
-
take(permits: number): Effect<number>
|
|
12852
|
-
|
|
12853
|
-
/**
|
|
12854
|
-
* Releases the specified number of permits and returns the resulting
|
|
12855
|
-
* available permits.
|
|
12856
|
-
*/
|
|
12857
|
-
release(permits: number): Effect<number>
|
|
12858
|
-
|
|
12859
|
-
/**
|
|
12860
|
-
* Releases all permits held by this semaphore and returns the resulting available permits.
|
|
13236
|
+
* @since 2.0.0
|
|
13237
|
+
* @category Interruption
|
|
12861
13238
|
*/
|
|
12862
|
-
|
|
12863
|
-
|
|
13239
|
+
<A, E, R, XE, XR>(
|
|
13240
|
+
self: Effect<A, E, R>,
|
|
13241
|
+
finalizer: (interruptors: ReadonlySet<number>) => Effect<void, XE, XR>
|
|
13242
|
+
): Effect<A, E | XE, R | XR>
|
|
13243
|
+
} = internal.onInterrupt
|
|
12864
13244
|
|
|
12865
13245
|
/**
|
|
12866
|
-
*
|
|
13246
|
+
* Returns a new effect that disables interruption for the given effect.
|
|
12867
13247
|
*
|
|
12868
13248
|
* @example
|
|
12869
13249
|
* ```ts
|
|
12870
|
-
* import { Effect } from "effect"
|
|
13250
|
+
* import { Console, Effect, Fiber } from "effect"
|
|
12871
13251
|
*
|
|
12872
|
-
* const
|
|
13252
|
+
* const criticalTask = Effect.gen(function*() {
|
|
13253
|
+
* yield* Console.log("Starting critical section...")
|
|
13254
|
+
* yield* Effect.sleep("2 seconds")
|
|
13255
|
+
* yield* Console.log("Critical section completed")
|
|
13256
|
+
* })
|
|
12873
13257
|
*
|
|
12874
|
-
* const
|
|
12875
|
-
* semaphore.withPermits(1)(
|
|
12876
|
-
* Effect.gen(function*() {
|
|
12877
|
-
* yield* Effect.log(`Task ${id} started`)
|
|
12878
|
-
* yield* Effect.sleep("1 second")
|
|
12879
|
-
* yield* Effect.log(`Task ${id} completed`)
|
|
12880
|
-
* })
|
|
12881
|
-
* )
|
|
13258
|
+
* const program = Effect.uninterruptible(criticalTask)
|
|
12882
13259
|
*
|
|
12883
|
-
*
|
|
12884
|
-
*
|
|
12885
|
-
*
|
|
12886
|
-
* task(2),
|
|
12887
|
-
* task(3),
|
|
12888
|
-
* task(4),
|
|
12889
|
-
* task(5)
|
|
12890
|
-
* ], { concurrency: "unbounded" })
|
|
13260
|
+
* const fiber = Effect.runFork(program)
|
|
13261
|
+
* // Even if interrupted, the critical task will complete
|
|
13262
|
+
* Effect.runPromise(Fiber.interrupt(fiber))
|
|
12891
13263
|
* ```
|
|
12892
13264
|
*
|
|
12893
13265
|
* @since 2.0.0
|
|
12894
|
-
* @category
|
|
13266
|
+
* @category Interruption
|
|
12895
13267
|
*/
|
|
12896
|
-
export const
|
|
13268
|
+
export const uninterruptible: <A, E, R>(
|
|
13269
|
+
self: Effect<A, E, R>
|
|
13270
|
+
) => Effect<A, E, R> = internal.uninterruptible
|
|
12897
13271
|
|
|
12898
13272
|
/**
|
|
12899
|
-
*
|
|
13273
|
+
* Disables interruption and provides a restore function to restore the
|
|
13274
|
+
* interruptible state within the effect.
|
|
12900
13275
|
*
|
|
12901
13276
|
* @example
|
|
12902
13277
|
* ```ts
|
|
12903
|
-
* import { Effect } from "effect"
|
|
13278
|
+
* import { Console, Effect } from "effect"
|
|
12904
13279
|
*
|
|
12905
|
-
* const program = Effect.
|
|
12906
|
-
*
|
|
13280
|
+
* const program = Effect.uninterruptibleMask((restore) =>
|
|
13281
|
+
* Effect.gen(function*() {
|
|
13282
|
+
* yield* Console.log("Uninterruptible phase...")
|
|
13283
|
+
* yield* Effect.sleep("1 second")
|
|
12907
13284
|
*
|
|
12908
|
-
*
|
|
12909
|
-
*
|
|
13285
|
+
* // Restore interruptibility for this part
|
|
13286
|
+
* yield* restore(
|
|
12910
13287
|
* Effect.gen(function*() {
|
|
12911
|
-
* yield*
|
|
12912
|
-
* yield* Effect.sleep("
|
|
12913
|
-
* yield* Effect.log(`Task ${id} releasing permit`)
|
|
13288
|
+
* yield* Console.log("Interruptible phase...")
|
|
13289
|
+
* yield* Effect.sleep("2 seconds")
|
|
12914
13290
|
* })
|
|
12915
13291
|
* )
|
|
12916
13292
|
*
|
|
12917
|
-
*
|
|
12918
|
-
*
|
|
12919
|
-
*
|
|
13293
|
+
* yield* Console.log("Back to uninterruptible")
|
|
13294
|
+
* })
|
|
13295
|
+
* )
|
|
12920
13296
|
* ```
|
|
12921
13297
|
*
|
|
12922
13298
|
* @since 2.0.0
|
|
12923
|
-
* @category
|
|
12924
|
-
*/
|
|
12925
|
-
export const makeSemaphore: (permits: number) => Effect<Semaphore> = internal.makeSemaphore
|
|
12926
|
-
|
|
12927
|
-
// -----------------------------------------------------------------------------
|
|
12928
|
-
// Latch
|
|
12929
|
-
// -----------------------------------------------------------------------------
|
|
12930
|
-
|
|
12931
|
-
/**
|
|
12932
|
-
* @category Latch
|
|
12933
|
-
* @since 3.8.0
|
|
12934
|
-
* @example
|
|
12935
|
-
* ```ts
|
|
12936
|
-
* import { Effect } from "effect"
|
|
12937
|
-
*
|
|
12938
|
-
* // Create and use a latch for coordination between fibers
|
|
12939
|
-
* const program = Effect.gen(function*() {
|
|
12940
|
-
* const latch = yield* Effect.makeLatch()
|
|
12941
|
-
*
|
|
12942
|
-
* // Wait for the latch to be opened
|
|
12943
|
-
* yield* latch.await
|
|
12944
|
-
*
|
|
12945
|
-
* return "Latch was opened!"
|
|
12946
|
-
* })
|
|
12947
|
-
* ```
|
|
12948
|
-
*/
|
|
12949
|
-
export interface Latch {
|
|
12950
|
-
/** open the latch, releasing all fibers waiting on it */
|
|
12951
|
-
readonly open: Effect<boolean>
|
|
12952
|
-
/** open the latch, releasing all fibers waiting on it */
|
|
12953
|
-
readonly openUnsafe: () => boolean
|
|
12954
|
-
/** release all fibers waiting on the latch, without opening it */
|
|
12955
|
-
readonly release: Effect<boolean>
|
|
12956
|
-
/** wait for the latch to be opened */
|
|
12957
|
-
readonly await: Effect<void>
|
|
12958
|
-
/** close the latch */
|
|
12959
|
-
readonly close: Effect<boolean>
|
|
12960
|
-
/** close the latch */
|
|
12961
|
-
readonly closeUnsafe: () => boolean
|
|
12962
|
-
/** only run the given effect when the latch is open */
|
|
12963
|
-
readonly whenOpen: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>
|
|
12964
|
-
}
|
|
12965
|
-
|
|
12966
|
-
/**
|
|
12967
|
-
* Creates a new Latch.
|
|
12968
|
-
*
|
|
12969
|
-
* @example
|
|
12970
|
-
* ```ts
|
|
12971
|
-
* import { Effect } from "effect"
|
|
12972
|
-
*
|
|
12973
|
-
* const latch = Effect.makeLatchUnsafe(false)
|
|
12974
|
-
*
|
|
12975
|
-
* const waiter = Effect.gen(function*() {
|
|
12976
|
-
* yield* Effect.log("Waiting for latch to open...")
|
|
12977
|
-
* yield* latch.await
|
|
12978
|
-
* yield* Effect.log("Latch opened! Continuing...")
|
|
12979
|
-
* })
|
|
12980
|
-
*
|
|
12981
|
-
* const opener = Effect.gen(function*() {
|
|
12982
|
-
* yield* Effect.sleep("2 seconds")
|
|
12983
|
-
* yield* Effect.log("Opening latch...")
|
|
12984
|
-
* yield* latch.open
|
|
12985
|
-
* })
|
|
12986
|
-
*
|
|
12987
|
-
* const program = Effect.all([waiter, opener])
|
|
12988
|
-
* ```
|
|
12989
|
-
*
|
|
12990
|
-
* @category Latch
|
|
12991
|
-
* @since 3.8.0
|
|
13299
|
+
* @category Interruption
|
|
12992
13300
|
*/
|
|
12993
|
-
export const
|
|
13301
|
+
export const uninterruptibleMask: <A, E, R>(
|
|
13302
|
+
f: (
|
|
13303
|
+
restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>
|
|
13304
|
+
) => Effect<A, E, R>
|
|
13305
|
+
) => Effect<A, E, R> = internal.uninterruptibleMask
|
|
12994
13306
|
|
|
12995
13307
|
/**
|
|
12996
|
-
*
|
|
13308
|
+
* This function behaves like {@link interruptible}, but it also provides a
|
|
13309
|
+
* `restore` function. This function can be used to restore the interruptibility
|
|
13310
|
+
* of any specific region of code.
|
|
12997
13311
|
*
|
|
12998
13312
|
* @example
|
|
12999
13313
|
* ```ts
|
|
13000
|
-
* import { Effect } from "effect"
|
|
13314
|
+
* import { Console, Effect } from "effect"
|
|
13001
13315
|
*
|
|
13002
|
-
* const program = Effect.
|
|
13003
|
-
*
|
|
13316
|
+
* const program = Effect.interruptibleMask((restore) =>
|
|
13317
|
+
* Effect.gen(function*() {
|
|
13318
|
+
* yield* Console.log("Interruptible phase...")
|
|
13319
|
+
* yield* Effect.sleep("1 second")
|
|
13004
13320
|
*
|
|
13005
|
-
*
|
|
13006
|
-
* yield*
|
|
13007
|
-
*
|
|
13008
|
-
*
|
|
13009
|
-
*
|
|
13321
|
+
* // Make this part uninterruptible
|
|
13322
|
+
* yield* restore(
|
|
13323
|
+
* Effect.gen(function*() {
|
|
13324
|
+
* yield* Console.log("Uninterruptible phase...")
|
|
13325
|
+
* yield* Effect.sleep("2 seconds")
|
|
13326
|
+
* })
|
|
13327
|
+
* )
|
|
13010
13328
|
*
|
|
13011
|
-
*
|
|
13012
|
-
* yield* Effect.sleep("2 seconds")
|
|
13013
|
-
* yield* Effect.log("Opening latch...")
|
|
13014
|
-
* yield* latch.open
|
|
13329
|
+
* yield* Console.log("Back to interruptible")
|
|
13015
13330
|
* })
|
|
13016
|
-
*
|
|
13017
|
-
* yield* Effect.all([waiter, opener])
|
|
13018
|
-
* })
|
|
13331
|
+
* )
|
|
13019
13332
|
* ```
|
|
13020
13333
|
*
|
|
13021
|
-
* @
|
|
13022
|
-
* @
|
|
13334
|
+
* @since 2.0.0
|
|
13335
|
+
* @category Interruption
|
|
13023
13336
|
*/
|
|
13024
|
-
export const
|
|
13337
|
+
export const interruptibleMask: <A, E, R>(
|
|
13338
|
+
f: (
|
|
13339
|
+
restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>
|
|
13340
|
+
) => Effect<A, E, R>
|
|
13341
|
+
) => Effect<A, E, R> = internal.interruptibleMask
|
|
13025
13342
|
|
|
13026
13343
|
// -----------------------------------------------------------------------------
|
|
13027
13344
|
// Repetition & Recursion
|
|
@@ -13057,17 +13374,14 @@ export declare namespace Repeat {
|
|
|
13057
13374
|
export type Return<R, E, A, O extends Options<A>> = Effect<
|
|
13058
13375
|
O extends { schedule: Schedule<infer Out, infer _I, infer _E, infer _R> } ? Out
|
|
13059
13376
|
: O extends { until: Predicate.Refinement<A, infer B> } ? B
|
|
13377
|
+
: O extends { while: Predicate.Refinement<A, infer B> } ? Exclude<A, B>
|
|
13060
13378
|
: A,
|
|
13061
13379
|
| E
|
|
13062
13380
|
| (O extends { schedule: Schedule<infer _Out, infer _I, infer E, infer _R> } ? E
|
|
13063
13381
|
: never)
|
|
13064
|
-
| (O extends {
|
|
13065
|
-
while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>
|
|
13066
|
-
} ? E
|
|
13382
|
+
| (O extends { while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R> } ? E
|
|
13067
13383
|
: never)
|
|
13068
|
-
| (O extends {
|
|
13069
|
-
until: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>
|
|
13070
|
-
} ? E
|
|
13384
|
+
| (O extends { until: (...args: Array<any>) => Effect<infer _A, infer E, infer _R> } ? E
|
|
13071
13385
|
: never),
|
|
13072
13386
|
| R
|
|
13073
13387
|
| (O extends { schedule: Schedule<infer _O, infer _I, infer _E, infer R> } ? R
|
|
@@ -13640,7 +13954,7 @@ export const repeat: {
|
|
|
13640
13954
|
* attempt++
|
|
13641
13955
|
* if (attempt <= 2) {
|
|
13642
13956
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
13643
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13957
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
13644
13958
|
* }
|
|
13645
13959
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
13646
13960
|
* return "success"
|
|
@@ -13690,7 +14004,7 @@ export const repeatOrElse: {
|
|
|
13690
14004
|
* attempt++
|
|
13691
14005
|
* if (attempt <= 2) {
|
|
13692
14006
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
13693
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
14007
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
13694
14008
|
* }
|
|
13695
14009
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
13696
14010
|
* return "success"
|
|
@@ -13743,7 +14057,7 @@ export const repeatOrElse: {
|
|
|
13743
14057
|
* attempt++
|
|
13744
14058
|
* if (attempt <= 2) {
|
|
13745
14059
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
13746
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
14060
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
13747
14061
|
* }
|
|
13748
14062
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
13749
14063
|
* return "success"
|
|
@@ -15208,7 +15522,7 @@ export const withParentSpan: {
|
|
|
15208
15522
|
* )
|
|
15209
15523
|
*
|
|
15210
15524
|
* const program = Effect.gen(function*() {
|
|
15211
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
15525
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
15212
15526
|
* yield* Console.log(name)
|
|
15213
15527
|
* })
|
|
15214
15528
|
* ```
|
|
@@ -15243,7 +15557,7 @@ export const request: {
|
|
|
15243
15557
|
* )
|
|
15244
15558
|
*
|
|
15245
15559
|
* const program = Effect.gen(function*() {
|
|
15246
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
15560
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
15247
15561
|
* yield* Console.log(name)
|
|
15248
15562
|
* })
|
|
15249
15563
|
* ```
|
|
@@ -15278,7 +15592,7 @@ export const request: {
|
|
|
15278
15592
|
* )
|
|
15279
15593
|
*
|
|
15280
15594
|
* const program = Effect.gen(function*() {
|
|
15281
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
15595
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
15282
15596
|
* yield* Console.log(name)
|
|
15283
15597
|
* })
|
|
15284
15598
|
* ```
|
|
@@ -15516,7 +15830,7 @@ export const forkScoped: <
|
|
|
15516
15830
|
readonly startImmediately?: boolean | undefined
|
|
15517
15831
|
readonly uninterruptible?: boolean | "inherit" | undefined
|
|
15518
15832
|
} | undefined
|
|
15519
|
-
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R>
|
|
15833
|
+
) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R | Scope>
|
|
15520
15834
|
: <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope> = internal.forkScoped
|
|
15521
15835
|
|
|
15522
15836
|
/**
|
|
@@ -20339,7 +20653,7 @@ export const clockWith: <A, E, R>(
|
|
|
20339
20653
|
* @since 2.0.0
|
|
20340
20654
|
* @category Logging
|
|
20341
20655
|
*/
|
|
20342
|
-
export const logWithLevel: (level?:
|
|
20656
|
+
export const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void> =
|
|
20343
20657
|
internal.logWithLevel
|
|
20344
20658
|
|
|
20345
20659
|
/**
|
|
@@ -20751,7 +21065,7 @@ export const annotateLogs = dual<
|
|
|
20751
21065
|
): Effect<A, E, R>;
|
|
20752
21066
|
}
|
|
20753
21067
|
>(
|
|
20754
|
-
(args) =>
|
|
21068
|
+
(args) => isEffect(args[0]),
|
|
20755
21069
|
<A, E, R>(
|
|
20756
21070
|
effect: Effect<A, E, R>,
|
|
20757
21071
|
...args: [Record<string, unknown>] | [key: string, value: unknown]
|
|
@@ -20767,6 +21081,86 @@ export const annotateLogs = dual<
|
|
|
20767
21081
|
})
|
|
20768
21082
|
)
|
|
20769
21083
|
|
|
21084
|
+
/**
|
|
21085
|
+
* Adds log annotations to the current scope.
|
|
21086
|
+
*
|
|
21087
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
21088
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
21089
|
+
* restores the previous annotations when the scope closes.
|
|
21090
|
+
*
|
|
21091
|
+
* @example
|
|
21092
|
+
* ```ts
|
|
21093
|
+
* import { Effect } from "effect"
|
|
21094
|
+
*
|
|
21095
|
+
* const program = Effect.scoped(
|
|
21096
|
+
* Effect.gen(function*() {
|
|
21097
|
+
* yield* Effect.log("before")
|
|
21098
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
21099
|
+
* yield* Effect.log("inside scope")
|
|
21100
|
+
* })
|
|
21101
|
+
* )
|
|
21102
|
+
*
|
|
21103
|
+
* Effect.runPromise(program)
|
|
21104
|
+
* ```
|
|
21105
|
+
*
|
|
21106
|
+
* @since 4.0.0
|
|
21107
|
+
* @category Logging
|
|
21108
|
+
*/
|
|
21109
|
+
export const annotateLogsScoped: {
|
|
21110
|
+
/**
|
|
21111
|
+
* Adds log annotations to the current scope.
|
|
21112
|
+
*
|
|
21113
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
21114
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
21115
|
+
* restores the previous annotations when the scope closes.
|
|
21116
|
+
*
|
|
21117
|
+
* @example
|
|
21118
|
+
* ```ts
|
|
21119
|
+
* import { Effect } from "effect"
|
|
21120
|
+
*
|
|
21121
|
+
* const program = Effect.scoped(
|
|
21122
|
+
* Effect.gen(function*() {
|
|
21123
|
+
* yield* Effect.log("before")
|
|
21124
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
21125
|
+
* yield* Effect.log("inside scope")
|
|
21126
|
+
* })
|
|
21127
|
+
* )
|
|
21128
|
+
*
|
|
21129
|
+
* Effect.runPromise(program)
|
|
21130
|
+
* ```
|
|
21131
|
+
*
|
|
21132
|
+
* @since 4.0.0
|
|
21133
|
+
* @category Logging
|
|
21134
|
+
*/
|
|
21135
|
+
(key: string, value: unknown): Effect<void, never, Scope>
|
|
21136
|
+
/**
|
|
21137
|
+
* Adds log annotations to the current scope.
|
|
21138
|
+
*
|
|
21139
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
21140
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
21141
|
+
* restores the previous annotations when the scope closes.
|
|
21142
|
+
*
|
|
21143
|
+
* @example
|
|
21144
|
+
* ```ts
|
|
21145
|
+
* import { Effect } from "effect"
|
|
21146
|
+
*
|
|
21147
|
+
* const program = Effect.scoped(
|
|
21148
|
+
* Effect.gen(function*() {
|
|
21149
|
+
* yield* Effect.log("before")
|
|
21150
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
21151
|
+
* yield* Effect.log("inside scope")
|
|
21152
|
+
* })
|
|
21153
|
+
* )
|
|
21154
|
+
*
|
|
21155
|
+
* Effect.runPromise(program)
|
|
21156
|
+
* ```
|
|
21157
|
+
*
|
|
21158
|
+
* @since 4.0.0
|
|
21159
|
+
* @category Logging
|
|
21160
|
+
*/
|
|
21161
|
+
(values: Record<string, unknown>): Effect<void, never, Scope>
|
|
21162
|
+
} = internal.annotateLogsScoped
|
|
21163
|
+
|
|
20770
21164
|
/**
|
|
20771
21165
|
* Adds a span to each log line in this effect.
|
|
20772
21166
|
*
|
|
@@ -21429,18 +21823,20 @@ export const trackSuccesses: {
|
|
|
21429
21823
|
*
|
|
21430
21824
|
* @example
|
|
21431
21825
|
* ```ts
|
|
21432
|
-
* import { Effect, Metric } from "effect"
|
|
21826
|
+
* import { Data, Effect, Metric } from "effect"
|
|
21827
|
+
*
|
|
21828
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
21433
21829
|
*
|
|
21434
21830
|
* // Track error types using frequency metric
|
|
21435
21831
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
21436
21832
|
*
|
|
21437
|
-
* const program = Effect.fail(new
|
|
21438
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
21833
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
21834
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
21439
21835
|
* )
|
|
21440
21836
|
*
|
|
21441
21837
|
* Effect.runPromiseExit(program).then(() =>
|
|
21442
21838
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
21443
|
-
* // Output: { occurrences: Map(1) { "
|
|
21839
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
21444
21840
|
* )
|
|
21445
21841
|
* ```
|
|
21446
21842
|
*
|
|
@@ -21475,18 +21871,20 @@ export const trackErrors: {
|
|
|
21475
21871
|
*
|
|
21476
21872
|
* @example
|
|
21477
21873
|
* ```ts
|
|
21478
|
-
* import { Effect, Metric } from "effect"
|
|
21874
|
+
* import { Data, Effect, Metric } from "effect"
|
|
21875
|
+
*
|
|
21876
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
21479
21877
|
*
|
|
21480
21878
|
* // Track error types using frequency metric
|
|
21481
21879
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
21482
21880
|
*
|
|
21483
|
-
* const program = Effect.fail(new
|
|
21484
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
21881
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
21882
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
21485
21883
|
* )
|
|
21486
21884
|
*
|
|
21487
21885
|
* Effect.runPromiseExit(program).then(() =>
|
|
21488
21886
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
21489
|
-
* // Output: { occurrences: Map(1) { "
|
|
21887
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
21490
21888
|
* )
|
|
21491
21889
|
* ```
|
|
21492
21890
|
*
|
|
@@ -21521,18 +21919,20 @@ export const trackErrors: {
|
|
|
21521
21919
|
*
|
|
21522
21920
|
* @example
|
|
21523
21921
|
* ```ts
|
|
21524
|
-
* import { Effect, Metric } from "effect"
|
|
21922
|
+
* import { Data, Effect, Metric } from "effect"
|
|
21923
|
+
*
|
|
21924
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
21525
21925
|
*
|
|
21526
21926
|
* // Track error types using frequency metric
|
|
21527
21927
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
21528
21928
|
*
|
|
21529
|
-
* const program = Effect.fail(new
|
|
21530
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
21929
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
21930
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
21531
21931
|
* )
|
|
21532
21932
|
*
|
|
21533
21933
|
* Effect.runPromiseExit(program).then(() =>
|
|
21534
21934
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
21535
|
-
* // Output: { occurrences: Map(1) { "
|
|
21935
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
21536
21936
|
* )
|
|
21537
21937
|
* ```
|
|
21538
21938
|
*
|
|
@@ -21567,18 +21967,20 @@ export const trackErrors: {
|
|
|
21567
21967
|
*
|
|
21568
21968
|
* @example
|
|
21569
21969
|
* ```ts
|
|
21570
|
-
* import { Effect, Metric } from "effect"
|
|
21970
|
+
* import { Data, Effect, Metric } from "effect"
|
|
21971
|
+
*
|
|
21972
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
21571
21973
|
*
|
|
21572
21974
|
* // Track error types using frequency metric
|
|
21573
21975
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
21574
21976
|
*
|
|
21575
|
-
* const program = Effect.fail(new
|
|
21576
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
21977
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
21978
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
21577
21979
|
* )
|
|
21578
21980
|
*
|
|
21579
21981
|
* Effect.runPromiseExit(program).then(() =>
|
|
21580
21982
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
21581
|
-
* // Output: { occurrences: Map(1) { "
|
|
21983
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
21582
21984
|
* )
|
|
21583
21985
|
* ```
|
|
21584
21986
|
*
|
|
@@ -21617,18 +22019,20 @@ export const trackErrors: {
|
|
|
21617
22019
|
*
|
|
21618
22020
|
* @example
|
|
21619
22021
|
* ```ts
|
|
21620
|
-
* import { Effect, Metric } from "effect"
|
|
22022
|
+
* import { Data, Effect, Metric } from "effect"
|
|
22023
|
+
*
|
|
22024
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
21621
22025
|
*
|
|
21622
22026
|
* // Track error types using frequency metric
|
|
21623
22027
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
21624
22028
|
*
|
|
21625
|
-
* const program = Effect.fail(new
|
|
21626
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
22029
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
22030
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
21627
22031
|
* )
|
|
21628
22032
|
*
|
|
21629
22033
|
* Effect.runPromiseExit(program).then(() =>
|
|
21630
22034
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
21631
|
-
* // Output: { occurrences: Map(1) { "
|
|
22035
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
21632
22036
|
* )
|
|
21633
22037
|
* ```
|
|
21634
22038
|
*
|
|
@@ -22151,8 +22555,8 @@ export const trackDuration: {
|
|
|
22151
22555
|
return onExit(self, () => {
|
|
22152
22556
|
const endTime = clock.currentTimeNanosUnsafe()
|
|
22153
22557
|
const duration = Duration.subtract(
|
|
22154
|
-
Duration.
|
|
22155
|
-
Duration.
|
|
22558
|
+
Duration.fromInputUnsafe(endTime),
|
|
22559
|
+
Duration.fromInputUnsafe(startTime)
|
|
22156
22560
|
)
|
|
22157
22561
|
const input = f === undefined ? duration : internalCall(() => f(duration))
|
|
22158
22562
|
return Metric.update(metric, input as any)
|
|
@@ -22200,136 +22604,70 @@ export class Transaction extends ServiceMap.Service<
|
|
|
22200
22604
|
>()("effect/Effect/Transaction") {}
|
|
22201
22605
|
|
|
22202
22606
|
/**
|
|
22203
|
-
*
|
|
22204
|
-
* transactional values (i.e. TxRef) that occur within the transaction body.
|
|
22205
|
-
*
|
|
22206
|
-
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
22607
|
+
* Accesses the current transaction state within an active transaction.
|
|
22207
22608
|
*
|
|
22208
|
-
*
|
|
22209
|
-
*
|
|
22210
|
-
*
|
|
22211
|
-
* - any of the accessed transactional values change during the execution of the transaction
|
|
22212
|
-
* due to a different transaction committing before the current.
|
|
22213
|
-
*
|
|
22214
|
-
* - parent transaction retry, if you have a transaction within another transaction and
|
|
22215
|
-
* the parent retries the child will also retry together with the parent.
|
|
22609
|
+
* This function requires `Transaction` in the context and does NOT create or strip
|
|
22610
|
+
* transaction boundaries. Use it to interact with the transaction journal (e.g. in
|
|
22611
|
+
* `TxRef` internals). To define a transaction boundary, use {@link transaction}.
|
|
22216
22612
|
*
|
|
22217
22613
|
* @example
|
|
22218
22614
|
* ```ts
|
|
22219
22615
|
* import { Effect, TxRef } from "effect"
|
|
22220
22616
|
*
|
|
22221
22617
|
* const program = Effect.gen(function*() {
|
|
22222
|
-
* const
|
|
22223
|
-
* const ref2 = yield* TxRef.make(0)
|
|
22224
|
-
*
|
|
22225
|
-
* // All operations within atomic block succeed or fail together
|
|
22226
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
22227
|
-
* yield* TxRef.set(ref1, 10)
|
|
22228
|
-
* yield* TxRef.set(ref2, 20)
|
|
22229
|
-
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
22230
|
-
* console.log(`Transaction sum: ${sum}`)
|
|
22231
|
-
* }))
|
|
22232
|
-
*
|
|
22233
|
-
* console.log(`Final ref1: ${yield* TxRef.get(ref1)}`) // 10
|
|
22234
|
-
* console.log(`Final ref2: ${yield* TxRef.get(ref2)}`) // 20
|
|
22235
|
-
* })
|
|
22236
|
-
* ```
|
|
22237
|
-
*
|
|
22238
|
-
* @since 4.0.0
|
|
22239
|
-
* @category Transactions
|
|
22240
|
-
*/
|
|
22241
|
-
export const atomic = <A, E, R>(
|
|
22242
|
-
effect: Effect<A, E, R>
|
|
22243
|
-
): Effect<A, E, Exclude<R, Transaction>> => atomicWith(() => effect)
|
|
22244
|
-
|
|
22245
|
-
/**
|
|
22246
|
-
* Executes a function within a transaction context, providing access to the transaction state.
|
|
22247
|
-
*
|
|
22248
|
-
* @example
|
|
22249
|
-
* ```ts
|
|
22250
|
-
* import { Effect, TxRef } from "effect"
|
|
22251
|
-
*
|
|
22252
|
-
* const program = Effect.atomicWith((txState) =>
|
|
22253
|
-
* Effect.gen(function*() {
|
|
22254
|
-
* const ref = yield* TxRef.make(0)
|
|
22255
|
-
*
|
|
22256
|
-
* // Access transaction state for debugging
|
|
22257
|
-
* console.log(`Journal size: ${txState.journal.size}`)
|
|
22258
|
-
* console.log(`Retry flag: ${txState.retry}`)
|
|
22618
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22259
22619
|
*
|
|
22620
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22260
22621
|
* yield* TxRef.set(ref, 42)
|
|
22261
22622
|
* return yield* TxRef.get(ref)
|
|
22262
|
-
* })
|
|
22263
|
-
* )
|
|
22264
|
-
*
|
|
22265
|
-
* Effect.runPromise(program).then(console.log) // 42
|
|
22623
|
+
* }))
|
|
22624
|
+
* })
|
|
22266
22625
|
* ```
|
|
22267
22626
|
*
|
|
22268
22627
|
* @since 4.0.0
|
|
22269
22628
|
* @category Transactions
|
|
22270
22629
|
*/
|
|
22271
|
-
export const
|
|
22630
|
+
export const withTxState = <A, E, R>(
|
|
22272
22631
|
f: (state: Transaction["Service"]) => Effect<A, E, R>
|
|
22273
|
-
): Effect<A, E,
|
|
22274
|
-
|
|
22275
|
-
|
|
22276
|
-
|
|
22277
|
-
|
|
22278
|
-
A,
|
|
22279
|
-
E,
|
|
22280
|
-
Exclude<R, Transaction>
|
|
22281
|
-
>
|
|
22282
|
-
}
|
|
22283
|
-
// No existing transaction, create isolated one using transactionWith
|
|
22284
|
-
return transactionWith(f)
|
|
22285
|
-
})
|
|
22632
|
+
): Effect<A, E, R | Transaction> =>
|
|
22633
|
+
flatMap(
|
|
22634
|
+
Transaction.asEffect(),
|
|
22635
|
+
(state) => internalCall(() => f(state))
|
|
22636
|
+
)
|
|
22286
22637
|
|
|
22287
22638
|
/**
|
|
22288
|
-
*
|
|
22639
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
22640
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
22289
22641
|
*
|
|
22290
|
-
*
|
|
22642
|
+
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
22291
22643
|
*
|
|
22292
|
-
*
|
|
22293
|
-
*
|
|
22294
|
-
* This ensures complete isolation between different transaction scopes.
|
|
22644
|
+
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
22645
|
+
* accessed transactional values changes.
|
|
22295
22646
|
*
|
|
22296
|
-
*
|
|
22297
|
-
*
|
|
22298
|
-
* - Parent transaction failures don't affect isolated transactions
|
|
22299
|
-
* - Isolated transaction failures don't affect parent transactions
|
|
22300
|
-
* - Each transaction has its own journal and retry logic
|
|
22647
|
+
* - any of the accessed transactional values change during the execution of the transaction
|
|
22648
|
+
* due to a different transaction committing before the current.
|
|
22301
22649
|
*
|
|
22302
|
-
*
|
|
22303
|
-
*
|
|
22304
|
-
* - For implementing independent operations that shouldn't be affected by outer transactions
|
|
22305
|
-
* - When building transaction-based systems where isolation is critical
|
|
22650
|
+
* Each call to `transaction` always creates a new isolated transaction boundary with its own
|
|
22651
|
+
* journal and retry logic.
|
|
22306
22652
|
*
|
|
22307
22653
|
* @example
|
|
22308
22654
|
* ```ts
|
|
22309
22655
|
* import { Effect, TxRef } from "effect"
|
|
22310
22656
|
*
|
|
22311
22657
|
* const program = Effect.gen(function*() {
|
|
22312
|
-
* const ref1 = yield* TxRef.make(0)
|
|
22313
|
-
* const ref2 = yield* TxRef.make(
|
|
22314
|
-
*
|
|
22315
|
-
* // Nested atomic transaction - ref1 will be part of outer transaction
|
|
22316
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
22317
|
-
* yield* TxRef.set(ref1, 10)
|
|
22658
|
+
* const ref1 = yield* Effect.transaction(TxRef.make(0))
|
|
22659
|
+
* const ref2 = yield* Effect.transaction(TxRef.make(0))
|
|
22318
22660
|
*
|
|
22319
|
-
*
|
|
22320
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
22321
|
-
* yield* TxRef.set(ref1, 20) // Part of same transaction
|
|
22322
|
-
* }))
|
|
22323
|
-
* }))
|
|
22324
|
-
*
|
|
22325
|
-
* // Isolated transaction - ref2 will be in its own transaction
|
|
22661
|
+
* // All operations within transaction block succeed or fail together
|
|
22326
22662
|
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22327
|
-
* yield* TxRef.set(
|
|
22663
|
+
* yield* TxRef.set(ref1, 10)
|
|
22664
|
+
* yield* TxRef.set(ref2, 20)
|
|
22665
|
+
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
22666
|
+
* console.log(`Transaction sum: ${sum}`)
|
|
22328
22667
|
* }))
|
|
22329
22668
|
*
|
|
22330
|
-
*
|
|
22331
|
-
*
|
|
22332
|
-
* return { ref1: val1, ref2: val2 }
|
|
22669
|
+
* console.log(`Final ref1: ${yield* Effect.transaction(TxRef.get(ref1))}`) // 10
|
|
22670
|
+
* console.log(`Final ref2: ${yield* Effect.transaction(TxRef.get(ref2))}`) // 20
|
|
22333
22671
|
* })
|
|
22334
22672
|
* ```
|
|
22335
22673
|
*
|
|
@@ -22341,34 +22679,21 @@ export const transaction = <A, E, R>(
|
|
|
22341
22679
|
): Effect<A, E, Exclude<R, Transaction>> => transactionWith(() => effect)
|
|
22342
22680
|
|
|
22343
22681
|
/**
|
|
22344
|
-
*
|
|
22682
|
+
* Like {@link transaction} but provides access to the transaction state.
|
|
22345
22683
|
*
|
|
22346
|
-
*
|
|
22347
|
-
* within another transaction. This ensures complete isolation between transaction scopes.
|
|
22684
|
+
* Always creates a new isolated transaction boundary with its own journal and retry logic.
|
|
22348
22685
|
*
|
|
22349
22686
|
* @example
|
|
22350
22687
|
* ```ts
|
|
22351
22688
|
* import { Effect, TxRef } from "effect"
|
|
22352
22689
|
*
|
|
22353
|
-
* const program = Effect.transactionWith((
|
|
22690
|
+
* const program = Effect.transactionWith((_txState) =>
|
|
22354
22691
|
* Effect.gen(function*() {
|
|
22355
22692
|
* const ref = yield* TxRef.make(0)
|
|
22356
|
-
*
|
|
22357
|
-
* // This transaction is isolated - it has its own journal
|
|
22358
|
-
* // txState.journal is independent of any parent transaction
|
|
22359
|
-
*
|
|
22360
22693
|
* yield* TxRef.set(ref, 42)
|
|
22361
22694
|
* return yield* TxRef.get(ref)
|
|
22362
22695
|
* })
|
|
22363
22696
|
* )
|
|
22364
|
-
*
|
|
22365
|
-
* // Even when nested in another atomic block, this transaction is isolated
|
|
22366
|
-
* const nestedProgram = Effect.atomic(
|
|
22367
|
-
* Effect.gen(function*() {
|
|
22368
|
-
* const result = yield* program // Runs in its own isolated transaction
|
|
22369
|
-
* return result
|
|
22370
|
-
* })
|
|
22371
|
-
* )
|
|
22372
22697
|
* ```
|
|
22373
22698
|
*
|
|
22374
22699
|
* @since 4.0.0
|
|
@@ -22380,7 +22705,6 @@ export const transactionWith = <A, E, R>(
|
|
|
22380
22705
|
withFiber((fiber) => {
|
|
22381
22706
|
// Always create a new transaction state, never compose with parent
|
|
22382
22707
|
const state: Transaction["Service"] = { journal: new Map(), retry: false }
|
|
22383
|
-
const scheduler = fiber.currentScheduler
|
|
22384
22708
|
let result: Exit.Exit<A, E> | undefined
|
|
22385
22709
|
return uninterruptibleMask((restore) =>
|
|
22386
22710
|
flatMap(
|
|
@@ -22401,7 +22725,7 @@ export const transactionWith = <A, E, R>(
|
|
|
22401
22725
|
return clearTransaction(state)
|
|
22402
22726
|
}
|
|
22403
22727
|
if (Exit.isSuccess(exit)) {
|
|
22404
|
-
commitTransaction(
|
|
22728
|
+
commitTransaction(fiber, state)
|
|
22405
22729
|
} else {
|
|
22406
22730
|
clearTransaction(state)
|
|
22407
22731
|
}
|
|
@@ -22443,14 +22767,14 @@ const awaitPendingTransaction = (state: Transaction["Service"]) =>
|
|
|
22443
22767
|
})
|
|
22444
22768
|
})
|
|
22445
22769
|
|
|
22446
|
-
function commitTransaction(
|
|
22770
|
+
function commitTransaction(fiber: Fiber<unknown, unknown>, state: Transaction["Service"]) {
|
|
22447
22771
|
for (const [ref, { value }] of state.journal) {
|
|
22448
22772
|
if (value !== ref.value) {
|
|
22449
22773
|
ref.version = ref.version + 1
|
|
22450
22774
|
ref.value = value
|
|
22451
22775
|
}
|
|
22452
22776
|
for (const pending of ref.pending.values()) {
|
|
22453
|
-
|
|
22777
|
+
fiber.currentDispatcher.scheduleTask(pending, 0)
|
|
22454
22778
|
}
|
|
22455
22779
|
ref.pending.clear()
|
|
22456
22780
|
}
|
|
@@ -22476,16 +22800,16 @@ function clearTransaction(state: Transaction["Service"]) {
|
|
|
22476
22800
|
*
|
|
22477
22801
|
* const program = Effect.gen(function*() {
|
|
22478
22802
|
* // create a transactional reference
|
|
22479
|
-
* const ref = yield* TxRef.make(0)
|
|
22803
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22480
22804
|
*
|
|
22481
22805
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
22482
22806
|
* yield* Effect.forkChild(Effect.forever(
|
|
22483
22807
|
* // update to transactional value
|
|
22484
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
22808
|
+
* Effect.transaction(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
22485
22809
|
* ))
|
|
22486
22810
|
*
|
|
22487
22811
|
* // the following will retry 10 times until the `ref` value is 10
|
|
22488
|
-
* yield* Effect.
|
|
22812
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22489
22813
|
* const value = yield* TxRef.get(ref)
|
|
22490
22814
|
* if (value < 10) {
|
|
22491
22815
|
* yield* Effect.log(`retry due to value: ${value}`)
|
|
@@ -22997,18 +23321,20 @@ export const satisfiesSuccessType = <A>() => <A2 extends A, E, R>(effect: Effect
|
|
|
22997
23321
|
*
|
|
22998
23322
|
* @example
|
|
22999
23323
|
* ```ts
|
|
23000
|
-
* import { Effect } from "effect"
|
|
23324
|
+
* import { Data, Effect } from "effect"
|
|
23325
|
+
*
|
|
23326
|
+
* class ValidationError extends Data.TaggedError("ValidationError")<{}> {}
|
|
23001
23327
|
*
|
|
23002
|
-
* // Define a constraint that the error type must be
|
|
23003
|
-
* const satisfiesError = Effect.satisfiesErrorType<
|
|
23328
|
+
* // Define a constraint that the error type must be a ValidationError
|
|
23329
|
+
* const satisfiesError = Effect.satisfiesErrorType<ValidationError>()
|
|
23004
23330
|
*
|
|
23005
|
-
* // This works - Effect<number,
|
|
23006
|
-
* const validEffect = satisfiesError(Effect.fail(new
|
|
23331
|
+
* // This works - Effect<number, ValidationError, never> extends the constrained type
|
|
23332
|
+
* const validEffect = satisfiesError(Effect.fail(new ValidationError()))
|
|
23007
23333
|
*
|
|
23008
23334
|
* // This would cause a TypeScript compilation error:
|
|
23009
23335
|
* // const invalidEffect = satisfiesError(Effect.fail("string error"))
|
|
23010
23336
|
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
23011
|
-
* // Type 'string' is not assignable to type '
|
|
23337
|
+
* // Type 'string' is not assignable to type 'ValidationError'
|
|
23012
23338
|
* ```
|
|
23013
23339
|
*
|
|
23014
23340
|
* @since 4.0.0
|