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/dts/Option.d.ts
CHANGED
|
@@ -110,11 +110,13 @@ export declare const some: <A>(value: A) => Option<A>;
|
|
|
110
110
|
* @param input - The value to check.
|
|
111
111
|
*
|
|
112
112
|
* @example
|
|
113
|
+
* ```ts
|
|
113
114
|
* import { Option } from "effect"
|
|
114
115
|
*
|
|
115
116
|
* assert.deepStrictEqual(Option.isOption(Option.some(1)), true)
|
|
116
117
|
* assert.deepStrictEqual(Option.isOption(Option.none()), true)
|
|
117
118
|
* assert.deepStrictEqual(Option.isOption({}), false)
|
|
119
|
+
* ```
|
|
118
120
|
*
|
|
119
121
|
* @category guards
|
|
120
122
|
* @since 2.0.0
|
|
@@ -126,10 +128,12 @@ export declare const isOption: (input: unknown) => input is Option<unknown>;
|
|
|
126
128
|
* @param self - The `Option` to check.
|
|
127
129
|
*
|
|
128
130
|
* @example
|
|
131
|
+
* ```ts
|
|
129
132
|
* import { Option } from "effect"
|
|
130
133
|
*
|
|
131
134
|
* assert.deepStrictEqual(Option.isNone(Option.some(1)), false)
|
|
132
135
|
* assert.deepStrictEqual(Option.isNone(Option.none()), true)
|
|
136
|
+
* ```
|
|
133
137
|
*
|
|
134
138
|
* @category guards
|
|
135
139
|
* @since 2.0.0
|
|
@@ -141,10 +145,12 @@ export declare const isNone: <A>(self: Option<A>) => self is None<A>;
|
|
|
141
145
|
* @param self - The `Option` to check.
|
|
142
146
|
*
|
|
143
147
|
* @example
|
|
148
|
+
* ```ts
|
|
144
149
|
* import { Option } from "effect"
|
|
145
150
|
*
|
|
146
151
|
* assert.deepStrictEqual(Option.isSome(Option.some(1)), true)
|
|
147
152
|
* assert.deepStrictEqual(Option.isSome(Option.none()), false)
|
|
153
|
+
* ```
|
|
148
154
|
*
|
|
149
155
|
* @category guards
|
|
150
156
|
* @since 2.0.0
|
|
@@ -159,6 +165,7 @@ export declare const isSome: <A>(self: Option<A>) => self is Some<A>;
|
|
|
159
165
|
* @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned
|
|
160
166
|
*
|
|
161
167
|
* @example
|
|
168
|
+
* ```ts
|
|
162
169
|
* import { pipe, Option } from "effect"
|
|
163
170
|
*
|
|
164
171
|
* assert.deepStrictEqual(
|
|
@@ -170,6 +177,7 @@ export declare const isSome: <A>(self: Option<A>) => self is Some<A>;
|
|
|
170
177
|
* pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
|
|
171
178
|
* 'a none'
|
|
172
179
|
* )
|
|
180
|
+
* ```
|
|
173
181
|
*
|
|
174
182
|
* @category pattern matching
|
|
175
183
|
* @since 2.0.0
|
|
@@ -184,6 +192,7 @@ export declare const match: {
|
|
|
184
192
|
* @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned
|
|
185
193
|
*
|
|
186
194
|
* @example
|
|
195
|
+
* ```ts
|
|
187
196
|
* import { pipe, Option } from "effect"
|
|
188
197
|
*
|
|
189
198
|
* assert.deepStrictEqual(
|
|
@@ -195,6 +204,7 @@ export declare const match: {
|
|
|
195
204
|
* pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
|
|
196
205
|
* 'a none'
|
|
197
206
|
* )
|
|
207
|
+
* ```
|
|
198
208
|
*
|
|
199
209
|
* @category pattern matching
|
|
200
210
|
* @since 2.0.0
|
|
@@ -212,6 +222,7 @@ export declare const match: {
|
|
|
212
222
|
* @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned
|
|
213
223
|
*
|
|
214
224
|
* @example
|
|
225
|
+
* ```ts
|
|
215
226
|
* import { pipe, Option } from "effect"
|
|
216
227
|
*
|
|
217
228
|
* assert.deepStrictEqual(
|
|
@@ -223,6 +234,7 @@ export declare const match: {
|
|
|
223
234
|
* pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
|
|
224
235
|
* 'a none'
|
|
225
236
|
* )
|
|
237
|
+
* ```
|
|
226
238
|
*
|
|
227
239
|
* @category pattern matching
|
|
228
240
|
* @since 2.0.0
|
|
@@ -237,6 +249,7 @@ export declare const match: {
|
|
|
237
249
|
* This function ensures that a type guard definition is type-safe.
|
|
238
250
|
*
|
|
239
251
|
* @example
|
|
252
|
+
* ```ts
|
|
240
253
|
* import { Option } from "effect"
|
|
241
254
|
*
|
|
242
255
|
* const parsePositive = (n: number): Option.Option<number> =>
|
|
@@ -246,6 +259,7 @@ export declare const match: {
|
|
|
246
259
|
*
|
|
247
260
|
* assert.deepStrictEqual(isPositive(1), true)
|
|
248
261
|
* assert.deepStrictEqual(isPositive(-1), false)
|
|
262
|
+
* ```
|
|
249
263
|
*
|
|
250
264
|
* @category conversions
|
|
251
265
|
* @since 2.0.0
|
|
@@ -258,10 +272,12 @@ export declare const toRefinement: <A, B extends A>(f: (a: A) => Option<B>) => (
|
|
|
258
272
|
* @param collection - The `Iterable` to be converted to an `Option`.
|
|
259
273
|
*
|
|
260
274
|
* @example
|
|
275
|
+
* ```ts
|
|
261
276
|
* import { Option } from "effect"
|
|
262
277
|
*
|
|
263
278
|
* assert.deepStrictEqual(Option.fromIterable([1, 2, 3]), Option.some(1))
|
|
264
279
|
* assert.deepStrictEqual(Option.fromIterable([]), Option.none())
|
|
280
|
+
* ```
|
|
265
281
|
*
|
|
266
282
|
* @category constructors
|
|
267
283
|
* @since 2.0.0
|
|
@@ -271,10 +287,12 @@ export declare const fromIterable: <A>(collection: Iterable<A>) => Option<A>;
|
|
|
271
287
|
* Converts a `Either` to an `Option` discarding the error.
|
|
272
288
|
*
|
|
273
289
|
* @example
|
|
290
|
+
* ```ts
|
|
274
291
|
* import { Option, Either } from "effect"
|
|
275
292
|
*
|
|
276
293
|
* assert.deepStrictEqual(Option.getRight(Either.right('ok')), Option.some('ok'))
|
|
277
294
|
* assert.deepStrictEqual(Option.getRight(Either.left('err')), Option.none())
|
|
295
|
+
* ```
|
|
278
296
|
*
|
|
279
297
|
* @category conversions
|
|
280
298
|
* @since 2.0.0
|
|
@@ -284,10 +302,12 @@ export declare const getRight: <R, L>(self: Either<R, L>) => Option<R>;
|
|
|
284
302
|
* Converts a `Either` to an `Option` discarding the value.
|
|
285
303
|
*
|
|
286
304
|
* @example
|
|
305
|
+
* ```ts
|
|
287
306
|
* import { Option, Either } from "effect"
|
|
288
307
|
*
|
|
289
308
|
* assert.deepStrictEqual(Option.getLeft(Either.right("ok")), Option.none())
|
|
290
309
|
* assert.deepStrictEqual(Option.getLeft(Either.left("a")), Option.some("a"))
|
|
310
|
+
* ```
|
|
291
311
|
*
|
|
292
312
|
* @category conversions
|
|
293
313
|
* @since 2.0.0
|
|
@@ -300,10 +320,12 @@ export declare const getLeft: <R, L>(self: Either<R, L>) => Option<L>;
|
|
|
300
320
|
* @param onNone - Function that returns the default value to return if the `Option` is `None`.
|
|
301
321
|
*
|
|
302
322
|
* @example
|
|
323
|
+
* ```ts
|
|
303
324
|
* import { pipe, Option } from "effect"
|
|
304
325
|
*
|
|
305
326
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
|
|
306
327
|
* assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
|
|
328
|
+
* ```
|
|
307
329
|
*
|
|
308
330
|
* @category getters
|
|
309
331
|
* @since 2.0.0
|
|
@@ -316,10 +338,12 @@ export declare const getOrElse: {
|
|
|
316
338
|
* @param onNone - Function that returns the default value to return if the `Option` is `None`.
|
|
317
339
|
*
|
|
318
340
|
* @example
|
|
341
|
+
* ```ts
|
|
319
342
|
* import { pipe, Option } from "effect"
|
|
320
343
|
*
|
|
321
344
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
|
|
322
345
|
* assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
|
|
346
|
+
* ```
|
|
323
347
|
*
|
|
324
348
|
* @category getters
|
|
325
349
|
* @since 2.0.0
|
|
@@ -332,10 +356,12 @@ export declare const getOrElse: {
|
|
|
332
356
|
* @param onNone - Function that returns the default value to return if the `Option` is `None`.
|
|
333
357
|
*
|
|
334
358
|
* @example
|
|
359
|
+
* ```ts
|
|
335
360
|
* import { pipe, Option } from "effect"
|
|
336
361
|
*
|
|
337
362
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
|
|
338
363
|
* assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
|
|
364
|
+
* ```
|
|
339
365
|
*
|
|
340
366
|
* @category getters
|
|
341
367
|
* @since 2.0.0
|
|
@@ -349,6 +375,7 @@ export declare const getOrElse: {
|
|
|
349
375
|
* @param that - The `Option` to return if `self` is `None`.
|
|
350
376
|
*
|
|
351
377
|
* @example
|
|
378
|
+
* ```ts
|
|
352
379
|
* import { pipe, Option } from "effect"
|
|
353
380
|
*
|
|
354
381
|
* assert.deepStrictEqual(
|
|
@@ -379,6 +406,7 @@ export declare const getOrElse: {
|
|
|
379
406
|
* ),
|
|
380
407
|
* Option.some('a')
|
|
381
408
|
* )
|
|
409
|
+
* ```
|
|
382
410
|
*
|
|
383
411
|
* @category error handling
|
|
384
412
|
* @since 2.0.0
|
|
@@ -391,6 +419,7 @@ export declare const orElse: {
|
|
|
391
419
|
* @param that - The `Option` to return if `self` is `None`.
|
|
392
420
|
*
|
|
393
421
|
* @example
|
|
422
|
+
* ```ts
|
|
394
423
|
* import { pipe, Option } from "effect"
|
|
395
424
|
*
|
|
396
425
|
* assert.deepStrictEqual(
|
|
@@ -421,6 +450,7 @@ export declare const orElse: {
|
|
|
421
450
|
* ),
|
|
422
451
|
* Option.some('a')
|
|
423
452
|
* )
|
|
453
|
+
* ```
|
|
424
454
|
*
|
|
425
455
|
* @category error handling
|
|
426
456
|
* @since 2.0.0
|
|
@@ -433,6 +463,7 @@ export declare const orElse: {
|
|
|
433
463
|
* @param that - The `Option` to return if `self` is `None`.
|
|
434
464
|
*
|
|
435
465
|
* @example
|
|
466
|
+
* ```ts
|
|
436
467
|
* import { pipe, Option } from "effect"
|
|
437
468
|
*
|
|
438
469
|
* assert.deepStrictEqual(
|
|
@@ -463,6 +494,7 @@ export declare const orElse: {
|
|
|
463
494
|
* ),
|
|
464
495
|
* Option.some('a')
|
|
465
496
|
* )
|
|
497
|
+
* ```
|
|
466
498
|
*
|
|
467
499
|
* @category error handling
|
|
468
500
|
* @since 2.0.0
|
|
@@ -476,6 +508,7 @@ export declare const orElse: {
|
|
|
476
508
|
* @param onNone - Function that returns the default value to return if the `Option` is `None`.
|
|
477
509
|
*
|
|
478
510
|
* @example
|
|
511
|
+
* ```ts
|
|
479
512
|
* import { pipe, Option } from "effect"
|
|
480
513
|
*
|
|
481
514
|
* assert.deepStrictEqual(
|
|
@@ -492,6 +525,7 @@ export declare const orElse: {
|
|
|
492
525
|
* ),
|
|
493
526
|
* Option.some('a')
|
|
494
527
|
* )
|
|
528
|
+
* ```
|
|
495
529
|
*
|
|
496
530
|
* @category error handling
|
|
497
531
|
* @since 2.0.0
|
|
@@ -504,6 +538,7 @@ export declare const orElseSome: {
|
|
|
504
538
|
* @param onNone - Function that returns the default value to return if the `Option` is `None`.
|
|
505
539
|
*
|
|
506
540
|
* @example
|
|
541
|
+
* ```ts
|
|
507
542
|
* import { pipe, Option } from "effect"
|
|
508
543
|
*
|
|
509
544
|
* assert.deepStrictEqual(
|
|
@@ -520,6 +555,7 @@ export declare const orElseSome: {
|
|
|
520
555
|
* ),
|
|
521
556
|
* Option.some('a')
|
|
522
557
|
* )
|
|
558
|
+
* ```
|
|
523
559
|
*
|
|
524
560
|
* @category error handling
|
|
525
561
|
* @since 2.0.0
|
|
@@ -532,6 +568,7 @@ export declare const orElseSome: {
|
|
|
532
568
|
* @param onNone - Function that returns the default value to return if the `Option` is `None`.
|
|
533
569
|
*
|
|
534
570
|
* @example
|
|
571
|
+
* ```ts
|
|
535
572
|
* import { pipe, Option } from "effect"
|
|
536
573
|
*
|
|
537
574
|
* assert.deepStrictEqual(
|
|
@@ -548,6 +585,7 @@ export declare const orElseSome: {
|
|
|
548
585
|
* ),
|
|
549
586
|
* Option.some('a')
|
|
550
587
|
* )
|
|
588
|
+
* ```
|
|
551
589
|
*
|
|
552
590
|
* @category error handling
|
|
553
591
|
* @since 2.0.0
|
|
@@ -600,9 +638,11 @@ export declare const orElseEither: {
|
|
|
600
638
|
* @param collection - An iterable collection of `Option` to be searched.
|
|
601
639
|
*
|
|
602
640
|
* @example
|
|
641
|
+
* ```ts
|
|
603
642
|
* import { Option } from "effect"
|
|
604
643
|
*
|
|
605
644
|
* assert.deepStrictEqual(Option.firstSomeOf([Option.none(), Option.some(1), Option.some(2)]), Option.some(1))
|
|
645
|
+
* ```
|
|
606
646
|
*
|
|
607
647
|
* @category error handling
|
|
608
648
|
* @since 2.0.0
|
|
@@ -615,11 +655,13 @@ export declare const firstSomeOf: <T, C extends Iterable<Option<T>> = Iterable<O
|
|
|
615
655
|
* @param nullableValue - The nullable value to be converted to an `Option`.
|
|
616
656
|
*
|
|
617
657
|
* @example
|
|
658
|
+
* ```ts
|
|
618
659
|
* import { Option } from "effect"
|
|
619
660
|
*
|
|
620
661
|
* assert.deepStrictEqual(Option.fromNullable(undefined), Option.none())
|
|
621
662
|
* assert.deepStrictEqual(Option.fromNullable(null), Option.none())
|
|
622
663
|
* assert.deepStrictEqual(Option.fromNullable(1), Option.some(1))
|
|
664
|
+
* ```
|
|
623
665
|
*
|
|
624
666
|
* @category conversions
|
|
625
667
|
* @since 2.0.0
|
|
@@ -629,6 +671,7 @@ export declare const fromNullable: <A>(nullableValue: A) => Option<NonNullable<A
|
|
|
629
671
|
* This API is useful for lifting a function that returns `null` or `undefined` into the `Option` context.
|
|
630
672
|
*
|
|
631
673
|
* @example
|
|
674
|
+
* ```ts
|
|
632
675
|
* import { Option } from "effect"
|
|
633
676
|
*
|
|
634
677
|
* const parse = (s: string): number | undefined => {
|
|
@@ -640,6 +683,7 @@ export declare const fromNullable: <A>(nullableValue: A) => Option<NonNullable<A
|
|
|
640
683
|
*
|
|
641
684
|
* assert.deepStrictEqual(parseOption('1'), Option.some(1))
|
|
642
685
|
* assert.deepStrictEqual(parseOption('not a number'), Option.none())
|
|
686
|
+
* ```
|
|
643
687
|
*
|
|
644
688
|
* @category conversions
|
|
645
689
|
* @since 2.0.0
|
|
@@ -651,10 +695,12 @@ export declare const liftNullable: <A extends ReadonlyArray<unknown>, B>(f: (...
|
|
|
651
695
|
* @param self - The `Option` to extract the value from.
|
|
652
696
|
*
|
|
653
697
|
* @example
|
|
698
|
+
* ```ts
|
|
654
699
|
* import { Option } from "effect"
|
|
655
700
|
*
|
|
656
701
|
* assert.deepStrictEqual(Option.getOrNull(Option.some(1)), 1)
|
|
657
702
|
* assert.deepStrictEqual(Option.getOrNull(Option.none()), null)
|
|
703
|
+
* ```
|
|
658
704
|
*
|
|
659
705
|
* @category getters
|
|
660
706
|
* @since 2.0.0
|
|
@@ -666,10 +712,12 @@ export declare const getOrNull: <A>(self: Option<A>) => A | null;
|
|
|
666
712
|
* @param self - The `Option` to extract the value from.
|
|
667
713
|
*
|
|
668
714
|
* @example
|
|
715
|
+
* ```ts
|
|
669
716
|
* import { Option } from "effect"
|
|
670
717
|
*
|
|
671
718
|
* assert.deepStrictEqual(Option.getOrUndefined(Option.some(1)), 1)
|
|
672
719
|
* assert.deepStrictEqual(Option.getOrUndefined(Option.none()), undefined)
|
|
720
|
+
* ```
|
|
673
721
|
*
|
|
674
722
|
* @category getters
|
|
675
723
|
* @since 2.0.0
|
|
@@ -684,12 +732,14 @@ export declare const getOrUndefined: <A>(self: Option<A>) => A | undefined;
|
|
|
684
732
|
* @param f - the function that can throw exceptions.
|
|
685
733
|
*
|
|
686
734
|
* @example
|
|
735
|
+
* ```ts
|
|
687
736
|
* import { Option } from "effect"
|
|
688
737
|
*
|
|
689
738
|
* const parse = Option.liftThrowable(JSON.parse)
|
|
690
739
|
*
|
|
691
740
|
* assert.deepStrictEqual(parse("1"), Option.some(1))
|
|
692
741
|
* assert.deepStrictEqual(parse(""), Option.none())
|
|
742
|
+
* ```
|
|
693
743
|
*
|
|
694
744
|
* @category conversions
|
|
695
745
|
* @since 2.0.0
|
|
@@ -704,6 +754,7 @@ export declare const liftThrowable: <A extends ReadonlyArray<unknown>, B>(f: (..
|
|
|
704
754
|
* @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
|
|
705
755
|
*
|
|
706
756
|
* @example
|
|
757
|
+
* ```ts
|
|
707
758
|
* import { Option } from "effect"
|
|
708
759
|
*
|
|
709
760
|
* assert.deepStrictEqual(
|
|
@@ -711,6 +762,7 @@ export declare const liftThrowable: <A extends ReadonlyArray<unknown>, B>(f: (..
|
|
|
711
762
|
* 1
|
|
712
763
|
* )
|
|
713
764
|
* assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
|
|
765
|
+
* ```
|
|
714
766
|
*
|
|
715
767
|
* @category conversions
|
|
716
768
|
* @since 2.0.0
|
|
@@ -725,6 +777,7 @@ export declare const getOrThrowWith: {
|
|
|
725
777
|
* @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
|
|
726
778
|
*
|
|
727
779
|
* @example
|
|
780
|
+
* ```ts
|
|
728
781
|
* import { Option } from "effect"
|
|
729
782
|
*
|
|
730
783
|
* assert.deepStrictEqual(
|
|
@@ -732,6 +785,7 @@ export declare const getOrThrowWith: {
|
|
|
732
785
|
* 1
|
|
733
786
|
* )
|
|
734
787
|
* assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
|
|
788
|
+
* ```
|
|
735
789
|
*
|
|
736
790
|
* @category conversions
|
|
737
791
|
* @since 2.0.0
|
|
@@ -746,6 +800,7 @@ export declare const getOrThrowWith: {
|
|
|
746
800
|
* @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
|
|
747
801
|
*
|
|
748
802
|
* @example
|
|
803
|
+
* ```ts
|
|
749
804
|
* import { Option } from "effect"
|
|
750
805
|
*
|
|
751
806
|
* assert.deepStrictEqual(
|
|
@@ -753,6 +808,7 @@ export declare const getOrThrowWith: {
|
|
|
753
808
|
* 1
|
|
754
809
|
* )
|
|
755
810
|
* assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
|
|
811
|
+
* ```
|
|
756
812
|
*
|
|
757
813
|
* @category conversions
|
|
758
814
|
* @since 2.0.0
|
|
@@ -768,10 +824,12 @@ export declare const getOrThrowWith: {
|
|
|
768
824
|
* @throws `Error("getOrThrow called on a None")`
|
|
769
825
|
*
|
|
770
826
|
* @example
|
|
827
|
+
* ```ts
|
|
771
828
|
* import { Option } from "effect"
|
|
772
829
|
*
|
|
773
830
|
* assert.deepStrictEqual(Option.getOrThrow(Option.some(1)), 1)
|
|
774
831
|
* assert.throws(() => Option.getOrThrow(Option.none()))
|
|
832
|
+
* ```
|
|
775
833
|
*
|
|
776
834
|
* @category conversions
|
|
777
835
|
* @since 2.0.0
|
|
@@ -928,6 +986,7 @@ export declare const andThen: {
|
|
|
928
986
|
* This is `flatMap` + `fromNullable`, useful when working with optional values.
|
|
929
987
|
*
|
|
930
988
|
* @example
|
|
989
|
+
* ```ts
|
|
931
990
|
* import { pipe, Option } from "effect"
|
|
932
991
|
*
|
|
933
992
|
* interface Employee {
|
|
@@ -959,6 +1018,7 @@ export declare const andThen: {
|
|
|
959
1018
|
* ),
|
|
960
1019
|
* Option.none()
|
|
961
1020
|
* )
|
|
1021
|
+
* ```
|
|
962
1022
|
*
|
|
963
1023
|
* @category sequencing
|
|
964
1024
|
* @since 2.0.0
|
|
@@ -968,6 +1028,7 @@ export declare const flatMapNullable: {
|
|
|
968
1028
|
* This is `flatMap` + `fromNullable`, useful when working with optional values.
|
|
969
1029
|
*
|
|
970
1030
|
* @example
|
|
1031
|
+
* ```ts
|
|
971
1032
|
* import { pipe, Option } from "effect"
|
|
972
1033
|
*
|
|
973
1034
|
* interface Employee {
|
|
@@ -999,6 +1060,7 @@ export declare const flatMapNullable: {
|
|
|
999
1060
|
* ),
|
|
1000
1061
|
* Option.none()
|
|
1001
1062
|
* )
|
|
1063
|
+
* ```
|
|
1002
1064
|
*
|
|
1003
1065
|
* @category sequencing
|
|
1004
1066
|
* @since 2.0.0
|
|
@@ -1008,6 +1070,7 @@ export declare const flatMapNullable: {
|
|
|
1008
1070
|
* This is `flatMap` + `fromNullable`, useful when working with optional values.
|
|
1009
1071
|
*
|
|
1010
1072
|
* @example
|
|
1073
|
+
* ```ts
|
|
1011
1074
|
* import { pipe, Option } from "effect"
|
|
1012
1075
|
*
|
|
1013
1076
|
* interface Employee {
|
|
@@ -1039,6 +1102,7 @@ export declare const flatMapNullable: {
|
|
|
1039
1102
|
* ),
|
|
1040
1103
|
* Option.none()
|
|
1041
1104
|
* )
|
|
1105
|
+
* ```
|
|
1042
1106
|
*
|
|
1043
1107
|
* @category sequencing
|
|
1044
1108
|
* @since 2.0.0
|
|
@@ -1129,6 +1193,7 @@ export declare const zipLeft: {
|
|
|
1129
1193
|
* @param self - The `Option` to apply the function to
|
|
1130
1194
|
*
|
|
1131
1195
|
* @example
|
|
1196
|
+
* ```ts
|
|
1132
1197
|
* import { Option } from "effect"
|
|
1133
1198
|
*
|
|
1134
1199
|
* const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
|
|
@@ -1136,6 +1201,7 @@ export declare const zipLeft: {
|
|
|
1136
1201
|
* assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
|
|
1137
1202
|
* assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
|
|
1138
1203
|
* assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
|
|
1204
|
+
* ```
|
|
1139
1205
|
*
|
|
1140
1206
|
* @category sequencing
|
|
1141
1207
|
* @since 2.0.0
|
|
@@ -1151,6 +1217,7 @@ export declare const tap: {
|
|
|
1151
1217
|
* @param self - The `Option` to apply the function to
|
|
1152
1218
|
*
|
|
1153
1219
|
* @example
|
|
1220
|
+
* ```ts
|
|
1154
1221
|
* import { Option } from "effect"
|
|
1155
1222
|
*
|
|
1156
1223
|
* const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
|
|
@@ -1158,6 +1225,7 @@ export declare const tap: {
|
|
|
1158
1225
|
* assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
|
|
1159
1226
|
* assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
|
|
1160
1227
|
* assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
|
|
1228
|
+
* ```
|
|
1161
1229
|
*
|
|
1162
1230
|
* @category sequencing
|
|
1163
1231
|
* @since 2.0.0
|
|
@@ -1173,6 +1241,7 @@ export declare const tap: {
|
|
|
1173
1241
|
* @param self - The `Option` to apply the function to
|
|
1174
1242
|
*
|
|
1175
1243
|
* @example
|
|
1244
|
+
* ```ts
|
|
1176
1245
|
* import { Option } from "effect"
|
|
1177
1246
|
*
|
|
1178
1247
|
* const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
|
|
@@ -1180,6 +1249,7 @@ export declare const tap: {
|
|
|
1180
1249
|
* assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
|
|
1181
1250
|
* assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
|
|
1182
1251
|
* assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
|
|
1252
|
+
* ```
|
|
1183
1253
|
*
|
|
1184
1254
|
* @category sequencing
|
|
1185
1255
|
* @since 2.0.0
|
|
@@ -1206,11 +1276,13 @@ export declare const productMany: <A>(self: Option<A>, collection: Iterable<Opti
|
|
|
1206
1276
|
* @param fields - the struct of `Option`s to be sequenced.
|
|
1207
1277
|
*
|
|
1208
1278
|
* @example
|
|
1279
|
+
* ```ts
|
|
1209
1280
|
* import { Option } from "effect"
|
|
1210
1281
|
*
|
|
1211
1282
|
* assert.deepStrictEqual(Option.all([Option.some(1), Option.some(2)]), Option.some([1, 2]))
|
|
1212
1283
|
* assert.deepStrictEqual(Option.all({ a: Option.some(1), b: Option.some("hello") }), Option.some({ a: 1, b: "hello" }))
|
|
1213
1284
|
* assert.deepStrictEqual(Option.all({ a: Option.some(1), b: Option.none() }), Option.none())
|
|
1285
|
+
* ```
|
|
1214
1286
|
*
|
|
1215
1287
|
* @category combining
|
|
1216
1288
|
* @since 2.0.0
|
|
@@ -1228,6 +1300,7 @@ export declare const all: <const I extends Iterable<Option<any>> | Record<string
|
|
|
1228
1300
|
* @param f - The function used to combine the values of the two `Option`s
|
|
1229
1301
|
*
|
|
1230
1302
|
* @example
|
|
1303
|
+
* ```ts
|
|
1231
1304
|
* import { Option } from "effect"
|
|
1232
1305
|
*
|
|
1233
1306
|
* type Complex = [real: number, imaginary: number]
|
|
@@ -1240,6 +1313,7 @@ export declare const all: <const I extends Iterable<Option<any>> | Record<string
|
|
|
1240
1313
|
* assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
|
|
1241
1314
|
*
|
|
1242
1315
|
* assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
|
|
1316
|
+
* ```
|
|
1243
1317
|
*
|
|
1244
1318
|
* @category zipping
|
|
1245
1319
|
* @since 2.0.0
|
|
@@ -1253,6 +1327,7 @@ export declare const zipWith: {
|
|
|
1253
1327
|
* @param f - The function used to combine the values of the two `Option`s
|
|
1254
1328
|
*
|
|
1255
1329
|
* @example
|
|
1330
|
+
* ```ts
|
|
1256
1331
|
* import { Option } from "effect"
|
|
1257
1332
|
*
|
|
1258
1333
|
* type Complex = [real: number, imaginary: number]
|
|
@@ -1265,6 +1340,7 @@ export declare const zipWith: {
|
|
|
1265
1340
|
* assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
|
|
1266
1341
|
*
|
|
1267
1342
|
* assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
|
|
1343
|
+
* ```
|
|
1268
1344
|
*
|
|
1269
1345
|
* @category zipping
|
|
1270
1346
|
* @since 2.0.0
|
|
@@ -1278,6 +1354,7 @@ export declare const zipWith: {
|
|
|
1278
1354
|
* @param f - The function used to combine the values of the two `Option`s
|
|
1279
1355
|
*
|
|
1280
1356
|
* @example
|
|
1357
|
+
* ```ts
|
|
1281
1358
|
* import { Option } from "effect"
|
|
1282
1359
|
*
|
|
1283
1360
|
* type Complex = [real: number, imaginary: number]
|
|
@@ -1290,6 +1367,7 @@ export declare const zipWith: {
|
|
|
1290
1367
|
* assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
|
|
1291
1368
|
*
|
|
1292
1369
|
* assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
|
|
1370
|
+
* ```
|
|
1293
1371
|
*
|
|
1294
1372
|
* @category zipping
|
|
1295
1373
|
* @since 2.0.0
|
|
@@ -1320,10 +1398,12 @@ export declare const ap: {
|
|
|
1320
1398
|
* @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
|
|
1321
1399
|
*
|
|
1322
1400
|
* @example
|
|
1401
|
+
* ```ts
|
|
1323
1402
|
* import { pipe, Option } from "effect"
|
|
1324
1403
|
*
|
|
1325
1404
|
* const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
|
|
1326
1405
|
* assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
|
|
1406
|
+
* ```
|
|
1327
1407
|
*
|
|
1328
1408
|
* @category folding
|
|
1329
1409
|
* @since 2.0.0
|
|
@@ -1337,10 +1417,12 @@ export declare const reduceCompact: {
|
|
|
1337
1417
|
* @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
|
|
1338
1418
|
*
|
|
1339
1419
|
* @example
|
|
1420
|
+
* ```ts
|
|
1340
1421
|
* import { pipe, Option } from "effect"
|
|
1341
1422
|
*
|
|
1342
1423
|
* const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
|
|
1343
1424
|
* assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
|
|
1425
|
+
* ```
|
|
1344
1426
|
*
|
|
1345
1427
|
* @category folding
|
|
1346
1428
|
* @since 2.0.0
|
|
@@ -1354,10 +1436,12 @@ export declare const reduceCompact: {
|
|
|
1354
1436
|
* @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
|
|
1355
1437
|
*
|
|
1356
1438
|
* @example
|
|
1439
|
+
* ```ts
|
|
1357
1440
|
* import { pipe, Option } from "effect"
|
|
1358
1441
|
*
|
|
1359
1442
|
* const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
|
|
1360
1443
|
* assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
|
|
1444
|
+
* ```
|
|
1361
1445
|
*
|
|
1362
1446
|
* @category folding
|
|
1363
1447
|
* @since 2.0.0
|
|
@@ -1372,10 +1456,12 @@ export declare const reduceCompact: {
|
|
|
1372
1456
|
* @param self - The `Option` to convert to an array.
|
|
1373
1457
|
*
|
|
1374
1458
|
* @example
|
|
1459
|
+
* ```ts
|
|
1375
1460
|
* import { Option } from "effect"
|
|
1376
1461
|
*
|
|
1377
1462
|
* assert.deepStrictEqual(Option.toArray(Option.some(1)), [1])
|
|
1378
1463
|
* assert.deepStrictEqual(Option.toArray(Option.none()), [])
|
|
1464
|
+
* ```
|
|
1379
1465
|
*
|
|
1380
1466
|
* @category conversions
|
|
1381
1467
|
* @since 2.0.0
|
|
@@ -1406,6 +1492,7 @@ export declare const partitionMap: {
|
|
|
1406
1492
|
* @param f - A function to apply to the value of the `Option`.
|
|
1407
1493
|
*
|
|
1408
1494
|
* @example
|
|
1495
|
+
* ```ts
|
|
1409
1496
|
* import { Option } from "effect"
|
|
1410
1497
|
*
|
|
1411
1498
|
* const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
|
|
@@ -1413,6 +1500,7 @@ export declare const partitionMap: {
|
|
|
1413
1500
|
* assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
|
|
1414
1501
|
* assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
|
|
1415
1502
|
* assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
|
|
1503
|
+
* ```
|
|
1416
1504
|
*
|
|
1417
1505
|
* @category filtering
|
|
1418
1506
|
* @since 2.0.0
|
|
@@ -1427,6 +1515,7 @@ export declare const filterMap: {
|
|
|
1427
1515
|
* @param f - A function to apply to the value of the `Option`.
|
|
1428
1516
|
*
|
|
1429
1517
|
* @example
|
|
1518
|
+
* ```ts
|
|
1430
1519
|
* import { Option } from "effect"
|
|
1431
1520
|
*
|
|
1432
1521
|
* const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
|
|
@@ -1434,6 +1523,7 @@ export declare const filterMap: {
|
|
|
1434
1523
|
* assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
|
|
1435
1524
|
* assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
|
|
1436
1525
|
* assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
|
|
1526
|
+
* ```
|
|
1437
1527
|
*
|
|
1438
1528
|
* @category filtering
|
|
1439
1529
|
* @since 2.0.0
|
|
@@ -1448,6 +1538,7 @@ export declare const filterMap: {
|
|
|
1448
1538
|
* @param f - A function to apply to the value of the `Option`.
|
|
1449
1539
|
*
|
|
1450
1540
|
* @example
|
|
1541
|
+
* ```ts
|
|
1451
1542
|
* import { Option } from "effect"
|
|
1452
1543
|
*
|
|
1453
1544
|
* const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
|
|
@@ -1455,6 +1546,7 @@ export declare const filterMap: {
|
|
|
1455
1546
|
* assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
|
|
1456
1547
|
* assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
|
|
1457
1548
|
* assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
|
|
1549
|
+
* ```
|
|
1458
1550
|
*
|
|
1459
1551
|
* @category filtering
|
|
1460
1552
|
* @since 2.0.0
|
|
@@ -1470,6 +1562,7 @@ export declare const filterMap: {
|
|
|
1470
1562
|
* @param fb - The `Option` to filter.
|
|
1471
1563
|
*
|
|
1472
1564
|
* @example
|
|
1565
|
+
* ```ts
|
|
1473
1566
|
* import { Option } from "effect"
|
|
1474
1567
|
*
|
|
1475
1568
|
* // predicate
|
|
@@ -1485,6 +1578,7 @@ export declare const filterMap: {
|
|
|
1485
1578
|
* assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
|
|
1486
1579
|
* assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
|
|
1487
1580
|
* assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
|
|
1581
|
+
* ```
|
|
1488
1582
|
*
|
|
1489
1583
|
* @category filtering
|
|
1490
1584
|
* @since 2.0.0
|
|
@@ -1499,6 +1593,7 @@ export declare const filter: {
|
|
|
1499
1593
|
* @param fb - The `Option` to filter.
|
|
1500
1594
|
*
|
|
1501
1595
|
* @example
|
|
1596
|
+
* ```ts
|
|
1502
1597
|
* import { Option } from "effect"
|
|
1503
1598
|
*
|
|
1504
1599
|
* // predicate
|
|
@@ -1514,6 +1609,7 @@ export declare const filter: {
|
|
|
1514
1609
|
* assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
|
|
1515
1610
|
* assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
|
|
1516
1611
|
* assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
|
|
1612
|
+
* ```
|
|
1517
1613
|
*
|
|
1518
1614
|
* @category filtering
|
|
1519
1615
|
* @since 2.0.0
|
|
@@ -1528,6 +1624,7 @@ export declare const filter: {
|
|
|
1528
1624
|
* @param fb - The `Option` to filter.
|
|
1529
1625
|
*
|
|
1530
1626
|
* @example
|
|
1627
|
+
* ```ts
|
|
1531
1628
|
* import { Option } from "effect"
|
|
1532
1629
|
*
|
|
1533
1630
|
* // predicate
|
|
@@ -1543,6 +1640,7 @@ export declare const filter: {
|
|
|
1543
1640
|
* assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
|
|
1544
1641
|
* assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
|
|
1545
1642
|
* assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
|
|
1643
|
+
* ```
|
|
1546
1644
|
*
|
|
1547
1645
|
* @category filtering
|
|
1548
1646
|
* @since 2.0.0
|
|
@@ -1557,6 +1655,7 @@ export declare const filter: {
|
|
|
1557
1655
|
* @param fb - The `Option` to filter.
|
|
1558
1656
|
*
|
|
1559
1657
|
* @example
|
|
1658
|
+
* ```ts
|
|
1560
1659
|
* import { Option } from "effect"
|
|
1561
1660
|
*
|
|
1562
1661
|
* // predicate
|
|
@@ -1572,6 +1671,7 @@ export declare const filter: {
|
|
|
1572
1671
|
* assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
|
|
1573
1672
|
* assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
|
|
1574
1673
|
* assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
|
|
1674
|
+
* ```
|
|
1575
1675
|
*
|
|
1576
1676
|
* @category filtering
|
|
1577
1677
|
* @since 2.0.0
|
|
@@ -1586,6 +1686,7 @@ export declare const filter: {
|
|
|
1586
1686
|
* @param fb - The `Option` to filter.
|
|
1587
1687
|
*
|
|
1588
1688
|
* @example
|
|
1689
|
+
* ```ts
|
|
1589
1690
|
* import { Option } from "effect"
|
|
1590
1691
|
*
|
|
1591
1692
|
* // predicate
|
|
@@ -1601,6 +1702,7 @@ export declare const filter: {
|
|
|
1601
1702
|
* assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
|
|
1602
1703
|
* assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
|
|
1603
1704
|
* assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
|
|
1705
|
+
* ```
|
|
1604
1706
|
*
|
|
1605
1707
|
* @category filtering
|
|
1606
1708
|
* @since 2.0.0
|
|
@@ -1609,6 +1711,7 @@ export declare const filter: {
|
|
|
1609
1711
|
};
|
|
1610
1712
|
/**
|
|
1611
1713
|
* @example
|
|
1714
|
+
* ```ts
|
|
1612
1715
|
* import { Option, Number } from "effect"
|
|
1613
1716
|
*
|
|
1614
1717
|
* const isEquivalent = Option.getEquivalence(Number.Equivalence)
|
|
@@ -1617,6 +1720,7 @@ export declare const filter: {
|
|
|
1617
1720
|
* assert.deepStrictEqual(isEquivalent(Option.some(1), Option.none()), false)
|
|
1618
1721
|
* assert.deepStrictEqual(isEquivalent(Option.some(1), Option.some(2)), false)
|
|
1619
1722
|
* assert.deepStrictEqual(isEquivalent(Option.some(1), Option.some(1)), true)
|
|
1723
|
+
* ```
|
|
1620
1724
|
*
|
|
1621
1725
|
* @category equivalence
|
|
1622
1726
|
* @since 2.0.0
|
|
@@ -1630,6 +1734,7 @@ export declare const getEquivalence: <A>(isEquivalent: Equivalence.Equivalence<A
|
|
|
1630
1734
|
* `None` is considered to be less than any `Some` value.
|
|
1631
1735
|
*
|
|
1632
1736
|
* @example
|
|
1737
|
+
* ```ts
|
|
1633
1738
|
* import { pipe, Option, Number } from "effect"
|
|
1634
1739
|
*
|
|
1635
1740
|
* const O = Option.getOrder(Number.Order)
|
|
@@ -1638,6 +1743,7 @@ export declare const getEquivalence: <A>(isEquivalent: Equivalence.Equivalence<A
|
|
|
1638
1743
|
* assert.deepStrictEqual(O(Option.some(1), Option.none()), 1)
|
|
1639
1744
|
* assert.deepStrictEqual(O(Option.some(1), Option.some(2)), -1)
|
|
1640
1745
|
* assert.deepStrictEqual(O(Option.some(1), Option.some(1)), 0)
|
|
1746
|
+
* ```
|
|
1641
1747
|
*
|
|
1642
1748
|
* @category sorting
|
|
1643
1749
|
* @since 2.0.0
|
|
@@ -1662,12 +1768,14 @@ export declare const lift2: <A, B, C>(f: (a: A, b: B) => C) => {
|
|
|
1662
1768
|
* @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
|
|
1663
1769
|
*
|
|
1664
1770
|
* @example
|
|
1771
|
+
* ```ts
|
|
1665
1772
|
* import { Option } from "effect"
|
|
1666
1773
|
*
|
|
1667
1774
|
* const getOption = Option.liftPredicate((n: number) => n >= 0)
|
|
1668
1775
|
*
|
|
1669
1776
|
* assert.deepStrictEqual(getOption(-1), Option.none())
|
|
1670
1777
|
* assert.deepStrictEqual(getOption(1), Option.some(1))
|
|
1778
|
+
* ```
|
|
1671
1779
|
*
|
|
1672
1780
|
* @category lifting
|
|
1673
1781
|
* @since 2.0.0
|
|
@@ -1681,12 +1789,14 @@ export declare const liftPredicate: {
|
|
|
1681
1789
|
* @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
|
|
1682
1790
|
*
|
|
1683
1791
|
* @example
|
|
1792
|
+
* ```ts
|
|
1684
1793
|
* import { Option } from "effect"
|
|
1685
1794
|
*
|
|
1686
1795
|
* const getOption = Option.liftPredicate((n: number) => n >= 0)
|
|
1687
1796
|
*
|
|
1688
1797
|
* assert.deepStrictEqual(getOption(-1), Option.none())
|
|
1689
1798
|
* assert.deepStrictEqual(getOption(1), Option.some(1))
|
|
1799
|
+
* ```
|
|
1690
1800
|
*
|
|
1691
1801
|
* @category lifting
|
|
1692
1802
|
* @since 2.0.0
|
|
@@ -1699,12 +1809,14 @@ export declare const liftPredicate: {
|
|
|
1699
1809
|
* @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
|
|
1700
1810
|
*
|
|
1701
1811
|
* @example
|
|
1812
|
+
* ```ts
|
|
1702
1813
|
* import { Option } from "effect"
|
|
1703
1814
|
*
|
|
1704
1815
|
* const getOption = Option.liftPredicate((n: number) => n >= 0)
|
|
1705
1816
|
*
|
|
1706
1817
|
* assert.deepStrictEqual(getOption(-1), Option.none())
|
|
1707
1818
|
* assert.deepStrictEqual(getOption(1), Option.some(1))
|
|
1819
|
+
* ```
|
|
1708
1820
|
*
|
|
1709
1821
|
* @category lifting
|
|
1710
1822
|
* @since 2.0.0
|
|
@@ -1717,12 +1829,14 @@ export declare const liftPredicate: {
|
|
|
1717
1829
|
* @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
|
|
1718
1830
|
*
|
|
1719
1831
|
* @example
|
|
1832
|
+
* ```ts
|
|
1720
1833
|
* import { Option } from "effect"
|
|
1721
1834
|
*
|
|
1722
1835
|
* const getOption = Option.liftPredicate((n: number) => n >= 0)
|
|
1723
1836
|
*
|
|
1724
1837
|
* assert.deepStrictEqual(getOption(-1), Option.none())
|
|
1725
1838
|
* assert.deepStrictEqual(getOption(1), Option.some(1))
|
|
1839
|
+
* ```
|
|
1726
1840
|
*
|
|
1727
1841
|
* @category lifting
|
|
1728
1842
|
* @since 2.0.0
|
|
@@ -1737,11 +1851,13 @@ export declare const liftPredicate: {
|
|
|
1737
1851
|
* @param a - The value to compare against the `Option`.
|
|
1738
1852
|
*
|
|
1739
1853
|
* @example
|
|
1854
|
+
* ```ts
|
|
1740
1855
|
* import { pipe, Option, Number } from "effect"
|
|
1741
1856
|
*
|
|
1742
1857
|
* assert.deepStrictEqual(pipe(Option.some(2), Option.containsWith(Number.Equivalence)(2)), true)
|
|
1743
1858
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.containsWith(Number.Equivalence)(2)), false)
|
|
1744
1859
|
* assert.deepStrictEqual(pipe(Option.none(), Option.containsWith(Number.Equivalence)(2)), false)
|
|
1860
|
+
* ```
|
|
1745
1861
|
*
|
|
1746
1862
|
* @category elements
|
|
1747
1863
|
* @since 2.0.0
|
|
@@ -1779,6 +1895,7 @@ export declare const contains: {
|
|
|
1779
1895
|
* @param predicate - The condition to check.
|
|
1780
1896
|
*
|
|
1781
1897
|
* @example
|
|
1898
|
+
* ```ts
|
|
1782
1899
|
* import { pipe, Option } from "effect"
|
|
1783
1900
|
*
|
|
1784
1901
|
* const isEven = (n: number) => n % 2 === 0
|
|
@@ -1786,6 +1903,7 @@ export declare const contains: {
|
|
|
1786
1903
|
* assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
|
|
1787
1904
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
|
|
1788
1905
|
* assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
|
|
1906
|
+
* ```
|
|
1789
1907
|
*
|
|
1790
1908
|
* @since 2.0.0
|
|
1791
1909
|
*/
|
|
@@ -1797,6 +1915,7 @@ export declare const exists: {
|
|
|
1797
1915
|
* @param predicate - The condition to check.
|
|
1798
1916
|
*
|
|
1799
1917
|
* @example
|
|
1918
|
+
* ```ts
|
|
1800
1919
|
* import { pipe, Option } from "effect"
|
|
1801
1920
|
*
|
|
1802
1921
|
* const isEven = (n: number) => n % 2 === 0
|
|
@@ -1804,6 +1923,7 @@ export declare const exists: {
|
|
|
1804
1923
|
* assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
|
|
1805
1924
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
|
|
1806
1925
|
* assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
|
|
1926
|
+
* ```
|
|
1807
1927
|
*
|
|
1808
1928
|
* @since 2.0.0
|
|
1809
1929
|
*/
|
|
@@ -1815,6 +1935,7 @@ export declare const exists: {
|
|
|
1815
1935
|
* @param predicate - The condition to check.
|
|
1816
1936
|
*
|
|
1817
1937
|
* @example
|
|
1938
|
+
* ```ts
|
|
1818
1939
|
* import { pipe, Option } from "effect"
|
|
1819
1940
|
*
|
|
1820
1941
|
* const isEven = (n: number) => n % 2 === 0
|
|
@@ -1822,6 +1943,7 @@ export declare const exists: {
|
|
|
1822
1943
|
* assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
|
|
1823
1944
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
|
|
1824
1945
|
* assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
|
|
1946
|
+
* ```
|
|
1825
1947
|
*
|
|
1826
1948
|
* @since 2.0.0
|
|
1827
1949
|
*/
|
|
@@ -1833,6 +1955,7 @@ export declare const exists: {
|
|
|
1833
1955
|
* @param predicate - The condition to check.
|
|
1834
1956
|
*
|
|
1835
1957
|
* @example
|
|
1958
|
+
* ```ts
|
|
1836
1959
|
* import { pipe, Option } from "effect"
|
|
1837
1960
|
*
|
|
1838
1961
|
* const isEven = (n: number) => n % 2 === 0
|
|
@@ -1840,6 +1963,7 @@ export declare const exists: {
|
|
|
1840
1963
|
* assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
|
|
1841
1964
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
|
|
1842
1965
|
* assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
|
|
1966
|
+
* ```
|
|
1843
1967
|
*
|
|
1844
1968
|
* @since 2.0.0
|
|
1845
1969
|
*/
|
|
@@ -1851,6 +1975,7 @@ export declare const exists: {
|
|
|
1851
1975
|
* @param predicate - The condition to check.
|
|
1852
1976
|
*
|
|
1853
1977
|
* @example
|
|
1978
|
+
* ```ts
|
|
1854
1979
|
* import { pipe, Option } from "effect"
|
|
1855
1980
|
*
|
|
1856
1981
|
* const isEven = (n: number) => n % 2 === 0
|
|
@@ -1858,6 +1983,7 @@ export declare const exists: {
|
|
|
1858
1983
|
* assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
|
|
1859
1984
|
* assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
|
|
1860
1985
|
* assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
|
|
1986
|
+
* ```
|
|
1861
1987
|
*
|
|
1862
1988
|
* @since 2.0.0
|
|
1863
1989
|
*/
|
|
@@ -1879,6 +2005,7 @@ export declare const exists: {
|
|
|
1879
2005
|
* @see {@link let_ let}
|
|
1880
2006
|
*
|
|
1881
2007
|
* @example
|
|
2008
|
+
* ```ts
|
|
1882
2009
|
* import { Option, pipe } from "effect"
|
|
1883
2010
|
*
|
|
1884
2011
|
* const result = pipe(
|
|
@@ -1889,6 +2016,7 @@ export declare const exists: {
|
|
|
1889
2016
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
1890
2017
|
* )
|
|
1891
2018
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2019
|
+
* ```
|
|
1892
2020
|
*
|
|
1893
2021
|
* @category do notation
|
|
1894
2022
|
* @since 2.0.0
|
|
@@ -1910,6 +2038,7 @@ export declare const bindTo: {
|
|
|
1910
2038
|
* @see {@link let_ let}
|
|
1911
2039
|
*
|
|
1912
2040
|
* @example
|
|
2041
|
+
* ```ts
|
|
1913
2042
|
* import { Option, pipe } from "effect"
|
|
1914
2043
|
*
|
|
1915
2044
|
* const result = pipe(
|
|
@@ -1920,6 +2049,7 @@ export declare const bindTo: {
|
|
|
1920
2049
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
1921
2050
|
* )
|
|
1922
2051
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2052
|
+
* ```
|
|
1923
2053
|
*
|
|
1924
2054
|
* @category do notation
|
|
1925
2055
|
* @since 2.0.0
|
|
@@ -1943,6 +2073,7 @@ export declare const bindTo: {
|
|
|
1943
2073
|
* @see {@link let_ let}
|
|
1944
2074
|
*
|
|
1945
2075
|
* @example
|
|
2076
|
+
* ```ts
|
|
1946
2077
|
* import { Option, pipe } from "effect"
|
|
1947
2078
|
*
|
|
1948
2079
|
* const result = pipe(
|
|
@@ -1953,6 +2084,7 @@ export declare const bindTo: {
|
|
|
1953
2084
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
1954
2085
|
* )
|
|
1955
2086
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2087
|
+
* ```
|
|
1956
2088
|
*
|
|
1957
2089
|
* @category do notation
|
|
1958
2090
|
* @since 2.0.0
|
|
@@ -1986,6 +2118,7 @@ export {
|
|
|
1986
2118
|
* @see {@link bindTo}
|
|
1987
2119
|
*
|
|
1988
2120
|
* @example
|
|
2121
|
+
* ```ts
|
|
1989
2122
|
* import { Option, pipe } from "effect"
|
|
1990
2123
|
*
|
|
1991
2124
|
* const result = pipe(
|
|
@@ -1997,6 +2130,7 @@ export {
|
|
|
1997
2130
|
* )
|
|
1998
2131
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
1999
2132
|
*
|
|
2133
|
+
* ```
|
|
2000
2134
|
* @category do notation
|
|
2001
2135
|
* @since 2.0.0
|
|
2002
2136
|
*/
|
|
@@ -2017,6 +2151,7 @@ let_ as let };
|
|
|
2017
2151
|
* @see {@link let_ let}
|
|
2018
2152
|
*
|
|
2019
2153
|
* @example
|
|
2154
|
+
* ```ts
|
|
2020
2155
|
* import { Option, pipe } from "effect"
|
|
2021
2156
|
*
|
|
2022
2157
|
* const result = pipe(
|
|
@@ -2027,6 +2162,7 @@ let_ as let };
|
|
|
2027
2162
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
2028
2163
|
* )
|
|
2029
2164
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2165
|
+
* ```
|
|
2030
2166
|
*
|
|
2031
2167
|
* @category do notation
|
|
2032
2168
|
* @since 2.0.0
|
|
@@ -2048,6 +2184,7 @@ export declare const bind: {
|
|
|
2048
2184
|
* @see {@link let_ let}
|
|
2049
2185
|
*
|
|
2050
2186
|
* @example
|
|
2187
|
+
* ```ts
|
|
2051
2188
|
* import { Option, pipe } from "effect"
|
|
2052
2189
|
*
|
|
2053
2190
|
* const result = pipe(
|
|
@@ -2058,6 +2195,7 @@ export declare const bind: {
|
|
|
2058
2195
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
2059
2196
|
* )
|
|
2060
2197
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2198
|
+
* ```
|
|
2061
2199
|
*
|
|
2062
2200
|
* @category do notation
|
|
2063
2201
|
* @since 2.0.0
|
|
@@ -2081,6 +2219,7 @@ export declare const bind: {
|
|
|
2081
2219
|
* @see {@link let_ let}
|
|
2082
2220
|
*
|
|
2083
2221
|
* @example
|
|
2222
|
+
* ```ts
|
|
2084
2223
|
* import { Option, pipe } from "effect"
|
|
2085
2224
|
*
|
|
2086
2225
|
* const result = pipe(
|
|
@@ -2091,6 +2230,7 @@ export declare const bind: {
|
|
|
2091
2230
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
2092
2231
|
* )
|
|
2093
2232
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2233
|
+
* ```
|
|
2094
2234
|
*
|
|
2095
2235
|
* @category do notation
|
|
2096
2236
|
* @since 2.0.0
|
|
@@ -2115,6 +2255,7 @@ export declare const bind: {
|
|
|
2115
2255
|
* @see {@link let_ let}
|
|
2116
2256
|
*
|
|
2117
2257
|
* @example
|
|
2258
|
+
* ```ts
|
|
2118
2259
|
* import { Option, pipe } from "effect"
|
|
2119
2260
|
*
|
|
2120
2261
|
* const result = pipe(
|
|
@@ -2125,6 +2266,7 @@ export declare const bind: {
|
|
|
2125
2266
|
* Option.filter(({ x, y }) => x * y > 5)
|
|
2126
2267
|
* )
|
|
2127
2268
|
* assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
|
|
2269
|
+
* ```
|
|
2128
2270
|
*
|
|
2129
2271
|
* @category do notation
|
|
2130
2272
|
* @since 2.0.0
|