effect 3.10.18 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Array.js +206 -0
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/BigDecimal.js +181 -24
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/BigInt.js +54 -0
- package/dist/cjs/BigInt.js.map +1 -1
- package/dist/cjs/Boolean.js +24 -0
- package/dist/cjs/Boolean.js.map +1 -1
- package/dist/cjs/Brand.js +4 -0
- package/dist/cjs/Brand.js.map +1 -1
- package/dist/cjs/Channel.js +44 -4
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Chunk.js +8 -0
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Config.js +10 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +50 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/Cron.js +81 -67
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/Data.js +14 -0
- package/dist/cjs/Data.js.map +1 -1
- package/dist/cjs/DateTime.js +178 -664
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Duration.js +2 -0
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js +296 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +38 -2
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/FiberHandle.js +6 -0
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +6 -0
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +6 -0
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/Function.js +34 -0
- package/dist/cjs/Function.js.map +1 -1
- package/dist/cjs/GlobalValue.js +2 -0
- package/dist/cjs/GlobalValue.js.map +1 -1
- package/dist/cjs/HashMap.js.map +1 -1
- package/dist/cjs/Inspectable.js +8 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/Iterable.js +18 -0
- package/dist/cjs/Iterable.js.map +1 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/List.js +4 -0
- package/dist/cjs/List.js.map +1 -1
- package/dist/cjs/Logger.js +26 -0
- package/dist/cjs/Logger.js.map +1 -1
- package/dist/cjs/Mailbox.js +2 -0
- package/dist/cjs/Mailbox.js.map +1 -1
- package/dist/cjs/ManagedRuntime.js +2 -0
- package/dist/cjs/ManagedRuntime.js.map +1 -1
- package/dist/cjs/Metric.js +10 -0
- package/dist/cjs/Metric.js.map +1 -1
- package/dist/cjs/Micro.js +1104 -1069
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/Number.js +44 -0
- package/dist/cjs/Number.js.map +1 -1
- package/dist/cjs/Option.js +70 -0
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/Order.js +2 -0
- package/dist/cjs/Order.js.map +1 -1
- package/dist/cjs/Ordering.js +4 -0
- package/dist/cjs/Ordering.js.map +1 -1
- package/dist/cjs/Predicate.js +68 -0
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Random.js +4 -0
- package/dist/cjs/Random.js.map +1 -1
- package/dist/cjs/RateLimiter.js +4 -0
- package/dist/cjs/RateLimiter.js.map +1 -1
- package/dist/cjs/RcMap.js +2 -0
- package/dist/cjs/RcMap.js.map +1 -1
- package/dist/cjs/RcRef.js +2 -0
- package/dist/cjs/RcRef.js.map +1 -1
- package/dist/cjs/Record.js +56 -0
- package/dist/cjs/Record.js.map +1 -1
- package/dist/cjs/Redacted.js +8 -0
- package/dist/cjs/Redacted.js.map +1 -1
- package/dist/cjs/RegExp.js +4 -0
- package/dist/cjs/RegExp.js.map +1 -1
- package/dist/cjs/Request.js +4 -0
- package/dist/cjs/Request.js.map +1 -1
- package/dist/cjs/RequestResolver.js +2 -0
- package/dist/cjs/RequestResolver.js.map +1 -1
- package/dist/cjs/Runtime.js +6 -0
- package/dist/cjs/Runtime.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schema.js +91 -8
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Sink.js +9 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +179 -7
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/String.js +62 -0
- package/dist/cjs/String.js.map +1 -1
- package/dist/cjs/Struct.js +12 -0
- package/dist/cjs/Struct.js.map +1 -1
- package/dist/cjs/Symbol.js +2 -0
- package/dist/cjs/Symbol.js.map +1 -1
- package/dist/cjs/Trie.js +56 -0
- package/dist/cjs/Trie.js.map +1 -1
- package/dist/cjs/Tuple.js +18 -0
- package/dist/cjs/Tuple.js.map +1 -1
- package/dist/cjs/Utils.js +7 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/channel/channelExecutor.js +5 -9
- package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
- package/dist/cjs/internal/channel.js +156 -130
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/config.js +13 -4
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/context.js +46 -3
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +747 -0
- package/dist/cjs/internal/dateTime.js.map +1 -0
- package/dist/cjs/internal/fiberRuntime.js +34 -11
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +9 -3
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/mailbox.js +1 -1
- package/dist/cjs/internal/mailbox.js.map +1 -1
- package/dist/cjs/internal/sink.js +25 -21
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stream.js +70 -71
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/Array.d.ts +534 -0
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/BigDecimal.d.ts +172 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/BigInt.d.ts +114 -0
- package/dist/dts/BigInt.d.ts.map +1 -1
- package/dist/dts/Boolean.d.ts +56 -0
- package/dist/dts/Boolean.d.ts.map +1 -1
- package/dist/dts/Brand.d.ts +6 -0
- package/dist/dts/Brand.d.ts.map +1 -1
- package/dist/dts/Channel.d.ts +66 -5
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts +30 -0
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +25 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +155 -0
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +21 -6
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/Data.d.ts +26 -0
- package/dist/dts/Data.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +192 -49
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +2 -0
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +658 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +84 -2
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts +6 -0
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts +6 -0
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts +6 -0
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Function.d.ts +50 -0
- package/dist/dts/Function.d.ts.map +1 -1
- package/dist/dts/GlobalValue.d.ts +2 -0
- package/dist/dts/GlobalValue.d.ts.map +1 -1
- package/dist/dts/HashMap.d.ts +6 -0
- package/dist/dts/HashMap.d.ts.map +1 -1
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/Iterable.d.ts +26 -0
- package/dist/dts/Iterable.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +1 -0
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/List.d.ts +20 -0
- package/dist/dts/List.d.ts.map +1 -1
- package/dist/dts/Logger.d.ts +34 -0
- package/dist/dts/Logger.d.ts.map +1 -1
- package/dist/dts/Mailbox.d.ts +2 -0
- package/dist/dts/Mailbox.d.ts.map +1 -1
- package/dist/dts/ManagedRuntime.d.ts +2 -0
- package/dist/dts/ManagedRuntime.d.ts.map +1 -1
- package/dist/dts/Metric.d.ts +18 -0
- package/dist/dts/Metric.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +880 -863
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/Number.d.ts +104 -0
- package/dist/dts/Number.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +142 -0
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/Order.d.ts +2 -0
- package/dist/dts/Order.d.ts.map +1 -1
- package/dist/dts/Ordering.d.ts +8 -0
- package/dist/dts/Ordering.d.ts.map +1 -1
- package/dist/dts/Predicate.d.ts +104 -0
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Random.d.ts +4 -0
- package/dist/dts/Random.d.ts.map +1 -1
- package/dist/dts/RateLimiter.d.ts +4 -0
- package/dist/dts/RateLimiter.d.ts.map +1 -1
- package/dist/dts/RcMap.d.ts +6 -0
- package/dist/dts/RcMap.d.ts.map +1 -1
- package/dist/dts/RcRef.d.ts +2 -0
- package/dist/dts/RcRef.d.ts.map +1 -1
- package/dist/dts/Record.d.ts +136 -0
- package/dist/dts/Record.d.ts.map +1 -1
- package/dist/dts/Redacted.d.ts +8 -0
- package/dist/dts/Redacted.d.ts.map +1 -1
- package/dist/dts/RegExp.d.ts +4 -0
- package/dist/dts/RegExp.d.ts.map +1 -1
- package/dist/dts/Request.d.ts +4 -0
- package/dist/dts/Request.d.ts.map +1 -1
- package/dist/dts/RequestResolver.d.ts +6 -0
- package/dist/dts/RequestResolver.d.ts.map +1 -1
- package/dist/dts/Runtime.d.ts +18 -0
- package/dist/dts/Runtime.d.ts.map +1 -1
- package/dist/dts/STM.d.ts +2 -0
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +90 -0
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +8 -0
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +394 -32
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/String.d.ts +94 -0
- package/dist/dts/String.d.ts.map +1 -1
- package/dist/dts/Struct.d.ts +24 -0
- package/dist/dts/Struct.d.ts.map +1 -1
- package/dist/dts/Symbol.d.ts +2 -0
- package/dist/dts/Symbol.d.ts.map +1 -1
- package/dist/dts/Trie.d.ts +132 -0
- package/dist/dts/Trie.d.ts.map +1 -1
- package/dist/dts/Tuple.d.ts +42 -0
- package/dist/dts/Tuple.d.ts.map +1 -1
- package/dist/dts/Types.d.ts +24 -0
- package/dist/dts/Types.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +4 -0
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/internal/context.d.ts +1 -1
- package/dist/dts/internal/context.d.ts.map +1 -1
- package/dist/dts/internal/dateTime.d.ts +2 -0
- package/dist/dts/internal/dateTime.d.ts.map +1 -0
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Array.js +208 -0
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/BigDecimal.js +175 -20
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/BigInt.js +54 -0
- package/dist/esm/BigInt.js.map +1 -1
- package/dist/esm/Boolean.js +24 -0
- package/dist/esm/Boolean.js.map +1 -1
- package/dist/esm/Brand.js +4 -0
- package/dist/esm/Brand.js.map +1 -1
- package/dist/esm/Channel.js +42 -2
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Chunk.js +8 -0
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Config.js +9 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +49 -0
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/Cron.js +81 -67
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/Data.js +16 -0
- package/dist/esm/Data.js.map +1 -1
- package/dist/esm/DateTime.js +176 -627
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Duration.js +2 -0
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js +297 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +40 -2
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/FiberHandle.js +6 -0
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +6 -0
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +6 -0
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/Function.js +34 -0
- package/dist/esm/Function.js.map +1 -1
- package/dist/esm/GlobalValue.js +2 -0
- package/dist/esm/GlobalValue.js.map +1 -1
- package/dist/esm/HashMap.js.map +1 -1
- package/dist/esm/Inspectable.js +8 -4
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/Iterable.js +18 -0
- package/dist/esm/Iterable.js.map +1 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/List.js +4 -0
- package/dist/esm/List.js.map +1 -1
- package/dist/esm/Logger.js +26 -0
- package/dist/esm/Logger.js.map +1 -1
- package/dist/esm/Mailbox.js +2 -0
- package/dist/esm/Mailbox.js.map +1 -1
- package/dist/esm/ManagedRuntime.js +2 -0
- package/dist/esm/ManagedRuntime.js.map +1 -1
- package/dist/esm/Metric.js +10 -0
- package/dist/esm/Metric.js.map +1 -1
- package/dist/esm/Micro.js +1077 -1037
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/Number.js +44 -0
- package/dist/esm/Number.js.map +1 -1
- package/dist/esm/Option.js +72 -0
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/Order.js +2 -0
- package/dist/esm/Order.js.map +1 -1
- package/dist/esm/Ordering.js +4 -0
- package/dist/esm/Ordering.js.map +1 -1
- package/dist/esm/Predicate.js +68 -0
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Random.js +4 -0
- package/dist/esm/Random.js.map +1 -1
- package/dist/esm/RateLimiter.js +4 -0
- package/dist/esm/RateLimiter.js.map +1 -1
- package/dist/esm/RcMap.js +2 -0
- package/dist/esm/RcMap.js.map +1 -1
- package/dist/esm/RcRef.js +2 -0
- package/dist/esm/RcRef.js.map +1 -1
- package/dist/esm/Record.js +56 -0
- package/dist/esm/Record.js.map +1 -1
- package/dist/esm/Redacted.js +8 -0
- package/dist/esm/Redacted.js.map +1 -1
- package/dist/esm/RegExp.js +4 -0
- package/dist/esm/RegExp.js.map +1 -1
- package/dist/esm/Request.js +4 -0
- package/dist/esm/Request.js.map +1 -1
- package/dist/esm/RequestResolver.js +2 -0
- package/dist/esm/RequestResolver.js.map +1 -1
- package/dist/esm/Runtime.js +6 -0
- package/dist/esm/Runtime.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schema.js +88 -0
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Sink.js +8 -0
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Stream.js +183 -5
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/String.js +62 -0
- package/dist/esm/String.js.map +1 -1
- package/dist/esm/Struct.js +12 -0
- package/dist/esm/Struct.js.map +1 -1
- package/dist/esm/Symbol.js +2 -0
- package/dist/esm/Symbol.js.map +1 -1
- package/dist/esm/Trie.js +56 -0
- package/dist/esm/Trie.js.map +1 -1
- package/dist/esm/Tuple.js +22 -0
- package/dist/esm/Tuple.js.map +1 -1
- package/dist/esm/Utils.js +5 -0
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/channel/channelExecutor.js +5 -7
- package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
- package/dist/esm/internal/channel.js +152 -129
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/config.js +11 -3
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/context.js +42 -2
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/dateTime.js +704 -0
- package/dist/esm/internal/dateTime.js.map +1 -0
- package/dist/esm/internal/fiberRuntime.js +31 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +9 -3
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/layer.js +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/mailbox.js +1 -1
- package/dist/esm/internal/mailbox.js.map +1 -1
- package/dist/esm/internal/sink.js +23 -20
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stream.js +66 -69
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +534 -0
- package/src/BigDecimal.ts +247 -21
- package/src/BigInt.ts +114 -0
- package/src/Boolean.ts +56 -0
- package/src/Brand.ts +6 -0
- package/src/Channel.ts +81 -5
- package/src/Chunk.ts +32 -0
- package/src/Config.ts +26 -1
- package/src/Context.ts +163 -0
- package/src/Cron.ts +91 -68
- package/src/Data.ts +26 -0
- package/src/DateTime.ts +307 -757
- package/src/Duration.ts +2 -0
- package/src/Effect.ts +910 -1
- package/src/Either.ts +84 -2
- package/src/FiberHandle.ts +6 -0
- package/src/FiberMap.ts +6 -0
- package/src/FiberSet.ts +6 -0
- package/src/Function.ts +50 -0
- package/src/GlobalValue.ts +2 -0
- package/src/HashMap.ts +6 -0
- package/src/Inspectable.ts +11 -7
- package/src/Iterable.ts +26 -0
- package/src/JSONSchema.ts +1 -0
- package/src/List.ts +24 -0
- package/src/Logger.ts +34 -0
- package/src/Mailbox.ts +2 -0
- package/src/ManagedRuntime.ts +2 -0
- package/src/Metric.ts +18 -0
- package/src/Micro.ts +2007 -1745
- package/src/Number.ts +104 -0
- package/src/Option.ts +142 -0
- package/src/Order.ts +2 -0
- package/src/Ordering.ts +8 -0
- package/src/Predicate.ts +104 -0
- package/src/Random.ts +4 -0
- package/src/RateLimiter.ts +4 -0
- package/src/RcMap.ts +6 -0
- package/src/RcRef.ts +2 -0
- package/src/Record.ts +136 -0
- package/src/Redacted.ts +8 -0
- package/src/RegExp.ts +4 -0
- package/src/Request.ts +4 -0
- package/src/RequestResolver.ts +6 -0
- package/src/Runtime.ts +18 -0
- package/src/STM.ts +2 -0
- package/src/Schema.ts +124 -0
- package/src/Sink.ts +11 -0
- package/src/Stream.ts +399 -44
- package/src/String.ts +94 -0
- package/src/Struct.ts +24 -0
- package/src/Symbol.ts +2 -0
- package/src/Trie.ts +132 -0
- package/src/Tuple.ts +42 -0
- package/src/Types.ts +24 -0
- package/src/Utils.ts +8 -0
- package/src/internal/channel/channelExecutor.ts +37 -33
- package/src/internal/channel.ts +504 -467
- package/src/internal/config.ts +18 -6
- package/src/internal/context.ts +56 -4
- package/src/internal/dateTime.ts +1126 -0
- package/src/internal/fiberRuntime.ts +35 -16
- package/src/internal/groupBy.ts +13 -22
- package/src/internal/layer.ts +5 -8
- package/src/internal/mailbox.ts +6 -4
- package/src/internal/sink.ts +55 -35
- package/src/internal/stream.ts +299 -299
- package/src/internal/version.ts +1 -1
package/dist/esm/Array.js
CHANGED
|
@@ -19,10 +19,12 @@ import * as Tuple from "./Tuple.js";
|
|
|
19
19
|
* Builds a `NonEmptyArray` from an non-empty collection of elements.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
|
+
* ```ts
|
|
22
23
|
* import { Array } from "effect"
|
|
23
24
|
*
|
|
24
25
|
* const result = Array.make(1, 2, 3)
|
|
25
26
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
27
|
+
* ```
|
|
26
28
|
*
|
|
27
29
|
* @category constructors
|
|
28
30
|
* @since 2.0.0
|
|
@@ -32,10 +34,12 @@ export const make = (...elements) => elements;
|
|
|
32
34
|
* Creates a new `Array` of the specified length.
|
|
33
35
|
*
|
|
34
36
|
* @example
|
|
37
|
+
* ```ts
|
|
35
38
|
* import { Array } from "effect"
|
|
36
39
|
*
|
|
37
40
|
* const result = Array.allocate<number>(3)
|
|
38
41
|
* assert.deepStrictEqual(result.length, 3)
|
|
42
|
+
* ```
|
|
39
43
|
*
|
|
40
44
|
* @category constructors
|
|
41
45
|
* @since 2.0.0
|
|
@@ -47,9 +51,11 @@ export const allocate = n => new Array(n);
|
|
|
47
51
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
48
52
|
*
|
|
49
53
|
* @example
|
|
54
|
+
* ```ts
|
|
50
55
|
* import { makeBy } from "effect/Array"
|
|
51
56
|
*
|
|
52
57
|
* assert.deepStrictEqual(makeBy(5, n => n * 2), [0, 2, 4, 6, 8])
|
|
58
|
+
* ```
|
|
53
59
|
*
|
|
54
60
|
* @category constructors
|
|
55
61
|
* @since 2.0.0
|
|
@@ -66,9 +72,11 @@ export const makeBy = (n, f) => {
|
|
|
66
72
|
* Return a `NonEmptyArray` containing a range of integers, including both endpoints.
|
|
67
73
|
*
|
|
68
74
|
* @example
|
|
75
|
+
* ```ts
|
|
69
76
|
* import { range } from "effect/Array"
|
|
70
77
|
*
|
|
71
78
|
* assert.deepStrictEqual(range(1, 3), [1, 2, 3])
|
|
79
|
+
* ```
|
|
72
80
|
*
|
|
73
81
|
* @category constructors
|
|
74
82
|
* @since 2.0.0
|
|
@@ -80,9 +88,11 @@ export const range = (start, end) => start <= end ? makeBy(end - start + 1, i =>
|
|
|
80
88
|
* **Note**. `n` is normalized to an integer >= 1.
|
|
81
89
|
*
|
|
82
90
|
* @example
|
|
91
|
+
* ```ts
|
|
83
92
|
* import { Array } from "effect"
|
|
84
93
|
*
|
|
85
94
|
* assert.deepStrictEqual(Array.replicate("a", 3), ["a", "a", "a"])
|
|
95
|
+
* ```
|
|
86
96
|
*
|
|
87
97
|
* @category constructors
|
|
88
98
|
* @since 2.0.0
|
|
@@ -94,11 +104,13 @@ export const replicate = /*#__PURE__*/dual(2, (a, n) => makeBy(n, () => a));
|
|
|
94
104
|
* Otherwise, it converts the iterable collection to an array.
|
|
95
105
|
*
|
|
96
106
|
* @example
|
|
107
|
+
* ```ts
|
|
97
108
|
* import { Array } from "effect"
|
|
98
109
|
*
|
|
99
110
|
* const set = new Set([1, 2, 3])
|
|
100
111
|
* const result = Array.fromIterable(set)
|
|
101
112
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
113
|
+
* ```
|
|
102
114
|
*
|
|
103
115
|
* @category constructors
|
|
104
116
|
* @since 2.0.0
|
|
@@ -108,11 +120,13 @@ export const fromIterable = collection => Array.isArray(collection) ? collection
|
|
|
108
120
|
* Creates a new `Array` from a value that might not be an iterable.
|
|
109
121
|
*
|
|
110
122
|
* @example
|
|
123
|
+
* ```ts
|
|
111
124
|
* import { Array } from "effect"
|
|
112
125
|
*
|
|
113
126
|
* assert.deepStrictEqual(Array.ensure("a"), ["a"])
|
|
114
127
|
* assert.deepStrictEqual(Array.ensure(["a"]), ["a"])
|
|
115
128
|
* assert.deepStrictEqual(Array.ensure(["a", "b", "c"]), ["a", "b", "c"])
|
|
129
|
+
* ```
|
|
116
130
|
*
|
|
117
131
|
* @category constructors
|
|
118
132
|
* @since 3.3.0
|
|
@@ -124,10 +138,12 @@ export const ensure = self => Array.isArray(self) ? self : [self];
|
|
|
124
138
|
* @param self - The record to transform.
|
|
125
139
|
*
|
|
126
140
|
* @example
|
|
141
|
+
* ```ts
|
|
127
142
|
* import { Array } from "effect"
|
|
128
143
|
*
|
|
129
144
|
* const x = { a: 1, b: 2, c: 3 }
|
|
130
145
|
* assert.deepStrictEqual(Array.fromRecord(x), [["a", 1], ["b", 2], ["c", 3]])
|
|
146
|
+
* ```
|
|
131
147
|
*
|
|
132
148
|
* @category conversions
|
|
133
149
|
* @since 2.0.0
|
|
@@ -137,10 +153,12 @@ export const fromRecord = Record.toEntries;
|
|
|
137
153
|
* Converts an `Option` to an array.
|
|
138
154
|
*
|
|
139
155
|
* @example
|
|
156
|
+
* ```ts
|
|
140
157
|
* import { Array, Option } from "effect"
|
|
141
158
|
*
|
|
142
159
|
* assert.deepStrictEqual(Array.fromOption(Option.some(1)), [1])
|
|
143
160
|
* assert.deepStrictEqual(Array.fromOption(Option.none()), [])
|
|
161
|
+
* ```
|
|
144
162
|
*
|
|
145
163
|
* @category conversions
|
|
146
164
|
* @since 2.0.0
|
|
@@ -150,6 +168,7 @@ export const fromOption = O.toArray;
|
|
|
150
168
|
* Matches the elements of an array, applying functions to cases of empty and non-empty arrays.
|
|
151
169
|
*
|
|
152
170
|
* @example
|
|
171
|
+
* ```ts
|
|
153
172
|
* import { Array } from "effect"
|
|
154
173
|
*
|
|
155
174
|
* const match = Array.match({
|
|
@@ -158,6 +177,7 @@ export const fromOption = O.toArray;
|
|
|
158
177
|
* })
|
|
159
178
|
* assert.deepStrictEqual(match([]), "empty")
|
|
160
179
|
* assert.deepStrictEqual(match([1, 2, 3]), "head: 1, tail: 2")
|
|
180
|
+
* ```
|
|
161
181
|
*
|
|
162
182
|
* @category pattern matching
|
|
163
183
|
* @since 2.0.0
|
|
@@ -170,6 +190,7 @@ export const match = /*#__PURE__*/dual(2, (self, {
|
|
|
170
190
|
* Matches the elements of an array from the left, applying functions to cases of empty and non-empty arrays.
|
|
171
191
|
*
|
|
172
192
|
* @example
|
|
193
|
+
* ```ts
|
|
173
194
|
* import { Array } from "effect"
|
|
174
195
|
*
|
|
175
196
|
* const matchLeft = Array.matchLeft({
|
|
@@ -178,6 +199,7 @@ export const match = /*#__PURE__*/dual(2, (self, {
|
|
|
178
199
|
* })
|
|
179
200
|
* assert.deepStrictEqual(matchLeft([]), "empty")
|
|
180
201
|
* assert.deepStrictEqual(matchLeft([1, 2, 3]), "head: 1, tail: 2")
|
|
202
|
+
* ```
|
|
181
203
|
*
|
|
182
204
|
* @category pattern matching
|
|
183
205
|
* @since 2.0.0
|
|
@@ -190,6 +212,7 @@ export const matchLeft = /*#__PURE__*/dual(2, (self, {
|
|
|
190
212
|
* Matches the elements of an array from the right, applying functions to cases of empty and non-empty arrays.
|
|
191
213
|
*
|
|
192
214
|
* @example
|
|
215
|
+
* ```ts
|
|
193
216
|
* import { Array } from "effect"
|
|
194
217
|
*
|
|
195
218
|
* const matchRight = Array.matchRight({
|
|
@@ -198,6 +221,7 @@ export const matchLeft = /*#__PURE__*/dual(2, (self, {
|
|
|
198
221
|
* })
|
|
199
222
|
* assert.deepStrictEqual(matchRight([]), "empty")
|
|
200
223
|
* assert.deepStrictEqual(matchRight([1, 2, 3]), "init: 2, last: 3")
|
|
224
|
+
* ```
|
|
201
225
|
*
|
|
202
226
|
* @category pattern matching
|
|
203
227
|
* @since 2.0.0
|
|
@@ -210,11 +234,13 @@ export const matchRight = /*#__PURE__*/dual(2, (self, {
|
|
|
210
234
|
* Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.
|
|
211
235
|
*
|
|
212
236
|
* @example
|
|
237
|
+
* ```ts
|
|
213
238
|
* import { Array } from "effect"
|
|
214
239
|
*
|
|
215
240
|
* const original = [2, 3, 4];
|
|
216
241
|
* const result = Array.prepend(original, 1);
|
|
217
242
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
243
|
+
* ```
|
|
218
244
|
*
|
|
219
245
|
* @category concatenating
|
|
220
246
|
* @since 2.0.0
|
|
@@ -225,12 +251,14 @@ export const prepend = /*#__PURE__*/dual(2, (self, head) => [head, ...self]);
|
|
|
225
251
|
* If either array is non-empty, the result is also a non-empty array.
|
|
226
252
|
*
|
|
227
253
|
* @example
|
|
254
|
+
* ```ts
|
|
228
255
|
* import { Array } from "effect"
|
|
229
256
|
*
|
|
230
257
|
* const prefix = [0, 1];
|
|
231
258
|
* const array = [2, 3];
|
|
232
259
|
* const result = Array.prependAll(array, prefix);
|
|
233
260
|
* assert.deepStrictEqual(result, [0, 1, 2, 3]);
|
|
261
|
+
* ```
|
|
234
262
|
*
|
|
235
263
|
* @category concatenating
|
|
236
264
|
* @since 2.0.0
|
|
@@ -240,11 +268,13 @@ export const prependAll = /*#__PURE__*/dual(2, (self, that) => fromIterable(that
|
|
|
240
268
|
* Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.
|
|
241
269
|
*
|
|
242
270
|
* @example
|
|
271
|
+
* ```ts
|
|
243
272
|
* import { Array } from "effect"
|
|
244
273
|
*
|
|
245
274
|
* const original = [1, 2, 3];
|
|
246
275
|
* const result = Array.append(original, 4);
|
|
247
276
|
* assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
277
|
+
* ```
|
|
248
278
|
*
|
|
249
279
|
* @category concatenating
|
|
250
280
|
* @since 2.0.0
|
|
@@ -264,6 +294,7 @@ export const appendAll = /*#__PURE__*/dual(2, (self, that) => fromIterable(self)
|
|
|
264
294
|
* a value through a series of transformations.
|
|
265
295
|
*
|
|
266
296
|
* @example
|
|
297
|
+
* ```ts
|
|
267
298
|
* import { Array } from "effect";
|
|
268
299
|
*
|
|
269
300
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -275,6 +306,7 @@ export const appendAll = /*#__PURE__*/dual(2, (self, that) => fromIterable(self)
|
|
|
275
306
|
* // and adds each element of the array to this accumulator one by one,
|
|
276
307
|
* // keeping track of the cumulative sum after each addition.
|
|
277
308
|
* // Each of these sums is captured in the resulting array.
|
|
309
|
+
* ```
|
|
278
310
|
*
|
|
279
311
|
* @category folding
|
|
280
312
|
* @since 2.0.0
|
|
@@ -294,11 +326,13 @@ export const scan = /*#__PURE__*/dual(3, (self, b, f) => {
|
|
|
294
326
|
* a value through a series of transformations.
|
|
295
327
|
*
|
|
296
328
|
* @example
|
|
329
|
+
* ```ts
|
|
297
330
|
* import { Array } from "effect";
|
|
298
331
|
*
|
|
299
332
|
* const numbers = [1, 2, 3, 4]
|
|
300
333
|
* const result = Array.scanRight(numbers, 0, (acc, value) => acc + value)
|
|
301
334
|
* assert.deepStrictEqual(result, [10, 9, 7, 4, 0])
|
|
335
|
+
* ```
|
|
302
336
|
*
|
|
303
337
|
* @category folding
|
|
304
338
|
* @since 2.0.0
|
|
@@ -318,10 +352,12 @@ export const scanRight = /*#__PURE__*/dual(3, (self, b, f) => {
|
|
|
318
352
|
* @param self - The value to check.
|
|
319
353
|
*
|
|
320
354
|
* @example
|
|
355
|
+
* ```ts
|
|
321
356
|
* import { isArray } from "effect/Array"
|
|
322
357
|
*
|
|
323
358
|
* assert.deepStrictEqual(isArray(null), false);
|
|
324
359
|
* assert.deepStrictEqual(isArray([1, 2, 3]), true);
|
|
360
|
+
* ```
|
|
325
361
|
*
|
|
326
362
|
* @category guards
|
|
327
363
|
* @since 2.0.0
|
|
@@ -333,10 +369,12 @@ export const isArray = Array.isArray;
|
|
|
333
369
|
* @param self - The `Array` to check.
|
|
334
370
|
*
|
|
335
371
|
* @example
|
|
372
|
+
* ```ts
|
|
336
373
|
* import { isEmptyArray } from "effect/Array"
|
|
337
374
|
*
|
|
338
375
|
* assert.deepStrictEqual(isEmptyArray([]), true);
|
|
339
376
|
* assert.deepStrictEqual(isEmptyArray([1, 2, 3]), false);
|
|
377
|
+
* ```
|
|
340
378
|
*
|
|
341
379
|
* @category guards
|
|
342
380
|
* @since 2.0.0
|
|
@@ -348,10 +386,12 @@ export const isEmptyArray = self => self.length === 0;
|
|
|
348
386
|
* @param self - The `ReadonlyArray` to check.
|
|
349
387
|
*
|
|
350
388
|
* @example
|
|
389
|
+
* ```ts
|
|
351
390
|
* import { isEmptyReadonlyArray } from "effect/Array"
|
|
352
391
|
*
|
|
353
392
|
* assert.deepStrictEqual(isEmptyReadonlyArray([]), true);
|
|
354
393
|
* assert.deepStrictEqual(isEmptyReadonlyArray([1, 2, 3]), false);
|
|
394
|
+
* ```
|
|
355
395
|
*
|
|
356
396
|
* @category guards
|
|
357
397
|
* @since 2.0.0
|
|
@@ -365,10 +405,12 @@ export const isEmptyReadonlyArray = isEmptyArray;
|
|
|
365
405
|
* @param self - The `Array` to check.
|
|
366
406
|
*
|
|
367
407
|
* @example
|
|
408
|
+
* ```ts
|
|
368
409
|
* import { isNonEmptyArray } from "effect/Array"
|
|
369
410
|
*
|
|
370
411
|
* assert.deepStrictEqual(isNonEmptyArray([]), false);
|
|
371
412
|
* assert.deepStrictEqual(isNonEmptyArray([1, 2, 3]), true);
|
|
413
|
+
* ```
|
|
372
414
|
*
|
|
373
415
|
* @category guards
|
|
374
416
|
* @since 2.0.0
|
|
@@ -382,10 +424,12 @@ export const isNonEmptyArray = readonlyArray.isNonEmptyArray;
|
|
|
382
424
|
* @param self - The `ReadonlyArray` to check.
|
|
383
425
|
*
|
|
384
426
|
* @example
|
|
427
|
+
* ```ts
|
|
385
428
|
* import { isNonEmptyReadonlyArray } from "effect/Array"
|
|
386
429
|
*
|
|
387
430
|
* assert.deepStrictEqual(isNonEmptyReadonlyArray([]), false);
|
|
388
431
|
* assert.deepStrictEqual(isNonEmptyReadonlyArray([1, 2, 3]), true);
|
|
432
|
+
* ```
|
|
389
433
|
*
|
|
390
434
|
* @category guards
|
|
391
435
|
* @since 2.0.0
|
|
@@ -427,10 +471,12 @@ export const unsafeGet = /*#__PURE__*/dual(2, (self, index) => {
|
|
|
427
471
|
* Return a tuple containing the first element, and a new `Array` of the remaining elements, if any.
|
|
428
472
|
*
|
|
429
473
|
* @example
|
|
474
|
+
* ```ts
|
|
430
475
|
* import { Array } from "effect";
|
|
431
476
|
*
|
|
432
477
|
* const result = Array.unprepend([1, 2, 3, 4])
|
|
433
478
|
* assert.deepStrictEqual(result, [1, [2, 3, 4]])
|
|
479
|
+
* ```
|
|
434
480
|
*
|
|
435
481
|
* @category splitting
|
|
436
482
|
* @since 2.0.0
|
|
@@ -440,10 +486,12 @@ export const unprepend = self => [headNonEmpty(self), tailNonEmpty(self)];
|
|
|
440
486
|
* Return a tuple containing a copy of the `NonEmptyReadonlyArray` without its last element, and that last element.
|
|
441
487
|
*
|
|
442
488
|
* @example
|
|
489
|
+
* ```ts
|
|
443
490
|
* import { Array } from "effect";
|
|
444
491
|
*
|
|
445
492
|
* const result = Array.unappend([1, 2, 3, 4])
|
|
446
493
|
* assert.deepStrictEqual(result, [[1, 2, 3], 4])
|
|
494
|
+
* ```
|
|
447
495
|
*
|
|
448
496
|
* @category splitting
|
|
449
497
|
* @since 2.0.0
|
|
@@ -460,10 +508,12 @@ export const head = /*#__PURE__*/get(0);
|
|
|
460
508
|
* Get the first element of a non empty array.
|
|
461
509
|
*
|
|
462
510
|
* @example
|
|
511
|
+
* ```ts
|
|
463
512
|
* import { Array } from "effect"
|
|
464
513
|
*
|
|
465
514
|
* const result = Array.headNonEmpty([1, 2, 3, 4])
|
|
466
515
|
* assert.deepStrictEqual(result, 1)
|
|
516
|
+
* ```
|
|
467
517
|
*
|
|
468
518
|
* @category getters
|
|
469
519
|
* @since 2.0.0
|
|
@@ -480,10 +530,12 @@ export const last = self => isNonEmptyReadonlyArray(self) ? O.some(lastNonEmpty(
|
|
|
480
530
|
* Get the last element of a non empty array.
|
|
481
531
|
*
|
|
482
532
|
* @example
|
|
533
|
+
* ```ts
|
|
483
534
|
* import { Array } from "effect"
|
|
484
535
|
*
|
|
485
536
|
* const result = Array.lastNonEmpty([1, 2, 3, 4])
|
|
486
537
|
* assert.deepStrictEqual(result, 4)
|
|
538
|
+
* ```
|
|
487
539
|
*
|
|
488
540
|
* @category getters
|
|
489
541
|
* @since 2.0.0
|
|
@@ -503,10 +555,12 @@ export const tail = self => {
|
|
|
503
555
|
* Get all but the first element of a `NonEmptyReadonlyArray`.
|
|
504
556
|
*
|
|
505
557
|
* @example
|
|
558
|
+
* ```ts
|
|
506
559
|
* import { Array } from "effect"
|
|
507
560
|
*
|
|
508
561
|
* const result = Array.tailNonEmpty([1, 2, 3, 4])
|
|
509
562
|
* assert.deepStrictEqual(result, [2, 3, 4])
|
|
563
|
+
* ```
|
|
510
564
|
*
|
|
511
565
|
* @category getters
|
|
512
566
|
* @since 2.0.0
|
|
@@ -526,10 +580,12 @@ export const init = self => {
|
|
|
526
580
|
* Get all but the last element of a non empty array, creating a new array.
|
|
527
581
|
*
|
|
528
582
|
* @example
|
|
583
|
+
* ```ts
|
|
529
584
|
* import { Array } from "effect"
|
|
530
585
|
*
|
|
531
586
|
* const result = Array.initNonEmpty([1, 2, 3, 4])
|
|
532
587
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
588
|
+
* ```
|
|
533
589
|
*
|
|
534
590
|
* @category getters
|
|
535
591
|
* @since 2.0.0
|
|
@@ -541,11 +597,13 @@ export const initNonEmpty = self => self.slice(0, -1);
|
|
|
541
597
|
* **Note**. `n` is normalized to a non negative integer.
|
|
542
598
|
*
|
|
543
599
|
* @example
|
|
600
|
+
* ```ts
|
|
544
601
|
* import { Array } from "effect"
|
|
545
602
|
*
|
|
546
603
|
* const numbers = [1, 2, 3, 4, 5]
|
|
547
604
|
* const result = Array.take(numbers, 3)
|
|
548
605
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
606
|
+
* ```
|
|
549
607
|
*
|
|
550
608
|
* @category getters
|
|
551
609
|
* @since 2.0.0
|
|
@@ -560,11 +618,13 @@ export const take = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
560
618
|
* **Note**. `n` is normalized to a non negative integer.
|
|
561
619
|
*
|
|
562
620
|
* @example
|
|
621
|
+
* ```ts
|
|
563
622
|
* import { Array } from "effect"
|
|
564
623
|
*
|
|
565
624
|
* const numbers = [1, 2, 3, 4, 5]
|
|
566
625
|
* const result = Array.takeRight(numbers, 3)
|
|
567
626
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
627
|
+
* ```
|
|
568
628
|
*
|
|
569
629
|
* @category getters
|
|
570
630
|
* @since 2.0.0
|
|
@@ -578,6 +638,7 @@ export const takeRight = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
578
638
|
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
579
639
|
*
|
|
580
640
|
* @example
|
|
641
|
+
* ```ts
|
|
581
642
|
* import { Array } from "effect"
|
|
582
643
|
*
|
|
583
644
|
* const numbers = [1, 3, 2, 4, 1, 2]
|
|
@@ -589,6 +650,7 @@ export const takeRight = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
589
650
|
* // - The next element (`3`) is also less than `4`, so it adds `3`.
|
|
590
651
|
* // - The next element (`2`) is again less than `4`, so it adds `2`.
|
|
591
652
|
* // - The function then encounters `4`, which is not less than `4`. At this point, it stops checking further elements and finalizes the result.
|
|
653
|
+
* ```
|
|
592
654
|
*
|
|
593
655
|
* @category getters
|
|
594
656
|
* @since 2.0.0
|
|
@@ -631,11 +693,13 @@ export const span = /*#__PURE__*/dual(2, (self, predicate) => splitAt(self, span
|
|
|
631
693
|
* **Note**. `n` is normalized to a non negative integer.
|
|
632
694
|
*
|
|
633
695
|
* @example
|
|
696
|
+
* ```ts
|
|
634
697
|
* import { Array } from "effect"
|
|
635
698
|
*
|
|
636
699
|
* const numbers = [1, 2, 3, 4, 5]
|
|
637
700
|
* const result = Array.drop(numbers, 2)
|
|
638
701
|
* assert.deepStrictEqual(result, [3, 4, 5])
|
|
702
|
+
* ```
|
|
639
703
|
*
|
|
640
704
|
* @category getters
|
|
641
705
|
* @since 2.0.0
|
|
@@ -650,11 +714,13 @@ export const drop = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
650
714
|
* **Note**. `n` is normalized to a non negative integer.
|
|
651
715
|
*
|
|
652
716
|
* @example
|
|
717
|
+
* ```ts
|
|
653
718
|
* import { Array } from "effect"
|
|
654
719
|
*
|
|
655
720
|
* const numbers = [1, 2, 3, 4, 5]
|
|
656
721
|
* const result = Array.dropRight(numbers, 2)
|
|
657
722
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
723
|
+
* ```
|
|
658
724
|
*
|
|
659
725
|
* @category getters
|
|
660
726
|
* @since 2.0.0
|
|
@@ -667,11 +733,13 @@ export const dropRight = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
667
733
|
* Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.
|
|
668
734
|
*
|
|
669
735
|
* @example
|
|
736
|
+
* ```ts
|
|
670
737
|
* import { Array } from "effect"
|
|
671
738
|
*
|
|
672
739
|
* const numbers = [1, 2, 3, 4, 5]
|
|
673
740
|
* const result = Array.dropWhile(numbers, x => x < 4)
|
|
674
741
|
* assert.deepStrictEqual(result, [4, 5])
|
|
742
|
+
* ```
|
|
675
743
|
*
|
|
676
744
|
* @category getters
|
|
677
745
|
* @since 2.0.0
|
|
@@ -681,11 +749,13 @@ export const dropWhile = /*#__PURE__*/dual(2, (self, predicate) => fromIterable(
|
|
|
681
749
|
* Return the first index for which a predicate holds.
|
|
682
750
|
*
|
|
683
751
|
* @example
|
|
752
|
+
* ```ts
|
|
684
753
|
* import { Array, Option } from "effect"
|
|
685
754
|
*
|
|
686
755
|
* const numbers = [5, 3, 8, 9]
|
|
687
756
|
* const result = Array.findFirstIndex(numbers, x => x > 5)
|
|
688
757
|
* assert.deepStrictEqual(result, Option.some(2))
|
|
758
|
+
* ```
|
|
689
759
|
*
|
|
690
760
|
* @category elements
|
|
691
761
|
* @since 2.0.0
|
|
@@ -704,11 +774,13 @@ export const findFirstIndex = /*#__PURE__*/dual(2, (self, predicate) => {
|
|
|
704
774
|
* Return the last index for which a predicate holds.
|
|
705
775
|
*
|
|
706
776
|
* @example
|
|
777
|
+
* ```ts
|
|
707
778
|
* import { Array, Option } from "effect"
|
|
708
779
|
*
|
|
709
780
|
* const numbers = [1, 3, 8, 9]
|
|
710
781
|
* const result = Array.findLastIndex(numbers, x => x < 5)
|
|
711
782
|
* assert.deepStrictEqual(result, Option.some(1))
|
|
783
|
+
* ```
|
|
712
784
|
*
|
|
713
785
|
* @category elements
|
|
714
786
|
* @since 2.0.0
|
|
@@ -727,11 +799,13 @@ export const findLastIndex = /*#__PURE__*/dual(2, (self, predicate) => {
|
|
|
727
799
|
* predicate, or `None` if no such element exists.
|
|
728
800
|
*
|
|
729
801
|
* @example
|
|
802
|
+
* ```ts
|
|
730
803
|
* import { Array, Option } from "effect"
|
|
731
804
|
*
|
|
732
805
|
* const numbers = [1, 2, 3, 4, 5]
|
|
733
806
|
* const result = Array.findFirst(numbers, x => x > 3)
|
|
734
807
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
808
|
+
* ```
|
|
735
809
|
*
|
|
736
810
|
* @category elements
|
|
737
811
|
* @since 2.0.0
|
|
@@ -742,11 +816,13 @@ export const findFirst = EffectIterable.findFirst;
|
|
|
742
816
|
* Returns an `Option` containing the found element, or `Option.none` if no element matches.
|
|
743
817
|
*
|
|
744
818
|
* @example
|
|
819
|
+
* ```ts
|
|
745
820
|
* import { Array, Option } from "effect"
|
|
746
821
|
*
|
|
747
822
|
* const numbers = [1, 2, 3, 4, 5]
|
|
748
823
|
* const result = Array.findLast(numbers, n => n % 2 === 0)
|
|
749
824
|
* assert.deepStrictEqual(result, Option.some(4))
|
|
825
|
+
* ```
|
|
750
826
|
*
|
|
751
827
|
* @category elements
|
|
752
828
|
* @since 2.0.0
|
|
@@ -773,11 +849,13 @@ export const findLast = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
773
849
|
* or return `None` if the index is out of bounds.
|
|
774
850
|
*
|
|
775
851
|
* @example
|
|
852
|
+
* ```ts
|
|
776
853
|
* import { Array, Option } from "effect"
|
|
777
854
|
*
|
|
778
855
|
* const letters = ['a', 'b', 'c', 'e']
|
|
779
856
|
* const result = Array.insertAt(letters, 3, 'd')
|
|
780
857
|
* assert.deepStrictEqual(result, Option.some(['a', 'b', 'c', 'd', 'e']))
|
|
858
|
+
* ```
|
|
781
859
|
*
|
|
782
860
|
* @since 2.0.0
|
|
783
861
|
*/
|
|
@@ -795,11 +873,13 @@ export const insertAt = /*#__PURE__*/dual(3, (self, i, b) => {
|
|
|
795
873
|
* or return a copy of the input if the index is out of bounds.
|
|
796
874
|
*
|
|
797
875
|
* @example
|
|
876
|
+
* ```ts
|
|
798
877
|
* import { Array } from "effect"
|
|
799
878
|
*
|
|
800
879
|
* const letters = ['a', 'b', 'c', 'd']
|
|
801
880
|
* const result = Array.replace(letters, 1, 'z')
|
|
802
881
|
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
|
|
882
|
+
* ```
|
|
803
883
|
*
|
|
804
884
|
* @since 2.0.0
|
|
805
885
|
*/
|
|
@@ -808,11 +888,13 @@ export const replace = /*#__PURE__*/dual(3, (self, i, b) => modify(self, i, () =
|
|
|
808
888
|
* Replaces an element in an array with the given value, returning an option of the updated array.
|
|
809
889
|
*
|
|
810
890
|
* @example
|
|
891
|
+
* ```ts
|
|
811
892
|
* import { Array, Option } from "effect"
|
|
812
893
|
*
|
|
813
894
|
* const numbers = [1, 2, 3]
|
|
814
895
|
* const result = Array.replaceOption(numbers, 1, 4)
|
|
815
896
|
* assert.deepStrictEqual(result, Option.some([1, 4, 3]))
|
|
897
|
+
* ```
|
|
816
898
|
*
|
|
817
899
|
* @since 2.0.0
|
|
818
900
|
*/
|
|
@@ -822,11 +904,13 @@ export const replaceOption = /*#__PURE__*/dual(3, (self, i, b) => modifyOption(s
|
|
|
822
904
|
* or return a copy of the input if the index is out of bounds.
|
|
823
905
|
*
|
|
824
906
|
* @example
|
|
907
|
+
* ```ts
|
|
825
908
|
* import { Array } from "effect"
|
|
826
909
|
*
|
|
827
910
|
* const numbers = [1, 2, 3, 4]
|
|
828
911
|
* const result = Array.modify(numbers, 2, (n) => n * 2)
|
|
829
912
|
* assert.deepStrictEqual(result, [1, 2, 6, 4])
|
|
913
|
+
* ```
|
|
830
914
|
*
|
|
831
915
|
* @since 2.0.0
|
|
832
916
|
*/
|
|
@@ -836,6 +920,7 @@ export const modify = /*#__PURE__*/dual(3, (self, i, f) => O.getOrElse(modifyOpt
|
|
|
836
920
|
* or return `None` if the index is out of bounds.
|
|
837
921
|
*
|
|
838
922
|
* @example
|
|
923
|
+
* ```ts
|
|
839
924
|
* import { Array, Option } from "effect"
|
|
840
925
|
*
|
|
841
926
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -844,6 +929,7 @@ export const modify = /*#__PURE__*/dual(3, (self, i, f) => O.getOrElse(modifyOpt
|
|
|
844
929
|
*
|
|
845
930
|
* const outOfBoundsResult = Array.modifyOption(numbers, 5, (n) => n * 2)
|
|
846
931
|
* assert.deepStrictEqual(outOfBoundsResult, Option.none())
|
|
932
|
+
* ```
|
|
847
933
|
*
|
|
848
934
|
* @since 2.0.0
|
|
849
935
|
*/
|
|
@@ -862,6 +948,7 @@ export const modifyOption = /*#__PURE__*/dual(3, (self, i, f) => {
|
|
|
862
948
|
* or return a copy of the input if the index is out of bounds.
|
|
863
949
|
*
|
|
864
950
|
* @example
|
|
951
|
+
* ```ts
|
|
865
952
|
* import { Array } from "effect"
|
|
866
953
|
*
|
|
867
954
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -870,6 +957,7 @@ export const modifyOption = /*#__PURE__*/dual(3, (self, i, f) => {
|
|
|
870
957
|
*
|
|
871
958
|
* const outOfBoundsResult = Array.remove(numbers, 5)
|
|
872
959
|
* assert.deepStrictEqual(outOfBoundsResult, [1, 2, 3, 4])
|
|
960
|
+
* ```
|
|
873
961
|
*
|
|
874
962
|
* @since 2.0.0
|
|
875
963
|
*/
|
|
@@ -885,11 +973,13 @@ export const remove = /*#__PURE__*/dual(2, (self, i) => {
|
|
|
885
973
|
* Reverse an `Iterable`, creating a new `Array`.
|
|
886
974
|
*
|
|
887
975
|
* @example
|
|
976
|
+
* ```ts
|
|
888
977
|
* import { Array } from "effect"
|
|
889
978
|
*
|
|
890
979
|
* const numbers = [1, 2, 3, 4]
|
|
891
980
|
* const result = Array.reverse(numbers)
|
|
892
981
|
* assert.deepStrictEqual(result, [4, 3, 2, 1])
|
|
982
|
+
* ```
|
|
893
983
|
*
|
|
894
984
|
* @category elements
|
|
895
985
|
* @since 2.0.0
|
|
@@ -913,6 +1003,7 @@ export const sort = /*#__PURE__*/dual(2, (self, O) => {
|
|
|
913
1003
|
* order defines how those values should be sorted.
|
|
914
1004
|
*
|
|
915
1005
|
* @example
|
|
1006
|
+
* ```ts
|
|
916
1007
|
* import { Array, Order } from "effect"
|
|
917
1008
|
*
|
|
918
1009
|
* const strings = ["aaa", "b", "cc"]
|
|
@@ -923,6 +1014,7 @@ export const sort = /*#__PURE__*/dual(2, (self, O) => {
|
|
|
923
1014
|
* // The array of strings is sorted based on their lengths. The mapping function `(s) => s.length`
|
|
924
1015
|
* // converts each string into its length, and the `Order.number` specifies that the lengths should
|
|
925
1016
|
* // be sorted in ascending order.
|
|
1017
|
+
* ```
|
|
926
1018
|
*
|
|
927
1019
|
* @since 2.0.0
|
|
928
1020
|
* @category elements
|
|
@@ -934,6 +1026,7 @@ export const sortWith = /*#__PURE__*/dual(3, (self, f, order) => Array.from(self
|
|
|
934
1026
|
* second order if the first comparison is equal, and so on.
|
|
935
1027
|
*
|
|
936
1028
|
* @example
|
|
1029
|
+
* ```ts
|
|
937
1030
|
* import { Array, Order } from "effect"
|
|
938
1031
|
*
|
|
939
1032
|
* const users = [
|
|
@@ -956,6 +1049,7 @@ export const sortWith = /*#__PURE__*/dual(3, (self, f, order) => Array.from(self
|
|
|
956
1049
|
* // Explanation:
|
|
957
1050
|
* // The array of users is sorted first by age in ascending order. When ages are equal,
|
|
958
1051
|
* // the users are further sorted by name in ascending order.
|
|
1052
|
+
* ```
|
|
959
1053
|
*
|
|
960
1054
|
* @category sorting
|
|
961
1055
|
* @since 2.0.0
|
|
@@ -976,12 +1070,14 @@ export const sortBy = (...orders) => {
|
|
|
976
1070
|
* longer `Iterable` are discarded.
|
|
977
1071
|
*
|
|
978
1072
|
* @example
|
|
1073
|
+
* ```ts
|
|
979
1074
|
* import { Array } from "effect"
|
|
980
1075
|
*
|
|
981
1076
|
* const array1 = [1, 2, 3]
|
|
982
1077
|
* const array2 = ['a', 'b']
|
|
983
1078
|
* const result = Array.zip(array1, array2)
|
|
984
1079
|
* assert.deepStrictEqual(result, [[1, 'a'], [2, 'b']])
|
|
1080
|
+
* ```
|
|
985
1081
|
*
|
|
986
1082
|
* @category zipping
|
|
987
1083
|
* @since 2.0.0
|
|
@@ -992,12 +1088,14 @@ export const zip = /*#__PURE__*/dual(2, (self, that) => zipWith(self, that, Tupl
|
|
|
992
1088
|
* input `Iterable` is short, excess elements of the longer `Iterable` are discarded.
|
|
993
1089
|
*
|
|
994
1090
|
* @example
|
|
1091
|
+
* ```ts
|
|
995
1092
|
* import { Array } from "effect"
|
|
996
1093
|
*
|
|
997
1094
|
* const array1 = [1, 2, 3]
|
|
998
1095
|
* const array2 = [4, 5, 6]
|
|
999
1096
|
* const result = Array.zipWith(array1, array2, (a, b) => a + b)
|
|
1000
1097
|
* assert.deepStrictEqual(result, [5, 7, 9])
|
|
1098
|
+
* ```
|
|
1001
1099
|
*
|
|
1002
1100
|
* @category zipping
|
|
1003
1101
|
* @since 2.0.0
|
|
@@ -1019,10 +1117,12 @@ export const zipWith = /*#__PURE__*/dual(3, (self, that, f) => {
|
|
|
1019
1117
|
* This function is the inverse of `zip`. Takes an `Iterable` of pairs and return two corresponding `Array`s.
|
|
1020
1118
|
*
|
|
1021
1119
|
* @example
|
|
1120
|
+
* ```ts
|
|
1022
1121
|
* import { Array } from "effect"
|
|
1023
1122
|
*
|
|
1024
1123
|
* const result = Array.unzip([[1, "a"], [2, "b"], [3, "c"]])
|
|
1025
1124
|
* assert.deepStrictEqual(result, [[1, 2, 3], ['a', 'b', 'c']])
|
|
1125
|
+
* ```
|
|
1026
1126
|
*
|
|
1027
1127
|
* @since 2.0.0
|
|
1028
1128
|
*/
|
|
@@ -1044,11 +1144,13 @@ export const unzip = self => {
|
|
|
1044
1144
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
1045
1145
|
*
|
|
1046
1146
|
* @example
|
|
1147
|
+
* ```ts
|
|
1047
1148
|
* import { Array } from "effect"
|
|
1048
1149
|
*
|
|
1049
1150
|
* const numbers = [1, 2, 3]
|
|
1050
1151
|
* const result = Array.intersperse(numbers, 0)
|
|
1051
1152
|
* assert.deepStrictEqual(result, [1, 0, 2, 0, 3])
|
|
1153
|
+
* ```
|
|
1052
1154
|
*
|
|
1053
1155
|
* @since 2.0.0
|
|
1054
1156
|
*/
|
|
@@ -1071,10 +1173,12 @@ export const intersperse = /*#__PURE__*/dual(2, (self, middle) => {
|
|
|
1071
1173
|
* Apply a function to the head, creating a new `NonEmptyReadonlyArray`.
|
|
1072
1174
|
*
|
|
1073
1175
|
* @example
|
|
1176
|
+
* ```ts
|
|
1074
1177
|
* import { Array } from "effect"
|
|
1075
1178
|
*
|
|
1076
1179
|
* const result = Array.modifyNonEmptyHead([1, 2, 3], n => n * 10)
|
|
1077
1180
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
1181
|
+
* ```
|
|
1078
1182
|
*
|
|
1079
1183
|
* @since 2.0.0
|
|
1080
1184
|
*/
|
|
@@ -1083,10 +1187,12 @@ export const modifyNonEmptyHead = /*#__PURE__*/dual(2, (self, f) => [f(headNonEm
|
|
|
1083
1187
|
* Change the head, creating a new `NonEmptyReadonlyArray`.
|
|
1084
1188
|
*
|
|
1085
1189
|
* @example
|
|
1190
|
+
* ```ts
|
|
1086
1191
|
* import { Array } from "effect"
|
|
1087
1192
|
*
|
|
1088
1193
|
* const result = Array.setNonEmptyHead([1, 2, 3], 10)
|
|
1089
1194
|
* assert.deepStrictEqual(result, [10, 2, 3])
|
|
1195
|
+
* ```
|
|
1090
1196
|
*
|
|
1091
1197
|
* @since 2.0.0
|
|
1092
1198
|
*/
|
|
@@ -1095,10 +1201,12 @@ export const setNonEmptyHead = /*#__PURE__*/dual(2, (self, b) => modifyNonEmptyH
|
|
|
1095
1201
|
* Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.
|
|
1096
1202
|
*
|
|
1097
1203
|
* @example
|
|
1204
|
+
* ```ts
|
|
1098
1205
|
* import { Array } from "effect"
|
|
1099
1206
|
*
|
|
1100
1207
|
* const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
|
|
1101
1208
|
* assert.deepStrictEqual(result, [1, 2, 6])
|
|
1209
|
+
* ```
|
|
1102
1210
|
*
|
|
1103
1211
|
* @since 2.0.0
|
|
1104
1212
|
*/
|
|
@@ -1107,10 +1215,12 @@ export const modifyNonEmptyLast = /*#__PURE__*/dual(2, (self, f) => append(initN
|
|
|
1107
1215
|
* Change the last element, creating a new `NonEmptyReadonlyArray`.
|
|
1108
1216
|
*
|
|
1109
1217
|
* @example
|
|
1218
|
+
* ```ts
|
|
1110
1219
|
* import { Array } from "effect"
|
|
1111
1220
|
*
|
|
1112
1221
|
* const result = Array.setNonEmptyLast([1, 2, 3], 4)
|
|
1113
1222
|
* assert.deepStrictEqual(result, [1, 2, 4])
|
|
1223
|
+
* ```
|
|
1114
1224
|
*
|
|
1115
1225
|
* @since 2.0.0
|
|
1116
1226
|
*/
|
|
@@ -1120,11 +1230,13 @@ export const setNonEmptyLast = /*#__PURE__*/dual(2, (self, b) => modifyNonEmptyL
|
|
|
1120
1230
|
* If the input is a non-empty array, the result is also a non-empty array.
|
|
1121
1231
|
*
|
|
1122
1232
|
* @example
|
|
1233
|
+
* ```ts
|
|
1123
1234
|
* import { Array } from "effect"
|
|
1124
1235
|
*
|
|
1125
1236
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1126
1237
|
* const result = Array.rotate(letters, 2)
|
|
1127
1238
|
* assert.deepStrictEqual(result, ['c', 'd', 'a', 'b'])
|
|
1239
|
+
* ```
|
|
1128
1240
|
*
|
|
1129
1241
|
* @since 2.0.0
|
|
1130
1242
|
*/
|
|
@@ -1149,6 +1261,7 @@ export const rotate = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
1149
1261
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using a provided `isEquivalent` function.
|
|
1150
1262
|
*
|
|
1151
1263
|
* @example
|
|
1264
|
+
* ```ts
|
|
1152
1265
|
* import { Array } from "effect"
|
|
1153
1266
|
*
|
|
1154
1267
|
* const numbers = [1, 2, 3, 4]
|
|
@@ -1156,6 +1269,7 @@ export const rotate = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
1156
1269
|
* const containsNumber = Array.containsWith(isEquivalent)
|
|
1157
1270
|
* const result = containsNumber(3)(numbers)
|
|
1158
1271
|
* assert.deepStrictEqual(result, true)
|
|
1272
|
+
* ```
|
|
1159
1273
|
*
|
|
1160
1274
|
* @category elements
|
|
1161
1275
|
* @since 2.0.0
|
|
@@ -1173,11 +1287,13 @@ const _equivalence = /*#__PURE__*/Equal.equivalence();
|
|
|
1173
1287
|
* Returns a function that checks if a `ReadonlyArray` contains a given value using the default `Equivalence`.
|
|
1174
1288
|
*
|
|
1175
1289
|
* @example
|
|
1290
|
+
* ```ts
|
|
1176
1291
|
* import { Array } from "effect"
|
|
1177
1292
|
*
|
|
1178
1293
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1179
1294
|
* const result = Array.contains('c')(letters)
|
|
1180
1295
|
* assert.deepStrictEqual(result, true)
|
|
1296
|
+
* ```
|
|
1181
1297
|
*
|
|
1182
1298
|
* @category elements
|
|
1183
1299
|
* @since 2.0.0
|
|
@@ -1189,6 +1305,7 @@ export const contains = /*#__PURE__*/containsWith(_equivalence);
|
|
|
1189
1305
|
* value and the rest of the `Array`.
|
|
1190
1306
|
*
|
|
1191
1307
|
* @example
|
|
1308
|
+
* ```ts
|
|
1192
1309
|
* import { Array } from "effect"
|
|
1193
1310
|
*
|
|
1194
1311
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -1199,6 +1316,7 @@ export const contains = /*#__PURE__*/containsWith(_equivalence);
|
|
|
1199
1316
|
* // The `chopFunction` takes the first element of the array, doubles it, and then returns it along with the rest of the array.
|
|
1200
1317
|
* // The `chop` function applies this `chopFunction` recursively to the input array `[1, 2, 3, 4, 5]`,
|
|
1201
1318
|
* // resulting in a new array `[2, 4, 6, 8, 10]`.
|
|
1319
|
+
* ```
|
|
1202
1320
|
*
|
|
1203
1321
|
* @since 2.0.0
|
|
1204
1322
|
*/
|
|
@@ -1222,11 +1340,13 @@ export const chop = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1222
1340
|
* The value of `n` can be `0`.
|
|
1223
1341
|
*
|
|
1224
1342
|
* @example
|
|
1343
|
+
* ```ts
|
|
1225
1344
|
* import { Array } from "effect"
|
|
1226
1345
|
*
|
|
1227
1346
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1228
1347
|
* const result = Array.splitAt(numbers, 3)
|
|
1229
1348
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
1349
|
+
* ```
|
|
1230
1350
|
*
|
|
1231
1351
|
* @category splitting
|
|
1232
1352
|
* @since 2.0.0
|
|
@@ -1247,10 +1367,12 @@ export const splitAt = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
1247
1367
|
* The value of `n` must be `>= 1`.
|
|
1248
1368
|
*
|
|
1249
1369
|
* @example
|
|
1370
|
+
* ```ts
|
|
1250
1371
|
* import { Array } from "effect"
|
|
1251
1372
|
*
|
|
1252
1373
|
* const result = Array.splitNonEmptyAt(["a", "b", "c", "d", "e"], 3)
|
|
1253
1374
|
* assert.deepStrictEqual(result, [["a", "b", "c"], ["d", "e"]])
|
|
1375
|
+
* ```
|
|
1254
1376
|
*
|
|
1255
1377
|
* @category splitting
|
|
1256
1378
|
* @since 2.0.0
|
|
@@ -1263,11 +1385,13 @@ export const splitNonEmptyAt = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
1263
1385
|
* Splits this iterable into `n` equally sized arrays.
|
|
1264
1386
|
*
|
|
1265
1387
|
* @example
|
|
1388
|
+
* ```ts
|
|
1266
1389
|
* import { Array } from "effect"
|
|
1267
1390
|
*
|
|
1268
1391
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
1269
1392
|
* const result = Array.split(numbers, 3)
|
|
1270
1393
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5, 6], [7, 8]])
|
|
1394
|
+
* ```
|
|
1271
1395
|
*
|
|
1272
1396
|
* @since 2.0.0
|
|
1273
1397
|
* @category splitting
|
|
@@ -1281,11 +1405,13 @@ export const split = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
1281
1405
|
* Returns a tuple containing two arrays: the first one is before the match, and the second one is from the match onward.
|
|
1282
1406
|
*
|
|
1283
1407
|
* @example
|
|
1408
|
+
* ```ts
|
|
1284
1409
|
* import { Array } from "effect"
|
|
1285
1410
|
*
|
|
1286
1411
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1287
1412
|
* const result = Array.splitWhere(numbers, n => n > 3)
|
|
1288
1413
|
* assert.deepStrictEqual(result, [[1, 2, 3], [4, 5]])
|
|
1414
|
+
* ```
|
|
1289
1415
|
*
|
|
1290
1416
|
* @category splitting
|
|
1291
1417
|
* @since 2.0.0
|
|
@@ -1295,11 +1421,13 @@ export const splitWhere = /*#__PURE__*/dual(2, (self, predicate) => span(self, (
|
|
|
1295
1421
|
* Copies an array.
|
|
1296
1422
|
*
|
|
1297
1423
|
* @example
|
|
1424
|
+
* ```ts
|
|
1298
1425
|
* import { Array } from "effect"
|
|
1299
1426
|
*
|
|
1300
1427
|
* const numbers = [1, 2, 3]
|
|
1301
1428
|
* const copy = Array.copy(numbers)
|
|
1302
1429
|
* assert.deepStrictEqual(copy, [1, 2, 3])
|
|
1430
|
+
* ```
|
|
1303
1431
|
*
|
|
1304
1432
|
* @since 2.0.0
|
|
1305
1433
|
*/
|
|
@@ -1311,11 +1439,13 @@ export const copy = self => self.slice();
|
|
|
1311
1439
|
* If `n` is less than or equal to 0, the returned array will be an empty array.
|
|
1312
1440
|
*
|
|
1313
1441
|
* @example
|
|
1442
|
+
* ```ts
|
|
1314
1443
|
* import { Array } from "effect"
|
|
1315
1444
|
*
|
|
1316
1445
|
* const arr = [1, 2, 3]
|
|
1317
1446
|
* const result = Array.pad(arr, 6, 0)
|
|
1318
1447
|
* assert.deepStrictEqual(result, [1, 2, 3, 0, 0, 0])
|
|
1448
|
+
* ```
|
|
1319
1449
|
*
|
|
1320
1450
|
* @since 3.8.4
|
|
1321
1451
|
*/
|
|
@@ -1337,6 +1467,7 @@ export const pad = /*#__PURE__*/dual(3, (self, n, fill) => {
|
|
|
1337
1467
|
* whenever `n` evenly divides the length of `self`.
|
|
1338
1468
|
*
|
|
1339
1469
|
* @example
|
|
1470
|
+
* ```ts
|
|
1340
1471
|
* import { Array } from "effect"
|
|
1341
1472
|
*
|
|
1342
1473
|
* const numbers = [1, 2, 3, 4, 5]
|
|
@@ -1348,6 +1479,7 @@ export const pad = /*#__PURE__*/dual(3, (self, n, fill) => {
|
|
|
1348
1479
|
* // It splits the array into chunks of length 2. Since the array length is not evenly divisible by 2,
|
|
1349
1480
|
* // the last chunk contains the remaining elements.
|
|
1350
1481
|
* // The result is `[[1, 2], [3, 4], [5]]`.
|
|
1482
|
+
* ```
|
|
1351
1483
|
*
|
|
1352
1484
|
* @category splitting
|
|
1353
1485
|
* @since 2.0.0
|
|
@@ -1363,10 +1495,12 @@ export const chunksOf = /*#__PURE__*/dual(2, (self, n) => {
|
|
|
1363
1495
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s using the provided `isEquivalent` function.
|
|
1364
1496
|
*
|
|
1365
1497
|
* @example
|
|
1498
|
+
* ```ts
|
|
1366
1499
|
* import { Array } from "effect"
|
|
1367
1500
|
*
|
|
1368
1501
|
* const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y)
|
|
1369
1502
|
* assert.deepStrictEqual(result, [["a", "a"], ["b", "b", "b"], ["c"], ["a"]])
|
|
1503
|
+
* ```
|
|
1370
1504
|
*
|
|
1371
1505
|
* @category grouping
|
|
1372
1506
|
* @since 2.0.0
|
|
@@ -1389,10 +1523,12 @@ export const groupWith = /*#__PURE__*/dual(2, (self, isEquivalent) => chop(self,
|
|
|
1389
1523
|
* Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s.
|
|
1390
1524
|
*
|
|
1391
1525
|
* @example
|
|
1526
|
+
* ```ts
|
|
1392
1527
|
* import { Array } from "effect"
|
|
1393
1528
|
*
|
|
1394
1529
|
* const result = Array.group([1, 1, 2, 2, 2, 3, 1])
|
|
1395
1530
|
* assert.deepStrictEqual(result, [[1, 1], [2, 2, 2], [3], [1]])
|
|
1531
|
+
* ```
|
|
1396
1532
|
*
|
|
1397
1533
|
* @category grouping
|
|
1398
1534
|
* @since 2.0.0
|
|
@@ -1403,6 +1539,7 @@ export const group = /*#__PURE__*/groupWith( /*#__PURE__*/Equal.equivalence());
|
|
|
1403
1539
|
* function on each element, and grouping the results according to values returned
|
|
1404
1540
|
*
|
|
1405
1541
|
* @example
|
|
1542
|
+
* ```ts
|
|
1406
1543
|
* import { Array } from "effect"
|
|
1407
1544
|
*
|
|
1408
1545
|
* const people = [
|
|
@@ -1415,6 +1552,7 @@ export const group = /*#__PURE__*/groupWith( /*#__PURE__*/Equal.equivalence());
|
|
|
1415
1552
|
* A: [{ name: "Alice", group: "A" }, { name: "Charlie", group: "A" }],
|
|
1416
1553
|
* B: [{ name: "Bob", group: "B" }]
|
|
1417
1554
|
* })
|
|
1555
|
+
* ```
|
|
1418
1556
|
*
|
|
1419
1557
|
* @category grouping
|
|
1420
1558
|
* @since 2.0.0
|
|
@@ -1435,12 +1573,14 @@ export const groupBy = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1435
1573
|
* Calculates the union of two arrays using the provided equivalence relation.
|
|
1436
1574
|
*
|
|
1437
1575
|
* @example
|
|
1576
|
+
* ```ts
|
|
1438
1577
|
* import { Array } from "effect"
|
|
1439
1578
|
*
|
|
1440
1579
|
* const array1 = [1, 2]
|
|
1441
1580
|
* const array2 = [2, 3]
|
|
1442
1581
|
* const union = Array.unionWith(array1, array2, (a, b) => a === b)
|
|
1443
1582
|
* assert.deepStrictEqual(union, [1, 2, 3])
|
|
1583
|
+
* ```
|
|
1444
1584
|
*
|
|
1445
1585
|
* @since 2.0.0
|
|
1446
1586
|
*/
|
|
@@ -1460,12 +1600,14 @@ export const unionWith = /*#__PURE__*/dual(3, (self, that, isEquivalent) => {
|
|
|
1460
1600
|
* Creates a union of two arrays, removing duplicates.
|
|
1461
1601
|
*
|
|
1462
1602
|
* @example
|
|
1603
|
+
* ```ts
|
|
1463
1604
|
* import { Array } from "effect"
|
|
1464
1605
|
*
|
|
1465
1606
|
* const array1 = [1, 2]
|
|
1466
1607
|
* const array2 = [2, 3]
|
|
1467
1608
|
* const result = Array.union(array1, array2)
|
|
1468
1609
|
* assert.deepStrictEqual(result, [1, 2, 3])
|
|
1610
|
+
* ```
|
|
1469
1611
|
*
|
|
1470
1612
|
* @since 2.0.0
|
|
1471
1613
|
*/
|
|
@@ -1475,6 +1617,7 @@ export const union = /*#__PURE__*/dual(2, (self, that) => unionWith(self, that,
|
|
|
1475
1617
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1476
1618
|
*
|
|
1477
1619
|
* @example
|
|
1620
|
+
* ```ts
|
|
1478
1621
|
* import { Array } from "effect"
|
|
1479
1622
|
*
|
|
1480
1623
|
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
@@ -1482,6 +1625,7 @@ export const union = /*#__PURE__*/dual(2, (self, that) => unionWith(self, that,
|
|
|
1482
1625
|
* const isEquivalent = (a: { id: number }, b: { id: number }) => a.id === b.id
|
|
1483
1626
|
* const result = Array.intersectionWith(isEquivalent)(array2)(array1)
|
|
1484
1627
|
* assert.deepStrictEqual(result, [{ id: 1 }, { id: 3 }])
|
|
1628
|
+
* ```
|
|
1485
1629
|
*
|
|
1486
1630
|
* @since 2.0.0
|
|
1487
1631
|
*/
|
|
@@ -1494,12 +1638,14 @@ export const intersectionWith = isEquivalent => {
|
|
|
1494
1638
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1495
1639
|
*
|
|
1496
1640
|
* @example
|
|
1641
|
+
* ```ts
|
|
1497
1642
|
* import { Array } from "effect"
|
|
1498
1643
|
*
|
|
1499
1644
|
* const array1 = [1, 2, 3]
|
|
1500
1645
|
* const array2 = [3, 4, 1]
|
|
1501
1646
|
* const result = Array.intersection(array1, array2)
|
|
1502
1647
|
* assert.deepStrictEqual(result, [1, 3])
|
|
1648
|
+
* ```
|
|
1503
1649
|
*
|
|
1504
1650
|
* @since 2.0.0
|
|
1505
1651
|
*/
|
|
@@ -1509,12 +1655,14 @@ export const intersection = /*#__PURE__*/intersectionWith(_equivalence);
|
|
|
1509
1655
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1510
1656
|
*
|
|
1511
1657
|
* @example
|
|
1658
|
+
* ```ts
|
|
1512
1659
|
* import { Array } from "effect"
|
|
1513
1660
|
*
|
|
1514
1661
|
* const array1 = [1, 2, 3]
|
|
1515
1662
|
* const array2 = [2, 3, 4]
|
|
1516
1663
|
* const difference = Array.differenceWith<number>((a, b) => a === b)(array1, array2)
|
|
1517
1664
|
* assert.deepStrictEqual(difference, [1])
|
|
1665
|
+
* ```
|
|
1518
1666
|
*
|
|
1519
1667
|
* @since 2.0.0
|
|
1520
1668
|
*/
|
|
@@ -1527,12 +1675,14 @@ export const differenceWith = isEquivalent => {
|
|
|
1527
1675
|
* The order and references of result values are determined by the first `Iterable`.
|
|
1528
1676
|
*
|
|
1529
1677
|
* @example
|
|
1678
|
+
* ```ts
|
|
1530
1679
|
* import { Array } from "effect"
|
|
1531
1680
|
*
|
|
1532
1681
|
* const array1 = [1, 2, 3]
|
|
1533
1682
|
* const array2 = [2, 3, 4]
|
|
1534
1683
|
* const difference = Array.difference(array1, array2)
|
|
1535
1684
|
* assert.deepStrictEqual(difference, [1])
|
|
1685
|
+
* ```
|
|
1536
1686
|
*
|
|
1537
1687
|
* @since 2.0.0
|
|
1538
1688
|
*/
|
|
@@ -1579,12 +1729,14 @@ export const flatMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1579
1729
|
* arrays is collapsed into a single, flat array.
|
|
1580
1730
|
*
|
|
1581
1731
|
* @example
|
|
1732
|
+
* ```ts
|
|
1582
1733
|
* import { Array } from "effect";
|
|
1583
1734
|
*
|
|
1584
1735
|
* const nestedArrays = [[1, 2], [], [3, 4], [], [5, 6]]
|
|
1585
1736
|
* const result = Array.flatten(nestedArrays)
|
|
1586
1737
|
*
|
|
1587
1738
|
* assert.deepStrictEqual(result, [1, 2, 3, 4, 5, 6]);
|
|
1739
|
+
* ```
|
|
1588
1740
|
*
|
|
1589
1741
|
* @category sequencing
|
|
1590
1742
|
* @since 2.0.0
|
|
@@ -1595,6 +1747,7 @@ export const flatten = /*#__PURE__*/flatMap(identity);
|
|
|
1595
1747
|
* This method combines filtering and mapping functionalities, allowing transformations and filtering of elements based on a single function pass.
|
|
1596
1748
|
*
|
|
1597
1749
|
* @example
|
|
1750
|
+
* ```ts
|
|
1598
1751
|
* import { Array, Option } from "effect";
|
|
1599
1752
|
*
|
|
1600
1753
|
* const data = [1, 2, 3, 4, 5];
|
|
@@ -1602,6 +1755,7 @@ export const flatten = /*#__PURE__*/flatMap(identity);
|
|
|
1602
1755
|
* const result = Array.filterMap(data, evenSquares);
|
|
1603
1756
|
*
|
|
1604
1757
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
1758
|
+
* ```
|
|
1605
1759
|
*
|
|
1606
1760
|
* @category filtering
|
|
1607
1761
|
* @since 2.0.0
|
|
@@ -1623,6 +1777,7 @@ export const filterMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1623
1777
|
* This is useful when you need to transform an array but only up to the point where a certain condition holds true.
|
|
1624
1778
|
*
|
|
1625
1779
|
* @example
|
|
1780
|
+
* ```ts
|
|
1626
1781
|
* import { Array, Option } from "effect";
|
|
1627
1782
|
*
|
|
1628
1783
|
* const data = [2, 4, 5];
|
|
@@ -1630,6 +1785,7 @@ export const filterMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1630
1785
|
* const result = Array.filterMapWhile(data, toSquareTillOdd);
|
|
1631
1786
|
*
|
|
1632
1787
|
* assert.deepStrictEqual(result, [4, 16]);
|
|
1788
|
+
* ```
|
|
1633
1789
|
*
|
|
1634
1790
|
* @category filtering
|
|
1635
1791
|
* @since 2.0.0
|
|
@@ -1655,6 +1811,7 @@ export const filterMapWhile = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1655
1811
|
* into successes and failures.
|
|
1656
1812
|
*
|
|
1657
1813
|
* @example
|
|
1814
|
+
* ```ts
|
|
1658
1815
|
* import { Array, Either } from "effect";
|
|
1659
1816
|
*
|
|
1660
1817
|
* const data = [1, 2, 3, 4, 5]
|
|
@@ -1667,6 +1824,7 @@ export const filterMapWhile = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1667
1824
|
* [1, 3, 5],
|
|
1668
1825
|
* [2, 4]
|
|
1669
1826
|
* ])
|
|
1827
|
+
* ```
|
|
1670
1828
|
*
|
|
1671
1829
|
* @category filtering
|
|
1672
1830
|
* @since 2.0.0
|
|
@@ -1689,12 +1847,14 @@ export const partitionMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1689
1847
|
* Retrieves the `Some` values from an `Iterable` of `Option`s, collecting them into an array.
|
|
1690
1848
|
*
|
|
1691
1849
|
* @example
|
|
1850
|
+
* ```ts
|
|
1692
1851
|
* import { Array, Option } from "effect"
|
|
1693
1852
|
*
|
|
1694
1853
|
* assert.deepStrictEqual(
|
|
1695
1854
|
* Array.getSomes([Option.some(1), Option.none(), Option.some(2)]),
|
|
1696
1855
|
* [1, 2]
|
|
1697
1856
|
* )
|
|
1857
|
+
* ```
|
|
1698
1858
|
*
|
|
1699
1859
|
* @category filtering
|
|
1700
1860
|
* @since 2.0.0
|
|
@@ -1704,12 +1864,14 @@ export const getSomes = /*#__PURE__*/filterMap(identity);
|
|
|
1704
1864
|
* Retrieves the `Left` values from an `Iterable` of `Either`s, collecting them into an array.
|
|
1705
1865
|
*
|
|
1706
1866
|
* @example
|
|
1867
|
+
* ```ts
|
|
1707
1868
|
* import { Array, Either } from "effect"
|
|
1708
1869
|
*
|
|
1709
1870
|
* assert.deepStrictEqual(
|
|
1710
1871
|
* Array.getLefts([Either.right(1), Either.left("err"), Either.right(2)]),
|
|
1711
1872
|
* ["err"]
|
|
1712
1873
|
* )
|
|
1874
|
+
* ```
|
|
1713
1875
|
*
|
|
1714
1876
|
* @category filtering
|
|
1715
1877
|
* @since 2.0.0
|
|
@@ -1727,12 +1889,14 @@ export const getLefts = self => {
|
|
|
1727
1889
|
* Retrieves the `Right` values from an `Iterable` of `Either`s, collecting them into an array.
|
|
1728
1890
|
*
|
|
1729
1891
|
* @example
|
|
1892
|
+
* ```ts
|
|
1730
1893
|
* import { Array, Either } from "effect"
|
|
1731
1894
|
*
|
|
1732
1895
|
* assert.deepStrictEqual(
|
|
1733
1896
|
* Array.getRights([Either.right(1), Either.left("err"), Either.right(2)]),
|
|
1734
1897
|
* [1, 2]
|
|
1735
1898
|
* )
|
|
1899
|
+
* ```
|
|
1736
1900
|
*
|
|
1737
1901
|
* @category filtering
|
|
1738
1902
|
* @since 2.0.0
|
|
@@ -1783,11 +1947,13 @@ export const partition = /*#__PURE__*/dual(2, (self, predicate) => {
|
|
|
1783
1947
|
* Separates an `Iterable` into two arrays based on a predicate.
|
|
1784
1948
|
*
|
|
1785
1949
|
* @example
|
|
1950
|
+
* ```ts
|
|
1786
1951
|
* import { Array } from "effect"
|
|
1787
1952
|
*
|
|
1788
1953
|
* const numbers = [1, 2, 3, 4]
|
|
1789
1954
|
* const result = Array.partition(numbers, n => n % 2 === 0)
|
|
1790
1955
|
* assert.deepStrictEqual(result, [[1, 3], [2, 4]])
|
|
1956
|
+
* ```
|
|
1791
1957
|
*
|
|
1792
1958
|
* @category filtering
|
|
1793
1959
|
* @since 2.0.0
|
|
@@ -1797,11 +1963,13 @@ export const separate = /*#__PURE__*/partitionMap(identity);
|
|
|
1797
1963
|
* Reduces an array from the left.
|
|
1798
1964
|
*
|
|
1799
1965
|
* @example
|
|
1966
|
+
* ```ts
|
|
1800
1967
|
* import { Array } from "effect"
|
|
1801
1968
|
*
|
|
1802
1969
|
* const numbers = [1, 2, 3]
|
|
1803
1970
|
* const result = Array.reduce(numbers, 0, (acc, n) => acc + n)
|
|
1804
1971
|
* assert.deepStrictEqual(result, 6)
|
|
1972
|
+
* ```
|
|
1805
1973
|
*
|
|
1806
1974
|
* @category folding
|
|
1807
1975
|
* @since 2.0.0
|
|
@@ -1811,11 +1979,13 @@ export const reduce = /*#__PURE__*/dual(3, (self, b, f) => fromIterable(self).re
|
|
|
1811
1979
|
* Reduces an array from the right.
|
|
1812
1980
|
*
|
|
1813
1981
|
* @example
|
|
1982
|
+
* ```ts
|
|
1814
1983
|
* import { Array } from "effect"
|
|
1815
1984
|
*
|
|
1816
1985
|
* const numbers = [1, 2, 3]
|
|
1817
1986
|
* const result = Array.reduceRight(numbers, 0, (acc, n) => acc + n)
|
|
1818
1987
|
* assert.deepStrictEqual(result, 6)
|
|
1988
|
+
* ```
|
|
1819
1989
|
*
|
|
1820
1990
|
* @category folding
|
|
1821
1991
|
* @since 2.0.0
|
|
@@ -1825,12 +1995,14 @@ export const reduceRight = /*#__PURE__*/dual(3, (self, b, f) => fromIterable(sel
|
|
|
1825
1995
|
* Lifts a predicate into an array.
|
|
1826
1996
|
*
|
|
1827
1997
|
* @example
|
|
1998
|
+
* ```ts
|
|
1828
1999
|
* import { Array } from "effect"
|
|
1829
2000
|
*
|
|
1830
2001
|
* const isEven = (n: number) => n % 2 === 0
|
|
1831
2002
|
* const to = Array.liftPredicate(isEven)
|
|
1832
2003
|
* assert.deepStrictEqual(to(1), [])
|
|
1833
2004
|
* assert.deepStrictEqual(to(2), [2])
|
|
2005
|
+
* ```
|
|
1834
2006
|
*
|
|
1835
2007
|
* @category lifting
|
|
1836
2008
|
* @since 2.0.0
|
|
@@ -1855,6 +2027,7 @@ export const liftNullable = f => (...a) => fromNullable(f(...a));
|
|
|
1855
2027
|
* Maps over an array and flattens the result, removing null and undefined values.
|
|
1856
2028
|
*
|
|
1857
2029
|
* @example
|
|
2030
|
+
* ```ts
|
|
1858
2031
|
* import { Array } from "effect"
|
|
1859
2032
|
*
|
|
1860
2033
|
* const numbers = [1, 2, 3]
|
|
@@ -1865,6 +2038,7 @@ export const liftNullable = f => (...a) => fromNullable(f(...a));
|
|
|
1865
2038
|
* // The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
|
|
1866
2039
|
* // and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
|
|
1867
2040
|
* // to remove null values, resulting in [1, 3].
|
|
2041
|
+
* ```
|
|
1868
2042
|
*
|
|
1869
2043
|
* @category sequencing
|
|
1870
2044
|
* @since 2.0.0
|
|
@@ -1876,6 +2050,7 @@ export const flatMapNullable = /*#__PURE__*/dual(2, (self, f) => flatMap(self, a
|
|
|
1876
2050
|
* If the `Either` is a right, it returns an array with the right value.
|
|
1877
2051
|
*
|
|
1878
2052
|
* @example
|
|
2053
|
+
* ```ts
|
|
1879
2054
|
* import { Array, Either } from "effect"
|
|
1880
2055
|
*
|
|
1881
2056
|
* const parseNumber = (s: string): Either.Either<number, Error> =>
|
|
@@ -1893,6 +2068,7 @@ export const flatMapNullable = /*#__PURE__*/dual(2, (self, f) => flatMap(self, a
|
|
|
1893
2068
|
* // The function parseNumber is lifted to return an array.
|
|
1894
2069
|
* // When parsing "42", it returns an Either.left with the number 42, resulting in [42].
|
|
1895
2070
|
* // When parsing "not a number", it returns an Either.right with an error, resulting in an empty array [].
|
|
2071
|
+
* ```
|
|
1896
2072
|
*
|
|
1897
2073
|
* @category lifting
|
|
1898
2074
|
* @since 2.0.0
|
|
@@ -1919,6 +2095,7 @@ export const some = /*#__PURE__*/dual(2, (self, predicate) => self.some(predicat
|
|
|
1919
2095
|
* Extends an array with a function that maps each subarray to a value.
|
|
1920
2096
|
*
|
|
1921
2097
|
* @example
|
|
2098
|
+
* ```ts
|
|
1922
2099
|
* import { Array } from "effect"
|
|
1923
2100
|
*
|
|
1924
2101
|
* const numbers = [1, 2, 3]
|
|
@@ -1930,6 +2107,7 @@ export const some = /*#__PURE__*/dual(2, (self, predicate) => self.some(predicat
|
|
|
1930
2107
|
* // The subarrays are: [1, 2, 3], [2, 3], [3].
|
|
1931
2108
|
* // The lengths are: 3, 2, 1.
|
|
1932
2109
|
* // Therefore, the result is [3, 2, 1].
|
|
2110
|
+
* ```
|
|
1933
2111
|
*
|
|
1934
2112
|
* @since 2.0.0
|
|
1935
2113
|
*/
|
|
@@ -1938,10 +2116,12 @@ export const extend = /*#__PURE__*/dual(2, (self, f) => self.map((_, i, as) => f
|
|
|
1938
2116
|
* Finds the minimum element in an array based on a comparator.
|
|
1939
2117
|
*
|
|
1940
2118
|
* @example
|
|
2119
|
+
* ```ts
|
|
1941
2120
|
* import { Array, Order } from "effect"
|
|
1942
2121
|
*
|
|
1943
2122
|
* const min = Array.min([3, 1, 2], Order.number)
|
|
1944
2123
|
* assert.deepStrictEqual(min, 1)
|
|
2124
|
+
* ```
|
|
1945
2125
|
*
|
|
1946
2126
|
* @since 2.0.0
|
|
1947
2127
|
*/
|
|
@@ -1950,10 +2130,12 @@ export const min = /*#__PURE__*/dual(2, (self, O) => self.reduce(Order.min(O)));
|
|
|
1950
2130
|
* Finds the maximum element in an array based on a comparator.
|
|
1951
2131
|
*
|
|
1952
2132
|
* @example
|
|
2133
|
+
* ```ts
|
|
1953
2134
|
* import { Array, Order } from "effect"
|
|
1954
2135
|
*
|
|
1955
2136
|
* const max = Array.max([3, 1, 2], Order.number)
|
|
1956
2137
|
* assert.deepStrictEqual(max, 3)
|
|
2138
|
+
* ```
|
|
1957
2139
|
*
|
|
1958
2140
|
* @since 2.0.0
|
|
1959
2141
|
*/
|
|
@@ -1987,12 +2169,14 @@ export const getOrder = Order.array;
|
|
|
1987
2169
|
* Creates an equivalence relation for arrays.
|
|
1988
2170
|
*
|
|
1989
2171
|
* @example
|
|
2172
|
+
* ```ts
|
|
1990
2173
|
* import { Array } from "effect"
|
|
1991
2174
|
*
|
|
1992
2175
|
* const numbers1 = [1, 2, 3]
|
|
1993
2176
|
* const numbers2 = [1, 2, 3]
|
|
1994
2177
|
* const eq = Array.getEquivalence<number>((a, b) => a === b)
|
|
1995
2178
|
* assert.deepStrictEqual(eq(numbers1, numbers2), true)
|
|
2179
|
+
* ```
|
|
1996
2180
|
*
|
|
1997
2181
|
* @category instances
|
|
1998
2182
|
* @since 2.0.0
|
|
@@ -2002,10 +2186,12 @@ export const getEquivalence = Equivalence.array;
|
|
|
2002
2186
|
* Performs a side-effect for each element of the `Iterable`.
|
|
2003
2187
|
*
|
|
2004
2188
|
* @example
|
|
2189
|
+
* ```ts
|
|
2005
2190
|
* import { Array } from "effect"
|
|
2006
2191
|
*
|
|
2007
2192
|
* const numbers = [1, 2, 3]
|
|
2008
2193
|
* Array.forEach(numbers, n => console.log(n)) // 1, 2, 3
|
|
2194
|
+
* ```
|
|
2009
2195
|
*
|
|
2010
2196
|
* @since 2.0.0
|
|
2011
2197
|
*/
|
|
@@ -2015,11 +2201,13 @@ export const forEach = /*#__PURE__*/dual(2, (self, f) => fromIterable(self).forE
|
|
|
2015
2201
|
* preserving the order of the first occurrence of each element.
|
|
2016
2202
|
*
|
|
2017
2203
|
* @example
|
|
2204
|
+
* ```ts
|
|
2018
2205
|
* import { Array } from "effect"
|
|
2019
2206
|
*
|
|
2020
2207
|
* const numbers = [1, 2, 2, 3, 3, 3]
|
|
2021
2208
|
* const unique = Array.dedupeWith(numbers, (a, b) => a === b)
|
|
2022
2209
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
2210
|
+
* ```
|
|
2023
2211
|
*
|
|
2024
2212
|
* @since 2.0.0
|
|
2025
2213
|
*/
|
|
@@ -2048,11 +2236,13 @@ export const dedupe = self => dedupeWith(self, Equal.equivalence());
|
|
|
2048
2236
|
* Deduplicates adjacent elements that are identical using the provided `isEquivalent` function.
|
|
2049
2237
|
*
|
|
2050
2238
|
* @example
|
|
2239
|
+
* ```ts
|
|
2051
2240
|
* import { Array } from "effect"
|
|
2052
2241
|
*
|
|
2053
2242
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
2054
2243
|
* const unique = Array.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
2055
2244
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
2245
|
+
* ```
|
|
2056
2246
|
*
|
|
2057
2247
|
* @since 2.0.0
|
|
2058
2248
|
*/
|
|
@@ -2071,11 +2261,13 @@ export const dedupeAdjacentWith = /*#__PURE__*/dual(2, (self, isEquivalent) => {
|
|
|
2071
2261
|
* Deduplicates adjacent elements that are identical.
|
|
2072
2262
|
*
|
|
2073
2263
|
* @example
|
|
2264
|
+
* ```ts
|
|
2074
2265
|
* import { Array } from "effect"
|
|
2075
2266
|
*
|
|
2076
2267
|
* const numbers = [1, 1, 2, 2, 3, 3]
|
|
2077
2268
|
* const unique = Array.dedupeAdjacent(numbers)
|
|
2078
2269
|
* assert.deepStrictEqual(unique, [1, 2, 3])
|
|
2270
|
+
* ```
|
|
2079
2271
|
*
|
|
2080
2272
|
* @since 2.0.0
|
|
2081
2273
|
*/
|
|
@@ -2084,11 +2276,13 @@ export const dedupeAdjacent = /*#__PURE__*/dedupeAdjacentWith( /*#__PURE__*/Equa
|
|
|
2084
2276
|
* Joins the elements together with "sep" in the middle.
|
|
2085
2277
|
*
|
|
2086
2278
|
* @example
|
|
2279
|
+
* ```ts
|
|
2087
2280
|
* import { Array } from "effect"
|
|
2088
2281
|
*
|
|
2089
2282
|
* const strings = ["a", "b", "c"]
|
|
2090
2283
|
* const joined = Array.join(strings, "-")
|
|
2091
2284
|
* assert.deepStrictEqual(joined, "a-b-c")
|
|
2285
|
+
* ```
|
|
2092
2286
|
*
|
|
2093
2287
|
* @since 2.0.0
|
|
2094
2288
|
* @category folding
|
|
@@ -2098,11 +2292,13 @@ export const join = /*#__PURE__*/dual(2, (self, sep) => fromIterable(self).join(
|
|
|
2098
2292
|
* Statefully maps over the chunk, producing new elements of type `B`.
|
|
2099
2293
|
*
|
|
2100
2294
|
* @example
|
|
2295
|
+
* ```ts
|
|
2101
2296
|
* import { Array } from "effect"
|
|
2102
2297
|
*
|
|
2103
2298
|
* const numbers = [1, 2, 3]
|
|
2104
2299
|
* const result = Array.mapAccum(numbers, 0, (acc, n) => [acc + n, acc + n])
|
|
2105
2300
|
* assert.deepStrictEqual(result, [6, [1, 3, 6]])
|
|
2301
|
+
* ```
|
|
2106
2302
|
*
|
|
2107
2303
|
* @since 2.0.0
|
|
2108
2304
|
* @category folding
|
|
@@ -2123,12 +2319,14 @@ export const mapAccum = /*#__PURE__*/dual(3, (self, s, f) => {
|
|
|
2123
2319
|
* Zips this chunk crosswise with the specified chunk using the specified combiner.
|
|
2124
2320
|
*
|
|
2125
2321
|
* @example
|
|
2322
|
+
* ```ts
|
|
2126
2323
|
* import { Array } from "effect"
|
|
2127
2324
|
*
|
|
2128
2325
|
* const array1 = [1, 2]
|
|
2129
2326
|
* const array2 = ["a", "b"]
|
|
2130
2327
|
* const product = Array.cartesianWith(array1, array2, (a, b) => `${a}-${b}`)
|
|
2131
2328
|
* assert.deepStrictEqual(product, ["1-a", "1-b", "2-a", "2-b"])
|
|
2329
|
+
* ```
|
|
2132
2330
|
*
|
|
2133
2331
|
* @since 2.0.0
|
|
2134
2332
|
* @category elements
|
|
@@ -2138,12 +2336,14 @@ export const cartesianWith = /*#__PURE__*/dual(3, (self, that, f) => flatMap(sel
|
|
|
2138
2336
|
* Zips this chunk crosswise with the specified chunk.
|
|
2139
2337
|
*
|
|
2140
2338
|
* @example
|
|
2339
|
+
* ```ts
|
|
2141
2340
|
* import { Array } from "effect"
|
|
2142
2341
|
*
|
|
2143
2342
|
* const array1 = [1, 2]
|
|
2144
2343
|
* const array2 = ["a", "b"]
|
|
2145
2344
|
* const product = Array.cartesian(array1, array2)
|
|
2146
2345
|
* assert.deepStrictEqual(product, [[1, "a"], [1, "b"], [2, "a"], [2, "b"]])
|
|
2346
|
+
* ```
|
|
2147
2347
|
*
|
|
2148
2348
|
* @since 2.0.0
|
|
2149
2349
|
* @category elements
|
|
@@ -2171,6 +2371,7 @@ export const cartesian = /*#__PURE__*/dual(2, (self, that) => cartesianWith(self
|
|
|
2171
2371
|
* @see {@link let_ let}
|
|
2172
2372
|
*
|
|
2173
2373
|
* @example
|
|
2374
|
+
* ```ts
|
|
2174
2375
|
* import { Array as Arr, pipe } from "effect"
|
|
2175
2376
|
* const doResult = pipe(
|
|
2176
2377
|
* Arr.Do,
|
|
@@ -2191,6 +2392,7 @@ export const cartesian = /*#__PURE__*/dual(2, (self, that) => cartesianWith(self
|
|
|
2191
2392
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
2192
2393
|
* }
|
|
2193
2394
|
* }
|
|
2395
|
+
* ```
|
|
2194
2396
|
*
|
|
2195
2397
|
* @category do notation
|
|
2196
2398
|
* @since 3.2.0
|
|
@@ -2215,6 +2417,7 @@ export const Do = /*#__PURE__*/of({});
|
|
|
2215
2417
|
* @see {@link let_ let}
|
|
2216
2418
|
*
|
|
2217
2419
|
* @example
|
|
2420
|
+
* ```ts
|
|
2218
2421
|
* import { Array as Arr, pipe } from "effect"
|
|
2219
2422
|
* const doResult = pipe(
|
|
2220
2423
|
* Arr.Do,
|
|
@@ -2235,6 +2438,7 @@ export const Do = /*#__PURE__*/of({});
|
|
|
2235
2438
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
2236
2439
|
* }
|
|
2237
2440
|
* }
|
|
2441
|
+
* ```
|
|
2238
2442
|
*
|
|
2239
2443
|
* @category do notation
|
|
2240
2444
|
* @since 3.2.0
|
|
@@ -2259,6 +2463,7 @@ export const bind = /*#__PURE__*/doNotation.bind(map, flatMap);
|
|
|
2259
2463
|
* @see {@link let_ let}
|
|
2260
2464
|
*
|
|
2261
2465
|
* @example
|
|
2466
|
+
* ```ts
|
|
2262
2467
|
* import { Array as Arr, pipe } from "effect"
|
|
2263
2468
|
* const doResult = pipe(
|
|
2264
2469
|
* Arr.Do,
|
|
@@ -2279,6 +2484,7 @@ export const bind = /*#__PURE__*/doNotation.bind(map, flatMap);
|
|
|
2279
2484
|
* if(_x < _y) result.push([_x, _y] as const)
|
|
2280
2485
|
* }
|
|
2281
2486
|
* }
|
|
2487
|
+
* ```
|
|
2282
2488
|
*
|
|
2283
2489
|
* @category do notation
|
|
2284
2490
|
* @since 3.2.0
|
|
@@ -2305,6 +2511,7 @@ export {
|
|
|
2305
2511
|
* @see {@link Do}
|
|
2306
2512
|
*
|
|
2307
2513
|
* @example
|
|
2514
|
+
* ```ts
|
|
2308
2515
|
* import { Array as Arr, pipe } from "effect"
|
|
2309
2516
|
* const doResult = pipe(
|
|
2310
2517
|
* Arr.Do,
|
|
@@ -2326,6 +2533,7 @@ export {
|
|
|
2326
2533
|
* }
|
|
2327
2534
|
* }
|
|
2328
2535
|
*
|
|
2536
|
+
* ```
|
|
2329
2537
|
* @category do notation
|
|
2330
2538
|
* @since 3.2.0
|
|
2331
2539
|
*/
|