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/Array.js
CHANGED
|
@@ -29,10 +29,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
29
29
|
* Builds a `NonEmptyArray` from an non-empty collection of elements.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
|
+
* ```ts
|
|
32
33
|
* import { Array } from "effect"
|
|
33
34
|
*
|
|
34
35
|
* const result = Array.make(1, 2, 3)
|
|
35
36
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
37
|
+
* ```
|
|
36
38
|
*
|
|
37
39
|
* @category constructors
|
|
38
40
|
* @since 2.0.0
|
|
@@ -42,10 +44,12 @@ const make = (...elements) => elements;
|
|
|
42
44
|
* Creates a new `Array` of the specified length.
|
|
43
45
|
*
|
|
44
46
|
* @example
|
|
47
|
+
* ```ts
|
|
45
48
|
* import { Array } from "effect"
|
|
46
49
|
*
|
|
47
50
|
* const result = Array.allocate<number>(3)
|
|
48
51
|
* assert.deepStrictEqual(result.length, 3)
|
|
52
|
+
* ```
|
|
49
53
|
*
|
|
50
54
|
* @category constructors
|
|
51
55
|
* @since 2.0.0
|
|
@@ -58,9 +62,11 @@ const allocate = n => new Array(n);
|
|
|
58
62
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
59
63
|
*
|
|
60
64
|
* @example
|
|
65
|
+
* ```ts
|
|
61
66
|
* import { makeBy } from "effect/Array"
|
|
62
67
|
*
|
|
63
68
|
* assert.deepStrictEqual(makeBy(5, n => n * 2), [0, 2, 4, 6, 8])
|
|
69
|
+
* ```
|
|
64
70
|
*
|
|
65
71
|
* @category constructors
|
|
66
72
|
* @since 2.0.0
|
|
@@ -78,9 +84,11 @@ const makeBy = (n, f) => {
|
|
|
78
84
|
* Return a `NonEmptyArray` containing a range of integers, including both endpoints.
|
|
79
85
|
*
|
|
80
86
|
* @example
|
|
87
|
+
* ```ts
|
|
81
88
|
* import { range } from "effect/Array"
|
|
82
89
|
*
|
|
83
90
|
* assert.deepStrictEqual(range(1, 3), [1, 2, 3])
|
|
91
|
+
* ```
|
|
84
92
|
*
|
|
85
93
|
* @category constructors
|
|
86
94
|
* @since 2.0.0
|
|
@@ -93,9 +101,11 @@ const range = (start, end) => start <= end ? makeBy(end - start + 1, i => start
|
|
|
93
101
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
94
102
|
*
|
|
95
103
|
* @example
|
|
104
|
+
* ```ts
|
|
96
105
|
* import { Array } from "effect"
|
|
97
106
|
*
|
|
98
107
|
* assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
|
|
108
|
+
* ```
|
|
99
109
|
*
|
|
100
110
|
* @category constructors
|
|
101
111
|
* @since 2.0.0
|
|
@@ -108,11 +118,13 @@ const replicate = exports.replicate = /*#__PURE__*/(0, _Function.dual)(2, (a, n)
|
|
|
108
118
|
* Otherwise, it converts the iterable collection to an array.
|
|
109
119
|
*
|
|
110
120
|
* @example
|
|
121
|
+
* ```ts
|
|
111
122
|
* import { Array } from "effect"
|
|
112
123
|
*
|
|
113
124
|
* const set = new Set([1, 2, 3])
|
|
114
125
|
* const result = Array.fromIterable(set)
|
|
115
126
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
127
|
+
* ```
|
|
116
128
|
*
|
|
117
129
|
* @category constructors
|
|
118
130
|
* @since 2.0.0
|
|
@@ -122,11 +134,13 @@ const fromIterable = collection => Array.isArray(collection) ? collection : Arra
|
|
|
122
134
|
* Creates a new `Array` from a value that might not be an iterable.
|
|
123
135
|
*
|
|
124
136
|
* @example
|
|
137
|
+
* ```ts
|
|
125
138
|
* import { Array } from "effect"
|
|
126
139
|
*
|
|
127
140
|
* assert.deepStrictEqual(Array.ensure("a"), ["a"])
|
|
128
141
|
* assert.deepStrictEqual(Array.ensure(["a"]), ["a"])
|
|
129
142
|
* assert.deepStrictEqual(Array.ensure(["a", "b", "c"]), ["a", "b", "c"])
|
|
143
|
+
* ```
|
|
130
144
|
*
|
|
131
145
|
* @category constructors
|
|
132
146
|
* @since 3.3.0
|
|
@@ -139,10 +153,12 @@ const ensure = self => Array.isArray(self) ? self : [self];
|
|
|
139
153
|
* @param self - The record to transform.
|
|
140
154
|
*
|
|
141
155
|
* @example
|
|
156
|
+
* ```ts
|
|
142
157
|
* import { Array } from "effect"
|
|
143
158
|
*
|
|
144
159
|
* const x = { a: 1, b: 2, c: 3 }
|
|
145
160
|
* assert.deepStrictEqual(Array.fromRecord(x), [["a", 1], ["b", 2], ["c", 3]])
|
|
161
|
+
* ```
|
|
146
162
|
*
|
|
147
163
|
* @category conversions
|
|
148
164
|
* @since 2.0.0
|
|
@@ -153,10 +169,12 @@ const fromRecord = exports.fromRecord = Record.toEntries;
|
|
|
153
169
|
* Converts an `Option` to an array.
|
|
154
170
|
*
|
|
155
171
|
* @example
|
|
172
|
+
* ```ts
|
|
156
173
|
* import { Array, Option } from "effect"
|
|
157
174
|
*
|
|
158
175
|
* assert.deepStrictEqual(Array.fromOption(Option.some(1)), [1])
|
|
159
176
|
* assert.deepStrictEqual(Array.fromOption(Option.none()), [])
|
|
177
|
+
* ```
|
|
160
178
|
*
|
|
161
179
|
* @category conversions
|
|
162
180
|
* @since 2.0.0
|
|
@@ -166,6 +184,7 @@ const fromOption = exports.fromOption = O.toArray;
|
|
|
166
184
|
* Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
|
|
167
185
|
*
|
|
168
186
|
* @example
|
|
187
|
+
* ```ts
|
|
169
188
|
* import { Array } from "effect"
|
|
170
189
|
*
|
|
171
190
|
* const match = Array.match({
|
|
@@ -174,6 +193,7 @@ const fromOption = exports.fromOption = O.toArray;
|
|
|
174
193
|
* })
|
|
175
194
|
* assert.deepStrictEqual(match([]), "empty")
|
|
176
195
|
* assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
|
|
196
|
+
* ```
|
|
177
197
|
*
|
|
178
198
|
* @category pattern matching
|
|
179
199
|
* @since 2.0.0
|
|
@@ -186,6 +206,7 @@ const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
|
|
|
186
206
|
* Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
|
|
187
207
|
*
|
|
188
208
|
* @example
|
|
209
|
+
* ```ts
|
|
189
210
|
* import { Array } from "effect"
|
|
190
211
|
*
|
|
191
212
|
* const matchLeft = Array.matchLeft({
|
|
@@ -194,6 +215,7 @@ const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
|
|
|
194
215
|
* })
|
|
195
216
|
* assert.deepStrictEqual(matchLeft([]), "empty")
|
|
196
217
|
* assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
|
|
218
|
+
* ```
|
|
197
219
|
*
|
|
198
220
|
* @category pattern matching
|
|
199
221
|
* @since 2.0.0
|
|
@@ -206,6 +228,7 @@ const matchLeft = exports.matchLeft = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
206
228
|
* Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
|
|
207
229
|
*
|
|
208
230
|
* @example
|
|
231
|
+
* ```ts
|
|
209
232
|
* import { Array } from "effect"
|
|
210
233
|
*
|
|
211
234
|
* const matchRight = Array.matchRight({
|
|
@@ -214,6 +237,7 @@ const matchLeft = exports.matchLeft = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
214
237
|
* })
|
|
215
238
|
* assert.deepStrictEqual(matchRight([]), "empty")
|
|
216
239
|
* assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
|
|
240
|
+
* ```
|
|
217
241
|
*
|
|
218
242
|
* @category pattern matching
|
|
219
243
|
* @since 2.0.0
|
|
@@ -226,11 +250,13 @@ const matchRight = exports.matchRight = /*#__PURE__*/(0, _Function.dual)(2, (sel
|
|
|
226
250
|
* Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
|
|
227
251
|
*
|
|
228
252
|
* @example
|
|
253
|
+
* ```ts
|
|
229
254
|
* import { Array } from "effect"
|
|
230
255
|
*
|
|
231
256
|
* const original = [2, 3, 4];
|
|
232
257
|
* const result = Array.prepend(original, 1);
|
|
233
258
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
259
|
+
* ```
|
|
234
260
|
*
|
|
235
261
|
* @category concatenating
|
|
236
262
|
* @since 2.0.0
|
|
@@ -241,12 +267,14 @@ const prepend = exports.prepend = /*#__PURE__*/(0, _Function.dual)(2, (self, hea
|
|
|
241
267
|
* If either array is non-empty, the result is also a non-empty array.
|
|
242
268
|
*
|
|
243
269
|
* @example
|
|
270
|
+
* ```ts
|
|
244
271
|
* import { Array } from "effect"
|
|
245
272
|
*
|
|
246
273
|
* const prefix = [0, 1];
|
|
247
274
|
* const array = [2, 3];
|
|
248
275
|
* const result = Array.prependAll(array, prefix);
|
|
249
276
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
277
|
+
* ```
|
|
250
278
|
*
|
|
251
279
|
* @category concatenating
|
|
252
280
|
* @since 2.0.0
|
|
@@ -256,11 +284,13 @@ const prependAll = exports.prependAll = /*#__PURE__*/(0, _Function.dual)(2, (sel
|
|
|
256
284
|
* Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
|
|
257
285
|
*
|
|
258
286
|
* @example
|
|
287
|
+
* ```ts
|
|
259
288
|
* import { Array } from "effect"
|
|
260
289
|
*
|
|
261
290
|
* const original = [1, 2, 3];
|
|
262
291
|
* const result = Array.append(original, 4);
|
|
263
292
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
293
|
+
* ```
|
|
264
294
|
*
|
|
265
295
|
* @category concatenating
|
|
266
296
|
* @since 2.0.0
|
|
@@ -280,6 +310,7 @@ const appendAll = exports.appendAll = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
280
310
|
* a value through a series of transformations.
|
|
281
311
|
*
|
|
282
312
|
* @example
|
|
313
|
+
* ```ts
|
|
283
314
|
* import { Array } from "effect";
|
|
284
315
|
*
|
|
285
316
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -291,6 +322,7 @@ const appendAll = exports.appendAll = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
291
322
|
* // and adds each element of the array to this accumulator one by one,
|
|
292
323
|
* // keeping track of the cumulative sum after each addition.
|
|
293
324
|
* // Each of these sums is captured in the resulting array.
|
|
325
|
+
* ```
|
|
294
326
|
*
|
|
295
327
|
* @category folding
|
|
296
328
|
* @since 2.0.0
|
|
@@ -310,11 +342,13 @@ const scan = exports.scan = /*#__PURE__*/(0, _Function.dual)(3, (self, b, f) =>
|
|
|
310
342
|
* a value through a series of transformations.
|
|
311
343
|
*
|
|
312
344
|
* @example
|
|
345
|
+
* ```ts
|
|
313
346
|
* import { Array } from "effect";
|
|
314
347
|
*
|
|
315
348
|
* const numbers = [1, 2, 3, 4]
|
|
316
349
|
* const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
|
|
317
350
|
* assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
|
|
351
|
+
* ```
|
|
318
352
|
*
|
|
319
353
|
* @category folding
|
|
320
354
|
* @since 2.0.0
|
|
@@ -334,10 +368,12 @@ const scanRight = exports.scanRight = /*#__PURE__*/(0, _Function.dual)(3, (self,
|
|
|
334
368
|
* @param self - The value to check.
|
|
335
369
|
*
|
|
336
370
|
* @example
|
|
371
|
+
* ```ts
|
|
337
372
|
* import { isArray } from "effect/Array"
|
|
338
373
|
*
|
|
339
374
|
* assert.deepStrictEqual(isArray(null), false);
|
|
340
375
|
* assert.deepStrictEqual(isArray([1, 2, 3]), true);
|
|
376
|
+
* ```
|
|
341
377
|
*
|
|
342
378
|
* @category guards
|
|
343
379
|
* @since 2.0.0
|
|
@@ -349,10 +385,12 @@ const isArray = exports.isArray = Array.isArray;
|
|
|
349
385
|
* @param self - The `Array` to check.
|
|
350
386
|
*
|
|
351
387
|
* @example
|
|
388
|
+
* ```ts
|
|
352
389
|
* import { isEmptyArray } from "effect/Array"
|
|
353
390
|
*
|
|
354
391
|
* assert.deepStrictEqual(isEmptyArray([]), true);
|
|
355
392
|
* assert.deepStrictEqual(isEmptyArray([1, 2, 3]), false);
|
|
393
|
+
* ```
|
|
356
394
|
*
|
|
357
395
|
* @category guards
|
|
358
396
|
* @since 2.0.0
|
|
@@ -364,10 +402,12 @@ const isEmptyArray = self => self.length === 0;
|
|
|
364
402
|
* @param self - The `ReadonlyArray` to check.
|
|
365
403
|
*
|
|
366
404
|
* @example
|
|
405
|
+
* ```ts
|
|
367
406
|
* import { isEmptyReadonlyArray } from "effect/Array"
|
|
368
407
|
*
|
|
369
408
|
* assert.deepStrictEqual(isEmptyReadonlyArray([]), true);
|
|
370
409
|
* assert.deepStrictEqual(isEmptyReadonlyArray([1, 2, 3]), false);
|
|
410
|
+
* ```
|
|
371
411
|
*
|
|
372
412
|
* @category guards
|
|
373
413
|
* @since 2.0.0
|
|
@@ -382,10 +422,12 @@ const isEmptyReadonlyArray = exports.isEmptyReadonlyArray = isEmptyArray;
|
|
|
382
422
|
* @param self - The `Array` to check.
|
|
383
423
|
*
|
|
384
424
|
* @example
|
|
425
|
+
* ```ts
|
|
385
426
|
* import { isNonEmptyArray } from "effect/Array"
|
|
386
427
|
*
|
|
387
428
|
* assert.deepStrictEqual(isNonEmptyArray([]), false);
|
|
388
429
|
* assert.deepStrictEqual(isNonEmptyArray([1, 2, 3]), true);
|
|
430
|
+
* ```
|
|
389
431
|
*
|
|
390
432
|
* @category guards
|
|
391
433
|
* @since 2.0.0
|
|
@@ -399,10 +441,12 @@ const isNonEmptyArray = exports.isNonEmptyArray = readonlyArray.isNonEmptyArray;
|
|
|
399
441
|
* @param self - The `ReadonlyArray` to check.
|
|
400
442
|
*
|
|
401
443
|
* @example
|
|
444
|
+
* ```ts
|
|
402
445
|
* import { isNonEmptyReadonlyArray } from "effect/Array"
|
|
403
446
|
*
|
|
404
447
|
* assert.deepStrictEqual(isNonEmptyReadonlyArray([]), false);
|
|
405
448
|
* assert.deepStrictEqual(isNonEmptyReadonlyArray([1, 2, 3]), true);
|
|
449
|
+
* ```
|
|
406
450
|
*
|
|
407
451
|
* @category guards
|
|
408
452
|
* @since 2.0.0
|
|
@@ -445,10 +489,12 @@ const unsafeGet = exports.unsafeGet = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
445
489
|
* Return a tuple containing the first element, and a new `Array` of the remaining elements, if any.
|
|
446
490
|
*
|
|
447
491
|
* @example
|
|
492
|
+
* ```ts
|
|
448
493
|
* import { Array } from "effect";
|
|
449
494
|
*
|
|
450
495
|
* const result = Array.unprepend([1, 2, 3, 4])
|
|
451
496
|
* assert.deepStrictEqual(result, [1, [2, 3, 4]])
|
|
497
|
+
* ```
|
|
452
498
|
*
|
|
453
499
|
* @category splitting
|
|
454
500
|
* @since 2.0.0
|
|
@@ -458,10 +504,12 @@ const unprepend = self => [headNonEmpty(self), tailNonEmpty(self)];
|
|
|
458
504
|
* Return a tuple containing a copy of the `NonEmptyReadonlyArray` without its last element, and that last element.
|
|
459
505
|
*
|
|
460
506
|
* @example
|
|
507
|
+
* ```ts
|
|
461
508
|
* import { Array } from "effect";
|
|
462
509
|
*
|
|
463
510
|
* const result = Array.unappend([1, 2, 3, 4])
|
|
464
511
|
* assert.deepStrictEqual(result, [[1, 2, 3], 4])
|
|
512
|
+
* ```
|
|
465
513
|
*
|
|
466
514
|
* @category splitting
|
|
467
515
|
* @since 2.0.0
|
|
@@ -480,10 +528,12 @@ const head = exports.head = /*#__PURE__*/get(0);
|
|
|
480
528
|
* Get the first element of a non empty array.
|
|
481
529
|
*
|
|
482
530
|
* @example
|
|
531
|
+
* ```ts
|
|
483
532
|
* import { Array } from "effect"
|
|
484
533
|
*
|
|
485
534
|
* const result = Array.headNonEmpty([1, 2, 3, 4])
|
|
486
535
|
* assert.deepStrictEqual(result, 1)
|
|
536
|
+
* ```
|
|
487
537
|
*
|
|
488
538
|
* @category getters
|
|
489
539
|
* @since 2.0.0
|
|
@@ -500,10 +550,12 @@ const last = self => isNonEmptyReadonlyArray(self) ? O.some(lastNonEmpty(self))
|
|
|
500
550
|
* Get the last element of a non empty array.
|
|
501
551
|
*
|
|
502
552
|
* @example
|
|
553
|
+
* ```ts
|
|
503
554
|
* import { Array } from "effect"
|
|
504
555
|
*
|
|
505
556
|
* const result = Array.lastNonEmpty([1, 2, 3, 4])
|
|
506
557
|
* assert.deepStrictEqual(result, 4)
|
|
558
|
+
* ```
|
|
507
559
|
*
|
|
508
560
|
* @category getters
|
|
509
561
|
* @since 2.0.0
|
|
@@ -525,10 +577,12 @@ const tail = self => {
|
|
|
525
577
|
* Get all but the first element of a `NonEmptyReadonlyArray`.
|
|
526
578
|
*
|
|
527
579
|
* @example
|
|
580
|
+
* ```ts
|
|
528
581
|
* import { Array } from "effect"
|
|
529
582
|
*
|
|
530
583
|
* const result = Array.tailNonEmpty([1, 2, 3, 4])
|
|
531
584
|
* assert.deepStrictEqual(result, [2, 3, 4])
|
|
585
|
+
* ```
|
|
532
586
|
*
|
|
533
587
|
* @category getters
|
|
534
588
|
* @since 2.0.0
|
|
@@ -550,10 +604,12 @@ const init = self => {
|
|
|
550
604
|
* Get all but the last element of a non empty array, creating a new array.
|
|
551
605
|
*
|
|
552
606
|
* @example
|
|
607
|
+
* ```ts
|
|
553
608
|
* import { Array } from "effect"
|
|
554
609
|
*
|
|
555
610
|
* const result = Array.initNonEmpty([1, 2, 3, 4])
|
|
556
611
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
612
|
+
* ```
|
|
557
613
|
*
|
|
558
614
|
* @category getters
|
|
559
615
|
* @since 2.0.0
|
|
@@ -566,11 +622,13 @@ const initNonEmpty = self => self.slice(0, -1);
|
|
|
566
622
|
* **Note**. `n` is normalized to a non negative integer.
|
|
567
623
|
*
|
|
568
624
|
* @example
|
|
625
|
+
* ```ts
|
|
569
626
|
* import { Array } from "effect"
|
|
570
627
|
*
|
|
571
628
|
* const numbers = [1, 2, 3, 4, 5]
|
|
572
629
|
* const result = Array.take(numbers, 3)
|
|
573
630
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
631
|
+
* ```
|
|
574
632
|
*
|
|
575
633
|
* @category getters
|
|
576
634
|
* @since 2.0.0
|
|
@@ -586,11 +644,13 @@ const take = exports.take = /*#__PURE__*/(0, _Function.dual)(2, (self, n) => {
|
|
|
586
644
|
* **Note**. `n` is normalized to a non negative integer.
|
|
587
645
|
*
|
|
588
646
|
* @example
|
|
647
|
+
* ```ts
|
|
589
648
|
* import { Array } from "effect"
|
|
590
649
|
*
|
|
591
650
|
* const numbers = [1, 2, 3, 4, 5]
|
|
592
651
|
* const result = Array.takeRight(numbers, 3)
|
|
593
652
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
653
|
+
* ```
|
|
594
654
|
*
|
|
595
655
|
* @category getters
|
|
596
656
|
* @since 2.0.0
|
|
@@ -604,6 +664,7 @@ const takeRight = exports.takeRight = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
604
664
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
605
665
|
*
|
|
606
666
|
* @example
|
|
667
|
+
* ```ts
|
|
607
668
|
* import { Array } from "effect"
|
|
608
669
|
*
|
|
609
670
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -615,6 +676,7 @@ const takeRight = exports.takeRight = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
615
676
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
616
677
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
617
678
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
679
|
+
* ```
|
|
618
680
|
*
|
|
619
681
|
* @category getters
|
|
620
682
|
* @since 2.0.0
|
|
@@ -657,11 +719,13 @@ const span = exports.span = /*#__PURE__*/(0, _Function.dual)(2, (self, predicate
|
|
|
657
719
|
* **Note**. `n` is normalized to a non negative integer.
|
|
658
720
|
*
|
|
659
721
|
* @example
|
|
722
|
+
* ```ts
|
|
660
723
|
* import { Array } from "effect"
|
|
661
724
|
*
|
|
662
725
|
* const numbers = [1, 2, 3, 4, 5]
|
|
663
726
|
* const result = Array.drop(numbers, 2)
|
|
664
727
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
728
|
+
* ```
|
|
665
729
|
*
|
|
666
730
|
* @category getters
|
|
667
731
|
* @since 2.0.0
|
|
@@ -676,11 +740,13 @@ const drop = exports.drop = /*#__PURE__*/(0, _Function.dual)(2, (self, n) => {
|
|
|
676
740
|
* **Note**. `n` is normalized to a non negative integer.
|
|
677
741
|
*
|
|
678
742
|
* @example
|
|
743
|
+
* ```ts
|
|
679
744
|
* import { Array } from "effect"
|
|
680
745
|
*
|
|
681
746
|
* const numbers = [1, 2, 3, 4, 5]
|
|
682
747
|
* const result = Array.dropRight(numbers, 2)
|
|
683
748
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
749
|
+
* ```
|
|
684
750
|
*
|
|
685
751
|
* @category getters
|
|
686
752
|
* @since 2.0.0
|
|
@@ -693,11 +759,13 @@ const dropRight = exports.dropRight = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
693
759
|
* Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
694
760
|
*
|
|
695
761
|
* @example
|
|
762
|
+
* ```ts
|
|
696
763
|
* import { Array } from "effect"
|
|
697
764
|
*
|
|
698
765
|
* const numbers = [1, 2, 3, 4, 5]
|
|
699
766
|
* const result = Array.dropWhile(numbers, x => x < 4)
|
|
700
767
|
* assert.deepStrictEqual(result, [4, 5])
|
|
768
|
+
* ```
|
|
701
769
|
*
|
|
702
770
|
* @category getters
|
|
703
771
|
* @since 2.0.0
|
|
@@ -707,11 +775,13 @@ const dropWhile = exports.dropWhile = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
707
775
|
* Return the first index for which a predicate holds.
|
|
708
776
|
*
|
|
709
777
|
* @example
|
|
778
|
+
* ```ts
|
|
710
779
|
* import { Array, Option } from "effect"
|
|
711
780
|
*
|
|
712
781
|
* const numbers = [5, 3, 8, 9]
|
|
713
782
|
* const result = Array.findFirstIndex(numbers, x => x > 5)
|
|
714
783
|
* assert.deepStrictEqual(result, Option.some(2))
|
|
784
|
+
* ```
|
|
715
785
|
*
|
|
716
786
|
* @category elements
|
|
717
787
|
* @since 2.0.0
|
|
@@ -730,11 +800,13 @@ const findFirstIndex = exports.findFirstIndex = /*#__PURE__*/(0, _Function.dual)
|
|
|
730
800
|
* Return the last index for which a predicate holds.
|
|
731
801
|
*
|
|
732
802
|
* @example
|
|
803
|
+
* ```ts
|
|
733
804
|
* import { Array, Option } from "effect"
|
|
734
805
|
*
|
|
735
806
|
* const numbers = [1, 3, 8, 9]
|
|
736
807
|
* const result = Array.findLastIndex(numbers, x => x < 5)
|
|
737
808
|
* assert.deepStrictEqual(result, Option.some(1))
|
|
809
|
+
* ```
|
|
738
810
|
*
|
|
739
811
|
* @category elements
|
|
740
812
|
* @since 2.0.0
|
|
@@ -753,11 +825,13 @@ const findLastIndex = exports.findLastIndex = /*#__PURE__*/(0, _Function.dual)(2
|
|
|
753
825
|
* predicate, or `None` if no such element exists.
|
|
754
826
|
*
|
|
755
827
|
* @example
|
|
828
|
+
* ```ts
|
|
756
829
|
* import { Array, Option } from "effect"
|
|
757
830
|
*
|
|
758
831
|
* const numbers = [1, 2, 3, 4, 5]
|
|
759
832
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
760
833
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
834
|
+
* ```
|
|
761
835
|
*
|
|
762
836
|
* @category elements
|
|
763
837
|
* @since 2.0.0
|
|
@@ -768,11 +842,13 @@ const findFirst = exports.findFirst = EffectIterable.findFirst;
|
|
|
768
842
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
769
843
|
*
|
|
770
844
|
* @example
|
|
845
|
+
* ```ts
|
|
771
846
|
* import { Array, Option } from "effect"
|
|
772
847
|
*
|
|
773
848
|
* const numbers = [1, 2, 3, 4, 5]
|
|
774
849
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
775
850
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
851
|
+
* ```
|
|
776
852
|
*
|
|
777
853
|
* @category elements
|
|
778
854
|
* @since 2.0.0
|
|
@@ -799,11 +875,13 @@ const findLast = exports.findLast = /*#__PURE__*/(0, _Function.dual)(2, (self, f
|
|
|
799
875
|
* or return `None` if the index is out of bounds.
|
|
800
876
|
*
|
|
801
877
|
* @example
|
|
878
|
+
* ```ts
|
|
802
879
|
* import { Array, Option } from "effect"
|
|
803
880
|
*
|
|
804
881
|
* const letters = ['a', 'b', 'c', 'e']
|
|
805
882
|
* const result = Array.insertAt(letters, 3, 'd')
|
|
806
883
|
* assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
|
|
884
|
+
* ```
|
|
807
885
|
*
|
|
808
886
|
* @since 2.0.0
|
|
809
887
|
*/
|
|
@@ -821,11 +899,13 @@ const insertAt = exports.insertAt = /*#__PURE__*/(0, _Function.dual)(3, (self, i
|
|
|
821
899
|
* or return a copy of the input if the index is out of bounds.
|
|
822
900
|
*
|
|
823
901
|
* @example
|
|
902
|
+
* ```ts
|
|
824
903
|
* import { Array } from "effect"
|
|
825
904
|
*
|
|
826
905
|
* const letters = ['a', 'b', 'c', 'd']
|
|
827
906
|
* const result = Array.replace(letters, 1, 'z')
|
|
828
907
|
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
|
|
908
|
+
* ```
|
|
829
909
|
*
|
|
830
910
|
* @since 2.0.0
|
|
831
911
|
*/
|
|
@@ -834,11 +914,13 @@ const replace = exports.replace = /*#__PURE__*/(0, _Function.dual)(3, (self, i,
|
|
|
834
914
|
* Replaces an element in an array with the given value, returning an option of the updated array.
|
|
835
915
|
*
|
|
836
916
|
* @example
|
|
917
|
+
* ```ts
|
|
837
918
|
* import { Array, Option } from "effect"
|
|
838
919
|
*
|
|
839
920
|
* const numbers = [1, 2, 3]
|
|
840
921
|
* const result = Array.replaceOption(numbers, 1, 4)
|
|
841
922
|
* assert.deepStrictEqual(result, Option.some([1, 4, 3]))
|
|
923
|
+
* ```
|
|
842
924
|
*
|
|
843
925
|
* @since 2.0.0
|
|
844
926
|
*/
|
|
@@ -848,11 +930,13 @@ const replaceOption = exports.replaceOption = /*#__PURE__*/(0, _Function.dual)(3
|
|
|
848
930
|
* or return a copy of the input if the index is out of bounds.
|
|
849
931
|
*
|
|
850
932
|
* @example
|
|
933
|
+
* ```ts
|
|
851
934
|
* import { Array } from "effect"
|
|
852
935
|
*
|
|
853
936
|
* const numbers = [1, 2, 3, 4]
|
|
854
937
|
* const result = Array.modify(numbers, 2, (n) => n * 2)
|
|
855
938
|
* assert.deepStrictEqual(result, [1, 2, 6, 4])
|
|
939
|
+
* ```
|
|
856
940
|
*
|
|
857
941
|
* @since 2.0.0
|
|
858
942
|
*/
|
|
@@ -862,6 +946,7 @@ const modify = exports.modify = /*#__PURE__*/(0, _Function.dual)(3, (self, i, f)
|
|
|
862
946
|
* or return `None` if the index is out of bounds.
|
|
863
947
|
*
|
|
864
948
|
* @example
|
|
949
|
+
* ```ts
|
|
865
950
|
* import { Array, Option } from "effect"
|
|
866
951
|
*
|
|
867
952
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -870,6 +955,7 @@ const modify = exports.modify = /*#__PURE__*/(0, _Function.dual)(3, (self, i, f)
|
|
|
870
955
|
*
|
|
871
956
|
* const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
|
|
872
957
|
* assert.deepStrictEqual(outOfBoundsResult, Option.none())
|
|
958
|
+
* ```
|
|
873
959
|
*
|
|
874
960
|
* @since 2.0.0
|
|
875
961
|
*/
|
|
@@ -888,6 +974,7 @@ const modifyOption = exports.modifyOption = /*#__PURE__*/(0, _Function.dual)(3,
|
|
|
888
974
|
* or return a copy of the input if the index is out of bounds.
|
|
889
975
|
*
|
|
890
976
|
* @example
|
|
977
|
+
* ```ts
|
|
891
978
|
* import { Array } from "effect"
|
|
892
979
|
*
|
|
893
980
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -896,6 +983,7 @@ const modifyOption = exports.modifyOption = /*#__PURE__*/(0, _Function.dual)(3,
|
|
|
896
983
|
*
|
|
897
984
|
* const outOfBoundsResult = Array.remove(numbers, 5)
|
|
898
985
|
* assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
|
|
986
|
+
* ```
|
|
899
987
|
*
|
|
900
988
|
* @since 2.0.0
|
|
901
989
|
*/
|
|
@@ -911,11 +999,13 @@ const remove = exports.remove = /*#__PURE__*/(0, _Function.dual)(2, (self, i) =>
|
|
|
911
999
|
* Reverse an `Iterable`, creating a new `Array`.
|
|
912
1000
|
*
|
|
913
1001
|
* @example
|
|
1002
|
+
* ```ts
|
|
914
1003
|
* import { Array } from "effect"
|
|
915
1004
|
*
|
|
916
1005
|
* const numbers = [1, 2, 3, 4]
|
|
917
1006
|
* const result = Array.reverse(numbers)
|
|
918
1007
|
* assert.deepStrictEqual(result, [4, 3, 2, 1])
|
|
1008
|
+
* ```
|
|
919
1009
|
*
|
|
920
1010
|
* @category elements
|
|
921
1011
|
* @since 2.0.0
|
|
@@ -940,6 +1030,7 @@ const sort = exports.sort = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => {
|
|
|
940
1030
|
* order defines how those values should be sorted.
|
|
941
1031
|
*
|
|
942
1032
|
* @example
|
|
1033
|
+
* ```ts
|
|
943
1034
|
* import { Array, Order } from "effect"
|
|
944
1035
|
*
|
|
945
1036
|
* const strings = ["aaa", "b", "cc"]
|
|
@@ -950,6 +1041,7 @@ const sort = exports.sort = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => {
|
|
|
950
1041
|
* // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
|
|
951
1042
|
* // converts each string into its length, and the `Order.number` specifies that the lengths should
|
|
952
1043
|
* // be sorted in ascending order.
|
|
1044
|
+
* ```
|
|
953
1045
|
*
|
|
954
1046
|
* @since 2.0.0
|
|
955
1047
|
* @category elements
|
|
@@ -961,6 +1053,7 @@ const sortWith = exports.sortWith = /*#__PURE__*/(0, _Function.dual)(3, (self, f
|
|
|
961
1053
|
* second order if the first comparison is equal, and so on.
|
|
962
1054
|
*
|
|
963
1055
|
* @example
|
|
1056
|
+
* ```ts
|
|
964
1057
|
* import { Array, Order } from "effect"
|
|
965
1058
|
*
|
|
966
1059
|
* const users = [
|
|
@@ -983,6 +1076,7 @@ const sortWith = exports.sortWith = /*#__PURE__*/(0, _Function.dual)(3, (self, f
|
|
|
983
1076
|
* // Explanation:
|
|
984
1077
|
* // The array of users is sorted first by age in ascending order. When ages are equal,
|
|
985
1078
|
* // the users are further sorted by name in ascending order.
|
|
1079
|
+
* ```
|
|
986
1080
|
*
|
|
987
1081
|
* @category sorting
|
|
988
1082
|
* @since 2.0.0
|
|
@@ -1003,12 +1097,14 @@ const sortBy = (...orders) => {
|
|
|
1003
1097
|
* longer `Iterable` are discarded.
|
|
1004
1098
|
*
|
|
1005
1099
|
* @example
|
|
1100
|
+
* ```ts
|
|
1006
1101
|
* import { Array } from "effect"
|
|
1007
1102
|
*
|
|
1008
1103
|
* const array1 = [1, 2, 3]
|
|
1009
1104
|
* const array2 = ['a', 'b']
|
|
1010
1105
|
* const result = Array.zip(array1, array2)
|
|
1011
1106
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
1107
|
+
* ```
|
|
1012
1108
|
*
|
|
1013
1109
|
* @category zipping
|
|
1014
1110
|
* @since 2.0.0
|
|
@@ -1020,12 +1116,14 @@ const zip = exports.zip = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => zi
|
|
|
1020
1116
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
1021
1117
|
*
|
|
1022
1118
|
* @example
|
|
1119
|
+
* ```ts
|
|
1023
1120
|
* import { Array } from "effect"
|
|
1024
1121
|
*
|
|
1025
1122
|
* const array1 = [1, 2, 3]
|
|
1026
1123
|
* const array2 = [4, 5, 6]
|
|
1027
1124
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
1028
1125
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
1126
|
+
* ```
|
|
1029
1127
|
*
|
|
1030
1128
|
* @category zipping
|
|
1031
1129
|
* @since 2.0.0
|
|
@@ -1047,10 +1145,12 @@ const zipWith = exports.zipWith = /*#__PURE__*/(0, _Function.dual)(3, (self, tha
|
|
|
1047
1145
|
* This function is the inverse of `zip`. Takes an `Iterable` of pairs and return two corresponding `Array`s.
|
|
1048
1146
|
*
|
|
1049
1147
|
* @example
|
|
1148
|
+
* ```ts
|
|
1050
1149
|
* import { Array } from "effect"
|
|
1051
1150
|
*
|
|
1052
1151
|
* const result = Array.unzip([[1, "a"], [2, "b"], [3, "c"]])
|
|
1053
1152
|
* assert.deepStrictEqual(result, [[1, 2, 3], ['a', 'b', 'c']])
|
|
1153
|
+
* ```
|
|
1054
1154
|
*
|
|
1055
1155
|
* @since 2.0.0
|
|
1056
1156
|
*/
|
|
@@ -1072,11 +1172,13 @@ const unzip = self => {
|
|
|
1072
1172
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
1073
1173
|
*
|
|
1074
1174
|
* @example
|
|
1175
|
+
* ```ts
|
|
1075
1176
|
* import { Array } from "effect"
|
|
1076
1177
|
*
|
|
1077
1178
|
* const numbers = [1, 2, 3]
|
|
1078
1179
|
* const result = Array.intersperse(numbers, 0)
|
|
1079
1180
|
* assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
|
|
1181
|
+
* ```
|
|
1080
1182
|
*
|
|
1081
1183
|
* @since 2.0.0
|
|
1082
1184
|
*/
|
|
@@ -1100,10 +1202,12 @@ const intersperse = exports.intersperse = /*#__PURE__*/(0, _Function.dual)(2, (s
|
|
|
1100
1202
|
* Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
|
|
1101
1203
|
*
|
|
1102
1204
|
* @example
|
|
1205
|
+
* ```ts
|
|
1103
1206
|
* import { Array } from "effect"
|
|
1104
1207
|
*
|
|
1105
1208
|
* const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
|
|
1106
1209
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
1210
|
+
* ```
|
|
1107
1211
|
*
|
|
1108
1212
|
* @since 2.0.0
|
|
1109
1213
|
*/
|
|
@@ -1112,10 +1216,12 @@ const modifyNonEmptyHead = exports.modifyNonEmptyHead = /*#__PURE__*/(0, _Functi
|
|
|
1112
1216
|
* Change the head, creating a new `NonEmptyReadonlyArray`.
|
|
1113
1217
|
*
|
|
1114
1218
|
* @example
|
|
1219
|
+
* ```ts
|
|
1115
1220
|
* import { Array } from "effect"
|
|
1116
1221
|
*
|
|
1117
1222
|
* const result = Array.setNonEmptyHead([1, 2, 3], 10)
|
|
1118
1223
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
1224
|
+
* ```
|
|
1119
1225
|
*
|
|
1120
1226
|
* @since 2.0.0
|
|
1121
1227
|
*/
|
|
@@ -1124,10 +1230,12 @@ const setNonEmptyHead = exports.setNonEmptyHead = /*#__PURE__*/(0, _Function.dua
|
|
|
1124
1230
|
* Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
|
|
1125
1231
|
*
|
|
1126
1232
|
* @example
|
|
1233
|
+
* ```ts
|
|
1127
1234
|
* import { Array } from "effect"
|
|
1128
1235
|
*
|
|
1129
1236
|
* const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
|
|
1130
1237
|
* assert.deepStrictEqual(result, [1, 2, 6])
|
|
1238
|
+
* ```
|
|
1131
1239
|
*
|
|
1132
1240
|
* @since 2.0.0
|
|
1133
1241
|
*/
|
|
@@ -1136,10 +1244,12 @@ const modifyNonEmptyLast = exports.modifyNonEmptyLast = /*#__PURE__*/(0, _Functi
|
|
|
1136
1244
|
* Change the last element, creating a new `NonEmptyReadonlyArray`.
|
|
1137
1245
|
*
|
|
1138
1246
|
* @example
|
|
1247
|
+
* ```ts
|
|
1139
1248
|
* import { Array } from "effect"
|
|
1140
1249
|
*
|
|
1141
1250
|
* const result = Array.setNonEmptyLast([1, 2, 3], 4)
|
|
1142
1251
|
* assert.deepStrictEqual(result, [1, 2, 4])
|
|
1252
|
+
* ```
|
|
1143
1253
|
*
|
|
1144
1254
|
* @since 2.0.0
|
|
1145
1255
|
*/
|
|
@@ -1149,11 +1259,13 @@ const setNonEmptyLast = exports.setNonEmptyLast = /*#__PURE__*/(0, _Function.dua
|
|
|
1149
1259
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
1150
1260
|
*
|
|
1151
1261
|
* @example
|
|
1262
|
+
* ```ts
|
|
1152
1263
|
* import { Array } from "effect"
|
|
1153
1264
|
*
|
|
1154
1265
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1155
1266
|
* const result = Array.rotate(letters, 2)
|
|
1156
1267
|
* assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
|
|
1268
|
+
* ```
|
|
1157
1269
|
*
|
|
1158
1270
|
* @since 2.0.0
|
|
1159
1271
|
*/
|
|
@@ -1178,6 +1290,7 @@ const rotate = exports.rotate = /*#__PURE__*/(0, _Function.dual)(2, (self, n) =>
|
|
|
1178
1290
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using a provided `isEquivalent` function.
|
|
1179
1291
|
*
|
|
1180
1292
|
* @example
|
|
1293
|
+
* ```ts
|
|
1181
1294
|
* import { Array } from "effect"
|
|
1182
1295
|
*
|
|
1183
1296
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -1185,6 +1298,7 @@ const rotate = exports.rotate = /*#__PURE__*/(0, _Function.dual)(2, (self, n) =>
|
|
|
1185
1298
|
* const containsNumber = Array.containsWith(isEquivalent)
|
|
1186
1299
|
* const result = containsNumber(3)(numbers)
|
|
1187
1300
|
* assert.deepStrictEqual(result, true)
|
|
1301
|
+
* ```
|
|
1188
1302
|
*
|
|
1189
1303
|
* @category elements
|
|
1190
1304
|
* @since 2.0.0
|
|
@@ -1203,11 +1317,13 @@ const _equivalence = /*#__PURE__*/Equal.equivalence();
|
|
|
1203
1317
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
|
|
1204
1318
|
*
|
|
1205
1319
|
* @example
|
|
1320
|
+
* ```ts
|
|
1206
1321
|
* import { Array } from "effect"
|
|
1207
1322
|
*
|
|
1208
1323
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1209
1324
|
* const result = Array.contains('c')(letters)
|
|
1210
1325
|
* assert.deepStrictEqual(result, true)
|
|
1326
|
+
* ```
|
|
1211
1327
|
*
|
|
1212
1328
|
* @category elements
|
|
1213
1329
|
* @since 2.0.0
|
|
@@ -1219,6 +1335,7 @@ const contains = exports.contains = /*#__PURE__*/containsWith(_equivalence);
|
|
|
1219
1335
|
* value and the rest of the `Array`.
|
|
1220
1336
|
*
|
|
1221
1337
|
* @example
|
|
1338
|
+
* ```ts
|
|
1222
1339
|
* import { Array } from "effect"
|
|
1223
1340
|
*
|
|
1224
1341
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -1229,6 +1346,7 @@ const contains = exports.contains = /*#__PURE__*/containsWith(_equivalence);
|
|
|
1229
1346
|
* // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
|
|
1230
1347
|
* // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
|
|
1231
1348
|
* // resulting in a new array `[2, 4, 6, 8, 10]`.
|
|
1349
|
+
* ```
|
|
1232
1350
|
*
|
|
1233
1351
|
* @since 2.0.0
|
|
1234
1352
|
*/
|
|
@@ -1252,11 +1370,13 @@ const chop = exports.chop = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
|
|
|
1252
1370
|
* The value of `n` can be `0`.
|
|
1253
1371
|
*
|
|
1254
1372
|
* @example
|
|
1373
|
+
* ```ts
|
|
1255
1374
|
* import { Array } from "effect"
|
|
1256
1375
|
*
|
|
1257
1376
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1258
1377
|
* const result = Array.splitAt(numbers, 3)
|
|
1259
1378
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
1379
|
+
* ```
|
|
1260
1380
|
*
|
|
1261
1381
|
* @category splitting
|
|
1262
1382
|
* @since 2.0.0
|
|
@@ -1277,10 +1397,12 @@ const splitAt = exports.splitAt = /*#__PURE__*/(0, _Function.dual)(2, (self, n)
|
|
|
1277
1397
|
* The value of `n` must be `>= 1`.
|
|
1278
1398
|
*
|
|
1279
1399
|
* @example
|
|
1400
|
+
* ```ts
|
|
1280
1401
|
* import { Array } from "effect"
|
|
1281
1402
|
*
|
|
1282
1403
|
* const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
|
|
1283
1404
|
* assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
|
|
1405
|
+
* ```
|
|
1284
1406
|
*
|
|
1285
1407
|
* @category splitting
|
|
1286
1408
|
* @since 2.0.0
|
|
@@ -1293,11 +1415,13 @@ const splitNonEmptyAt = exports.splitNonEmptyAt = /*#__PURE__*/(0, _Function.dua
|
|
|
1293
1415
|
* Splits this iterable into `n` equally sized arrays.
|
|
1294
1416
|
*
|
|
1295
1417
|
* @example
|
|
1418
|
+
* ```ts
|
|
1296
1419
|
* import { Array } from "effect"
|
|
1297
1420
|
*
|
|
1298
1421
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
1299
1422
|
* const result = Array.split(numbers, 3)
|
|
1300
1423
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
|
|
1424
|
+
* ```
|
|
1301
1425
|
*
|
|
1302
1426
|
* @since 2.0.0
|
|
1303
1427
|
* @category splitting
|
|
@@ -1311,11 +1435,13 @@ const split = exports.split = /*#__PURE__*/(0, _Function.dual)(2, (self, n) => {
|
|
|
1311
1435
|
* Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
|
|
1312
1436
|
*
|
|
1313
1437
|
* @example
|
|
1438
|
+
* ```ts
|
|
1314
1439
|
* import { Array } from "effect"
|
|
1315
1440
|
*
|
|
1316
1441
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1317
1442
|
* const result = Array.splitWhere(numbers, n => n > 3)
|
|
1318
1443
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
1444
|
+
* ```
|
|
1319
1445
|
*
|
|
1320
1446
|
* @category splitting
|
|
1321
1447
|
* @since 2.0.0
|
|
@@ -1325,11 +1451,13 @@ const splitWhere = exports.splitWhere = /*#__PURE__*/(0, _Function.dual)(2, (sel
|
|
|
1325
1451
|
* Copies an array.
|
|
1326
1452
|
*
|
|
1327
1453
|
* @example
|
|
1454
|
+
* ```ts
|
|
1328
1455
|
* import { Array } from "effect"
|
|
1329
1456
|
*
|
|
1330
1457
|
* const numbers = [1, 2, 3]
|
|
1331
1458
|
* const copy = Array.copy(numbers)
|
|
1332
1459
|
* assert.deepStrictEqual(copy, [1, 2, 3])
|
|
1460
|
+
* ```
|
|
1333
1461
|
*
|
|
1334
1462
|
* @since 2.0.0
|
|
1335
1463
|
*/
|
|
@@ -1341,11 +1469,13 @@ const copy = self => self.slice();
|
|
|
1341
1469
|
* If `n` is less than or equal to 0, the returned array will be an empty array.
|
|
1342
1470
|
*
|
|
1343
1471
|
* @example
|
|
1472
|
+
* ```ts
|
|
1344
1473
|
* import { Array } from "effect"
|
|
1345
1474
|
*
|
|
1346
1475
|
* const arr = [1, 2, 3]
|
|
1347
1476
|
* const result = Array.pad(arr, 6, 0)
|
|
1348
1477
|
* assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
|
|
1478
|
+
* ```
|
|
1349
1479
|
*
|
|
1350
1480
|
* @since 3.8.4
|
|
1351
1481
|
*/
|
|
@@ -1368,6 +1498,7 @@ const pad = exports.pad = /*#__PURE__*/(0, _Function.dual)(3, (self, n, fill) =>
|
|
|
1368
1498
|
* whenever `n` evenly divides the length of `self`.
|
|
1369
1499
|
*
|
|
1370
1500
|
* @example
|
|
1501
|
+
* ```ts
|
|
1371
1502
|
* import { Array } from "effect"
|
|
1372
1503
|
*
|
|
1373
1504
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -1379,6 +1510,7 @@ const pad = exports.pad = /*#__PURE__*/(0, _Function.dual)(3, (self, n, fill) =>
|
|
|
1379
1510
|
* // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
|
|
1380
1511
|
* // the last chunk contains the remaining elements.
|
|
1381
1512
|
* // The result is `[[1, 2], [3, 4], [5]]`.
|
|
1513
|
+
* ```
|
|
1382
1514
|
*
|
|
1383
1515
|
* @category splitting
|
|
1384
1516
|
* @since 2.0.0
|
|
@@ -1394,10 +1526,12 @@ const chunksOf = exports.chunksOf = /*#__PURE__*/(0, _Function.dual)(2, (self, n
|
|
|
1394
1526
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
|
|
1395
1527
|
*
|
|
1396
1528
|
* @example
|
|
1529
|
+
* ```ts
|
|
1397
1530
|
* import { Array } from "effect"
|
|
1398
1531
|
*
|
|
1399
1532
|
* const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
|
|
1400
1533
|
* assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
|
|
1534
|
+
* ```
|
|
1401
1535
|
*
|
|
1402
1536
|
* @category grouping
|
|
1403
1537
|
* @since 2.0.0
|
|
@@ -1420,10 +1554,12 @@ const groupWith = exports.groupWith = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
1420
1554
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s.
|
|
1421
1555
|
*
|
|
1422
1556
|
* @example
|
|
1557
|
+
* ```ts
|
|
1423
1558
|
* import { Array } from "effect"
|
|
1424
1559
|
*
|
|
1425
1560
|
* const result = Array.group([1, 1, 2, 2, 2, 3, 1])
|
|
1426
1561
|
* assert.deepStrictEqual(result, [[1, 1], [2, 2, 2], [3], [1]])
|
|
1562
|
+
* ```
|
|
1427
1563
|
*
|
|
1428
1564
|
* @category grouping
|
|
1429
1565
|
* @since 2.0.0
|
|
@@ -1434,6 +1570,7 @@ const group = exports.group = /*#__PURE__*/groupWith( /*#__PURE__*/Equal.equival
|
|
|
1434
1570
|
* function on each element, and grouping the results according to values returned
|
|
1435
1571
|
*
|
|
1436
1572
|
* @example
|
|
1573
|
+
* ```ts
|
|
1437
1574
|
* import { Array } from "effect"
|
|
1438
1575
|
*
|
|
1439
1576
|
* const people = [
|
|
@@ -1446,6 +1583,7 @@ const group = exports.group = /*#__PURE__*/groupWith( /*#__PURE__*/Equal.equival
|
|
|
1446
1583
|
* A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
|
|
1447
1584
|
* B: [{ name: "Bob", group: "B" }]
|
|
1448
1585
|
* })
|
|
1586
|
+
* ```
|
|
1449
1587
|
*
|
|
1450
1588
|
* @category grouping
|
|
1451
1589
|
* @since 2.0.0
|
|
@@ -1466,12 +1604,14 @@ const groupBy = exports.groupBy = /*#__PURE__*/(0, _Function.dual)(2, (self, f)
|
|
|
1466
1604
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
1467
1605
|
*
|
|
1468
1606
|
* @example
|
|
1607
|
+
* ```ts
|
|
1469
1608
|
* import { Array } from "effect"
|
|
1470
1609
|
*
|
|
1471
1610
|
* const array1 = [1, 2]
|
|
1472
1611
|
* const array2 = [2, 3]
|
|
1473
1612
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
1474
1613
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
1614
|
+
* ```
|
|
1475
1615
|
*
|
|
1476
1616
|
* @since 2.0.0
|
|
1477
1617
|
*/
|
|
@@ -1491,12 +1631,14 @@ const unionWith = exports.unionWith = /*#__PURE__*/(0, _Function.dual)(3, (self,
|
|
|
1491
1631
|
* Creates a union of two arrays, removing duplicates.
|
|
1492
1632
|
*
|
|
1493
1633
|
* @example
|
|
1634
|
+
* ```ts
|
|
1494
1635
|
* import { Array } from "effect"
|
|
1495
1636
|
*
|
|
1496
1637
|
* const array1 = [1, 2]
|
|
1497
1638
|
* const array2 = [2, 3]
|
|
1498
1639
|
* const result = Array.union(array1, array2)
|
|
1499
1640
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1641
|
+
* ```
|
|
1500
1642
|
*
|
|
1501
1643
|
* @since 2.0.0
|
|
1502
1644
|
*/
|
|
@@ -1506,6 +1648,7 @@ const union = exports.union = /*#__PURE__*/(0, _Function.dual)(2, (self, that) =
|
|
|
1506
1648
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1507
1649
|
*
|
|
1508
1650
|
* @example
|
|
1651
|
+
* ```ts
|
|
1509
1652
|
* import { Array } from "effect"
|
|
1510
1653
|
*
|
|
1511
1654
|
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
@@ -1513,6 +1656,7 @@ const union = exports.union = /*#__PURE__*/(0, _Function.dual)(2, (self, that) =
|
|
|
1513
1656
|
* const isEquivalent = (a: { id: number }, b: { id: number }) => a.id === b.id
|
|
1514
1657
|
* const result = Array.intersectionWith(isEquivalent)(array2)(array1)
|
|
1515
1658
|
* assert.deepStrictEqual(result, [{ id: 1 }, { id: 3 }])
|
|
1659
|
+
* ```
|
|
1516
1660
|
*
|
|
1517
1661
|
* @since 2.0.0
|
|
1518
1662
|
*/
|
|
@@ -1525,12 +1669,14 @@ const intersectionWith = isEquivalent => {
|
|
|
1525
1669
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1526
1670
|
*
|
|
1527
1671
|
* @example
|
|
1672
|
+
* ```ts
|
|
1528
1673
|
* import { Array } from "effect"
|
|
1529
1674
|
*
|
|
1530
1675
|
* const array1 = [1, 2, 3]
|
|
1531
1676
|
* const array2 = [3, 4, 1]
|
|
1532
1677
|
* const result = Array.intersection(array1, array2)
|
|
1533
1678
|
* assert.deepStrictEqual(result, [1, 3])
|
|
1679
|
+
* ```
|
|
1534
1680
|
*
|
|
1535
1681
|
* @since 2.0.0
|
|
1536
1682
|
*/
|
|
@@ -1541,12 +1687,14 @@ const intersection = exports.intersection = /*#__PURE__*/intersectionWith(_equiv
|
|
|
1541
1687
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1542
1688
|
*
|
|
1543
1689
|
* @example
|
|
1690
|
+
* ```ts
|
|
1544
1691
|
* import { Array } from "effect"
|
|
1545
1692
|
*
|
|
1546
1693
|
* const array1 = [1, 2, 3]
|
|
1547
1694
|
* const array2 = [2, 3, 4]
|
|
1548
1695
|
* const difference = Array.differenceWith<number>((a, b) => a === b)(array1, array2)
|
|
1549
1696
|
* assert.deepStrictEqual(difference, [1])
|
|
1697
|
+
* ```
|
|
1550
1698
|
*
|
|
1551
1699
|
* @since 2.0.0
|
|
1552
1700
|
*/
|
|
@@ -1559,12 +1707,14 @@ const differenceWith = isEquivalent => {
|
|
|
1559
1707
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1560
1708
|
*
|
|
1561
1709
|
* @example
|
|
1710
|
+
* ```ts
|
|
1562
1711
|
* import { Array } from "effect"
|
|
1563
1712
|
*
|
|
1564
1713
|
* const array1 = [1, 2, 3]
|
|
1565
1714
|
* const array2 = [2, 3, 4]
|
|
1566
1715
|
* const difference = Array.difference(array1, array2)
|
|
1567
1716
|
* assert.deepStrictEqual(difference, [1])
|
|
1717
|
+
* ```
|
|
1568
1718
|
*
|
|
1569
1719
|
* @since 2.0.0
|
|
1570
1720
|
*/
|
|
@@ -1614,12 +1764,14 @@ const flatMap = exports.flatMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f)
|
|
|
1614
1764
|
* arrays is collapsed into a single, flat array.
|
|
1615
1765
|
*
|
|
1616
1766
|
* @example
|
|
1767
|
+
* ```ts
|
|
1617
1768
|
* import { Array } from "effect";
|
|
1618
1769
|
*
|
|
1619
1770
|
* const nestedArrays = [[1, 2], [], [3, 4], [], [5, 6]]
|
|
1620
1771
|
* const result = Array.flatten(nestedArrays)
|
|
1621
1772
|
*
|
|
1622
1773
|
* assert.deepStrictEqual(result, [1, 2, 3, 4, 5, 6]);
|
|
1774
|
+
* ```
|
|
1623
1775
|
*
|
|
1624
1776
|
* @category sequencing
|
|
1625
1777
|
* @since 2.0.0
|
|
@@ -1630,6 +1782,7 @@ const flatten = exports.flatten = /*#__PURE__*/flatMap(_Function.identity);
|
|
|
1630
1782
|
* This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
|
|
1631
1783
|
*
|
|
1632
1784
|
* @example
|
|
1785
|
+
* ```ts
|
|
1633
1786
|
* import { Array, Option } from "effect";
|
|
1634
1787
|
*
|
|
1635
1788
|
* const data = [1, 2, 3, 4, 5];
|
|
@@ -1637,6 +1790,7 @@ const flatten = exports.flatten = /*#__PURE__*/flatMap(_Function.identity);
|
|
|
1637
1790
|
* const result = Array.filterMap(data, evenSquares);
|
|
1638
1791
|
*
|
|
1639
1792
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
1793
|
+
* ```
|
|
1640
1794
|
*
|
|
1641
1795
|
* @category filtering
|
|
1642
1796
|
* @since 2.0.0
|
|
@@ -1658,6 +1812,7 @@ const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
1658
1812
|
* This is useful when you need to transform an array but only up to the point where a certain condition holds true.
|
|
1659
1813
|
*
|
|
1660
1814
|
* @example
|
|
1815
|
+
* ```ts
|
|
1661
1816
|
* import { Array, Option } from "effect";
|
|
1662
1817
|
*
|
|
1663
1818
|
* const data = [2, 4, 5];
|
|
@@ -1665,6 +1820,7 @@ const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
1665
1820
|
* const result = Array.filterMapWhile(data, toSquareTillOdd);
|
|
1666
1821
|
*
|
|
1667
1822
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
1823
|
+
* ```
|
|
1668
1824
|
*
|
|
1669
1825
|
* @category filtering
|
|
1670
1826
|
* @since 2.0.0
|
|
@@ -1690,6 +1846,7 @@ const filterMapWhile = exports.filterMapWhile = /*#__PURE__*/(0, _Function.dual)
|
|
|
1690
1846
|
* into successes and failures.
|
|
1691
1847
|
*
|
|
1692
1848
|
* @example
|
|
1849
|
+
* ```ts
|
|
1693
1850
|
* import { Array, Either } from "effect";
|
|
1694
1851
|
*
|
|
1695
1852
|
* const data = [1, 2, 3, 4, 5]
|
|
@@ -1702,6 +1859,7 @@ const filterMapWhile = exports.filterMapWhile = /*#__PURE__*/(0, _Function.dual)
|
|
|
1702
1859
|
* [1, 3, 5],
|
|
1703
1860
|
* [2, 4]
|
|
1704
1861
|
* ])
|
|
1862
|
+
* ```
|
|
1705
1863
|
*
|
|
1706
1864
|
* @category filtering
|
|
1707
1865
|
* @since 2.0.0
|
|
@@ -1724,12 +1882,14 @@ const partitionMap = exports.partitionMap = /*#__PURE__*/(0, _Function.dual)(2,
|
|
|
1724
1882
|
* Retrieves the `Some` values from an `Iterable` of `Option`s, collecting them into an array.
|
|
1725
1883
|
*
|
|
1726
1884
|
* @example
|
|
1885
|
+
* ```ts
|
|
1727
1886
|
* import { Array, Option } from "effect"
|
|
1728
1887
|
*
|
|
1729
1888
|
* assert.deepStrictEqual(
|
|
1730
1889
|
* Array.getSomes([Option.some(1), Option.none(), Option.some(2)]),
|
|
1731
1890
|
* [1, 2]
|
|
1732
1891
|
* )
|
|
1892
|
+
* ```
|
|
1733
1893
|
*
|
|
1734
1894
|
* @category filtering
|
|
1735
1895
|
* @since 2.0.0
|
|
@@ -1739,12 +1899,14 @@ const getSomes = exports.getSomes = /*#__PURE__*/filterMap(_Function.identity);
|
|
|
1739
1899
|
* Retrieves the `Left` values from an `Iterable` of `Either`s, collecting them into an array.
|
|
1740
1900
|
*
|
|
1741
1901
|
* @example
|
|
1902
|
+
* ```ts
|
|
1742
1903
|
* import { Array, Either } from "effect"
|
|
1743
1904
|
*
|
|
1744
1905
|
* assert.deepStrictEqual(
|
|
1745
1906
|
* Array.getLefts([Either.right(1), Either.left("err"), Either.right(2)]),
|
|
1746
1907
|
* ["err"]
|
|
1747
1908
|
* )
|
|
1909
|
+
* ```
|
|
1748
1910
|
*
|
|
1749
1911
|
* @category filtering
|
|
1750
1912
|
* @since 2.0.0
|
|
@@ -1762,12 +1924,14 @@ const getLefts = self => {
|
|
|
1762
1924
|
* Retrieves the `Right` values from an `Iterable` of `Either`s, collecting them into an array.
|
|
1763
1925
|
*
|
|
1764
1926
|
* @example
|
|
1927
|
+
* ```ts
|
|
1765
1928
|
* import { Array, Either } from "effect"
|
|
1766
1929
|
*
|
|
1767
1930
|
* assert.deepStrictEqual(
|
|
1768
1931
|
* Array.getRights([Either.right(1), Either.left("err"), Either.right(2)]),
|
|
1769
1932
|
* [1, 2]
|
|
1770
1933
|
* )
|
|
1934
|
+
* ```
|
|
1771
1935
|
*
|
|
1772
1936
|
* @category filtering
|
|
1773
1937
|
* @since 2.0.0
|
|
@@ -1820,11 +1984,13 @@ const partition = exports.partition = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
1820
1984
|
* Separates an `Iterable` into two arrays based on a predicate.
|
|
1821
1985
|
*
|
|
1822
1986
|
* @example
|
|
1987
|
+
* ```ts
|
|
1823
1988
|
* import { Array } from "effect"
|
|
1824
1989
|
*
|
|
1825
1990
|
* const numbers = [1, 2, 3, 4]
|
|
1826
1991
|
* const result = Array.partition(numbers, n => n % 2 === 0)
|
|
1827
1992
|
* assert.deepStrictEqual(result, [[1, 3], [2, 4]])
|
|
1993
|
+
* ```
|
|
1828
1994
|
*
|
|
1829
1995
|
* @category filtering
|
|
1830
1996
|
* @since 2.0.0
|
|
@@ -1834,11 +2000,13 @@ const separate = exports.separate = /*#__PURE__*/partitionMap(_Function.identity
|
|
|
1834
2000
|
* Reduces an array from the left.
|
|
1835
2001
|
*
|
|
1836
2002
|
* @example
|
|
2003
|
+
* ```ts
|
|
1837
2004
|
* import { Array } from "effect"
|
|
1838
2005
|
*
|
|
1839
2006
|
* const numbers = [1, 2, 3]
|
|
1840
2007
|
* const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
|
|
1841
2008
|
* assert.deepStrictEqual(result, 6)
|
|
2009
|
+
* ```
|
|
1842
2010
|
*
|
|
1843
2011
|
* @category folding
|
|
1844
2012
|
* @since 2.0.0
|
|
@@ -1848,11 +2016,13 @@ const reduce = exports.reduce = /*#__PURE__*/(0, _Function.dual)(3, (self, b, f)
|
|
|
1848
2016
|
* Reduces an array from the right.
|
|
1849
2017
|
*
|
|
1850
2018
|
* @example
|
|
2019
|
+
* ```ts
|
|
1851
2020
|
* import { Array } from "effect"
|
|
1852
2021
|
*
|
|
1853
2022
|
* const numbers = [1, 2, 3]
|
|
1854
2023
|
* const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
|
|
1855
2024
|
* assert.deepStrictEqual(result, 6)
|
|
2025
|
+
* ```
|
|
1856
2026
|
*
|
|
1857
2027
|
* @category folding
|
|
1858
2028
|
* @since 2.0.0
|
|
@@ -1862,12 +2032,14 @@ const reduceRight = exports.reduceRight = /*#__PURE__*/(0, _Function.dual)(3, (s
|
|
|
1862
2032
|
* Lifts a predicate into an array.
|
|
1863
2033
|
*
|
|
1864
2034
|
* @example
|
|
2035
|
+
* ```ts
|
|
1865
2036
|
* import { Array } from "effect"
|
|
1866
2037
|
*
|
|
1867
2038
|
* const isEven = (n: number) => n % 2 === 0
|
|
1868
2039
|
* const to = Array.liftPredicate(isEven)
|
|
1869
2040
|
* assert.deepStrictEqual(to(1), [])
|
|
1870
2041
|
* assert.deepStrictEqual(to(2), [2])
|
|
2042
|
+
* ```
|
|
1871
2043
|
*
|
|
1872
2044
|
* @category lifting
|
|
1873
2045
|
* @since 2.0.0
|
|
@@ -1895,6 +2067,7 @@ const liftNullable = f => (...a) => fromNullable(f(...a));
|
|
|
1895
2067
|
* Maps over an array and flattens the result, removing null and undefined values.
|
|
1896
2068
|
*
|
|
1897
2069
|
* @example
|
|
2070
|
+
* ```ts
|
|
1898
2071
|
* import { Array } from "effect"
|
|
1899
2072
|
*
|
|
1900
2073
|
* const numbers = [1, 2, 3]
|
|
@@ -1905,6 +2078,7 @@ const liftNullable = f => (...a) => fromNullable(f(...a));
|
|
|
1905
2078
|
* // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
|
|
1906
2079
|
* // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
|
|
1907
2080
|
* // to remove null values, resulting in [1, 3].
|
|
2081
|
+
* ```
|
|
1908
2082
|
*
|
|
1909
2083
|
* @category sequencing
|
|
1910
2084
|
* @since 2.0.0
|
|
@@ -1917,6 +2091,7 @@ const flatMapNullable = exports.flatMapNullable = /*#__PURE__*/(0, _Function.dua
|
|
|
1917
2091
|
* If the `Either` is a right, it returns an array with the right value.
|
|
1918
2092
|
*
|
|
1919
2093
|
* @example
|
|
2094
|
+
* ```ts
|
|
1920
2095
|
* import { Array, Either } from "effect"
|
|
1921
2096
|
*
|
|
1922
2097
|
* const parseNumber = (s: string): Either.Either<number, Error> =>
|
|
@@ -1934,6 +2109,7 @@ const flatMapNullable = exports.flatMapNullable = /*#__PURE__*/(0, _Function.dua
|
|
|
1934
2109
|
* // The function parseNumber is lifted to return an array.
|
|
1935
2110
|
* // When parsing "42", it returns an Either.left with the number 42, resulting in [42].
|
|
1936
2111
|
* // When parsing "not a number", it returns an Either.right with an error, resulting in an empty array [].
|
|
2112
|
+
* ```
|
|
1937
2113
|
*
|
|
1938
2114
|
* @category lifting
|
|
1939
2115
|
* @since 2.0.0
|
|
@@ -1961,6 +2137,7 @@ const some = exports.some = /*#__PURE__*/(0, _Function.dual)(2, (self, predicate
|
|
|
1961
2137
|
* Extends an array with a function that maps each subarray to a value.
|
|
1962
2138
|
*
|
|
1963
2139
|
* @example
|
|
2140
|
+
* ```ts
|
|
1964
2141
|
* import { Array } from "effect"
|
|
1965
2142
|
*
|
|
1966
2143
|
* const numbers = [1, 2, 3]
|
|
@@ -1972,6 +2149,7 @@ const some = exports.some = /*#__PURE__*/(0, _Function.dual)(2, (self, predicate
|
|
|
1972
2149
|
* // The subarrays are: [1, 2, 3], [2, 3], [3].
|
|
1973
2150
|
* // The lengths are: 3, 2, 1.
|
|
1974
2151
|
* // Therefore, the result is [3, 2, 1].
|
|
2152
|
+
* ```
|
|
1975
2153
|
*
|
|
1976
2154
|
* @since 2.0.0
|
|
1977
2155
|
*/
|
|
@@ -1980,10 +2158,12 @@ const extend = exports.extend = /*#__PURE__*/(0, _Function.dual)(2, (self, f) =>
|
|
|
1980
2158
|
* Finds the minimum element in an array based on a comparator.
|
|
1981
2159
|
*
|
|
1982
2160
|
* @example
|
|
2161
|
+
* ```ts
|
|
1983
2162
|
* import { Array, Order } from "effect"
|
|
1984
2163
|
*
|
|
1985
2164
|
* const min = Array.min([3, 1, 2], Order.number)
|
|
1986
2165
|
* assert.deepStrictEqual(min, 1)
|
|
2166
|
+
* ```
|
|
1987
2167
|
*
|
|
1988
2168
|
* @since 2.0.0
|
|
1989
2169
|
*/
|
|
@@ -1992,10 +2172,12 @@ const min = exports.min = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => self.
|
|
|
1992
2172
|
* Finds the maximum element in an array based on a comparator.
|
|
1993
2173
|
*
|
|
1994
2174
|
* @example
|
|
2175
|
+
* ```ts
|
|
1995
2176
|
* import { Array, Order } from "effect"
|
|
1996
2177
|
*
|
|
1997
2178
|
* const max = Array.max([3, 1, 2], Order.number)
|
|
1998
2179
|
* assert.deepStrictEqual(max, 3)
|
|
2180
|
+
* ```
|
|
1999
2181
|
*
|
|
2000
2182
|
* @since 2.0.0
|
|
2001
2183
|
*/
|
|
@@ -2030,12 +2212,14 @@ const getOrder = exports.getOrder = Order.array;
|
|
|
2030
2212
|
* Creates an equivalence relation for arrays.
|
|
2031
2213
|
*
|
|
2032
2214
|
* @example
|
|
2215
|
+
* ```ts
|
|
2033
2216
|
* import { Array } from "effect"
|
|
2034
2217
|
*
|
|
2035
2218
|
* const numbers1 = [1, 2, 3]
|
|
2036
2219
|
* const numbers2 = [1, 2, 3]
|
|
2037
2220
|
* const eq = Array.getEquivalence<number>((a, b) => a === b)
|
|
2038
2221
|
* assert.deepStrictEqual(eq(numbers1, numbers2), true)
|
|
2222
|
+
* ```
|
|
2039
2223
|
*
|
|
2040
2224
|
* @category instances
|
|
2041
2225
|
* @since 2.0.0
|
|
@@ -2045,10 +2229,12 @@ const getEquivalence = exports.getEquivalence = Equivalence.array;
|
|
|
2045
2229
|
* Performs a side-effect for each element of the `Iterable`.
|
|
2046
2230
|
*
|
|
2047
2231
|
* @example
|
|
2232
|
+
* ```ts
|
|
2048
2233
|
* import { Array } from "effect"
|
|
2049
2234
|
*
|
|
2050
2235
|
* const numbers = [1, 2, 3]
|
|
2051
2236
|
* Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
|
|
2237
|
+
* ```
|
|
2052
2238
|
*
|
|
2053
2239
|
* @since 2.0.0
|
|
2054
2240
|
*/
|
|
@@ -2058,11 +2244,13 @@ const forEach = exports.forEach = /*#__PURE__*/(0, _Function.dual)(2, (self, f)
|
|
|
2058
2244
|
* preserving the order of the first occurrence of each element.
|
|
2059
2245
|
*
|
|
2060
2246
|
* @example
|
|
2247
|
+
* ```ts
|
|
2061
2248
|
* import { Array } from "effect"
|
|
2062
2249
|
*
|
|
2063
2250
|
* const numbers = [1, 2, 2, 3, 3, 3]
|
|
2064
2251
|
* const unique = Array.dedupeWith(numbers, (a, b) => a === b)
|
|
2065
2252
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
2253
|
+
* ```
|
|
2066
2254
|
*
|
|
2067
2255
|
* @since 2.0.0
|
|
2068
2256
|
*/
|
|
@@ -2091,11 +2279,13 @@ const dedupe = self => dedupeWith(self, Equal.equivalence());
|
|
|
2091
2279
|
* Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
|
|
2092
2280
|
*
|
|
2093
2281
|
* @example
|
|
2282
|
+
* ```ts
|
|
2094
2283
|
* import { Array } from "effect"
|
|
2095
2284
|
*
|
|
2096
2285
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
2097
2286
|
* const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
2098
2287
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
2288
|
+
* ```
|
|
2099
2289
|
*
|
|
2100
2290
|
* @since 2.0.0
|
|
2101
2291
|
*/
|
|
@@ -2115,11 +2305,13 @@ const dedupeAdjacentWith = exports.dedupeAdjacentWith = /*#__PURE__*/(0, _Functi
|
|
|
2115
2305
|
* Deduplicates adjacent elements that are identical.
|
|
2116
2306
|
*
|
|
2117
2307
|
* @example
|
|
2308
|
+
* ```ts
|
|
2118
2309
|
* import { Array } from "effect"
|
|
2119
2310
|
*
|
|
2120
2311
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
2121
2312
|
* const unique = Array.dedupeAdjacent(numbers)
|
|
2122
2313
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
2314
|
+
* ```
|
|
2123
2315
|
*
|
|
2124
2316
|
* @since 2.0.0
|
|
2125
2317
|
*/
|
|
@@ -2128,11 +2320,13 @@ const dedupeAdjacent = exports.dedupeAdjacent = /*#__PURE__*/dedupeAdjacentWith(
|
|
|
2128
2320
|
* Joins the elements together with "sep" in the middle.
|
|
2129
2321
|
*
|
|
2130
2322
|
* @example
|
|
2323
|
+
* ```ts
|
|
2131
2324
|
* import { Array } from "effect"
|
|
2132
2325
|
*
|
|
2133
2326
|
* const strings = ["a", "b", "c"]
|
|
2134
2327
|
* const joined = Array.join(strings, "-")
|
|
2135
2328
|
* assert.deepStrictEqual(joined, "a-b-c")
|
|
2329
|
+
* ```
|
|
2136
2330
|
*
|
|
2137
2331
|
* @since 2.0.0
|
|
2138
2332
|
* @category folding
|
|
@@ -2142,11 +2336,13 @@ const join = exports.join = /*#__PURE__*/(0, _Function.dual)(2, (self, sep) => f
|
|
|
2142
2336
|
* Statefully maps over the chunk, producing new elements of type `B`.
|
|
2143
2337
|
*
|
|
2144
2338
|
* @example
|
|
2339
|
+
* ```ts
|
|
2145
2340
|
* import { Array } from "effect"
|
|
2146
2341
|
*
|
|
2147
2342
|
* const numbers = [1, 2, 3]
|
|
2148
2343
|
* const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
|
|
2149
2344
|
* assert.deepStrictEqual(result, [6, [1, 3, 6]])
|
|
2345
|
+
* ```
|
|
2150
2346
|
*
|
|
2151
2347
|
* @since 2.0.0
|
|
2152
2348
|
* @category folding
|
|
@@ -2167,12 +2363,14 @@ const mapAccum = exports.mapAccum = /*#__PURE__*/(0, _Function.dual)(3, (self, s
|
|
|
2167
2363
|
* Zips this chunk crosswise with the specified chunk using the specified combiner.
|
|
2168
2364
|
*
|
|
2169
2365
|
* @example
|
|
2366
|
+
* ```ts
|
|
2170
2367
|
* import { Array } from "effect"
|
|
2171
2368
|
*
|
|
2172
2369
|
* const array1 = [1, 2]
|
|
2173
2370
|
* const array2 = ["a", "b"]
|
|
2174
2371
|
* const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
|
|
2175
2372
|
* assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
|
|
2373
|
+
* ```
|
|
2176
2374
|
*
|
|
2177
2375
|
* @since 2.0.0
|
|
2178
2376
|
* @category elements
|
|
@@ -2182,12 +2380,14 @@ const cartesianWith = exports.cartesianWith = /*#__PURE__*/(0, _Function.dual)(3
|
|
|
2182
2380
|
* Zips this chunk crosswise with the specified chunk.
|
|
2183
2381
|
*
|
|
2184
2382
|
* @example
|
|
2383
|
+
* ```ts
|
|
2185
2384
|
* import { Array } from "effect"
|
|
2186
2385
|
*
|
|
2187
2386
|
* const array1 = [1, 2]
|
|
2188
2387
|
* const array2 = ["a", "b"]
|
|
2189
2388
|
* const product = Array.cartesian(array1, array2)
|
|
2190
2389
|
* assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
|
|
2390
|
+
* ```
|
|
2191
2391
|
*
|
|
2192
2392
|
* @since 2.0.0
|
|
2193
2393
|
* @category elements
|
|
@@ -2215,6 +2415,7 @@ const cartesian = exports.cartesian = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
2215
2415
|
* @see {@link let_ let}
|
|
2216
2416
|
*
|
|
2217
2417
|
* @example
|
|
2418
|
+
* ```ts
|
|
2218
2419
|
* import { Array as Arr, pipe } from "effect"
|
|
2219
2420
|
* const doResult = pipe(
|
|
2220
2421
|
* Arr.Do,
|
|
@@ -2235,6 +2436,7 @@ const cartesian = exports.cartesian = /*#__PURE__*/(0, _Function.dual)(2, (self,
|
|
|
2235
2436
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
2236
2437
|
* }
|
|
2237
2438
|
* }
|
|
2439
|
+
* ```
|
|
2238
2440
|
*
|
|
2239
2441
|
* @category do notation
|
|
2240
2442
|
* @since 3.2.0
|
|
@@ -2259,6 +2461,7 @@ const Do = exports.Do = /*#__PURE__*/of({});
|
|
|
2259
2461
|
* @see {@link let_ let}
|
|
2260
2462
|
*
|
|
2261
2463
|
* @example
|
|
2464
|
+
* ```ts
|
|
2262
2465
|
* import { Array as Arr, pipe } from "effect"
|
|
2263
2466
|
* const doResult = pipe(
|
|
2264
2467
|
* Arr.Do,
|
|
@@ -2279,6 +2482,7 @@ const Do = exports.Do = /*#__PURE__*/of({});
|
|
|
2279
2482
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
2280
2483
|
* }
|
|
2281
2484
|
* }
|
|
2485
|
+
* ```
|
|
2282
2486
|
*
|
|
2283
2487
|
* @category do notation
|
|
2284
2488
|
* @since 3.2.0
|
|
@@ -2303,6 +2507,7 @@ const bind = exports.bind = /*#__PURE__*/doNotation.bind(map, flatMap);
|
|
|
2303
2507
|
* @see {@link let_ let}
|
|
2304
2508
|
*
|
|
2305
2509
|
* @example
|
|
2510
|
+
* ```ts
|
|
2306
2511
|
* import { Array as Arr, pipe } from "effect"
|
|
2307
2512
|
* const doResult = pipe(
|
|
2308
2513
|
* Arr.Do,
|
|
@@ -2323,6 +2528,7 @@ const bind = exports.bind = /*#__PURE__*/doNotation.bind(map, flatMap);
|
|
|
2323
2528
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
2324
2529
|
* }
|
|
2325
2530
|
* }
|
|
2531
|
+
* ```
|
|
2326
2532
|
*
|
|
2327
2533
|
* @category do notation
|
|
2328
2534
|
* @since 3.2.0
|