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/src/Array.ts
CHANGED
|
@@ -47,10 +47,12 @@ export type NonEmptyArray<A> = [A, ...Array<A>]
|
|
|
47
47
|
* Builds a `NonEmptyArray` from an non-empty collection of elements.
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
|
+
* ```ts
|
|
50
51
|
* import { Array } from "effect"
|
|
51
52
|
*
|
|
52
53
|
* const result = Array.make(1, 2, 3)
|
|
53
54
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
55
|
+
* ```
|
|
54
56
|
*
|
|
55
57
|
* @category constructors
|
|
56
58
|
* @since 2.0.0
|
|
@@ -63,10 +65,12 @@ export const make = <Elements extends NonEmptyArray<any>>(
|
|
|
63
65
|
* Creates a new `Array` of the specified length.
|
|
64
66
|
*
|
|
65
67
|
* @example
|
|
68
|
+
* ```ts
|
|
66
69
|
* import { Array } from "effect"
|
|
67
70
|
*
|
|
68
71
|
* const result = Array.allocate<number>(3)
|
|
69
72
|
* assert.deepStrictEqual(result.length, 3)
|
|
73
|
+
* ```
|
|
70
74
|
*
|
|
71
75
|
* @category constructors
|
|
72
76
|
* @since 2.0.0
|
|
@@ -79,9 +83,11 @@ export const allocate = <A = never>(n: number): Array<A | undefined> => new Arra
|
|
|
79
83
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
80
84
|
*
|
|
81
85
|
* @example
|
|
86
|
+
* ```ts
|
|
82
87
|
* import { makeBy } from "effect/Array"
|
|
83
88
|
*
|
|
84
89
|
* assert.deepStrictEqual(makeBy(5, n => n * 2), [0, 2, 4, 6, 8])
|
|
90
|
+
* ```
|
|
85
91
|
*
|
|
86
92
|
* @category constructors
|
|
87
93
|
* @since 2.0.0
|
|
@@ -99,9 +105,11 @@ export const makeBy = <A>(n: number, f: (i: number) => A): NonEmptyArray<A> => {
|
|
|
99
105
|
* Return a `NonEmptyArray` containing a range of integers, including both endpoints.
|
|
100
106
|
*
|
|
101
107
|
* @example
|
|
108
|
+
* ```ts
|
|
102
109
|
* import { range } from "effect/Array"
|
|
103
110
|
*
|
|
104
111
|
* assert.deepStrictEqual(range(1, 3), [1, 2, 3])
|
|
112
|
+
* ```
|
|
105
113
|
*
|
|
106
114
|
* @category constructors
|
|
107
115
|
* @since 2.0.0
|
|
@@ -115,9 +123,11 @@ export const range = (start: number, end: number): NonEmptyArray<number> =>
|
|
|
115
123
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
116
124
|
*
|
|
117
125
|
* @example
|
|
126
|
+
* ```ts
|
|
118
127
|
* import { Array } from "effect"
|
|
119
128
|
*
|
|
120
129
|
* assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
|
|
130
|
+
* ```
|
|
121
131
|
*
|
|
122
132
|
* @category constructors
|
|
123
133
|
* @since 2.0.0
|
|
@@ -129,9 +139,11 @@ export const replicate: {
|
|
|
129
139
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
130
140
|
*
|
|
131
141
|
* @example
|
|
142
|
+
* ```ts
|
|
132
143
|
* import { Array } from "effect"
|
|
133
144
|
*
|
|
134
145
|
* assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
|
|
146
|
+
* ```
|
|
135
147
|
*
|
|
136
148
|
* @category constructors
|
|
137
149
|
* @since 2.0.0
|
|
@@ -143,9 +155,11 @@ export const replicate: {
|
|
|
143
155
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
144
156
|
*
|
|
145
157
|
* @example
|
|
158
|
+
* ```ts
|
|
146
159
|
* import { Array } from "effect"
|
|
147
160
|
*
|
|
148
161
|
* assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
|
|
162
|
+
* ```
|
|
149
163
|
*
|
|
150
164
|
* @category constructors
|
|
151
165
|
* @since 2.0.0
|
|
@@ -159,11 +173,13 @@ export const replicate: {
|
|
|
159
173
|
* Otherwise, it converts the iterable collection to an array.
|
|
160
174
|
*
|
|
161
175
|
* @example
|
|
176
|
+
* ```ts
|
|
162
177
|
* import { Array } from "effect"
|
|
163
178
|
*
|
|
164
179
|
* const set = new Set([1, 2, 3])
|
|
165
180
|
* const result = Array.fromIterable(set)
|
|
166
181
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
182
|
+
* ```
|
|
167
183
|
*
|
|
168
184
|
* @category constructors
|
|
169
185
|
* @since 2.0.0
|
|
@@ -175,11 +191,13 @@ export const fromIterable = <A>(collection: Iterable<A>): Array<A> =>
|
|
|
175
191
|
* Creates a new `Array` from a value that might not be an iterable.
|
|
176
192
|
*
|
|
177
193
|
* @example
|
|
194
|
+
* ```ts
|
|
178
195
|
* import { Array } from "effect"
|
|
179
196
|
*
|
|
180
197
|
* assert.deepStrictEqual(Array.ensure("a"), ["a"])
|
|
181
198
|
* assert.deepStrictEqual(Array.ensure(["a"]), ["a"])
|
|
182
199
|
* assert.deepStrictEqual(Array.ensure(["a", "b", "c"]), ["a", "b", "c"])
|
|
200
|
+
* ```
|
|
183
201
|
*
|
|
184
202
|
* @category constructors
|
|
185
203
|
* @since 3.3.0
|
|
@@ -192,10 +210,12 @@ export const ensure = <A>(self: ReadonlyArray<A> | A): Array<A> => Array.isArray
|
|
|
192
210
|
* @param self - The record to transform.
|
|
193
211
|
*
|
|
194
212
|
* @example
|
|
213
|
+
* ```ts
|
|
195
214
|
* import { Array } from "effect"
|
|
196
215
|
*
|
|
197
216
|
* const x = { a: 1, b: 2, c: 3 }
|
|
198
217
|
* assert.deepStrictEqual(Array.fromRecord(x), [["a", 1], ["b", 2], ["c", 3]])
|
|
218
|
+
* ```
|
|
199
219
|
*
|
|
200
220
|
* @category conversions
|
|
201
221
|
* @since 2.0.0
|
|
@@ -206,10 +226,12 @@ export const fromRecord: <K extends string, A>(self: Readonly<Record<K, A>>) =>
|
|
|
206
226
|
* Converts an `Option` to an array.
|
|
207
227
|
*
|
|
208
228
|
* @example
|
|
229
|
+
* ```ts
|
|
209
230
|
* import { Array, Option } from "effect"
|
|
210
231
|
*
|
|
211
232
|
* assert.deepStrictEqual(Array.fromOption(Option.some(1)), [1])
|
|
212
233
|
* assert.deepStrictEqual(Array.fromOption(Option.none()), [])
|
|
234
|
+
* ```
|
|
213
235
|
*
|
|
214
236
|
* @category conversions
|
|
215
237
|
* @since 2.0.0
|
|
@@ -220,6 +242,7 @@ export const fromOption: <A>(self: Option<A>) => Array<A> = O.toArray
|
|
|
220
242
|
* Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
|
|
221
243
|
*
|
|
222
244
|
* @example
|
|
245
|
+
* ```ts
|
|
223
246
|
* import { Array } from "effect"
|
|
224
247
|
*
|
|
225
248
|
* const match = Array.match({
|
|
@@ -228,6 +251,7 @@ export const fromOption: <A>(self: Option<A>) => Array<A> = O.toArray
|
|
|
228
251
|
* })
|
|
229
252
|
* assert.deepStrictEqual(match([]), "empty")
|
|
230
253
|
* assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
|
|
254
|
+
* ```
|
|
231
255
|
*
|
|
232
256
|
* @category pattern matching
|
|
233
257
|
* @since 2.0.0
|
|
@@ -237,6 +261,7 @@ export const match: {
|
|
|
237
261
|
* Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
|
|
238
262
|
*
|
|
239
263
|
* @example
|
|
264
|
+
* ```ts
|
|
240
265
|
* import { Array } from "effect"
|
|
241
266
|
*
|
|
242
267
|
* const match = Array.match({
|
|
@@ -245,6 +270,7 @@ export const match: {
|
|
|
245
270
|
* })
|
|
246
271
|
* assert.deepStrictEqual(match([]), "empty")
|
|
247
272
|
* assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
|
|
273
|
+
* ```
|
|
248
274
|
*
|
|
249
275
|
* @category pattern matching
|
|
250
276
|
* @since 2.0.0
|
|
@@ -259,6 +285,7 @@ export const match: {
|
|
|
259
285
|
* Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
|
|
260
286
|
*
|
|
261
287
|
* @example
|
|
288
|
+
* ```ts
|
|
262
289
|
* import { Array } from "effect"
|
|
263
290
|
*
|
|
264
291
|
* const match = Array.match({
|
|
@@ -267,6 +294,7 @@ export const match: {
|
|
|
267
294
|
* })
|
|
268
295
|
* assert.deepStrictEqual(match([]), "empty")
|
|
269
296
|
* assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
|
|
297
|
+
* ```
|
|
270
298
|
*
|
|
271
299
|
* @category pattern matching
|
|
272
300
|
* @since 2.0.0
|
|
@@ -290,6 +318,7 @@ export const match: {
|
|
|
290
318
|
* Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
|
|
291
319
|
*
|
|
292
320
|
* @example
|
|
321
|
+
* ```ts
|
|
293
322
|
* import { Array } from "effect"
|
|
294
323
|
*
|
|
295
324
|
* const matchLeft = Array.matchLeft({
|
|
@@ -298,6 +327,7 @@ export const match: {
|
|
|
298
327
|
* })
|
|
299
328
|
* assert.deepStrictEqual(matchLeft([]), "empty")
|
|
300
329
|
* assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
|
|
330
|
+
* ```
|
|
301
331
|
*
|
|
302
332
|
* @category pattern matching
|
|
303
333
|
* @since 2.0.0
|
|
@@ -307,6 +337,7 @@ export const matchLeft: {
|
|
|
307
337
|
* Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
|
|
308
338
|
*
|
|
309
339
|
* @example
|
|
340
|
+
* ```ts
|
|
310
341
|
* import { Array } from "effect"
|
|
311
342
|
*
|
|
312
343
|
* const matchLeft = Array.matchLeft({
|
|
@@ -315,6 +346,7 @@ export const matchLeft: {
|
|
|
315
346
|
* })
|
|
316
347
|
* assert.deepStrictEqual(matchLeft([]), "empty")
|
|
317
348
|
* assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
|
|
349
|
+
* ```
|
|
318
350
|
*
|
|
319
351
|
* @category pattern matching
|
|
320
352
|
* @since 2.0.0
|
|
@@ -329,6 +361,7 @@ export const matchLeft: {
|
|
|
329
361
|
* Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
|
|
330
362
|
*
|
|
331
363
|
* @example
|
|
364
|
+
* ```ts
|
|
332
365
|
* import { Array } from "effect"
|
|
333
366
|
*
|
|
334
367
|
* const matchLeft = Array.matchLeft({
|
|
@@ -337,6 +370,7 @@ export const matchLeft: {
|
|
|
337
370
|
* })
|
|
338
371
|
* assert.deepStrictEqual(matchLeft([]), "empty")
|
|
339
372
|
* assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
|
|
373
|
+
* ```
|
|
340
374
|
*
|
|
341
375
|
* @category pattern matching
|
|
342
376
|
* @since 2.0.0
|
|
@@ -360,6 +394,7 @@ export const matchLeft: {
|
|
|
360
394
|
* Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
|
|
361
395
|
*
|
|
362
396
|
* @example
|
|
397
|
+
* ```ts
|
|
363
398
|
* import { Array } from "effect"
|
|
364
399
|
*
|
|
365
400
|
* const matchRight = Array.matchRight({
|
|
@@ -368,6 +403,7 @@ export const matchLeft: {
|
|
|
368
403
|
* })
|
|
369
404
|
* assert.deepStrictEqual(matchRight([]), "empty")
|
|
370
405
|
* assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
|
|
406
|
+
* ```
|
|
371
407
|
*
|
|
372
408
|
* @category pattern matching
|
|
373
409
|
* @since 2.0.0
|
|
@@ -377,6 +413,7 @@ export const matchRight: {
|
|
|
377
413
|
* Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
|
|
378
414
|
*
|
|
379
415
|
* @example
|
|
416
|
+
* ```ts
|
|
380
417
|
* import { Array } from "effect"
|
|
381
418
|
*
|
|
382
419
|
* const matchRight = Array.matchRight({
|
|
@@ -385,6 +422,7 @@ export const matchRight: {
|
|
|
385
422
|
* })
|
|
386
423
|
* assert.deepStrictEqual(matchRight([]), "empty")
|
|
387
424
|
* assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
|
|
425
|
+
* ```
|
|
388
426
|
*
|
|
389
427
|
* @category pattern matching
|
|
390
428
|
* @since 2.0.0
|
|
@@ -399,6 +437,7 @@ export const matchRight: {
|
|
|
399
437
|
* Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
|
|
400
438
|
*
|
|
401
439
|
* @example
|
|
440
|
+
* ```ts
|
|
402
441
|
* import { Array } from "effect"
|
|
403
442
|
*
|
|
404
443
|
* const matchRight = Array.matchRight({
|
|
@@ -407,6 +446,7 @@ export const matchRight: {
|
|
|
407
446
|
* })
|
|
408
447
|
* assert.deepStrictEqual(matchRight([]), "empty")
|
|
409
448
|
* assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
|
|
449
|
+
* ```
|
|
410
450
|
*
|
|
411
451
|
* @category pattern matching
|
|
412
452
|
* @since 2.0.0
|
|
@@ -433,11 +473,13 @@ export const matchRight: {
|
|
|
433
473
|
* Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
|
|
434
474
|
*
|
|
435
475
|
* @example
|
|
476
|
+
* ```ts
|
|
436
477
|
* import { Array } from "effect"
|
|
437
478
|
*
|
|
438
479
|
* const original = [2, 3, 4];
|
|
439
480
|
* const result = Array.prepend(original, 1);
|
|
440
481
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
482
|
+
* ```
|
|
441
483
|
*
|
|
442
484
|
* @category concatenating
|
|
443
485
|
* @since 2.0.0
|
|
@@ -447,11 +489,13 @@ export const prepend: {
|
|
|
447
489
|
* Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
|
|
448
490
|
*
|
|
449
491
|
* @example
|
|
492
|
+
* ```ts
|
|
450
493
|
* import { Array } from "effect"
|
|
451
494
|
*
|
|
452
495
|
* const original = [2, 3, 4];
|
|
453
496
|
* const result = Array.prepend(original, 1);
|
|
454
497
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
498
|
+
* ```
|
|
455
499
|
*
|
|
456
500
|
* @category concatenating
|
|
457
501
|
* @since 2.0.0
|
|
@@ -461,11 +505,13 @@ export const prepend: {
|
|
|
461
505
|
* Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
|
|
462
506
|
*
|
|
463
507
|
* @example
|
|
508
|
+
* ```ts
|
|
464
509
|
* import { Array } from "effect"
|
|
465
510
|
*
|
|
466
511
|
* const original = [2, 3, 4];
|
|
467
512
|
* const result = Array.prepend(original, 1);
|
|
468
513
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
514
|
+
* ```
|
|
469
515
|
*
|
|
470
516
|
* @category concatenating
|
|
471
517
|
* @since 2.0.0
|
|
@@ -478,12 +524,14 @@ export const prepend: {
|
|
|
478
524
|
* If either array is non-empty, the result is also a non-empty array.
|
|
479
525
|
*
|
|
480
526
|
* @example
|
|
527
|
+
* ```ts
|
|
481
528
|
* import { Array } from "effect"
|
|
482
529
|
*
|
|
483
530
|
* const prefix = [0, 1];
|
|
484
531
|
* const array = [2, 3];
|
|
485
532
|
* const result = Array.prependAll(array, prefix);
|
|
486
533
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
534
|
+
* ```
|
|
487
535
|
*
|
|
488
536
|
* @category concatenating
|
|
489
537
|
* @since 2.0.0
|
|
@@ -494,12 +542,14 @@ export const prependAll: {
|
|
|
494
542
|
* If either array is non-empty, the result is also a non-empty array.
|
|
495
543
|
*
|
|
496
544
|
* @example
|
|
545
|
+
* ```ts
|
|
497
546
|
* import { Array } from "effect"
|
|
498
547
|
*
|
|
499
548
|
* const prefix = [0, 1];
|
|
500
549
|
* const array = [2, 3];
|
|
501
550
|
* const result = Array.prependAll(array, prefix);
|
|
502
551
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
552
|
+
* ```
|
|
503
553
|
*
|
|
504
554
|
* @category concatenating
|
|
505
555
|
* @since 2.0.0
|
|
@@ -512,12 +562,14 @@ export const prependAll: {
|
|
|
512
562
|
* If either array is non-empty, the result is also a non-empty array.
|
|
513
563
|
*
|
|
514
564
|
* @example
|
|
565
|
+
* ```ts
|
|
515
566
|
* import { Array } from "effect"
|
|
516
567
|
*
|
|
517
568
|
* const prefix = [0, 1];
|
|
518
569
|
* const array = [2, 3];
|
|
519
570
|
* const result = Array.prependAll(array, prefix);
|
|
520
571
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
572
|
+
* ```
|
|
521
573
|
*
|
|
522
574
|
* @category concatenating
|
|
523
575
|
* @since 2.0.0
|
|
@@ -528,12 +580,14 @@ export const prependAll: {
|
|
|
528
580
|
* If either array is non-empty, the result is also a non-empty array.
|
|
529
581
|
*
|
|
530
582
|
* @example
|
|
583
|
+
* ```ts
|
|
531
584
|
* import { Array } from "effect"
|
|
532
585
|
*
|
|
533
586
|
* const prefix = [0, 1];
|
|
534
587
|
* const array = [2, 3];
|
|
535
588
|
* const result = Array.prependAll(array, prefix);
|
|
536
589
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
590
|
+
* ```
|
|
537
591
|
*
|
|
538
592
|
* @category concatenating
|
|
539
593
|
* @since 2.0.0
|
|
@@ -544,12 +598,14 @@ export const prependAll: {
|
|
|
544
598
|
* If either array is non-empty, the result is also a non-empty array.
|
|
545
599
|
*
|
|
546
600
|
* @example
|
|
601
|
+
* ```ts
|
|
547
602
|
* import { Array } from "effect"
|
|
548
603
|
*
|
|
549
604
|
* const prefix = [0, 1];
|
|
550
605
|
* const array = [2, 3];
|
|
551
606
|
* const result = Array.prependAll(array, prefix);
|
|
552
607
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
608
|
+
* ```
|
|
553
609
|
*
|
|
554
610
|
* @category concatenating
|
|
555
611
|
* @since 2.0.0
|
|
@@ -564,11 +620,13 @@ export const prependAll: {
|
|
|
564
620
|
* Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
|
|
565
621
|
*
|
|
566
622
|
* @example
|
|
623
|
+
* ```ts
|
|
567
624
|
* import { Array } from "effect"
|
|
568
625
|
*
|
|
569
626
|
* const original = [1, 2, 3];
|
|
570
627
|
* const result = Array.append(original, 4);
|
|
571
628
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
629
|
+
* ```
|
|
572
630
|
*
|
|
573
631
|
* @category concatenating
|
|
574
632
|
* @since 2.0.0
|
|
@@ -578,11 +636,13 @@ export const append: {
|
|
|
578
636
|
* Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
|
|
579
637
|
*
|
|
580
638
|
* @example
|
|
639
|
+
* ```ts
|
|
581
640
|
* import { Array } from "effect"
|
|
582
641
|
*
|
|
583
642
|
* const original = [1, 2, 3];
|
|
584
643
|
* const result = Array.append(original, 4);
|
|
585
644
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
645
|
+
* ```
|
|
586
646
|
*
|
|
587
647
|
* @category concatenating
|
|
588
648
|
* @since 2.0.0
|
|
@@ -592,11 +652,13 @@ export const append: {
|
|
|
592
652
|
* Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
|
|
593
653
|
*
|
|
594
654
|
* @example
|
|
655
|
+
* ```ts
|
|
595
656
|
* import { Array } from "effect"
|
|
596
657
|
*
|
|
597
658
|
* const original = [1, 2, 3];
|
|
598
659
|
* const result = Array.append(original, 4);
|
|
599
660
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
661
|
+
* ```
|
|
600
662
|
*
|
|
601
663
|
* @category concatenating
|
|
602
664
|
* @since 2.0.0
|
|
@@ -657,6 +719,7 @@ export const appendAll: {
|
|
|
657
719
|
* a value through a series of transformations.
|
|
658
720
|
*
|
|
659
721
|
* @example
|
|
722
|
+
* ```ts
|
|
660
723
|
* import { Array } from "effect";
|
|
661
724
|
*
|
|
662
725
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -668,6 +731,7 @@ export const appendAll: {
|
|
|
668
731
|
* // and adds each element of the array to this accumulator one by one,
|
|
669
732
|
* // keeping track of the cumulative sum after each addition.
|
|
670
733
|
* // Each of these sums is captured in the resulting array.
|
|
734
|
+
* ```
|
|
671
735
|
*
|
|
672
736
|
* @category folding
|
|
673
737
|
* @since 2.0.0
|
|
@@ -679,6 +743,7 @@ export const scan: {
|
|
|
679
743
|
* a value through a series of transformations.
|
|
680
744
|
*
|
|
681
745
|
* @example
|
|
746
|
+
* ```ts
|
|
682
747
|
* import { Array } from "effect";
|
|
683
748
|
*
|
|
684
749
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -690,6 +755,7 @@ export const scan: {
|
|
|
690
755
|
* // and adds each element of the array to this accumulator one by one,
|
|
691
756
|
* // keeping track of the cumulative sum after each addition.
|
|
692
757
|
* // Each of these sums is captured in the resulting array.
|
|
758
|
+
* ```
|
|
693
759
|
*
|
|
694
760
|
* @category folding
|
|
695
761
|
* @since 2.0.0
|
|
@@ -701,6 +767,7 @@ export const scan: {
|
|
|
701
767
|
* a value through a series of transformations.
|
|
702
768
|
*
|
|
703
769
|
* @example
|
|
770
|
+
* ```ts
|
|
704
771
|
* import { Array } from "effect";
|
|
705
772
|
*
|
|
706
773
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -712,6 +779,7 @@ export const scan: {
|
|
|
712
779
|
* // and adds each element of the array to this accumulator one by one,
|
|
713
780
|
* // keeping track of the cumulative sum after each addition.
|
|
714
781
|
* // Each of these sums is captured in the resulting array.
|
|
782
|
+
* ```
|
|
715
783
|
*
|
|
716
784
|
* @category folding
|
|
717
785
|
* @since 2.0.0
|
|
@@ -733,11 +801,13 @@ export const scan: {
|
|
|
733
801
|
* a value through a series of transformations.
|
|
734
802
|
*
|
|
735
803
|
* @example
|
|
804
|
+
* ```ts
|
|
736
805
|
* import { Array } from "effect";
|
|
737
806
|
*
|
|
738
807
|
* const numbers = [1, 2, 3, 4]
|
|
739
808
|
* const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
|
|
740
809
|
* assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
|
|
810
|
+
* ```
|
|
741
811
|
*
|
|
742
812
|
* @category folding
|
|
743
813
|
* @since 2.0.0
|
|
@@ -749,11 +819,13 @@ export const scanRight: {
|
|
|
749
819
|
* a value through a series of transformations.
|
|
750
820
|
*
|
|
751
821
|
* @example
|
|
822
|
+
* ```ts
|
|
752
823
|
* import { Array } from "effect";
|
|
753
824
|
*
|
|
754
825
|
* const numbers = [1, 2, 3, 4]
|
|
755
826
|
* const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
|
|
756
827
|
* assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
|
|
828
|
+
* ```
|
|
757
829
|
*
|
|
758
830
|
* @category folding
|
|
759
831
|
* @since 2.0.0
|
|
@@ -765,11 +837,13 @@ export const scanRight: {
|
|
|
765
837
|
* a value through a series of transformations.
|
|
766
838
|
*
|
|
767
839
|
* @example
|
|
840
|
+
* ```ts
|
|
768
841
|
* import { Array } from "effect";
|
|
769
842
|
*
|
|
770
843
|
* const numbers = [1, 2, 3, 4]
|
|
771
844
|
* const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
|
|
772
845
|
* assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
|
|
846
|
+
* ```
|
|
773
847
|
*
|
|
774
848
|
* @category folding
|
|
775
849
|
* @since 2.0.0
|
|
@@ -791,10 +865,12 @@ export const scanRight: {
|
|
|
791
865
|
* @param self - The value to check.
|
|
792
866
|
*
|
|
793
867
|
* @example
|
|
868
|
+
* ```ts
|
|
794
869
|
* import { isArray } from "effect/Array"
|
|
795
870
|
*
|
|
796
871
|
* assert.deepStrictEqual(isArray(null), false);
|
|
797
872
|
* assert.deepStrictEqual(isArray([1, 2, 3]), true);
|
|
873
|
+
* ```
|
|
798
874
|
*
|
|
799
875
|
* @category guards
|
|
800
876
|
* @since 2.0.0
|
|
@@ -806,10 +882,12 @@ export const isArray: {
|
|
|
806
882
|
* @param self - The value to check.
|
|
807
883
|
*
|
|
808
884
|
* @example
|
|
885
|
+
* ```ts
|
|
809
886
|
* import { isArray } from "effect/Array"
|
|
810
887
|
*
|
|
811
888
|
* assert.deepStrictEqual(isArray(null), false);
|
|
812
889
|
* assert.deepStrictEqual(isArray([1, 2, 3]), true);
|
|
890
|
+
* ```
|
|
813
891
|
*
|
|
814
892
|
* @category guards
|
|
815
893
|
* @since 2.0.0
|
|
@@ -821,10 +899,12 @@ export const isArray: {
|
|
|
821
899
|
* @param self - The value to check.
|
|
822
900
|
*
|
|
823
901
|
* @example
|
|
902
|
+
* ```ts
|
|
824
903
|
* import { isArray } from "effect/Array"
|
|
825
904
|
*
|
|
826
905
|
* assert.deepStrictEqual(isArray(null), false);
|
|
827
906
|
* assert.deepStrictEqual(isArray([1, 2, 3]), true);
|
|
907
|
+
* ```
|
|
828
908
|
*
|
|
829
909
|
* @category guards
|
|
830
910
|
* @since 2.0.0
|
|
@@ -838,10 +918,12 @@ export const isArray: {
|
|
|
838
918
|
* @param self - The `Array` to check.
|
|
839
919
|
*
|
|
840
920
|
* @example
|
|
921
|
+
* ```ts
|
|
841
922
|
* import { isEmptyArray } from "effect/Array"
|
|
842
923
|
*
|
|
843
924
|
* assert.deepStrictEqual(isEmptyArray([]), true);
|
|
844
925
|
* assert.deepStrictEqual(isEmptyArray([1, 2, 3]), false);
|
|
926
|
+
* ```
|
|
845
927
|
*
|
|
846
928
|
* @category guards
|
|
847
929
|
* @since 2.0.0
|
|
@@ -854,10 +936,12 @@ export const isEmptyArray = <A>(self: Array<A>): self is [] => self.length === 0
|
|
|
854
936
|
* @param self - The `ReadonlyArray` to check.
|
|
855
937
|
*
|
|
856
938
|
* @example
|
|
939
|
+
* ```ts
|
|
857
940
|
* import { isEmptyReadonlyArray } from "effect/Array"
|
|
858
941
|
*
|
|
859
942
|
* assert.deepStrictEqual(isEmptyReadonlyArray([]), true);
|
|
860
943
|
* assert.deepStrictEqual(isEmptyReadonlyArray([1, 2, 3]), false);
|
|
944
|
+
* ```
|
|
861
945
|
*
|
|
862
946
|
* @category guards
|
|
863
947
|
* @since 2.0.0
|
|
@@ -872,10 +956,12 @@ export const isEmptyReadonlyArray: <A>(self: ReadonlyArray<A>) => self is readon
|
|
|
872
956
|
* @param self - The `Array` to check.
|
|
873
957
|
*
|
|
874
958
|
* @example
|
|
959
|
+
* ```ts
|
|
875
960
|
* import { isNonEmptyArray } from "effect/Array"
|
|
876
961
|
*
|
|
877
962
|
* assert.deepStrictEqual(isNonEmptyArray([]), false);
|
|
878
963
|
* assert.deepStrictEqual(isNonEmptyArray([1, 2, 3]), true);
|
|
964
|
+
* ```
|
|
879
965
|
*
|
|
880
966
|
* @category guards
|
|
881
967
|
* @since 2.0.0
|
|
@@ -890,10 +976,12 @@ export const isNonEmptyArray: <A>(self: Array<A>) => self is NonEmptyArray<A> =
|
|
|
890
976
|
* @param self - The `ReadonlyArray` to check.
|
|
891
977
|
*
|
|
892
978
|
* @example
|
|
979
|
+
* ```ts
|
|
893
980
|
* import { isNonEmptyReadonlyArray } from "effect/Array"
|
|
894
981
|
*
|
|
895
982
|
* assert.deepStrictEqual(isNonEmptyReadonlyArray([]), false);
|
|
896
983
|
* assert.deepStrictEqual(isNonEmptyReadonlyArray([1, 2, 3]), true);
|
|
984
|
+
* ```
|
|
897
985
|
*
|
|
898
986
|
* @category guards
|
|
899
987
|
* @since 2.0.0
|
|
@@ -972,10 +1060,12 @@ export const unsafeGet: {
|
|
|
972
1060
|
* Return a tuple containing the first element, and a new `Array` of the remaining elements, if any.
|
|
973
1061
|
*
|
|
974
1062
|
* @example
|
|
1063
|
+
* ```ts
|
|
975
1064
|
* import { Array } from "effect";
|
|
976
1065
|
*
|
|
977
1066
|
* const result = Array.unprepend([1, 2, 3, 4])
|
|
978
1067
|
* assert.deepStrictEqual(result, [1, [2, 3, 4]])
|
|
1068
|
+
* ```
|
|
979
1069
|
*
|
|
980
1070
|
* @category splitting
|
|
981
1071
|
* @since 2.0.0
|
|
@@ -988,10 +1078,12 @@ export const unprepend = <A>(
|
|
|
988
1078
|
* Return a tuple containing a copy of the `NonEmptyReadonlyArray` without its last element, and that last element.
|
|
989
1079
|
*
|
|
990
1080
|
* @example
|
|
1081
|
+
* ```ts
|
|
991
1082
|
* import { Array } from "effect";
|
|
992
1083
|
*
|
|
993
1084
|
* const result = Array.unappend([1, 2, 3, 4])
|
|
994
1085
|
* assert.deepStrictEqual(result, [[1, 2, 3], 4])
|
|
1086
|
+
* ```
|
|
995
1087
|
*
|
|
996
1088
|
* @category splitting
|
|
997
1089
|
* @since 2.0.0
|
|
@@ -1012,10 +1104,12 @@ export const head: <A>(self: ReadonlyArray<A>) => Option<A> = get(0)
|
|
|
1012
1104
|
* Get the first element of a non empty array.
|
|
1013
1105
|
*
|
|
1014
1106
|
* @example
|
|
1107
|
+
* ```ts
|
|
1015
1108
|
* import { Array } from "effect"
|
|
1016
1109
|
*
|
|
1017
1110
|
* const result = Array.headNonEmpty([1, 2, 3, 4])
|
|
1018
1111
|
* assert.deepStrictEqual(result, 1)
|
|
1112
|
+
* ```
|
|
1019
1113
|
*
|
|
1020
1114
|
* @category getters
|
|
1021
1115
|
* @since 2.0.0
|
|
@@ -1035,10 +1129,12 @@ export const last = <A>(self: ReadonlyArray<A>): Option<A> =>
|
|
|
1035
1129
|
* Get the last element of a non empty array.
|
|
1036
1130
|
*
|
|
1037
1131
|
* @example
|
|
1132
|
+
* ```ts
|
|
1038
1133
|
* import { Array } from "effect"
|
|
1039
1134
|
*
|
|
1040
1135
|
* const result = Array.lastNonEmpty([1, 2, 3, 4])
|
|
1041
1136
|
* assert.deepStrictEqual(result, 4)
|
|
1137
|
+
* ```
|
|
1042
1138
|
*
|
|
1043
1139
|
* @category getters
|
|
1044
1140
|
* @since 2.0.0
|
|
@@ -1060,10 +1156,12 @@ export const tail = <A>(self: Iterable<A>): Option<Array<A>> => {
|
|
|
1060
1156
|
* Get all but the first element of a `NonEmptyReadonlyArray`.
|
|
1061
1157
|
*
|
|
1062
1158
|
* @example
|
|
1159
|
+
* ```ts
|
|
1063
1160
|
* import { Array } from "effect"
|
|
1064
1161
|
*
|
|
1065
1162
|
* const result = Array.tailNonEmpty([1, 2, 3, 4])
|
|
1066
1163
|
* assert.deepStrictEqual(result, [2, 3, 4])
|
|
1164
|
+
* ```
|
|
1067
1165
|
*
|
|
1068
1166
|
* @category getters
|
|
1069
1167
|
* @since 2.0.0
|
|
@@ -1085,10 +1183,12 @@ export const init = <A>(self: Iterable<A>): Option<Array<A>> => {
|
|
|
1085
1183
|
* Get all but the last element of a non empty array, creating a new array.
|
|
1086
1184
|
*
|
|
1087
1185
|
* @example
|
|
1186
|
+
* ```ts
|
|
1088
1187
|
* import { Array } from "effect"
|
|
1089
1188
|
*
|
|
1090
1189
|
* const result = Array.initNonEmpty([1, 2, 3, 4])
|
|
1091
1190
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1191
|
+
* ```
|
|
1092
1192
|
*
|
|
1093
1193
|
* @category getters
|
|
1094
1194
|
* @since 2.0.0
|
|
@@ -1101,11 +1201,13 @@ export const initNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): Array<A> => sel
|
|
|
1101
1201
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1102
1202
|
*
|
|
1103
1203
|
* @example
|
|
1204
|
+
* ```ts
|
|
1104
1205
|
* import { Array } from "effect"
|
|
1105
1206
|
*
|
|
1106
1207
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1107
1208
|
* const result = Array.take(numbers, 3)
|
|
1108
1209
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1210
|
+
* ```
|
|
1109
1211
|
*
|
|
1110
1212
|
* @category getters
|
|
1111
1213
|
* @since 2.0.0
|
|
@@ -1117,11 +1219,13 @@ export const take: {
|
|
|
1117
1219
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1118
1220
|
*
|
|
1119
1221
|
* @example
|
|
1222
|
+
* ```ts
|
|
1120
1223
|
* import { Array } from "effect"
|
|
1121
1224
|
*
|
|
1122
1225
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1123
1226
|
* const result = Array.take(numbers, 3)
|
|
1124
1227
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1228
|
+
* ```
|
|
1125
1229
|
*
|
|
1126
1230
|
* @category getters
|
|
1127
1231
|
* @since 2.0.0
|
|
@@ -1133,11 +1237,13 @@ export const take: {
|
|
|
1133
1237
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1134
1238
|
*
|
|
1135
1239
|
* @example
|
|
1240
|
+
* ```ts
|
|
1136
1241
|
* import { Array } from "effect"
|
|
1137
1242
|
*
|
|
1138
1243
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1139
1244
|
* const result = Array.take(numbers, 3)
|
|
1140
1245
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1246
|
+
* ```
|
|
1141
1247
|
*
|
|
1142
1248
|
* @category getters
|
|
1143
1249
|
* @since 2.0.0
|
|
@@ -1154,11 +1260,13 @@ export const take: {
|
|
|
1154
1260
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1155
1261
|
*
|
|
1156
1262
|
* @example
|
|
1263
|
+
* ```ts
|
|
1157
1264
|
* import { Array } from "effect"
|
|
1158
1265
|
*
|
|
1159
1266
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1160
1267
|
* const result = Array.takeRight(numbers, 3)
|
|
1161
1268
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
1269
|
+
* ```
|
|
1162
1270
|
*
|
|
1163
1271
|
* @category getters
|
|
1164
1272
|
* @since 2.0.0
|
|
@@ -1170,11 +1278,13 @@ export const takeRight: {
|
|
|
1170
1278
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1171
1279
|
*
|
|
1172
1280
|
* @example
|
|
1281
|
+
* ```ts
|
|
1173
1282
|
* import { Array } from "effect"
|
|
1174
1283
|
*
|
|
1175
1284
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1176
1285
|
* const result = Array.takeRight(numbers, 3)
|
|
1177
1286
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
1287
|
+
* ```
|
|
1178
1288
|
*
|
|
1179
1289
|
* @category getters
|
|
1180
1290
|
* @since 2.0.0
|
|
@@ -1186,11 +1296,13 @@ export const takeRight: {
|
|
|
1186
1296
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1187
1297
|
*
|
|
1188
1298
|
* @example
|
|
1299
|
+
* ```ts
|
|
1189
1300
|
* import { Array } from "effect"
|
|
1190
1301
|
*
|
|
1191
1302
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1192
1303
|
* const result = Array.takeRight(numbers, 3)
|
|
1193
1304
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
1305
|
+
* ```
|
|
1194
1306
|
*
|
|
1195
1307
|
* @category getters
|
|
1196
1308
|
* @since 2.0.0
|
|
@@ -1206,6 +1318,7 @@ export const takeRight: {
|
|
|
1206
1318
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1207
1319
|
*
|
|
1208
1320
|
* @example
|
|
1321
|
+
* ```ts
|
|
1209
1322
|
* import { Array } from "effect"
|
|
1210
1323
|
*
|
|
1211
1324
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -1217,6 +1330,7 @@ export const takeRight: {
|
|
|
1217
1330
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
1218
1331
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
1219
1332
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
1333
|
+
* ```
|
|
1220
1334
|
*
|
|
1221
1335
|
* @category getters
|
|
1222
1336
|
* @since 2.0.0
|
|
@@ -1226,6 +1340,7 @@ export const takeWhile: {
|
|
|
1226
1340
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1227
1341
|
*
|
|
1228
1342
|
* @example
|
|
1343
|
+
* ```ts
|
|
1229
1344
|
* import { Array } from "effect"
|
|
1230
1345
|
*
|
|
1231
1346
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -1237,6 +1352,7 @@ export const takeWhile: {
|
|
|
1237
1352
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
1238
1353
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
1239
1354
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
1355
|
+
* ```
|
|
1240
1356
|
*
|
|
1241
1357
|
* @category getters
|
|
1242
1358
|
* @since 2.0.0
|
|
@@ -1246,6 +1362,7 @@ export const takeWhile: {
|
|
|
1246
1362
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1247
1363
|
*
|
|
1248
1364
|
* @example
|
|
1365
|
+
* ```ts
|
|
1249
1366
|
* import { Array } from "effect"
|
|
1250
1367
|
*
|
|
1251
1368
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -1257,6 +1374,7 @@ export const takeWhile: {
|
|
|
1257
1374
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
1258
1375
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
1259
1376
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
1377
|
+
* ```
|
|
1260
1378
|
*
|
|
1261
1379
|
* @category getters
|
|
1262
1380
|
* @since 2.0.0
|
|
@@ -1266,6 +1384,7 @@ export const takeWhile: {
|
|
|
1266
1384
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1267
1385
|
*
|
|
1268
1386
|
* @example
|
|
1387
|
+
* ```ts
|
|
1269
1388
|
* import { Array } from "effect"
|
|
1270
1389
|
*
|
|
1271
1390
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -1277,6 +1396,7 @@ export const takeWhile: {
|
|
|
1277
1396
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
1278
1397
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
1279
1398
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
1399
|
+
* ```
|
|
1280
1400
|
*
|
|
1281
1401
|
* @category getters
|
|
1282
1402
|
* @since 2.0.0
|
|
@@ -1286,6 +1406,7 @@ export const takeWhile: {
|
|
|
1286
1406
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1287
1407
|
*
|
|
1288
1408
|
* @example
|
|
1409
|
+
* ```ts
|
|
1289
1410
|
* import { Array } from "effect"
|
|
1290
1411
|
*
|
|
1291
1412
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -1297,6 +1418,7 @@ export const takeWhile: {
|
|
|
1297
1418
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
1298
1419
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
1299
1420
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
1421
|
+
* ```
|
|
1300
1422
|
*
|
|
1301
1423
|
* @category getters
|
|
1302
1424
|
* @since 2.0.0
|
|
@@ -1393,11 +1515,13 @@ export const span: {
|
|
|
1393
1515
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1394
1516
|
*
|
|
1395
1517
|
* @example
|
|
1518
|
+
* ```ts
|
|
1396
1519
|
* import { Array } from "effect"
|
|
1397
1520
|
*
|
|
1398
1521
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1399
1522
|
* const result = Array.drop(numbers, 2)
|
|
1400
1523
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
1524
|
+
* ```
|
|
1401
1525
|
*
|
|
1402
1526
|
* @category getters
|
|
1403
1527
|
* @since 2.0.0
|
|
@@ -1409,11 +1533,13 @@ export const drop: {
|
|
|
1409
1533
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1410
1534
|
*
|
|
1411
1535
|
* @example
|
|
1536
|
+
* ```ts
|
|
1412
1537
|
* import { Array } from "effect"
|
|
1413
1538
|
*
|
|
1414
1539
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1415
1540
|
* const result = Array.drop(numbers, 2)
|
|
1416
1541
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
1542
|
+
* ```
|
|
1417
1543
|
*
|
|
1418
1544
|
* @category getters
|
|
1419
1545
|
* @since 2.0.0
|
|
@@ -1425,11 +1551,13 @@ export const drop: {
|
|
|
1425
1551
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1426
1552
|
*
|
|
1427
1553
|
* @example
|
|
1554
|
+
* ```ts
|
|
1428
1555
|
* import { Array } from "effect"
|
|
1429
1556
|
*
|
|
1430
1557
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1431
1558
|
* const result = Array.drop(numbers, 2)
|
|
1432
1559
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
1560
|
+
* ```
|
|
1433
1561
|
*
|
|
1434
1562
|
* @category getters
|
|
1435
1563
|
* @since 2.0.0
|
|
@@ -1446,11 +1574,13 @@ export const drop: {
|
|
|
1446
1574
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1447
1575
|
*
|
|
1448
1576
|
* @example
|
|
1577
|
+
* ```ts
|
|
1449
1578
|
* import { Array } from "effect"
|
|
1450
1579
|
*
|
|
1451
1580
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1452
1581
|
* const result = Array.dropRight(numbers, 2)
|
|
1453
1582
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1583
|
+
* ```
|
|
1454
1584
|
*
|
|
1455
1585
|
* @category getters
|
|
1456
1586
|
* @since 2.0.0
|
|
@@ -1462,11 +1592,13 @@ export const dropRight: {
|
|
|
1462
1592
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1463
1593
|
*
|
|
1464
1594
|
* @example
|
|
1595
|
+
* ```ts
|
|
1465
1596
|
* import { Array } from "effect"
|
|
1466
1597
|
*
|
|
1467
1598
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1468
1599
|
* const result = Array.dropRight(numbers, 2)
|
|
1469
1600
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1601
|
+
* ```
|
|
1470
1602
|
*
|
|
1471
1603
|
* @category getters
|
|
1472
1604
|
* @since 2.0.0
|
|
@@ -1478,11 +1610,13 @@ export const dropRight: {
|
|
|
1478
1610
|
* **Note**. `n` is normalized to a non negative integer.
|
|
1479
1611
|
*
|
|
1480
1612
|
* @example
|
|
1613
|
+
* ```ts
|
|
1481
1614
|
* import { Array } from "effect"
|
|
1482
1615
|
*
|
|
1483
1616
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1484
1617
|
* const result = Array.dropRight(numbers, 2)
|
|
1485
1618
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1619
|
+
* ```
|
|
1486
1620
|
*
|
|
1487
1621
|
* @category getters
|
|
1488
1622
|
* @since 2.0.0
|
|
@@ -1497,11 +1631,13 @@ export const dropRight: {
|
|
|
1497
1631
|
* Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1498
1632
|
*
|
|
1499
1633
|
* @example
|
|
1634
|
+
* ```ts
|
|
1500
1635
|
* import { Array } from "effect"
|
|
1501
1636
|
*
|
|
1502
1637
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1503
1638
|
* const result = Array.dropWhile(numbers, x => x < 4)
|
|
1504
1639
|
* assert.deepStrictEqual(result, [4, 5])
|
|
1640
|
+
* ```
|
|
1505
1641
|
*
|
|
1506
1642
|
* @category getters
|
|
1507
1643
|
* @since 2.0.0
|
|
@@ -1511,11 +1647,13 @@ export const dropWhile: {
|
|
|
1511
1647
|
* Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1512
1648
|
*
|
|
1513
1649
|
* @example
|
|
1650
|
+
* ```ts
|
|
1514
1651
|
* import { Array } from "effect"
|
|
1515
1652
|
*
|
|
1516
1653
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1517
1654
|
* const result = Array.dropWhile(numbers, x => x < 4)
|
|
1518
1655
|
* assert.deepStrictEqual(result, [4, 5])
|
|
1656
|
+
* ```
|
|
1519
1657
|
*
|
|
1520
1658
|
* @category getters
|
|
1521
1659
|
* @since 2.0.0
|
|
@@ -1525,11 +1663,13 @@ export const dropWhile: {
|
|
|
1525
1663
|
* Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
1526
1664
|
*
|
|
1527
1665
|
* @example
|
|
1666
|
+
* ```ts
|
|
1528
1667
|
* import { Array } from "effect"
|
|
1529
1668
|
*
|
|
1530
1669
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1531
1670
|
* const result = Array.dropWhile(numbers, x => x < 4)
|
|
1532
1671
|
* assert.deepStrictEqual(result, [4, 5])
|
|
1672
|
+
* ```
|
|
1533
1673
|
*
|
|
1534
1674
|
* @category getters
|
|
1535
1675
|
* @since 2.0.0
|
|
@@ -1545,11 +1685,13 @@ export const dropWhile: {
|
|
|
1545
1685
|
* Return the first index for which a predicate holds.
|
|
1546
1686
|
*
|
|
1547
1687
|
* @example
|
|
1688
|
+
* ```ts
|
|
1548
1689
|
* import { Array, Option } from "effect"
|
|
1549
1690
|
*
|
|
1550
1691
|
* const numbers = [5, 3, 8, 9]
|
|
1551
1692
|
* const result = Array.findFirstIndex(numbers, x => x > 5)
|
|
1552
1693
|
* assert.deepStrictEqual(result, Option.some(2))
|
|
1694
|
+
* ```
|
|
1553
1695
|
*
|
|
1554
1696
|
* @category elements
|
|
1555
1697
|
* @since 2.0.0
|
|
@@ -1559,11 +1701,13 @@ export const findFirstIndex: {
|
|
|
1559
1701
|
* Return the first index for which a predicate holds.
|
|
1560
1702
|
*
|
|
1561
1703
|
* @example
|
|
1704
|
+
* ```ts
|
|
1562
1705
|
* import { Array, Option } from "effect"
|
|
1563
1706
|
*
|
|
1564
1707
|
* const numbers = [5, 3, 8, 9]
|
|
1565
1708
|
* const result = Array.findFirstIndex(numbers, x => x > 5)
|
|
1566
1709
|
* assert.deepStrictEqual(result, Option.some(2))
|
|
1710
|
+
* ```
|
|
1567
1711
|
*
|
|
1568
1712
|
* @category elements
|
|
1569
1713
|
* @since 2.0.0
|
|
@@ -1573,11 +1717,13 @@ export const findFirstIndex: {
|
|
|
1573
1717
|
* Return the first index for which a predicate holds.
|
|
1574
1718
|
*
|
|
1575
1719
|
* @example
|
|
1720
|
+
* ```ts
|
|
1576
1721
|
* import { Array, Option } from "effect"
|
|
1577
1722
|
*
|
|
1578
1723
|
* const numbers = [5, 3, 8, 9]
|
|
1579
1724
|
* const result = Array.findFirstIndex(numbers, x => x > 5)
|
|
1580
1725
|
* assert.deepStrictEqual(result, Option.some(2))
|
|
1726
|
+
* ```
|
|
1581
1727
|
*
|
|
1582
1728
|
* @category elements
|
|
1583
1729
|
* @since 2.0.0
|
|
@@ -1598,11 +1744,13 @@ export const findFirstIndex: {
|
|
|
1598
1744
|
* Return the last index for which a predicate holds.
|
|
1599
1745
|
*
|
|
1600
1746
|
* @example
|
|
1747
|
+
* ```ts
|
|
1601
1748
|
* import { Array, Option } from "effect"
|
|
1602
1749
|
*
|
|
1603
1750
|
* const numbers = [1, 3, 8, 9]
|
|
1604
1751
|
* const result = Array.findLastIndex(numbers, x => x < 5)
|
|
1605
1752
|
* assert.deepStrictEqual(result, Option.some(1))
|
|
1753
|
+
* ```
|
|
1606
1754
|
*
|
|
1607
1755
|
* @category elements
|
|
1608
1756
|
* @since 2.0.0
|
|
@@ -1612,11 +1760,13 @@ export const findLastIndex: {
|
|
|
1612
1760
|
* Return the last index for which a predicate holds.
|
|
1613
1761
|
*
|
|
1614
1762
|
* @example
|
|
1763
|
+
* ```ts
|
|
1615
1764
|
* import { Array, Option } from "effect"
|
|
1616
1765
|
*
|
|
1617
1766
|
* const numbers = [1, 3, 8, 9]
|
|
1618
1767
|
* const result = Array.findLastIndex(numbers, x => x < 5)
|
|
1619
1768
|
* assert.deepStrictEqual(result, Option.some(1))
|
|
1769
|
+
* ```
|
|
1620
1770
|
*
|
|
1621
1771
|
* @category elements
|
|
1622
1772
|
* @since 2.0.0
|
|
@@ -1626,11 +1776,13 @@ export const findLastIndex: {
|
|
|
1626
1776
|
* Return the last index for which a predicate holds.
|
|
1627
1777
|
*
|
|
1628
1778
|
* @example
|
|
1779
|
+
* ```ts
|
|
1629
1780
|
* import { Array, Option } from "effect"
|
|
1630
1781
|
*
|
|
1631
1782
|
* const numbers = [1, 3, 8, 9]
|
|
1632
1783
|
* const result = Array.findLastIndex(numbers, x => x < 5)
|
|
1633
1784
|
* assert.deepStrictEqual(result, Option.some(1))
|
|
1785
|
+
* ```
|
|
1634
1786
|
*
|
|
1635
1787
|
* @category elements
|
|
1636
1788
|
* @since 2.0.0
|
|
@@ -1651,11 +1803,13 @@ export const findLastIndex: {
|
|
|
1651
1803
|
* predicate, or `None` if no such element exists.
|
|
1652
1804
|
*
|
|
1653
1805
|
* @example
|
|
1806
|
+
* ```ts
|
|
1654
1807
|
* import { Array, Option } from "effect"
|
|
1655
1808
|
*
|
|
1656
1809
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1657
1810
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1658
1811
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1812
|
+
* ```
|
|
1659
1813
|
*
|
|
1660
1814
|
* @category elements
|
|
1661
1815
|
* @since 2.0.0
|
|
@@ -1666,11 +1820,13 @@ export const findFirst: {
|
|
|
1666
1820
|
* predicate, or `None` if no such element exists.
|
|
1667
1821
|
*
|
|
1668
1822
|
* @example
|
|
1823
|
+
* ```ts
|
|
1669
1824
|
* import { Array, Option } from "effect"
|
|
1670
1825
|
*
|
|
1671
1826
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1672
1827
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1673
1828
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1829
|
+
* ```
|
|
1674
1830
|
*
|
|
1675
1831
|
* @category elements
|
|
1676
1832
|
* @since 2.0.0
|
|
@@ -1681,11 +1837,13 @@ export const findFirst: {
|
|
|
1681
1837
|
* predicate, or `None` if no such element exists.
|
|
1682
1838
|
*
|
|
1683
1839
|
* @example
|
|
1840
|
+
* ```ts
|
|
1684
1841
|
* import { Array, Option } from "effect"
|
|
1685
1842
|
*
|
|
1686
1843
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1687
1844
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1688
1845
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1846
|
+
* ```
|
|
1689
1847
|
*
|
|
1690
1848
|
* @category elements
|
|
1691
1849
|
* @since 2.0.0
|
|
@@ -1696,11 +1854,13 @@ export const findFirst: {
|
|
|
1696
1854
|
* predicate, or `None` if no such element exists.
|
|
1697
1855
|
*
|
|
1698
1856
|
* @example
|
|
1857
|
+
* ```ts
|
|
1699
1858
|
* import { Array, Option } from "effect"
|
|
1700
1859
|
*
|
|
1701
1860
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1702
1861
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1703
1862
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1863
|
+
* ```
|
|
1704
1864
|
*
|
|
1705
1865
|
* @category elements
|
|
1706
1866
|
* @since 2.0.0
|
|
@@ -1711,11 +1871,13 @@ export const findFirst: {
|
|
|
1711
1871
|
* predicate, or `None` if no such element exists.
|
|
1712
1872
|
*
|
|
1713
1873
|
* @example
|
|
1874
|
+
* ```ts
|
|
1714
1875
|
* import { Array, Option } from "effect"
|
|
1715
1876
|
*
|
|
1716
1877
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1717
1878
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1718
1879
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1880
|
+
* ```
|
|
1719
1881
|
*
|
|
1720
1882
|
* @category elements
|
|
1721
1883
|
* @since 2.0.0
|
|
@@ -1726,11 +1888,13 @@ export const findFirst: {
|
|
|
1726
1888
|
* predicate, or `None` if no such element exists.
|
|
1727
1889
|
*
|
|
1728
1890
|
* @example
|
|
1891
|
+
* ```ts
|
|
1729
1892
|
* import { Array, Option } from "effect"
|
|
1730
1893
|
*
|
|
1731
1894
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1732
1895
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1733
1896
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1897
|
+
* ```
|
|
1734
1898
|
*
|
|
1735
1899
|
* @category elements
|
|
1736
1900
|
* @since 2.0.0
|
|
@@ -1741,11 +1905,13 @@ export const findFirst: {
|
|
|
1741
1905
|
* predicate, or `None` if no such element exists.
|
|
1742
1906
|
*
|
|
1743
1907
|
* @example
|
|
1908
|
+
* ```ts
|
|
1744
1909
|
* import { Array, Option } from "effect"
|
|
1745
1910
|
*
|
|
1746
1911
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1747
1912
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
1748
1913
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1914
|
+
* ```
|
|
1749
1915
|
*
|
|
1750
1916
|
* @category elements
|
|
1751
1917
|
* @since 2.0.0
|
|
@@ -1758,11 +1924,13 @@ export const findFirst: {
|
|
|
1758
1924
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1759
1925
|
*
|
|
1760
1926
|
* @example
|
|
1927
|
+
* ```ts
|
|
1761
1928
|
* import { Array, Option } from "effect"
|
|
1762
1929
|
*
|
|
1763
1930
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1764
1931
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1765
1932
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1933
|
+
* ```
|
|
1766
1934
|
*
|
|
1767
1935
|
* @category elements
|
|
1768
1936
|
* @since 2.0.0
|
|
@@ -1773,11 +1941,13 @@ export const findLast: {
|
|
|
1773
1941
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1774
1942
|
*
|
|
1775
1943
|
* @example
|
|
1944
|
+
* ```ts
|
|
1776
1945
|
* import { Array, Option } from "effect"
|
|
1777
1946
|
*
|
|
1778
1947
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1779
1948
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1780
1949
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1950
|
+
* ```
|
|
1781
1951
|
*
|
|
1782
1952
|
* @category elements
|
|
1783
1953
|
* @since 2.0.0
|
|
@@ -1788,11 +1958,13 @@ export const findLast: {
|
|
|
1788
1958
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1789
1959
|
*
|
|
1790
1960
|
* @example
|
|
1961
|
+
* ```ts
|
|
1791
1962
|
* import { Array, Option } from "effect"
|
|
1792
1963
|
*
|
|
1793
1964
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1794
1965
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1795
1966
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1967
|
+
* ```
|
|
1796
1968
|
*
|
|
1797
1969
|
* @category elements
|
|
1798
1970
|
* @since 2.0.0
|
|
@@ -1803,11 +1975,13 @@ export const findLast: {
|
|
|
1803
1975
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1804
1976
|
*
|
|
1805
1977
|
* @example
|
|
1978
|
+
* ```ts
|
|
1806
1979
|
* import { Array, Option } from "effect"
|
|
1807
1980
|
*
|
|
1808
1981
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1809
1982
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1810
1983
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
1984
|
+
* ```
|
|
1811
1985
|
*
|
|
1812
1986
|
* @category elements
|
|
1813
1987
|
* @since 2.0.0
|
|
@@ -1818,11 +1992,13 @@ export const findLast: {
|
|
|
1818
1992
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1819
1993
|
*
|
|
1820
1994
|
* @example
|
|
1995
|
+
* ```ts
|
|
1821
1996
|
* import { Array, Option } from "effect"
|
|
1822
1997
|
*
|
|
1823
1998
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1824
1999
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1825
2000
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
2001
|
+
* ```
|
|
1826
2002
|
*
|
|
1827
2003
|
* @category elements
|
|
1828
2004
|
* @since 2.0.0
|
|
@@ -1833,11 +2009,13 @@ export const findLast: {
|
|
|
1833
2009
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1834
2010
|
*
|
|
1835
2011
|
* @example
|
|
2012
|
+
* ```ts
|
|
1836
2013
|
* import { Array, Option } from "effect"
|
|
1837
2014
|
*
|
|
1838
2015
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1839
2016
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1840
2017
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
2018
|
+
* ```
|
|
1841
2019
|
*
|
|
1842
2020
|
* @category elements
|
|
1843
2021
|
* @since 2.0.0
|
|
@@ -1848,11 +2026,13 @@ export const findLast: {
|
|
|
1848
2026
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
1849
2027
|
*
|
|
1850
2028
|
* @example
|
|
2029
|
+
* ```ts
|
|
1851
2030
|
* import { Array, Option } from "effect"
|
|
1852
2031
|
*
|
|
1853
2032
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1854
2033
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
1855
2034
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
2035
|
+
* ```
|
|
1856
2036
|
*
|
|
1857
2037
|
* @category elements
|
|
1858
2038
|
* @since 2.0.0
|
|
@@ -1884,11 +2064,13 @@ export const findLast: {
|
|
|
1884
2064
|
* or return `None` if the index is out of bounds.
|
|
1885
2065
|
*
|
|
1886
2066
|
* @example
|
|
2067
|
+
* ```ts
|
|
1887
2068
|
* import { Array, Option } from "effect"
|
|
1888
2069
|
*
|
|
1889
2070
|
* const letters = ['a', 'b', 'c', 'e']
|
|
1890
2071
|
* const result = Array.insertAt(letters, 3, 'd')
|
|
1891
2072
|
* assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
|
|
2073
|
+
* ```
|
|
1892
2074
|
*
|
|
1893
2075
|
* @since 2.0.0
|
|
1894
2076
|
*/
|
|
@@ -1898,11 +2080,13 @@ export const insertAt: {
|
|
|
1898
2080
|
* or return `None` if the index is out of bounds.
|
|
1899
2081
|
*
|
|
1900
2082
|
* @example
|
|
2083
|
+
* ```ts
|
|
1901
2084
|
* import { Array, Option } from "effect"
|
|
1902
2085
|
*
|
|
1903
2086
|
* const letters = ['a', 'b', 'c', 'e']
|
|
1904
2087
|
* const result = Array.insertAt(letters, 3, 'd')
|
|
1905
2088
|
* assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
|
|
2089
|
+
* ```
|
|
1906
2090
|
*
|
|
1907
2091
|
* @since 2.0.0
|
|
1908
2092
|
*/
|
|
@@ -1912,11 +2096,13 @@ export const insertAt: {
|
|
|
1912
2096
|
* or return `None` if the index is out of bounds.
|
|
1913
2097
|
*
|
|
1914
2098
|
* @example
|
|
2099
|
+
* ```ts
|
|
1915
2100
|
* import { Array, Option } from "effect"
|
|
1916
2101
|
*
|
|
1917
2102
|
* const letters = ['a', 'b', 'c', 'e']
|
|
1918
2103
|
* const result = Array.insertAt(letters, 3, 'd')
|
|
1919
2104
|
* assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
|
|
2105
|
+
* ```
|
|
1920
2106
|
*
|
|
1921
2107
|
* @since 2.0.0
|
|
1922
2108
|
*/
|
|
@@ -1936,11 +2122,13 @@ export const insertAt: {
|
|
|
1936
2122
|
* or return a copy of the input if the index is out of bounds.
|
|
1937
2123
|
*
|
|
1938
2124
|
* @example
|
|
2125
|
+
* ```ts
|
|
1939
2126
|
* import { Array } from "effect"
|
|
1940
2127
|
*
|
|
1941
2128
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1942
2129
|
* const result = Array.replace(letters, 1, 'z')
|
|
1943
2130
|
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
|
|
2131
|
+
* ```
|
|
1944
2132
|
*
|
|
1945
2133
|
* @since 2.0.0
|
|
1946
2134
|
*/
|
|
@@ -1950,11 +2138,13 @@ export const replace: {
|
|
|
1950
2138
|
* or return a copy of the input if the index is out of bounds.
|
|
1951
2139
|
*
|
|
1952
2140
|
* @example
|
|
2141
|
+
* ```ts
|
|
1953
2142
|
* import { Array } from "effect"
|
|
1954
2143
|
*
|
|
1955
2144
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1956
2145
|
* const result = Array.replace(letters, 1, 'z')
|
|
1957
2146
|
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
|
|
2147
|
+
* ```
|
|
1958
2148
|
*
|
|
1959
2149
|
* @since 2.0.0
|
|
1960
2150
|
*/
|
|
@@ -1966,11 +2156,13 @@ export const replace: {
|
|
|
1966
2156
|
* or return a copy of the input if the index is out of bounds.
|
|
1967
2157
|
*
|
|
1968
2158
|
* @example
|
|
2159
|
+
* ```ts
|
|
1969
2160
|
* import { Array } from "effect"
|
|
1970
2161
|
*
|
|
1971
2162
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1972
2163
|
* const result = Array.replace(letters, 1, 'z')
|
|
1973
2164
|
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
|
|
2165
|
+
* ```
|
|
1974
2166
|
*
|
|
1975
2167
|
* @since 2.0.0
|
|
1976
2168
|
*/
|
|
@@ -1985,11 +2177,13 @@ export const replace: {
|
|
|
1985
2177
|
* Replaces an element in an array with the given value, returning an option of the updated array.
|
|
1986
2178
|
*
|
|
1987
2179
|
* @example
|
|
2180
|
+
* ```ts
|
|
1988
2181
|
* import { Array, Option } from "effect"
|
|
1989
2182
|
*
|
|
1990
2183
|
* const numbers = [1, 2, 3]
|
|
1991
2184
|
* const result = Array.replaceOption(numbers, 1, 4)
|
|
1992
2185
|
* assert.deepStrictEqual(result, Option.some([1, 4, 3]))
|
|
2186
|
+
* ```
|
|
1993
2187
|
*
|
|
1994
2188
|
* @since 2.0.0
|
|
1995
2189
|
*/
|
|
@@ -1998,11 +2192,13 @@ export const replaceOption: {
|
|
|
1998
2192
|
* Replaces an element in an array with the given value, returning an option of the updated array.
|
|
1999
2193
|
*
|
|
2000
2194
|
* @example
|
|
2195
|
+
* ```ts
|
|
2001
2196
|
* import { Array, Option } from "effect"
|
|
2002
2197
|
*
|
|
2003
2198
|
* const numbers = [1, 2, 3]
|
|
2004
2199
|
* const result = Array.replaceOption(numbers, 1, 4)
|
|
2005
2200
|
* assert.deepStrictEqual(result, Option.some([1, 4, 3]))
|
|
2201
|
+
* ```
|
|
2006
2202
|
*
|
|
2007
2203
|
* @since 2.0.0
|
|
2008
2204
|
*/
|
|
@@ -2014,11 +2210,13 @@ export const replaceOption: {
|
|
|
2014
2210
|
* Replaces an element in an array with the given value, returning an option of the updated array.
|
|
2015
2211
|
*
|
|
2016
2212
|
* @example
|
|
2213
|
+
* ```ts
|
|
2017
2214
|
* import { Array, Option } from "effect"
|
|
2018
2215
|
*
|
|
2019
2216
|
* const numbers = [1, 2, 3]
|
|
2020
2217
|
* const result = Array.replaceOption(numbers, 1, 4)
|
|
2021
2218
|
* assert.deepStrictEqual(result, Option.some([1, 4, 3]))
|
|
2219
|
+
* ```
|
|
2022
2220
|
*
|
|
2023
2221
|
* @since 2.0.0
|
|
2024
2222
|
*/
|
|
@@ -2037,11 +2235,13 @@ export const replaceOption: {
|
|
|
2037
2235
|
* or return a copy of the input if the index is out of bounds.
|
|
2038
2236
|
*
|
|
2039
2237
|
* @example
|
|
2238
|
+
* ```ts
|
|
2040
2239
|
* import { Array } from "effect"
|
|
2041
2240
|
*
|
|
2042
2241
|
* const numbers = [1, 2, 3, 4]
|
|
2043
2242
|
* const result = Array.modify(numbers, 2, (n) => n * 2)
|
|
2044
2243
|
* assert.deepStrictEqual(result, [1, 2, 6, 4])
|
|
2244
|
+
* ```
|
|
2045
2245
|
*
|
|
2046
2246
|
* @since 2.0.0
|
|
2047
2247
|
*/
|
|
@@ -2051,11 +2251,13 @@ export const modify: {
|
|
|
2051
2251
|
* or return a copy of the input if the index is out of bounds.
|
|
2052
2252
|
*
|
|
2053
2253
|
* @example
|
|
2254
|
+
* ```ts
|
|
2054
2255
|
* import { Array } from "effect"
|
|
2055
2256
|
*
|
|
2056
2257
|
* const numbers = [1, 2, 3, 4]
|
|
2057
2258
|
* const result = Array.modify(numbers, 2, (n) => n * 2)
|
|
2058
2259
|
* assert.deepStrictEqual(result, [1, 2, 6, 4])
|
|
2260
|
+
* ```
|
|
2059
2261
|
*
|
|
2060
2262
|
* @since 2.0.0
|
|
2061
2263
|
*/
|
|
@@ -2068,11 +2270,13 @@ export const modify: {
|
|
|
2068
2270
|
* or return a copy of the input if the index is out of bounds.
|
|
2069
2271
|
*
|
|
2070
2272
|
* @example
|
|
2273
|
+
* ```ts
|
|
2071
2274
|
* import { Array } from "effect"
|
|
2072
2275
|
*
|
|
2073
2276
|
* const numbers = [1, 2, 3, 4]
|
|
2074
2277
|
* const result = Array.modify(numbers, 2, (n) => n * 2)
|
|
2075
2278
|
* assert.deepStrictEqual(result, [1, 2, 6, 4])
|
|
2279
|
+
* ```
|
|
2076
2280
|
*
|
|
2077
2281
|
* @since 2.0.0
|
|
2078
2282
|
*/
|
|
@@ -2092,6 +2296,7 @@ export const modify: {
|
|
|
2092
2296
|
* or return `None` if the index is out of bounds.
|
|
2093
2297
|
*
|
|
2094
2298
|
* @example
|
|
2299
|
+
* ```ts
|
|
2095
2300
|
* import { Array, Option } from "effect"
|
|
2096
2301
|
*
|
|
2097
2302
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2100,6 +2305,7 @@ export const modify: {
|
|
|
2100
2305
|
*
|
|
2101
2306
|
* const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
|
|
2102
2307
|
* assert.deepStrictEqual(outOfBoundsResult, Option.none())
|
|
2308
|
+
* ```
|
|
2103
2309
|
*
|
|
2104
2310
|
* @since 2.0.0
|
|
2105
2311
|
*/
|
|
@@ -2109,6 +2315,7 @@ export const modifyOption: {
|
|
|
2109
2315
|
* or return `None` if the index is out of bounds.
|
|
2110
2316
|
*
|
|
2111
2317
|
* @example
|
|
2318
|
+
* ```ts
|
|
2112
2319
|
* import { Array, Option } from "effect"
|
|
2113
2320
|
*
|
|
2114
2321
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2117,6 +2324,7 @@ export const modifyOption: {
|
|
|
2117
2324
|
*
|
|
2118
2325
|
* const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
|
|
2119
2326
|
* assert.deepStrictEqual(outOfBoundsResult, Option.none())
|
|
2327
|
+
* ```
|
|
2120
2328
|
*
|
|
2121
2329
|
* @since 2.0.0
|
|
2122
2330
|
*/
|
|
@@ -2129,6 +2337,7 @@ export const modifyOption: {
|
|
|
2129
2337
|
* or return `None` if the index is out of bounds.
|
|
2130
2338
|
*
|
|
2131
2339
|
* @example
|
|
2340
|
+
* ```ts
|
|
2132
2341
|
* import { Array, Option } from "effect"
|
|
2133
2342
|
*
|
|
2134
2343
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2137,6 +2346,7 @@ export const modifyOption: {
|
|
|
2137
2346
|
*
|
|
2138
2347
|
* const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
|
|
2139
2348
|
* assert.deepStrictEqual(outOfBoundsResult, Option.none())
|
|
2349
|
+
* ```
|
|
2140
2350
|
*
|
|
2141
2351
|
* @since 2.0.0
|
|
2142
2352
|
*/
|
|
@@ -2161,6 +2371,7 @@ export const modifyOption: {
|
|
|
2161
2371
|
* or return a copy of the input if the index is out of bounds.
|
|
2162
2372
|
*
|
|
2163
2373
|
* @example
|
|
2374
|
+
* ```ts
|
|
2164
2375
|
* import { Array } from "effect"
|
|
2165
2376
|
*
|
|
2166
2377
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2169,6 +2380,7 @@ export const modifyOption: {
|
|
|
2169
2380
|
*
|
|
2170
2381
|
* const outOfBoundsResult = Array.remove(numbers, 5)
|
|
2171
2382
|
* assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
|
|
2383
|
+
* ```
|
|
2172
2384
|
*
|
|
2173
2385
|
* @since 2.0.0
|
|
2174
2386
|
*/
|
|
@@ -2178,6 +2390,7 @@ export const remove: {
|
|
|
2178
2390
|
* or return a copy of the input if the index is out of bounds.
|
|
2179
2391
|
*
|
|
2180
2392
|
* @example
|
|
2393
|
+
* ```ts
|
|
2181
2394
|
* import { Array } from "effect"
|
|
2182
2395
|
*
|
|
2183
2396
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2186,6 +2399,7 @@ export const remove: {
|
|
|
2186
2399
|
*
|
|
2187
2400
|
* const outOfBoundsResult = Array.remove(numbers, 5)
|
|
2188
2401
|
* assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
|
|
2402
|
+
* ```
|
|
2189
2403
|
*
|
|
2190
2404
|
* @since 2.0.0
|
|
2191
2405
|
*/
|
|
@@ -2195,6 +2409,7 @@ export const remove: {
|
|
|
2195
2409
|
* or return a copy of the input if the index is out of bounds.
|
|
2196
2410
|
*
|
|
2197
2411
|
* @example
|
|
2412
|
+
* ```ts
|
|
2198
2413
|
* import { Array } from "effect"
|
|
2199
2414
|
*
|
|
2200
2415
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2203,6 +2418,7 @@ export const remove: {
|
|
|
2203
2418
|
*
|
|
2204
2419
|
* const outOfBoundsResult = Array.remove(numbers, 5)
|
|
2205
2420
|
* assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
|
|
2421
|
+
* ```
|
|
2206
2422
|
*
|
|
2207
2423
|
* @since 2.0.0
|
|
2208
2424
|
*/
|
|
@@ -2220,11 +2436,13 @@ export const remove: {
|
|
|
2220
2436
|
* Reverse an `Iterable`, creating a new `Array`.
|
|
2221
2437
|
*
|
|
2222
2438
|
* @example
|
|
2439
|
+
* ```ts
|
|
2223
2440
|
* import { Array } from "effect"
|
|
2224
2441
|
*
|
|
2225
2442
|
* const numbers = [1, 2, 3, 4]
|
|
2226
2443
|
* const result = Array.reverse(numbers)
|
|
2227
2444
|
* assert.deepStrictEqual(result, [4, 3, 2, 1])
|
|
2445
|
+
* ```
|
|
2228
2446
|
*
|
|
2229
2447
|
* @category elements
|
|
2230
2448
|
* @since 2.0.0
|
|
@@ -2280,6 +2498,7 @@ export const sort: {
|
|
|
2280
2498
|
* order defines how those values should be sorted.
|
|
2281
2499
|
*
|
|
2282
2500
|
* @example
|
|
2501
|
+
* ```ts
|
|
2283
2502
|
* import { Array, Order } from "effect"
|
|
2284
2503
|
*
|
|
2285
2504
|
* const strings = ["aaa", "b", "cc"]
|
|
@@ -2290,6 +2509,7 @@ export const sort: {
|
|
|
2290
2509
|
* // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
|
|
2291
2510
|
* // converts each string into its length, and the `Order.number` specifies that the lengths should
|
|
2292
2511
|
* // be sorted in ascending order.
|
|
2512
|
+
* ```
|
|
2293
2513
|
*
|
|
2294
2514
|
* @since 2.0.0
|
|
2295
2515
|
* @category elements
|
|
@@ -2301,6 +2521,7 @@ export const sortWith: {
|
|
|
2301
2521
|
* order defines how those values should be sorted.
|
|
2302
2522
|
*
|
|
2303
2523
|
* @example
|
|
2524
|
+
* ```ts
|
|
2304
2525
|
* import { Array, Order } from "effect"
|
|
2305
2526
|
*
|
|
2306
2527
|
* const strings = ["aaa", "b", "cc"]
|
|
@@ -2311,6 +2532,7 @@ export const sortWith: {
|
|
|
2311
2532
|
* // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
|
|
2312
2533
|
* // converts each string into its length, and the `Order.number` specifies that the lengths should
|
|
2313
2534
|
* // be sorted in ascending order.
|
|
2535
|
+
* ```
|
|
2314
2536
|
*
|
|
2315
2537
|
* @since 2.0.0
|
|
2316
2538
|
* @category elements
|
|
@@ -2325,6 +2547,7 @@ export const sortWith: {
|
|
|
2325
2547
|
* order defines how those values should be sorted.
|
|
2326
2548
|
*
|
|
2327
2549
|
* @example
|
|
2550
|
+
* ```ts
|
|
2328
2551
|
* import { Array, Order } from "effect"
|
|
2329
2552
|
*
|
|
2330
2553
|
* const strings = ["aaa", "b", "cc"]
|
|
@@ -2335,6 +2558,7 @@ export const sortWith: {
|
|
|
2335
2558
|
* // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
|
|
2336
2559
|
* // converts each string into its length, and the `Order.number` specifies that the lengths should
|
|
2337
2560
|
* // be sorted in ascending order.
|
|
2561
|
+
* ```
|
|
2338
2562
|
*
|
|
2339
2563
|
* @since 2.0.0
|
|
2340
2564
|
* @category elements
|
|
@@ -2346,6 +2570,7 @@ export const sortWith: {
|
|
|
2346
2570
|
* order defines how those values should be sorted.
|
|
2347
2571
|
*
|
|
2348
2572
|
* @example
|
|
2573
|
+
* ```ts
|
|
2349
2574
|
* import { Array, Order } from "effect"
|
|
2350
2575
|
*
|
|
2351
2576
|
* const strings = ["aaa", "b", "cc"]
|
|
@@ -2356,6 +2581,7 @@ export const sortWith: {
|
|
|
2356
2581
|
* // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
|
|
2357
2582
|
* // converts each string into its length, and the `Order.number` specifies that the lengths should
|
|
2358
2583
|
* // be sorted in ascending order.
|
|
2584
|
+
* ```
|
|
2359
2585
|
*
|
|
2360
2586
|
* @since 2.0.0
|
|
2361
2587
|
* @category elements
|
|
@@ -2373,6 +2599,7 @@ export const sortWith: {
|
|
|
2373
2599
|
* second order if the first comparison is equal, and so on.
|
|
2374
2600
|
*
|
|
2375
2601
|
* @example
|
|
2602
|
+
* ```ts
|
|
2376
2603
|
* import { Array, Order } from "effect"
|
|
2377
2604
|
*
|
|
2378
2605
|
* const users = [
|
|
@@ -2395,6 +2622,7 @@ export const sortWith: {
|
|
|
2395
2622
|
* // Explanation:
|
|
2396
2623
|
* // The array of users is sorted first by age in ascending order. When ages are equal,
|
|
2397
2624
|
* // the users are further sorted by name in ascending order.
|
|
2625
|
+
* ```
|
|
2398
2626
|
*
|
|
2399
2627
|
* @category sorting
|
|
2400
2628
|
* @since 2.0.0
|
|
@@ -2420,12 +2648,14 @@ export const sortBy = <S extends Iterable<any> | NonEmptyReadonlyArray<any>>(
|
|
|
2420
2648
|
* longer `Iterable` are discarded.
|
|
2421
2649
|
*
|
|
2422
2650
|
* @example
|
|
2651
|
+
* ```ts
|
|
2423
2652
|
* import { Array } from "effect"
|
|
2424
2653
|
*
|
|
2425
2654
|
* const array1 = [1, 2, 3]
|
|
2426
2655
|
* const array2 = ['a', 'b']
|
|
2427
2656
|
* const result = Array.zip(array1, array2)
|
|
2428
2657
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
2658
|
+
* ```
|
|
2429
2659
|
*
|
|
2430
2660
|
* @category zipping
|
|
2431
2661
|
* @since 2.0.0
|
|
@@ -2437,12 +2667,14 @@ export const zip: {
|
|
|
2437
2667
|
* longer `Iterable` are discarded.
|
|
2438
2668
|
*
|
|
2439
2669
|
* @example
|
|
2670
|
+
* ```ts
|
|
2440
2671
|
* import { Array } from "effect"
|
|
2441
2672
|
*
|
|
2442
2673
|
* const array1 = [1, 2, 3]
|
|
2443
2674
|
* const array2 = ['a', 'b']
|
|
2444
2675
|
* const result = Array.zip(array1, array2)
|
|
2445
2676
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
2677
|
+
* ```
|
|
2446
2678
|
*
|
|
2447
2679
|
* @category zipping
|
|
2448
2680
|
* @since 2.0.0
|
|
@@ -2454,12 +2686,14 @@ export const zip: {
|
|
|
2454
2686
|
* longer `Iterable` are discarded.
|
|
2455
2687
|
*
|
|
2456
2688
|
* @example
|
|
2689
|
+
* ```ts
|
|
2457
2690
|
* import { Array } from "effect"
|
|
2458
2691
|
*
|
|
2459
2692
|
* const array1 = [1, 2, 3]
|
|
2460
2693
|
* const array2 = ['a', 'b']
|
|
2461
2694
|
* const result = Array.zip(array1, array2)
|
|
2462
2695
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
2696
|
+
* ```
|
|
2463
2697
|
*
|
|
2464
2698
|
* @category zipping
|
|
2465
2699
|
* @since 2.0.0
|
|
@@ -2471,12 +2705,14 @@ export const zip: {
|
|
|
2471
2705
|
* longer `Iterable` are discarded.
|
|
2472
2706
|
*
|
|
2473
2707
|
* @example
|
|
2708
|
+
* ```ts
|
|
2474
2709
|
* import { Array } from "effect"
|
|
2475
2710
|
*
|
|
2476
2711
|
* const array1 = [1, 2, 3]
|
|
2477
2712
|
* const array2 = ['a', 'b']
|
|
2478
2713
|
* const result = Array.zip(array1, array2)
|
|
2479
2714
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
2715
|
+
* ```
|
|
2480
2716
|
*
|
|
2481
2717
|
* @category zipping
|
|
2482
2718
|
* @since 2.0.0
|
|
@@ -2488,12 +2724,14 @@ export const zip: {
|
|
|
2488
2724
|
* longer `Iterable` are discarded.
|
|
2489
2725
|
*
|
|
2490
2726
|
* @example
|
|
2727
|
+
* ```ts
|
|
2491
2728
|
* import { Array } from "effect"
|
|
2492
2729
|
*
|
|
2493
2730
|
* const array1 = [1, 2, 3]
|
|
2494
2731
|
* const array2 = ['a', 'b']
|
|
2495
2732
|
* const result = Array.zip(array1, array2)
|
|
2496
2733
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
2734
|
+
* ```
|
|
2497
2735
|
*
|
|
2498
2736
|
* @category zipping
|
|
2499
2737
|
* @since 2.0.0
|
|
@@ -2509,12 +2747,14 @@ export const zip: {
|
|
|
2509
2747
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
2510
2748
|
*
|
|
2511
2749
|
* @example
|
|
2750
|
+
* ```ts
|
|
2512
2751
|
* import { Array } from "effect"
|
|
2513
2752
|
*
|
|
2514
2753
|
* const array1 = [1, 2, 3]
|
|
2515
2754
|
* const array2 = [4, 5, 6]
|
|
2516
2755
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
2517
2756
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
2757
|
+
* ```
|
|
2518
2758
|
*
|
|
2519
2759
|
* @category zipping
|
|
2520
2760
|
* @since 2.0.0
|
|
@@ -2525,12 +2765,14 @@ export const zipWith: {
|
|
|
2525
2765
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
2526
2766
|
*
|
|
2527
2767
|
* @example
|
|
2768
|
+
* ```ts
|
|
2528
2769
|
* import { Array } from "effect"
|
|
2529
2770
|
*
|
|
2530
2771
|
* const array1 = [1, 2, 3]
|
|
2531
2772
|
* const array2 = [4, 5, 6]
|
|
2532
2773
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
2533
2774
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
2775
|
+
* ```
|
|
2534
2776
|
*
|
|
2535
2777
|
* @category zipping
|
|
2536
2778
|
* @since 2.0.0
|
|
@@ -2541,12 +2783,14 @@ export const zipWith: {
|
|
|
2541
2783
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
2542
2784
|
*
|
|
2543
2785
|
* @example
|
|
2786
|
+
* ```ts
|
|
2544
2787
|
* import { Array } from "effect"
|
|
2545
2788
|
*
|
|
2546
2789
|
* const array1 = [1, 2, 3]
|
|
2547
2790
|
* const array2 = [4, 5, 6]
|
|
2548
2791
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
2549
2792
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
2793
|
+
* ```
|
|
2550
2794
|
*
|
|
2551
2795
|
* @category zipping
|
|
2552
2796
|
* @since 2.0.0
|
|
@@ -2557,12 +2801,14 @@ export const zipWith: {
|
|
|
2557
2801
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
2558
2802
|
*
|
|
2559
2803
|
* @example
|
|
2804
|
+
* ```ts
|
|
2560
2805
|
* import { Array } from "effect"
|
|
2561
2806
|
*
|
|
2562
2807
|
* const array1 = [1, 2, 3]
|
|
2563
2808
|
* const array2 = [4, 5, 6]
|
|
2564
2809
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
2565
2810
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
2811
|
+
* ```
|
|
2566
2812
|
*
|
|
2567
2813
|
* @category zipping
|
|
2568
2814
|
* @since 2.0.0
|
|
@@ -2577,12 +2823,14 @@ export const zipWith: {
|
|
|
2577
2823
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
2578
2824
|
*
|
|
2579
2825
|
* @example
|
|
2826
|
+
* ```ts
|
|
2580
2827
|
* import { Array } from "effect"
|
|
2581
2828
|
*
|
|
2582
2829
|
* const array1 = [1, 2, 3]
|
|
2583
2830
|
* const array2 = [4, 5, 6]
|
|
2584
2831
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
2585
2832
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
2833
|
+
* ```
|
|
2586
2834
|
*
|
|
2587
2835
|
* @category zipping
|
|
2588
2836
|
* @since 2.0.0
|
|
@@ -2606,10 +2854,12 @@ export const zipWith: {
|
|
|
2606
2854
|
* This function is the inverse of `zip`. Takes an `Iterable` of pairs and return two corresponding `Array`s.
|
|
2607
2855
|
*
|
|
2608
2856
|
* @example
|
|
2857
|
+
* ```ts
|
|
2609
2858
|
* import { Array } from "effect"
|
|
2610
2859
|
*
|
|
2611
2860
|
* const result = Array.unzip([[1, "a"], [2, "b"], [3, "c"]])
|
|
2612
2861
|
* assert.deepStrictEqual(result, [[1, 2, 3], ['a', 'b', 'c']])
|
|
2862
|
+
* ```
|
|
2613
2863
|
*
|
|
2614
2864
|
* @since 2.0.0
|
|
2615
2865
|
*/
|
|
@@ -2636,11 +2886,13 @@ export const unzip: <S extends Iterable<readonly [any, any]> | NonEmptyReadonlyA
|
|
|
2636
2886
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2637
2887
|
*
|
|
2638
2888
|
* @example
|
|
2889
|
+
* ```ts
|
|
2639
2890
|
* import { Array } from "effect"
|
|
2640
2891
|
*
|
|
2641
2892
|
* const numbers = [1, 2, 3]
|
|
2642
2893
|
* const result = Array.intersperse(numbers, 0)
|
|
2643
2894
|
* assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
|
|
2895
|
+
* ```
|
|
2644
2896
|
*
|
|
2645
2897
|
* @since 2.0.0
|
|
2646
2898
|
*/
|
|
@@ -2650,11 +2902,13 @@ export const intersperse: {
|
|
|
2650
2902
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2651
2903
|
*
|
|
2652
2904
|
* @example
|
|
2905
|
+
* ```ts
|
|
2653
2906
|
* import { Array } from "effect"
|
|
2654
2907
|
*
|
|
2655
2908
|
* const numbers = [1, 2, 3]
|
|
2656
2909
|
* const result = Array.intersperse(numbers, 0)
|
|
2657
2910
|
* assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
|
|
2911
|
+
* ```
|
|
2658
2912
|
*
|
|
2659
2913
|
* @since 2.0.0
|
|
2660
2914
|
*/
|
|
@@ -2664,11 +2918,13 @@ export const intersperse: {
|
|
|
2664
2918
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2665
2919
|
*
|
|
2666
2920
|
* @example
|
|
2921
|
+
* ```ts
|
|
2667
2922
|
* import { Array } from "effect"
|
|
2668
2923
|
*
|
|
2669
2924
|
* const numbers = [1, 2, 3]
|
|
2670
2925
|
* const result = Array.intersperse(numbers, 0)
|
|
2671
2926
|
* assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
|
|
2927
|
+
* ```
|
|
2672
2928
|
*
|
|
2673
2929
|
* @since 2.0.0
|
|
2674
2930
|
*/
|
|
@@ -2678,11 +2934,13 @@ export const intersperse: {
|
|
|
2678
2934
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2679
2935
|
*
|
|
2680
2936
|
* @example
|
|
2937
|
+
* ```ts
|
|
2681
2938
|
* import { Array } from "effect"
|
|
2682
2939
|
*
|
|
2683
2940
|
* const numbers = [1, 2, 3]
|
|
2684
2941
|
* const result = Array.intersperse(numbers, 0)
|
|
2685
2942
|
* assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
|
|
2943
|
+
* ```
|
|
2686
2944
|
*
|
|
2687
2945
|
* @since 2.0.0
|
|
2688
2946
|
*/
|
|
@@ -2707,10 +2965,12 @@ export const intersperse: {
|
|
|
2707
2965
|
* Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
|
|
2708
2966
|
*
|
|
2709
2967
|
* @example
|
|
2968
|
+
* ```ts
|
|
2710
2969
|
* import { Array } from "effect"
|
|
2711
2970
|
*
|
|
2712
2971
|
* const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
|
|
2713
2972
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
2973
|
+
* ```
|
|
2714
2974
|
*
|
|
2715
2975
|
* @since 2.0.0
|
|
2716
2976
|
*/
|
|
@@ -2719,10 +2979,12 @@ export const modifyNonEmptyHead: {
|
|
|
2719
2979
|
* Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
|
|
2720
2980
|
*
|
|
2721
2981
|
* @example
|
|
2982
|
+
* ```ts
|
|
2722
2983
|
* import { Array } from "effect"
|
|
2723
2984
|
*
|
|
2724
2985
|
* const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
|
|
2725
2986
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
2987
|
+
* ```
|
|
2726
2988
|
*
|
|
2727
2989
|
* @since 2.0.0
|
|
2728
2990
|
*/
|
|
@@ -2731,10 +2993,12 @@ export const modifyNonEmptyHead: {
|
|
|
2731
2993
|
* Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
|
|
2732
2994
|
*
|
|
2733
2995
|
* @example
|
|
2996
|
+
* ```ts
|
|
2734
2997
|
* import { Array } from "effect"
|
|
2735
2998
|
*
|
|
2736
2999
|
* const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
|
|
2737
3000
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
3001
|
+
* ```
|
|
2738
3002
|
*
|
|
2739
3003
|
* @since 2.0.0
|
|
2740
3004
|
*/
|
|
@@ -2751,10 +3015,12 @@ export const modifyNonEmptyHead: {
|
|
|
2751
3015
|
* Change the head, creating a new `NonEmptyReadonlyArray`.
|
|
2752
3016
|
*
|
|
2753
3017
|
* @example
|
|
3018
|
+
* ```ts
|
|
2754
3019
|
* import { Array } from "effect"
|
|
2755
3020
|
*
|
|
2756
3021
|
* const result = Array.setNonEmptyHead([1, 2, 3], 10)
|
|
2757
3022
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
3023
|
+
* ```
|
|
2758
3024
|
*
|
|
2759
3025
|
* @since 2.0.0
|
|
2760
3026
|
*/
|
|
@@ -2763,10 +3029,12 @@ export const setNonEmptyHead: {
|
|
|
2763
3029
|
* Change the head, creating a new `NonEmptyReadonlyArray`.
|
|
2764
3030
|
*
|
|
2765
3031
|
* @example
|
|
3032
|
+
* ```ts
|
|
2766
3033
|
* import { Array } from "effect"
|
|
2767
3034
|
*
|
|
2768
3035
|
* const result = Array.setNonEmptyHead([1, 2, 3], 10)
|
|
2769
3036
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
3037
|
+
* ```
|
|
2770
3038
|
*
|
|
2771
3039
|
* @since 2.0.0
|
|
2772
3040
|
*/
|
|
@@ -2775,10 +3043,12 @@ export const setNonEmptyHead: {
|
|
|
2775
3043
|
* Change the head, creating a new `NonEmptyReadonlyArray`.
|
|
2776
3044
|
*
|
|
2777
3045
|
* @example
|
|
3046
|
+
* ```ts
|
|
2778
3047
|
* import { Array } from "effect"
|
|
2779
3048
|
*
|
|
2780
3049
|
* const result = Array.setNonEmptyHead([1, 2, 3], 10)
|
|
2781
3050
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
3051
|
+
* ```
|
|
2782
3052
|
*
|
|
2783
3053
|
* @since 2.0.0
|
|
2784
3054
|
*/
|
|
@@ -2792,10 +3062,12 @@ export const setNonEmptyHead: {
|
|
|
2792
3062
|
* Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
|
|
2793
3063
|
*
|
|
2794
3064
|
* @example
|
|
3065
|
+
* ```ts
|
|
2795
3066
|
* import { Array } from "effect"
|
|
2796
3067
|
*
|
|
2797
3068
|
* const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
|
|
2798
3069
|
* assert.deepStrictEqual(result, [1, 2, 6])
|
|
3070
|
+
* ```
|
|
2799
3071
|
*
|
|
2800
3072
|
* @since 2.0.0
|
|
2801
3073
|
*/
|
|
@@ -2804,10 +3076,12 @@ export const modifyNonEmptyLast: {
|
|
|
2804
3076
|
* Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
|
|
2805
3077
|
*
|
|
2806
3078
|
* @example
|
|
3079
|
+
* ```ts
|
|
2807
3080
|
* import { Array } from "effect"
|
|
2808
3081
|
*
|
|
2809
3082
|
* const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
|
|
2810
3083
|
* assert.deepStrictEqual(result, [1, 2, 6])
|
|
3084
|
+
* ```
|
|
2811
3085
|
*
|
|
2812
3086
|
* @since 2.0.0
|
|
2813
3087
|
*/
|
|
@@ -2816,10 +3090,12 @@ export const modifyNonEmptyLast: {
|
|
|
2816
3090
|
* Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
|
|
2817
3091
|
*
|
|
2818
3092
|
* @example
|
|
3093
|
+
* ```ts
|
|
2819
3094
|
* import { Array } from "effect"
|
|
2820
3095
|
*
|
|
2821
3096
|
* const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
|
|
2822
3097
|
* assert.deepStrictEqual(result, [1, 2, 6])
|
|
3098
|
+
* ```
|
|
2823
3099
|
*
|
|
2824
3100
|
* @since 2.0.0
|
|
2825
3101
|
*/
|
|
@@ -2834,10 +3110,12 @@ export const modifyNonEmptyLast: {
|
|
|
2834
3110
|
* Change the last element, creating a new `NonEmptyReadonlyArray`.
|
|
2835
3111
|
*
|
|
2836
3112
|
* @example
|
|
3113
|
+
* ```ts
|
|
2837
3114
|
* import { Array } from "effect"
|
|
2838
3115
|
*
|
|
2839
3116
|
* const result = Array.setNonEmptyLast([1, 2, 3], 4)
|
|
2840
3117
|
* assert.deepStrictEqual(result, [1, 2, 4])
|
|
3118
|
+
* ```
|
|
2841
3119
|
*
|
|
2842
3120
|
* @since 2.0.0
|
|
2843
3121
|
*/
|
|
@@ -2846,10 +3124,12 @@ export const setNonEmptyLast: {
|
|
|
2846
3124
|
* Change the last element, creating a new `NonEmptyReadonlyArray`.
|
|
2847
3125
|
*
|
|
2848
3126
|
* @example
|
|
3127
|
+
* ```ts
|
|
2849
3128
|
* import { Array } from "effect"
|
|
2850
3129
|
*
|
|
2851
3130
|
* const result = Array.setNonEmptyLast([1, 2, 3], 4)
|
|
2852
3131
|
* assert.deepStrictEqual(result, [1, 2, 4])
|
|
3132
|
+
* ```
|
|
2853
3133
|
*
|
|
2854
3134
|
* @since 2.0.0
|
|
2855
3135
|
*/
|
|
@@ -2858,10 +3138,12 @@ export const setNonEmptyLast: {
|
|
|
2858
3138
|
* Change the last element, creating a new `NonEmptyReadonlyArray`.
|
|
2859
3139
|
*
|
|
2860
3140
|
* @example
|
|
3141
|
+
* ```ts
|
|
2861
3142
|
* import { Array } from "effect"
|
|
2862
3143
|
*
|
|
2863
3144
|
* const result = Array.setNonEmptyLast([1, 2, 3], 4)
|
|
2864
3145
|
* assert.deepStrictEqual(result, [1, 2, 4])
|
|
3146
|
+
* ```
|
|
2865
3147
|
*
|
|
2866
3148
|
* @since 2.0.0
|
|
2867
3149
|
*/
|
|
@@ -2876,11 +3158,13 @@ export const setNonEmptyLast: {
|
|
|
2876
3158
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2877
3159
|
*
|
|
2878
3160
|
* @example
|
|
3161
|
+
* ```ts
|
|
2879
3162
|
* import { Array } from "effect"
|
|
2880
3163
|
*
|
|
2881
3164
|
* const letters = ['a', 'b', 'c', 'd']
|
|
2882
3165
|
* const result = Array.rotate(letters, 2)
|
|
2883
3166
|
* assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
|
|
3167
|
+
* ```
|
|
2884
3168
|
*
|
|
2885
3169
|
* @since 2.0.0
|
|
2886
3170
|
*/
|
|
@@ -2890,11 +3174,13 @@ export const rotate: {
|
|
|
2890
3174
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2891
3175
|
*
|
|
2892
3176
|
* @example
|
|
3177
|
+
* ```ts
|
|
2893
3178
|
* import { Array } from "effect"
|
|
2894
3179
|
*
|
|
2895
3180
|
* const letters = ['a', 'b', 'c', 'd']
|
|
2896
3181
|
* const result = Array.rotate(letters, 2)
|
|
2897
3182
|
* assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
|
|
3183
|
+
* ```
|
|
2898
3184
|
*
|
|
2899
3185
|
* @since 2.0.0
|
|
2900
3186
|
*/
|
|
@@ -2904,11 +3190,13 @@ export const rotate: {
|
|
|
2904
3190
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2905
3191
|
*
|
|
2906
3192
|
* @example
|
|
3193
|
+
* ```ts
|
|
2907
3194
|
* import { Array } from "effect"
|
|
2908
3195
|
*
|
|
2909
3196
|
* const letters = ['a', 'b', 'c', 'd']
|
|
2910
3197
|
* const result = Array.rotate(letters, 2)
|
|
2911
3198
|
* assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
|
|
3199
|
+
* ```
|
|
2912
3200
|
*
|
|
2913
3201
|
* @since 2.0.0
|
|
2914
3202
|
*/
|
|
@@ -2918,11 +3206,13 @@ export const rotate: {
|
|
|
2918
3206
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
2919
3207
|
*
|
|
2920
3208
|
* @example
|
|
3209
|
+
* ```ts
|
|
2921
3210
|
* import { Array } from "effect"
|
|
2922
3211
|
*
|
|
2923
3212
|
* const letters = ['a', 'b', 'c', 'd']
|
|
2924
3213
|
* const result = Array.rotate(letters, 2)
|
|
2925
3214
|
* assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
|
|
3215
|
+
* ```
|
|
2926
3216
|
*
|
|
2927
3217
|
* @since 2.0.0
|
|
2928
3218
|
*/
|
|
@@ -2949,6 +3239,7 @@ export const rotate: {
|
|
|
2949
3239
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using a provided `isEquivalent` function.
|
|
2950
3240
|
*
|
|
2951
3241
|
* @example
|
|
3242
|
+
* ```ts
|
|
2952
3243
|
* import { Array } from "effect"
|
|
2953
3244
|
*
|
|
2954
3245
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -2956,6 +3247,7 @@ export const rotate: {
|
|
|
2956
3247
|
* const containsNumber = Array.containsWith(isEquivalent)
|
|
2957
3248
|
* const result = containsNumber(3)(numbers)
|
|
2958
3249
|
* assert.deepStrictEqual(result, true)
|
|
3250
|
+
* ```
|
|
2959
3251
|
*
|
|
2960
3252
|
* @category elements
|
|
2961
3253
|
* @since 2.0.0
|
|
@@ -2979,11 +3271,13 @@ const _equivalence = Equal.equivalence()
|
|
|
2979
3271
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
|
|
2980
3272
|
*
|
|
2981
3273
|
* @example
|
|
3274
|
+
* ```ts
|
|
2982
3275
|
* import { Array } from "effect"
|
|
2983
3276
|
*
|
|
2984
3277
|
* const letters = ['a', 'b', 'c', 'd']
|
|
2985
3278
|
* const result = Array.contains('c')(letters)
|
|
2986
3279
|
* assert.deepStrictEqual(result, true)
|
|
3280
|
+
* ```
|
|
2987
3281
|
*
|
|
2988
3282
|
* @category elements
|
|
2989
3283
|
* @since 2.0.0
|
|
@@ -2993,11 +3287,13 @@ export const contains: {
|
|
|
2993
3287
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
|
|
2994
3288
|
*
|
|
2995
3289
|
* @example
|
|
3290
|
+
* ```ts
|
|
2996
3291
|
* import { Array } from "effect"
|
|
2997
3292
|
*
|
|
2998
3293
|
* const letters = ['a', 'b', 'c', 'd']
|
|
2999
3294
|
* const result = Array.contains('c')(letters)
|
|
3000
3295
|
* assert.deepStrictEqual(result, true)
|
|
3296
|
+
* ```
|
|
3001
3297
|
*
|
|
3002
3298
|
* @category elements
|
|
3003
3299
|
* @since 2.0.0
|
|
@@ -3007,11 +3303,13 @@ export const contains: {
|
|
|
3007
3303
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
|
|
3008
3304
|
*
|
|
3009
3305
|
* @example
|
|
3306
|
+
* ```ts
|
|
3010
3307
|
* import { Array } from "effect"
|
|
3011
3308
|
*
|
|
3012
3309
|
* const letters = ['a', 'b', 'c', 'd']
|
|
3013
3310
|
* const result = Array.contains('c')(letters)
|
|
3014
3311
|
* assert.deepStrictEqual(result, true)
|
|
3312
|
+
* ```
|
|
3015
3313
|
*
|
|
3016
3314
|
* @category elements
|
|
3017
3315
|
* @since 2.0.0
|
|
@@ -3025,6 +3323,7 @@ export const contains: {
|
|
|
3025
3323
|
* value and the rest of the `Array`.
|
|
3026
3324
|
*
|
|
3027
3325
|
* @example
|
|
3326
|
+
* ```ts
|
|
3028
3327
|
* import { Array } from "effect"
|
|
3029
3328
|
*
|
|
3030
3329
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3035,6 +3334,7 @@ export const contains: {
|
|
|
3035
3334
|
* // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
|
|
3036
3335
|
* // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
|
|
3037
3336
|
* // resulting in a new array `[2, 4, 6, 8, 10]`.
|
|
3337
|
+
* ```
|
|
3038
3338
|
*
|
|
3039
3339
|
* @since 2.0.0
|
|
3040
3340
|
*/
|
|
@@ -3045,6 +3345,7 @@ export const chop: {
|
|
|
3045
3345
|
* value and the rest of the `Array`.
|
|
3046
3346
|
*
|
|
3047
3347
|
* @example
|
|
3348
|
+
* ```ts
|
|
3048
3349
|
* import { Array } from "effect"
|
|
3049
3350
|
*
|
|
3050
3351
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3055,6 +3356,7 @@ export const chop: {
|
|
|
3055
3356
|
* // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
|
|
3056
3357
|
* // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
|
|
3057
3358
|
* // resulting in a new array `[2, 4, 6, 8, 10]`.
|
|
3359
|
+
* ```
|
|
3058
3360
|
*
|
|
3059
3361
|
* @since 2.0.0
|
|
3060
3362
|
*/
|
|
@@ -3067,6 +3369,7 @@ export const chop: {
|
|
|
3067
3369
|
* value and the rest of the `Array`.
|
|
3068
3370
|
*
|
|
3069
3371
|
* @example
|
|
3372
|
+
* ```ts
|
|
3070
3373
|
* import { Array } from "effect"
|
|
3071
3374
|
*
|
|
3072
3375
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3077,6 +3380,7 @@ export const chop: {
|
|
|
3077
3380
|
* // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
|
|
3078
3381
|
* // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
|
|
3079
3382
|
* // resulting in a new array `[2, 4, 6, 8, 10]`.
|
|
3383
|
+
* ```
|
|
3080
3384
|
*
|
|
3081
3385
|
* @since 2.0.0
|
|
3082
3386
|
*/
|
|
@@ -3090,6 +3394,7 @@ export const chop: {
|
|
|
3090
3394
|
* value and the rest of the `Array`.
|
|
3091
3395
|
*
|
|
3092
3396
|
* @example
|
|
3397
|
+
* ```ts
|
|
3093
3398
|
* import { Array } from "effect"
|
|
3094
3399
|
*
|
|
3095
3400
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3100,6 +3405,7 @@ export const chop: {
|
|
|
3100
3405
|
* // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
|
|
3101
3406
|
* // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
|
|
3102
3407
|
* // resulting in a new array `[2, 4, 6, 8, 10]`.
|
|
3408
|
+
* ```
|
|
3103
3409
|
*
|
|
3104
3410
|
* @since 2.0.0
|
|
3105
3411
|
*/
|
|
@@ -3131,11 +3437,13 @@ export const chop: {
|
|
|
3131
3437
|
* The value of `n` can be `0`.
|
|
3132
3438
|
*
|
|
3133
3439
|
* @example
|
|
3440
|
+
* ```ts
|
|
3134
3441
|
* import { Array } from "effect"
|
|
3135
3442
|
*
|
|
3136
3443
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3137
3444
|
* const result = Array.splitAt(numbers, 3)
|
|
3138
3445
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
3446
|
+
* ```
|
|
3139
3447
|
*
|
|
3140
3448
|
* @category splitting
|
|
3141
3449
|
* @since 2.0.0
|
|
@@ -3146,11 +3454,13 @@ export const splitAt: {
|
|
|
3146
3454
|
* The value of `n` can be `0`.
|
|
3147
3455
|
*
|
|
3148
3456
|
* @example
|
|
3457
|
+
* ```ts
|
|
3149
3458
|
* import { Array } from "effect"
|
|
3150
3459
|
*
|
|
3151
3460
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3152
3461
|
* const result = Array.splitAt(numbers, 3)
|
|
3153
3462
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
3463
|
+
* ```
|
|
3154
3464
|
*
|
|
3155
3465
|
* @category splitting
|
|
3156
3466
|
* @since 2.0.0
|
|
@@ -3161,11 +3471,13 @@ export const splitAt: {
|
|
|
3161
3471
|
* The value of `n` can be `0`.
|
|
3162
3472
|
*
|
|
3163
3473
|
* @example
|
|
3474
|
+
* ```ts
|
|
3164
3475
|
* import { Array } from "effect"
|
|
3165
3476
|
*
|
|
3166
3477
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3167
3478
|
* const result = Array.splitAt(numbers, 3)
|
|
3168
3479
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
3480
|
+
* ```
|
|
3169
3481
|
*
|
|
3170
3482
|
* @category splitting
|
|
3171
3483
|
* @since 2.0.0
|
|
@@ -3188,10 +3500,12 @@ export const splitAt: {
|
|
|
3188
3500
|
* The value of `n` must be `>= 1`.
|
|
3189
3501
|
*
|
|
3190
3502
|
* @example
|
|
3503
|
+
* ```ts
|
|
3191
3504
|
* import { Array } from "effect"
|
|
3192
3505
|
*
|
|
3193
3506
|
* const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
|
|
3194
3507
|
* assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
|
|
3508
|
+
* ```
|
|
3195
3509
|
*
|
|
3196
3510
|
* @category splitting
|
|
3197
3511
|
* @since 2.0.0
|
|
@@ -3202,10 +3516,12 @@ export const splitNonEmptyAt: {
|
|
|
3202
3516
|
* The value of `n` must be `>= 1`.
|
|
3203
3517
|
*
|
|
3204
3518
|
* @example
|
|
3519
|
+
* ```ts
|
|
3205
3520
|
* import { Array } from "effect"
|
|
3206
3521
|
*
|
|
3207
3522
|
* const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
|
|
3208
3523
|
* assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
|
|
3524
|
+
* ```
|
|
3209
3525
|
*
|
|
3210
3526
|
* @category splitting
|
|
3211
3527
|
* @since 2.0.0
|
|
@@ -3216,10 +3532,12 @@ export const splitNonEmptyAt: {
|
|
|
3216
3532
|
* The value of `n` must be `>= 1`.
|
|
3217
3533
|
*
|
|
3218
3534
|
* @example
|
|
3535
|
+
* ```ts
|
|
3219
3536
|
* import { Array } from "effect"
|
|
3220
3537
|
*
|
|
3221
3538
|
* const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
|
|
3222
3539
|
* assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
|
|
3540
|
+
* ```
|
|
3223
3541
|
*
|
|
3224
3542
|
* @category splitting
|
|
3225
3543
|
* @since 2.0.0
|
|
@@ -3236,11 +3554,13 @@ export const splitNonEmptyAt: {
|
|
|
3236
3554
|
* Splits this iterable into `n` equally sized arrays.
|
|
3237
3555
|
*
|
|
3238
3556
|
* @example
|
|
3557
|
+
* ```ts
|
|
3239
3558
|
* import { Array } from "effect"
|
|
3240
3559
|
*
|
|
3241
3560
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
3242
3561
|
* const result = Array.split(numbers, 3)
|
|
3243
3562
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
|
|
3563
|
+
* ```
|
|
3244
3564
|
*
|
|
3245
3565
|
* @since 2.0.0
|
|
3246
3566
|
* @category splitting
|
|
@@ -3250,11 +3570,13 @@ export const split: {
|
|
|
3250
3570
|
* Splits this iterable into `n` equally sized arrays.
|
|
3251
3571
|
*
|
|
3252
3572
|
* @example
|
|
3573
|
+
* ```ts
|
|
3253
3574
|
* import { Array } from "effect"
|
|
3254
3575
|
*
|
|
3255
3576
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
3256
3577
|
* const result = Array.split(numbers, 3)
|
|
3257
3578
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
|
|
3579
|
+
* ```
|
|
3258
3580
|
*
|
|
3259
3581
|
* @since 2.0.0
|
|
3260
3582
|
* @category splitting
|
|
@@ -3264,11 +3586,13 @@ export const split: {
|
|
|
3264
3586
|
* Splits this iterable into `n` equally sized arrays.
|
|
3265
3587
|
*
|
|
3266
3588
|
* @example
|
|
3589
|
+
* ```ts
|
|
3267
3590
|
* import { Array } from "effect"
|
|
3268
3591
|
*
|
|
3269
3592
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
3270
3593
|
* const result = Array.split(numbers, 3)
|
|
3271
3594
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
|
|
3595
|
+
* ```
|
|
3272
3596
|
*
|
|
3273
3597
|
* @since 2.0.0
|
|
3274
3598
|
* @category splitting
|
|
@@ -3284,11 +3608,13 @@ export const split: {
|
|
|
3284
3608
|
* Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
|
|
3285
3609
|
*
|
|
3286
3610
|
* @example
|
|
3611
|
+
* ```ts
|
|
3287
3612
|
* import { Array } from "effect"
|
|
3288
3613
|
*
|
|
3289
3614
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3290
3615
|
* const result = Array.splitWhere(numbers, n => n > 3)
|
|
3291
3616
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
3617
|
+
* ```
|
|
3292
3618
|
*
|
|
3293
3619
|
* @category splitting
|
|
3294
3620
|
* @since 2.0.0
|
|
@@ -3299,11 +3625,13 @@ export const splitWhere: {
|
|
|
3299
3625
|
* Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
|
|
3300
3626
|
*
|
|
3301
3627
|
* @example
|
|
3628
|
+
* ```ts
|
|
3302
3629
|
* import { Array } from "effect"
|
|
3303
3630
|
*
|
|
3304
3631
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3305
3632
|
* const result = Array.splitWhere(numbers, n => n > 3)
|
|
3306
3633
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
3634
|
+
* ```
|
|
3307
3635
|
*
|
|
3308
3636
|
* @category splitting
|
|
3309
3637
|
* @since 2.0.0
|
|
@@ -3316,11 +3644,13 @@ export const splitWhere: {
|
|
|
3316
3644
|
* Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
|
|
3317
3645
|
*
|
|
3318
3646
|
* @example
|
|
3647
|
+
* ```ts
|
|
3319
3648
|
* import { Array } from "effect"
|
|
3320
3649
|
*
|
|
3321
3650
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3322
3651
|
* const result = Array.splitWhere(numbers, n => n > 3)
|
|
3323
3652
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
3653
|
+
* ```
|
|
3324
3654
|
*
|
|
3325
3655
|
* @category splitting
|
|
3326
3656
|
* @since 2.0.0
|
|
@@ -3336,11 +3666,13 @@ export const splitWhere: {
|
|
|
3336
3666
|
* Copies an array.
|
|
3337
3667
|
*
|
|
3338
3668
|
* @example
|
|
3669
|
+
* ```ts
|
|
3339
3670
|
* import { Array } from "effect"
|
|
3340
3671
|
*
|
|
3341
3672
|
* const numbers = [1, 2, 3]
|
|
3342
3673
|
* const copy = Array.copy(numbers)
|
|
3343
3674
|
* assert.deepStrictEqual(copy, [1, 2, 3])
|
|
3675
|
+
* ```
|
|
3344
3676
|
*
|
|
3345
3677
|
* @since 2.0.0
|
|
3346
3678
|
*/
|
|
@@ -3349,11 +3681,13 @@ export const copy: {
|
|
|
3349
3681
|
* Copies an array.
|
|
3350
3682
|
*
|
|
3351
3683
|
* @example
|
|
3684
|
+
* ```ts
|
|
3352
3685
|
* import { Array } from "effect"
|
|
3353
3686
|
*
|
|
3354
3687
|
* const numbers = [1, 2, 3]
|
|
3355
3688
|
* const copy = Array.copy(numbers)
|
|
3356
3689
|
* assert.deepStrictEqual(copy, [1, 2, 3])
|
|
3690
|
+
* ```
|
|
3357
3691
|
*
|
|
3358
3692
|
* @since 2.0.0
|
|
3359
3693
|
*/
|
|
@@ -3362,11 +3696,13 @@ export const copy: {
|
|
|
3362
3696
|
* Copies an array.
|
|
3363
3697
|
*
|
|
3364
3698
|
* @example
|
|
3699
|
+
* ```ts
|
|
3365
3700
|
* import { Array } from "effect"
|
|
3366
3701
|
*
|
|
3367
3702
|
* const numbers = [1, 2, 3]
|
|
3368
3703
|
* const copy = Array.copy(numbers)
|
|
3369
3704
|
* assert.deepStrictEqual(copy, [1, 2, 3])
|
|
3705
|
+
* ```
|
|
3370
3706
|
*
|
|
3371
3707
|
* @since 2.0.0
|
|
3372
3708
|
*/
|
|
@@ -3380,11 +3716,13 @@ export const copy: {
|
|
|
3380
3716
|
* If `n` is less than or equal to 0, the returned array will be an empty array.
|
|
3381
3717
|
*
|
|
3382
3718
|
* @example
|
|
3719
|
+
* ```ts
|
|
3383
3720
|
* import { Array } from "effect"
|
|
3384
3721
|
*
|
|
3385
3722
|
* const arr = [1, 2, 3]
|
|
3386
3723
|
* const result = Array.pad(arr, 6, 0)
|
|
3387
3724
|
* assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
|
|
3725
|
+
* ```
|
|
3388
3726
|
*
|
|
3389
3727
|
* @since 3.8.4
|
|
3390
3728
|
*/
|
|
@@ -3396,11 +3734,13 @@ export const pad: {
|
|
|
3396
3734
|
* If `n` is less than or equal to 0, the returned array will be an empty array.
|
|
3397
3735
|
*
|
|
3398
3736
|
* @example
|
|
3737
|
+
* ```ts
|
|
3399
3738
|
* import { Array } from "effect"
|
|
3400
3739
|
*
|
|
3401
3740
|
* const arr = [1, 2, 3]
|
|
3402
3741
|
* const result = Array.pad(arr, 6, 0)
|
|
3403
3742
|
* assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
|
|
3743
|
+
* ```
|
|
3404
3744
|
*
|
|
3405
3745
|
* @since 3.8.4
|
|
3406
3746
|
*/
|
|
@@ -3414,11 +3754,13 @@ export const pad: {
|
|
|
3414
3754
|
* If `n` is less than or equal to 0, the returned array will be an empty array.
|
|
3415
3755
|
*
|
|
3416
3756
|
* @example
|
|
3757
|
+
* ```ts
|
|
3417
3758
|
* import { Array } from "effect"
|
|
3418
3759
|
*
|
|
3419
3760
|
* const arr = [1, 2, 3]
|
|
3420
3761
|
* const result = Array.pad(arr, 6, 0)
|
|
3421
3762
|
* assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
|
|
3763
|
+
* ```
|
|
3422
3764
|
*
|
|
3423
3765
|
* @since 3.8.4
|
|
3424
3766
|
*/
|
|
@@ -3445,6 +3787,7 @@ export const pad: {
|
|
|
3445
3787
|
* whenever `n` evenly divides the length of `self`.
|
|
3446
3788
|
*
|
|
3447
3789
|
* @example
|
|
3790
|
+
* ```ts
|
|
3448
3791
|
* import { Array } from "effect"
|
|
3449
3792
|
*
|
|
3450
3793
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3456,6 +3799,7 @@ export const pad: {
|
|
|
3456
3799
|
* // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
|
|
3457
3800
|
* // the last chunk contains the remaining elements.
|
|
3458
3801
|
* // The result is `[[1, 2], [3, 4], [5]]`.
|
|
3802
|
+
* ```
|
|
3459
3803
|
*
|
|
3460
3804
|
* @category splitting
|
|
3461
3805
|
* @since 2.0.0
|
|
@@ -3473,6 +3817,7 @@ export const chunksOf: {
|
|
|
3473
3817
|
* whenever `n` evenly divides the length of `self`.
|
|
3474
3818
|
*
|
|
3475
3819
|
* @example
|
|
3820
|
+
* ```ts
|
|
3476
3821
|
* import { Array } from "effect"
|
|
3477
3822
|
*
|
|
3478
3823
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3484,6 +3829,7 @@ export const chunksOf: {
|
|
|
3484
3829
|
* // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
|
|
3485
3830
|
* // the last chunk contains the remaining elements.
|
|
3486
3831
|
* // The result is `[[1, 2], [3, 4], [5]]`.
|
|
3832
|
+
* ```
|
|
3487
3833
|
*
|
|
3488
3834
|
* @category splitting
|
|
3489
3835
|
* @since 2.0.0
|
|
@@ -3503,6 +3849,7 @@ export const chunksOf: {
|
|
|
3503
3849
|
* whenever `n` evenly divides the length of `self`.
|
|
3504
3850
|
*
|
|
3505
3851
|
* @example
|
|
3852
|
+
* ```ts
|
|
3506
3853
|
* import { Array } from "effect"
|
|
3507
3854
|
*
|
|
3508
3855
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3514,6 +3861,7 @@ export const chunksOf: {
|
|
|
3514
3861
|
* // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
|
|
3515
3862
|
* // the last chunk contains the remaining elements.
|
|
3516
3863
|
* // The result is `[[1, 2], [3, 4], [5]]`.
|
|
3864
|
+
* ```
|
|
3517
3865
|
*
|
|
3518
3866
|
* @category splitting
|
|
3519
3867
|
* @since 2.0.0
|
|
@@ -3531,6 +3879,7 @@ export const chunksOf: {
|
|
|
3531
3879
|
* whenever `n` evenly divides the length of `self`.
|
|
3532
3880
|
*
|
|
3533
3881
|
* @example
|
|
3882
|
+
* ```ts
|
|
3534
3883
|
* import { Array } from "effect"
|
|
3535
3884
|
*
|
|
3536
3885
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -3542,6 +3891,7 @@ export const chunksOf: {
|
|
|
3542
3891
|
* // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
|
|
3543
3892
|
* // the last chunk contains the remaining elements.
|
|
3544
3893
|
* // The result is `[[1, 2], [3, 4], [5]]`.
|
|
3894
|
+
* ```
|
|
3545
3895
|
*
|
|
3546
3896
|
* @category splitting
|
|
3547
3897
|
* @since 2.0.0
|
|
@@ -3559,10 +3909,12 @@ export const chunksOf: {
|
|
|
3559
3909
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
|
|
3560
3910
|
*
|
|
3561
3911
|
* @example
|
|
3912
|
+
* ```ts
|
|
3562
3913
|
* import { Array } from "effect"
|
|
3563
3914
|
*
|
|
3564
3915
|
* const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
|
|
3565
3916
|
* assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
|
|
3917
|
+
* ```
|
|
3566
3918
|
*
|
|
3567
3919
|
* @category grouping
|
|
3568
3920
|
* @since 2.0.0
|
|
@@ -3572,10 +3924,12 @@ export const groupWith: {
|
|
|
3572
3924
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
|
|
3573
3925
|
*
|
|
3574
3926
|
* @example
|
|
3927
|
+
* ```ts
|
|
3575
3928
|
* import { Array } from "effect"
|
|
3576
3929
|
*
|
|
3577
3930
|
* const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
|
|
3578
3931
|
* assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
|
|
3932
|
+
* ```
|
|
3579
3933
|
*
|
|
3580
3934
|
* @category grouping
|
|
3581
3935
|
* @since 2.0.0
|
|
@@ -3585,10 +3939,12 @@ export const groupWith: {
|
|
|
3585
3939
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
|
|
3586
3940
|
*
|
|
3587
3941
|
* @example
|
|
3942
|
+
* ```ts
|
|
3588
3943
|
* import { Array } from "effect"
|
|
3589
3944
|
*
|
|
3590
3945
|
* const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
|
|
3591
3946
|
* assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
|
|
3947
|
+
* ```
|
|
3592
3948
|
*
|
|
3593
3949
|
* @category grouping
|
|
3594
3950
|
* @since 2.0.0
|
|
@@ -3620,10 +3976,12 @@ export const groupWith: {
|
|
|
3620
3976
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s.
|
|
3621
3977
|
*
|
|
3622
3978
|
* @example
|
|
3979
|
+
* ```ts
|
|
3623
3980
|
* import { Array } from "effect"
|
|
3624
3981
|
*
|
|
3625
3982
|
* const result = Array.group([1, 1, 2, 2, 2, 3, 1])
|
|
3626
3983
|
* assert.deepStrictEqual(result, [[1, 1], [2, 2, 2], [3], [1]])
|
|
3984
|
+
* ```
|
|
3627
3985
|
*
|
|
3628
3986
|
* @category grouping
|
|
3629
3987
|
* @since 2.0.0
|
|
@@ -3637,6 +3995,7 @@ export const group: <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<NonEmpt
|
|
|
3637
3995
|
* function on each element, and grouping the results according to values returned
|
|
3638
3996
|
*
|
|
3639
3997
|
* @example
|
|
3998
|
+
* ```ts
|
|
3640
3999
|
* import { Array } from "effect"
|
|
3641
4000
|
*
|
|
3642
4001
|
* const people = [
|
|
@@ -3649,6 +4008,7 @@ export const group: <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<NonEmpt
|
|
|
3649
4008
|
* A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
|
|
3650
4009
|
* B: [{ name: "Bob", group: "B" }]
|
|
3651
4010
|
* })
|
|
4011
|
+
* ```
|
|
3652
4012
|
*
|
|
3653
4013
|
* @category grouping
|
|
3654
4014
|
* @since 2.0.0
|
|
@@ -3659,6 +4019,7 @@ export const groupBy: {
|
|
|
3659
4019
|
* function on each element, and grouping the results according to values returned
|
|
3660
4020
|
*
|
|
3661
4021
|
* @example
|
|
4022
|
+
* ```ts
|
|
3662
4023
|
* import { Array } from "effect"
|
|
3663
4024
|
*
|
|
3664
4025
|
* const people = [
|
|
@@ -3671,6 +4032,7 @@ export const groupBy: {
|
|
|
3671
4032
|
* A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
|
|
3672
4033
|
* B: [{ name: "Bob", group: "B" }]
|
|
3673
4034
|
* })
|
|
4035
|
+
* ```
|
|
3674
4036
|
*
|
|
3675
4037
|
* @category grouping
|
|
3676
4038
|
* @since 2.0.0
|
|
@@ -3683,6 +4045,7 @@ export const groupBy: {
|
|
|
3683
4045
|
* function on each element, and grouping the results according to values returned
|
|
3684
4046
|
*
|
|
3685
4047
|
* @example
|
|
4048
|
+
* ```ts
|
|
3686
4049
|
* import { Array } from "effect"
|
|
3687
4050
|
*
|
|
3688
4051
|
* const people = [
|
|
@@ -3695,6 +4058,7 @@ export const groupBy: {
|
|
|
3695
4058
|
* A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
|
|
3696
4059
|
* B: [{ name: "Bob", group: "B" }]
|
|
3697
4060
|
* })
|
|
4061
|
+
* ```
|
|
3698
4062
|
*
|
|
3699
4063
|
* @category grouping
|
|
3700
4064
|
* @since 2.0.0
|
|
@@ -3723,12 +4087,14 @@ export const groupBy: {
|
|
|
3723
4087
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
3724
4088
|
*
|
|
3725
4089
|
* @example
|
|
4090
|
+
* ```ts
|
|
3726
4091
|
* import { Array } from "effect"
|
|
3727
4092
|
*
|
|
3728
4093
|
* const array1 = [1, 2]
|
|
3729
4094
|
* const array2 = [2, 3]
|
|
3730
4095
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
3731
4096
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
4097
|
+
* ```
|
|
3732
4098
|
*
|
|
3733
4099
|
* @since 2.0.0
|
|
3734
4100
|
*/
|
|
@@ -3737,12 +4103,14 @@ export const unionWith: {
|
|
|
3737
4103
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
3738
4104
|
*
|
|
3739
4105
|
* @example
|
|
4106
|
+
* ```ts
|
|
3740
4107
|
* import { Array } from "effect"
|
|
3741
4108
|
*
|
|
3742
4109
|
* const array1 = [1, 2]
|
|
3743
4110
|
* const array2 = [2, 3]
|
|
3744
4111
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
3745
4112
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
4113
|
+
* ```
|
|
3746
4114
|
*
|
|
3747
4115
|
* @since 2.0.0
|
|
3748
4116
|
*/
|
|
@@ -3754,12 +4122,14 @@ export const unionWith: {
|
|
|
3754
4122
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
3755
4123
|
*
|
|
3756
4124
|
* @example
|
|
4125
|
+
* ```ts
|
|
3757
4126
|
* import { Array } from "effect"
|
|
3758
4127
|
*
|
|
3759
4128
|
* const array1 = [1, 2]
|
|
3760
4129
|
* const array2 = [2, 3]
|
|
3761
4130
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
3762
4131
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
4132
|
+
* ```
|
|
3763
4133
|
*
|
|
3764
4134
|
* @since 2.0.0
|
|
3765
4135
|
*/
|
|
@@ -3772,12 +4142,14 @@ export const unionWith: {
|
|
|
3772
4142
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
3773
4143
|
*
|
|
3774
4144
|
* @example
|
|
4145
|
+
* ```ts
|
|
3775
4146
|
* import { Array } from "effect"
|
|
3776
4147
|
*
|
|
3777
4148
|
* const array1 = [1, 2]
|
|
3778
4149
|
* const array2 = [2, 3]
|
|
3779
4150
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
3780
4151
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
4152
|
+
* ```
|
|
3781
4153
|
*
|
|
3782
4154
|
* @since 2.0.0
|
|
3783
4155
|
*/
|
|
@@ -3790,12 +4162,14 @@ export const unionWith: {
|
|
|
3790
4162
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
3791
4163
|
*
|
|
3792
4164
|
* @example
|
|
4165
|
+
* ```ts
|
|
3793
4166
|
* import { Array } from "effect"
|
|
3794
4167
|
*
|
|
3795
4168
|
* const array1 = [1, 2]
|
|
3796
4169
|
* const array2 = [2, 3]
|
|
3797
4170
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
3798
4171
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
4172
|
+
* ```
|
|
3799
4173
|
*
|
|
3800
4174
|
* @since 2.0.0
|
|
3801
4175
|
*/
|
|
@@ -3821,12 +4195,14 @@ export const unionWith: {
|
|
|
3821
4195
|
* Creates a union of two arrays, removing duplicates.
|
|
3822
4196
|
*
|
|
3823
4197
|
* @example
|
|
4198
|
+
* ```ts
|
|
3824
4199
|
* import { Array } from "effect"
|
|
3825
4200
|
*
|
|
3826
4201
|
* const array1 = [1, 2]
|
|
3827
4202
|
* const array2 = [2, 3]
|
|
3828
4203
|
* const result = Array.union(array1, array2)
|
|
3829
4204
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
4205
|
+
* ```
|
|
3830
4206
|
*
|
|
3831
4207
|
* @since 2.0.0
|
|
3832
4208
|
*/
|
|
@@ -3835,12 +4211,14 @@ export const union: {
|
|
|
3835
4211
|
* Creates a union of two arrays, removing duplicates.
|
|
3836
4212
|
*
|
|
3837
4213
|
* @example
|
|
4214
|
+
* ```ts
|
|
3838
4215
|
* import { Array } from "effect"
|
|
3839
4216
|
*
|
|
3840
4217
|
* const array1 = [1, 2]
|
|
3841
4218
|
* const array2 = [2, 3]
|
|
3842
4219
|
* const result = Array.union(array1, array2)
|
|
3843
4220
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
4221
|
+
* ```
|
|
3844
4222
|
*
|
|
3845
4223
|
* @since 2.0.0
|
|
3846
4224
|
*/
|
|
@@ -3851,12 +4229,14 @@ export const union: {
|
|
|
3851
4229
|
* Creates a union of two arrays, removing duplicates.
|
|
3852
4230
|
*
|
|
3853
4231
|
* @example
|
|
4232
|
+
* ```ts
|
|
3854
4233
|
* import { Array } from "effect"
|
|
3855
4234
|
*
|
|
3856
4235
|
* const array1 = [1, 2]
|
|
3857
4236
|
* const array2 = [2, 3]
|
|
3858
4237
|
* const result = Array.union(array1, array2)
|
|
3859
4238
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
4239
|
+
* ```
|
|
3860
4240
|
*
|
|
3861
4241
|
* @since 2.0.0
|
|
3862
4242
|
*/
|
|
@@ -3865,12 +4245,14 @@ export const union: {
|
|
|
3865
4245
|
* Creates a union of two arrays, removing duplicates.
|
|
3866
4246
|
*
|
|
3867
4247
|
* @example
|
|
4248
|
+
* ```ts
|
|
3868
4249
|
* import { Array } from "effect"
|
|
3869
4250
|
*
|
|
3870
4251
|
* const array1 = [1, 2]
|
|
3871
4252
|
* const array2 = [2, 3]
|
|
3872
4253
|
* const result = Array.union(array1, array2)
|
|
3873
4254
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
4255
|
+
* ```
|
|
3874
4256
|
*
|
|
3875
4257
|
* @since 2.0.0
|
|
3876
4258
|
*/
|
|
@@ -3879,12 +4261,14 @@ export const union: {
|
|
|
3879
4261
|
* Creates a union of two arrays, removing duplicates.
|
|
3880
4262
|
*
|
|
3881
4263
|
* @example
|
|
4264
|
+
* ```ts
|
|
3882
4265
|
* import { Array } from "effect"
|
|
3883
4266
|
*
|
|
3884
4267
|
* const array1 = [1, 2]
|
|
3885
4268
|
* const array2 = [2, 3]
|
|
3886
4269
|
* const result = Array.union(array1, array2)
|
|
3887
4270
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
4271
|
+
* ```
|
|
3888
4272
|
*
|
|
3889
4273
|
* @since 2.0.0
|
|
3890
4274
|
*/
|
|
@@ -3896,6 +4280,7 @@ export const union: {
|
|
|
3896
4280
|
* The order and references of result values are determined by the first `Iterable`.
|
|
3897
4281
|
*
|
|
3898
4282
|
* @example
|
|
4283
|
+
* ```ts
|
|
3899
4284
|
* import { Array } from "effect"
|
|
3900
4285
|
*
|
|
3901
4286
|
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
@@ -3903,6 +4288,7 @@ export const union: {
|
|
|
3903
4288
|
* const isEquivalent = (a: { id: number }, b: { id: number }) => a.id === b.id
|
|
3904
4289
|
* const result = Array.intersectionWith(isEquivalent)(array2)(array1)
|
|
3905
4290
|
* assert.deepStrictEqual(result, [{ id: 1 }, { id: 3 }])
|
|
4291
|
+
* ```
|
|
3906
4292
|
*
|
|
3907
4293
|
* @since 2.0.0
|
|
3908
4294
|
*/
|
|
@@ -3922,12 +4308,14 @@ export const intersectionWith = <A>(isEquivalent: (self: A, that: A) => boolean)
|
|
|
3922
4308
|
* The order and references of result values are determined by the first `Iterable`.
|
|
3923
4309
|
*
|
|
3924
4310
|
* @example
|
|
4311
|
+
* ```ts
|
|
3925
4312
|
* import { Array } from "effect"
|
|
3926
4313
|
*
|
|
3927
4314
|
* const array1 = [1, 2, 3]
|
|
3928
4315
|
* const array2 = [3, 4, 1]
|
|
3929
4316
|
* const result = Array.intersection(array1, array2)
|
|
3930
4317
|
* assert.deepStrictEqual(result, [1, 3])
|
|
4318
|
+
* ```
|
|
3931
4319
|
*
|
|
3932
4320
|
* @since 2.0.0
|
|
3933
4321
|
*/
|
|
@@ -3937,12 +4325,14 @@ export const intersection: {
|
|
|
3937
4325
|
* The order and references of result values are determined by the first `Iterable`.
|
|
3938
4326
|
*
|
|
3939
4327
|
* @example
|
|
4328
|
+
* ```ts
|
|
3940
4329
|
* import { Array } from "effect"
|
|
3941
4330
|
*
|
|
3942
4331
|
* const array1 = [1, 2, 3]
|
|
3943
4332
|
* const array2 = [3, 4, 1]
|
|
3944
4333
|
* const result = Array.intersection(array1, array2)
|
|
3945
4334
|
* assert.deepStrictEqual(result, [1, 3])
|
|
4335
|
+
* ```
|
|
3946
4336
|
*
|
|
3947
4337
|
* @since 2.0.0
|
|
3948
4338
|
*/
|
|
@@ -3952,12 +4342,14 @@ export const intersection: {
|
|
|
3952
4342
|
* The order and references of result values are determined by the first `Iterable`.
|
|
3953
4343
|
*
|
|
3954
4344
|
* @example
|
|
4345
|
+
* ```ts
|
|
3955
4346
|
* import { Array } from "effect"
|
|
3956
4347
|
*
|
|
3957
4348
|
* const array1 = [1, 2, 3]
|
|
3958
4349
|
* const array2 = [3, 4, 1]
|
|
3959
4350
|
* const result = Array.intersection(array1, array2)
|
|
3960
4351
|
* assert.deepStrictEqual(result, [1, 3])
|
|
4352
|
+
* ```
|
|
3961
4353
|
*
|
|
3962
4354
|
* @since 2.0.0
|
|
3963
4355
|
*/
|
|
@@ -3969,12 +4361,14 @@ export const intersection: {
|
|
|
3969
4361
|
* The order and references of result values are determined by the first `Iterable`.
|
|
3970
4362
|
*
|
|
3971
4363
|
* @example
|
|
4364
|
+
* ```ts
|
|
3972
4365
|
* import { Array } from "effect"
|
|
3973
4366
|
*
|
|
3974
4367
|
* const array1 = [1, 2, 3]
|
|
3975
4368
|
* const array2 = [2, 3, 4]
|
|
3976
4369
|
* const difference = Array.differenceWith<number>((a, b) => a === b)(array1, array2)
|
|
3977
4370
|
* assert.deepStrictEqual(difference, [1])
|
|
4371
|
+
* ```
|
|
3978
4372
|
*
|
|
3979
4373
|
* @since 2.0.0
|
|
3980
4374
|
*/
|
|
@@ -3994,12 +4388,14 @@ export const differenceWith = <A>(isEquivalent: (self: A, that: A) => boolean):
|
|
|
3994
4388
|
* The order and references of result values are determined by the first `Iterable`.
|
|
3995
4389
|
*
|
|
3996
4390
|
* @example
|
|
4391
|
+
* ```ts
|
|
3997
4392
|
* import { Array } from "effect"
|
|
3998
4393
|
*
|
|
3999
4394
|
* const array1 = [1, 2, 3]
|
|
4000
4395
|
* const array2 = [2, 3, 4]
|
|
4001
4396
|
* const difference = Array.difference(array1, array2)
|
|
4002
4397
|
* assert.deepStrictEqual(difference, [1])
|
|
4398
|
+
* ```
|
|
4003
4399
|
*
|
|
4004
4400
|
* @since 2.0.0
|
|
4005
4401
|
*/
|
|
@@ -4009,12 +4405,14 @@ export const difference: {
|
|
|
4009
4405
|
* The order and references of result values are determined by the first `Iterable`.
|
|
4010
4406
|
*
|
|
4011
4407
|
* @example
|
|
4408
|
+
* ```ts
|
|
4012
4409
|
* import { Array } from "effect"
|
|
4013
4410
|
*
|
|
4014
4411
|
* const array1 = [1, 2, 3]
|
|
4015
4412
|
* const array2 = [2, 3, 4]
|
|
4016
4413
|
* const difference = Array.difference(array1, array2)
|
|
4017
4414
|
* assert.deepStrictEqual(difference, [1])
|
|
4415
|
+
* ```
|
|
4018
4416
|
*
|
|
4019
4417
|
* @since 2.0.0
|
|
4020
4418
|
*/
|
|
@@ -4024,12 +4422,14 @@ export const difference: {
|
|
|
4024
4422
|
* The order and references of result values are determined by the first `Iterable`.
|
|
4025
4423
|
*
|
|
4026
4424
|
* @example
|
|
4425
|
+
* ```ts
|
|
4027
4426
|
* import { Array } from "effect"
|
|
4028
4427
|
*
|
|
4029
4428
|
* const array1 = [1, 2, 3]
|
|
4030
4429
|
* const array2 = [2, 3, 4]
|
|
4031
4430
|
* const difference = Array.difference(array1, array2)
|
|
4032
4431
|
* assert.deepStrictEqual(difference, [1])
|
|
4432
|
+
* ```
|
|
4033
4433
|
*
|
|
4034
4434
|
* @since 2.0.0
|
|
4035
4435
|
*/
|
|
@@ -4173,12 +4573,14 @@ export const flatMap: {
|
|
|
4173
4573
|
* arrays is collapsed into a single, flat array.
|
|
4174
4574
|
*
|
|
4175
4575
|
* @example
|
|
4576
|
+
* ```ts
|
|
4176
4577
|
* import { Array } from "effect";
|
|
4177
4578
|
*
|
|
4178
4579
|
* const nestedArrays = [[1, 2], [], [3, 4], [], [5, 6]]
|
|
4179
4580
|
* const result = Array.flatten(nestedArrays)
|
|
4180
4581
|
*
|
|
4181
4582
|
* assert.deepStrictEqual(result, [1, 2, 3, 4, 5, 6]);
|
|
4583
|
+
* ```
|
|
4182
4584
|
*
|
|
4183
4585
|
* @category sequencing
|
|
4184
4586
|
* @since 2.0.0
|
|
@@ -4192,6 +4594,7 @@ export const flatten: <S extends ReadonlyArray<ReadonlyArray<any>>>(self: S) =>
|
|
|
4192
4594
|
* This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
|
|
4193
4595
|
*
|
|
4194
4596
|
* @example
|
|
4597
|
+
* ```ts
|
|
4195
4598
|
* import { Array, Option } from "effect";
|
|
4196
4599
|
*
|
|
4197
4600
|
* const data = [1, 2, 3, 4, 5];
|
|
@@ -4199,6 +4602,7 @@ export const flatten: <S extends ReadonlyArray<ReadonlyArray<any>>>(self: S) =>
|
|
|
4199
4602
|
* const result = Array.filterMap(data, evenSquares);
|
|
4200
4603
|
*
|
|
4201
4604
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
4605
|
+
* ```
|
|
4202
4606
|
*
|
|
4203
4607
|
* @category filtering
|
|
4204
4608
|
* @since 2.0.0
|
|
@@ -4209,6 +4613,7 @@ export const filterMap: {
|
|
|
4209
4613
|
* This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
|
|
4210
4614
|
*
|
|
4211
4615
|
* @example
|
|
4616
|
+
* ```ts
|
|
4212
4617
|
* import { Array, Option } from "effect";
|
|
4213
4618
|
*
|
|
4214
4619
|
* const data = [1, 2, 3, 4, 5];
|
|
@@ -4216,6 +4621,7 @@ export const filterMap: {
|
|
|
4216
4621
|
* const result = Array.filterMap(data, evenSquares);
|
|
4217
4622
|
*
|
|
4218
4623
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
4624
|
+
* ```
|
|
4219
4625
|
*
|
|
4220
4626
|
* @category filtering
|
|
4221
4627
|
* @since 2.0.0
|
|
@@ -4226,6 +4632,7 @@ export const filterMap: {
|
|
|
4226
4632
|
* This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
|
|
4227
4633
|
*
|
|
4228
4634
|
* @example
|
|
4635
|
+
* ```ts
|
|
4229
4636
|
* import { Array, Option } from "effect";
|
|
4230
4637
|
*
|
|
4231
4638
|
* const data = [1, 2, 3, 4, 5];
|
|
@@ -4233,6 +4640,7 @@ export const filterMap: {
|
|
|
4233
4640
|
* const result = Array.filterMap(data, evenSquares);
|
|
4234
4641
|
*
|
|
4235
4642
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
4643
|
+
* ```
|
|
4236
4644
|
*
|
|
4237
4645
|
* @category filtering
|
|
4238
4646
|
* @since 2.0.0
|
|
@@ -4259,6 +4667,7 @@ export const filterMap: {
|
|
|
4259
4667
|
* This is useful when you need to transform an array but only up to the point where a certain condition holds true.
|
|
4260
4668
|
*
|
|
4261
4669
|
* @example
|
|
4670
|
+
* ```ts
|
|
4262
4671
|
* import { Array, Option } from "effect";
|
|
4263
4672
|
*
|
|
4264
4673
|
* const data = [2, 4, 5];
|
|
@@ -4266,6 +4675,7 @@ export const filterMap: {
|
|
|
4266
4675
|
* const result = Array.filterMapWhile(data, toSquareTillOdd);
|
|
4267
4676
|
*
|
|
4268
4677
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
4678
|
+
* ```
|
|
4269
4679
|
*
|
|
4270
4680
|
* @category filtering
|
|
4271
4681
|
* @since 2.0.0
|
|
@@ -4277,6 +4687,7 @@ export const filterMapWhile: {
|
|
|
4277
4687
|
* This is useful when you need to transform an array but only up to the point where a certain condition holds true.
|
|
4278
4688
|
*
|
|
4279
4689
|
* @example
|
|
4690
|
+
* ```ts
|
|
4280
4691
|
* import { Array, Option } from "effect";
|
|
4281
4692
|
*
|
|
4282
4693
|
* const data = [2, 4, 5];
|
|
@@ -4284,6 +4695,7 @@ export const filterMapWhile: {
|
|
|
4284
4695
|
* const result = Array.filterMapWhile(data, toSquareTillOdd);
|
|
4285
4696
|
*
|
|
4286
4697
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
4698
|
+
* ```
|
|
4287
4699
|
*
|
|
4288
4700
|
* @category filtering
|
|
4289
4701
|
* @since 2.0.0
|
|
@@ -4295,6 +4707,7 @@ export const filterMapWhile: {
|
|
|
4295
4707
|
* This is useful when you need to transform an array but only up to the point where a certain condition holds true.
|
|
4296
4708
|
*
|
|
4297
4709
|
* @example
|
|
4710
|
+
* ```ts
|
|
4298
4711
|
* import { Array, Option } from "effect";
|
|
4299
4712
|
*
|
|
4300
4713
|
* const data = [2, 4, 5];
|
|
@@ -4302,6 +4715,7 @@ export const filterMapWhile: {
|
|
|
4302
4715
|
* const result = Array.filterMapWhile(data, toSquareTillOdd);
|
|
4303
4716
|
*
|
|
4304
4717
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
4718
|
+
* ```
|
|
4305
4719
|
*
|
|
4306
4720
|
* @category filtering
|
|
4307
4721
|
* @since 2.0.0
|
|
@@ -4329,6 +4743,7 @@ export const filterMapWhile: {
|
|
|
4329
4743
|
* into successes and failures.
|
|
4330
4744
|
*
|
|
4331
4745
|
* @example
|
|
4746
|
+
* ```ts
|
|
4332
4747
|
* import { Array, Either } from "effect";
|
|
4333
4748
|
*
|
|
4334
4749
|
* const data = [1, 2, 3, 4, 5]
|
|
@@ -4341,6 +4756,7 @@ export const filterMapWhile: {
|
|
|
4341
4756
|
* [1, 3, 5],
|
|
4342
4757
|
* [2, 4]
|
|
4343
4758
|
* ])
|
|
4759
|
+
* ```
|
|
4344
4760
|
*
|
|
4345
4761
|
* @category filtering
|
|
4346
4762
|
* @since 2.0.0
|
|
@@ -4353,6 +4769,7 @@ export const partitionMap: {
|
|
|
4353
4769
|
* into successes and failures.
|
|
4354
4770
|
*
|
|
4355
4771
|
* @example
|
|
4772
|
+
* ```ts
|
|
4356
4773
|
* import { Array, Either } from "effect";
|
|
4357
4774
|
*
|
|
4358
4775
|
* const data = [1, 2, 3, 4, 5]
|
|
@@ -4365,6 +4782,7 @@ export const partitionMap: {
|
|
|
4365
4782
|
* [1, 3, 5],
|
|
4366
4783
|
* [2, 4]
|
|
4367
4784
|
* ])
|
|
4785
|
+
* ```
|
|
4368
4786
|
*
|
|
4369
4787
|
* @category filtering
|
|
4370
4788
|
* @since 2.0.0
|
|
@@ -4377,6 +4795,7 @@ export const partitionMap: {
|
|
|
4377
4795
|
* into successes and failures.
|
|
4378
4796
|
*
|
|
4379
4797
|
* @example
|
|
4798
|
+
* ```ts
|
|
4380
4799
|
* import { Array, Either } from "effect";
|
|
4381
4800
|
*
|
|
4382
4801
|
* const data = [1, 2, 3, 4, 5]
|
|
@@ -4389,6 +4808,7 @@ export const partitionMap: {
|
|
|
4389
4808
|
* [1, 3, 5],
|
|
4390
4809
|
* [2, 4]
|
|
4391
4810
|
* ])
|
|
4811
|
+
* ```
|
|
4392
4812
|
*
|
|
4393
4813
|
* @category filtering
|
|
4394
4814
|
* @since 2.0.0
|
|
@@ -4416,12 +4836,14 @@ export const partitionMap: {
|
|
|
4416
4836
|
* Retrieves the `Some` values from an `Iterable` of `Option`s, collecting them into an array.
|
|
4417
4837
|
*
|
|
4418
4838
|
* @example
|
|
4839
|
+
* ```ts
|
|
4419
4840
|
* import { Array, Option } from "effect"
|
|
4420
4841
|
*
|
|
4421
4842
|
* assert.deepStrictEqual(
|
|
4422
4843
|
* Array.getSomes([Option.some(1), Option.none(), Option.some(2)]),
|
|
4423
4844
|
* [1, 2]
|
|
4424
4845
|
* )
|
|
4846
|
+
* ```
|
|
4425
4847
|
*
|
|
4426
4848
|
* @category filtering
|
|
4427
4849
|
* @since 2.0.0
|
|
@@ -4435,12 +4857,14 @@ export const getSomes: <T extends Iterable<Option<X>>, X = any>(
|
|
|
4435
4857
|
* Retrieves the `Left` values from an `Iterable` of `Either`s, collecting them into an array.
|
|
4436
4858
|
*
|
|
4437
4859
|
* @example
|
|
4860
|
+
* ```ts
|
|
4438
4861
|
* import { Array, Either } from "effect"
|
|
4439
4862
|
*
|
|
4440
4863
|
* assert.deepStrictEqual(
|
|
4441
4864
|
* Array.getLefts([Either.right(1), Either.left("err"), Either.right(2)]),
|
|
4442
4865
|
* ["err"]
|
|
4443
4866
|
* )
|
|
4867
|
+
* ```
|
|
4444
4868
|
*
|
|
4445
4869
|
* @category filtering
|
|
4446
4870
|
* @since 2.0.0
|
|
@@ -4460,12 +4884,14 @@ export const getLefts = <T extends Iterable<array_<any, any>>>(self: T): Array<a
|
|
|
4460
4884
|
* Retrieves the `Right` values from an `Iterable` of `Either`s, collecting them into an array.
|
|
4461
4885
|
*
|
|
4462
4886
|
* @example
|
|
4887
|
+
* ```ts
|
|
4463
4888
|
* import { Array, Either } from "effect"
|
|
4464
4889
|
*
|
|
4465
4890
|
* assert.deepStrictEqual(
|
|
4466
4891
|
* Array.getRights([Either.right(1), Either.left("err"), Either.right(2)]),
|
|
4467
4892
|
* [1, 2]
|
|
4468
4893
|
* )
|
|
4894
|
+
* ```
|
|
4469
4895
|
*
|
|
4470
4896
|
* @category filtering
|
|
4471
4897
|
* @since 2.0.0
|
|
@@ -4585,11 +5011,13 @@ export const partition: {
|
|
|
4585
5011
|
* Separates an `Iterable` into two arrays based on a predicate.
|
|
4586
5012
|
*
|
|
4587
5013
|
* @example
|
|
5014
|
+
* ```ts
|
|
4588
5015
|
* import { Array } from "effect"
|
|
4589
5016
|
*
|
|
4590
5017
|
* const numbers = [1, 2, 3, 4]
|
|
4591
5018
|
* const result = Array.partition(numbers, n => n % 2 === 0)
|
|
4592
5019
|
* assert.deepStrictEqual(result, [[1, 3], [2, 4]])
|
|
5020
|
+
* ```
|
|
4593
5021
|
*
|
|
4594
5022
|
* @category filtering
|
|
4595
5023
|
* @since 2.0.0
|
|
@@ -4604,11 +5032,13 @@ export const separate: <T extends Iterable<array_<any, any>>>(
|
|
|
4604
5032
|
* Reduces an array from the left.
|
|
4605
5033
|
*
|
|
4606
5034
|
* @example
|
|
5035
|
+
* ```ts
|
|
4607
5036
|
* import { Array } from "effect"
|
|
4608
5037
|
*
|
|
4609
5038
|
* const numbers = [1, 2, 3]
|
|
4610
5039
|
* const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4611
5040
|
* assert.deepStrictEqual(result, 6)
|
|
5041
|
+
* ```
|
|
4612
5042
|
*
|
|
4613
5043
|
* @category folding
|
|
4614
5044
|
* @since 2.0.0
|
|
@@ -4618,11 +5048,13 @@ export const reduce: {
|
|
|
4618
5048
|
* Reduces an array from the left.
|
|
4619
5049
|
*
|
|
4620
5050
|
* @example
|
|
5051
|
+
* ```ts
|
|
4621
5052
|
* import { Array } from "effect"
|
|
4622
5053
|
*
|
|
4623
5054
|
* const numbers = [1, 2, 3]
|
|
4624
5055
|
* const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4625
5056
|
* assert.deepStrictEqual(result, 6)
|
|
5057
|
+
* ```
|
|
4626
5058
|
*
|
|
4627
5059
|
* @category folding
|
|
4628
5060
|
* @since 2.0.0
|
|
@@ -4632,11 +5064,13 @@ export const reduce: {
|
|
|
4632
5064
|
* Reduces an array from the left.
|
|
4633
5065
|
*
|
|
4634
5066
|
* @example
|
|
5067
|
+
* ```ts
|
|
4635
5068
|
* import { Array } from "effect"
|
|
4636
5069
|
*
|
|
4637
5070
|
* const numbers = [1, 2, 3]
|
|
4638
5071
|
* const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4639
5072
|
* assert.deepStrictEqual(result, 6)
|
|
5073
|
+
* ```
|
|
4640
5074
|
*
|
|
4641
5075
|
* @category folding
|
|
4642
5076
|
* @since 2.0.0
|
|
@@ -4652,11 +5086,13 @@ export const reduce: {
|
|
|
4652
5086
|
* Reduces an array from the right.
|
|
4653
5087
|
*
|
|
4654
5088
|
* @example
|
|
5089
|
+
* ```ts
|
|
4655
5090
|
* import { Array } from "effect"
|
|
4656
5091
|
*
|
|
4657
5092
|
* const numbers = [1, 2, 3]
|
|
4658
5093
|
* const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
|
|
4659
5094
|
* assert.deepStrictEqual(result, 6)
|
|
5095
|
+
* ```
|
|
4660
5096
|
*
|
|
4661
5097
|
* @category folding
|
|
4662
5098
|
* @since 2.0.0
|
|
@@ -4666,11 +5102,13 @@ export const reduceRight: {
|
|
|
4666
5102
|
* Reduces an array from the right.
|
|
4667
5103
|
*
|
|
4668
5104
|
* @example
|
|
5105
|
+
* ```ts
|
|
4669
5106
|
* import { Array } from "effect"
|
|
4670
5107
|
*
|
|
4671
5108
|
* const numbers = [1, 2, 3]
|
|
4672
5109
|
* const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
|
|
4673
5110
|
* assert.deepStrictEqual(result, 6)
|
|
5111
|
+
* ```
|
|
4674
5112
|
*
|
|
4675
5113
|
* @category folding
|
|
4676
5114
|
* @since 2.0.0
|
|
@@ -4680,11 +5118,13 @@ export const reduceRight: {
|
|
|
4680
5118
|
* Reduces an array from the right.
|
|
4681
5119
|
*
|
|
4682
5120
|
* @example
|
|
5121
|
+
* ```ts
|
|
4683
5122
|
* import { Array } from "effect"
|
|
4684
5123
|
*
|
|
4685
5124
|
* const numbers = [1, 2, 3]
|
|
4686
5125
|
* const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
|
|
4687
5126
|
* assert.deepStrictEqual(result, 6)
|
|
5127
|
+
* ```
|
|
4688
5128
|
*
|
|
4689
5129
|
* @category folding
|
|
4690
5130
|
* @since 2.0.0
|
|
@@ -4700,12 +5140,14 @@ export const reduceRight: {
|
|
|
4700
5140
|
* Lifts a predicate into an array.
|
|
4701
5141
|
*
|
|
4702
5142
|
* @example
|
|
5143
|
+
* ```ts
|
|
4703
5144
|
* import { Array } from "effect"
|
|
4704
5145
|
*
|
|
4705
5146
|
* const isEven = (n: number) => n % 2 === 0
|
|
4706
5147
|
* const to = Array.liftPredicate(isEven)
|
|
4707
5148
|
* assert.deepStrictEqual(to(1), [])
|
|
4708
5149
|
* assert.deepStrictEqual(to(2), [2])
|
|
5150
|
+
* ```
|
|
4709
5151
|
*
|
|
4710
5152
|
* @category lifting
|
|
4711
5153
|
* @since 2.0.0
|
|
@@ -4716,12 +5158,14 @@ export const liftPredicate: { // Note: I intentionally avoid using the NoInfer p
|
|
|
4716
5158
|
* Lifts a predicate into an array.
|
|
4717
5159
|
*
|
|
4718
5160
|
* @example
|
|
5161
|
+
* ```ts
|
|
4719
5162
|
* import { Array } from "effect"
|
|
4720
5163
|
*
|
|
4721
5164
|
* const isEven = (n: number) => n % 2 === 0
|
|
4722
5165
|
* const to = Array.liftPredicate(isEven)
|
|
4723
5166
|
* assert.deepStrictEqual(to(1), [])
|
|
4724
5167
|
* assert.deepStrictEqual(to(2), [2])
|
|
5168
|
+
* ```
|
|
4725
5169
|
*
|
|
4726
5170
|
* @category lifting
|
|
4727
5171
|
* @since 2.0.0
|
|
@@ -4757,6 +5201,7 @@ export const liftNullable = <A extends Array<unknown>, B>(
|
|
|
4757
5201
|
* Maps over an array and flattens the result, removing null and undefined values.
|
|
4758
5202
|
*
|
|
4759
5203
|
* @example
|
|
5204
|
+
* ```ts
|
|
4760
5205
|
* import { Array } from "effect"
|
|
4761
5206
|
*
|
|
4762
5207
|
* const numbers = [1, 2, 3]
|
|
@@ -4767,6 +5212,7 @@ export const liftNullable = <A extends Array<unknown>, B>(
|
|
|
4767
5212
|
* // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
|
|
4768
5213
|
* // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
|
|
4769
5214
|
* // to remove null values, resulting in [1, 3].
|
|
5215
|
+
* ```
|
|
4770
5216
|
*
|
|
4771
5217
|
* @category sequencing
|
|
4772
5218
|
* @since 2.0.0
|
|
@@ -4776,6 +5222,7 @@ export const flatMapNullable: {
|
|
|
4776
5222
|
* Maps over an array and flattens the result, removing null and undefined values.
|
|
4777
5223
|
*
|
|
4778
5224
|
* @example
|
|
5225
|
+
* ```ts
|
|
4779
5226
|
* import { Array } from "effect"
|
|
4780
5227
|
*
|
|
4781
5228
|
* const numbers = [1, 2, 3]
|
|
@@ -4786,6 +5233,7 @@ export const flatMapNullable: {
|
|
|
4786
5233
|
* // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
|
|
4787
5234
|
* // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
|
|
4788
5235
|
* // to remove null values, resulting in [1, 3].
|
|
5236
|
+
* ```
|
|
4789
5237
|
*
|
|
4790
5238
|
* @category sequencing
|
|
4791
5239
|
* @since 2.0.0
|
|
@@ -4795,6 +5243,7 @@ export const flatMapNullable: {
|
|
|
4795
5243
|
* Maps over an array and flattens the result, removing null and undefined values.
|
|
4796
5244
|
*
|
|
4797
5245
|
* @example
|
|
5246
|
+
* ```ts
|
|
4798
5247
|
* import { Array } from "effect"
|
|
4799
5248
|
*
|
|
4800
5249
|
* const numbers = [1, 2, 3]
|
|
@@ -4805,6 +5254,7 @@ export const flatMapNullable: {
|
|
|
4805
5254
|
* // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
|
|
4806
5255
|
* // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
|
|
4807
5256
|
* // to remove null values, resulting in [1, 3].
|
|
5257
|
+
* ```
|
|
4808
5258
|
*
|
|
4809
5259
|
* @category sequencing
|
|
4810
5260
|
* @since 2.0.0
|
|
@@ -4822,6 +5272,7 @@ export const flatMapNullable: {
|
|
|
4822
5272
|
* If the `Either` is a right, it returns an array with the right value.
|
|
4823
5273
|
*
|
|
4824
5274
|
* @example
|
|
5275
|
+
* ```ts
|
|
4825
5276
|
* import { Array, Either } from "effect"
|
|
4826
5277
|
*
|
|
4827
5278
|
* const parseNumber = (s: string): Either.Either<number, Error> =>
|
|
@@ -4839,6 +5290,7 @@ export const flatMapNullable: {
|
|
|
4839
5290
|
* // The function parseNumber is lifted to return an array.
|
|
4840
5291
|
* // When parsing "42", it returns an Either.left with the number 42, resulting in [42].
|
|
4841
5292
|
* // When parsing "not a number", it returns an Either.right with an error, resulting in an empty array [].
|
|
5293
|
+
* ```
|
|
4842
5294
|
*
|
|
4843
5295
|
* @category lifting
|
|
4844
5296
|
* @since 2.0.0
|
|
@@ -4925,6 +5377,7 @@ export const some: {
|
|
|
4925
5377
|
* Extends an array with a function that maps each subarray to a value.
|
|
4926
5378
|
*
|
|
4927
5379
|
* @example
|
|
5380
|
+
* ```ts
|
|
4928
5381
|
* import { Array } from "effect"
|
|
4929
5382
|
*
|
|
4930
5383
|
* const numbers = [1, 2, 3]
|
|
@@ -4936,6 +5389,7 @@ export const some: {
|
|
|
4936
5389
|
* // The subarrays are: [1, 2, 3], [2, 3], [3].
|
|
4937
5390
|
* // The lengths are: 3, 2, 1.
|
|
4938
5391
|
* // Therefore, the result is [3, 2, 1].
|
|
5392
|
+
* ```
|
|
4939
5393
|
*
|
|
4940
5394
|
* @since 2.0.0
|
|
4941
5395
|
*/
|
|
@@ -4944,6 +5398,7 @@ export const extend: {
|
|
|
4944
5398
|
* Extends an array with a function that maps each subarray to a value.
|
|
4945
5399
|
*
|
|
4946
5400
|
* @example
|
|
5401
|
+
* ```ts
|
|
4947
5402
|
* import { Array } from "effect"
|
|
4948
5403
|
*
|
|
4949
5404
|
* const numbers = [1, 2, 3]
|
|
@@ -4955,6 +5410,7 @@ export const extend: {
|
|
|
4955
5410
|
* // The subarrays are: [1, 2, 3], [2, 3], [3].
|
|
4956
5411
|
* // The lengths are: 3, 2, 1.
|
|
4957
5412
|
* // Therefore, the result is [3, 2, 1].
|
|
5413
|
+
* ```
|
|
4958
5414
|
*
|
|
4959
5415
|
* @since 2.0.0
|
|
4960
5416
|
*/
|
|
@@ -4963,6 +5419,7 @@ export const extend: {
|
|
|
4963
5419
|
* Extends an array with a function that maps each subarray to a value.
|
|
4964
5420
|
*
|
|
4965
5421
|
* @example
|
|
5422
|
+
* ```ts
|
|
4966
5423
|
* import { Array } from "effect"
|
|
4967
5424
|
*
|
|
4968
5425
|
* const numbers = [1, 2, 3]
|
|
@@ -4974,6 +5431,7 @@ export const extend: {
|
|
|
4974
5431
|
* // The subarrays are: [1, 2, 3], [2, 3], [3].
|
|
4975
5432
|
* // The lengths are: 3, 2, 1.
|
|
4976
5433
|
* // Therefore, the result is [3, 2, 1].
|
|
5434
|
+
* ```
|
|
4977
5435
|
*
|
|
4978
5436
|
* @since 2.0.0
|
|
4979
5437
|
*/
|
|
@@ -4987,10 +5445,12 @@ export const extend: {
|
|
|
4987
5445
|
* Finds the minimum element in an array based on a comparator.
|
|
4988
5446
|
*
|
|
4989
5447
|
* @example
|
|
5448
|
+
* ```ts
|
|
4990
5449
|
* import { Array, Order } from "effect"
|
|
4991
5450
|
*
|
|
4992
5451
|
* const min = Array.min([3, 1, 2], Order.number)
|
|
4993
5452
|
* assert.deepStrictEqual(min, 1)
|
|
5453
|
+
* ```
|
|
4994
5454
|
*
|
|
4995
5455
|
* @since 2.0.0
|
|
4996
5456
|
*/
|
|
@@ -4999,10 +5459,12 @@ export const min: {
|
|
|
4999
5459
|
* Finds the minimum element in an array based on a comparator.
|
|
5000
5460
|
*
|
|
5001
5461
|
* @example
|
|
5462
|
+
* ```ts
|
|
5002
5463
|
* import { Array, Order } from "effect"
|
|
5003
5464
|
*
|
|
5004
5465
|
* const min = Array.min([3, 1, 2], Order.number)
|
|
5005
5466
|
* assert.deepStrictEqual(min, 1)
|
|
5467
|
+
* ```
|
|
5006
5468
|
*
|
|
5007
5469
|
* @since 2.0.0
|
|
5008
5470
|
*/
|
|
@@ -5011,10 +5473,12 @@ export const min: {
|
|
|
5011
5473
|
* Finds the minimum element in an array based on a comparator.
|
|
5012
5474
|
*
|
|
5013
5475
|
* @example
|
|
5476
|
+
* ```ts
|
|
5014
5477
|
* import { Array, Order } from "effect"
|
|
5015
5478
|
*
|
|
5016
5479
|
* const min = Array.min([3, 1, 2], Order.number)
|
|
5017
5480
|
* assert.deepStrictEqual(min, 1)
|
|
5481
|
+
* ```
|
|
5018
5482
|
*
|
|
5019
5483
|
* @since 2.0.0
|
|
5020
5484
|
*/
|
|
@@ -5025,10 +5489,12 @@ export const min: {
|
|
|
5025
5489
|
* Finds the maximum element in an array based on a comparator.
|
|
5026
5490
|
*
|
|
5027
5491
|
* @example
|
|
5492
|
+
* ```ts
|
|
5028
5493
|
* import { Array, Order } from "effect"
|
|
5029
5494
|
*
|
|
5030
5495
|
* const max = Array.max([3, 1, 2], Order.number)
|
|
5031
5496
|
* assert.deepStrictEqual(max, 3)
|
|
5497
|
+
* ```
|
|
5032
5498
|
*
|
|
5033
5499
|
* @since 2.0.0
|
|
5034
5500
|
*/
|
|
@@ -5037,10 +5503,12 @@ export const max: {
|
|
|
5037
5503
|
* Finds the maximum element in an array based on a comparator.
|
|
5038
5504
|
*
|
|
5039
5505
|
* @example
|
|
5506
|
+
* ```ts
|
|
5040
5507
|
* import { Array, Order } from "effect"
|
|
5041
5508
|
*
|
|
5042
5509
|
* const max = Array.max([3, 1, 2], Order.number)
|
|
5043
5510
|
* assert.deepStrictEqual(max, 3)
|
|
5511
|
+
* ```
|
|
5044
5512
|
*
|
|
5045
5513
|
* @since 2.0.0
|
|
5046
5514
|
*/
|
|
@@ -5049,10 +5517,12 @@ export const max: {
|
|
|
5049
5517
|
* Finds the maximum element in an array based on a comparator.
|
|
5050
5518
|
*
|
|
5051
5519
|
* @example
|
|
5520
|
+
* ```ts
|
|
5052
5521
|
* import { Array, Order } from "effect"
|
|
5053
5522
|
*
|
|
5054
5523
|
* const max = Array.max([3, 1, 2], Order.number)
|
|
5055
5524
|
* assert.deepStrictEqual(max, 3)
|
|
5525
|
+
* ```
|
|
5056
5526
|
*
|
|
5057
5527
|
* @since 2.0.0
|
|
5058
5528
|
*/
|
|
@@ -5090,12 +5560,14 @@ export const getOrder: <A>(O: Order.Order<A>) => Order.Order<ReadonlyArray<A>> =
|
|
|
5090
5560
|
* Creates an equivalence relation for arrays.
|
|
5091
5561
|
*
|
|
5092
5562
|
* @example
|
|
5563
|
+
* ```ts
|
|
5093
5564
|
* import { Array } from "effect"
|
|
5094
5565
|
*
|
|
5095
5566
|
* const numbers1 = [1, 2, 3]
|
|
5096
5567
|
* const numbers2 = [1, 2, 3]
|
|
5097
5568
|
* const eq = Array.getEquivalence<number>((a, b) => a === b)
|
|
5098
5569
|
* assert.deepStrictEqual(eq(numbers1, numbers2), true)
|
|
5570
|
+
* ```
|
|
5099
5571
|
*
|
|
5100
5572
|
* @category instances
|
|
5101
5573
|
* @since 2.0.0
|
|
@@ -5108,10 +5580,12 @@ export const getEquivalence: <A>(
|
|
|
5108
5580
|
* Performs a side-effect for each element of the `Iterable`.
|
|
5109
5581
|
*
|
|
5110
5582
|
* @example
|
|
5583
|
+
* ```ts
|
|
5111
5584
|
* import { Array } from "effect"
|
|
5112
5585
|
*
|
|
5113
5586
|
* const numbers = [1, 2, 3]
|
|
5114
5587
|
* Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
|
|
5588
|
+
* ```
|
|
5115
5589
|
*
|
|
5116
5590
|
* @since 2.0.0
|
|
5117
5591
|
*/
|
|
@@ -5120,10 +5594,12 @@ export const forEach: {
|
|
|
5120
5594
|
* Performs a side-effect for each element of the `Iterable`.
|
|
5121
5595
|
*
|
|
5122
5596
|
* @example
|
|
5597
|
+
* ```ts
|
|
5123
5598
|
* import { Array } from "effect"
|
|
5124
5599
|
*
|
|
5125
5600
|
* const numbers = [1, 2, 3]
|
|
5126
5601
|
* Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
|
|
5602
|
+
* ```
|
|
5127
5603
|
*
|
|
5128
5604
|
* @since 2.0.0
|
|
5129
5605
|
*/
|
|
@@ -5132,10 +5608,12 @@ export const forEach: {
|
|
|
5132
5608
|
* Performs a side-effect for each element of the `Iterable`.
|
|
5133
5609
|
*
|
|
5134
5610
|
* @example
|
|
5611
|
+
* ```ts
|
|
5135
5612
|
* import { Array } from "effect"
|
|
5136
5613
|
*
|
|
5137
5614
|
* const numbers = [1, 2, 3]
|
|
5138
5615
|
* Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
|
|
5616
|
+
* ```
|
|
5139
5617
|
*
|
|
5140
5618
|
* @since 2.0.0
|
|
5141
5619
|
*/
|
|
@@ -5147,11 +5625,13 @@ export const forEach: {
|
|
|
5147
5625
|
* preserving the order of the first occurrence of each element.
|
|
5148
5626
|
*
|
|
5149
5627
|
* @example
|
|
5628
|
+
* ```ts
|
|
5150
5629
|
* import { Array } from "effect"
|
|
5151
5630
|
*
|
|
5152
5631
|
* const numbers = [1, 2, 2, 3, 3, 3]
|
|
5153
5632
|
* const unique = Array.dedupeWith(numbers, (a, b) => a === b)
|
|
5154
5633
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5634
|
+
* ```
|
|
5155
5635
|
*
|
|
5156
5636
|
* @since 2.0.0
|
|
5157
5637
|
*/
|
|
@@ -5161,11 +5641,13 @@ export const dedupeWith: {
|
|
|
5161
5641
|
* preserving the order of the first occurrence of each element.
|
|
5162
5642
|
*
|
|
5163
5643
|
* @example
|
|
5644
|
+
* ```ts
|
|
5164
5645
|
* import { Array } from "effect"
|
|
5165
5646
|
*
|
|
5166
5647
|
* const numbers = [1, 2, 2, 3, 3, 3]
|
|
5167
5648
|
* const unique = Array.dedupeWith(numbers, (a, b) => a === b)
|
|
5168
5649
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5650
|
+
* ```
|
|
5169
5651
|
*
|
|
5170
5652
|
* @since 2.0.0
|
|
5171
5653
|
*/
|
|
@@ -5177,11 +5659,13 @@ export const dedupeWith: {
|
|
|
5177
5659
|
* preserving the order of the first occurrence of each element.
|
|
5178
5660
|
*
|
|
5179
5661
|
* @example
|
|
5662
|
+
* ```ts
|
|
5180
5663
|
* import { Array } from "effect"
|
|
5181
5664
|
*
|
|
5182
5665
|
* const numbers = [1, 2, 2, 3, 3, 3]
|
|
5183
5666
|
* const unique = Array.dedupeWith(numbers, (a, b) => a === b)
|
|
5184
5667
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5668
|
+
* ```
|
|
5185
5669
|
*
|
|
5186
5670
|
* @since 2.0.0
|
|
5187
5671
|
*/
|
|
@@ -5194,11 +5678,13 @@ export const dedupeWith: {
|
|
|
5194
5678
|
* preserving the order of the first occurrence of each element.
|
|
5195
5679
|
*
|
|
5196
5680
|
* @example
|
|
5681
|
+
* ```ts
|
|
5197
5682
|
* import { Array } from "effect"
|
|
5198
5683
|
*
|
|
5199
5684
|
* const numbers = [1, 2, 2, 3, 3, 3]
|
|
5200
5685
|
* const unique = Array.dedupeWith(numbers, (a, b) => a === b)
|
|
5201
5686
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5687
|
+
* ```
|
|
5202
5688
|
*
|
|
5203
5689
|
* @since 2.0.0
|
|
5204
5690
|
*/
|
|
@@ -5236,11 +5722,13 @@ export const dedupe = <S extends Iterable<any> | NonEmptyReadonlyArray<any>>(
|
|
|
5236
5722
|
* Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
|
|
5237
5723
|
*
|
|
5238
5724
|
* @example
|
|
5725
|
+
* ```ts
|
|
5239
5726
|
* import { Array } from "effect"
|
|
5240
5727
|
*
|
|
5241
5728
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
5242
5729
|
* const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
5243
5730
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5731
|
+
* ```
|
|
5244
5732
|
*
|
|
5245
5733
|
* @since 2.0.0
|
|
5246
5734
|
*/
|
|
@@ -5249,11 +5737,13 @@ export const dedupeAdjacentWith: {
|
|
|
5249
5737
|
* Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
|
|
5250
5738
|
*
|
|
5251
5739
|
* @example
|
|
5740
|
+
* ```ts
|
|
5252
5741
|
* import { Array } from "effect"
|
|
5253
5742
|
*
|
|
5254
5743
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
5255
5744
|
* const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
5256
5745
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5746
|
+
* ```
|
|
5257
5747
|
*
|
|
5258
5748
|
* @since 2.0.0
|
|
5259
5749
|
*/
|
|
@@ -5262,11 +5752,13 @@ export const dedupeAdjacentWith: {
|
|
|
5262
5752
|
* Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
|
|
5263
5753
|
*
|
|
5264
5754
|
* @example
|
|
5755
|
+
* ```ts
|
|
5265
5756
|
* import { Array } from "effect"
|
|
5266
5757
|
*
|
|
5267
5758
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
5268
5759
|
* const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
5269
5760
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5761
|
+
* ```
|
|
5270
5762
|
*
|
|
5271
5763
|
* @since 2.0.0
|
|
5272
5764
|
*/
|
|
@@ -5287,11 +5779,13 @@ export const dedupeAdjacentWith: {
|
|
|
5287
5779
|
* Deduplicates adjacent elements that are identical.
|
|
5288
5780
|
*
|
|
5289
5781
|
* @example
|
|
5782
|
+
* ```ts
|
|
5290
5783
|
* import { Array } from "effect"
|
|
5291
5784
|
*
|
|
5292
5785
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
5293
5786
|
* const unique = Array.dedupeAdjacent(numbers)
|
|
5294
5787
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
5788
|
+
* ```
|
|
5295
5789
|
*
|
|
5296
5790
|
* @since 2.0.0
|
|
5297
5791
|
*/
|
|
@@ -5301,11 +5795,13 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Array<A> = dedupeAdjacent
|
|
|
5301
5795
|
* Joins the elements together with "sep" in the middle.
|
|
5302
5796
|
*
|
|
5303
5797
|
* @example
|
|
5798
|
+
* ```ts
|
|
5304
5799
|
* import { Array } from "effect"
|
|
5305
5800
|
*
|
|
5306
5801
|
* const strings = ["a", "b", "c"]
|
|
5307
5802
|
* const joined = Array.join(strings, "-")
|
|
5308
5803
|
* assert.deepStrictEqual(joined, "a-b-c")
|
|
5804
|
+
* ```
|
|
5309
5805
|
*
|
|
5310
5806
|
* @since 2.0.0
|
|
5311
5807
|
* @category folding
|
|
@@ -5315,11 +5811,13 @@ export const join: {
|
|
|
5315
5811
|
* Joins the elements together with "sep" in the middle.
|
|
5316
5812
|
*
|
|
5317
5813
|
* @example
|
|
5814
|
+
* ```ts
|
|
5318
5815
|
* import { Array } from "effect"
|
|
5319
5816
|
*
|
|
5320
5817
|
* const strings = ["a", "b", "c"]
|
|
5321
5818
|
* const joined = Array.join(strings, "-")
|
|
5322
5819
|
* assert.deepStrictEqual(joined, "a-b-c")
|
|
5820
|
+
* ```
|
|
5323
5821
|
*
|
|
5324
5822
|
* @since 2.0.0
|
|
5325
5823
|
* @category folding
|
|
@@ -5329,11 +5827,13 @@ export const join: {
|
|
|
5329
5827
|
* Joins the elements together with "sep" in the middle.
|
|
5330
5828
|
*
|
|
5331
5829
|
* @example
|
|
5830
|
+
* ```ts
|
|
5332
5831
|
* import { Array } from "effect"
|
|
5333
5832
|
*
|
|
5334
5833
|
* const strings = ["a", "b", "c"]
|
|
5335
5834
|
* const joined = Array.join(strings, "-")
|
|
5336
5835
|
* assert.deepStrictEqual(joined, "a-b-c")
|
|
5836
|
+
* ```
|
|
5337
5837
|
*
|
|
5338
5838
|
* @since 2.0.0
|
|
5339
5839
|
* @category folding
|
|
@@ -5345,11 +5845,13 @@ export const join: {
|
|
|
5345
5845
|
* Statefully maps over the chunk, producing new elements of type `B`.
|
|
5346
5846
|
*
|
|
5347
5847
|
* @example
|
|
5848
|
+
* ```ts
|
|
5348
5849
|
* import { Array } from "effect"
|
|
5349
5850
|
*
|
|
5350
5851
|
* const numbers = [1, 2, 3]
|
|
5351
5852
|
* const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
|
|
5352
5853
|
* assert.deepStrictEqual(result, [6, [1, 3, 6]])
|
|
5854
|
+
* ```
|
|
5353
5855
|
*
|
|
5354
5856
|
* @since 2.0.0
|
|
5355
5857
|
* @category folding
|
|
@@ -5359,11 +5861,13 @@ export const mapAccum: {
|
|
|
5359
5861
|
* Statefully maps over the chunk, producing new elements of type `B`.
|
|
5360
5862
|
*
|
|
5361
5863
|
* @example
|
|
5864
|
+
* ```ts
|
|
5362
5865
|
* import { Array } from "effect"
|
|
5363
5866
|
*
|
|
5364
5867
|
* const numbers = [1, 2, 3]
|
|
5365
5868
|
* const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
|
|
5366
5869
|
* assert.deepStrictEqual(result, [6, [1, 3, 6]])
|
|
5870
|
+
* ```
|
|
5367
5871
|
*
|
|
5368
5872
|
* @since 2.0.0
|
|
5369
5873
|
* @category folding
|
|
@@ -5376,11 +5880,13 @@ export const mapAccum: {
|
|
|
5376
5880
|
* Statefully maps over the chunk, producing new elements of type `B`.
|
|
5377
5881
|
*
|
|
5378
5882
|
* @example
|
|
5883
|
+
* ```ts
|
|
5379
5884
|
* import { Array } from "effect"
|
|
5380
5885
|
*
|
|
5381
5886
|
* const numbers = [1, 2, 3]
|
|
5382
5887
|
* const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
|
|
5383
5888
|
* assert.deepStrictEqual(result, [6, [1, 3, 6]])
|
|
5889
|
+
* ```
|
|
5384
5890
|
*
|
|
5385
5891
|
* @since 2.0.0
|
|
5386
5892
|
* @category folding
|
|
@@ -5410,12 +5916,14 @@ export const mapAccum: {
|
|
|
5410
5916
|
* Zips this chunk crosswise with the specified chunk using the specified combiner.
|
|
5411
5917
|
*
|
|
5412
5918
|
* @example
|
|
5919
|
+
* ```ts
|
|
5413
5920
|
* import { Array } from "effect"
|
|
5414
5921
|
*
|
|
5415
5922
|
* const array1 = [1, 2]
|
|
5416
5923
|
* const array2 = ["a", "b"]
|
|
5417
5924
|
* const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
|
|
5418
5925
|
* assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
|
|
5926
|
+
* ```
|
|
5419
5927
|
*
|
|
5420
5928
|
* @since 2.0.0
|
|
5421
5929
|
* @category elements
|
|
@@ -5425,12 +5933,14 @@ export const cartesianWith: {
|
|
|
5425
5933
|
* Zips this chunk crosswise with the specified chunk using the specified combiner.
|
|
5426
5934
|
*
|
|
5427
5935
|
* @example
|
|
5936
|
+
* ```ts
|
|
5428
5937
|
* import { Array } from "effect"
|
|
5429
5938
|
*
|
|
5430
5939
|
* const array1 = [1, 2]
|
|
5431
5940
|
* const array2 = ["a", "b"]
|
|
5432
5941
|
* const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
|
|
5433
5942
|
* assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
|
|
5943
|
+
* ```
|
|
5434
5944
|
*
|
|
5435
5945
|
* @since 2.0.0
|
|
5436
5946
|
* @category elements
|
|
@@ -5440,12 +5950,14 @@ export const cartesianWith: {
|
|
|
5440
5950
|
* Zips this chunk crosswise with the specified chunk using the specified combiner.
|
|
5441
5951
|
*
|
|
5442
5952
|
* @example
|
|
5953
|
+
* ```ts
|
|
5443
5954
|
* import { Array } from "effect"
|
|
5444
5955
|
*
|
|
5445
5956
|
* const array1 = [1, 2]
|
|
5446
5957
|
* const array2 = ["a", "b"]
|
|
5447
5958
|
* const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
|
|
5448
5959
|
* assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
|
|
5960
|
+
* ```
|
|
5449
5961
|
*
|
|
5450
5962
|
* @since 2.0.0
|
|
5451
5963
|
* @category elements
|
|
@@ -5461,12 +5973,14 @@ export const cartesianWith: {
|
|
|
5461
5973
|
* Zips this chunk crosswise with the specified chunk.
|
|
5462
5974
|
*
|
|
5463
5975
|
* @example
|
|
5976
|
+
* ```ts
|
|
5464
5977
|
* import { Array } from "effect"
|
|
5465
5978
|
*
|
|
5466
5979
|
* const array1 = [1, 2]
|
|
5467
5980
|
* const array2 = ["a", "b"]
|
|
5468
5981
|
* const product = Array.cartesian(array1, array2)
|
|
5469
5982
|
* assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
|
|
5983
|
+
* ```
|
|
5470
5984
|
*
|
|
5471
5985
|
* @since 2.0.0
|
|
5472
5986
|
* @category elements
|
|
@@ -5476,12 +5990,14 @@ export const cartesian: {
|
|
|
5476
5990
|
* Zips this chunk crosswise with the specified chunk.
|
|
5477
5991
|
*
|
|
5478
5992
|
* @example
|
|
5993
|
+
* ```ts
|
|
5479
5994
|
* import { Array } from "effect"
|
|
5480
5995
|
*
|
|
5481
5996
|
* const array1 = [1, 2]
|
|
5482
5997
|
* const array2 = ["a", "b"]
|
|
5483
5998
|
* const product = Array.cartesian(array1, array2)
|
|
5484
5999
|
* assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
|
|
6000
|
+
* ```
|
|
5485
6001
|
*
|
|
5486
6002
|
* @since 2.0.0
|
|
5487
6003
|
* @category elements
|
|
@@ -5491,12 +6007,14 @@ export const cartesian: {
|
|
|
5491
6007
|
* Zips this chunk crosswise with the specified chunk.
|
|
5492
6008
|
*
|
|
5493
6009
|
* @example
|
|
6010
|
+
* ```ts
|
|
5494
6011
|
* import { Array } from "effect"
|
|
5495
6012
|
*
|
|
5496
6013
|
* const array1 = [1, 2]
|
|
5497
6014
|
* const array2 = ["a", "b"]
|
|
5498
6015
|
* const product = Array.cartesian(array1, array2)
|
|
5499
6016
|
* assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
|
|
6017
|
+
* ```
|
|
5500
6018
|
*
|
|
5501
6019
|
* @since 2.0.0
|
|
5502
6020
|
* @category elements
|
|
@@ -5530,6 +6048,7 @@ export const cartesian: {
|
|
|
5530
6048
|
* @see {@link let_ let}
|
|
5531
6049
|
*
|
|
5532
6050
|
* @example
|
|
6051
|
+
* ```ts
|
|
5533
6052
|
* import { Array as Arr, pipe } from "effect"
|
|
5534
6053
|
* const doResult = pipe(
|
|
5535
6054
|
* Arr.Do,
|
|
@@ -5550,6 +6069,7 @@ export const cartesian: {
|
|
|
5550
6069
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5551
6070
|
* }
|
|
5552
6071
|
* }
|
|
6072
|
+
* ```
|
|
5553
6073
|
*
|
|
5554
6074
|
* @category do notation
|
|
5555
6075
|
* @since 3.2.0
|
|
@@ -5575,6 +6095,7 @@ export const Do: ReadonlyArray<{}> = of({})
|
|
|
5575
6095
|
* @see {@link let_ let}
|
|
5576
6096
|
*
|
|
5577
6097
|
* @example
|
|
6098
|
+
* ```ts
|
|
5578
6099
|
* import { Array as Arr, pipe } from "effect"
|
|
5579
6100
|
* const doResult = pipe(
|
|
5580
6101
|
* Arr.Do,
|
|
@@ -5595,6 +6116,7 @@ export const Do: ReadonlyArray<{}> = of({})
|
|
|
5595
6116
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5596
6117
|
* }
|
|
5597
6118
|
* }
|
|
6119
|
+
* ```
|
|
5598
6120
|
*
|
|
5599
6121
|
* @category do notation
|
|
5600
6122
|
* @since 3.2.0
|
|
@@ -5619,6 +6141,7 @@ export const bind: {
|
|
|
5619
6141
|
* @see {@link let_ let}
|
|
5620
6142
|
*
|
|
5621
6143
|
* @example
|
|
6144
|
+
* ```ts
|
|
5622
6145
|
* import { Array as Arr, pipe } from "effect"
|
|
5623
6146
|
* const doResult = pipe(
|
|
5624
6147
|
* Arr.Do,
|
|
@@ -5639,6 +6162,7 @@ export const bind: {
|
|
|
5639
6162
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5640
6163
|
* }
|
|
5641
6164
|
* }
|
|
6165
|
+
* ```
|
|
5642
6166
|
*
|
|
5643
6167
|
* @category do notation
|
|
5644
6168
|
* @since 3.2.0
|
|
@@ -5665,6 +6189,7 @@ export const bind: {
|
|
|
5665
6189
|
* @see {@link let_ let}
|
|
5666
6190
|
*
|
|
5667
6191
|
* @example
|
|
6192
|
+
* ```ts
|
|
5668
6193
|
* import { Array as Arr, pipe } from "effect"
|
|
5669
6194
|
* const doResult = pipe(
|
|
5670
6195
|
* Arr.Do,
|
|
@@ -5685,6 +6210,7 @@ export const bind: {
|
|
|
5685
6210
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5686
6211
|
* }
|
|
5687
6212
|
* }
|
|
6213
|
+
* ```
|
|
5688
6214
|
*
|
|
5689
6215
|
* @category do notation
|
|
5690
6216
|
* @since 3.2.0
|
|
@@ -5715,6 +6241,7 @@ export const bind: {
|
|
|
5715
6241
|
* @see {@link let_ let}
|
|
5716
6242
|
*
|
|
5717
6243
|
* @example
|
|
6244
|
+
* ```ts
|
|
5718
6245
|
* import { Array as Arr, pipe } from "effect"
|
|
5719
6246
|
* const doResult = pipe(
|
|
5720
6247
|
* Arr.Do,
|
|
@@ -5735,6 +6262,7 @@ export const bind: {
|
|
|
5735
6262
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5736
6263
|
* }
|
|
5737
6264
|
* }
|
|
6265
|
+
* ```
|
|
5738
6266
|
*
|
|
5739
6267
|
* @category do notation
|
|
5740
6268
|
* @since 3.2.0
|
|
@@ -5759,6 +6287,7 @@ export const bindTo: {
|
|
|
5759
6287
|
* @see {@link let_ let}
|
|
5760
6288
|
*
|
|
5761
6289
|
* @example
|
|
6290
|
+
* ```ts
|
|
5762
6291
|
* import { Array as Arr, pipe } from "effect"
|
|
5763
6292
|
* const doResult = pipe(
|
|
5764
6293
|
* Arr.Do,
|
|
@@ -5779,6 +6308,7 @@ export const bindTo: {
|
|
|
5779
6308
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5780
6309
|
* }
|
|
5781
6310
|
* }
|
|
6311
|
+
* ```
|
|
5782
6312
|
*
|
|
5783
6313
|
* @category do notation
|
|
5784
6314
|
* @since 3.2.0
|
|
@@ -5803,6 +6333,7 @@ export const bindTo: {
|
|
|
5803
6333
|
* @see {@link let_ let}
|
|
5804
6334
|
*
|
|
5805
6335
|
* @example
|
|
6336
|
+
* ```ts
|
|
5806
6337
|
* import { Array as Arr, pipe } from "effect"
|
|
5807
6338
|
* const doResult = pipe(
|
|
5808
6339
|
* Arr.Do,
|
|
@@ -5823,6 +6354,7 @@ export const bindTo: {
|
|
|
5823
6354
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
5824
6355
|
* }
|
|
5825
6356
|
* }
|
|
6357
|
+
* ```
|
|
5826
6358
|
*
|
|
5827
6359
|
* @category do notation
|
|
5828
6360
|
* @since 3.2.0
|
|
@@ -5862,6 +6394,7 @@ export {
|
|
|
5862
6394
|
* @see {@link Do}
|
|
5863
6395
|
*
|
|
5864
6396
|
* @example
|
|
6397
|
+
* ```ts
|
|
5865
6398
|
* import { Array as Arr, pipe } from "effect"
|
|
5866
6399
|
* const doResult = pipe(
|
|
5867
6400
|
* Arr.Do,
|
|
@@ -5883,6 +6416,7 @@ export {
|
|
|
5883
6416
|
* }
|
|
5884
6417
|
* }
|
|
5885
6418
|
*
|
|
6419
|
+
* ```
|
|
5886
6420
|
* @category do notation
|
|
5887
6421
|
* @since 3.2.0
|
|
5888
6422
|
*/
|