effect 3.10.18 → 3.11.0
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/cjs/Array.js +206 -0
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/BigDecimal.js +181 -24
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/BigInt.js +54 -0
- package/dist/cjs/BigInt.js.map +1 -1
- package/dist/cjs/Boolean.js +24 -0
- package/dist/cjs/Boolean.js.map +1 -1
- package/dist/cjs/Brand.js +4 -0
- package/dist/cjs/Brand.js.map +1 -1
- package/dist/cjs/Channel.js +44 -4
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Chunk.js +8 -0
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Config.js +10 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +50 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/Cron.js +81 -67
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/Data.js +14 -0
- package/dist/cjs/Data.js.map +1 -1
- package/dist/cjs/DateTime.js +178 -664
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Duration.js +2 -0
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js +296 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +38 -2
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/FiberHandle.js +6 -0
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +6 -0
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +6 -0
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/Function.js +34 -0
- package/dist/cjs/Function.js.map +1 -1
- package/dist/cjs/GlobalValue.js +2 -0
- package/dist/cjs/GlobalValue.js.map +1 -1
- package/dist/cjs/HashMap.js.map +1 -1
- package/dist/cjs/Inspectable.js +8 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/Iterable.js +18 -0
- package/dist/cjs/Iterable.js.map +1 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/List.js +4 -0
- package/dist/cjs/List.js.map +1 -1
- package/dist/cjs/Logger.js +26 -0
- package/dist/cjs/Logger.js.map +1 -1
- package/dist/cjs/Mailbox.js +2 -0
- package/dist/cjs/Mailbox.js.map +1 -1
- package/dist/cjs/ManagedRuntime.js +2 -0
- package/dist/cjs/ManagedRuntime.js.map +1 -1
- package/dist/cjs/Metric.js +10 -0
- package/dist/cjs/Metric.js.map +1 -1
- package/dist/cjs/Micro.js +1104 -1069
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/Number.js +44 -0
- package/dist/cjs/Number.js.map +1 -1
- package/dist/cjs/Option.js +70 -0
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/Order.js +2 -0
- package/dist/cjs/Order.js.map +1 -1
- package/dist/cjs/Ordering.js +4 -0
- package/dist/cjs/Ordering.js.map +1 -1
- package/dist/cjs/Predicate.js +68 -0
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Random.js +4 -0
- package/dist/cjs/Random.js.map +1 -1
- package/dist/cjs/RateLimiter.js +4 -0
- package/dist/cjs/RateLimiter.js.map +1 -1
- package/dist/cjs/RcMap.js +2 -0
- package/dist/cjs/RcMap.js.map +1 -1
- package/dist/cjs/RcRef.js +2 -0
- package/dist/cjs/RcRef.js.map +1 -1
- package/dist/cjs/Record.js +56 -0
- package/dist/cjs/Record.js.map +1 -1
- package/dist/cjs/Redacted.js +8 -0
- package/dist/cjs/Redacted.js.map +1 -1
- package/dist/cjs/RegExp.js +4 -0
- package/dist/cjs/RegExp.js.map +1 -1
- package/dist/cjs/Request.js +4 -0
- package/dist/cjs/Request.js.map +1 -1
- package/dist/cjs/RequestResolver.js +2 -0
- package/dist/cjs/RequestResolver.js.map +1 -1
- package/dist/cjs/Runtime.js +6 -0
- package/dist/cjs/Runtime.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schema.js +91 -8
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Sink.js +9 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +179 -7
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/String.js +62 -0
- package/dist/cjs/String.js.map +1 -1
- package/dist/cjs/Struct.js +12 -0
- package/dist/cjs/Struct.js.map +1 -1
- package/dist/cjs/Symbol.js +2 -0
- package/dist/cjs/Symbol.js.map +1 -1
- package/dist/cjs/Trie.js +56 -0
- package/dist/cjs/Trie.js.map +1 -1
- package/dist/cjs/Tuple.js +18 -0
- package/dist/cjs/Tuple.js.map +1 -1
- package/dist/cjs/Utils.js +7 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/channel/channelExecutor.js +5 -9
- package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
- package/dist/cjs/internal/channel.js +156 -130
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/config.js +13 -4
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/context.js +46 -3
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +747 -0
- package/dist/cjs/internal/dateTime.js.map +1 -0
- package/dist/cjs/internal/fiberRuntime.js +34 -11
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +9 -3
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/mailbox.js +1 -1
- package/dist/cjs/internal/mailbox.js.map +1 -1
- package/dist/cjs/internal/sink.js +25 -21
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stream.js +70 -71
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/Array.d.ts +534 -0
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/BigDecimal.d.ts +172 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/BigInt.d.ts +114 -0
- package/dist/dts/BigInt.d.ts.map +1 -1
- package/dist/dts/Boolean.d.ts +56 -0
- package/dist/dts/Boolean.d.ts.map +1 -1
- package/dist/dts/Brand.d.ts +6 -0
- package/dist/dts/Brand.d.ts.map +1 -1
- package/dist/dts/Channel.d.ts +66 -5
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts +30 -0
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +25 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +155 -0
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +21 -6
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/Data.d.ts +26 -0
- package/dist/dts/Data.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +192 -49
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +2 -0
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +658 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +84 -2
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts +6 -0
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts +6 -0
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts +6 -0
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Function.d.ts +50 -0
- package/dist/dts/Function.d.ts.map +1 -1
- package/dist/dts/GlobalValue.d.ts +2 -0
- package/dist/dts/GlobalValue.d.ts.map +1 -1
- package/dist/dts/HashMap.d.ts +6 -0
- package/dist/dts/HashMap.d.ts.map +1 -1
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/Iterable.d.ts +26 -0
- package/dist/dts/Iterable.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +1 -0
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/List.d.ts +20 -0
- package/dist/dts/List.d.ts.map +1 -1
- package/dist/dts/Logger.d.ts +34 -0
- package/dist/dts/Logger.d.ts.map +1 -1
- package/dist/dts/Mailbox.d.ts +2 -0
- package/dist/dts/Mailbox.d.ts.map +1 -1
- package/dist/dts/ManagedRuntime.d.ts +2 -0
- package/dist/dts/ManagedRuntime.d.ts.map +1 -1
- package/dist/dts/Metric.d.ts +18 -0
- package/dist/dts/Metric.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +880 -863
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/Number.d.ts +104 -0
- package/dist/dts/Number.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +142 -0
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/Order.d.ts +2 -0
- package/dist/dts/Order.d.ts.map +1 -1
- package/dist/dts/Ordering.d.ts +8 -0
- package/dist/dts/Ordering.d.ts.map +1 -1
- package/dist/dts/Predicate.d.ts +104 -0
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Random.d.ts +4 -0
- package/dist/dts/Random.d.ts.map +1 -1
- package/dist/dts/RateLimiter.d.ts +4 -0
- package/dist/dts/RateLimiter.d.ts.map +1 -1
- package/dist/dts/RcMap.d.ts +6 -0
- package/dist/dts/RcMap.d.ts.map +1 -1
- package/dist/dts/RcRef.d.ts +2 -0
- package/dist/dts/RcRef.d.ts.map +1 -1
- package/dist/dts/Record.d.ts +136 -0
- package/dist/dts/Record.d.ts.map +1 -1
- package/dist/dts/Redacted.d.ts +8 -0
- package/dist/dts/Redacted.d.ts.map +1 -1
- package/dist/dts/RegExp.d.ts +4 -0
- package/dist/dts/RegExp.d.ts.map +1 -1
- package/dist/dts/Request.d.ts +4 -0
- package/dist/dts/Request.d.ts.map +1 -1
- package/dist/dts/RequestResolver.d.ts +6 -0
- package/dist/dts/RequestResolver.d.ts.map +1 -1
- package/dist/dts/Runtime.d.ts +18 -0
- package/dist/dts/Runtime.d.ts.map +1 -1
- package/dist/dts/STM.d.ts +2 -0
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +90 -0
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +8 -0
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +394 -32
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/String.d.ts +94 -0
- package/dist/dts/String.d.ts.map +1 -1
- package/dist/dts/Struct.d.ts +24 -0
- package/dist/dts/Struct.d.ts.map +1 -1
- package/dist/dts/Symbol.d.ts +2 -0
- package/dist/dts/Symbol.d.ts.map +1 -1
- package/dist/dts/Trie.d.ts +132 -0
- package/dist/dts/Trie.d.ts.map +1 -1
- package/dist/dts/Tuple.d.ts +42 -0
- package/dist/dts/Tuple.d.ts.map +1 -1
- package/dist/dts/Types.d.ts +24 -0
- package/dist/dts/Types.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +4 -0
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/internal/context.d.ts +1 -1
- package/dist/dts/internal/context.d.ts.map +1 -1
- package/dist/dts/internal/dateTime.d.ts +2 -0
- package/dist/dts/internal/dateTime.d.ts.map +1 -0
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Array.js +208 -0
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/BigDecimal.js +175 -20
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/BigInt.js +54 -0
- package/dist/esm/BigInt.js.map +1 -1
- package/dist/esm/Boolean.js +24 -0
- package/dist/esm/Boolean.js.map +1 -1
- package/dist/esm/Brand.js +4 -0
- package/dist/esm/Brand.js.map +1 -1
- package/dist/esm/Channel.js +42 -2
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Chunk.js +8 -0
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Config.js +9 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +49 -0
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/Cron.js +81 -67
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/Data.js +16 -0
- package/dist/esm/Data.js.map +1 -1
- package/dist/esm/DateTime.js +176 -627
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Duration.js +2 -0
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js +297 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +40 -2
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/FiberHandle.js +6 -0
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +6 -0
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +6 -0
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/Function.js +34 -0
- package/dist/esm/Function.js.map +1 -1
- package/dist/esm/GlobalValue.js +2 -0
- package/dist/esm/GlobalValue.js.map +1 -1
- package/dist/esm/HashMap.js.map +1 -1
- package/dist/esm/Inspectable.js +8 -4
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/Iterable.js +18 -0
- package/dist/esm/Iterable.js.map +1 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/List.js +4 -0
- package/dist/esm/List.js.map +1 -1
- package/dist/esm/Logger.js +26 -0
- package/dist/esm/Logger.js.map +1 -1
- package/dist/esm/Mailbox.js +2 -0
- package/dist/esm/Mailbox.js.map +1 -1
- package/dist/esm/ManagedRuntime.js +2 -0
- package/dist/esm/ManagedRuntime.js.map +1 -1
- package/dist/esm/Metric.js +10 -0
- package/dist/esm/Metric.js.map +1 -1
- package/dist/esm/Micro.js +1077 -1037
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/Number.js +44 -0
- package/dist/esm/Number.js.map +1 -1
- package/dist/esm/Option.js +72 -0
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/Order.js +2 -0
- package/dist/esm/Order.js.map +1 -1
- package/dist/esm/Ordering.js +4 -0
- package/dist/esm/Ordering.js.map +1 -1
- package/dist/esm/Predicate.js +68 -0
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Random.js +4 -0
- package/dist/esm/Random.js.map +1 -1
- package/dist/esm/RateLimiter.js +4 -0
- package/dist/esm/RateLimiter.js.map +1 -1
- package/dist/esm/RcMap.js +2 -0
- package/dist/esm/RcMap.js.map +1 -1
- package/dist/esm/RcRef.js +2 -0
- package/dist/esm/RcRef.js.map +1 -1
- package/dist/esm/Record.js +56 -0
- package/dist/esm/Record.js.map +1 -1
- package/dist/esm/Redacted.js +8 -0
- package/dist/esm/Redacted.js.map +1 -1
- package/dist/esm/RegExp.js +4 -0
- package/dist/esm/RegExp.js.map +1 -1
- package/dist/esm/Request.js +4 -0
- package/dist/esm/Request.js.map +1 -1
- package/dist/esm/RequestResolver.js +2 -0
- package/dist/esm/RequestResolver.js.map +1 -1
- package/dist/esm/Runtime.js +6 -0
- package/dist/esm/Runtime.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schema.js +88 -0
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Sink.js +8 -0
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Stream.js +183 -5
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/String.js +62 -0
- package/dist/esm/String.js.map +1 -1
- package/dist/esm/Struct.js +12 -0
- package/dist/esm/Struct.js.map +1 -1
- package/dist/esm/Symbol.js +2 -0
- package/dist/esm/Symbol.js.map +1 -1
- package/dist/esm/Trie.js +56 -0
- package/dist/esm/Trie.js.map +1 -1
- package/dist/esm/Tuple.js +22 -0
- package/dist/esm/Tuple.js.map +1 -1
- package/dist/esm/Utils.js +5 -0
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/channel/channelExecutor.js +5 -7
- package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
- package/dist/esm/internal/channel.js +152 -129
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/config.js +11 -3
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/context.js +42 -2
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/dateTime.js +704 -0
- package/dist/esm/internal/dateTime.js.map +1 -0
- package/dist/esm/internal/fiberRuntime.js +31 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +9 -3
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/layer.js +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/mailbox.js +1 -1
- package/dist/esm/internal/mailbox.js.map +1 -1
- package/dist/esm/internal/sink.js +23 -20
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stream.js +66 -69
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +534 -0
- package/src/BigDecimal.ts +247 -21
- package/src/BigInt.ts +114 -0
- package/src/Boolean.ts +56 -0
- package/src/Brand.ts +6 -0
- package/src/Channel.ts +81 -5
- package/src/Chunk.ts +32 -0
- package/src/Config.ts +26 -1
- package/src/Context.ts +163 -0
- package/src/Cron.ts +91 -68
- package/src/Data.ts +26 -0
- package/src/DateTime.ts +307 -757
- package/src/Duration.ts +2 -0
- package/src/Effect.ts +910 -1
- package/src/Either.ts +84 -2
- package/src/FiberHandle.ts +6 -0
- package/src/FiberMap.ts +6 -0
- package/src/FiberSet.ts +6 -0
- package/src/Function.ts +50 -0
- package/src/GlobalValue.ts +2 -0
- package/src/HashMap.ts +6 -0
- package/src/Inspectable.ts +11 -7
- package/src/Iterable.ts +26 -0
- package/src/JSONSchema.ts +1 -0
- package/src/List.ts +24 -0
- package/src/Logger.ts +34 -0
- package/src/Mailbox.ts +2 -0
- package/src/ManagedRuntime.ts +2 -0
- package/src/Metric.ts +18 -0
- package/src/Micro.ts +2007 -1745
- package/src/Number.ts +104 -0
- package/src/Option.ts +142 -0
- package/src/Order.ts +2 -0
- package/src/Ordering.ts +8 -0
- package/src/Predicate.ts +104 -0
- package/src/Random.ts +4 -0
- package/src/RateLimiter.ts +4 -0
- package/src/RcMap.ts +6 -0
- package/src/RcRef.ts +2 -0
- package/src/Record.ts +136 -0
- package/src/Redacted.ts +8 -0
- package/src/RegExp.ts +4 -0
- package/src/Request.ts +4 -0
- package/src/RequestResolver.ts +6 -0
- package/src/Runtime.ts +18 -0
- package/src/STM.ts +2 -0
- package/src/Schema.ts +124 -0
- package/src/Sink.ts +11 -0
- package/src/Stream.ts +399 -44
- package/src/String.ts +94 -0
- package/src/Struct.ts +24 -0
- package/src/Symbol.ts +2 -0
- package/src/Trie.ts +132 -0
- package/src/Tuple.ts +42 -0
- package/src/Types.ts +24 -0
- package/src/Utils.ts +8 -0
- package/src/internal/channel/channelExecutor.ts +37 -33
- package/src/internal/channel.ts +504 -467
- package/src/internal/config.ts +18 -6
- package/src/internal/context.ts +56 -4
- package/src/internal/dateTime.ts +1126 -0
- package/src/internal/fiberRuntime.ts +35 -16
- package/src/internal/groupBy.ts +13 -22
- package/src/internal/layer.ts +5 -8
- package/src/internal/mailbox.ts +6 -4
- package/src/internal/sink.ts +55 -35
- package/src/internal/stream.ts +299 -299
- package/src/internal/version.ts +1 -1
package/dist/cjs/Effect.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withTracerTiming = exports.withTracerScoped = exports.withTracerEnabled = exports.withTracer = exports.withSpanScoped = exports.withSpan = exports.withSchedulingPriority = exports.withScheduler = exports.withRuntimeFlagsPatchScoped = void 0;
|
|
6
|
+
exports.forkAll = exports.fork = exports.forever = exports.forEach = exports.fn = exports.flipWith = exports.flip = exports.flatten = exports.flatMap = exports.firstSuccessOf = exports.findFirst = exports.finalizersMask = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filterMap = exports.filter = exports.fiberIdWith = exports.fiberId = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.exit = exports.exists = exports.every = exports.eventually = exports.ensuringChildren = exports.ensuringChild = exports.ensuring = exports.either = exports.dropWhile = exports.dropUntil = exports.disconnect = exports.diffFiberRefs = exports.dieSync = exports.dieMessage = exports.die = exports.descriptorWith = exports.descriptor = exports.delay = exports.daemonChildren = exports.custom = exports.currentSpan = exports.currentParentSpan = exports.contextWithEffect = exports.contextWith = exports.context = exports.consoleWith = exports.console = exports.configProviderWith = exports.clockWith = exports.clock = exports.checkInterruptible = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchSome = exports.catchIf = exports.catchAllDefect = exports.catchAllCause = exports.catchAll = exports.catch = exports.cachedWithTTL = exports.cachedInvalidateWithTTL = exports.cachedFunction = exports.cached = exports.cacheRequestResult = exports.blocked = exports.bindTo = exports.bindAll = exports.bind = exports.awaitAllChildren = exports.asyncEffect = exports.async = exports.asVoid = exports.asSomeError = exports.asSome = exports.as = exports.ap = exports.annotateSpans = exports.annotateLogsScoped = exports.annotateLogs = exports.annotateCurrentSpan = exports.andThen = exports.allowInterrupt = exports.allWith = exports.allSuccesses = exports.all = exports.addFinalizer = exports.acquireUseRelease = exports.acquireReleaseInterruptible = exports.acquireRelease = exports.Tag = exports.Service = exports.EffectTypeId = exports.Do = void 0;
|
|
7
|
+
exports.request = exports.replicateEffect = exports.replicate = exports.repeatOrElse = exports.repeatN = exports.repeat = exports.reduceWhile = exports.reduceRight = exports.reduceEffect = exports.reduce = exports.randomWith = exports.random = exports.raceWith = exports.raceFirst = exports.raceAll = exports.race = exports.provideServiceEffect = exports.provideService = exports.provide = exports.promise = exports.patchRuntimeFlags = exports.patchFiberRefs = exports.partition = exports.parallelFinalizers = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.orElse = exports.orDieWith = exports.orDie = exports.optionFromOptional = exports.option = exports.once = exports.onInterrupt = exports.onExit = exports.onError = exports.none = exports.never = exports.negate = exports.metricLabels = exports.mergeAll = exports.merge = exports.matchEffect = exports.matchCauseEffect = exports.matchCause = exports.match = exports.mapInputContext = exports.mapErrorCause = exports.mapError = exports.mapBoth = exports.mapAccum = exports.map = exports.makeSpanScoped = exports.makeSpan = exports.makeSemaphore = exports.makeLatch = exports.loop = exports.logWithLevel = exports.logWarning = exports.logTrace = exports.logInfo = exports.logFatal = exports.logError = exports.logDebug = exports.logAnnotations = exports.log = exports.locallyWith = exports.locallyScopedWith = exports.locallyScoped = exports.locally = exports.linkSpans = exports.liftPredicate = exports.let = exports.labelMetricsScoped = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.isEffect = exports.intoDeferred = exports.interruptibleMask = exports.interruptible = exports.interruptWith = exports.interrupt = exports.inheritFiberRefs = exports.ignoreLogged = exports.ignore = exports.if = exports.head = exports.getRuntimeFlags = exports.getFiberRefs = exports.gen = exports.functionWithSpan = exports.fromNullable = exports.fromFiberEffect = exports.fromFiber = exports.forkWithErrorHandler = exports.forkScoped = exports.forkIn = exports.forkDaemon = void 0;
|
|
8
|
+
exports.withRequestCache = exports.withRequestBatching = exports.withRandomScoped = exports.withRandom = exports.withParentSpan = exports.withMetric = exports.withMaxOpsBeforeYield = exports.withLogSpan = exports.withFiberRuntime = exports.withEarlyRelease = exports.withConsoleScoped = exports.withConsole = exports.withConfigProviderScoped = exports.withConfigProvider = exports.withConcurrency = exports.withClockScoped = exports.withClock = exports.whileLoop = exports.whenRef = exports.whenFiberRef = exports.whenEffect = exports.when = exports.void = exports.validateWith = exports.validateFirst = exports.validateAll = exports.validate = exports.using = exports.useSpan = exports.updateService = exports.updateFiberRefs = exports.unsandbox = exports.unsafeMakeSemaphore = exports.unsafeMakeLatch = exports.unlessEffect = exports.unless = exports.uninterruptibleMask = exports.uninterruptible = exports.tryPromise = exports.tryMapPromise = exports.tryMap = exports.try = exports.transplant = exports.tracerWith = exports.tracer = exports.timeoutTo = exports.timeoutOption = exports.timeoutFailCause = exports.timeoutFail = exports.timeout = exports.timedWith = exports.timed = exports.tapErrorTag = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.tap = exports.takeWhile = exports.takeUntil = exports.tagMetricsScoped = exports.tagMetrics = exports.sync = exports.suspend = exports.supervised = exports.summarized = exports.succeedSome = exports.succeedNone = exports.succeed = exports.step = exports.spanLinks = exports.spanAnnotations = exports.sleep = exports.setFiberRefs = exports.serviceOptional = exports.serviceOption = exports.serviceMembers = exports.serviceFunctions = exports.serviceFunctionEffect = exports.serviceFunction = exports.serviceConstants = exports.sequentialFinalizers = exports.scopedWith = exports.scoped = exports.scopeWith = exports.scope = exports.scheduleFrom = exports.scheduleForked = exports.schedule = exports.sandbox = exports.runtime = exports.runSyncExit = exports.runSync = exports.runRequestBlock = exports.runPromiseExit = exports.runPromise = exports.runFork = exports.runCallback = exports.retryOrElse = exports.retry = void 0;
|
|
9
|
+
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withTracerTiming = exports.withTracerScoped = exports.withTracerEnabled = exports.withTracer = exports.withSpanScoped = exports.withSpan = exports.withSchedulingPriority = exports.withScheduler = exports.withRuntimeFlagsPatchScoped = exports.withRuntimeFlagsPatch = exports.withRequestCaching = void 0;
|
|
10
10
|
var _Function = require("./Function.js");
|
|
11
|
+
var internalCause = _interopRequireWildcard(require("./internal/cause.js"));
|
|
11
12
|
var _console = _interopRequireWildcard(require("./internal/console.js"));
|
|
12
13
|
var _context = require("./internal/context.js");
|
|
13
14
|
var effect = _interopRequireWildcard(require("./internal/core-effect.js"));
|
|
@@ -21,6 +22,7 @@ var _runtime = _interopRequireWildcard(require("./internal/runtime.js"));
|
|
|
21
22
|
var _schedule = _interopRequireWildcard(require("./internal/schedule.js"));
|
|
22
23
|
var Request = _interopRequireWildcard(require("./Request.js"));
|
|
23
24
|
var Scheduler = _interopRequireWildcard(require("./Scheduler.js"));
|
|
25
|
+
var _Utils = require("./Utils.js");
|
|
24
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
28
|
/**
|
|
@@ -47,6 +49,7 @@ const isEffect = exports.isEffect = core.isEffect;
|
|
|
47
49
|
* be recomputed upon next evaluation.
|
|
48
50
|
*
|
|
49
51
|
* @example
|
|
52
|
+
* ```ts
|
|
50
53
|
* import { Effect, Console } from "effect"
|
|
51
54
|
*
|
|
52
55
|
* let i = 1
|
|
@@ -74,6 +77,7 @@ const isEffect = exports.isEffect = core.isEffect;
|
|
|
74
77
|
* // result 1
|
|
75
78
|
* // expensive task...
|
|
76
79
|
* // result 2
|
|
80
|
+
* ```
|
|
77
81
|
*
|
|
78
82
|
* @since 2.0.0
|
|
79
83
|
* @category Caching
|
|
@@ -85,6 +89,7 @@ const cachedWithTTL = exports.cachedWithTTL = circular.cached;
|
|
|
85
89
|
* invalidating the cached value before it naturally expires.
|
|
86
90
|
*
|
|
87
91
|
* @example
|
|
92
|
+
* ```ts
|
|
88
93
|
* import { Effect, Console } from "effect"
|
|
89
94
|
*
|
|
90
95
|
* let i = 1
|
|
@@ -115,6 +120,7 @@ const cachedWithTTL = exports.cachedWithTTL = circular.cached;
|
|
|
115
120
|
* // result 1
|
|
116
121
|
* // expensive task...
|
|
117
122
|
* // result 2
|
|
123
|
+
* ```
|
|
118
124
|
*
|
|
119
125
|
* @since 2.0.0
|
|
120
126
|
* @category Caching
|
|
@@ -126,6 +132,7 @@ const cachedInvalidateWithTTL = exports.cachedInvalidateWithTTL = circular.cache
|
|
|
126
132
|
* the logic.
|
|
127
133
|
*
|
|
128
134
|
* @example
|
|
135
|
+
* ```ts
|
|
129
136
|
* import { Effect, Console } from "effect"
|
|
130
137
|
*
|
|
131
138
|
* let i = 1
|
|
@@ -159,6 +166,7 @@ const cachedInvalidateWithTTL = exports.cachedInvalidateWithTTL = circular.cache
|
|
|
159
166
|
* // expensive task...
|
|
160
167
|
* // result 3
|
|
161
168
|
* // result 3
|
|
169
|
+
* ```
|
|
162
170
|
*
|
|
163
171
|
* @since 2.0.0
|
|
164
172
|
* @category Caching
|
|
@@ -170,6 +178,7 @@ const cached = exports.cached = effect.memoize;
|
|
|
170
178
|
* recompute them.
|
|
171
179
|
*
|
|
172
180
|
* @example
|
|
181
|
+
* ```ts
|
|
173
182
|
* import { Effect, Random } from "effect"
|
|
174
183
|
*
|
|
175
184
|
* const program = Effect.gen(function* () {
|
|
@@ -192,6 +201,7 @@ const cached = exports.cached = effect.memoize;
|
|
|
192
201
|
* // memoized version:
|
|
193
202
|
* // 5
|
|
194
203
|
* // 5
|
|
204
|
+
* ```
|
|
195
205
|
*
|
|
196
206
|
* @since 2.0.0
|
|
197
207
|
* @category Caching
|
|
@@ -202,6 +212,7 @@ const cachedFunction = exports.cachedFunction = circular.cachedFunction;
|
|
|
202
212
|
* called.
|
|
203
213
|
*
|
|
204
214
|
* @example
|
|
215
|
+
* ```ts
|
|
205
216
|
* import { Effect, Console } from "effect"
|
|
206
217
|
*
|
|
207
218
|
* const program = Effect.gen(function* () {
|
|
@@ -217,6 +228,7 @@ const cachedFunction = exports.cachedFunction = circular.cachedFunction;
|
|
|
217
228
|
* // task1
|
|
218
229
|
* // task1
|
|
219
230
|
* // task2
|
|
231
|
+
* ```
|
|
220
232
|
*
|
|
221
233
|
* @since 2.0.0
|
|
222
234
|
* @category Caching
|
|
@@ -272,6 +284,7 @@ const once = exports.once = effect.once;
|
|
|
272
284
|
* @see {@link forEach} for iterating over elements and applying an effect.
|
|
273
285
|
*
|
|
274
286
|
* @example
|
|
287
|
+
* ```ts
|
|
275
288
|
* // Title: Combining Effects in Tuples
|
|
276
289
|
* import { Effect, Console } from "effect"
|
|
277
290
|
*
|
|
@@ -289,6 +302,7 @@ const once = exports.once = effect.once;
|
|
|
289
302
|
* // 42
|
|
290
303
|
* // Hello
|
|
291
304
|
* // [ 42, 'Hello' ]
|
|
305
|
+
* ```
|
|
292
306
|
*
|
|
293
307
|
* @example
|
|
294
308
|
* // Title: Combining Effects in Iterables
|
|
@@ -437,6 +451,7 @@ const all = exports.all = fiberRuntime.all;
|
|
|
437
451
|
* your data and then apply operations to it.
|
|
438
452
|
*
|
|
439
453
|
* @example
|
|
454
|
+
* ```ts
|
|
440
455
|
* import { Effect, pipe } from "effect"
|
|
441
456
|
*
|
|
442
457
|
* const task1 = Effect.succeed(1).pipe(
|
|
@@ -460,6 +475,7 @@ const all = exports.all = fiberRuntime.all;
|
|
|
460
475
|
* // timestamp=... level=INFO fiber=#3 message="task2 done"
|
|
461
476
|
* // timestamp=... level=INFO fiber=#2 message="task1 done"
|
|
462
477
|
* // [ 1, 'hello' ]
|
|
478
|
+
* ```
|
|
463
479
|
*
|
|
464
480
|
* @since 2.0.0
|
|
465
481
|
* @category Collecting
|
|
@@ -521,6 +537,7 @@ const filter = exports.filter = fiberRuntime.filter;
|
|
|
521
537
|
* @see {@link filter} for concurrent filtering without mapping.
|
|
522
538
|
*
|
|
523
539
|
* @example
|
|
540
|
+
* ```ts
|
|
524
541
|
* import { Console, Effect, Option } from "effect"
|
|
525
542
|
*
|
|
526
543
|
* const task = (n: number) =>
|
|
@@ -541,6 +558,7 @@ const filter = exports.filter = fiberRuntime.filter;
|
|
|
541
558
|
* // task3 done
|
|
542
559
|
* // task4 done
|
|
543
560
|
* // [ 2, 4 ]
|
|
561
|
+
* ```
|
|
544
562
|
*
|
|
545
563
|
* @since 2.0.0
|
|
546
564
|
* @category Filtering
|
|
@@ -577,6 +595,7 @@ const findFirst = exports.findFirst = effect.findFirst;
|
|
|
577
595
|
* @see {@link all} for combining multiple effects into one.
|
|
578
596
|
*
|
|
579
597
|
* @example
|
|
598
|
+
* ```ts
|
|
580
599
|
* // Title: Applying Effects to Iterable Elements
|
|
581
600
|
* import { Effect, Console } from "effect"
|
|
582
601
|
*
|
|
@@ -592,6 +611,7 @@ const findFirst = exports.findFirst = effect.findFirst;
|
|
|
592
611
|
* // Currently at index 3
|
|
593
612
|
* // Currently at index 4
|
|
594
613
|
* // [ 2, 4, 6, 8, 10 ]
|
|
614
|
+
* ```
|
|
595
615
|
*
|
|
596
616
|
* @example
|
|
597
617
|
* // Title: Using discard to Ignore Results
|
|
@@ -650,6 +670,7 @@ const mergeAll = exports.mergeAll = fiberRuntime.mergeAll;
|
|
|
650
670
|
* @see {@link validateFirst} for a function that stops at the first success.
|
|
651
671
|
*
|
|
652
672
|
* @example
|
|
673
|
+
* ```ts
|
|
653
674
|
* import { Effect } from "effect"
|
|
654
675
|
*
|
|
655
676
|
* // ┌─── Effect<[string[], number[]], never, never>
|
|
@@ -665,6 +686,7 @@ const mergeAll = exports.mergeAll = fiberRuntime.mergeAll;
|
|
|
665
686
|
* Effect.runPromise(program).then(console.log, console.error)
|
|
666
687
|
* // Output:
|
|
667
688
|
* // [ [ '1 is not even', '3 is not even' ], [ 0, 2, 4 ] ]
|
|
689
|
+
* ```
|
|
668
690
|
*
|
|
669
691
|
* @since 2.0.0
|
|
670
692
|
* @category Error Accumulation
|
|
@@ -745,6 +767,7 @@ const takeWhile = exports.takeWhile = effect.takeWhile;
|
|
|
745
767
|
* @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
|
|
746
768
|
*
|
|
747
769
|
* @example
|
|
770
|
+
* ```ts
|
|
748
771
|
* import { Effect, Console } from "effect"
|
|
749
772
|
*
|
|
750
773
|
* // ┌─── Effect<number[], string[], never>
|
|
@@ -771,6 +794,7 @@ const takeWhile = exports.takeWhile = effect.takeWhile;
|
|
|
771
794
|
* // failure: [ '4 is not less that 4', '5 is not less that 4' ]
|
|
772
795
|
* // }
|
|
773
796
|
* // }
|
|
797
|
+
* ```
|
|
774
798
|
*
|
|
775
799
|
* @since 2.0.0
|
|
776
800
|
* @category Error Accumulation
|
|
@@ -792,6 +816,7 @@ const validateAll = exports.validateAll = fiberRuntime.validateAll;
|
|
|
792
816
|
* @see {@link firstSuccessOf} for a similar function that processes multiple effects and returns the first successful one or the last error.
|
|
793
817
|
*
|
|
794
818
|
* @example
|
|
819
|
+
* ```ts
|
|
795
820
|
* import { Effect, Console } from "effect"
|
|
796
821
|
*
|
|
797
822
|
* // ┌─── Effect<number, string[], never>
|
|
@@ -808,6 +833,7 @@ const validateAll = exports.validateAll = fiberRuntime.validateAll;
|
|
|
808
833
|
* // Output:
|
|
809
834
|
* // item 4
|
|
810
835
|
* // 4
|
|
836
|
+
* ```
|
|
811
837
|
*
|
|
812
838
|
* @since 2.0.0
|
|
813
839
|
* @category Error Accumulation
|
|
@@ -838,6 +864,7 @@ const validateFirst = exports.validateFirst = fiberRuntime.validateFirst;
|
|
|
838
864
|
* behavior of the returned effect.
|
|
839
865
|
*
|
|
840
866
|
* @example
|
|
867
|
+
* ```ts
|
|
841
868
|
* // Title: Wrapping a Callback API
|
|
842
869
|
* import { Effect } from "effect"
|
|
843
870
|
* import * as NodeFS from "node:fs"
|
|
@@ -858,6 +885,7 @@ const validateFirst = exports.validateFirst = fiberRuntime.validateFirst;
|
|
|
858
885
|
* // ┌─── Effect<Buffer, Error, never>
|
|
859
886
|
* // ▼
|
|
860
887
|
* const program = readFile("example.txt")
|
|
888
|
+
* ```
|
|
861
889
|
*
|
|
862
890
|
* @example
|
|
863
891
|
* // Title: Handling Interruption with Cleanup
|
|
@@ -948,12 +976,14 @@ const asyncEffect = exports.asyncEffect = _runtime.asyncEffect;
|
|
|
948
976
|
* the "this" of the effect.
|
|
949
977
|
*
|
|
950
978
|
* @example
|
|
979
|
+
* ```ts
|
|
951
980
|
* import { Effect } from "effect"
|
|
952
981
|
*
|
|
953
982
|
* const throwingFunction = () => { throw new Error() }
|
|
954
983
|
* const blowUp = Effect.custom(throwingFunction, function() {
|
|
955
984
|
* return Effect.succeed(this.effect_instruction_i0())
|
|
956
985
|
* })
|
|
986
|
+
* ```
|
|
957
987
|
*
|
|
958
988
|
* @since 2.0.0
|
|
959
989
|
* @category Creating Effects
|
|
@@ -976,6 +1006,7 @@ const withFiberRuntime = exports.withFiberRuntime = core.withFiberRuntime;
|
|
|
976
1006
|
* @see {@link succeed} to create an effect that represents a successful value.
|
|
977
1007
|
*
|
|
978
1008
|
* @example
|
|
1009
|
+
* ```ts
|
|
979
1010
|
* // Title: Creating a Failed Effect
|
|
980
1011
|
* import { Effect } from "effect"
|
|
981
1012
|
*
|
|
@@ -984,6 +1015,7 @@ const withFiberRuntime = exports.withFiberRuntime = core.withFiberRuntime;
|
|
|
984
1015
|
* const failure = Effect.fail(
|
|
985
1016
|
* new Error("Operation failed due to network error")
|
|
986
1017
|
* )
|
|
1018
|
+
* ```
|
|
987
1019
|
*
|
|
988
1020
|
* @since 2.0.0
|
|
989
1021
|
* @category Creating Effects
|
|
@@ -1025,6 +1057,7 @@ const failCauseSync = exports.failCauseSync = core.failCauseSync;
|
|
|
1025
1057
|
* @see {@link dieMessage} for a variant that throws a `RuntimeException` with a message.
|
|
1026
1058
|
*
|
|
1027
1059
|
* @example
|
|
1060
|
+
* ```ts
|
|
1028
1061
|
* // Title: Terminating on Division by Zero with a Specified Error
|
|
1029
1062
|
* import { Effect } from "effect"
|
|
1030
1063
|
*
|
|
@@ -1041,6 +1074,7 @@ const failCauseSync = exports.failCauseSync = core.failCauseSync;
|
|
|
1041
1074
|
* // Output:
|
|
1042
1075
|
* // (FiberFailure) Error: Cannot divide by zero
|
|
1043
1076
|
* // ...stack trace...
|
|
1077
|
+
* ```
|
|
1044
1078
|
*
|
|
1045
1079
|
* @since 2.0.0
|
|
1046
1080
|
* @category Creating Effects
|
|
@@ -1069,6 +1103,7 @@ const die = exports.die = core.die;
|
|
|
1069
1103
|
* lazily.
|
|
1070
1104
|
*
|
|
1071
1105
|
* @example
|
|
1106
|
+
* ```ts
|
|
1072
1107
|
* // Title: Terminating on Division by Zero with a Specified Message
|
|
1073
1108
|
* import { Effect } from "effect"
|
|
1074
1109
|
*
|
|
@@ -1085,6 +1120,7 @@ const die = exports.die = core.die;
|
|
|
1085
1120
|
* // Output:
|
|
1086
1121
|
* // (FiberFailure) RuntimeException: Cannot divide by zero
|
|
1087
1122
|
* // ...stack trace...
|
|
1123
|
+
* ```
|
|
1088
1124
|
*
|
|
1089
1125
|
* @since 2.0.0
|
|
1090
1126
|
* @category Creating Effects
|
|
@@ -1118,6 +1154,7 @@ const dieSync = exports.dieSync = core.dieSync;
|
|
|
1118
1154
|
* effects and return the final result at the end.
|
|
1119
1155
|
*
|
|
1120
1156
|
* @example
|
|
1157
|
+
* ```ts
|
|
1121
1158
|
* import { Effect } from "effect"
|
|
1122
1159
|
*
|
|
1123
1160
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
@@ -1144,6 +1181,7 @@ const dieSync = exports.dieSync = core.dieSync;
|
|
|
1144
1181
|
* const finalAmount = addServiceCharge(discountedAmount)
|
|
1145
1182
|
* return `Final amount to charge: ${finalAmount}`
|
|
1146
1183
|
* })
|
|
1184
|
+
* ```
|
|
1147
1185
|
*
|
|
1148
1186
|
* @since 2.0.0
|
|
1149
1187
|
* @category Creating Effects
|
|
@@ -1190,6 +1228,7 @@ const none = exports.none = effect.none;
|
|
|
1190
1228
|
* @see {@link tryPromise} for a version that can handle failures.
|
|
1191
1229
|
*
|
|
1192
1230
|
* @example
|
|
1231
|
+
* ```ts
|
|
1193
1232
|
* // Title: Delayed Message
|
|
1194
1233
|
* import { Effect } from "effect"
|
|
1195
1234
|
*
|
|
@@ -1206,6 +1245,7 @@ const none = exports.none = effect.none;
|
|
|
1206
1245
|
* // ┌─── Effect<string, never, never>
|
|
1207
1246
|
* // ▼
|
|
1208
1247
|
* const program = delay("Async operation completed successfully!")
|
|
1248
|
+
* ```
|
|
1209
1249
|
*
|
|
1210
1250
|
* @since 2.0.0
|
|
1211
1251
|
* @category Creating Effects
|
|
@@ -1222,6 +1262,7 @@ const promise = exports.promise = effect.promise;
|
|
|
1222
1262
|
* @see {@link fail} to create an effect that represents a failure.
|
|
1223
1263
|
*
|
|
1224
1264
|
* @example
|
|
1265
|
+
* ```ts
|
|
1225
1266
|
* // Title: Creating a Successful Effect
|
|
1226
1267
|
* import { Effect } from "effect"
|
|
1227
1268
|
*
|
|
@@ -1230,6 +1271,7 @@ const promise = exports.promise = effect.promise;
|
|
|
1230
1271
|
* // ┌─── Effect<number, never, never>
|
|
1231
1272
|
* // ▼
|
|
1232
1273
|
* const success = Effect.succeed(42)
|
|
1274
|
+
* ```
|
|
1233
1275
|
*
|
|
1234
1276
|
* @since 2.0.0
|
|
1235
1277
|
* @category Creating Effects
|
|
@@ -1264,6 +1306,7 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
|
|
|
1264
1306
|
* - **Unifying Return Types**: Can help TypeScript unify return types in situations where multiple branches of logic return different effects, simplifying type inference.
|
|
1265
1307
|
*
|
|
1266
1308
|
* @example
|
|
1309
|
+
* ```ts
|
|
1267
1310
|
* // Title: Lazy Evaluation with Side Effects
|
|
1268
1311
|
* import { Effect } from "effect"
|
|
1269
1312
|
*
|
|
@@ -1278,6 +1321,7 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
|
|
|
1278
1321
|
*
|
|
1279
1322
|
* console.log(Effect.runSync(good)) // Output: 1
|
|
1280
1323
|
* console.log(Effect.runSync(good)) // Output: 2
|
|
1324
|
+
* ```
|
|
1281
1325
|
*
|
|
1282
1326
|
* @example
|
|
1283
1327
|
* // Title: Recursive Fibonacci
|
|
@@ -1350,6 +1394,7 @@ const suspend = exports.suspend = core.suspend;
|
|
|
1350
1394
|
* @see {@link try_ | try} for a version that can handle failures.
|
|
1351
1395
|
*
|
|
1352
1396
|
* @example
|
|
1397
|
+
* ```ts
|
|
1353
1398
|
* // Title: Logging a Message
|
|
1354
1399
|
* import { Effect } from "effect"
|
|
1355
1400
|
*
|
|
@@ -1361,6 +1406,7 @@ const suspend = exports.suspend = core.suspend;
|
|
|
1361
1406
|
* // ┌─── Effect<void, never, never>
|
|
1362
1407
|
* // ▼
|
|
1363
1408
|
* const program = log("Hello, World!")
|
|
1409
|
+
* ```
|
|
1364
1410
|
*
|
|
1365
1411
|
* @since 2.0.0
|
|
1366
1412
|
* @category Creating Effects
|
|
@@ -1389,6 +1435,7 @@ const _catch = exports.catch = effect._catch;
|
|
|
1389
1435
|
* @see {@link catchAllCause} for a version that can recover from both recoverable and unrecoverable errors.
|
|
1390
1436
|
*
|
|
1391
1437
|
* @example
|
|
1438
|
+
* ```ts
|
|
1392
1439
|
* // Title: Providing Recovery Logic for Recoverable Errors
|
|
1393
1440
|
* import { Effect, Random } from "effect"
|
|
1394
1441
|
*
|
|
@@ -1421,6 +1468,7 @@ const _catch = exports.catch = effect._catch;
|
|
|
1421
1468
|
* Effect.succeed(`Recovering from ${error._tag}`)
|
|
1422
1469
|
* )
|
|
1423
1470
|
* )
|
|
1471
|
+
* ```
|
|
1424
1472
|
*
|
|
1425
1473
|
* @since 2.0.0
|
|
1426
1474
|
* @category Error handling
|
|
@@ -1444,6 +1492,7 @@ const catchAll = exports.catchAll = core.catchAll;
|
|
|
1444
1492
|
* dynamically loaded plugins, controlled recovery might be needed.
|
|
1445
1493
|
*
|
|
1446
1494
|
* @example
|
|
1495
|
+
* ```ts
|
|
1447
1496
|
* // Title: Recovering from All Errors
|
|
1448
1497
|
* import { Cause, Effect } from "effect"
|
|
1449
1498
|
*
|
|
@@ -1461,6 +1510,7 @@ const catchAll = exports.catchAll = core.catchAll;
|
|
|
1461
1510
|
*
|
|
1462
1511
|
* Effect.runPromise(recovered).then(console.log)
|
|
1463
1512
|
* // Output: "Recovered from a regular error"
|
|
1513
|
+
* ```
|
|
1464
1514
|
*
|
|
1465
1515
|
* @since 2.0.0
|
|
1466
1516
|
* @category Error handling
|
|
@@ -1490,6 +1540,7 @@ const catchAllCause = exports.catchAllCause = core.catchAllCause;
|
|
|
1490
1540
|
* dynamically loaded plugins, controlled recovery might be needed.
|
|
1491
1541
|
*
|
|
1492
1542
|
* @example
|
|
1543
|
+
* ```ts
|
|
1493
1544
|
* // Title: Handling All Defects
|
|
1494
1545
|
* import { Effect, Cause, Console } from "effect"
|
|
1495
1546
|
*
|
|
@@ -1514,6 +1565,7 @@ const catchAllCause = exports.catchAllCause = core.catchAllCause;
|
|
|
1514
1565
|
* // _tag: "Success",
|
|
1515
1566
|
* // value: undefined
|
|
1516
1567
|
* // }
|
|
1568
|
+
* ```
|
|
1517
1569
|
*
|
|
1518
1570
|
* @since 2.0.0
|
|
1519
1571
|
* @category Error handling
|
|
@@ -1531,6 +1583,7 @@ const catchAllDefect = exports.catchAllDefect = effect.catchAllDefect;
|
|
|
1531
1583
|
* error type unless a user-defined type guard is used to narrow the type.
|
|
1532
1584
|
*
|
|
1533
1585
|
* @example
|
|
1586
|
+
* ```ts
|
|
1534
1587
|
* // Title: Catching Specific Errors with a Predicate
|
|
1535
1588
|
* import { Effect, Random } from "effect"
|
|
1536
1589
|
*
|
|
@@ -1565,6 +1618,7 @@ const catchAllDefect = exports.catchAllDefect = effect.catchAllDefect;
|
|
|
1565
1618
|
* () => Effect.succeed("Recovering from HttpError")
|
|
1566
1619
|
* )
|
|
1567
1620
|
* )
|
|
1621
|
+
* ```
|
|
1568
1622
|
*
|
|
1569
1623
|
* @since 2.0.0
|
|
1570
1624
|
* @category Error handling
|
|
@@ -1585,6 +1639,7 @@ const catchIf = exports.catchIf = core.catchIf;
|
|
|
1585
1639
|
* @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
|
|
1586
1640
|
*
|
|
1587
1641
|
* @example
|
|
1642
|
+
* ```ts
|
|
1588
1643
|
* // Title: Handling Specific Errors with Effect.catchSome
|
|
1589
1644
|
* import { Effect, Random, Option } from "effect"
|
|
1590
1645
|
*
|
|
@@ -1622,6 +1677,7 @@ const catchIf = exports.catchIf = core.catchIf;
|
|
|
1622
1677
|
* }
|
|
1623
1678
|
* })
|
|
1624
1679
|
* )
|
|
1680
|
+
* ```
|
|
1625
1681
|
*
|
|
1626
1682
|
* @since 2.0.0
|
|
1627
1683
|
* @category Error handling
|
|
@@ -1661,6 +1717,7 @@ const catchSomeCause = exports.catchSomeCause = effect.catchSomeCause;
|
|
|
1661
1717
|
* - If the defect does not match, the function returns `Option.none`, allowing the defect to propagate.
|
|
1662
1718
|
*
|
|
1663
1719
|
* @example
|
|
1720
|
+
* ```ts
|
|
1664
1721
|
* // Title: Handling Specific Defects
|
|
1665
1722
|
* import { Effect, Cause, Option, Console } from "effect"
|
|
1666
1723
|
*
|
|
@@ -1691,6 +1748,7 @@ const catchSomeCause = exports.catchSomeCause = effect.catchSomeCause;
|
|
|
1691
1748
|
* // defect: { _tag: 'RuntimeException' }
|
|
1692
1749
|
* // }
|
|
1693
1750
|
* // }
|
|
1751
|
+
* ```
|
|
1694
1752
|
*
|
|
1695
1753
|
* @since 2.0.0
|
|
1696
1754
|
* @category Error handling
|
|
@@ -1714,6 +1772,7 @@ const catchSomeDefect = exports.catchSomeDefect = effect.catchSomeDefect;
|
|
|
1714
1772
|
* types at once.
|
|
1715
1773
|
*
|
|
1716
1774
|
* @example
|
|
1775
|
+
* ```ts
|
|
1717
1776
|
* // Title: Handling Errors by Tag
|
|
1718
1777
|
* import { Effect, Random } from "effect"
|
|
1719
1778
|
*
|
|
@@ -1747,6 +1806,7 @@ const catchSomeDefect = exports.catchSomeDefect = effect.catchSomeDefect;
|
|
|
1747
1806
|
* Effect.succeed("Recovering from HttpError")
|
|
1748
1807
|
* )
|
|
1749
1808
|
* )
|
|
1809
|
+
* ```
|
|
1750
1810
|
*
|
|
1751
1811
|
* @since 2.0.0
|
|
1752
1812
|
* @category Error handling
|
|
@@ -1767,6 +1827,7 @@ const catchTag = exports.catchTag = effect.catchTag;
|
|
|
1767
1827
|
* field is used to identify and match errors.
|
|
1768
1828
|
*
|
|
1769
1829
|
* @example
|
|
1830
|
+
* ```ts
|
|
1770
1831
|
* // Title: Handling Multiple Tagged Error Types at Once
|
|
1771
1832
|
* import { Effect, Random } from "effect"
|
|
1772
1833
|
*
|
|
@@ -1802,6 +1863,7 @@ const catchTag = exports.catchTag = effect.catchTag;
|
|
|
1802
1863
|
* Effect.succeed(`Recovering from ValidationError`)
|
|
1803
1864
|
* })
|
|
1804
1865
|
* )
|
|
1866
|
+
* ```
|
|
1805
1867
|
*
|
|
1806
1868
|
* @since 2.0.0
|
|
1807
1869
|
* @category Error handling
|
|
@@ -1819,6 +1881,7 @@ const catchTags = exports.catchTags = effect.catchTags;
|
|
|
1819
1881
|
* interruptions, etc.).
|
|
1820
1882
|
*
|
|
1821
1883
|
* @example
|
|
1884
|
+
* ```ts
|
|
1822
1885
|
* import { Effect, Console } from "effect"
|
|
1823
1886
|
*
|
|
1824
1887
|
* // ┌─── Effect<number, string, never>
|
|
@@ -1831,6 +1894,7 @@ const catchTags = exports.catchTags = effect.catchTags;
|
|
|
1831
1894
|
* const cause = yield* Effect.cause(program)
|
|
1832
1895
|
* yield* Console.log(cause)
|
|
1833
1896
|
* })
|
|
1897
|
+
* ```
|
|
1834
1898
|
*
|
|
1835
1899
|
* @since 2.0.0
|
|
1836
1900
|
* @category Error handling
|
|
@@ -1852,6 +1916,7 @@ const eventually = exports.eventually = effect.eventually;
|
|
|
1852
1916
|
* side effects of the effect and do not need to handle or process its outcome.
|
|
1853
1917
|
*
|
|
1854
1918
|
* @example
|
|
1919
|
+
* ```ts
|
|
1855
1920
|
* import { Effect } from "effect"
|
|
1856
1921
|
*
|
|
1857
1922
|
* // ┌─── Effect<number, string, never>
|
|
@@ -1861,6 +1926,7 @@ const eventually = exports.eventually = effect.eventually;
|
|
|
1861
1926
|
* // ┌─── Effect<void, never, never>
|
|
1862
1927
|
* // ▼
|
|
1863
1928
|
* const program = Effect.ignore(task)
|
|
1929
|
+
* ```
|
|
1864
1930
|
*
|
|
1865
1931
|
* @since 2.0.0
|
|
1866
1932
|
* @category Error handling
|
|
@@ -1886,6 +1952,7 @@ const ignoreLogged = exports.ignoreLogged = effect.ignoreLogged;
|
|
|
1886
1952
|
* it easier to manage and respond to errors from multiple operations at once.
|
|
1887
1953
|
*
|
|
1888
1954
|
* @example
|
|
1955
|
+
* ```ts
|
|
1889
1956
|
* import { Effect } from "effect"
|
|
1890
1957
|
*
|
|
1891
1958
|
* const fail1 = Effect.fail("Oh uh!")
|
|
@@ -1904,6 +1971,7 @@ const ignoreLogged = exports.ignoreLogged = effect.ignoreLogged;
|
|
|
1904
1971
|
* // _tag: 'Failure',
|
|
1905
1972
|
* // cause: { _id: 'Cause', _tag: 'Fail', failure: [ 'Oh uh!', 'Oh no!' ] }
|
|
1906
1973
|
* // }
|
|
1974
|
+
* ```
|
|
1907
1975
|
*
|
|
1908
1976
|
* @since 2.0.0
|
|
1909
1977
|
* @category Error handling
|
|
@@ -1925,6 +1993,7 @@ const parallelErrors = exports.parallelErrors = effect.parallelErrors;
|
|
|
1925
1993
|
* @see {@link unsandbox} to restore the original error handling.
|
|
1926
1994
|
*
|
|
1927
1995
|
* @example
|
|
1996
|
+
* ```ts
|
|
1928
1997
|
* import { Effect, Console } from "effect"
|
|
1929
1998
|
*
|
|
1930
1999
|
* // ┌─── Effect<string, Error, never>
|
|
@@ -1959,6 +2028,7 @@ const parallelErrors = exports.parallelErrors = effect.parallelErrors;
|
|
|
1959
2028
|
* // Output:
|
|
1960
2029
|
* // Caught a defect: Oh uh!
|
|
1961
2030
|
* // fallback result on failure
|
|
2031
|
+
* ```
|
|
1962
2032
|
*
|
|
1963
2033
|
* @since 2.0.0
|
|
1964
2034
|
* @category Error handling
|
|
@@ -1981,6 +2051,7 @@ const sandbox = exports.sandbox = effect.sandbox;
|
|
|
1981
2051
|
* @see {@link retryOrElse} for a version that allows you to run a fallback.
|
|
1982
2052
|
*
|
|
1983
2053
|
* @example
|
|
2054
|
+
* ```ts
|
|
1984
2055
|
* import { Effect, Schedule } from "effect"
|
|
1985
2056
|
*
|
|
1986
2057
|
* let count = 0
|
|
@@ -2009,6 +2080,7 @@ const sandbox = exports.sandbox = effect.sandbox;
|
|
|
2009
2080
|
* // failure
|
|
2010
2081
|
* // success
|
|
2011
2082
|
* // yay!
|
|
2083
|
+
* ```
|
|
2012
2084
|
*
|
|
2013
2085
|
* @since 2.0.0
|
|
2014
2086
|
* @category Error handling
|
|
@@ -2026,6 +2098,7 @@ const retry = exports.retry = _schedule.retry_combined;
|
|
|
2026
2098
|
* @see {@link retry} for a version that does not run a fallback effect.
|
|
2027
2099
|
*
|
|
2028
2100
|
* @example
|
|
2101
|
+
* ```ts
|
|
2029
2102
|
* import { Effect, Schedule, Console } from "effect"
|
|
2030
2103
|
*
|
|
2031
2104
|
* let count = 0
|
|
@@ -2057,6 +2130,7 @@ const retry = exports.retry = _schedule.retry_combined;
|
|
|
2057
2130
|
* // failure
|
|
2058
2131
|
* // orElse
|
|
2059
2132
|
* // default value
|
|
2133
|
+
* ```
|
|
2060
2134
|
*
|
|
2061
2135
|
* @since 2.0.0
|
|
2062
2136
|
* @category Error handling
|
|
@@ -2113,6 +2187,7 @@ const tryMapPromise = exports.tryMapPromise = effect.tryMapPromise;
|
|
|
2113
2187
|
* @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
|
|
2114
2188
|
*
|
|
2115
2189
|
* @example
|
|
2190
|
+
* ```ts
|
|
2116
2191
|
* // Title: Fetching a TODO Item
|
|
2117
2192
|
* import { Effect } from "effect"
|
|
2118
2193
|
*
|
|
@@ -2125,6 +2200,7 @@ const tryMapPromise = exports.tryMapPromise = effect.tryMapPromise;
|
|
|
2125
2200
|
* // ┌─── Effect<Response, UnknownException, never>
|
|
2126
2201
|
* // ▼
|
|
2127
2202
|
* const program = getTodo(1)
|
|
2203
|
+
* ```
|
|
2128
2204
|
*
|
|
2129
2205
|
* @example
|
|
2130
2206
|
* // Title: Custom Error Handling
|
|
@@ -2207,6 +2283,7 @@ const checkInterruptible = exports.checkInterruptible = core.checkInterruptible;
|
|
|
2207
2283
|
* @see {@link Effect.uninterruptible} for creating an uninterruptible effect.
|
|
2208
2284
|
*
|
|
2209
2285
|
* @example
|
|
2286
|
+
* ```ts
|
|
2210
2287
|
* import { Effect } from "effect"
|
|
2211
2288
|
*
|
|
2212
2289
|
* const longRunningTask = Effect.gen(function* () {
|
|
@@ -2236,6 +2313,7 @@ const checkInterruptible = exports.checkInterruptible = core.checkInterruptible;
|
|
|
2236
2313
|
* // }
|
|
2237
2314
|
* // }
|
|
2238
2315
|
* // Heavy processing done.
|
|
2316
|
+
* ```
|
|
2239
2317
|
*
|
|
2240
2318
|
* @since 2.0.0
|
|
2241
2319
|
* @category Interruption
|
|
@@ -2281,6 +2359,7 @@ const uninterruptibleMask = exports.uninterruptibleMask = core.uninterruptibleMa
|
|
|
2281
2359
|
* or failing with specified error if the predicate fails
|
|
2282
2360
|
*
|
|
2283
2361
|
* @example
|
|
2362
|
+
* ```ts
|
|
2284
2363
|
* import { Effect } from "effect"
|
|
2285
2364
|
*
|
|
2286
2365
|
* const isPositive = (n: number): boolean => n > 0
|
|
@@ -2290,6 +2369,7 @@ const uninterruptibleMask = exports.uninterruptibleMask = core.uninterruptibleMa
|
|
|
2290
2369
|
*
|
|
2291
2370
|
* // fails with `"0 is not positive"`
|
|
2292
2371
|
* Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
|
|
2372
|
+
* ```
|
|
2293
2373
|
*
|
|
2294
2374
|
* @category Condition Checking
|
|
2295
2375
|
* @since 3.4.0
|
|
@@ -2302,6 +2382,7 @@ const liftPredicate = exports.liftPredicate = effect.liftPredicate;
|
|
|
2302
2382
|
* replace it with a new constant value.
|
|
2303
2383
|
*
|
|
2304
2384
|
* @example
|
|
2385
|
+
* ```ts
|
|
2305
2386
|
* // Title: Replacing a Value
|
|
2306
2387
|
* import { pipe, Effect } from "effect"
|
|
2307
2388
|
*
|
|
@@ -2310,6 +2391,7 @@ const liftPredicate = exports.liftPredicate = effect.liftPredicate;
|
|
|
2310
2391
|
*
|
|
2311
2392
|
* Effect.runPromise(program).then(console.log)
|
|
2312
2393
|
* // Output: "new value"
|
|
2394
|
+
* ```
|
|
2313
2395
|
*
|
|
2314
2396
|
* @since 2.0.0
|
|
2315
2397
|
* @category Mapping
|
|
@@ -2353,6 +2435,7 @@ const asVoid = exports.asVoid = core.asVoid;
|
|
|
2353
2435
|
* treat an error as a valid result.
|
|
2354
2436
|
*
|
|
2355
2437
|
* @example
|
|
2438
|
+
* ```ts
|
|
2356
2439
|
* import { Effect } from "effect"
|
|
2357
2440
|
*
|
|
2358
2441
|
* // ┌─── Effect<number, string, never>
|
|
@@ -2362,6 +2445,7 @@ const asVoid = exports.asVoid = core.asVoid;
|
|
|
2362
2445
|
* // ┌─── Effect<string, number, never>
|
|
2363
2446
|
* // ▼
|
|
2364
2447
|
* const flipped = Effect.flip(program)
|
|
2448
|
+
* ```
|
|
2365
2449
|
*
|
|
2366
2450
|
* @since 2.0.0
|
|
2367
2451
|
* @category Mapping
|
|
@@ -2402,6 +2486,7 @@ const flipWith = exports.flipWith = effect.flipWith;
|
|
|
2402
2486
|
* @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
|
|
2403
2487
|
*
|
|
2404
2488
|
* @example
|
|
2489
|
+
* ```ts
|
|
2405
2490
|
* // Title: Adding a Service Charge
|
|
2406
2491
|
* import { pipe, Effect } from "effect"
|
|
2407
2492
|
*
|
|
@@ -2416,6 +2501,7 @@ const flipWith = exports.flipWith = effect.flipWith;
|
|
|
2416
2501
|
*
|
|
2417
2502
|
* Effect.runPromise(finalAmount).then(console.log)
|
|
2418
2503
|
* // Output: 101
|
|
2504
|
+
* ```
|
|
2419
2505
|
* @since 2.0.0
|
|
2420
2506
|
* @category Mapping
|
|
2421
2507
|
*/
|
|
@@ -2440,6 +2526,7 @@ const map = exports.map = core.map;
|
|
|
2440
2526
|
* input collection type.
|
|
2441
2527
|
*
|
|
2442
2528
|
* @example
|
|
2529
|
+
* ```ts
|
|
2443
2530
|
* import { Effect } from "effect"
|
|
2444
2531
|
*
|
|
2445
2532
|
* // Define an initial state and a transformation function
|
|
@@ -2458,6 +2545,7 @@ const map = exports.map = core.map;
|
|
|
2458
2545
|
* // Output:
|
|
2459
2546
|
* // 6
|
|
2460
2547
|
* // [ 'A', 'BB', 'CCC' ]
|
|
2548
|
+
* ```
|
|
2461
2549
|
*
|
|
2462
2550
|
* @since 2.0.0
|
|
2463
2551
|
* @category Mapping
|
|
@@ -2476,6 +2564,7 @@ const mapAccum = exports.mapAccum = effect.mapAccum;
|
|
|
2476
2564
|
* @see {@link mapError} for a version that operates on the error channel.
|
|
2477
2565
|
*
|
|
2478
2566
|
* @example
|
|
2567
|
+
* ```ts
|
|
2479
2568
|
* import { Effect } from "effect"
|
|
2480
2569
|
*
|
|
2481
2570
|
* // ┌─── Effect<number, string, never>
|
|
@@ -2488,6 +2577,7 @@ const mapAccum = exports.mapAccum = effect.mapAccum;
|
|
|
2488
2577
|
* onFailure: (message) => new Error(message),
|
|
2489
2578
|
* onSuccess: (n) => n > 0
|
|
2490
2579
|
* })
|
|
2580
|
+
* ```
|
|
2491
2581
|
*
|
|
2492
2582
|
* @since 2.0.0
|
|
2493
2583
|
* @category Mapping
|
|
@@ -2507,6 +2597,7 @@ const mapBoth = exports.mapBoth = core.mapBoth;
|
|
|
2507
2597
|
* @see {@link orElseFail} if you want to replace the error with a new one.
|
|
2508
2598
|
*
|
|
2509
2599
|
* @example
|
|
2600
|
+
* ```ts
|
|
2510
2601
|
* import { Effect } from "effect"
|
|
2511
2602
|
*
|
|
2512
2603
|
* // ┌─── Effect<number, string, never>
|
|
@@ -2519,6 +2610,7 @@ const mapBoth = exports.mapBoth = core.mapBoth;
|
|
|
2519
2610
|
* simulatedTask,
|
|
2520
2611
|
* (message) => new Error(message)
|
|
2521
2612
|
* )
|
|
2613
|
+
* ```
|
|
2522
2614
|
*
|
|
2523
2615
|
* @since 2.0.0
|
|
2524
2616
|
* @category Mapping
|
|
@@ -2546,6 +2638,7 @@ const mapErrorCause = exports.mapErrorCause = effect.mapErrorCause;
|
|
|
2546
2638
|
* errors as part of the outcome.
|
|
2547
2639
|
*
|
|
2548
2640
|
* @example
|
|
2641
|
+
* ```ts
|
|
2549
2642
|
* import { Effect } from "effect"
|
|
2550
2643
|
*
|
|
2551
2644
|
* // ┌─── Effect<number, string, never>
|
|
@@ -2555,6 +2648,7 @@ const mapErrorCause = exports.mapErrorCause = effect.mapErrorCause;
|
|
|
2555
2648
|
* // ┌─── Effect<number | string, never, never>
|
|
2556
2649
|
* // ▼
|
|
2557
2650
|
* const recovered = Effect.merge(program)
|
|
2651
|
+
* ```
|
|
2558
2652
|
*
|
|
2559
2653
|
* @since 2.0.0
|
|
2560
2654
|
* @category Mapping
|
|
@@ -2703,6 +2797,15 @@ const scope = exports.scope = fiberRuntime.scope;
|
|
|
2703
2797
|
* @category scoping, resources & finalization
|
|
2704
2798
|
*/
|
|
2705
2799
|
const scopeWith = exports.scopeWith = fiberRuntime.scopeWith;
|
|
2800
|
+
/**
|
|
2801
|
+
* Creates a `Scope`, passes it to the specified effectful function, and then
|
|
2802
|
+
* closes the scope as soon as the effect is complete (whether through success,
|
|
2803
|
+
* failure, or interruption).
|
|
2804
|
+
*
|
|
2805
|
+
* @since 3.11.0
|
|
2806
|
+
* @category scoping, resources & finalization
|
|
2807
|
+
*/
|
|
2808
|
+
const scopedWith = exports.scopedWith = fiberRuntime.scopedWith;
|
|
2706
2809
|
/**
|
|
2707
2810
|
* Scopes all resources used in this workflow to the lifetime of the workflow,
|
|
2708
2811
|
* ensuring that their finalizers are run as soon as this workflow completes
|
|
@@ -3026,6 +3129,7 @@ const timedWith = exports.timedWith = effect.timedWith;
|
|
|
3026
3129
|
* @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
|
|
3027
3130
|
*
|
|
3028
3131
|
* @example
|
|
3132
|
+
* ```ts
|
|
3029
3133
|
* import { Effect } from "effect"
|
|
3030
3134
|
*
|
|
3031
3135
|
* const task = Effect.gen(function* () {
|
|
@@ -3051,6 +3155,7 @@ const timedWith = exports.timedWith = effect.timedWith;
|
|
|
3051
3155
|
* // failure: { _tag: 'TimeoutException' }
|
|
3052
3156
|
* // }
|
|
3053
3157
|
* // }
|
|
3158
|
+
* ```
|
|
3054
3159
|
*
|
|
3055
3160
|
* @since 2.0.0
|
|
3056
3161
|
* @category delays & timeouts
|
|
@@ -3076,6 +3181,7 @@ const timeout = exports.timeout = circular.timeout;
|
|
|
3076
3181
|
* @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
|
|
3077
3182
|
*
|
|
3078
3183
|
* @example
|
|
3184
|
+
* ```ts
|
|
3079
3185
|
* import { Effect } from "effect"
|
|
3080
3186
|
*
|
|
3081
3187
|
* const task = Effect.gen(function* () {
|
|
@@ -3099,6 +3205,7 @@ const timeout = exports.timeout = circular.timeout;
|
|
|
3099
3205
|
* // { _id: 'Option', _tag: 'Some', value: 'Result' },
|
|
3100
3206
|
* // { _id: 'Option', _tag: 'None' }
|
|
3101
3207
|
* // ]
|
|
3208
|
+
* ```
|
|
3102
3209
|
*
|
|
3103
3210
|
* @since 3.1.0
|
|
3104
3211
|
* @category delays & timeouts
|
|
@@ -3123,6 +3230,7 @@ const timeoutOption = exports.timeoutOption = circular.timeoutOption;
|
|
|
3123
3230
|
* @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
|
|
3124
3231
|
*
|
|
3125
3232
|
* @example
|
|
3233
|
+
* ```ts
|
|
3126
3234
|
* import { Effect } from "effect"
|
|
3127
3235
|
*
|
|
3128
3236
|
* const task = Effect.gen(function* () {
|
|
@@ -3155,6 +3263,7 @@ const timeoutOption = exports.timeoutOption = circular.timeoutOption;
|
|
|
3155
3263
|
* // failure: MyTimeoutError { _tag: 'MyTimeoutError' }
|
|
3156
3264
|
* // }
|
|
3157
3265
|
* // }
|
|
3266
|
+
* ```
|
|
3158
3267
|
*
|
|
3159
3268
|
* @since 2.0.0
|
|
3160
3269
|
* @category delays & timeouts
|
|
@@ -3178,6 +3287,7 @@ const timeoutFail = exports.timeoutFail = circular.timeoutFail;
|
|
|
3178
3287
|
* @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
|
|
3179
3288
|
*
|
|
3180
3289
|
* @example
|
|
3290
|
+
* ```ts
|
|
3181
3291
|
* import { Effect, Cause } from "effect"
|
|
3182
3292
|
*
|
|
3183
3293
|
* const task = Effect.gen(function* () {
|
|
@@ -3202,6 +3312,7 @@ const timeoutFail = exports.timeoutFail = circular.timeoutFail;
|
|
|
3202
3312
|
* // _tag: 'Failure',
|
|
3203
3313
|
* // cause: { _id: 'Cause', _tag: 'Die', defect: 'Timed out!' }
|
|
3204
3314
|
* // }
|
|
3315
|
+
* ```
|
|
3205
3316
|
*
|
|
3206
3317
|
* @since 2.0.0
|
|
3207
3318
|
* @category delays & timeouts
|
|
@@ -3229,6 +3340,7 @@ const timeoutFailCause = exports.timeoutFailCause = circular.timeoutFailCause;
|
|
|
3229
3340
|
* @see {@link timeoutFailCause} for a version that raises a custom defect.
|
|
3230
3341
|
*
|
|
3231
3342
|
* @example
|
|
3343
|
+
* ```ts
|
|
3232
3344
|
* import { Effect, Either } from "effect"
|
|
3233
3345
|
*
|
|
3234
3346
|
* const task = Effect.gen(function* () {
|
|
@@ -3256,6 +3368,7 @@ const timeoutFailCause = exports.timeoutFailCause = circular.timeoutFailCause;
|
|
|
3256
3368
|
* // _tag: "Left",
|
|
3257
3369
|
* // left: "Timed out!"
|
|
3258
3370
|
* // }
|
|
3371
|
+
* ```
|
|
3259
3372
|
*
|
|
3260
3373
|
* @since 2.0.0
|
|
3261
3374
|
* @category delays & timeouts
|
|
@@ -3322,6 +3435,7 @@ const mapInputContext = exports.mapInputContext = core.mapInputContext;
|
|
|
3322
3435
|
* @see {@link provideService} for providing a service to an effect.
|
|
3323
3436
|
*
|
|
3324
3437
|
* @example
|
|
3438
|
+
* ```ts
|
|
3325
3439
|
* import { Context, Effect, Layer } from "effect"
|
|
3326
3440
|
*
|
|
3327
3441
|
* class Database extends Context.Tag("Database")<
|
|
@@ -3353,6 +3467,7 @@ const mapInputContext = exports.mapInputContext = core.mapInputContext;
|
|
|
3353
3467
|
* // Output:
|
|
3354
3468
|
* // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
|
|
3355
3469
|
* // []
|
|
3470
|
+
* ```
|
|
3356
3471
|
*
|
|
3357
3472
|
* @since 2.0.0
|
|
3358
3473
|
* @category Context
|
|
@@ -3371,6 +3486,7 @@ const provide = exports.provide = layer.effect_provide;
|
|
|
3371
3486
|
* @see {@link provide} for providing multiple layers to an effect.
|
|
3372
3487
|
*
|
|
3373
3488
|
* @example
|
|
3489
|
+
* ```ts
|
|
3374
3490
|
* import { Effect, Context } from "effect"
|
|
3375
3491
|
*
|
|
3376
3492
|
* // Declaring a tag for a service that generates random numbers
|
|
@@ -3398,6 +3514,7 @@ const provide = exports.provide = layer.effect_provide;
|
|
|
3398
3514
|
* Effect.runPromise(runnable)
|
|
3399
3515
|
* // Example Output:
|
|
3400
3516
|
* // random number: 0.8241872233134417
|
|
3517
|
+
* ```
|
|
3401
3518
|
*
|
|
3402
3519
|
* @since 2.0.0
|
|
3403
3520
|
* @category Context
|
|
@@ -3468,6 +3585,7 @@ const updateService = exports.updateService = effect.updateService;
|
|
|
3468
3585
|
* @see {@link let_ let}
|
|
3469
3586
|
*
|
|
3470
3587
|
* @example
|
|
3588
|
+
* ```ts
|
|
3471
3589
|
* import { Effect, pipe } from "effect"
|
|
3472
3590
|
*
|
|
3473
3591
|
* const result = pipe(
|
|
@@ -3477,6 +3595,7 @@ const updateService = exports.updateService = effect.updateService;
|
|
|
3477
3595
|
* Effect.let("sum", ({ x, y }) => x + y)
|
|
3478
3596
|
* )
|
|
3479
3597
|
* assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
|
|
3598
|
+
* ```
|
|
3480
3599
|
*
|
|
3481
3600
|
* @category Do notation
|
|
3482
3601
|
* @since 2.0.0
|
|
@@ -3497,6 +3616,7 @@ const Do = exports.Do = effect.Do;
|
|
|
3497
3616
|
* @see {@link let_ let}
|
|
3498
3617
|
*
|
|
3499
3618
|
* @example
|
|
3619
|
+
* ```ts
|
|
3500
3620
|
* import { Effect, pipe } from "effect"
|
|
3501
3621
|
*
|
|
3502
3622
|
* const result = pipe(
|
|
@@ -3506,6 +3626,7 @@ const Do = exports.Do = effect.Do;
|
|
|
3506
3626
|
* Effect.let("sum", ({ x, y }) => x + y)
|
|
3507
3627
|
* )
|
|
3508
3628
|
* assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
|
|
3629
|
+
* ```
|
|
3509
3630
|
*
|
|
3510
3631
|
* @category Do notation
|
|
3511
3632
|
* @since 2.0.0
|
|
@@ -3517,6 +3638,7 @@ const bind = exports.bind = effect.bind;
|
|
|
3517
3638
|
* results in a Do notation pipeline.
|
|
3518
3639
|
*
|
|
3519
3640
|
* @example
|
|
3641
|
+
* ```ts
|
|
3520
3642
|
* import { Effect, Either, pipe } from "effect"
|
|
3521
3643
|
*
|
|
3522
3644
|
* const result = pipe(
|
|
@@ -3528,6 +3650,7 @@ const bind = exports.bind = effect.bind;
|
|
|
3528
3650
|
* }), { concurrency: 2, mode: "either" })
|
|
3529
3651
|
* )
|
|
3530
3652
|
* assert.deepStrictEqual(Effect.runSync(result), { x: 2, a: Either.right(2), b: Either.left("oops") })
|
|
3653
|
+
* ```
|
|
3531
3654
|
*
|
|
3532
3655
|
* @category Do notation
|
|
3533
3656
|
* @since 3.7.0
|
|
@@ -3548,6 +3671,7 @@ const bindAll = exports.bindAll = circular.bindAll;
|
|
|
3548
3671
|
* @see {@link let_ let}
|
|
3549
3672
|
*
|
|
3550
3673
|
* @example
|
|
3674
|
+
* ```ts
|
|
3551
3675
|
* import { Effect, pipe } from "effect"
|
|
3552
3676
|
*
|
|
3553
3677
|
* const result = pipe(
|
|
@@ -3557,6 +3681,7 @@ const bindAll = exports.bindAll = circular.bindAll;
|
|
|
3557
3681
|
* Effect.let("sum", ({ x, y }) => x + y)
|
|
3558
3682
|
* )
|
|
3559
3683
|
* assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
|
|
3684
|
+
* ```
|
|
3560
3685
|
*
|
|
3561
3686
|
* @category Do notation
|
|
3562
3687
|
* @since 2.0.0
|
|
@@ -3581,6 +3706,7 @@ const let_ = exports.let = effect.let_;
|
|
|
3581
3706
|
* @see {@link exit} for a version that uses `Exit` instead.
|
|
3582
3707
|
*
|
|
3583
3708
|
* @example
|
|
3709
|
+
* ```ts
|
|
3584
3710
|
* // Title: Using Effect.option to Handle Errors
|
|
3585
3711
|
* import { Effect } from "effect"
|
|
3586
3712
|
*
|
|
@@ -3613,6 +3739,7 @@ const let_ = exports.let = effect.let_;
|
|
|
3613
3739
|
* // _tag: 'Failure',
|
|
3614
3740
|
* // cause: { _id: 'Cause', _tag: 'Die', defect: 'Boom!' }
|
|
3615
3741
|
* // }
|
|
3742
|
+
* ```
|
|
3616
3743
|
*
|
|
3617
3744
|
* @since 2.0.0
|
|
3618
3745
|
* @category Outcome Encapsulation
|
|
@@ -3637,6 +3764,7 @@ const option = exports.option = effect.option;
|
|
|
3637
3764
|
* @see {@link exit} for a version that uses `Exit` instead.
|
|
3638
3765
|
*
|
|
3639
3766
|
* @example
|
|
3767
|
+
* ```ts
|
|
3640
3768
|
* import { Effect, Either, Random } from "effect"
|
|
3641
3769
|
*
|
|
3642
3770
|
* class HttpError {
|
|
@@ -3672,6 +3800,7 @@ const option = exports.option = effect.option;
|
|
|
3672
3800
|
* onRight: (value) => value // Do nothing in case of success
|
|
3673
3801
|
* })
|
|
3674
3802
|
* })
|
|
3803
|
+
* ```
|
|
3675
3804
|
*
|
|
3676
3805
|
* @since 2.0.0
|
|
3677
3806
|
* @category Outcome Encapsulation
|
|
@@ -3694,6 +3823,7 @@ const either = exports.either = core.either;
|
|
|
3694
3823
|
* @see {@link either} for a version that uses `Either` instead.
|
|
3695
3824
|
*
|
|
3696
3825
|
* @example
|
|
3826
|
+
* ```ts
|
|
3697
3827
|
* import { Effect, Cause, Console, Exit } from "effect"
|
|
3698
3828
|
*
|
|
3699
3829
|
* // Simulating a runtime error
|
|
@@ -3725,6 +3855,7 @@ const either = exports.either = core.either;
|
|
|
3725
3855
|
* // _tag: "Success",
|
|
3726
3856
|
* // value: undefined
|
|
3727
3857
|
* // }
|
|
3858
|
+
* ```
|
|
3728
3859
|
*
|
|
3729
3860
|
* @since 2.0.0
|
|
3730
3861
|
* @category Outcome Encapsulation
|
|
@@ -3741,6 +3872,7 @@ const exit = exports.exit = core.exit;
|
|
|
3741
3872
|
* failure. Additionally, if the effect is interrupted, the `Deferred` will also be interrupted.
|
|
3742
3873
|
*
|
|
3743
3874
|
* @example
|
|
3875
|
+
* ```ts
|
|
3744
3876
|
* import { Deferred, Effect } from "effect"
|
|
3745
3877
|
*
|
|
3746
3878
|
* // Define an effect that succeeds
|
|
@@ -3764,6 +3896,7 @@ const exit = exports.exit = core.exit;
|
|
|
3764
3896
|
* // Output:
|
|
3765
3897
|
* // 42
|
|
3766
3898
|
* // true
|
|
3899
|
+
* ```
|
|
3767
3900
|
*
|
|
3768
3901
|
* @since 2.0.0
|
|
3769
3902
|
* @category Synchronization Utilities
|
|
@@ -3805,6 +3938,7 @@ const filterOrElse = exports.filterOrElse = effect.filterOrElse;
|
|
|
3805
3938
|
* Let's explore this concept through an example:
|
|
3806
3939
|
*
|
|
3807
3940
|
* @example
|
|
3941
|
+
* ```ts
|
|
3808
3942
|
* import { Effect, pipe } from "effect"
|
|
3809
3943
|
*
|
|
3810
3944
|
* // Define a user interface
|
|
@@ -3825,6 +3959,7 @@ const filterOrElse = exports.filterOrElse = effect.filterOrElse;
|
|
|
3825
3959
|
* // 'user' now has the type `User` (not `User | null`)
|
|
3826
3960
|
* Effect.andThen((user) => user.name)
|
|
3827
3961
|
* )
|
|
3962
|
+
* ```
|
|
3828
3963
|
*
|
|
3829
3964
|
* @since 2.0.0
|
|
3830
3965
|
* @category Filtering
|
|
@@ -3868,6 +4003,7 @@ const unlessEffect = exports.unlessEffect = effect.unlessEffect;
|
|
|
3868
4003
|
* @see {@link unless} for a version that executes the effect when the condition is `false`.
|
|
3869
4004
|
*
|
|
3870
4005
|
* @example
|
|
4006
|
+
* ```ts
|
|
3871
4007
|
* // Title: Conditional Effect Execution
|
|
3872
4008
|
* import { Effect, Option } from "effect"
|
|
3873
4009
|
*
|
|
@@ -3893,6 +4029,7 @@ const unlessEffect = exports.unlessEffect = effect.unlessEffect;
|
|
|
3893
4029
|
* // _id: "Option",
|
|
3894
4030
|
* // _tag: "None"
|
|
3895
4031
|
* // }
|
|
4032
|
+
* ```
|
|
3896
4033
|
*
|
|
3897
4034
|
* @since 2.0.0
|
|
3898
4035
|
* @category Conditional Operators
|
|
@@ -3916,6 +4053,7 @@ const when = exports.when = effect.when;
|
|
|
3916
4053
|
* @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
|
|
3917
4054
|
*
|
|
3918
4055
|
* @example
|
|
4056
|
+
* ```ts
|
|
3919
4057
|
* // Title: Using an Effect as a Condition
|
|
3920
4058
|
* import { Effect, Random } from "effect"
|
|
3921
4059
|
*
|
|
@@ -3926,6 +4064,7 @@ const when = exports.when = effect.when;
|
|
|
3926
4064
|
* console.log(Effect.runSync(randomIntOption))
|
|
3927
4065
|
* // Example Output:
|
|
3928
4066
|
* // { _id: 'Option', _tag: 'Some', value: 8609104974198840 }
|
|
4067
|
+
* ```
|
|
3929
4068
|
*
|
|
3930
4069
|
* @since 2.0.0
|
|
3931
4070
|
* @category Conditional Operators
|
|
@@ -3976,6 +4115,7 @@ const whenRef = exports.whenRef = effect.whenRef;
|
|
|
3976
4115
|
* changing the original one.
|
|
3977
4116
|
*
|
|
3978
4117
|
* @example
|
|
4118
|
+
* ```ts
|
|
3979
4119
|
* import { pipe, Effect } from "effect"
|
|
3980
4120
|
*
|
|
3981
4121
|
* // Function to apply a discount safely to a transaction amount
|
|
@@ -3998,6 +4138,7 @@ const whenRef = exports.whenRef = effect.whenRef;
|
|
|
3998
4138
|
*
|
|
3999
4139
|
* Effect.runPromise(finalAmount).then(console.log)
|
|
4000
4140
|
* // Output: 95
|
|
4141
|
+
* ```
|
|
4001
4142
|
*
|
|
4002
4143
|
* @since 2.0.0
|
|
4003
4144
|
* @category sequencing
|
|
@@ -4037,6 +4178,7 @@ const flatMap = exports.flatMap = core.flatMap;
|
|
|
4037
4178
|
* treating them as effects.
|
|
4038
4179
|
*
|
|
4039
4180
|
* @example
|
|
4181
|
+
* ```ts
|
|
4040
4182
|
* // Title: Applying a Discount Based on Fetched Amount
|
|
4041
4183
|
* import { pipe, Effect } from "effect"
|
|
4042
4184
|
*
|
|
@@ -4071,6 +4213,7 @@ const flatMap = exports.flatMap = core.flatMap;
|
|
|
4071
4213
|
*
|
|
4072
4214
|
* Effect.runPromise(result2).then(console.log)
|
|
4073
4215
|
* // Output: 190
|
|
4216
|
+
* ```
|
|
4074
4217
|
*
|
|
4075
4218
|
* @since 2.0.0
|
|
4076
4219
|
* @category sequencing
|
|
@@ -4151,6 +4294,7 @@ const summarized = exports.summarized = effect.summarized;
|
|
|
4151
4294
|
* will fail too.
|
|
4152
4295
|
*
|
|
4153
4296
|
* @example
|
|
4297
|
+
* ```ts
|
|
4154
4298
|
* // Title: Logging a step in a pipeline
|
|
4155
4299
|
* import { Console, Effect, pipe } from "effect"
|
|
4156
4300
|
*
|
|
@@ -4178,6 +4322,7 @@ const summarized = exports.summarized = effect.summarized;
|
|
|
4178
4322
|
* // Output:
|
|
4179
4323
|
* // Apply a discount to: 100
|
|
4180
4324
|
* // 95
|
|
4325
|
+
* ```
|
|
4181
4326
|
*
|
|
4182
4327
|
* @since 2.0.0
|
|
4183
4328
|
* @category sequencing
|
|
@@ -4195,6 +4340,7 @@ const tap = exports.tap = core.tap;
|
|
|
4195
4340
|
* altering the result.
|
|
4196
4341
|
*
|
|
4197
4342
|
* @example
|
|
4343
|
+
* ```ts
|
|
4198
4344
|
* import { Effect, Random, Console } from "effect"
|
|
4199
4345
|
*
|
|
4200
4346
|
* // Simulate a task that might fail
|
|
@@ -4214,6 +4360,7 @@ const tap = exports.tap = core.tap;
|
|
|
4214
4360
|
* Effect.runFork(tapping)
|
|
4215
4361
|
* // Example Output:
|
|
4216
4362
|
* // failure: random number is negative
|
|
4363
|
+
* ```
|
|
4217
4364
|
*
|
|
4218
4365
|
* @since 2.0.0
|
|
4219
4366
|
* @category sequencing
|
|
@@ -4230,6 +4377,7 @@ const tapBoth = exports.tapBoth = effect.tapBoth;
|
|
|
4230
4377
|
* severe errors.
|
|
4231
4378
|
*
|
|
4232
4379
|
* @example
|
|
4380
|
+
* ```ts
|
|
4233
4381
|
* import { Effect, Console } from "effect"
|
|
4234
4382
|
*
|
|
4235
4383
|
* // Simulate a task that fails with a recoverable error
|
|
@@ -4257,6 +4405,7 @@ const tapBoth = exports.tapBoth = effect.tapBoth;
|
|
|
4257
4405
|
* // Output:
|
|
4258
4406
|
* // defect: RuntimeException: Something went wrong
|
|
4259
4407
|
* // ... stack trace ...
|
|
4408
|
+
* ```
|
|
4260
4409
|
*
|
|
4261
4410
|
* @since 2.0.0
|
|
4262
4411
|
* @category sequencing
|
|
@@ -4272,6 +4421,7 @@ const tapDefect = exports.tapDefect = effect.tapDefect;
|
|
|
4272
4421
|
* while the operation you provide can inspect or act on it.
|
|
4273
4422
|
*
|
|
4274
4423
|
* @example
|
|
4424
|
+
* ```ts
|
|
4275
4425
|
* import { Effect, Console } from "effect"
|
|
4276
4426
|
*
|
|
4277
4427
|
* // Simulate a task that fails with an error
|
|
@@ -4285,6 +4435,7 @@ const tapDefect = exports.tapDefect = effect.tapDefect;
|
|
|
4285
4435
|
* Effect.runFork(tapping)
|
|
4286
4436
|
* // Output:
|
|
4287
4437
|
* // expected error: NetworkError
|
|
4438
|
+
* ```
|
|
4288
4439
|
*
|
|
4289
4440
|
* @since 2.0.0
|
|
4290
4441
|
* @category sequencing
|
|
@@ -4300,6 +4451,7 @@ const tapError = exports.tapError = effect.tapError;
|
|
|
4300
4451
|
* without modifying the error or the overall result of the effect.
|
|
4301
4452
|
*
|
|
4302
4453
|
* @example
|
|
4454
|
+
* ```ts
|
|
4303
4455
|
* import { Effect, Console } from "effect"
|
|
4304
4456
|
*
|
|
4305
4457
|
* class NetworkError {
|
|
@@ -4324,6 +4476,7 @@ const tapError = exports.tapError = effect.tapError;
|
|
|
4324
4476
|
* Effect.runFork(tapping)
|
|
4325
4477
|
* // Output:
|
|
4326
4478
|
* // expected error: 504
|
|
4479
|
+
* ```
|
|
4327
4480
|
*
|
|
4328
4481
|
* @since 2.0.0
|
|
4329
4482
|
* @category sequencing
|
|
@@ -4339,6 +4492,7 @@ const tapErrorTag = exports.tapErrorTag = effect.tapErrorTag;
|
|
|
4339
4492
|
* altering the error or the overall result of the effect.
|
|
4340
4493
|
*
|
|
4341
4494
|
* @example
|
|
4495
|
+
* ```ts
|
|
4342
4496
|
* import { Effect, Console } from "effect"
|
|
4343
4497
|
*
|
|
4344
4498
|
* // Create a task that fails with a NetworkError
|
|
@@ -4365,6 +4519,7 @@ const tapErrorTag = exports.tapErrorTag = effect.tapErrorTag;
|
|
|
4365
4519
|
* // Output:
|
|
4366
4520
|
* // error cause: RuntimeException: Something went wrong
|
|
4367
4521
|
* // ... stack trace ...
|
|
4522
|
+
* ```
|
|
4368
4523
|
*
|
|
4369
4524
|
* @since 2.0.0
|
|
4370
4525
|
* @category sequencing
|
|
@@ -4396,6 +4551,7 @@ const forever = exports.forever = effect.forever;
|
|
|
4396
4551
|
* ```
|
|
4397
4552
|
*
|
|
4398
4553
|
* @example
|
|
4554
|
+
* ```ts
|
|
4399
4555
|
* // Title: Effectful Iteration
|
|
4400
4556
|
* import { Effect } from "effect"
|
|
4401
4557
|
*
|
|
@@ -4412,6 +4568,7 @@ const forever = exports.forever = effect.forever;
|
|
|
4412
4568
|
*
|
|
4413
4569
|
* Effect.runPromise(result).then(console.log)
|
|
4414
4570
|
* // Output: 6
|
|
4571
|
+
* ```
|
|
4415
4572
|
*
|
|
4416
4573
|
* @since 2.0.0
|
|
4417
4574
|
* @category Looping
|
|
@@ -4444,6 +4601,7 @@ const iterate = exports.iterate = effect.iterate;
|
|
|
4444
4601
|
* discarded, and the final result will be `void`.
|
|
4445
4602
|
*
|
|
4446
4603
|
* @example
|
|
4604
|
+
* ```ts
|
|
4447
4605
|
* // Title: Looping with Collected Results
|
|
4448
4606
|
* import { Effect } from "effect"
|
|
4449
4607
|
*
|
|
@@ -4463,6 +4621,7 @@ const iterate = exports.iterate = effect.iterate;
|
|
|
4463
4621
|
*
|
|
4464
4622
|
* Effect.runPromise(result).then(console.log)
|
|
4465
4623
|
* // Output: [1, 2, 3, 4, 5]
|
|
4624
|
+
* ```
|
|
4466
4625
|
*
|
|
4467
4626
|
* @example
|
|
4468
4627
|
* // Title: Loop with Discarded Results
|
|
@@ -4504,6 +4663,7 @@ const loop = exports.loop = effect.loop;
|
|
|
4504
4663
|
* an additional time.
|
|
4505
4664
|
*
|
|
4506
4665
|
* @example
|
|
4666
|
+
* ```ts
|
|
4507
4667
|
* // Success Example
|
|
4508
4668
|
* import { Effect, Schedule, Console } from "effect"
|
|
4509
4669
|
*
|
|
@@ -4512,6 +4672,7 @@ const loop = exports.loop = effect.loop;
|
|
|
4512
4672
|
* const program = Effect.repeat(action, policy)
|
|
4513
4673
|
*
|
|
4514
4674
|
* Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
|
|
4675
|
+
* ```
|
|
4515
4676
|
*
|
|
4516
4677
|
* @example
|
|
4517
4678
|
* // Failure Example
|
|
@@ -4547,12 +4708,14 @@ const repeat = exports.repeat = _schedule.repeat_combined;
|
|
|
4547
4708
|
* initially and then repeats it one additional time if it succeeds.
|
|
4548
4709
|
*
|
|
4549
4710
|
* @example
|
|
4711
|
+
* ```ts
|
|
4550
4712
|
* import { Effect, Console } from "effect"
|
|
4551
4713
|
*
|
|
4552
4714
|
* const action = Console.log("success")
|
|
4553
4715
|
* const program = Effect.repeatN(action, 2)
|
|
4554
4716
|
*
|
|
4555
4717
|
* Effect.runPromise(program)
|
|
4718
|
+
* ```
|
|
4556
4719
|
*
|
|
4557
4720
|
* @since 2.0.0
|
|
4558
4721
|
* @category repetition / recursion
|
|
@@ -4567,6 +4730,7 @@ const repeatN = exports.repeatN = effect.repeatN;
|
|
|
4567
4730
|
* initially and then repeats it an additional time if it succeeds.
|
|
4568
4731
|
*
|
|
4569
4732
|
* @example
|
|
4733
|
+
* ```ts
|
|
4570
4734
|
* import { Effect, Schedule } from "effect"
|
|
4571
4735
|
*
|
|
4572
4736
|
* let count = 0
|
|
@@ -4596,6 +4760,7 @@ const repeatN = exports.repeatN = effect.repeatN;
|
|
|
4596
4760
|
* )
|
|
4597
4761
|
*
|
|
4598
4762
|
* Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
|
|
4763
|
+
* ```
|
|
4599
4764
|
*
|
|
4600
4765
|
* @since 2.0.0
|
|
4601
4766
|
* @category repetition / recursion
|
|
@@ -4718,6 +4883,7 @@ const isSuccess = exports.isSuccess = effect.isSuccess;
|
|
|
4718
4883
|
* @see {@link matchEffect} if you need to perform side effects in the handlers.
|
|
4719
4884
|
*
|
|
4720
4885
|
* @example
|
|
4886
|
+
* ```ts
|
|
4721
4887
|
* import { Effect } from "effect"
|
|
4722
4888
|
*
|
|
4723
4889
|
* const success: Effect.Effect<number, Error> = Effect.succeed(42)
|
|
@@ -4743,6 +4909,7 @@ const isSuccess = exports.isSuccess = effect.isSuccess;
|
|
|
4743
4909
|
* // Run and log the result of the failed effect
|
|
4744
4910
|
* Effect.runPromise(program2).then(console.log)
|
|
4745
4911
|
* // Output: "failure: Uh oh!"
|
|
4912
|
+
* ```
|
|
4746
4913
|
*
|
|
4747
4914
|
* @since 2.0.0
|
|
4748
4915
|
* @category getters & folding
|
|
@@ -4778,6 +4945,7 @@ const matchCause = exports.matchCause = core.matchCause;
|
|
|
4778
4945
|
* @see {@link matchEffect} if you don't need to handle the cause of the failure.
|
|
4779
4946
|
*
|
|
4780
4947
|
* @example
|
|
4948
|
+
* ```ts
|
|
4781
4949
|
* import { Effect, Console } from "effect"
|
|
4782
4950
|
*
|
|
4783
4951
|
* const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
|
|
@@ -4805,6 +4973,7 @@ const matchCause = exports.matchCause = core.matchCause;
|
|
|
4805
4973
|
*
|
|
4806
4974
|
* Effect.runSync(program)
|
|
4807
4975
|
* // Output: "Die: Uh oh!"
|
|
4976
|
+
* ```
|
|
4808
4977
|
*
|
|
4809
4978
|
* @since 2.0.0
|
|
4810
4979
|
* @category getters & folding
|
|
@@ -4833,6 +5002,7 @@ const matchEffect = exports.matchEffect = core.matchEffect;
|
|
|
4833
5002
|
* To adjust the log level, use the `Logger.withMinimumLogLevel` function.
|
|
4834
5003
|
*
|
|
4835
5004
|
* @example
|
|
5005
|
+
* ```ts
|
|
4836
5006
|
* import { Cause, Effect } from "effect"
|
|
4837
5007
|
*
|
|
4838
5008
|
* const program = Effect.log(
|
|
@@ -4846,6 +5016,7 @@ const matchEffect = exports.matchEffect = core.matchEffect;
|
|
|
4846
5016
|
* // Output:
|
|
4847
5017
|
* // timestamp=... level=INFO fiber=#0 message=message1 message=message2 cause="Error: Oh no!
|
|
4848
5018
|
* // Error: Oh uh!"
|
|
5019
|
+
* ```
|
|
4849
5020
|
*
|
|
4850
5021
|
* @since 2.0.0
|
|
4851
5022
|
* @category Logging
|
|
@@ -4874,12 +5045,14 @@ const logTrace = exports.logTrace = effect.logTrace;
|
|
|
4874
5045
|
* `Logger.withMinimumLogLevel` and set the log level to `LogLevel.Debug`.
|
|
4875
5046
|
*
|
|
4876
5047
|
* @example
|
|
5048
|
+
* ```ts
|
|
4877
5049
|
* import { Effect, Logger, LogLevel } from "effect"
|
|
4878
5050
|
*
|
|
4879
5051
|
* const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
|
|
4880
5052
|
*
|
|
4881
5053
|
* // Effect.runFork(program)
|
|
4882
5054
|
* // timestamp=... level=DEBUG fiber=#0 message=message1
|
|
5055
|
+
* ```
|
|
4883
5056
|
*
|
|
4884
5057
|
* @since 2.0.0
|
|
4885
5058
|
* @category Logging
|
|
@@ -4919,6 +5092,7 @@ const logFatal = exports.logFatal = effect.logFatal;
|
|
|
4919
5092
|
* time-sensitive processes.
|
|
4920
5093
|
*
|
|
4921
5094
|
* @example
|
|
5095
|
+
* ```ts
|
|
4922
5096
|
* import { Effect } from "effect"
|
|
4923
5097
|
*
|
|
4924
5098
|
* const program = Effect.gen(function*() {
|
|
@@ -4928,6 +5102,7 @@ const logFatal = exports.logFatal = effect.logFatal;
|
|
|
4928
5102
|
*
|
|
4929
5103
|
* // Effect.runFork(program)
|
|
4930
5104
|
* // timestamp=... level=INFO fiber=#0 message="The job is finished!" myspan=1011ms
|
|
5105
|
+
* ```
|
|
4931
5106
|
*
|
|
4932
5107
|
* @since 2.0.0
|
|
4933
5108
|
* @category Logging
|
|
@@ -4939,6 +5114,7 @@ const withLogSpan = exports.withLogSpan = effect.withLogSpan;
|
|
|
4939
5114
|
* to log messages, making them more informative and easier to trace.
|
|
4940
5115
|
*
|
|
4941
5116
|
* @example
|
|
5117
|
+
* ```ts
|
|
4942
5118
|
* import { Effect } from "effect"
|
|
4943
5119
|
*
|
|
4944
5120
|
* const program = Effect.gen(function*() {
|
|
@@ -4949,6 +5125,7 @@ const withLogSpan = exports.withLogSpan = effect.withLogSpan;
|
|
|
4949
5125
|
* // Effect.runFork(program)
|
|
4950
5126
|
* // timestamp=... level=INFO fiber=#0 message=message1 key=value
|
|
4951
5127
|
* // timestamp=... level=INFO fiber=#0 message=message2 key=value
|
|
5128
|
+
* ```
|
|
4952
5129
|
*
|
|
4953
5130
|
* @since 2.0.0
|
|
4954
5131
|
* @category Logging
|
|
@@ -4961,6 +5138,7 @@ const annotateLogs = exports.annotateLogs = effect.annotateLogs;
|
|
|
4961
5138
|
* defined `Scope`, making it easier to manage context-specific logging.
|
|
4962
5139
|
*
|
|
4963
5140
|
* @example
|
|
5141
|
+
* ```ts
|
|
4964
5142
|
* import { Effect } from "effect"
|
|
4965
5143
|
*
|
|
4966
5144
|
* const program = Effect.gen(function*() {
|
|
@@ -4975,6 +5153,7 @@ const annotateLogs = exports.annotateLogs = effect.annotateLogs;
|
|
|
4975
5153
|
* // timestamp=... level=INFO fiber=#0 message=message1 key=value
|
|
4976
5154
|
* // timestamp=... level=INFO fiber=#0 message=message2 key=value
|
|
4977
5155
|
* // timestamp=... level=INFO fiber=#0 message="no annotations again"
|
|
5156
|
+
* ```
|
|
4978
5157
|
*
|
|
4979
5158
|
* @since 3.1.0
|
|
4980
5159
|
* @category Logging
|
|
@@ -5010,6 +5189,7 @@ const withUnhandledErrorLogLevel = exports.withUnhandledErrorLogLevel = core.wit
|
|
|
5010
5189
|
* @see {@link orDieWith} if you need to customize the error.
|
|
5011
5190
|
*
|
|
5012
5191
|
* @example
|
|
5192
|
+
* ```ts
|
|
5013
5193
|
* // Title: Propagating an Error as a Defect
|
|
5014
5194
|
* import { Effect } from "effect"
|
|
5015
5195
|
*
|
|
@@ -5026,6 +5206,7 @@ const withUnhandledErrorLogLevel = exports.withUnhandledErrorLogLevel = core.wit
|
|
|
5026
5206
|
* // Output:
|
|
5027
5207
|
* // (FiberFailure) Error: Cannot divide by zero
|
|
5028
5208
|
* // ...stack trace...
|
|
5209
|
+
* ```
|
|
5029
5210
|
*
|
|
5030
5211
|
* @since 2.0.0
|
|
5031
5212
|
* @category Converting Failures to Defects
|
|
@@ -5049,6 +5230,7 @@ const orDie = exports.orDie = core.orDie;
|
|
|
5049
5230
|
* @see {@link orDie} if you don't need to customize the error.
|
|
5050
5231
|
*
|
|
5051
5232
|
* @example
|
|
5233
|
+
* ```ts
|
|
5052
5234
|
* // Title: Customizing Defect
|
|
5053
5235
|
* import { Effect } from "effect"
|
|
5054
5236
|
*
|
|
@@ -5068,6 +5250,7 @@ const orDie = exports.orDie = core.orDie;
|
|
|
5068
5250
|
* // Output:
|
|
5069
5251
|
* // (FiberFailure) Error: defect: Cannot divide by zero
|
|
5070
5252
|
* // ...stack trace...
|
|
5253
|
+
* ```
|
|
5071
5254
|
*
|
|
5072
5255
|
* @since 2.0.0
|
|
5073
5256
|
* @category Converting Failures to Defects
|
|
@@ -5084,6 +5267,7 @@ const orDieWith = exports.orDieWith = core.orDieWith;
|
|
|
5084
5267
|
* @see {@link catchAll} if you need to access the error in the fallback effect.
|
|
5085
5268
|
*
|
|
5086
5269
|
* @example
|
|
5270
|
+
* ```ts
|
|
5087
5271
|
* import { Effect } from "effect"
|
|
5088
5272
|
*
|
|
5089
5273
|
* const success = Effect.succeed("success")
|
|
@@ -5099,6 +5283,7 @@ const orDieWith = exports.orDieWith = core.orDieWith;
|
|
|
5099
5283
|
* const program2 = Effect.orElse(failure, () => fallback)
|
|
5100
5284
|
* console.log(Effect.runSync(program2))
|
|
5101
5285
|
* // Output: "fallback"
|
|
5286
|
+
* ```
|
|
5102
5287
|
*
|
|
5103
5288
|
* @since 2.0.0
|
|
5104
5289
|
* @category Fallback
|
|
@@ -5117,6 +5302,7 @@ const orElse = exports.orElse = core.orElse;
|
|
|
5117
5302
|
* @see {@link mapError} if you need to access the error to transform it.
|
|
5118
5303
|
*
|
|
5119
5304
|
* @example
|
|
5305
|
+
* ```ts
|
|
5120
5306
|
* import { Effect } from "effect"
|
|
5121
5307
|
*
|
|
5122
5308
|
* const validate = (age: number): Effect.Effect<number, string> => {
|
|
@@ -5138,6 +5324,7 @@ const orElse = exports.orElse = core.orElse;
|
|
|
5138
5324
|
* // _tag: 'Failure',
|
|
5139
5325
|
* // cause: { _id: 'Cause', _tag: 'Fail', failure: 'invalid age' }
|
|
5140
5326
|
* // }
|
|
5327
|
+
* ```
|
|
5141
5328
|
*
|
|
5142
5329
|
* @since 2.0.0
|
|
5143
5330
|
* @category Fallback
|
|
@@ -5161,6 +5348,7 @@ const orElseFail = exports.orElseFail = effect.orElseFail;
|
|
|
5161
5348
|
* already succeeds, it will remain unchanged.
|
|
5162
5349
|
*
|
|
5163
5350
|
* @example
|
|
5351
|
+
* ```ts
|
|
5164
5352
|
* import { Effect } from "effect"
|
|
5165
5353
|
*
|
|
5166
5354
|
* const validate = (age: number): Effect.Effect<number, string> => {
|
|
@@ -5178,6 +5366,7 @@ const orElseFail = exports.orElseFail = effect.orElseFail;
|
|
|
5178
5366
|
* console.log(Effect.runSyncExit(program))
|
|
5179
5367
|
* // Output:
|
|
5180
5368
|
* // { _id: 'Exit', _tag: 'Success', value: 18 }
|
|
5369
|
+
* ```
|
|
5181
5370
|
*
|
|
5182
5371
|
* @since 2.0.0
|
|
5183
5372
|
* @category Fallback
|
|
@@ -5201,6 +5390,7 @@ const orElseSucceed = exports.orElseSucceed = effect.orElseSucceed;
|
|
|
5201
5390
|
* error.
|
|
5202
5391
|
*
|
|
5203
5392
|
* @example
|
|
5393
|
+
* ```ts
|
|
5204
5394
|
* import { Effect, Console } from "effect"
|
|
5205
5395
|
*
|
|
5206
5396
|
* interface Config {
|
|
@@ -5247,6 +5437,7 @@ const orElseSucceed = exports.orElseSucceed = effect.orElseSucceed;
|
|
|
5247
5437
|
* // Unavailable config for node2
|
|
5248
5438
|
* // Config for node3 found
|
|
5249
5439
|
* // { host: 'node3.example.com', port: 8080, apiKey: '12345-abcde' }
|
|
5440
|
+
* ```
|
|
5250
5441
|
*
|
|
5251
5442
|
* @since 2.0.0
|
|
5252
5443
|
* @category Fallback
|
|
@@ -5378,6 +5569,7 @@ const unsafeMakeLatch = exports.unsafeMakeLatch = circular.unsafeMakeLatch;
|
|
|
5378
5569
|
* @category latch
|
|
5379
5570
|
* @since 3.8.0
|
|
5380
5571
|
* @example
|
|
5572
|
+
* ```ts
|
|
5381
5573
|
* import { Effect } from "effect"
|
|
5382
5574
|
*
|
|
5383
5575
|
* Effect.gen(function*() {
|
|
@@ -5394,6 +5586,7 @@ const unsafeMakeLatch = exports.unsafeMakeLatch = circular.unsafeMakeLatch;
|
|
|
5394
5586
|
* yield* latch.open
|
|
5395
5587
|
* yield* fiber.await
|
|
5396
5588
|
* })
|
|
5589
|
+
* ```
|
|
5397
5590
|
*/
|
|
5398
5591
|
const makeLatch = exports.makeLatch = circular.makeLatch;
|
|
5399
5592
|
/**
|
|
@@ -5410,6 +5603,7 @@ const makeLatch = exports.makeLatch = circular.makeLatch;
|
|
|
5410
5603
|
* `runFork` is a good default choice.
|
|
5411
5604
|
*
|
|
5412
5605
|
* @example
|
|
5606
|
+
* ```ts
|
|
5413
5607
|
* // Title: Running an Effect in the Background
|
|
5414
5608
|
* import { Effect, Console, Schedule, Fiber } from "effect"
|
|
5415
5609
|
*
|
|
@@ -5427,6 +5621,7 @@ const makeLatch = exports.makeLatch = circular.makeLatch;
|
|
|
5427
5621
|
* setTimeout(() => {
|
|
5428
5622
|
* Effect.runFork(Fiber.interrupt(fiber))
|
|
5429
5623
|
* }, 500)
|
|
5624
|
+
* ```
|
|
5430
5625
|
*
|
|
5431
5626
|
* @since 2.0.0
|
|
5432
5627
|
* @category Running Effects
|
|
@@ -5452,11 +5647,13 @@ const runCallback = exports.runCallback = _runtime.unsafeRunEffect;
|
|
|
5452
5647
|
* @see {@link runPromiseExit} for a version that returns an `Exit` type instead of rejecting.
|
|
5453
5648
|
*
|
|
5454
5649
|
* @example
|
|
5650
|
+
* ```ts
|
|
5455
5651
|
* // Title: Running a Successful Effect as a Promise
|
|
5456
5652
|
* import { Effect } from "effect"
|
|
5457
5653
|
*
|
|
5458
5654
|
* Effect.runPromise(Effect.succeed(1)).then(console.log)
|
|
5459
5655
|
* // Output: 1
|
|
5656
|
+
* ```
|
|
5460
5657
|
*
|
|
5461
5658
|
* @example
|
|
5462
5659
|
* //Example: Handling a Failing Effect as a Rejected Promise
|
|
@@ -5487,6 +5684,7 @@ const runPromise = exports.runPromise = _runtime.unsafeRunPromiseEffect;
|
|
|
5487
5684
|
* a `Cause` type.
|
|
5488
5685
|
*
|
|
5489
5686
|
* @example
|
|
5687
|
+
* ```ts
|
|
5490
5688
|
* // Title: Handling Results as Exit
|
|
5491
5689
|
* import { Effect } from "effect"
|
|
5492
5690
|
*
|
|
@@ -5511,6 +5709,7 @@ const runPromise = exports.runPromise = _runtime.unsafeRunPromiseEffect;
|
|
|
5511
5709
|
* // failure: "my error"
|
|
5512
5710
|
* // }
|
|
5513
5711
|
* // }
|
|
5712
|
+
* ```
|
|
5514
5713
|
*
|
|
5515
5714
|
* @since 2.0.0
|
|
5516
5715
|
* @category Running Effects
|
|
@@ -5532,6 +5731,7 @@ const runPromiseExit = exports.runPromiseExit = _runtime.unsafeRunPromiseExitEff
|
|
|
5532
5731
|
* throwing an error.
|
|
5533
5732
|
*
|
|
5534
5733
|
* @example
|
|
5734
|
+
* ```ts
|
|
5535
5735
|
* // Title: Synchronous Logging
|
|
5536
5736
|
* import { Effect } from "effect"
|
|
5537
5737
|
*
|
|
@@ -5545,6 +5745,7 @@ const runPromiseExit = exports.runPromiseExit = _runtime.unsafeRunPromiseExitEff
|
|
|
5545
5745
|
*
|
|
5546
5746
|
* console.log(result)
|
|
5547
5747
|
* // Output: 1
|
|
5748
|
+
* ```
|
|
5548
5749
|
*
|
|
5549
5750
|
* @example
|
|
5550
5751
|
* // Title: Incorrect Usage with Failing or Async Effects
|
|
@@ -5593,6 +5794,7 @@ const runSync = exports.runSync = _runtime.unsafeRunSyncEffect;
|
|
|
5593
5794
|
* resolved synchronously.
|
|
5594
5795
|
*
|
|
5595
5796
|
* @example
|
|
5797
|
+
* ```ts
|
|
5596
5798
|
* // Title: Handling Results as Exit
|
|
5597
5799
|
* import { Effect } from "effect"
|
|
5598
5800
|
*
|
|
@@ -5615,6 +5817,7 @@ const runSync = exports.runSync = _runtime.unsafeRunSyncEffect;
|
|
|
5615
5817
|
* // failure: "my error"
|
|
5616
5818
|
* // }
|
|
5617
5819
|
* // }
|
|
5820
|
+
* ```
|
|
5618
5821
|
*
|
|
5619
5822
|
* @example
|
|
5620
5823
|
* // Title: Asynchronous Operation Resulting in Die
|
|
@@ -5655,6 +5858,7 @@ const runSyncExit = exports.runSyncExit = _runtime.unsafeRunSyncExitEffect;
|
|
|
5655
5858
|
* @see {@link zip} for a version that stops at the first error.
|
|
5656
5859
|
*
|
|
5657
5860
|
* @example
|
|
5861
|
+
* ```ts
|
|
5658
5862
|
* import { Effect, Console } from "effect"
|
|
5659
5863
|
*
|
|
5660
5864
|
* const task1 = Console.log("task1").pipe(Effect.as(1))
|
|
@@ -5682,6 +5886,7 @@ const runSyncExit = exports.runSyncExit = _runtime.unsafeRunSyncExitEffect;
|
|
|
5682
5886
|
* // right: { _id: 'Cause', _tag: 'Fail', failure: 'Oh no!' }
|
|
5683
5887
|
* // }
|
|
5684
5888
|
* // }
|
|
5889
|
+
* ```
|
|
5685
5890
|
*
|
|
5686
5891
|
* @since 2.0.0
|
|
5687
5892
|
* @category Error Accumulation
|
|
@@ -5710,6 +5915,7 @@ const validateWith = exports.validateWith = fiberRuntime.validateWith;
|
|
|
5710
5915
|
* @see {@link validate} for a version that accumulates errors.
|
|
5711
5916
|
*
|
|
5712
5917
|
* @example
|
|
5918
|
+
* ```ts
|
|
5713
5919
|
* // Title: Combining Two Effects Sequentially
|
|
5714
5920
|
* import { Effect } from "effect"
|
|
5715
5921
|
*
|
|
@@ -5733,6 +5939,7 @@ const validateWith = exports.validateWith = fiberRuntime.validateWith;
|
|
|
5733
5939
|
* // timestamp=... level=INFO fiber=#0 message="task1 done"
|
|
5734
5940
|
* // timestamp=... level=INFO fiber=#0 message="task2 done"
|
|
5735
5941
|
* // [ 1, 'hello' ]
|
|
5942
|
+
* ```
|
|
5736
5943
|
*
|
|
5737
5944
|
* @example
|
|
5738
5945
|
* // Title: Combining Two Effects Concurrently
|
|
@@ -5778,6 +5985,7 @@ const zip = exports.zip = fiberRuntime.zipOptions;
|
|
|
5778
5985
|
* @see {@link zipRight} for a version that returns the result of the second effect.
|
|
5779
5986
|
*
|
|
5780
5987
|
* @example
|
|
5988
|
+
* ```ts
|
|
5781
5989
|
* import { Effect } from "effect"
|
|
5782
5990
|
*
|
|
5783
5991
|
* const task1 = Effect.succeed(1).pipe(
|
|
@@ -5796,6 +6004,7 @@ const zip = exports.zip = fiberRuntime.zipOptions;
|
|
|
5796
6004
|
* // timestamp=... level=INFO fiber=#0 message="task1 done"
|
|
5797
6005
|
* // timestamp=... level=INFO fiber=#0 message="task2 done"
|
|
5798
6006
|
* // 1
|
|
6007
|
+
* ```
|
|
5799
6008
|
*
|
|
5800
6009
|
* @since 2.0.0
|
|
5801
6010
|
* @category Zipping
|
|
@@ -5819,6 +6028,7 @@ const zipLeft = exports.zipLeft = fiberRuntime.zipLeftOptions;
|
|
|
5819
6028
|
* @see {@link zipLeft} for a version that returns the result of the first effect.
|
|
5820
6029
|
*
|
|
5821
6030
|
* @example
|
|
6031
|
+
* ```ts
|
|
5822
6032
|
* import { Effect } from "effect"
|
|
5823
6033
|
*
|
|
5824
6034
|
* const task1 = Effect.succeed(1).pipe(
|
|
@@ -5837,6 +6047,7 @@ const zipLeft = exports.zipLeft = fiberRuntime.zipLeftOptions;
|
|
|
5837
6047
|
* // timestamp=... level=INFO fiber=#0 message="task1 done"
|
|
5838
6048
|
* // timestamp=... level=INFO fiber=#0 message="task2 done"
|
|
5839
6049
|
* // hello
|
|
6050
|
+
* ```
|
|
5840
6051
|
*
|
|
5841
6052
|
* @since 2.0.0
|
|
5842
6053
|
* @category Zipping
|
|
@@ -5858,6 +6069,7 @@ const zipRight = exports.zipRight = fiberRuntime.zipRightOptions;
|
|
|
5858
6069
|
* use the `{ concurrent: true }` option.
|
|
5859
6070
|
*
|
|
5860
6071
|
* @example
|
|
6072
|
+
* ```ts
|
|
5861
6073
|
* // Title: Combining Effects with a Custom Function
|
|
5862
6074
|
* import { Effect } from "effect"
|
|
5863
6075
|
*
|
|
@@ -5882,6 +6094,7 @@ const zipRight = exports.zipRight = fiberRuntime.zipRightOptions;
|
|
|
5882
6094
|
* // timestamp=... level=INFO fiber=#3 message="task1 done"
|
|
5883
6095
|
* // timestamp=... level=INFO fiber=#2 message="task2 done"
|
|
5884
6096
|
* // 6
|
|
6097
|
+
* ```
|
|
5885
6098
|
*
|
|
5886
6099
|
* @since 2.0.0
|
|
5887
6100
|
* @category Zipping
|
|
@@ -5958,6 +6171,7 @@ const withTracerScoped = exports.withTracerScoped = fiberRuntime.withTracerScope
|
|
|
5958
6171
|
* @since 2.0.0
|
|
5959
6172
|
* @category Tracing
|
|
5960
6173
|
* @example
|
|
6174
|
+
* ```ts
|
|
5961
6175
|
* import { Effect } from "effect"
|
|
5962
6176
|
*
|
|
5963
6177
|
* Effect.succeed(42).pipe(
|
|
@@ -5965,6 +6179,7 @@ const withTracerScoped = exports.withTracerScoped = fiberRuntime.withTracerScope
|
|
|
5965
6179
|
* // the span will not be registered with the tracer
|
|
5966
6180
|
* Effect.withTracerEnabled(false)
|
|
5967
6181
|
* )
|
|
6182
|
+
* ```
|
|
5968
6183
|
*/
|
|
5969
6184
|
const withTracerEnabled = exports.withTracerEnabled = core.withTracerEnabled;
|
|
5970
6185
|
/**
|
|
@@ -6055,6 +6270,7 @@ const withSpan = exports.withSpan = effect.withSpan;
|
|
|
6055
6270
|
* @since 3.2.0
|
|
6056
6271
|
* @category Tracing
|
|
6057
6272
|
* @example
|
|
6273
|
+
* ```ts
|
|
6058
6274
|
* import { Effect } from "effect"
|
|
6059
6275
|
*
|
|
6060
6276
|
* const getTodo = Effect.functionWithSpan({
|
|
@@ -6064,6 +6280,7 @@ const withSpan = exports.withSpan = effect.withSpan;
|
|
|
6064
6280
|
* attributes: { id }
|
|
6065
6281
|
* })
|
|
6066
6282
|
* })
|
|
6283
|
+
* ```
|
|
6067
6284
|
*/
|
|
6068
6285
|
const functionWithSpan = exports.functionWithSpan = effect.functionWithSpan;
|
|
6069
6286
|
/**
|
|
@@ -6094,6 +6311,7 @@ const withParentSpan = exports.withParentSpan = effect.withParentSpan;
|
|
|
6094
6311
|
* value.
|
|
6095
6312
|
*
|
|
6096
6313
|
* @example
|
|
6314
|
+
* ```ts
|
|
6097
6315
|
* import { Effect } from "effect"
|
|
6098
6316
|
*
|
|
6099
6317
|
* // ┌─── Effect<number, NoSuchElementException, never>
|
|
@@ -6119,6 +6337,7 @@ const withParentSpan = exports.withParentSpan = effect.withParentSpan;
|
|
|
6119
6337
|
* // failure: { _tag: 'NoSuchElementException' }
|
|
6120
6338
|
* // }
|
|
6121
6339
|
* // }
|
|
6340
|
+
* ```
|
|
6122
6341
|
*
|
|
6123
6342
|
* @since 2.0.0
|
|
6124
6343
|
* @category Optional Wrapping
|
|
@@ -6136,6 +6355,7 @@ const fromNullable = exports.fromNullable = effect.fromNullable;
|
|
|
6136
6355
|
* unchanged.
|
|
6137
6356
|
*
|
|
6138
6357
|
* @example
|
|
6358
|
+
* ```ts
|
|
6139
6359
|
* import { Effect } from "effect"
|
|
6140
6360
|
*
|
|
6141
6361
|
* // ┌─── Effect<number, NoSuchElementException, never>
|
|
@@ -6159,6 +6379,7 @@ const fromNullable = exports.fromNullable = effect.fromNullable;
|
|
|
6159
6379
|
*
|
|
6160
6380
|
* Effect.runPromise(option2).then(console.log)
|
|
6161
6381
|
* // Output: { _tag: 'None' }
|
|
6382
|
+
* ```
|
|
6162
6383
|
*
|
|
6163
6384
|
* @since 2.0.0
|
|
6164
6385
|
* @category Optional Wrapping
|
|
@@ -6192,6 +6413,7 @@ const makeTagProxy = TagClass => {
|
|
|
6192
6413
|
};
|
|
6193
6414
|
/**
|
|
6194
6415
|
* @example
|
|
6416
|
+
* ```ts
|
|
6195
6417
|
* import { Effect, Layer } from "effect"
|
|
6196
6418
|
*
|
|
6197
6419
|
* class MapTag extends Effect.Tag("MapTag")<MapTag, Map<string, string>>() {
|
|
@@ -6200,6 +6422,7 @@ const makeTagProxy = TagClass => {
|
|
|
6200
6422
|
* Effect.sync(() => new Map())
|
|
6201
6423
|
* )
|
|
6202
6424
|
* }
|
|
6425
|
+
* ```
|
|
6203
6426
|
*
|
|
6204
6427
|
* @since 2.0.0
|
|
6205
6428
|
* @category Context
|
|
@@ -6226,6 +6449,7 @@ const Tag = id => () => {
|
|
|
6226
6449
|
};
|
|
6227
6450
|
/**
|
|
6228
6451
|
* @example
|
|
6452
|
+
* ```ts
|
|
6229
6453
|
* import { Effect } from 'effect';
|
|
6230
6454
|
*
|
|
6231
6455
|
* class Prefix extends Effect.Service<Prefix>()("Prefix", {
|
|
@@ -6245,6 +6469,7 @@ const Tag = id => () => {
|
|
|
6245
6469
|
* }),
|
|
6246
6470
|
* dependencies: [Prefix.Default]
|
|
6247
6471
|
* }) {}
|
|
6472
|
+
* ```
|
|
6248
6473
|
*
|
|
6249
6474
|
* @since 3.9.0
|
|
6250
6475
|
* @category Context
|
|
@@ -6335,5 +6560,72 @@ const Service = function () {
|
|
|
6335
6560
|
return proxy === true ? makeTagProxy(TagClass) : TagClass;
|
|
6336
6561
|
};
|
|
6337
6562
|
};
|
|
6563
|
+
/**
|
|
6564
|
+
* Creates a function that returns an Effect which is automatically traced with a span pointing to the call site.
|
|
6565
|
+
*
|
|
6566
|
+
* The function can be created both using a generator function that can yield effects or using a normal function.
|
|
6567
|
+
*
|
|
6568
|
+
* @since 3.11.0
|
|
6569
|
+
* @category function
|
|
6570
|
+
*
|
|
6571
|
+
* @example
|
|
6572
|
+
* import { Effect } from "effect"
|
|
6573
|
+
*
|
|
6574
|
+
* const logExample = Effect.fn("logExample")(
|
|
6575
|
+
* function*<N extends number>(n: N) {
|
|
6576
|
+
* yield* Effect.annotateCurrentSpan("n", n)
|
|
6577
|
+
* yield* Effect.logInfo(`got: ${n}`)
|
|
6578
|
+
* yield* Effect.fail(new Error())
|
|
6579
|
+
* },
|
|
6580
|
+
* Effect.delay("1 second")
|
|
6581
|
+
* )
|
|
6582
|
+
*
|
|
6583
|
+
* Effect.runFork(
|
|
6584
|
+
* // this location is printed on the stack trace of the following `Effect.logError`
|
|
6585
|
+
* logExample(100).pipe(
|
|
6586
|
+
* Effect.catchAllCause(Effect.logError)
|
|
6587
|
+
* )
|
|
6588
|
+
* )
|
|
6589
|
+
*/
|
|
6338
6590
|
exports.Service = Service;
|
|
6591
|
+
const fn = (name, options) => (body, ...pipeables) => {
|
|
6592
|
+
return function (...args) {
|
|
6593
|
+
const limit = Error.stackTraceLimit;
|
|
6594
|
+
Error.stackTraceLimit = 2;
|
|
6595
|
+
const error = new Error();
|
|
6596
|
+
Error.stackTraceLimit = limit;
|
|
6597
|
+
let cache = false;
|
|
6598
|
+
const captureStackTrace = () => {
|
|
6599
|
+
if (cache !== false) {
|
|
6600
|
+
return cache;
|
|
6601
|
+
}
|
|
6602
|
+
if (error.stack) {
|
|
6603
|
+
const stack = error.stack.trim().split("\n");
|
|
6604
|
+
cache = stack.slice(2).join("\n").trim();
|
|
6605
|
+
return cache;
|
|
6606
|
+
}
|
|
6607
|
+
};
|
|
6608
|
+
let effect;
|
|
6609
|
+
let fnError = undefined;
|
|
6610
|
+
try {
|
|
6611
|
+
effect = (0, _Utils.isGeneratorFunction)(body) ? gen(() => (0, _Utils.internalCall)(() => body.apply(this, args))) : body.apply(this, args);
|
|
6612
|
+
} catch (error) {
|
|
6613
|
+
fnError = error;
|
|
6614
|
+
effect = die(error);
|
|
6615
|
+
}
|
|
6616
|
+
try {
|
|
6617
|
+
for (const x of pipeables) {
|
|
6618
|
+
effect = x(effect);
|
|
6619
|
+
}
|
|
6620
|
+
} catch (error) {
|
|
6621
|
+
effect = fnError ? failCause(internalCause.sequential(internalCause.die(fnError), internalCause.die(error))) : die(error);
|
|
6622
|
+
}
|
|
6623
|
+
const opts = options && "captureStackTrace" in options ? options : {
|
|
6624
|
+
captureStackTrace,
|
|
6625
|
+
...options
|
|
6626
|
+
};
|
|
6627
|
+
return withSpan(effect, name, opts);
|
|
6628
|
+
};
|
|
6629
|
+
};
|
|
6630
|
+
exports.fn = fn;
|
|
6339
6631
|
//# sourceMappingURL=Effect.js.map
|