effect 4.0.0-beta.98 → 4.0.0-rc.108
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/AGENTS.md +381 -0
- package/CLAUDE.md +381 -0
- package/README.md +13 -20
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +5 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +165 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +116 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +136 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +24 -0
- package/dist/Array.d.ts +971 -1037
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +463 -413
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +433 -756
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +200 -325
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +207 -267
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +107 -135
- package/dist/BigInt.js.map +1 -1
- package/dist/Boolean.d.ts +146 -188
- package/dist/Boolean.d.ts.map +1 -1
- package/dist/Boolean.js +64 -84
- package/dist/Boolean.js.map +1 -1
- package/dist/Brand.d.ts +3 -3
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +4 -3
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +409 -256
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +213 -134
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +167 -277
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +122 -176
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +756 -769
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +588 -449
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +834 -1173
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +326 -439
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +180 -49
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +96 -31
- package/dist/Clock.js.map +1 -1
- package/dist/Combiner.d.ts +20 -33
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +18 -30
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +226 -174
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +361 -267
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +229 -71
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +164 -95
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +233 -33
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js +232 -32
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +153 -277
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +172 -236
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +144 -176
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +227 -162
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +13 -15
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +22 -15
- package/dist/Crypto.js.map +1 -1
- package/dist/Data.d.ts +60 -80
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +18 -24
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +562 -660
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +307 -362
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +253 -256
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +110 -98
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +216 -308
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +157 -188
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +3142 -3345
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1452 -1570
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +22 -40
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +22 -40
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +33 -37
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +39 -23
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +103 -105
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +77 -79
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +51 -27
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +50 -26
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +86 -55
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +8 -29
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +116 -192
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +82 -130
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +83 -147
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +48 -87
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +152 -105
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +109 -75
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +213 -168
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +114 -89
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +123 -81
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +86 -60
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +154 -265
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +42 -147
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +61 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +26 -15
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +24 -32
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +55 -60
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +106 -148
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +81 -62
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +1412 -775
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +1180 -561
- package/dist/Graph.js.map +1 -1
- package/dist/HKT.d.ts +12 -6
- package/dist/HKT.d.ts.map +1 -1
- package/dist/Hash.d.ts +47 -83
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +46 -68
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +319 -411
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +122 -166
- package/dist/HashMap.js.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +1 -0
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +177 -284
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js +68 -109
- package/dist/HashSet.js.map +1 -1
- package/dist/Inspectable.d.ts +19 -18
- package/dist/Inspectable.d.ts.map +1 -1
- package/dist/Inspectable.js +20 -16
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +620 -786
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +282 -318
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts +11 -13
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +46 -103
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +8 -8
- package/dist/JsonPointer.js +8 -8
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +98 -44
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +319 -241
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +23 -35
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +16 -28
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +359 -260
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +202 -180
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +42 -29
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +31 -21
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +6 -2
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +6 -2
- package/dist/LayerRef.js.map +1 -1
- package/dist/LogLevel.d.ts +114 -214
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +41 -76
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +218 -467
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +208 -453
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +16 -5
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +10 -5
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +217 -252
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +150 -183
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +442 -993
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +202 -645
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +144 -173
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +68 -79
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +84 -89
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +44 -47
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +71 -370
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +63 -284
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts +420 -243
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +209 -120
- package/dist/MutableRef.js.map +1 -1
- package/dist/Newtype.d.ts +21 -14
- package/dist/Newtype.d.ts.map +1 -1
- package/dist/Newtype.js +15 -13
- package/dist/Newtype.js.map +1 -1
- package/dist/NonEmptyIterable.d.ts +7 -137
- package/dist/NonEmptyIterable.d.ts.map +1 -1
- package/dist/NonEmptyIterable.js +5 -93
- package/dist/NonEmptyIterable.js.map +1 -1
- package/dist/Number.d.ts +196 -233
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +90 -109
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +132 -210
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +221 -324
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +447 -812
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +213 -393
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +109 -109
- package/dist/Order.js +91 -91
- package/dist/Order.js.map +1 -1
- package/dist/Ordering.d.ts +20 -23
- package/dist/Ordering.d.ts.map +1 -1
- package/dist/Ordering.js +8 -9
- package/dist/Ordering.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -4
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +38 -41
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +3 -4
- package/dist/Path.js.map +1 -1
- package/dist/Pipeable.d.ts +6 -5
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +2 -2
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +4 -4
- package/dist/PlatformError.js +3 -3
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +4 -2
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +4 -2
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +200 -181
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +100 -108
- package/dist/Predicate.js.map +1 -1
- package/dist/PrimaryKey.d.ts +7 -7
- package/dist/PrimaryKey.js +5 -5
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +425 -494
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +373 -362
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts +24 -18
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +11 -9
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +200 -159
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +166 -138
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +49 -74
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +35 -54
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +121 -63
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +42 -21
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +24 -13
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/RcRef.js +15 -9
- package/dist/RcRef.js.map +1 -1
- package/dist/Record.d.ts +361 -466
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +163 -216
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +6 -2
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +7 -2
- package/dist/Redactable.js.map +1 -1
- package/dist/Redacted.d.ts +25 -25
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +19 -20
- package/dist/Redacted.js.map +1 -1
- package/dist/Reducer.d.ts +8 -15
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +6 -12
- package/dist/Reducer.js.map +1 -1
- package/dist/Ref.d.ts +95 -165
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +75 -122
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +102 -213
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +102 -213
- package/dist/References.js.map +1 -1
- package/dist/RegExp.d.ts +10 -14
- package/dist/RegExp.d.ts.map +1 -1
- package/dist/RegExp.js +10 -14
- package/dist/RegExp.js.map +1 -1
- package/dist/Request.d.ts +31 -21
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +25 -19
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +201 -90
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +87 -41
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +302 -470
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +135 -218
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +50 -75
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +39 -60
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +292 -1638
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +164 -805
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +5 -5
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +18 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2056 -1269
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2869 -1136
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +64 -72
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +698 -468
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +236 -188
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +281 -234
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +219 -190
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +303 -309
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +32 -2
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +170 -118
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +433 -1511
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +301 -2854
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +117 -77
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +139 -104
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +123 -151
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +72 -92
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/ScopedRef.d.ts +3 -3
- package/dist/ScopedRef.d.ts.map +1 -1
- package/dist/ScopedRef.js +2 -2
- package/dist/ScopedRef.js.map +1 -1
- package/dist/Semaphore.d.ts +101 -13
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +78 -39
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +118 -108
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +107 -100
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +18 -5
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +6 -3
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +2467 -2962
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1154 -1413
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +262 -308
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +184 -215
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +109 -114
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +46 -54
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +282 -250
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +104 -92
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Symbol.d.ts +3 -3
- package/dist/Symbol.js +3 -3
- package/dist/Symbol.js.map +1 -1
- package/dist/SynchronizedRef.js +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Take.js.map +1 -1
- package/dist/Terminal.d.ts +2 -2
- package/dist/Terminal.js +2 -2
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +100 -54
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +41 -24
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +287 -679
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +109 -251
- package/dist/Trie.js.map +1 -1
- package/dist/Tuple.d.ts +98 -131
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js +42 -57
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +201 -121
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +85 -56
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +62 -46
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +30 -22
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +631 -779
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +268 -330
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +297 -236
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +130 -100
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +126 -95
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +74 -56
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +101 -88
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +87 -66
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +200 -180
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +161 -137
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +89 -114
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +75 -53
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +51 -32
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +23 -15
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +129 -95
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +85 -70
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +97 -70
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +44 -34
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +127 -70
- package/dist/Types.d.ts.map +1 -1
- package/dist/UndefinedOr.js.map +1 -1
- package/dist/Unify.d.ts +45 -65
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js +6 -9
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +23 -16
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +3 -7
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/internal/array.js.map +1 -1
- package/dist/internal/core.js +4 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +5 -1
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/doNotation.js.map +1 -1
- package/dist/internal/effect.js +261 -111
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/executionPlan.js +52 -3
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js +12 -8
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/matcher.js +2 -2
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/persistence.d.ts +2 -0
- package/dist/internal/persistence.d.ts.map +1 -0
- package/dist/internal/persistence.js +3 -0
- package/dist/internal/persistence.js.map +1 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js +18 -13
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/record.d.ts +0 -3
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +10 -5
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/redacted.js.map +1 -1
- package/dist/internal/references.js +3 -4
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js +15 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/cause.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +761 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/fromRepresentation.d.ts +2 -0
- package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/fromRepresentation.js +245 -0
- package/dist/internal/schema/fromRepresentation.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +14 -0
- package/dist/internal/schema/parser.d.ts.map +1 -0
- package/dist/internal/schema/parser.js +13 -0
- package/dist/internal/schema/parser.js.map +1 -0
- package/dist/internal/schema/schema.js +29 -49
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/toArbitrary.d.ts +2 -0
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
- package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -83
- package/dist/internal/schema/toArbitrary.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.d.ts +2 -0
- package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +438 -0
- package/dist/internal/schema/toCodeDocument.js.map +1 -0
- package/dist/internal/schema/toEquivalence.d.ts +2 -0
- package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
- package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
- package/dist/internal/schema/toEquivalence.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +522 -0
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/toRepresentation.d.ts +2 -0
- package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/toRepresentation.js +351 -0
- package/dist/internal/schema/toRepresentation.js.map +1 -0
- package/dist/internal/stackTraceLimit.js +3 -6
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +24 -10
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/FastCheck.d.ts +8 -7
- package/dist/testing/FastCheck.d.ts.map +1 -1
- package/dist/testing/FastCheck.js +8 -7
- package/dist/testing/FastCheck.js.map +1 -1
- package/dist/testing/TestClock.d.ts +57 -28
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +65 -20
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +32 -31
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +24 -22
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +31 -31
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +35 -34
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +121 -144
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +118 -140
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +22 -7
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +87 -317
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +132 -97
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +56 -52
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts +32 -28
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +26 -21
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +111 -68
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +127 -83
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpProtocol.d.ts +30 -0
- package/dist/unstable/ai/McpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/McpProtocol.js +20 -0
- package/dist/unstable/ai/McpProtocol.js.map +1 -0
- package/dist/unstable/ai/McpSchema.d.ts +198 -132
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +79 -71
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +71 -62
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +777 -245
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +8 -19
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +9 -20
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +33 -11
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +194 -378
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +131 -44
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +100 -36
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +47 -33
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +23 -18
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts +46 -13
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +18 -7
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +14 -3
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +10 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +63 -44
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +70 -55
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +35 -9
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +32 -14
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +15 -12
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/mcpProtocol.d.ts +21 -0
- package/dist/unstable/ai/internal/mcpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocol.js +22 -0
- package/dist/unstable/ai/internal/mcpProtocol.js.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts +2 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js +32 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js.map +1 -0
- package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
- package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +315 -0
- package/dist/unstable/ai/internal/structured-output.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +279 -72
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +113 -34
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliConfig.d.ts +76 -0
- package/dist/unstable/cli/CliConfig.d.ts.map +1 -0
- package/dist/unstable/cli/CliConfig.js +63 -0
- package/dist/unstable/cli/CliConfig.js.map +1 -0
- package/dist/unstable/cli/CliError.d.ts +126 -76
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +138 -75
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +35 -54
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -42
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +765 -109
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +335 -52
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +418 -138
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +197 -71
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +24 -3
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +20 -4
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +12 -4
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +299 -83
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +152 -62
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +370 -149
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +377 -162
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -14
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +54 -31
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
- package/dist/unstable/cli/internal/ansi.js +4 -2
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/auto-suggest.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +5 -3
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +21 -13
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js +69 -9
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js +5 -5
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +0 -48
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +8 -10
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts.map +1 -1
- package/dist/unstable/cli/internal/help.js +4 -2
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/lexer.js +17 -7
- package/dist/unstable/cli/internal/lexer.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +16 -7
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.d.ts +13 -0
- package/dist/unstable/cli/internal/wizard.d.ts.map +1 -0
- package/dist/unstable/cli/internal/wizard.js +212 -0
- package/dist/unstable/cli/internal/wizard.js.map +1 -0
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js +7 -7
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterMetrics.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +8 -8
- package/dist/unstable/cluster/ClusterSchema.js +8 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +32 -16
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +12 -12
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +9 -9
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityId.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts +7 -5
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +8 -5
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/EntityType.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +5 -4
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts +2 -2
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +6 -4
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/MachineId.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +9 -9
- package/dist/unstable/cluster/Message.js +6 -6
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +15 -15
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +13 -6
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +8 -0
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +17 -5
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +1 -1
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +2 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +29 -23
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +3 -4
- package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.js +9 -8
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +11 -15
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +32 -22
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +164 -31
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +13 -5
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +3 -3
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/ShardingRegistrationEvent.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js +2 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/Singleton.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +1 -1
- package/dist/unstable/cluster/SingletonAddress.js +1 -1
- package/dist/unstable/cluster/SingletonAddress.js.map +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts +8 -8
- package/dist/unstable/cluster/Snowflake.js +8 -8
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +56 -25
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +141 -79
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/TestRunner.js.map +1 -1
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +25 -13
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/hash.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +2 -2
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +17 -0
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
- package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/shardLock.js +4 -0
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
- package/dist/unstable/devtools/DevTools.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +7 -2
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +8 -5
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/devtools/DevToolsServer.js.map +1 -1
- package/dist/unstable/devtools/index.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +20 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -0
- package/dist/unstable/encoding/Ini.js +153 -0
- package/dist/unstable/encoding/Ini.js.map +1 -0
- package/dist/unstable/encoding/Msgpack.d.ts +2 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +31 -19
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js +7 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +72 -8
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +72 -31
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +19 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -0
- package/dist/unstable/encoding/Toml.js +434 -0
- package/dist/unstable/encoding/Toml.js.map +1 -0
- package/dist/unstable/encoding/Yaml.d.ts +19 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
- package/dist/unstable/encoding/Yaml.js +461 -0
- package/dist/unstable/encoding/Yaml.js.map +1 -0
- package/dist/unstable/encoding/index.d.ts +12 -0
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +12 -0
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +20 -20
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +4 -4
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +17 -17
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +27 -19
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +3 -3
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +18 -14
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +8 -7
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +16 -14
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +31 -31
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +12 -8
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/eventlog/EventLogRemote.js +5 -5
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +11 -2
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +45 -21
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +4 -4
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +16 -7
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +5 -5
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +15 -7
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +3 -6
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +2 -2
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +54 -40
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +1 -1
- package/dist/unstable/http/Etag.js +1 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
- package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
- package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
- package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
- package/dist/unstable/http/FindMyWay.d.ts +33 -8
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +4 -7
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +2 -2
- package/dist/unstable/http/Headers.js +10 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +5 -3
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +11 -5
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +110 -47
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +79 -36
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +16 -12
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +4 -4
- package/dist/unstable/http/HttpClientResponse.js +3 -18
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -9
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +7 -8
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +6 -9
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +6 -9
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +75 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +164 -39
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +76 -0
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +53 -3
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +91 -92
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +78 -79
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +13 -13
- package/dist/unstable/http/HttpServer.js +6 -6
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -2
- package/dist/unstable/http/HttpServerError.js +2 -2
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +4 -4
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +23 -15
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +22 -0
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +17 -5
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +35 -7
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +35 -7
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +28 -9
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +68 -36
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
- package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
- package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
- package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/Search.js +14 -0
- package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
- package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
- package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/headers.js +208 -0
- package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.js +241 -0
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
- package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
- package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
- package/dist/unstable/http/MultipartParser.d.ts +98 -0
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
- package/dist/unstable/http/MultipartParser.js +23 -0
- package/dist/unstable/http/MultipartParser.js.map +1 -0
- package/dist/unstable/http/Template.d.ts.map +1 -1
- package/dist/unstable/http/Template.js +3 -3
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +33 -63
- package/dist/unstable/http/Url.d.ts.map +1 -1
- package/dist/unstable/http/Url.js +14 -28
- package/dist/unstable/http/Url.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +10 -18
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +26 -31
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +1 -1
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.d.ts +2 -0
- package/dist/unstable/http/internal/compression.d.ts.map +1 -0
- package/dist/unstable/http/internal/compression.js +155 -0
- package/dist/unstable/http/internal/compression.js.map +1 -0
- package/dist/unstable/http/internal/httpBody.d.ts +2 -0
- package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +10 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +9 -9
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +82 -30
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -5
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +89 -51
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +48 -46
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +18 -18
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +30 -30
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +15 -15
- package/dist/unstable/httpapi/HttpApiGroup.js +2 -2
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +71 -24
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +57 -10
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +0 -12
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +225 -6
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +174 -4
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +21 -13
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +110 -57
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/index.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -1
- package/dist/unstable/observability/Otlp.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +71 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +86 -7
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +4 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +11 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +31 -15
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts +16 -7
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +21 -12
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +3 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +13 -4
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +10 -3
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/index.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +3 -0
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +8 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +22 -13
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +8 -8
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +2 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +6 -6
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +15 -15
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +3 -3
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +108 -22
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +47 -26
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +31 -47
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +2 -2
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +9 -7
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/persistence/index.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +72 -21
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +14 -5
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +21 -10
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +4 -2
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/process/index.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +8 -8
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +14 -13
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +131 -30
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +53 -34
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +4 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRef.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +25 -4
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +4 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +1 -1
- package/dist/unstable/reactivity/Hydration.js +1 -1
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +35 -33
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -2
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +26 -12
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +40 -22
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js +2 -2
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +8 -8
- package/dist/unstable/rpc/RpcGroup.js +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +31 -30
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +6 -6
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +10 -10
- package/dist/unstable/rpc/RpcMiddleware.js +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +4 -4
- package/dist/unstable/rpc/RpcSchema.js +3 -3
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +58 -7
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +177 -96
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +13 -13
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +20 -15
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcTest.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +5 -5
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/rpc/index.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +53 -51
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +35 -33
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +11 -12
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +28 -17
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/schema/index.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +12 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +38 -17
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/socket/index.js.map +1 -1
- package/dist/unstable/sql/Migrator.d.ts +9 -1
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.js +15 -2
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +2 -3
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +8 -4
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.js +15 -15
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.js +2 -2
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +5 -5
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +30 -24
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/SqlStream.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +6 -6
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +30 -27
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/sql/index.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +2 -2
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +13 -14
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +7 -7
- package/dist/unstable/workers/WorkerError.js +11 -11
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workers/WorkerRunner.d.ts +1 -1
- package/dist/unstable/workers/WorkerRunner.js +1 -1
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workers/index.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.js +2 -2
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +10 -10
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +13 -8
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +22 -20
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +22 -20
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +21 -21
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +13 -14
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +26 -3
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +72 -6
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +4 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/dist/unstable/workflow/index.js.map +1 -1
- package/dist/unstable/workflow/internal/crypto.js.map +1 -1
- package/package.json +12 -16
- package/src/Array.ts +1069 -1071
- package/src/BigDecimal.ts +433 -756
- package/src/BigInt.ts +213 -269
- package/src/Boolean.ts +146 -188
- package/src/Brand.ts +4 -4
- package/src/Cache.ts +469 -851
- package/src/Cause.ts +167 -277
- package/src/Channel.ts +982 -831
- package/src/ChannelSchema.ts +1 -1
- package/src/Chunk.ts +841 -1181
- package/src/Clock.ts +181 -49
- package/src/Combiner.ts +20 -33
- package/src/Config.ts +642 -335
- package/src/ConfigProvider.ts +267 -135
- package/src/Console.ts +289 -39
- package/src/Context.ts +323 -404
- package/src/Cron.ts +271 -219
- package/src/Crypto.ts +30 -23
- package/src/Data.ts +63 -82
- package/src/DateTime.ts +564 -660
- package/src/Deferred.ts +259 -258
- package/src/Duration.ts +244 -311
- package/src/Effect.ts +3215 -3394
- package/src/Encoding.ts +22 -40
- package/src/Equal.ts +59 -41
- package/src/Equivalence.ts +103 -105
- package/src/ErrorReporter.ts +51 -27
- package/src/ExecutionPlan.ts +91 -56
- package/src/Exit.ts +116 -192
- package/src/Fiber.ts +82 -149
- package/src/FiberHandle.ts +155 -107
- package/src/FiberMap.ts +225 -174
- package/src/FiberSet.ts +125 -83
- package/src/FileSystem.ts +156 -264
- package/src/Filter.ts +61 -33
- package/src/Formatter.ts +69 -76
- package/src/Function.ts +119 -151
- package/src/Graph.ts +3258 -1102
- package/src/HKT.ts +12 -6
- package/src/Hash.ts +52 -83
- package/src/HashMap.ts +319 -411
- package/src/HashRing.ts +1 -0
- package/src/HashSet.ts +177 -284
- package/src/Inspectable.ts +22 -20
- package/src/Iterable.ts +665 -799
- package/src/JsonPatch.ts +60 -113
- package/src/JsonPointer.ts +8 -8
- package/src/JsonSchema.ts +408 -251
- package/src/Latch.ts +23 -35
- package/src/Layer.ts +366 -265
- package/src/LayerMap.ts +49 -29
- package/src/LayerRef.ts +6 -2
- package/src/LogLevel.ts +114 -214
- package/src/Logger.ts +348 -700
- package/src/ManagedRuntime.ts +20 -5
- package/src/Match.ts +217 -252
- package/src/Metric.ts +520 -1092
- package/src/MutableHashMap.ts +218 -255
- package/src/MutableHashSet.ts +84 -89
- package/src/MutableList.ts +77 -370
- package/src/MutableRef.ts +420 -243
- package/src/Newtype.ts +21 -14
- package/src/NonEmptyIterable.ts +7 -137
- package/src/Number.ts +196 -233
- package/src/Optic.ts +303 -441
- package/src/Option.ts +449 -813
- package/src/Order.ts +109 -109
- package/src/Ordering.ts +20 -23
- package/src/PartitionedSemaphore.ts +1 -4
- package/src/Path.ts +38 -41
- package/src/Pipeable.ts +6 -5
- package/src/PlatformError.ts +4 -4
- package/src/Pool.ts +4 -2
- package/src/Predicate.ts +200 -181
- package/src/PrimaryKey.ts +7 -7
- package/src/PubSub.ts +526 -552
- package/src/Pull.ts +24 -18
- package/src/Queue.ts +204 -165
- package/src/Random.ts +49 -74
- package/src/RcMap.ts +121 -63
- package/src/RcRef.ts +24 -13
- package/src/Record.ts +387 -487
- package/src/Redactable.ts +10 -3
- package/src/Redacted.ts +25 -25
- package/src/Reducer.ts +8 -15
- package/src/Ref.ts +221 -361
- package/src/References.ts +102 -214
- package/src/RegExp.ts +10 -14
- package/src/Request.ts +36 -28
- package/src/RequestResolver.ts +202 -91
- package/src/Result.ts +314 -485
- package/src/Runtime.ts +50 -75
- package/src/Schedule.ts +311 -1737
- package/src/Scheduler.ts +20 -7
- package/src/Schema.ts +3476 -1914
- package/src/SchemaAST.ts +902 -573
- package/src/SchemaGetter.ts +351 -233
- package/src/SchemaIssue.ts +367 -334
- package/src/SchemaParser.ts +254 -148
- package/src/SchemaRepresentation.ts +732 -3414
- package/src/SchemaTransformation.ts +186 -97
- package/src/Scope.ts +123 -151
- package/src/ScopedCache.ts +1 -1
- package/src/ScopedRef.ts +6 -4
- package/src/Semaphore.ts +157 -54
- package/src/Sink.ts +129 -114
- package/src/Stdio.ts +24 -5
- package/src/Stream.ts +2745 -3173
- package/src/String.ts +275 -312
- package/src/Struct.ts +114 -118
- package/src/SubscriptionRef.ts +284 -252
- package/src/Symbol.ts +3 -3
- package/src/SynchronizedRef.ts +1 -1
- package/src/Terminal.ts +3 -3
- package/src/Tracer.ts +102 -55
- package/src/Trie.ts +287 -679
- package/src/Tuple.ts +99 -131
- package/src/TxChunk.ts +201 -121
- package/src/TxDeferred.ts +62 -46
- package/src/TxHashMap.ts +645 -799
- package/src/TxHashSet.ts +443 -356
- package/src/TxPriorityQueue.ts +130 -98
- package/src/TxPubSub.ts +107 -80
- package/src/TxQueue.ts +215 -184
- package/src/TxReentrantLock.ts +136 -101
- package/src/TxRef.ts +51 -32
- package/src/TxSemaphore.ts +129 -95
- package/src/TxSubscriptionRef.ts +97 -70
- package/src/Types.ts +127 -70
- package/src/Unify.ts +45 -65
- package/src/Utils.ts +23 -16
- package/src/index.ts +0 -10
- package/src/internal/core.ts +6 -5
- package/src/internal/dateTime.ts +7 -1
- package/src/internal/effect.ts +313 -137
- package/src/internal/executionPlan.ts +106 -10
- package/src/internal/hashMap.ts +20 -14
- package/src/internal/matcher.ts +3 -3
- package/src/internal/persistence.ts +2 -0
- package/src/internal/rcRef.ts +24 -16
- package/src/internal/record.ts +11 -7
- package/src/internal/references.ts +3 -7
- package/src/internal/schedule.ts +4 -4
- package/src/internal/schema/annotations.ts +48 -1
- package/src/internal/schema/fromJsonSchemaDocument.ts +977 -0
- package/src/internal/schema/fromRepresentation.ts +339 -0
- package/src/internal/schema/parser.ts +22 -0
- package/src/internal/schema/schema.ts +46 -63
- package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +9 -81
- package/src/internal/schema/toCodeDocument.ts +572 -0
- package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
- package/src/internal/schema/toJsonSchemaDocument.ts +549 -0
- package/src/internal/schema/toRepresentation.ts +404 -0
- package/src/internal/stackTraceLimit.ts +3 -7
- package/src/internal/trie.ts +21 -12
- package/src/testing/FastCheck.ts +8 -7
- package/src/testing/TestClock.ts +86 -32
- package/src/testing/TestConsole.ts +32 -31
- package/src/testing/TestSchema.ts +40 -40
- package/src/unstable/ai/AiError.ts +119 -141
- package/src/unstable/ai/AnthropicStructuredOutput.ts +103 -334
- package/src/unstable/ai/Chat.ts +133 -98
- package/src/unstable/ai/EmbeddingModel.ts +1 -1
- package/src/unstable/ai/IdGenerator.ts +32 -28
- package/src/unstable/ai/LanguageModel.ts +141 -97
- package/src/unstable/ai/McpProtocol.ts +48 -0
- package/src/unstable/ai/McpSchema.ts +92 -81
- package/src/unstable/ai/McpServer.ts +1057 -303
- package/src/unstable/ai/Model.ts +9 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +231 -396
- package/src/unstable/ai/Prompt.ts +212 -63
- package/src/unstable/ai/Response.ts +52 -38
- package/src/unstable/ai/Telemetry.ts +46 -13
- package/src/unstable/ai/Tokenizer.ts +14 -3
- package/src/unstable/ai/Tool.ts +94 -64
- package/src/unstable/ai/Toolkit.ts +45 -15
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/ai/internal/codec-transformer.ts +13 -7
- package/src/unstable/ai/internal/mcpProtocol.ts +85 -0
- package/src/unstable/ai/internal/mcpProtocolRegistry.ts +70 -0
- package/src/unstable/ai/internal/structured-output.ts +453 -0
- package/src/unstable/cli/Argument.ts +279 -72
- package/src/unstable/cli/CliConfig.ts +85 -0
- package/src/unstable/cli/CliError.ts +161 -90
- package/src/unstable/cli/CliOutput.ts +44 -58
- package/src/unstable/cli/Command.ts +839 -123
- package/src/unstable/cli/Flag.ts +418 -138
- package/src/unstable/cli/GlobalFlag.ts +34 -6
- package/src/unstable/cli/HelpDoc.ts +12 -4
- package/src/unstable/cli/Param.ts +351 -103
- package/src/unstable/cli/Primitive.ts +383 -156
- package/src/unstable/cli/Prompt.ts +64 -34
- package/src/unstable/cli/index.ts +5 -0
- package/src/unstable/cli/internal/ansi.ts +5 -2
- package/src/unstable/cli/internal/command.ts +28 -15
- package/src/unstable/cli/internal/completions/bash.ts +59 -9
- package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
- package/src/unstable/cli/internal/completions/fish.ts +5 -7
- package/src/unstable/cli/internal/config.ts +8 -10
- package/src/unstable/cli/internal/help.ts +4 -2
- package/src/unstable/cli/internal/lexer.ts +8 -2
- package/src/unstable/cli/internal/parser.ts +19 -7
- package/src/unstable/cli/internal/wizard.ts +283 -0
- package/src/unstable/cluster/ClusterError.ts +7 -7
- package/src/unstable/cluster/ClusterSchema.ts +8 -8
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +36 -20
- package/src/unstable/cluster/Entity.ts +23 -19
- package/src/unstable/cluster/EntityProxy.ts +16 -7
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/Envelope.ts +5 -4
- package/src/unstable/cluster/HttpRunner.ts +6 -4
- package/src/unstable/cluster/Message.ts +9 -9
- package/src/unstable/cluster/MessageStorage.ts +24 -20
- package/src/unstable/cluster/Reply.ts +26 -7
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/RunnerHealth.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +45 -18
- package/src/unstable/cluster/RunnerStorage.ts +12 -10
- package/src/unstable/cluster/Runners.ts +48 -26
- package/src/unstable/cluster/ShardId.ts +1 -1
- package/src/unstable/cluster/Sharding.ts +223 -55
- package/src/unstable/cluster/ShardingConfig.ts +8 -4
- package/src/unstable/cluster/SingleRunner.ts +4 -2
- package/src/unstable/cluster/SingletonAddress.ts +1 -1
- package/src/unstable/cluster/Snowflake.ts +8 -8
- package/src/unstable/cluster/SqlMessageStorage.ts +84 -36
- package/src/unstable/cluster/SqlRunnerStorage.ts +223 -133
- package/src/unstable/cluster/internal/entityManager.ts +43 -26
- package/src/unstable/cluster/internal/resourceMap.ts +5 -2
- package/src/unstable/cluster/internal/resourceRef.ts +27 -5
- package/src/unstable/cluster/internal/shardLock.ts +9 -0
- package/src/unstable/devtools/DevToolsClient.ts +3 -2
- package/src/unstable/devtools/DevToolsSchema.ts +10 -5
- package/src/unstable/encoding/Ini.ts +174 -0
- package/src/unstable/encoding/Msgpack.ts +61 -40
- package/src/unstable/encoding/Ndjson.ts +9 -1
- package/src/unstable/encoding/Sse.ts +109 -37
- package/src/unstable/encoding/Toml.ts +504 -0
- package/src/unstable/encoding/Yaml.ts +541 -0
- package/src/unstable/encoding/index.ts +15 -0
- package/src/unstable/eventlog/Event.ts +20 -20
- package/src/unstable/eventlog/EventGroup.ts +4 -4
- package/src/unstable/eventlog/EventJournal.ts +30 -22
- package/src/unstable/eventlog/EventLog.ts +24 -14
- package/src/unstable/eventlog/EventLogEncryption.ts +17 -18
- package/src/unstable/eventlog/EventLogMessage.ts +15 -9
- package/src/unstable/eventlog/EventLogRemote.ts +5 -5
- package/src/unstable/eventlog/EventLogServer.ts +41 -7
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +15 -7
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +15 -7
- package/src/unstable/eventlog/EventLogSessionAuth.ts +1 -1
- package/src/unstable/eventlog/SqlEventJournal.ts +8 -6
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
- package/src/unstable/http/Cookies.ts +64 -45
- package/src/unstable/http/Etag.ts +1 -1
- package/src/unstable/http/FetchHttpClient.ts +3 -1
- package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
- package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
- package/src/unstable/http/FindMyWay.ts +65 -6
- package/src/unstable/http/Headers.ts +10 -10
- package/src/unstable/http/HttpBody.ts +20 -5
- package/src/unstable/http/HttpClient.ts +215 -78
- package/src/unstable/http/HttpClientError.ts +1 -1
- package/src/unstable/http/HttpClientRequest.ts +59 -12
- package/src/unstable/http/HttpClientResponse.ts +5 -21
- package/src/unstable/http/HttpEffect.ts +20 -19
- package/src/unstable/http/HttpMethod.ts +6 -9
- package/src/unstable/http/HttpMiddleware.ts +202 -39
- package/src/unstable/http/HttpPlatform.ts +129 -6
- package/src/unstable/http/HttpRouter.ts +109 -101
- package/src/unstable/http/HttpServer.ts +13 -13
- package/src/unstable/http/HttpServerError.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +31 -17
- package/src/unstable/http/HttpServerResponse.ts +38 -6
- package/src/unstable/http/HttpStaticServer.ts +35 -7
- package/src/unstable/http/Multipart.ts +70 -37
- package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
- package/src/unstable/http/MultipartParser/Search.ts +17 -0
- package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
- package/src/unstable/http/MultipartParser/internal/headers.ts +244 -0
- package/src/unstable/http/MultipartParser/internal/multipart.ts +279 -0
- package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
- package/src/unstable/http/MultipartParser.ts +115 -0
- package/src/unstable/http/Template.ts +7 -6
- package/src/unstable/http/Url.ts +33 -63
- package/src/unstable/http/UrlParams.ts +27 -32
- package/src/unstable/http/index.ts +1 -1
- package/src/unstable/http/internal/compression.ts +196 -0
- package/src/unstable/http/internal/httpBody.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +10 -11
- package/src/unstable/httpapi/HttpApiBuilder.ts +155 -34
- package/src/unstable/httpapi/HttpApiClient.ts +142 -61
- package/src/unstable/httpapi/HttpApiEndpoint.ts +159 -71
- package/src/unstable/httpapi/HttpApiError.ts +46 -52
- package/src/unstable/httpapi/HttpApiGroup.ts +17 -17
- package/src/unstable/httpapi/HttpApiMiddleware.ts +71 -24
- package/src/unstable/httpapi/HttpApiScalar.ts +0 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +359 -6
- package/src/unstable/httpapi/OpenApi.ts +153 -62
- package/src/unstable/observability/OtlpExporter.ts +130 -12
- package/src/unstable/observability/OtlpLogger.ts +8 -6
- package/src/unstable/observability/OtlpMetrics.ts +42 -21
- package/src/unstable/observability/OtlpResource.ts +26 -17
- package/src/unstable/observability/OtlpTracer.ts +9 -5
- package/src/unstable/observability/PrometheusMetrics.ts +13 -4
- package/src/unstable/observability/internal/otlpEnv.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +3 -0
- package/src/unstable/persistence/KeyValueStore.ts +72 -49
- package/src/unstable/persistence/Persistable.ts +11 -10
- package/src/unstable/persistence/PersistedQueue.ts +18 -15
- package/src/unstable/persistence/Persistence.ts +153 -26
- package/src/unstable/persistence/RateLimiter.ts +79 -45
- package/src/unstable/persistence/Redis.ts +14 -9
- package/src/unstable/process/ChildProcess.ts +72 -21
- package/src/unstable/process/ChildProcessSpawner.ts +22 -11
- package/src/unstable/reactivity/AsyncResult.ts +23 -18
- package/src/unstable/reactivity/Atom.ts +161 -47
- package/src/unstable/reactivity/AtomHttpApi.ts +5 -4
- package/src/unstable/reactivity/AtomRegistry.ts +25 -4
- package/src/unstable/reactivity/AtomRpc.ts +5 -4
- package/src/unstable/reactivity/Hydration.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +35 -33
- package/src/unstable/rpc/RpcClient.ts +65 -29
- package/src/unstable/rpc/RpcClientError.ts +2 -2
- package/src/unstable/rpc/RpcGroup.ts +8 -8
- package/src/unstable/rpc/RpcMessage.ts +31 -30
- package/src/unstable/rpc/RpcMiddleware.ts +10 -10
- package/src/unstable/rpc/RpcSchema.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +167 -68
- package/src/unstable/rpc/RpcServer.ts +22 -17
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/schema/Model.ts +52 -50
- package/src/unstable/schema/VariantSchema.ts +51 -43
- package/src/unstable/socket/Socket.ts +42 -19
- package/src/unstable/sql/Migrator.ts +22 -9
- package/src/unstable/sql/SqlClient.ts +65 -58
- package/src/unstable/sql/SqlError.ts +15 -15
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +41 -31
- package/src/unstable/sql/Statement.ts +44 -37
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +15 -16
- package/src/unstable/workers/WorkerError.ts +12 -12
- package/src/unstable/workers/WorkerRunner.ts +1 -1
- package/src/unstable/workflow/Activity.ts +2 -2
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +18 -13
- package/src/unstable/workflow/DurableQueue.ts +22 -20
- package/src/unstable/workflow/Workflow.ts +23 -26
- package/src/unstable/workflow/WorkflowEngine.ts +111 -8
- package/src/unstable/workflow/WorkflowProxy.ts +4 -2
- package/dist/SchemaError.d.ts +0 -53
- package/dist/SchemaError.d.ts.map +0 -1
- package/dist/SchemaError.js +0 -61
- package/dist/SchemaError.js.map +0 -1
- package/dist/SchemaUtils.d.ts +0 -28
- package/dist/SchemaUtils.d.ts.map +0 -1
- package/dist/SchemaUtils.js +0 -45
- package/dist/SchemaUtils.js.map +0 -1
- package/dist/internal/schema/arbitrary.d.ts +0 -5
- package/dist/internal/schema/arbitrary.d.ts.map +0 -1
- package/dist/internal/schema/arbitrary.js.map +0 -1
- package/dist/internal/schema/equivalence.d.ts +0 -2
- package/dist/internal/schema/equivalence.d.ts.map +0 -1
- package/dist/internal/schema/equivalence.js.map +0 -1
- package/dist/internal/schema/representation.d.ts +0 -2
- package/dist/internal/schema/representation.d.ts.map +0 -1
- package/dist/internal/schema/representation.js +0 -865
- package/dist/internal/schema/representation.js.map +0 -1
- package/dist/internal/version.d.ts +0 -3
- package/dist/internal/version.d.ts.map +0 -1
- package/dist/internal/version.js +0 -2
- package/dist/internal/version.js.map +0 -1
- package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
- package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
- package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
- package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Node.js +0 -14
- package/dist/unstable/http/Multipasta/Node.js.map +0 -1
- package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Search.js +0 -14
- package/dist/unstable/http/Multipasta/Search.js.map +0 -1
- package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
- package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta/Web.js +0 -14
- package/dist/unstable/http/Multipasta/Web.js.map +0 -1
- package/dist/unstable/http/Multipasta.d.ts +0 -15
- package/dist/unstable/http/Multipasta.d.ts.map +0 -1
- package/dist/unstable/http/Multipasta.js +0 -15
- package/dist/unstable/http/Multipasta.js.map +0 -1
- package/src/SchemaError.ts +0 -64
- package/src/SchemaUtils.ts +0 -51
- package/src/internal/schema/representation.ts +0 -795
- package/src/internal/version.ts +0 -2
- package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
- package/src/unstable/http/Multipasta/Node.ts +0 -14
- package/src/unstable/http/Multipasta/Search.ts +0 -14
- package/src/unstable/http/Multipasta/Web.ts +0 -14
- package/src/unstable/http/Multipasta.ts +0 -15
package/src/Iterable.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import type { NonEmptyArray } from "./Array.ts"
|
|
13
13
|
import * as Equal from "./Equal.ts"
|
|
14
14
|
import { dual } from "./Function.ts"
|
|
15
|
+
import * as InternalRecord from "./internal/record.ts"
|
|
15
16
|
import type { Option } from "./Option.ts"
|
|
16
17
|
import * as O from "./Option.ts"
|
|
17
18
|
import { isBoolean } from "./Predicate.ts"
|
|
@@ -32,21 +33,21 @@ import type { NoInfer } from "./Types.ts"
|
|
|
32
33
|
*
|
|
33
34
|
* **Example** (Generating values by index)
|
|
34
35
|
*
|
|
35
|
-
* ```ts
|
|
36
|
+
* ```ts import.meta.vitest
|
|
36
37
|
* import { Iterable } from "effect"
|
|
37
38
|
*
|
|
38
39
|
* // Generate first 5 even numbers
|
|
39
40
|
* const evens = Iterable.makeBy((n) => n * 2, { length: 5 })
|
|
40
|
-
*
|
|
41
|
+
* Array.from(evens) // => [0, 2, 4, 6, 8]
|
|
41
42
|
*
|
|
42
43
|
* // Generate squares
|
|
43
44
|
* const squares = Iterable.makeBy((n) => n * n, { length: 4 })
|
|
44
|
-
*
|
|
45
|
+
* Array.from(squares) // => [0, 1, 4, 9]
|
|
45
46
|
*
|
|
46
47
|
* // Infinite sequence (be careful when consuming!)
|
|
47
48
|
* const naturals = Iterable.makeBy((n) => n)
|
|
48
49
|
* const first10 = Iterable.take(naturals, 10)
|
|
49
|
-
*
|
|
50
|
+
* Array.from(first10) // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
50
51
|
* ```
|
|
51
52
|
*
|
|
52
53
|
* @category constructors
|
|
@@ -82,11 +83,10 @@ export const makeBy = <A>(f: (i: number) => A, options?: {
|
|
|
82
83
|
*
|
|
83
84
|
* **Example** (Creating a range)
|
|
84
85
|
*
|
|
85
|
-
* ```ts
|
|
86
|
+
* ```ts import.meta.vitest
|
|
86
87
|
* import { Iterable } from "effect"
|
|
87
|
-
* import * as assert from "node:assert"
|
|
88
88
|
*
|
|
89
|
-
*
|
|
89
|
+
* Array.from(Iterable.range(1, 3)) // => [1, 2, 3]
|
|
90
90
|
* ```
|
|
91
91
|
*
|
|
92
92
|
* @category constructors
|
|
@@ -110,11 +110,10 @@ export const range = (start: number, end?: number): Iterable<number> => {
|
|
|
110
110
|
*
|
|
111
111
|
* **Example** (Repeating a value)
|
|
112
112
|
*
|
|
113
|
-
* ```ts
|
|
113
|
+
* ```ts import.meta.vitest
|
|
114
114
|
* import { Iterable } from "effect"
|
|
115
|
-
* import * as assert from "node:assert"
|
|
116
115
|
*
|
|
117
|
-
*
|
|
116
|
+
* Array.from(Iterable.replicate("a", 3)) // => ["a", "a", "a"]
|
|
118
117
|
* ```
|
|
119
118
|
*
|
|
120
119
|
* @category constructors
|
|
@@ -130,11 +129,10 @@ export const replicate: {
|
|
|
130
129
|
*
|
|
131
130
|
* **Example** (Repeating a value)
|
|
132
131
|
*
|
|
133
|
-
* ```ts
|
|
132
|
+
* ```ts import.meta.vitest
|
|
134
133
|
* import { Iterable } from "effect"
|
|
135
|
-
* import * as assert from "node:assert"
|
|
136
134
|
*
|
|
137
|
-
*
|
|
135
|
+
* Array.from(Iterable.replicate("a", 3)) // => ["a", "a", "a"]
|
|
138
136
|
* ```
|
|
139
137
|
*
|
|
140
138
|
* @category constructors
|
|
@@ -150,11 +148,10 @@ export const replicate: {
|
|
|
150
148
|
*
|
|
151
149
|
* **Example** (Repeating a value)
|
|
152
150
|
*
|
|
153
|
-
* ```ts
|
|
151
|
+
* ```ts import.meta.vitest
|
|
154
152
|
* import { Iterable } from "effect"
|
|
155
|
-
* import * as assert from "node:assert"
|
|
156
153
|
*
|
|
157
|
-
*
|
|
154
|
+
* Array.from(Iterable.replicate("a", 3)) // => ["a", "a", "a"]
|
|
158
155
|
* ```
|
|
159
156
|
*
|
|
160
157
|
* @category constructors
|
|
@@ -245,15 +242,11 @@ export const forever = <A>(self: Iterable<A>): Iterable<A> => repeat(self, Infin
|
|
|
245
242
|
*
|
|
246
243
|
* **Example** (Converting a record to entries)
|
|
247
244
|
*
|
|
248
|
-
* ```ts
|
|
245
|
+
* ```ts import.meta.vitest
|
|
249
246
|
* import { Iterable } from "effect"
|
|
250
|
-
* import * as assert from "node:assert"
|
|
251
247
|
*
|
|
252
248
|
* const x = { a: 1, b: 2, c: 3 }
|
|
253
|
-
*
|
|
254
|
-
* "c",
|
|
255
|
-
* 3
|
|
256
|
-
* ]])
|
|
249
|
+
* Array.from(Iterable.fromRecord(x)) // => [["a", 1], ["b", 2], ["c", 3]]
|
|
257
250
|
* ```
|
|
258
251
|
*
|
|
259
252
|
* @category converting
|
|
@@ -274,17 +267,17 @@ export const fromRecord = <K extends string, A>(self: Readonly<Record<K, A>>): I
|
|
|
274
267
|
*
|
|
275
268
|
* **Example** (Prepending an element)
|
|
276
269
|
*
|
|
277
|
-
* ```ts
|
|
270
|
+
* ```ts import.meta.vitest
|
|
278
271
|
* import { Iterable } from "effect"
|
|
279
272
|
*
|
|
280
273
|
* const numbers = [2, 3, 4]
|
|
281
274
|
* const withOne = Iterable.prepend(numbers, 1)
|
|
282
|
-
*
|
|
275
|
+
* Array.from(withOne) // => [1, 2, 3, 4]
|
|
283
276
|
*
|
|
284
277
|
* // Works with any iterable
|
|
285
278
|
* const letters = "abc"
|
|
286
279
|
* const withZ = Iterable.prepend(letters, "z")
|
|
287
|
-
*
|
|
280
|
+
* Array.from(withZ) // => ["z", "a", "b", "c"]
|
|
288
281
|
* ```
|
|
289
282
|
*
|
|
290
283
|
* @category combining
|
|
@@ -296,17 +289,17 @@ export const prepend: {
|
|
|
296
289
|
*
|
|
297
290
|
* **Example** (Prepending an element)
|
|
298
291
|
*
|
|
299
|
-
* ```ts
|
|
292
|
+
* ```ts import.meta.vitest
|
|
300
293
|
* import { Iterable } from "effect"
|
|
301
294
|
*
|
|
302
295
|
* const numbers = [2, 3, 4]
|
|
303
296
|
* const withOne = Iterable.prepend(numbers, 1)
|
|
304
|
-
*
|
|
297
|
+
* Array.from(withOne) // => [1, 2, 3, 4]
|
|
305
298
|
*
|
|
306
299
|
* // Works with any iterable
|
|
307
300
|
* const letters = "abc"
|
|
308
301
|
* const withZ = Iterable.prepend(letters, "z")
|
|
309
|
-
*
|
|
302
|
+
* Array.from(withZ) // => ["z", "a", "b", "c"]
|
|
310
303
|
* ```
|
|
311
304
|
*
|
|
312
305
|
* @category combining
|
|
@@ -318,17 +311,17 @@ export const prepend: {
|
|
|
318
311
|
*
|
|
319
312
|
* **Example** (Prepending an element)
|
|
320
313
|
*
|
|
321
|
-
* ```ts
|
|
314
|
+
* ```ts import.meta.vitest
|
|
322
315
|
* import { Iterable } from "effect"
|
|
323
316
|
*
|
|
324
317
|
* const numbers = [2, 3, 4]
|
|
325
318
|
* const withOne = Iterable.prepend(numbers, 1)
|
|
326
|
-
*
|
|
319
|
+
* Array.from(withOne) // => [1, 2, 3, 4]
|
|
327
320
|
*
|
|
328
321
|
* // Works with any iterable
|
|
329
322
|
* const letters = "abc"
|
|
330
323
|
* const withZ = Iterable.prepend(letters, "z")
|
|
331
|
-
*
|
|
324
|
+
* Array.from(withZ) // => ["z", "a", "b", "c"]
|
|
332
325
|
* ```
|
|
333
326
|
*
|
|
334
327
|
* @category combining
|
|
@@ -342,14 +335,10 @@ export const prepend: {
|
|
|
342
335
|
*
|
|
343
336
|
* **Example** (Prepending another iterable)
|
|
344
337
|
*
|
|
345
|
-
* ```ts
|
|
338
|
+
* ```ts import.meta.vitest
|
|
346
339
|
* import { Iterable } from "effect"
|
|
347
|
-
* import * as assert from "node:assert"
|
|
348
340
|
*
|
|
349
|
-
*
|
|
350
|
-
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
|
|
351
|
-
* ["a", "b", 1, 2]
|
|
352
|
-
* )
|
|
341
|
+
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])) // => ["a", "b", 1, 2]
|
|
353
342
|
* ```
|
|
354
343
|
*
|
|
355
344
|
* @category combining
|
|
@@ -361,14 +350,10 @@ export const prependAll: {
|
|
|
361
350
|
*
|
|
362
351
|
* **Example** (Prepending another iterable)
|
|
363
352
|
*
|
|
364
|
-
* ```ts
|
|
353
|
+
* ```ts import.meta.vitest
|
|
365
354
|
* import { Iterable } from "effect"
|
|
366
|
-
* import * as assert from "node:assert"
|
|
367
355
|
*
|
|
368
|
-
*
|
|
369
|
-
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
|
|
370
|
-
* ["a", "b", 1, 2]
|
|
371
|
-
* )
|
|
356
|
+
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])) // => ["a", "b", 1, 2]
|
|
372
357
|
* ```
|
|
373
358
|
*
|
|
374
359
|
* @category combining
|
|
@@ -380,14 +365,10 @@ export const prependAll: {
|
|
|
380
365
|
*
|
|
381
366
|
* **Example** (Prepending another iterable)
|
|
382
367
|
*
|
|
383
|
-
* ```ts
|
|
368
|
+
* ```ts import.meta.vitest
|
|
384
369
|
* import { Iterable } from "effect"
|
|
385
|
-
* import * as assert from "node:assert"
|
|
386
370
|
*
|
|
387
|
-
*
|
|
388
|
-
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
|
|
389
|
-
* ["a", "b", 1, 2]
|
|
390
|
-
* )
|
|
371
|
+
* Array.from(Iterable.prependAll([1, 2], ["a", "b"])) // => ["a", "b", 1, 2]
|
|
391
372
|
* ```
|
|
392
373
|
*
|
|
393
374
|
* @category combining
|
|
@@ -419,19 +400,11 @@ export const prependAll: {
|
|
|
419
400
|
*
|
|
420
401
|
* **Example** (Appending an element)
|
|
421
402
|
*
|
|
422
|
-
* ```ts
|
|
403
|
+
* ```ts import.meta.vitest
|
|
423
404
|
* import { Iterable } from "effect"
|
|
424
405
|
*
|
|
425
406
|
* const numbers = [1, 2, 3]
|
|
426
|
-
*
|
|
427
|
-
* console.log(Array.from(withFour)) // [1, 2, 3, 4]
|
|
428
|
-
*
|
|
429
|
-
* // Chain multiple appends
|
|
430
|
-
* const result = Iterable.append(
|
|
431
|
-
* Iterable.append([1, 2], 3),
|
|
432
|
-
* 4
|
|
433
|
-
* )
|
|
434
|
-
* console.log(Array.from(result)) // [1, 2, 3, 4]
|
|
407
|
+
* Array.from(Iterable.append(numbers, 4)) // => [1, 2, 3, 4]
|
|
435
408
|
* ```
|
|
436
409
|
*
|
|
437
410
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -461,19 +434,11 @@ export const append: {
|
|
|
461
434
|
*
|
|
462
435
|
* **Example** (Appending an element)
|
|
463
436
|
*
|
|
464
|
-
* ```ts
|
|
437
|
+
* ```ts import.meta.vitest
|
|
465
438
|
* import { Iterable } from "effect"
|
|
466
439
|
*
|
|
467
440
|
* const numbers = [1, 2, 3]
|
|
468
|
-
*
|
|
469
|
-
* console.log(Array.from(withFour)) // [1, 2, 3, 4]
|
|
470
|
-
*
|
|
471
|
-
* // Chain multiple appends
|
|
472
|
-
* const result = Iterable.append(
|
|
473
|
-
* Iterable.append([1, 2], 3),
|
|
474
|
-
* 4
|
|
475
|
-
* )
|
|
476
|
-
* console.log(Array.from(result)) // [1, 2, 3, 4]
|
|
441
|
+
* Array.from(Iterable.append(numbers, 4)) // => [1, 2, 3, 4]
|
|
477
442
|
* ```
|
|
478
443
|
*
|
|
479
444
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -503,19 +468,11 @@ export const append: {
|
|
|
503
468
|
*
|
|
504
469
|
* **Example** (Appending an element)
|
|
505
470
|
*
|
|
506
|
-
* ```ts
|
|
471
|
+
* ```ts import.meta.vitest
|
|
507
472
|
* import { Iterable } from "effect"
|
|
508
473
|
*
|
|
509
474
|
* const numbers = [1, 2, 3]
|
|
510
|
-
*
|
|
511
|
-
* console.log(Array.from(withFour)) // [1, 2, 3, 4]
|
|
512
|
-
*
|
|
513
|
-
* // Chain multiple appends
|
|
514
|
-
* const result = Iterable.append(
|
|
515
|
-
* Iterable.append([1, 2], 3),
|
|
516
|
-
* 4
|
|
517
|
-
* )
|
|
518
|
-
* console.log(Array.from(result)) // [1, 2, 3, 4]
|
|
475
|
+
* Array.from(Iterable.append(numbers, 4)) // => [1, 2, 3, 4]
|
|
519
476
|
* ```
|
|
520
477
|
*
|
|
521
478
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -546,25 +503,21 @@ export const append: {
|
|
|
546
503
|
*
|
|
547
504
|
* **Example** (Concatenating iterables)
|
|
548
505
|
*
|
|
549
|
-
* ```ts
|
|
506
|
+
* ```ts import.meta.vitest
|
|
550
507
|
* import { Iterable } from "effect"
|
|
551
508
|
*
|
|
552
|
-
*
|
|
553
|
-
* const second = [4, 5, 6]
|
|
554
|
-
* const combined = Iterable.appendAll(first, second)
|
|
555
|
-
* console.log(Array.from(combined)) // [1, 2, 3, 4, 5, 6]
|
|
509
|
+
* Array.from(Iterable.appendAll([1, 2, 3], [4, 5, 6])) // => [1, 2, 3, 4, 5, 6]
|
|
556
510
|
*
|
|
557
511
|
* // Works with different iterable types
|
|
558
512
|
* const numbers = [1, 2]
|
|
559
513
|
* const letters = "abc"
|
|
560
514
|
* const mixed = Iterable.appendAll(numbers, letters)
|
|
561
|
-
*
|
|
515
|
+
* Array.from(mixed) // => [1, 2, "a", "b", "c"]
|
|
562
516
|
*
|
|
563
517
|
* // Lazy evaluation - only consumes what's needed
|
|
564
518
|
* const infinite = Iterable.range(1)
|
|
565
519
|
* const finite = [0, -1, -2]
|
|
566
|
-
*
|
|
567
|
-
* console.log(Array.from(result)) // [0, -1, -2, 1, 2]
|
|
520
|
+
* Array.from(Iterable.take(Iterable.appendAll(finite, infinite), 5)) // => [0, -1, -2, 1, 2]
|
|
568
521
|
* ```
|
|
569
522
|
*
|
|
570
523
|
* @see {@link append} for appending one value instead of another iterable
|
|
@@ -593,25 +546,21 @@ export const appendAll: {
|
|
|
593
546
|
*
|
|
594
547
|
* **Example** (Concatenating iterables)
|
|
595
548
|
*
|
|
596
|
-
* ```ts
|
|
549
|
+
* ```ts import.meta.vitest
|
|
597
550
|
* import { Iterable } from "effect"
|
|
598
551
|
*
|
|
599
|
-
*
|
|
600
|
-
* const second = [4, 5, 6]
|
|
601
|
-
* const combined = Iterable.appendAll(first, second)
|
|
602
|
-
* console.log(Array.from(combined)) // [1, 2, 3, 4, 5, 6]
|
|
552
|
+
* Array.from(Iterable.appendAll([1, 2, 3], [4, 5, 6])) // => [1, 2, 3, 4, 5, 6]
|
|
603
553
|
*
|
|
604
554
|
* // Works with different iterable types
|
|
605
555
|
* const numbers = [1, 2]
|
|
606
556
|
* const letters = "abc"
|
|
607
557
|
* const mixed = Iterable.appendAll(numbers, letters)
|
|
608
|
-
*
|
|
558
|
+
* Array.from(mixed) // => [1, 2, "a", "b", "c"]
|
|
609
559
|
*
|
|
610
560
|
* // Lazy evaluation - only consumes what's needed
|
|
611
561
|
* const infinite = Iterable.range(1)
|
|
612
562
|
* const finite = [0, -1, -2]
|
|
613
|
-
*
|
|
614
|
-
* console.log(Array.from(result)) // [0, -1, -2, 1, 2]
|
|
563
|
+
* Array.from(Iterable.take(Iterable.appendAll(finite, infinite), 5)) // => [0, -1, -2, 1, 2]
|
|
615
564
|
* ```
|
|
616
565
|
*
|
|
617
566
|
* @see {@link append} for appending one value instead of another iterable
|
|
@@ -640,25 +589,21 @@ export const appendAll: {
|
|
|
640
589
|
*
|
|
641
590
|
* **Example** (Concatenating iterables)
|
|
642
591
|
*
|
|
643
|
-
* ```ts
|
|
592
|
+
* ```ts import.meta.vitest
|
|
644
593
|
* import { Iterable } from "effect"
|
|
645
594
|
*
|
|
646
|
-
*
|
|
647
|
-
* const second = [4, 5, 6]
|
|
648
|
-
* const combined = Iterable.appendAll(first, second)
|
|
649
|
-
* console.log(Array.from(combined)) // [1, 2, 3, 4, 5, 6]
|
|
595
|
+
* Array.from(Iterable.appendAll([1, 2, 3], [4, 5, 6])) // => [1, 2, 3, 4, 5, 6]
|
|
650
596
|
*
|
|
651
597
|
* // Works with different iterable types
|
|
652
598
|
* const numbers = [1, 2]
|
|
653
599
|
* const letters = "abc"
|
|
654
600
|
* const mixed = Iterable.appendAll(numbers, letters)
|
|
655
|
-
*
|
|
601
|
+
* Array.from(mixed) // => [1, 2, "a", "b", "c"]
|
|
656
602
|
*
|
|
657
603
|
* // Lazy evaluation - only consumes what's needed
|
|
658
604
|
* const infinite = Iterable.range(1)
|
|
659
605
|
* const finite = [0, -1, -2]
|
|
660
|
-
*
|
|
661
|
-
* console.log(Array.from(result)) // [0, -1, -2, 1, 2]
|
|
606
|
+
* Array.from(Iterable.take(Iterable.appendAll(finite, infinite), 5)) // => [0, -1, -2, 1, 2]
|
|
662
607
|
* ```
|
|
663
608
|
*
|
|
664
609
|
* @see {@link append} for appending one value instead of another iterable
|
|
@@ -698,23 +643,23 @@ export const appendAll: {
|
|
|
698
643
|
*
|
|
699
644
|
* **Example** (Tracking running results)
|
|
700
645
|
*
|
|
701
|
-
* ```ts
|
|
646
|
+
* ```ts import.meta.vitest
|
|
702
647
|
* import { Iterable } from "effect"
|
|
703
648
|
*
|
|
704
649
|
* // Running sum of numbers
|
|
705
650
|
* const numbers = [1, 2, 3, 4, 5]
|
|
706
651
|
* const runningSum = Iterable.scan(numbers, 0, (acc, n) => acc + n)
|
|
707
|
-
*
|
|
652
|
+
* Array.from(runningSum) // => [0, 1, 3, 6, 10, 15]
|
|
708
653
|
*
|
|
709
654
|
* // Build strings progressively
|
|
710
655
|
* const letters = ["a", "b", "c"]
|
|
711
656
|
* const progressive = Iterable.scan(letters, "", (acc, letter) => acc + letter)
|
|
712
|
-
*
|
|
657
|
+
* Array.from(progressive) // => ["", "a", "ab", "abc"]
|
|
713
658
|
*
|
|
714
659
|
* // Track maximum values seen so far
|
|
715
660
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
716
661
|
* const runningMax = Iterable.scan(values, -Infinity, Math.max)
|
|
717
|
-
*
|
|
662
|
+
* Array.from(runningMax) // => [-Infinity, 3, 3, 4, 4, 5, 9, 9]
|
|
718
663
|
* ```
|
|
719
664
|
*
|
|
720
665
|
* @category folding
|
|
@@ -726,23 +671,23 @@ export const scan: {
|
|
|
726
671
|
*
|
|
727
672
|
* **Example** (Tracking running results)
|
|
728
673
|
*
|
|
729
|
-
* ```ts
|
|
674
|
+
* ```ts import.meta.vitest
|
|
730
675
|
* import { Iterable } from "effect"
|
|
731
676
|
*
|
|
732
677
|
* // Running sum of numbers
|
|
733
678
|
* const numbers = [1, 2, 3, 4, 5]
|
|
734
679
|
* const runningSum = Iterable.scan(numbers, 0, (acc, n) => acc + n)
|
|
735
|
-
*
|
|
680
|
+
* Array.from(runningSum) // => [0, 1, 3, 6, 10, 15]
|
|
736
681
|
*
|
|
737
682
|
* // Build strings progressively
|
|
738
683
|
* const letters = ["a", "b", "c"]
|
|
739
684
|
* const progressive = Iterable.scan(letters, "", (acc, letter) => acc + letter)
|
|
740
|
-
*
|
|
685
|
+
* Array.from(progressive) // => ["", "a", "ab", "abc"]
|
|
741
686
|
*
|
|
742
687
|
* // Track maximum values seen so far
|
|
743
688
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
744
689
|
* const runningMax = Iterable.scan(values, -Infinity, Math.max)
|
|
745
|
-
*
|
|
690
|
+
* Array.from(runningMax) // => [-Infinity, 3, 3, 4, 4, 5, 9, 9]
|
|
746
691
|
* ```
|
|
747
692
|
*
|
|
748
693
|
* @category folding
|
|
@@ -754,23 +699,23 @@ export const scan: {
|
|
|
754
699
|
*
|
|
755
700
|
* **Example** (Tracking running results)
|
|
756
701
|
*
|
|
757
|
-
* ```ts
|
|
702
|
+
* ```ts import.meta.vitest
|
|
758
703
|
* import { Iterable } from "effect"
|
|
759
704
|
*
|
|
760
705
|
* // Running sum of numbers
|
|
761
706
|
* const numbers = [1, 2, 3, 4, 5]
|
|
762
707
|
* const runningSum = Iterable.scan(numbers, 0, (acc, n) => acc + n)
|
|
763
|
-
*
|
|
708
|
+
* Array.from(runningSum) // => [0, 1, 3, 6, 10, 15]
|
|
764
709
|
*
|
|
765
710
|
* // Build strings progressively
|
|
766
711
|
* const letters = ["a", "b", "c"]
|
|
767
712
|
* const progressive = Iterable.scan(letters, "", (acc, letter) => acc + letter)
|
|
768
|
-
*
|
|
713
|
+
* Array.from(progressive) // => ["", "a", "ab", "abc"]
|
|
769
714
|
*
|
|
770
715
|
* // Track maximum values seen so far
|
|
771
716
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
772
717
|
* const runningMax = Iterable.scan(values, -Infinity, Math.max)
|
|
773
|
-
*
|
|
718
|
+
* Array.from(runningMax) // => [-Infinity, 3, 3, 4, 4, 5, 9, 9]
|
|
774
719
|
* ```
|
|
775
720
|
*
|
|
776
721
|
* @category folding
|
|
@@ -802,12 +747,11 @@ export const scan: {
|
|
|
802
747
|
*
|
|
803
748
|
* **Example** (Checking for emptiness)
|
|
804
749
|
*
|
|
805
|
-
* ```ts
|
|
750
|
+
* ```ts import.meta.vitest
|
|
806
751
|
* import { Iterable } from "effect"
|
|
807
|
-
* import * as assert from "node:assert"
|
|
808
752
|
*
|
|
809
|
-
*
|
|
810
|
-
*
|
|
753
|
+
* Iterable.isEmpty([]) // => true
|
|
754
|
+
* Iterable.isEmpty([1, 2, 3]) // => false
|
|
811
755
|
* ```
|
|
812
756
|
*
|
|
813
757
|
* @category guards
|
|
@@ -823,22 +767,22 @@ export const isEmpty = <A>(self: Iterable<A>): self is Iterable<never> => {
|
|
|
823
767
|
*
|
|
824
768
|
* **Example** (Counting iterable elements)
|
|
825
769
|
*
|
|
826
|
-
* ```ts
|
|
770
|
+
* ```ts import.meta.vitest
|
|
827
771
|
* import { Iterable } from "effect"
|
|
828
772
|
*
|
|
829
773
|
* const numbers = [1, 2, 3, 4, 5]
|
|
830
|
-
*
|
|
774
|
+
* Iterable.size(numbers) // => 5
|
|
831
775
|
*
|
|
832
776
|
* const empty = Iterable.empty<number>()
|
|
833
|
-
*
|
|
777
|
+
* Iterable.size(empty) // => 0
|
|
834
778
|
*
|
|
835
779
|
* // Works with any iterable
|
|
836
780
|
* const letters = "hello"
|
|
837
|
-
*
|
|
781
|
+
* Iterable.size(letters) // => 5
|
|
838
782
|
*
|
|
839
783
|
* // Note: This consumes the entire iterable
|
|
840
784
|
* const range = Iterable.range(1, 100)
|
|
841
|
-
*
|
|
785
|
+
* Iterable.size(range) // => 100
|
|
842
786
|
* ```
|
|
843
787
|
*
|
|
844
788
|
* @category getters
|
|
@@ -858,24 +802,24 @@ export const size = <A>(self: Iterable<A>): number => {
|
|
|
858
802
|
*
|
|
859
803
|
* **Example** (Getting the first element)
|
|
860
804
|
*
|
|
861
|
-
* ```ts
|
|
805
|
+
* ```ts import.meta.vitest
|
|
862
806
|
* import { Iterable, Option } from "effect"
|
|
863
807
|
*
|
|
864
808
|
* const numbers = [1, 2, 3]
|
|
865
|
-
*
|
|
809
|
+
* Iterable.head(numbers) // => Option.some(1)
|
|
866
810
|
*
|
|
867
811
|
* const empty = Iterable.empty<number>()
|
|
868
|
-
*
|
|
812
|
+
* Iterable.head(empty) // => Option.none()
|
|
869
813
|
*
|
|
870
814
|
* // Safe way to get first element
|
|
871
815
|
* const firstEven = Iterable.head(
|
|
872
816
|
* Iterable.filter([1, 3, 4, 5], (x) => x % 2 === 0)
|
|
873
817
|
* )
|
|
874
|
-
*
|
|
818
|
+
* firstEven // => Option.some(4)
|
|
875
819
|
*
|
|
876
820
|
* // Use with Option methods
|
|
877
821
|
* const doubled = Option.map(Iterable.head([5, 10, 15]), (x) => x * 2)
|
|
878
|
-
*
|
|
822
|
+
* doubled // => Option.some(10)
|
|
879
823
|
* ```
|
|
880
824
|
*
|
|
881
825
|
* @category getters
|
|
@@ -901,21 +845,21 @@ export const head = <A>(self: Iterable<A>): Option<A> => {
|
|
|
901
845
|
*
|
|
902
846
|
* **Example** (Getting the first element unsafely)
|
|
903
847
|
*
|
|
904
|
-
* ```ts
|
|
848
|
+
* ```ts import.meta.vitest
|
|
905
849
|
* import { Iterable } from "effect"
|
|
906
850
|
*
|
|
907
851
|
* const numbers = [1, 2, 3]
|
|
908
|
-
*
|
|
852
|
+
* Iterable.headUnsafe(numbers) // => 1
|
|
909
853
|
*
|
|
910
854
|
* const letters = "hello"
|
|
911
|
-
*
|
|
855
|
+
* Iterable.headUnsafe(letters) // => "h"
|
|
912
856
|
*
|
|
913
857
|
* // Iterable.headUnsafe(Iterable.empty<number>())
|
|
914
858
|
* // throws Error: "headUnsafe: empty iterable"
|
|
915
859
|
*
|
|
916
860
|
* // Use only when you're certain the iterable is non-empty
|
|
917
861
|
* const nonEmpty = Iterable.range(1, 10)
|
|
918
|
-
*
|
|
862
|
+
* Iterable.headUnsafe(nonEmpty) // => 1
|
|
919
863
|
* ```
|
|
920
864
|
*
|
|
921
865
|
* @category getters
|
|
@@ -937,25 +881,25 @@ export const headUnsafe = <A>(self: Iterable<A>): A => {
|
|
|
937
881
|
*
|
|
938
882
|
* **Example** (Taking from the start)
|
|
939
883
|
*
|
|
940
|
-
* ```ts
|
|
884
|
+
* ```ts import.meta.vitest
|
|
941
885
|
* import { Iterable } from "effect"
|
|
942
886
|
*
|
|
943
887
|
* const numbers = [1, 2, 3, 4, 5]
|
|
944
888
|
* const firstThree = Iterable.take(numbers, 3)
|
|
945
|
-
*
|
|
889
|
+
* Array.from(firstThree) // => [1, 2, 3]
|
|
946
890
|
*
|
|
947
891
|
* // Taking more than available returns all elements
|
|
948
892
|
* const firstTen = Iterable.take(numbers, 10)
|
|
949
|
-
*
|
|
893
|
+
* Array.from(firstTen) // => [1, 2, 3, 4, 5]
|
|
950
894
|
*
|
|
951
895
|
* // Taking 0 or negative returns empty
|
|
952
896
|
* const none = Iterable.take(numbers, 0)
|
|
953
|
-
*
|
|
897
|
+
* Array.from(none) // => []
|
|
954
898
|
*
|
|
955
899
|
* // Useful with infinite iterables
|
|
956
900
|
* const naturals = Iterable.range(1)
|
|
957
901
|
* const firstFive = Iterable.take(naturals, 5)
|
|
958
|
-
*
|
|
902
|
+
* Array.from(firstFive) // => [1, 2, 3, 4, 5]
|
|
959
903
|
* ```
|
|
960
904
|
*
|
|
961
905
|
* @category getters
|
|
@@ -971,25 +915,25 @@ export const take: {
|
|
|
971
915
|
*
|
|
972
916
|
* **Example** (Taking from the start)
|
|
973
917
|
*
|
|
974
|
-
* ```ts
|
|
918
|
+
* ```ts import.meta.vitest
|
|
975
919
|
* import { Iterable } from "effect"
|
|
976
920
|
*
|
|
977
921
|
* const numbers = [1, 2, 3, 4, 5]
|
|
978
922
|
* const firstThree = Iterable.take(numbers, 3)
|
|
979
|
-
*
|
|
923
|
+
* Array.from(firstThree) // => [1, 2, 3]
|
|
980
924
|
*
|
|
981
925
|
* // Taking more than available returns all elements
|
|
982
926
|
* const firstTen = Iterable.take(numbers, 10)
|
|
983
|
-
*
|
|
927
|
+
* Array.from(firstTen) // => [1, 2, 3, 4, 5]
|
|
984
928
|
*
|
|
985
929
|
* // Taking 0 or negative returns empty
|
|
986
930
|
* const none = Iterable.take(numbers, 0)
|
|
987
|
-
*
|
|
931
|
+
* Array.from(none) // => []
|
|
988
932
|
*
|
|
989
933
|
* // Useful with infinite iterables
|
|
990
934
|
* const naturals = Iterable.range(1)
|
|
991
935
|
* const firstFive = Iterable.take(naturals, 5)
|
|
992
|
-
*
|
|
936
|
+
* Array.from(firstFive) // => [1, 2, 3, 4, 5]
|
|
993
937
|
* ```
|
|
994
938
|
*
|
|
995
939
|
* @category getters
|
|
@@ -1005,25 +949,25 @@ export const take: {
|
|
|
1005
949
|
*
|
|
1006
950
|
* **Example** (Taking from the start)
|
|
1007
951
|
*
|
|
1008
|
-
* ```ts
|
|
952
|
+
* ```ts import.meta.vitest
|
|
1009
953
|
* import { Iterable } from "effect"
|
|
1010
954
|
*
|
|
1011
955
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1012
956
|
* const firstThree = Iterable.take(numbers, 3)
|
|
1013
|
-
*
|
|
957
|
+
* Array.from(firstThree) // => [1, 2, 3]
|
|
1014
958
|
*
|
|
1015
959
|
* // Taking more than available returns all elements
|
|
1016
960
|
* const firstTen = Iterable.take(numbers, 10)
|
|
1017
|
-
*
|
|
961
|
+
* Array.from(firstTen) // => [1, 2, 3, 4, 5]
|
|
1018
962
|
*
|
|
1019
963
|
* // Taking 0 or negative returns empty
|
|
1020
964
|
* const none = Iterable.take(numbers, 0)
|
|
1021
|
-
*
|
|
965
|
+
* Array.from(none) // => []
|
|
1022
966
|
*
|
|
1023
967
|
* // Useful with infinite iterables
|
|
1024
968
|
* const naturals = Iterable.range(1)
|
|
1025
969
|
* const firstFive = Iterable.take(naturals, 5)
|
|
1026
|
-
*
|
|
970
|
+
* Array.from(firstFive) // => [1, 2, 3, 4, 5]
|
|
1027
971
|
* ```
|
|
1028
972
|
*
|
|
1029
973
|
* @category getters
|
|
@@ -1052,22 +996,22 @@ export const take: {
|
|
|
1052
996
|
*
|
|
1053
997
|
* **Example** (Taking while a predicate holds)
|
|
1054
998
|
*
|
|
1055
|
-
* ```ts
|
|
999
|
+
* ```ts import.meta.vitest
|
|
1056
1000
|
* import { Iterable } from "effect"
|
|
1057
1001
|
*
|
|
1058
1002
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1059
1003
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1060
|
-
*
|
|
1004
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1061
1005
|
*
|
|
1062
1006
|
* // With index
|
|
1063
1007
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1064
1008
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1065
|
-
*
|
|
1009
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1066
1010
|
*
|
|
1067
1011
|
* // Stops at first non-matching element
|
|
1068
1012
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1069
1013
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1070
|
-
*
|
|
1014
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1071
1015
|
*
|
|
1072
1016
|
* // Type refinement
|
|
1073
1017
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1075,7 +1019,7 @@ export const take: {
|
|
|
1075
1019
|
* values,
|
|
1076
1020
|
* (x): x is string => typeof x === "string"
|
|
1077
1021
|
* )
|
|
1078
|
-
*
|
|
1022
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1079
1023
|
* ```
|
|
1080
1024
|
*
|
|
1081
1025
|
* @category getters
|
|
@@ -1088,22 +1032,22 @@ export const takeWhile: {
|
|
|
1088
1032
|
*
|
|
1089
1033
|
* **Example** (Taking while a predicate holds)
|
|
1090
1034
|
*
|
|
1091
|
-
* ```ts
|
|
1035
|
+
* ```ts import.meta.vitest
|
|
1092
1036
|
* import { Iterable } from "effect"
|
|
1093
1037
|
*
|
|
1094
1038
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1095
1039
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1096
|
-
*
|
|
1040
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1097
1041
|
*
|
|
1098
1042
|
* // With index
|
|
1099
1043
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1100
1044
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1101
|
-
*
|
|
1045
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1102
1046
|
*
|
|
1103
1047
|
* // Stops at first non-matching element
|
|
1104
1048
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1105
1049
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1106
|
-
*
|
|
1050
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1107
1051
|
*
|
|
1108
1052
|
* // Type refinement
|
|
1109
1053
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1111,7 +1055,7 @@ export const takeWhile: {
|
|
|
1111
1055
|
* values,
|
|
1112
1056
|
* (x): x is string => typeof x === "string"
|
|
1113
1057
|
* )
|
|
1114
|
-
*
|
|
1058
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1115
1059
|
* ```
|
|
1116
1060
|
*
|
|
1117
1061
|
* @category getters
|
|
@@ -1124,22 +1068,22 @@ export const takeWhile: {
|
|
|
1124
1068
|
*
|
|
1125
1069
|
* **Example** (Taking while a predicate holds)
|
|
1126
1070
|
*
|
|
1127
|
-
* ```ts
|
|
1071
|
+
* ```ts import.meta.vitest
|
|
1128
1072
|
* import { Iterable } from "effect"
|
|
1129
1073
|
*
|
|
1130
1074
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1131
1075
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1132
|
-
*
|
|
1076
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1133
1077
|
*
|
|
1134
1078
|
* // With index
|
|
1135
1079
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1136
1080
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1137
|
-
*
|
|
1081
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1138
1082
|
*
|
|
1139
1083
|
* // Stops at first non-matching element
|
|
1140
1084
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1141
1085
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1142
|
-
*
|
|
1086
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1143
1087
|
*
|
|
1144
1088
|
* // Type refinement
|
|
1145
1089
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1147,7 +1091,7 @@ export const takeWhile: {
|
|
|
1147
1091
|
* values,
|
|
1148
1092
|
* (x): x is string => typeof x === "string"
|
|
1149
1093
|
* )
|
|
1150
|
-
*
|
|
1094
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1151
1095
|
* ```
|
|
1152
1096
|
*
|
|
1153
1097
|
* @category getters
|
|
@@ -1160,22 +1104,22 @@ export const takeWhile: {
|
|
|
1160
1104
|
*
|
|
1161
1105
|
* **Example** (Taking while a predicate holds)
|
|
1162
1106
|
*
|
|
1163
|
-
* ```ts
|
|
1107
|
+
* ```ts import.meta.vitest
|
|
1164
1108
|
* import { Iterable } from "effect"
|
|
1165
1109
|
*
|
|
1166
1110
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1167
1111
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1168
|
-
*
|
|
1112
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1169
1113
|
*
|
|
1170
1114
|
* // With index
|
|
1171
1115
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1172
1116
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1173
|
-
*
|
|
1117
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1174
1118
|
*
|
|
1175
1119
|
* // Stops at first non-matching element
|
|
1176
1120
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1177
1121
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1178
|
-
*
|
|
1122
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1179
1123
|
*
|
|
1180
1124
|
* // Type refinement
|
|
1181
1125
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1183,7 +1127,7 @@ export const takeWhile: {
|
|
|
1183
1127
|
* values,
|
|
1184
1128
|
* (x): x is string => typeof x === "string"
|
|
1185
1129
|
* )
|
|
1186
|
-
*
|
|
1130
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1187
1131
|
* ```
|
|
1188
1132
|
*
|
|
1189
1133
|
* @category getters
|
|
@@ -1196,22 +1140,22 @@ export const takeWhile: {
|
|
|
1196
1140
|
*
|
|
1197
1141
|
* **Example** (Taking while a predicate holds)
|
|
1198
1142
|
*
|
|
1199
|
-
* ```ts
|
|
1143
|
+
* ```ts import.meta.vitest
|
|
1200
1144
|
* import { Iterable } from "effect"
|
|
1201
1145
|
*
|
|
1202
1146
|
* const numbers = [2, 4, 6, 8, 3, 10, 12]
|
|
1203
1147
|
* const evenPrefix = Iterable.takeWhile(numbers, (x) => x % 2 === 0)
|
|
1204
|
-
*
|
|
1148
|
+
* Array.from(evenPrefix) // => [2, 4, 6, 8]
|
|
1205
1149
|
*
|
|
1206
1150
|
* // With index
|
|
1207
1151
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1208
1152
|
* const firstThreeByIndex = Iterable.takeWhile(letters, (_, i) => i < 3)
|
|
1209
|
-
*
|
|
1153
|
+
* Array.from(firstThreeByIndex) // => ["a", "b", "c"]
|
|
1210
1154
|
*
|
|
1211
1155
|
* // Stops at first non-matching element
|
|
1212
1156
|
* const mixed = [1, 3, 5, 4, 7, 9]
|
|
1213
1157
|
* const oddPrefix = Iterable.takeWhile(mixed, (x) => x % 2 === 1)
|
|
1214
|
-
*
|
|
1158
|
+
* Array.from(oddPrefix) // => [1, 3, 5]
|
|
1215
1159
|
*
|
|
1216
1160
|
* // Type refinement
|
|
1217
1161
|
* const values: Array<string | number> = ["a", "b", "c", 1, "d"]
|
|
@@ -1219,7 +1163,7 @@ export const takeWhile: {
|
|
|
1219
1163
|
* values,
|
|
1220
1164
|
* (x): x is string => typeof x === "string"
|
|
1221
1165
|
* )
|
|
1222
|
-
*
|
|
1166
|
+
* Array.from(stringPrefix) // => ["a", "b", "c"]
|
|
1223
1167
|
* ```
|
|
1224
1168
|
*
|
|
1225
1169
|
* @category getters
|
|
@@ -1251,24 +1195,24 @@ export const takeWhile: {
|
|
|
1251
1195
|
*
|
|
1252
1196
|
* **Example** (Dropping from the start)
|
|
1253
1197
|
*
|
|
1254
|
-
* ```ts
|
|
1198
|
+
* ```ts import.meta.vitest
|
|
1255
1199
|
* import { Iterable } from "effect"
|
|
1256
1200
|
*
|
|
1257
1201
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1258
1202
|
* const withoutFirstTwo = Iterable.drop(numbers, 2)
|
|
1259
|
-
*
|
|
1203
|
+
* Array.from(withoutFirstTwo) // => [3, 4, 5]
|
|
1260
1204
|
*
|
|
1261
1205
|
* // Dropping more than available returns empty
|
|
1262
1206
|
* const withoutFirstTen = Iterable.drop(numbers, 10)
|
|
1263
|
-
*
|
|
1207
|
+
* Array.from(withoutFirstTen) // => []
|
|
1264
1208
|
*
|
|
1265
1209
|
* // Dropping 0 or negative returns all elements
|
|
1266
1210
|
* const all = Iterable.drop(numbers, 0)
|
|
1267
|
-
*
|
|
1211
|
+
* Array.from(all) // => [1, 2, 3, 4, 5]
|
|
1268
1212
|
*
|
|
1269
1213
|
* // Combine with take for slicing
|
|
1270
1214
|
* const slice = Iterable.take(Iterable.drop(numbers, 1), 3)
|
|
1271
|
-
*
|
|
1215
|
+
* Array.from(slice) // => [2, 3, 4]
|
|
1272
1216
|
* ```
|
|
1273
1217
|
*
|
|
1274
1218
|
* @category getters
|
|
@@ -1284,24 +1228,24 @@ export const drop: {
|
|
|
1284
1228
|
*
|
|
1285
1229
|
* **Example** (Dropping from the start)
|
|
1286
1230
|
*
|
|
1287
|
-
* ```ts
|
|
1231
|
+
* ```ts import.meta.vitest
|
|
1288
1232
|
* import { Iterable } from "effect"
|
|
1289
1233
|
*
|
|
1290
1234
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1291
1235
|
* const withoutFirstTwo = Iterable.drop(numbers, 2)
|
|
1292
|
-
*
|
|
1236
|
+
* Array.from(withoutFirstTwo) // => [3, 4, 5]
|
|
1293
1237
|
*
|
|
1294
1238
|
* // Dropping more than available returns empty
|
|
1295
1239
|
* const withoutFirstTen = Iterable.drop(numbers, 10)
|
|
1296
|
-
*
|
|
1240
|
+
* Array.from(withoutFirstTen) // => []
|
|
1297
1241
|
*
|
|
1298
1242
|
* // Dropping 0 or negative returns all elements
|
|
1299
1243
|
* const all = Iterable.drop(numbers, 0)
|
|
1300
|
-
*
|
|
1244
|
+
* Array.from(all) // => [1, 2, 3, 4, 5]
|
|
1301
1245
|
*
|
|
1302
1246
|
* // Combine with take for slicing
|
|
1303
1247
|
* const slice = Iterable.take(Iterable.drop(numbers, 1), 3)
|
|
1304
|
-
*
|
|
1248
|
+
* Array.from(slice) // => [2, 3, 4]
|
|
1305
1249
|
* ```
|
|
1306
1250
|
*
|
|
1307
1251
|
* @category getters
|
|
@@ -1317,24 +1261,24 @@ export const drop: {
|
|
|
1317
1261
|
*
|
|
1318
1262
|
* **Example** (Dropping from the start)
|
|
1319
1263
|
*
|
|
1320
|
-
* ```ts
|
|
1264
|
+
* ```ts import.meta.vitest
|
|
1321
1265
|
* import { Iterable } from "effect"
|
|
1322
1266
|
*
|
|
1323
1267
|
* const numbers = [1, 2, 3, 4, 5]
|
|
1324
1268
|
* const withoutFirstTwo = Iterable.drop(numbers, 2)
|
|
1325
|
-
*
|
|
1269
|
+
* Array.from(withoutFirstTwo) // => [3, 4, 5]
|
|
1326
1270
|
*
|
|
1327
1271
|
* // Dropping more than available returns empty
|
|
1328
1272
|
* const withoutFirstTen = Iterable.drop(numbers, 10)
|
|
1329
|
-
*
|
|
1273
|
+
* Array.from(withoutFirstTen) // => []
|
|
1330
1274
|
*
|
|
1331
1275
|
* // Dropping 0 or negative returns all elements
|
|
1332
1276
|
* const all = Iterable.drop(numbers, 0)
|
|
1333
|
-
*
|
|
1277
|
+
* Array.from(all) // => [1, 2, 3, 4, 5]
|
|
1334
1278
|
*
|
|
1335
1279
|
* // Combine with take for slicing
|
|
1336
1280
|
* const slice = Iterable.take(Iterable.drop(numbers, 1), 3)
|
|
1337
|
-
*
|
|
1281
|
+
* Array.from(slice) // => [2, 3, 4]
|
|
1338
1282
|
* ```
|
|
1339
1283
|
*
|
|
1340
1284
|
* @category getters
|
|
@@ -1366,20 +1310,20 @@ export const drop: {
|
|
|
1366
1310
|
*
|
|
1367
1311
|
* **Example** (Finding the first match)
|
|
1368
1312
|
*
|
|
1369
|
-
* ```ts
|
|
1313
|
+
* ```ts import.meta.vitest
|
|
1370
1314
|
* import { Iterable, Option } from "effect"
|
|
1371
1315
|
*
|
|
1372
1316
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1373
1317
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1374
|
-
*
|
|
1318
|
+
* firstEven // => Option.some(4)
|
|
1375
1319
|
*
|
|
1376
1320
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1377
|
-
*
|
|
1321
|
+
* firstGreaterThan10 // => Option.none()
|
|
1378
1322
|
*
|
|
1379
1323
|
* // With index
|
|
1380
1324
|
* const letters = ["a", "b", "c", "d"]
|
|
1381
1325
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1382
|
-
*
|
|
1326
|
+
* atEvenIndex // => Option.some("a")
|
|
1383
1327
|
*
|
|
1384
1328
|
* // Type refinement
|
|
1385
1329
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1387,17 +1331,17 @@ export const drop: {
|
|
|
1387
1331
|
* mixed,
|
|
1388
1332
|
* (x): x is string => typeof x === "string"
|
|
1389
1333
|
* )
|
|
1390
|
-
*
|
|
1334
|
+
* firstString // => Option.some("hello")
|
|
1391
1335
|
*
|
|
1392
1336
|
* // Transform during search
|
|
1393
1337
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1394
1338
|
* const sqrt = Math.sqrt(x)
|
|
1395
1339
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1396
1340
|
* })
|
|
1397
|
-
*
|
|
1341
|
+
* findSquareRoot // => Option.some(1)
|
|
1398
1342
|
* ```
|
|
1399
1343
|
*
|
|
1400
|
-
* @category
|
|
1344
|
+
* @category searching
|
|
1401
1345
|
* @since 2.0.0
|
|
1402
1346
|
*/
|
|
1403
1347
|
export const findFirst: {
|
|
@@ -1407,20 +1351,20 @@ export const findFirst: {
|
|
|
1407
1351
|
*
|
|
1408
1352
|
* **Example** (Finding the first match)
|
|
1409
1353
|
*
|
|
1410
|
-
* ```ts
|
|
1354
|
+
* ```ts import.meta.vitest
|
|
1411
1355
|
* import { Iterable, Option } from "effect"
|
|
1412
1356
|
*
|
|
1413
1357
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1414
1358
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1415
|
-
*
|
|
1359
|
+
* firstEven // => Option.some(4)
|
|
1416
1360
|
*
|
|
1417
1361
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1418
|
-
*
|
|
1362
|
+
* firstGreaterThan10 // => Option.none()
|
|
1419
1363
|
*
|
|
1420
1364
|
* // With index
|
|
1421
1365
|
* const letters = ["a", "b", "c", "d"]
|
|
1422
1366
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1423
|
-
*
|
|
1367
|
+
* atEvenIndex // => Option.some("a")
|
|
1424
1368
|
*
|
|
1425
1369
|
* // Type refinement
|
|
1426
1370
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1428,17 +1372,17 @@ export const findFirst: {
|
|
|
1428
1372
|
* mixed,
|
|
1429
1373
|
* (x): x is string => typeof x === "string"
|
|
1430
1374
|
* )
|
|
1431
|
-
*
|
|
1375
|
+
* firstString // => Option.some("hello")
|
|
1432
1376
|
*
|
|
1433
1377
|
* // Transform during search
|
|
1434
1378
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1435
1379
|
* const sqrt = Math.sqrt(x)
|
|
1436
1380
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1437
1381
|
* })
|
|
1438
|
-
*
|
|
1382
|
+
* findSquareRoot // => Option.some(1)
|
|
1439
1383
|
* ```
|
|
1440
1384
|
*
|
|
1441
|
-
* @category
|
|
1385
|
+
* @category searching
|
|
1442
1386
|
* @since 2.0.0
|
|
1443
1387
|
*/
|
|
1444
1388
|
<A, B>(f: (a: NoInfer<A>, i: number) => Option<B>): (self: Iterable<A>) => Option<B>
|
|
@@ -1448,20 +1392,20 @@ export const findFirst: {
|
|
|
1448
1392
|
*
|
|
1449
1393
|
* **Example** (Finding the first match)
|
|
1450
1394
|
*
|
|
1451
|
-
* ```ts
|
|
1395
|
+
* ```ts import.meta.vitest
|
|
1452
1396
|
* import { Iterable, Option } from "effect"
|
|
1453
1397
|
*
|
|
1454
1398
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1455
1399
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1456
|
-
*
|
|
1400
|
+
* firstEven // => Option.some(4)
|
|
1457
1401
|
*
|
|
1458
1402
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1459
|
-
*
|
|
1403
|
+
* firstGreaterThan10 // => Option.none()
|
|
1460
1404
|
*
|
|
1461
1405
|
* // With index
|
|
1462
1406
|
* const letters = ["a", "b", "c", "d"]
|
|
1463
1407
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1464
|
-
*
|
|
1408
|
+
* atEvenIndex // => Option.some("a")
|
|
1465
1409
|
*
|
|
1466
1410
|
* // Type refinement
|
|
1467
1411
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1469,17 +1413,17 @@ export const findFirst: {
|
|
|
1469
1413
|
* mixed,
|
|
1470
1414
|
* (x): x is string => typeof x === "string"
|
|
1471
1415
|
* )
|
|
1472
|
-
*
|
|
1416
|
+
* firstString // => Option.some("hello")
|
|
1473
1417
|
*
|
|
1474
1418
|
* // Transform during search
|
|
1475
1419
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1476
1420
|
* const sqrt = Math.sqrt(x)
|
|
1477
1421
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1478
1422
|
* })
|
|
1479
|
-
*
|
|
1423
|
+
* findSquareRoot // => Option.some(1)
|
|
1480
1424
|
* ```
|
|
1481
1425
|
*
|
|
1482
|
-
* @category
|
|
1426
|
+
* @category searching
|
|
1483
1427
|
* @since 2.0.0
|
|
1484
1428
|
*/
|
|
1485
1429
|
<A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option<B>
|
|
@@ -1489,20 +1433,20 @@ export const findFirst: {
|
|
|
1489
1433
|
*
|
|
1490
1434
|
* **Example** (Finding the first match)
|
|
1491
1435
|
*
|
|
1492
|
-
* ```ts
|
|
1436
|
+
* ```ts import.meta.vitest
|
|
1493
1437
|
* import { Iterable, Option } from "effect"
|
|
1494
1438
|
*
|
|
1495
1439
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1496
1440
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1497
|
-
*
|
|
1441
|
+
* firstEven // => Option.some(4)
|
|
1498
1442
|
*
|
|
1499
1443
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1500
|
-
*
|
|
1444
|
+
* firstGreaterThan10 // => Option.none()
|
|
1501
1445
|
*
|
|
1502
1446
|
* // With index
|
|
1503
1447
|
* const letters = ["a", "b", "c", "d"]
|
|
1504
1448
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1505
|
-
*
|
|
1449
|
+
* atEvenIndex // => Option.some("a")
|
|
1506
1450
|
*
|
|
1507
1451
|
* // Type refinement
|
|
1508
1452
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1510,17 +1454,17 @@ export const findFirst: {
|
|
|
1510
1454
|
* mixed,
|
|
1511
1455
|
* (x): x is string => typeof x === "string"
|
|
1512
1456
|
* )
|
|
1513
|
-
*
|
|
1457
|
+
* firstString // => Option.some("hello")
|
|
1514
1458
|
*
|
|
1515
1459
|
* // Transform during search
|
|
1516
1460
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1517
1461
|
* const sqrt = Math.sqrt(x)
|
|
1518
1462
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1519
1463
|
* })
|
|
1520
|
-
*
|
|
1464
|
+
* findSquareRoot // => Option.some(1)
|
|
1521
1465
|
* ```
|
|
1522
1466
|
*
|
|
1523
|
-
* @category
|
|
1467
|
+
* @category searching
|
|
1524
1468
|
* @since 2.0.0
|
|
1525
1469
|
*/
|
|
1526
1470
|
<A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<A>
|
|
@@ -1530,20 +1474,20 @@ export const findFirst: {
|
|
|
1530
1474
|
*
|
|
1531
1475
|
* **Example** (Finding the first match)
|
|
1532
1476
|
*
|
|
1533
|
-
* ```ts
|
|
1477
|
+
* ```ts import.meta.vitest
|
|
1534
1478
|
* import { Iterable, Option } from "effect"
|
|
1535
1479
|
*
|
|
1536
1480
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1537
1481
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1538
|
-
*
|
|
1482
|
+
* firstEven // => Option.some(4)
|
|
1539
1483
|
*
|
|
1540
1484
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1541
|
-
*
|
|
1485
|
+
* firstGreaterThan10 // => Option.none()
|
|
1542
1486
|
*
|
|
1543
1487
|
* // With index
|
|
1544
1488
|
* const letters = ["a", "b", "c", "d"]
|
|
1545
1489
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1546
|
-
*
|
|
1490
|
+
* atEvenIndex // => Option.some("a")
|
|
1547
1491
|
*
|
|
1548
1492
|
* // Type refinement
|
|
1549
1493
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1551,17 +1495,17 @@ export const findFirst: {
|
|
|
1551
1495
|
* mixed,
|
|
1552
1496
|
* (x): x is string => typeof x === "string"
|
|
1553
1497
|
* )
|
|
1554
|
-
*
|
|
1498
|
+
* firstString // => Option.some("hello")
|
|
1555
1499
|
*
|
|
1556
1500
|
* // Transform during search
|
|
1557
1501
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1558
1502
|
* const sqrt = Math.sqrt(x)
|
|
1559
1503
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1560
1504
|
* })
|
|
1561
|
-
*
|
|
1505
|
+
* findSquareRoot // => Option.some(1)
|
|
1562
1506
|
* ```
|
|
1563
1507
|
*
|
|
1564
|
-
* @category
|
|
1508
|
+
* @category searching
|
|
1565
1509
|
* @since 2.0.0
|
|
1566
1510
|
*/
|
|
1567
1511
|
<A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Option<B>
|
|
@@ -1571,20 +1515,20 @@ export const findFirst: {
|
|
|
1571
1515
|
*
|
|
1572
1516
|
* **Example** (Finding the first match)
|
|
1573
1517
|
*
|
|
1574
|
-
* ```ts
|
|
1518
|
+
* ```ts import.meta.vitest
|
|
1575
1519
|
* import { Iterable, Option } from "effect"
|
|
1576
1520
|
*
|
|
1577
1521
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1578
1522
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1579
|
-
*
|
|
1523
|
+
* firstEven // => Option.some(4)
|
|
1580
1524
|
*
|
|
1581
1525
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1582
|
-
*
|
|
1526
|
+
* firstGreaterThan10 // => Option.none()
|
|
1583
1527
|
*
|
|
1584
1528
|
* // With index
|
|
1585
1529
|
* const letters = ["a", "b", "c", "d"]
|
|
1586
1530
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1587
|
-
*
|
|
1531
|
+
* atEvenIndex // => Option.some("a")
|
|
1588
1532
|
*
|
|
1589
1533
|
* // Type refinement
|
|
1590
1534
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1592,17 +1536,17 @@ export const findFirst: {
|
|
|
1592
1536
|
* mixed,
|
|
1593
1537
|
* (x): x is string => typeof x === "string"
|
|
1594
1538
|
* )
|
|
1595
|
-
*
|
|
1539
|
+
* firstString // => Option.some("hello")
|
|
1596
1540
|
*
|
|
1597
1541
|
* // Transform during search
|
|
1598
1542
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1599
1543
|
* const sqrt = Math.sqrt(x)
|
|
1600
1544
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1601
1545
|
* })
|
|
1602
|
-
*
|
|
1546
|
+
* findSquareRoot // => Option.some(1)
|
|
1603
1547
|
* ```
|
|
1604
1548
|
*
|
|
1605
|
-
* @category
|
|
1549
|
+
* @category searching
|
|
1606
1550
|
* @since 2.0.0
|
|
1607
1551
|
*/
|
|
1608
1552
|
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option<B>
|
|
@@ -1612,20 +1556,20 @@ export const findFirst: {
|
|
|
1612
1556
|
*
|
|
1613
1557
|
* **Example** (Finding the first match)
|
|
1614
1558
|
*
|
|
1615
|
-
* ```ts
|
|
1559
|
+
* ```ts import.meta.vitest
|
|
1616
1560
|
* import { Iterable, Option } from "effect"
|
|
1617
1561
|
*
|
|
1618
1562
|
* const numbers = [1, 3, 4, 6, 8]
|
|
1619
1563
|
* const firstEven = Iterable.findFirst(numbers, (x) => x % 2 === 0)
|
|
1620
|
-
*
|
|
1564
|
+
* firstEven // => Option.some(4)
|
|
1621
1565
|
*
|
|
1622
1566
|
* const firstGreaterThan10 = Iterable.findFirst(numbers, (x) => x > 10)
|
|
1623
|
-
*
|
|
1567
|
+
* firstGreaterThan10 // => Option.none()
|
|
1624
1568
|
*
|
|
1625
1569
|
* // With index
|
|
1626
1570
|
* const letters = ["a", "b", "c", "d"]
|
|
1627
1571
|
* const atEvenIndex = Iterable.findFirst(letters, (_, i) => i % 2 === 0)
|
|
1628
|
-
*
|
|
1572
|
+
* atEvenIndex // => Option.some("a")
|
|
1629
1573
|
*
|
|
1630
1574
|
* // Type refinement
|
|
1631
1575
|
* const mixed: Array<string | number> = [1, "hello", 2, "world"]
|
|
@@ -1633,17 +1577,17 @@ export const findFirst: {
|
|
|
1633
1577
|
* mixed,
|
|
1634
1578
|
* (x): x is string => typeof x === "string"
|
|
1635
1579
|
* )
|
|
1636
|
-
*
|
|
1580
|
+
* firstString // => Option.some("hello")
|
|
1637
1581
|
*
|
|
1638
1582
|
* // Transform during search
|
|
1639
1583
|
* const findSquareRoot = Iterable.findFirst([1, 4, 9, 16], (x) => {
|
|
1640
1584
|
* const sqrt = Math.sqrt(x)
|
|
1641
1585
|
* return Number.isInteger(sqrt) ? Option.some(sqrt) : Option.none()
|
|
1642
1586
|
* })
|
|
1643
|
-
*
|
|
1587
|
+
* findSquareRoot // => Option.some(1)
|
|
1644
1588
|
* ```
|
|
1645
1589
|
*
|
|
1646
|
-
* @category
|
|
1590
|
+
* @category searching
|
|
1647
1591
|
* @since 2.0.0
|
|
1648
1592
|
*/
|
|
1649
1593
|
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<A>
|
|
@@ -1673,20 +1617,20 @@ export const findFirst: {
|
|
|
1673
1617
|
*
|
|
1674
1618
|
* **Example** (Finding the last match)
|
|
1675
1619
|
*
|
|
1676
|
-
* ```ts
|
|
1677
|
-
* import { Iterable } from "effect"
|
|
1620
|
+
* ```ts import.meta.vitest
|
|
1621
|
+
* import { Iterable, Option } from "effect"
|
|
1678
1622
|
*
|
|
1679
1623
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1680
1624
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1681
|
-
*
|
|
1625
|
+
* lastEven // => Option.some(2)
|
|
1682
1626
|
*
|
|
1683
1627
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1684
|
-
*
|
|
1628
|
+
* lastGreaterThan10 // => Option.none()
|
|
1685
1629
|
*
|
|
1686
1630
|
* // With index
|
|
1687
1631
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1688
1632
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1689
|
-
*
|
|
1633
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1690
1634
|
*
|
|
1691
1635
|
* // Type refinement
|
|
1692
1636
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1694,10 +1638,10 @@ export const findFirst: {
|
|
|
1694
1638
|
* mixed,
|
|
1695
1639
|
* (x): x is string => typeof x === "string"
|
|
1696
1640
|
* )
|
|
1697
|
-
*
|
|
1641
|
+
* lastString // => Option.some("world")
|
|
1698
1642
|
* ```
|
|
1699
1643
|
*
|
|
1700
|
-
* @category
|
|
1644
|
+
* @category searching
|
|
1701
1645
|
* @since 2.0.0
|
|
1702
1646
|
*/
|
|
1703
1647
|
export const findLast: {
|
|
@@ -1706,20 +1650,20 @@ export const findLast: {
|
|
|
1706
1650
|
*
|
|
1707
1651
|
* **Example** (Finding the last match)
|
|
1708
1652
|
*
|
|
1709
|
-
* ```ts
|
|
1710
|
-
* import { Iterable } from "effect"
|
|
1653
|
+
* ```ts import.meta.vitest
|
|
1654
|
+
* import { Iterable, Option } from "effect"
|
|
1711
1655
|
*
|
|
1712
1656
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1713
1657
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1714
|
-
*
|
|
1658
|
+
* lastEven // => Option.some(2)
|
|
1715
1659
|
*
|
|
1716
1660
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1717
|
-
*
|
|
1661
|
+
* lastGreaterThan10 // => Option.none()
|
|
1718
1662
|
*
|
|
1719
1663
|
* // With index
|
|
1720
1664
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1721
1665
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1722
|
-
*
|
|
1666
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1723
1667
|
*
|
|
1724
1668
|
* // Type refinement
|
|
1725
1669
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1727,10 +1671,10 @@ export const findLast: {
|
|
|
1727
1671
|
* mixed,
|
|
1728
1672
|
* (x): x is string => typeof x === "string"
|
|
1729
1673
|
* )
|
|
1730
|
-
*
|
|
1674
|
+
* lastString // => Option.some("world")
|
|
1731
1675
|
* ```
|
|
1732
1676
|
*
|
|
1733
|
-
* @category
|
|
1677
|
+
* @category searching
|
|
1734
1678
|
* @since 2.0.0
|
|
1735
1679
|
*/
|
|
1736
1680
|
<A, B>(f: (a: NoInfer<A>, i: number) => Option<B>): (self: Iterable<A>) => Option<B>
|
|
@@ -1739,20 +1683,20 @@ export const findLast: {
|
|
|
1739
1683
|
*
|
|
1740
1684
|
* **Example** (Finding the last match)
|
|
1741
1685
|
*
|
|
1742
|
-
* ```ts
|
|
1743
|
-
* import { Iterable } from "effect"
|
|
1686
|
+
* ```ts import.meta.vitest
|
|
1687
|
+
* import { Iterable, Option } from "effect"
|
|
1744
1688
|
*
|
|
1745
1689
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1746
1690
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1747
|
-
*
|
|
1691
|
+
* lastEven // => Option.some(2)
|
|
1748
1692
|
*
|
|
1749
1693
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1750
|
-
*
|
|
1694
|
+
* lastGreaterThan10 // => Option.none()
|
|
1751
1695
|
*
|
|
1752
1696
|
* // With index
|
|
1753
1697
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1754
1698
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1755
|
-
*
|
|
1699
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1756
1700
|
*
|
|
1757
1701
|
* // Type refinement
|
|
1758
1702
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1760,10 +1704,10 @@ export const findLast: {
|
|
|
1760
1704
|
* mixed,
|
|
1761
1705
|
* (x): x is string => typeof x === "string"
|
|
1762
1706
|
* )
|
|
1763
|
-
*
|
|
1707
|
+
* lastString // => Option.some("world")
|
|
1764
1708
|
* ```
|
|
1765
1709
|
*
|
|
1766
|
-
* @category
|
|
1710
|
+
* @category searching
|
|
1767
1711
|
* @since 2.0.0
|
|
1768
1712
|
*/
|
|
1769
1713
|
<A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option<B>
|
|
@@ -1772,20 +1716,20 @@ export const findLast: {
|
|
|
1772
1716
|
*
|
|
1773
1717
|
* **Example** (Finding the last match)
|
|
1774
1718
|
*
|
|
1775
|
-
* ```ts
|
|
1776
|
-
* import { Iterable } from "effect"
|
|
1719
|
+
* ```ts import.meta.vitest
|
|
1720
|
+
* import { Iterable, Option } from "effect"
|
|
1777
1721
|
*
|
|
1778
1722
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1779
1723
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1780
|
-
*
|
|
1724
|
+
* lastEven // => Option.some(2)
|
|
1781
1725
|
*
|
|
1782
1726
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1783
|
-
*
|
|
1727
|
+
* lastGreaterThan10 // => Option.none()
|
|
1784
1728
|
*
|
|
1785
1729
|
* // With index
|
|
1786
1730
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1787
1731
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1788
|
-
*
|
|
1732
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1789
1733
|
*
|
|
1790
1734
|
* // Type refinement
|
|
1791
1735
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1793,10 +1737,10 @@ export const findLast: {
|
|
|
1793
1737
|
* mixed,
|
|
1794
1738
|
* (x): x is string => typeof x === "string"
|
|
1795
1739
|
* )
|
|
1796
|
-
*
|
|
1740
|
+
* lastString // => Option.some("world")
|
|
1797
1741
|
* ```
|
|
1798
1742
|
*
|
|
1799
|
-
* @category
|
|
1743
|
+
* @category searching
|
|
1800
1744
|
* @since 2.0.0
|
|
1801
1745
|
*/
|
|
1802
1746
|
<A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option<A>
|
|
@@ -1805,20 +1749,20 @@ export const findLast: {
|
|
|
1805
1749
|
*
|
|
1806
1750
|
* **Example** (Finding the last match)
|
|
1807
1751
|
*
|
|
1808
|
-
* ```ts
|
|
1809
|
-
* import { Iterable } from "effect"
|
|
1752
|
+
* ```ts import.meta.vitest
|
|
1753
|
+
* import { Iterable, Option } from "effect"
|
|
1810
1754
|
*
|
|
1811
1755
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1812
1756
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1813
|
-
*
|
|
1757
|
+
* lastEven // => Option.some(2)
|
|
1814
1758
|
*
|
|
1815
1759
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1816
|
-
*
|
|
1760
|
+
* lastGreaterThan10 // => Option.none()
|
|
1817
1761
|
*
|
|
1818
1762
|
* // With index
|
|
1819
1763
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1820
1764
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1821
|
-
*
|
|
1765
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1822
1766
|
*
|
|
1823
1767
|
* // Type refinement
|
|
1824
1768
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1826,10 +1770,10 @@ export const findLast: {
|
|
|
1826
1770
|
* mixed,
|
|
1827
1771
|
* (x): x is string => typeof x === "string"
|
|
1828
1772
|
* )
|
|
1829
|
-
*
|
|
1773
|
+
* lastString // => Option.some("world")
|
|
1830
1774
|
* ```
|
|
1831
1775
|
*
|
|
1832
|
-
* @category
|
|
1776
|
+
* @category searching
|
|
1833
1777
|
* @since 2.0.0
|
|
1834
1778
|
*/
|
|
1835
1779
|
<A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Option<B>
|
|
@@ -1838,20 +1782,20 @@ export const findLast: {
|
|
|
1838
1782
|
*
|
|
1839
1783
|
* **Example** (Finding the last match)
|
|
1840
1784
|
*
|
|
1841
|
-
* ```ts
|
|
1842
|
-
* import { Iterable } from "effect"
|
|
1785
|
+
* ```ts import.meta.vitest
|
|
1786
|
+
* import { Iterable, Option } from "effect"
|
|
1843
1787
|
*
|
|
1844
1788
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1845
1789
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1846
|
-
*
|
|
1790
|
+
* lastEven // => Option.some(2)
|
|
1847
1791
|
*
|
|
1848
1792
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1849
|
-
*
|
|
1793
|
+
* lastGreaterThan10 // => Option.none()
|
|
1850
1794
|
*
|
|
1851
1795
|
* // With index
|
|
1852
1796
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1853
1797
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1854
|
-
*
|
|
1798
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1855
1799
|
*
|
|
1856
1800
|
* // Type refinement
|
|
1857
1801
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1859,10 +1803,10 @@ export const findLast: {
|
|
|
1859
1803
|
* mixed,
|
|
1860
1804
|
* (x): x is string => typeof x === "string"
|
|
1861
1805
|
* )
|
|
1862
|
-
*
|
|
1806
|
+
* lastString // => Option.some("world")
|
|
1863
1807
|
* ```
|
|
1864
1808
|
*
|
|
1865
|
-
* @category
|
|
1809
|
+
* @category searching
|
|
1866
1810
|
* @since 2.0.0
|
|
1867
1811
|
*/
|
|
1868
1812
|
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option<B>
|
|
@@ -1871,20 +1815,20 @@ export const findLast: {
|
|
|
1871
1815
|
*
|
|
1872
1816
|
* **Example** (Finding the last match)
|
|
1873
1817
|
*
|
|
1874
|
-
* ```ts
|
|
1875
|
-
* import { Iterable } from "effect"
|
|
1818
|
+
* ```ts import.meta.vitest
|
|
1819
|
+
* import { Iterable, Option } from "effect"
|
|
1876
1820
|
*
|
|
1877
1821
|
* const numbers = [1, 3, 4, 6, 8, 2]
|
|
1878
1822
|
* const lastEven = Iterable.findLast(numbers, (x) => x % 2 === 0)
|
|
1879
|
-
*
|
|
1823
|
+
* lastEven // => Option.some(2)
|
|
1880
1824
|
*
|
|
1881
1825
|
* const lastGreaterThan10 = Iterable.findLast(numbers, (x) => x > 10)
|
|
1882
|
-
*
|
|
1826
|
+
* lastGreaterThan10 // => Option.none()
|
|
1883
1827
|
*
|
|
1884
1828
|
* // With index
|
|
1885
1829
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
1886
1830
|
* const lastAtEvenIndex = Iterable.findLast(letters, (_, i) => i % 2 === 0)
|
|
1887
|
-
*
|
|
1831
|
+
* lastAtEvenIndex // => Option.some("e")
|
|
1888
1832
|
*
|
|
1889
1833
|
* // Type refinement
|
|
1890
1834
|
* const mixed: Array<string | number> = [1, "hello", 2, "world", 3]
|
|
@@ -1892,10 +1836,10 @@ export const findLast: {
|
|
|
1892
1836
|
* mixed,
|
|
1893
1837
|
* (x): x is string => typeof x === "string"
|
|
1894
1838
|
* )
|
|
1895
|
-
*
|
|
1839
|
+
* lastString // => Option.some("world")
|
|
1896
1840
|
* ```
|
|
1897
1841
|
*
|
|
1898
|
-
* @category
|
|
1842
|
+
* @category searching
|
|
1899
1843
|
* @since 2.0.0
|
|
1900
1844
|
*/
|
|
1901
1845
|
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option<A>
|
|
@@ -1926,31 +1870,31 @@ export const findLast: {
|
|
|
1926
1870
|
*
|
|
1927
1871
|
* **Example** (Zipping iterables)
|
|
1928
1872
|
*
|
|
1929
|
-
* ```ts
|
|
1873
|
+
* ```ts import.meta.vitest
|
|
1930
1874
|
* import { Iterable } from "effect"
|
|
1931
1875
|
*
|
|
1932
1876
|
* const numbers = [1, 2, 3]
|
|
1933
1877
|
* const letters = ["a", "b", "c"]
|
|
1934
1878
|
* const zipped = Iterable.zip(numbers, letters)
|
|
1935
|
-
*
|
|
1879
|
+
* Array.from(zipped) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1936
1880
|
*
|
|
1937
1881
|
* // Different lengths - shorter one determines result length
|
|
1938
1882
|
* const short = [1, 2]
|
|
1939
1883
|
* const long = ["a", "b", "c", "d"]
|
|
1940
1884
|
* const partial = Iterable.zip(short, long)
|
|
1941
|
-
*
|
|
1885
|
+
* Array.from(partial) // => [[1, "a"], [2, "b"]]
|
|
1942
1886
|
*
|
|
1943
1887
|
* // Works with any iterables
|
|
1944
1888
|
* const range = Iterable.range(1, 3)
|
|
1945
1889
|
* const word = "abc"
|
|
1946
1890
|
* const mixed = Iterable.zip(range, word)
|
|
1947
|
-
*
|
|
1891
|
+
* Array.from(mixed) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1948
1892
|
*
|
|
1949
1893
|
* // Create indexed pairs
|
|
1950
1894
|
* const values = ["apple", "banana", "cherry"]
|
|
1951
1895
|
* const indices = Iterable.range(0, 2)
|
|
1952
1896
|
* const indexed = Iterable.zip(indices, values)
|
|
1953
|
-
*
|
|
1897
|
+
* Array.from(indexed) // => [[0, "apple"], [1, "banana"], [2, "cherry"]]
|
|
1954
1898
|
* ```
|
|
1955
1899
|
*
|
|
1956
1900
|
* @category zipping
|
|
@@ -1962,31 +1906,31 @@ export const zip: {
|
|
|
1962
1906
|
*
|
|
1963
1907
|
* **Example** (Zipping iterables)
|
|
1964
1908
|
*
|
|
1965
|
-
* ```ts
|
|
1909
|
+
* ```ts import.meta.vitest
|
|
1966
1910
|
* import { Iterable } from "effect"
|
|
1967
1911
|
*
|
|
1968
1912
|
* const numbers = [1, 2, 3]
|
|
1969
1913
|
* const letters = ["a", "b", "c"]
|
|
1970
1914
|
* const zipped = Iterable.zip(numbers, letters)
|
|
1971
|
-
*
|
|
1915
|
+
* Array.from(zipped) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1972
1916
|
*
|
|
1973
1917
|
* // Different lengths - shorter one determines result length
|
|
1974
1918
|
* const short = [1, 2]
|
|
1975
1919
|
* const long = ["a", "b", "c", "d"]
|
|
1976
1920
|
* const partial = Iterable.zip(short, long)
|
|
1977
|
-
*
|
|
1921
|
+
* Array.from(partial) // => [[1, "a"], [2, "b"]]
|
|
1978
1922
|
*
|
|
1979
1923
|
* // Works with any iterables
|
|
1980
1924
|
* const range = Iterable.range(1, 3)
|
|
1981
1925
|
* const word = "abc"
|
|
1982
1926
|
* const mixed = Iterable.zip(range, word)
|
|
1983
|
-
*
|
|
1927
|
+
* Array.from(mixed) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
1984
1928
|
*
|
|
1985
1929
|
* // Create indexed pairs
|
|
1986
1930
|
* const values = ["apple", "banana", "cherry"]
|
|
1987
1931
|
* const indices = Iterable.range(0, 2)
|
|
1988
1932
|
* const indexed = Iterable.zip(indices, values)
|
|
1989
|
-
*
|
|
1933
|
+
* Array.from(indexed) // => [[0, "apple"], [1, "banana"], [2, "cherry"]]
|
|
1990
1934
|
* ```
|
|
1991
1935
|
*
|
|
1992
1936
|
* @category zipping
|
|
@@ -1998,31 +1942,31 @@ export const zip: {
|
|
|
1998
1942
|
*
|
|
1999
1943
|
* **Example** (Zipping iterables)
|
|
2000
1944
|
*
|
|
2001
|
-
* ```ts
|
|
1945
|
+
* ```ts import.meta.vitest
|
|
2002
1946
|
* import { Iterable } from "effect"
|
|
2003
1947
|
*
|
|
2004
1948
|
* const numbers = [1, 2, 3]
|
|
2005
1949
|
* const letters = ["a", "b", "c"]
|
|
2006
1950
|
* const zipped = Iterable.zip(numbers, letters)
|
|
2007
|
-
*
|
|
1951
|
+
* Array.from(zipped) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
2008
1952
|
*
|
|
2009
1953
|
* // Different lengths - shorter one determines result length
|
|
2010
1954
|
* const short = [1, 2]
|
|
2011
1955
|
* const long = ["a", "b", "c", "d"]
|
|
2012
1956
|
* const partial = Iterable.zip(short, long)
|
|
2013
|
-
*
|
|
1957
|
+
* Array.from(partial) // => [[1, "a"], [2, "b"]]
|
|
2014
1958
|
*
|
|
2015
1959
|
* // Works with any iterables
|
|
2016
1960
|
* const range = Iterable.range(1, 3)
|
|
2017
1961
|
* const word = "abc"
|
|
2018
1962
|
* const mixed = Iterable.zip(range, word)
|
|
2019
|
-
*
|
|
1963
|
+
* Array.from(mixed) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
2020
1964
|
*
|
|
2021
1965
|
* // Create indexed pairs
|
|
2022
1966
|
* const values = ["apple", "banana", "cherry"]
|
|
2023
1967
|
* const indices = Iterable.range(0, 2)
|
|
2024
1968
|
* const indexed = Iterable.zip(indices, values)
|
|
2025
|
-
*
|
|
1969
|
+
* Array.from(indexed) // => [[0, "apple"], [1, "banana"], [2, "cherry"]]
|
|
2026
1970
|
* ```
|
|
2027
1971
|
*
|
|
2028
1972
|
* @category zipping
|
|
@@ -2040,14 +1984,14 @@ export const zip: {
|
|
|
2040
1984
|
*
|
|
2041
1985
|
* **Example** (Zipping with a combining function)
|
|
2042
1986
|
*
|
|
2043
|
-
* ```ts
|
|
1987
|
+
* ```ts import.meta.vitest
|
|
2044
1988
|
* import { Iterable } from "effect"
|
|
2045
1989
|
*
|
|
2046
1990
|
* // Add corresponding elements
|
|
2047
1991
|
* const a = [1, 2, 3, 4]
|
|
2048
1992
|
* const b = [10, 20, 30, 40]
|
|
2049
1993
|
* const sums = Iterable.zipWith(a, b, (x, y) => x + y)
|
|
2050
|
-
*
|
|
1994
|
+
* Array.from(sums) // => [11, 22, 33, 44]
|
|
2051
1995
|
*
|
|
2052
1996
|
* // Combine strings
|
|
2053
1997
|
* const firstNames = ["John", "Jane", "Bob"]
|
|
@@ -2057,7 +2001,7 @@ export const zip: {
|
|
|
2057
2001
|
* lastNames,
|
|
2058
2002
|
* (first, last) => `${first} ${last}`
|
|
2059
2003
|
* )
|
|
2060
|
-
*
|
|
2004
|
+
* Array.from(fullNames) // => ["John Doe", "Jane Smith", "Bob Johnson"]
|
|
2061
2005
|
*
|
|
2062
2006
|
* // Different lengths - stops at shorter
|
|
2063
2007
|
* const short = [1, 2]
|
|
@@ -2067,7 +2011,7 @@ export const zip: {
|
|
|
2067
2011
|
* long,
|
|
2068
2012
|
* (num, letter) => `${num}${letter}`
|
|
2069
2013
|
* )
|
|
2070
|
-
*
|
|
2014
|
+
* Array.from(combined) // => ["1a", "2b"]
|
|
2071
2015
|
*
|
|
2072
2016
|
* // Complex transformations
|
|
2073
2017
|
* const prices = [10.99, 25.50, 5.00]
|
|
@@ -2075,7 +2019,7 @@ export const zip: {
|
|
|
2075
2019
|
* const totals = Iterable.zipWith(prices, quantities, (price, qty) => {
|
|
2076
2020
|
* return Math.round(price * qty * 100) / 100 // round to 2 decimal places
|
|
2077
2021
|
* })
|
|
2078
|
-
*
|
|
2022
|
+
* Array.from(totals) // => [21.98, 25.5, 15]
|
|
2079
2023
|
* ```
|
|
2080
2024
|
*
|
|
2081
2025
|
* @category zipping
|
|
@@ -2088,14 +2032,14 @@ export const zipWith: {
|
|
|
2088
2032
|
*
|
|
2089
2033
|
* **Example** (Zipping with a combining function)
|
|
2090
2034
|
*
|
|
2091
|
-
* ```ts
|
|
2035
|
+
* ```ts import.meta.vitest
|
|
2092
2036
|
* import { Iterable } from "effect"
|
|
2093
2037
|
*
|
|
2094
2038
|
* // Add corresponding elements
|
|
2095
2039
|
* const a = [1, 2, 3, 4]
|
|
2096
2040
|
* const b = [10, 20, 30, 40]
|
|
2097
2041
|
* const sums = Iterable.zipWith(a, b, (x, y) => x + y)
|
|
2098
|
-
*
|
|
2042
|
+
* Array.from(sums) // => [11, 22, 33, 44]
|
|
2099
2043
|
*
|
|
2100
2044
|
* // Combine strings
|
|
2101
2045
|
* const firstNames = ["John", "Jane", "Bob"]
|
|
@@ -2105,7 +2049,7 @@ export const zipWith: {
|
|
|
2105
2049
|
* lastNames,
|
|
2106
2050
|
* (first, last) => `${first} ${last}`
|
|
2107
2051
|
* )
|
|
2108
|
-
*
|
|
2052
|
+
* Array.from(fullNames) // => ["John Doe", "Jane Smith", "Bob Johnson"]
|
|
2109
2053
|
*
|
|
2110
2054
|
* // Different lengths - stops at shorter
|
|
2111
2055
|
* const short = [1, 2]
|
|
@@ -2115,7 +2059,7 @@ export const zipWith: {
|
|
|
2115
2059
|
* long,
|
|
2116
2060
|
* (num, letter) => `${num}${letter}`
|
|
2117
2061
|
* )
|
|
2118
|
-
*
|
|
2062
|
+
* Array.from(combined) // => ["1a", "2b"]
|
|
2119
2063
|
*
|
|
2120
2064
|
* // Complex transformations
|
|
2121
2065
|
* const prices = [10.99, 25.50, 5.00]
|
|
@@ -2123,7 +2067,7 @@ export const zipWith: {
|
|
|
2123
2067
|
* const totals = Iterable.zipWith(prices, quantities, (price, qty) => {
|
|
2124
2068
|
* return Math.round(price * qty * 100) / 100 // round to 2 decimal places
|
|
2125
2069
|
* })
|
|
2126
|
-
*
|
|
2070
|
+
* Array.from(totals) // => [21.98, 25.5, 15]
|
|
2127
2071
|
* ```
|
|
2128
2072
|
*
|
|
2129
2073
|
* @category zipping
|
|
@@ -2136,14 +2080,14 @@ export const zipWith: {
|
|
|
2136
2080
|
*
|
|
2137
2081
|
* **Example** (Zipping with a combining function)
|
|
2138
2082
|
*
|
|
2139
|
-
* ```ts
|
|
2083
|
+
* ```ts import.meta.vitest
|
|
2140
2084
|
* import { Iterable } from "effect"
|
|
2141
2085
|
*
|
|
2142
2086
|
* // Add corresponding elements
|
|
2143
2087
|
* const a = [1, 2, 3, 4]
|
|
2144
2088
|
* const b = [10, 20, 30, 40]
|
|
2145
2089
|
* const sums = Iterable.zipWith(a, b, (x, y) => x + y)
|
|
2146
|
-
*
|
|
2090
|
+
* Array.from(sums) // => [11, 22, 33, 44]
|
|
2147
2091
|
*
|
|
2148
2092
|
* // Combine strings
|
|
2149
2093
|
* const firstNames = ["John", "Jane", "Bob"]
|
|
@@ -2153,7 +2097,7 @@ export const zipWith: {
|
|
|
2153
2097
|
* lastNames,
|
|
2154
2098
|
* (first, last) => `${first} ${last}`
|
|
2155
2099
|
* )
|
|
2156
|
-
*
|
|
2100
|
+
* Array.from(fullNames) // => ["John Doe", "Jane Smith", "Bob Johnson"]
|
|
2157
2101
|
*
|
|
2158
2102
|
* // Different lengths - stops at shorter
|
|
2159
2103
|
* const short = [1, 2]
|
|
@@ -2163,7 +2107,7 @@ export const zipWith: {
|
|
|
2163
2107
|
* long,
|
|
2164
2108
|
* (num, letter) => `${num}${letter}`
|
|
2165
2109
|
* )
|
|
2166
|
-
*
|
|
2110
|
+
* Array.from(combined) // => ["1a", "2b"]
|
|
2167
2111
|
*
|
|
2168
2112
|
* // Complex transformations
|
|
2169
2113
|
* const prices = [10.99, 25.50, 5.00]
|
|
@@ -2171,7 +2115,7 @@ export const zipWith: {
|
|
|
2171
2115
|
* const totals = Iterable.zipWith(prices, quantities, (price, qty) => {
|
|
2172
2116
|
* return Math.round(price * qty * 100) / 100 // round to 2 decimal places
|
|
2173
2117
|
* })
|
|
2174
|
-
*
|
|
2118
|
+
* Array.from(totals) // => [21.98, 25.5, 15]
|
|
2175
2119
|
* ```
|
|
2176
2120
|
*
|
|
2177
2121
|
* @category zipping
|
|
@@ -2208,33 +2152,33 @@ export const zipWith: {
|
|
|
2208
2152
|
*
|
|
2209
2153
|
* **Example** (Interspersing separators)
|
|
2210
2154
|
*
|
|
2211
|
-
* ```ts
|
|
2155
|
+
* ```ts import.meta.vitest
|
|
2212
2156
|
* import { Iterable } from "effect"
|
|
2213
2157
|
*
|
|
2214
2158
|
* // Join numbers with separator
|
|
2215
2159
|
* const numbers = [1, 2, 3, 4]
|
|
2216
2160
|
* const withCommas = Iterable.intersperse(numbers, ",")
|
|
2217
|
-
*
|
|
2161
|
+
* Array.from(withCommas) // => [1, ",", 2, ",", 3, ",", 4]
|
|
2218
2162
|
*
|
|
2219
2163
|
* // Join words with spaces
|
|
2220
2164
|
* const words = ["hello", "world", "from", "effect"]
|
|
2221
2165
|
* const sentence = Iterable.intersperse(words, " ")
|
|
2222
|
-
*
|
|
2166
|
+
* Array.from(sentence).join("") // => "hello world from effect"
|
|
2223
2167
|
*
|
|
2224
2168
|
* // Empty iterable remains empty
|
|
2225
2169
|
* const empty = Iterable.empty<string>()
|
|
2226
2170
|
* const stillEmpty = Iterable.intersperse(empty, "-")
|
|
2227
|
-
*
|
|
2171
|
+
* Array.from(stillEmpty) // => []
|
|
2228
2172
|
*
|
|
2229
2173
|
* // Single element has no separators added
|
|
2230
2174
|
* const single = [42]
|
|
2231
2175
|
* const noSeparator = Iterable.intersperse(single, "|")
|
|
2232
|
-
*
|
|
2176
|
+
* Array.from(noSeparator) // => [42]
|
|
2233
2177
|
*
|
|
2234
2178
|
* // Build CSS-like strings
|
|
2235
2179
|
* const styles = ["color: red", "font-size: 14px", "margin: 10px"]
|
|
2236
2180
|
* const css = Iterable.intersperse(styles, "; ")
|
|
2237
|
-
*
|
|
2181
|
+
* Array.from(css).join("") // => "color: red; font-size: 14px; margin: 10px"
|
|
2238
2182
|
* ```
|
|
2239
2183
|
*
|
|
2240
2184
|
* @category combining
|
|
@@ -2254,33 +2198,33 @@ export const intersperse: {
|
|
|
2254
2198
|
*
|
|
2255
2199
|
* **Example** (Interspersing separators)
|
|
2256
2200
|
*
|
|
2257
|
-
* ```ts
|
|
2201
|
+
* ```ts import.meta.vitest
|
|
2258
2202
|
* import { Iterable } from "effect"
|
|
2259
2203
|
*
|
|
2260
2204
|
* // Join numbers with separator
|
|
2261
2205
|
* const numbers = [1, 2, 3, 4]
|
|
2262
2206
|
* const withCommas = Iterable.intersperse(numbers, ",")
|
|
2263
|
-
*
|
|
2207
|
+
* Array.from(withCommas) // => [1, ",", 2, ",", 3, ",", 4]
|
|
2264
2208
|
*
|
|
2265
2209
|
* // Join words with spaces
|
|
2266
2210
|
* const words = ["hello", "world", "from", "effect"]
|
|
2267
2211
|
* const sentence = Iterable.intersperse(words, " ")
|
|
2268
|
-
*
|
|
2212
|
+
* Array.from(sentence).join("") // => "hello world from effect"
|
|
2269
2213
|
*
|
|
2270
2214
|
* // Empty iterable remains empty
|
|
2271
2215
|
* const empty = Iterable.empty<string>()
|
|
2272
2216
|
* const stillEmpty = Iterable.intersperse(empty, "-")
|
|
2273
|
-
*
|
|
2217
|
+
* Array.from(stillEmpty) // => []
|
|
2274
2218
|
*
|
|
2275
2219
|
* // Single element has no separators added
|
|
2276
2220
|
* const single = [42]
|
|
2277
2221
|
* const noSeparator = Iterable.intersperse(single, "|")
|
|
2278
|
-
*
|
|
2222
|
+
* Array.from(noSeparator) // => [42]
|
|
2279
2223
|
*
|
|
2280
2224
|
* // Build CSS-like strings
|
|
2281
2225
|
* const styles = ["color: red", "font-size: 14px", "margin: 10px"]
|
|
2282
2226
|
* const css = Iterable.intersperse(styles, "; ")
|
|
2283
|
-
*
|
|
2227
|
+
* Array.from(css).join("") // => "color: red; font-size: 14px; margin: 10px"
|
|
2284
2228
|
* ```
|
|
2285
2229
|
*
|
|
2286
2230
|
* @category combining
|
|
@@ -2300,33 +2244,33 @@ export const intersperse: {
|
|
|
2300
2244
|
*
|
|
2301
2245
|
* **Example** (Interspersing separators)
|
|
2302
2246
|
*
|
|
2303
|
-
* ```ts
|
|
2247
|
+
* ```ts import.meta.vitest
|
|
2304
2248
|
* import { Iterable } from "effect"
|
|
2305
2249
|
*
|
|
2306
2250
|
* // Join numbers with separator
|
|
2307
2251
|
* const numbers = [1, 2, 3, 4]
|
|
2308
2252
|
* const withCommas = Iterable.intersperse(numbers, ",")
|
|
2309
|
-
*
|
|
2253
|
+
* Array.from(withCommas) // => [1, ",", 2, ",", 3, ",", 4]
|
|
2310
2254
|
*
|
|
2311
2255
|
* // Join words with spaces
|
|
2312
2256
|
* const words = ["hello", "world", "from", "effect"]
|
|
2313
2257
|
* const sentence = Iterable.intersperse(words, " ")
|
|
2314
|
-
*
|
|
2258
|
+
* Array.from(sentence).join("") // => "hello world from effect"
|
|
2315
2259
|
*
|
|
2316
2260
|
* // Empty iterable remains empty
|
|
2317
2261
|
* const empty = Iterable.empty<string>()
|
|
2318
2262
|
* const stillEmpty = Iterable.intersperse(empty, "-")
|
|
2319
|
-
*
|
|
2263
|
+
* Array.from(stillEmpty) // => []
|
|
2320
2264
|
*
|
|
2321
2265
|
* // Single element has no separators added
|
|
2322
2266
|
* const single = [42]
|
|
2323
2267
|
* const noSeparator = Iterable.intersperse(single, "|")
|
|
2324
|
-
*
|
|
2268
|
+
* Array.from(noSeparator) // => [42]
|
|
2325
2269
|
*
|
|
2326
2270
|
* // Build CSS-like strings
|
|
2327
2271
|
* const styles = ["color: red", "font-size: 14px", "margin: 10px"]
|
|
2328
2272
|
* const css = Iterable.intersperse(styles, "; ")
|
|
2329
|
-
*
|
|
2273
|
+
* Array.from(css).join("") // => "color: red; font-size: 14px; margin: 10px"
|
|
2330
2274
|
* ```
|
|
2331
2275
|
*
|
|
2332
2276
|
* @category combining
|
|
@@ -2360,7 +2304,7 @@ export const intersperse: {
|
|
|
2360
2304
|
*
|
|
2361
2305
|
* **Example** (Checking membership with custom equivalence)
|
|
2362
2306
|
*
|
|
2363
|
-
* ```ts
|
|
2307
|
+
* ```ts import.meta.vitest
|
|
2364
2308
|
* import { Iterable } from "effect"
|
|
2365
2309
|
*
|
|
2366
2310
|
* // Custom equivalence for objects
|
|
@@ -2369,7 +2313,7 @@ export const intersperse: {
|
|
|
2369
2313
|
*
|
|
2370
2314
|
* const users = [{ id: 1 }, { id: 2 }]
|
|
2371
2315
|
* const hasUser1 = containsById(users, { id: 1 })
|
|
2372
|
-
*
|
|
2316
|
+
* hasUser1 // => true
|
|
2373
2317
|
*
|
|
2374
2318
|
* // Case-insensitive string comparison
|
|
2375
2319
|
* const caseInsensitive = (a: string, b: string) =>
|
|
@@ -2378,7 +2322,7 @@ export const intersperse: {
|
|
|
2378
2322
|
*
|
|
2379
2323
|
* const words = ["Hello", "World"]
|
|
2380
2324
|
* const hasHello = containsCaseInsensitive(words, "hello")
|
|
2381
|
-
*
|
|
2325
|
+
* hasHello // => true
|
|
2382
2326
|
*
|
|
2383
2327
|
* // Approximate number comparison
|
|
2384
2328
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
@@ -2386,10 +2330,10 @@ export const intersperse: {
|
|
|
2386
2330
|
*
|
|
2387
2331
|
* const values = [1.0, 2.0, 3.0]
|
|
2388
2332
|
* const hasAlmostTwo = containsApprox(values, 2.05)
|
|
2389
|
-
*
|
|
2333
|
+
* hasAlmostTwo // => true
|
|
2390
2334
|
* ```
|
|
2391
2335
|
*
|
|
2392
|
-
* @category
|
|
2336
|
+
* @category predicates
|
|
2393
2337
|
* @since 2.0.0
|
|
2394
2338
|
*/
|
|
2395
2339
|
export const containsWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
|
|
@@ -2416,29 +2360,29 @@ export const containsWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
|
|
|
2416
2360
|
*
|
|
2417
2361
|
* **Example** (Checking membership)
|
|
2418
2362
|
*
|
|
2419
|
-
* ```ts
|
|
2363
|
+
* ```ts import.meta.vitest
|
|
2420
2364
|
* import { Iterable } from "effect"
|
|
2421
2365
|
*
|
|
2422
2366
|
* const numbers = [1, 2, 3, 4, 5]
|
|
2423
|
-
*
|
|
2424
|
-
*
|
|
2367
|
+
* Iterable.contains(numbers, 3) // => true
|
|
2368
|
+
* Iterable.contains(numbers, 6) // => false
|
|
2425
2369
|
*
|
|
2426
2370
|
* const letters = "hello"
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
2371
|
+
* Iterable.contains(letters, "l") // => true
|
|
2372
|
+
* Iterable.contains(letters, "x") // => false
|
|
2429
2373
|
*
|
|
2430
2374
|
* // Works with any iterable
|
|
2431
2375
|
* const range = Iterable.range(1, 100)
|
|
2432
|
-
*
|
|
2433
|
-
*
|
|
2376
|
+
* Iterable.contains(range, 50) // => true
|
|
2377
|
+
* Iterable.contains(range, 150) // => false
|
|
2434
2378
|
*
|
|
2435
2379
|
* // Curried version
|
|
2436
2380
|
* const containsThree = Iterable.contains(3)
|
|
2437
|
-
*
|
|
2438
|
-
*
|
|
2381
|
+
* containsThree([1, 2, 3]) // => true
|
|
2382
|
+
* containsThree([4, 5, 6]) // => false
|
|
2439
2383
|
* ```
|
|
2440
2384
|
*
|
|
2441
|
-
* @category
|
|
2385
|
+
* @category predicates
|
|
2442
2386
|
* @since 2.0.0
|
|
2443
2387
|
*/
|
|
2444
2388
|
export const contains: {
|
|
@@ -2453,29 +2397,29 @@ export const contains: {
|
|
|
2453
2397
|
*
|
|
2454
2398
|
* **Example** (Checking membership)
|
|
2455
2399
|
*
|
|
2456
|
-
* ```ts
|
|
2400
|
+
* ```ts import.meta.vitest
|
|
2457
2401
|
* import { Iterable } from "effect"
|
|
2458
2402
|
*
|
|
2459
2403
|
* const numbers = [1, 2, 3, 4, 5]
|
|
2460
|
-
*
|
|
2461
|
-
*
|
|
2404
|
+
* Iterable.contains(numbers, 3) // => true
|
|
2405
|
+
* Iterable.contains(numbers, 6) // => false
|
|
2462
2406
|
*
|
|
2463
2407
|
* const letters = "hello"
|
|
2464
|
-
*
|
|
2465
|
-
*
|
|
2408
|
+
* Iterable.contains(letters, "l") // => true
|
|
2409
|
+
* Iterable.contains(letters, "x") // => false
|
|
2466
2410
|
*
|
|
2467
2411
|
* // Works with any iterable
|
|
2468
2412
|
* const range = Iterable.range(1, 100)
|
|
2469
|
-
*
|
|
2470
|
-
*
|
|
2413
|
+
* Iterable.contains(range, 50) // => true
|
|
2414
|
+
* Iterable.contains(range, 150) // => false
|
|
2471
2415
|
*
|
|
2472
2416
|
* // Curried version
|
|
2473
2417
|
* const containsThree = Iterable.contains(3)
|
|
2474
|
-
*
|
|
2475
|
-
*
|
|
2418
|
+
* containsThree([1, 2, 3]) // => true
|
|
2419
|
+
* containsThree([4, 5, 6]) // => false
|
|
2476
2420
|
* ```
|
|
2477
2421
|
*
|
|
2478
|
-
* @category
|
|
2422
|
+
* @category predicates
|
|
2479
2423
|
* @since 2.0.0
|
|
2480
2424
|
*/
|
|
2481
2425
|
<A>(a: A): (self: Iterable<A>) => boolean
|
|
@@ -2490,29 +2434,29 @@ export const contains: {
|
|
|
2490
2434
|
*
|
|
2491
2435
|
* **Example** (Checking membership)
|
|
2492
2436
|
*
|
|
2493
|
-
* ```ts
|
|
2437
|
+
* ```ts import.meta.vitest
|
|
2494
2438
|
* import { Iterable } from "effect"
|
|
2495
2439
|
*
|
|
2496
2440
|
* const numbers = [1, 2, 3, 4, 5]
|
|
2497
|
-
*
|
|
2498
|
-
*
|
|
2441
|
+
* Iterable.contains(numbers, 3) // => true
|
|
2442
|
+
* Iterable.contains(numbers, 6) // => false
|
|
2499
2443
|
*
|
|
2500
2444
|
* const letters = "hello"
|
|
2501
|
-
*
|
|
2502
|
-
*
|
|
2445
|
+
* Iterable.contains(letters, "l") // => true
|
|
2446
|
+
* Iterable.contains(letters, "x") // => false
|
|
2503
2447
|
*
|
|
2504
2448
|
* // Works with any iterable
|
|
2505
2449
|
* const range = Iterable.range(1, 100)
|
|
2506
|
-
*
|
|
2507
|
-
*
|
|
2450
|
+
* Iterable.contains(range, 50) // => true
|
|
2451
|
+
* Iterable.contains(range, 150) // => false
|
|
2508
2452
|
*
|
|
2509
2453
|
* // Curried version
|
|
2510
2454
|
* const containsThree = Iterable.contains(3)
|
|
2511
|
-
*
|
|
2512
|
-
*
|
|
2455
|
+
* containsThree([1, 2, 3]) // => true
|
|
2456
|
+
* containsThree([4, 5, 6]) // => false
|
|
2513
2457
|
* ```
|
|
2514
2458
|
*
|
|
2515
|
-
* @category
|
|
2459
|
+
* @category predicates
|
|
2516
2460
|
* @since 2.0.0
|
|
2517
2461
|
*/
|
|
2518
2462
|
<A>(self: Iterable<A>, a: A): boolean
|
|
@@ -2524,25 +2468,22 @@ export const contains: {
|
|
|
2524
2468
|
*
|
|
2525
2469
|
* **Example** (Chunking an iterable)
|
|
2526
2470
|
*
|
|
2527
|
-
* ```ts
|
|
2471
|
+
* ```ts import.meta.vitest
|
|
2528
2472
|
* import { Iterable } from "effect"
|
|
2529
2473
|
*
|
|
2530
2474
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
2531
2475
|
* const chunks = Iterable.chunksOf(numbers, 3)
|
|
2532
|
-
*
|
|
2533
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2476
|
+
* Array.from(chunks) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2534
2477
|
*
|
|
2535
2478
|
* // Last chunk can be shorter
|
|
2536
2479
|
* const uneven = [1, 2, 3, 4, 5, 6, 7]
|
|
2537
2480
|
* const chunks2 = Iterable.chunksOf(uneven, 3)
|
|
2538
|
-
*
|
|
2539
|
-
* // [[1, 2, 3], [4, 5, 6], [7]]
|
|
2481
|
+
* Array.from(chunks2) // => [[1, 2, 3], [4, 5, 6], [7]]
|
|
2540
2482
|
*
|
|
2541
2483
|
* // Chunk size larger than iterable
|
|
2542
2484
|
* const small = [1, 2]
|
|
2543
2485
|
* const chunks3 = Iterable.chunksOf(small, 5)
|
|
2544
|
-
*
|
|
2545
|
-
* // [[1, 2]]
|
|
2486
|
+
* Array.from(chunks3) // => [[1, 2]]
|
|
2546
2487
|
*
|
|
2547
2488
|
* // Process data in batches
|
|
2548
2489
|
* const data = Iterable.range(1, 100)
|
|
@@ -2551,7 +2492,7 @@ export const contains: {
|
|
|
2551
2492
|
* batches,
|
|
2552
2493
|
* (batch) => Iterable.reduce(batch, 0, (sum, n) => sum + n)
|
|
2553
2494
|
* )
|
|
2554
|
-
*
|
|
2495
|
+
* Array.from(Iterable.take(batchSums, 3)) // => [55, 155, 255]
|
|
2555
2496
|
* ```
|
|
2556
2497
|
*
|
|
2557
2498
|
* @category splitting
|
|
@@ -2564,25 +2505,22 @@ export const chunksOf: {
|
|
|
2564
2505
|
*
|
|
2565
2506
|
* **Example** (Chunking an iterable)
|
|
2566
2507
|
*
|
|
2567
|
-
* ```ts
|
|
2508
|
+
* ```ts import.meta.vitest
|
|
2568
2509
|
* import { Iterable } from "effect"
|
|
2569
2510
|
*
|
|
2570
2511
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
2571
2512
|
* const chunks = Iterable.chunksOf(numbers, 3)
|
|
2572
|
-
*
|
|
2573
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2513
|
+
* Array.from(chunks) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2574
2514
|
*
|
|
2575
2515
|
* // Last chunk can be shorter
|
|
2576
2516
|
* const uneven = [1, 2, 3, 4, 5, 6, 7]
|
|
2577
2517
|
* const chunks2 = Iterable.chunksOf(uneven, 3)
|
|
2578
|
-
*
|
|
2579
|
-
* // [[1, 2, 3], [4, 5, 6], [7]]
|
|
2518
|
+
* Array.from(chunks2) // => [[1, 2, 3], [4, 5, 6], [7]]
|
|
2580
2519
|
*
|
|
2581
2520
|
* // Chunk size larger than iterable
|
|
2582
2521
|
* const small = [1, 2]
|
|
2583
2522
|
* const chunks3 = Iterable.chunksOf(small, 5)
|
|
2584
|
-
*
|
|
2585
|
-
* // [[1, 2]]
|
|
2523
|
+
* Array.from(chunks3) // => [[1, 2]]
|
|
2586
2524
|
*
|
|
2587
2525
|
* // Process data in batches
|
|
2588
2526
|
* const data = Iterable.range(1, 100)
|
|
@@ -2591,7 +2529,7 @@ export const chunksOf: {
|
|
|
2591
2529
|
* batches,
|
|
2592
2530
|
* (batch) => Iterable.reduce(batch, 0, (sum, n) => sum + n)
|
|
2593
2531
|
* )
|
|
2594
|
-
*
|
|
2532
|
+
* Array.from(Iterable.take(batchSums, 3)) // => [55, 155, 255]
|
|
2595
2533
|
* ```
|
|
2596
2534
|
*
|
|
2597
2535
|
* @category splitting
|
|
@@ -2604,25 +2542,22 @@ export const chunksOf: {
|
|
|
2604
2542
|
*
|
|
2605
2543
|
* **Example** (Chunking an iterable)
|
|
2606
2544
|
*
|
|
2607
|
-
* ```ts
|
|
2545
|
+
* ```ts import.meta.vitest
|
|
2608
2546
|
* import { Iterable } from "effect"
|
|
2609
2547
|
*
|
|
2610
2548
|
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
2611
2549
|
* const chunks = Iterable.chunksOf(numbers, 3)
|
|
2612
|
-
*
|
|
2613
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2550
|
+
* Array.from(chunks) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2614
2551
|
*
|
|
2615
2552
|
* // Last chunk can be shorter
|
|
2616
2553
|
* const uneven = [1, 2, 3, 4, 5, 6, 7]
|
|
2617
2554
|
* const chunks2 = Iterable.chunksOf(uneven, 3)
|
|
2618
|
-
*
|
|
2619
|
-
* // [[1, 2, 3], [4, 5, 6], [7]]
|
|
2555
|
+
* Array.from(chunks2) // => [[1, 2, 3], [4, 5, 6], [7]]
|
|
2620
2556
|
*
|
|
2621
2557
|
* // Chunk size larger than iterable
|
|
2622
2558
|
* const small = [1, 2]
|
|
2623
2559
|
* const chunks3 = Iterable.chunksOf(small, 5)
|
|
2624
|
-
*
|
|
2625
|
-
* // [[1, 2]]
|
|
2560
|
+
* Array.from(chunks3) // => [[1, 2]]
|
|
2626
2561
|
*
|
|
2627
2562
|
* // Process data in batches
|
|
2628
2563
|
* const data = Iterable.range(1, 100)
|
|
@@ -2631,7 +2566,7 @@ export const chunksOf: {
|
|
|
2631
2566
|
* batches,
|
|
2632
2567
|
* (batch) => Iterable.reduce(batch, 0, (sum, n) => sum + n)
|
|
2633
2568
|
* )
|
|
2634
|
-
*
|
|
2569
|
+
* Array.from(Iterable.take(batchSums, 3)) // => [55, 155, 255]
|
|
2635
2570
|
* ```
|
|
2636
2571
|
*
|
|
2637
2572
|
* @category splitting
|
|
@@ -2671,35 +2606,31 @@ export const chunksOf: {
|
|
|
2671
2606
|
*
|
|
2672
2607
|
* **Example** (Grouping consecutive elements with custom equivalence)
|
|
2673
2608
|
*
|
|
2674
|
-
* ```ts
|
|
2609
|
+
* ```ts import.meta.vitest
|
|
2675
2610
|
* import { Iterable } from "effect"
|
|
2676
2611
|
*
|
|
2677
2612
|
* // Group consecutive equal numbers
|
|
2678
2613
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2679
2614
|
* const grouped = Iterable.groupWith(numbers, (a, b) => a === b)
|
|
2680
|
-
*
|
|
2681
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2615
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2682
2616
|
*
|
|
2683
2617
|
* // Case-insensitive grouping of strings
|
|
2684
2618
|
* const words = ["Apple", "APPLE", "banana", "Banana", "cherry"]
|
|
2685
2619
|
* const caseInsensitive = (a: string, b: string) =>
|
|
2686
2620
|
* a.toLowerCase() === b.toLowerCase()
|
|
2687
2621
|
* const groupedWords = Iterable.groupWith(words, caseInsensitive)
|
|
2688
|
-
*
|
|
2689
|
-
* // [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2622
|
+
* Array.from(groupedWords) // => [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2690
2623
|
*
|
|
2691
2624
|
* // Group by approximate equality
|
|
2692
2625
|
* const floats = [1.1, 1.12, 1.9, 2.01, 2.05, 3.5]
|
|
2693
2626
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.2
|
|
2694
2627
|
* const groupedFloats = Iterable.groupWith(floats, approxEqual)
|
|
2695
|
-
*
|
|
2696
|
-
* // [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2628
|
+
* Array.from(groupedFloats) // => [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2697
2629
|
*
|
|
2698
2630
|
* // Only groups consecutive elements
|
|
2699
2631
|
* const scattered = [1, 2, 1, 2, 1]
|
|
2700
2632
|
* const scatteredGroups = Iterable.groupWith(scattered, (a, b) => a === b)
|
|
2701
|
-
*
|
|
2702
|
-
* // [[1], [2], [1], [2], [1]] (no grouping since none are consecutive)
|
|
2633
|
+
* Array.from(scatteredGroups) // => [[1], [2], [1], [2], [1]]
|
|
2703
2634
|
* ```
|
|
2704
2635
|
*
|
|
2705
2636
|
* @category grouping
|
|
@@ -2711,35 +2642,31 @@ export const groupWith: {
|
|
|
2711
2642
|
*
|
|
2712
2643
|
* **Example** (Grouping consecutive elements with custom equivalence)
|
|
2713
2644
|
*
|
|
2714
|
-
* ```ts
|
|
2645
|
+
* ```ts import.meta.vitest
|
|
2715
2646
|
* import { Iterable } from "effect"
|
|
2716
2647
|
*
|
|
2717
2648
|
* // Group consecutive equal numbers
|
|
2718
2649
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2719
2650
|
* const grouped = Iterable.groupWith(numbers, (a, b) => a === b)
|
|
2720
|
-
*
|
|
2721
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2651
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2722
2652
|
*
|
|
2723
2653
|
* // Case-insensitive grouping of strings
|
|
2724
2654
|
* const words = ["Apple", "APPLE", "banana", "Banana", "cherry"]
|
|
2725
2655
|
* const caseInsensitive = (a: string, b: string) =>
|
|
2726
2656
|
* a.toLowerCase() === b.toLowerCase()
|
|
2727
2657
|
* const groupedWords = Iterable.groupWith(words, caseInsensitive)
|
|
2728
|
-
*
|
|
2729
|
-
* // [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2658
|
+
* Array.from(groupedWords) // => [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2730
2659
|
*
|
|
2731
2660
|
* // Group by approximate equality
|
|
2732
2661
|
* const floats = [1.1, 1.12, 1.9, 2.01, 2.05, 3.5]
|
|
2733
2662
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.2
|
|
2734
2663
|
* const groupedFloats = Iterable.groupWith(floats, approxEqual)
|
|
2735
|
-
*
|
|
2736
|
-
* // [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2664
|
+
* Array.from(groupedFloats) // => [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2737
2665
|
*
|
|
2738
2666
|
* // Only groups consecutive elements
|
|
2739
2667
|
* const scattered = [1, 2, 1, 2, 1]
|
|
2740
2668
|
* const scatteredGroups = Iterable.groupWith(scattered, (a, b) => a === b)
|
|
2741
|
-
*
|
|
2742
|
-
* // [[1], [2], [1], [2], [1]] (no grouping since none are consecutive)
|
|
2669
|
+
* Array.from(scatteredGroups) // => [[1], [2], [1], [2], [1]]
|
|
2743
2670
|
* ```
|
|
2744
2671
|
*
|
|
2745
2672
|
* @category grouping
|
|
@@ -2751,35 +2678,31 @@ export const groupWith: {
|
|
|
2751
2678
|
*
|
|
2752
2679
|
* **Example** (Grouping consecutive elements with custom equivalence)
|
|
2753
2680
|
*
|
|
2754
|
-
* ```ts
|
|
2681
|
+
* ```ts import.meta.vitest
|
|
2755
2682
|
* import { Iterable } from "effect"
|
|
2756
2683
|
*
|
|
2757
2684
|
* // Group consecutive equal numbers
|
|
2758
2685
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2759
2686
|
* const grouped = Iterable.groupWith(numbers, (a, b) => a === b)
|
|
2760
|
-
*
|
|
2761
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2687
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2762
2688
|
*
|
|
2763
2689
|
* // Case-insensitive grouping of strings
|
|
2764
2690
|
* const words = ["Apple", "APPLE", "banana", "Banana", "cherry"]
|
|
2765
2691
|
* const caseInsensitive = (a: string, b: string) =>
|
|
2766
2692
|
* a.toLowerCase() === b.toLowerCase()
|
|
2767
2693
|
* const groupedWords = Iterable.groupWith(words, caseInsensitive)
|
|
2768
|
-
*
|
|
2769
|
-
* // [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2694
|
+
* Array.from(groupedWords) // => [["Apple", "APPLE"], ["banana", "Banana"], ["cherry"]]
|
|
2770
2695
|
*
|
|
2771
2696
|
* // Group by approximate equality
|
|
2772
2697
|
* const floats = [1.1, 1.12, 1.9, 2.01, 2.05, 3.5]
|
|
2773
2698
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.2
|
|
2774
2699
|
* const groupedFloats = Iterable.groupWith(floats, approxEqual)
|
|
2775
|
-
*
|
|
2776
|
-
* // [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2700
|
+
* Array.from(groupedFloats) // => [[1.1, 1.12], [1.9, 2.01, 2.05], [3.5]]
|
|
2777
2701
|
*
|
|
2778
2702
|
* // Only groups consecutive elements
|
|
2779
2703
|
* const scattered = [1, 2, 1, 2, 1]
|
|
2780
2704
|
* const scatteredGroups = Iterable.groupWith(scattered, (a, b) => a === b)
|
|
2781
|
-
*
|
|
2782
|
-
* // [[1], [2], [1], [2], [1]] (no grouping since none are consecutive)
|
|
2705
|
+
* Array.from(scatteredGroups) // => [[1], [2], [1], [2], [1]]
|
|
2783
2706
|
* ```
|
|
2784
2707
|
*
|
|
2785
2708
|
* @category grouping
|
|
@@ -2828,18 +2751,16 @@ export const groupWith: {
|
|
|
2828
2751
|
*
|
|
2829
2752
|
* **Example** (Grouping consecutive elements)
|
|
2830
2753
|
*
|
|
2831
|
-
* ```ts
|
|
2754
|
+
* ```ts import.meta.vitest
|
|
2832
2755
|
* import { Iterable } from "effect"
|
|
2833
2756
|
*
|
|
2834
2757
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
2835
2758
|
* const grouped = Iterable.group(numbers)
|
|
2836
|
-
*
|
|
2837
|
-
* // [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2759
|
+
* Array.from(grouped) // => [[1, 1], [2, 2, 2], [3], [1, 1]]
|
|
2838
2760
|
*
|
|
2839
2761
|
* const letters = "aabbccaa"
|
|
2840
2762
|
* const groupedLetters = Iterable.group(letters)
|
|
2841
|
-
*
|
|
2842
|
-
* // [["a", "a"], ["b", "b"], ["c", "c"], ["a", "a"]]
|
|
2763
|
+
* Array.from(groupedLetters) // => [["a", "a"], ["b", "b"], ["c", "c"], ["a", "a"]]
|
|
2843
2764
|
*
|
|
2844
2765
|
* // Works with objects using deep equality
|
|
2845
2766
|
* const objects = [
|
|
@@ -2849,7 +2770,7 @@ export const groupWith: {
|
|
|
2849
2770
|
* { type: "A", value: 1 }
|
|
2850
2771
|
* ]
|
|
2851
2772
|
* const groupedObjects = Iterable.group(objects)
|
|
2852
|
-
*
|
|
2773
|
+
* Array.from(groupedObjects).length // => 3
|
|
2853
2774
|
* // Note: Only consecutive equal objects are grouped together
|
|
2854
2775
|
* ```
|
|
2855
2776
|
*
|
|
@@ -2871,20 +2792,18 @@ export const group: <A>(self: Iterable<A>) => Iterable<NonEmptyArray<A>> = group
|
|
|
2871
2792
|
*
|
|
2872
2793
|
* **Example** (Grouping by a key)
|
|
2873
2794
|
*
|
|
2874
|
-
* ```ts
|
|
2795
|
+
* ```ts import.meta.vitest
|
|
2875
2796
|
* import { Iterable } from "effect"
|
|
2876
2797
|
*
|
|
2877
2798
|
* // Group by string length
|
|
2878
2799
|
* const words = ["a", "bb", "ccc", "dd", "eee", "f"]
|
|
2879
2800
|
* const byLength = Iterable.groupBy(words, (word) => word.length.toString())
|
|
2880
|
-
*
|
|
2881
|
-
* // { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2801
|
+
* byLength // => { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2882
2802
|
*
|
|
2883
2803
|
* // Group by first letter
|
|
2884
2804
|
* const names = ["Alice", "Bob", "Charlie", "David", "Anna", "Betty"]
|
|
2885
2805
|
* const byFirstLetter = Iterable.groupBy(names, (name) => name[0])
|
|
2886
|
-
*
|
|
2887
|
-
* // { "A": ["Alice", "Anna"], "B": ["Bob", "Betty"], "C": ["Charlie"], "D": ["David"] }
|
|
2806
|
+
* byFirstLetter // => { A: ["Alice", "Anna"], B: ["Bob", "Betty"], C: ["Charlie"], D: ["David"] }
|
|
2888
2807
|
*
|
|
2889
2808
|
* // Group by category
|
|
2890
2809
|
* const items = [
|
|
@@ -2894,17 +2813,12 @@ export const group: <A>(self: Iterable<A>) => Iterable<NonEmptyArray<A>> = group
|
|
|
2894
2813
|
* { name: "broccoli", category: "vegetable" }
|
|
2895
2814
|
* ]
|
|
2896
2815
|
* const byCategory = Iterable.groupBy(items, (item) => item.category)
|
|
2897
|
-
*
|
|
2898
|
-
* // {
|
|
2899
|
-
* // "fruit": [{ name: "apple", category: "fruit" }, { name: "banana", category: "fruit" }],
|
|
2900
|
-
* // "vegetable": [{ name: "carrot", category: "vegetable" }, { name: "broccoli", category: "vegetable" }]
|
|
2901
|
-
* // }
|
|
2816
|
+
* Object.keys(byCategory) // => ["fruit", "vegetable"]
|
|
2902
2817
|
*
|
|
2903
2818
|
* // Group numbers by even/odd
|
|
2904
2819
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
2905
2820
|
* const evenOdd = Iterable.groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd")
|
|
2906
|
-
*
|
|
2907
|
-
* // { "odd": [1, 3, 5], "even": [2, 4, 6] }
|
|
2821
|
+
* evenOdd // => { odd: [1, 3, 5], even: [2, 4, 6] }
|
|
2908
2822
|
* ```
|
|
2909
2823
|
*
|
|
2910
2824
|
* @category grouping
|
|
@@ -2922,20 +2836,18 @@ export const groupBy: {
|
|
|
2922
2836
|
*
|
|
2923
2837
|
* **Example** (Grouping by a key)
|
|
2924
2838
|
*
|
|
2925
|
-
* ```ts
|
|
2839
|
+
* ```ts import.meta.vitest
|
|
2926
2840
|
* import { Iterable } from "effect"
|
|
2927
2841
|
*
|
|
2928
2842
|
* // Group by string length
|
|
2929
2843
|
* const words = ["a", "bb", "ccc", "dd", "eee", "f"]
|
|
2930
2844
|
* const byLength = Iterable.groupBy(words, (word) => word.length.toString())
|
|
2931
|
-
*
|
|
2932
|
-
* // { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2845
|
+
* byLength // => { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2933
2846
|
*
|
|
2934
2847
|
* // Group by first letter
|
|
2935
2848
|
* const names = ["Alice", "Bob", "Charlie", "David", "Anna", "Betty"]
|
|
2936
2849
|
* const byFirstLetter = Iterable.groupBy(names, (name) => name[0])
|
|
2937
|
-
*
|
|
2938
|
-
* // { "A": ["Alice", "Anna"], "B": ["Bob", "Betty"], "C": ["Charlie"], "D": ["David"] }
|
|
2850
|
+
* byFirstLetter // => { A: ["Alice", "Anna"], B: ["Bob", "Betty"], C: ["Charlie"], D: ["David"] }
|
|
2939
2851
|
*
|
|
2940
2852
|
* // Group by category
|
|
2941
2853
|
* const items = [
|
|
@@ -2945,17 +2857,12 @@ export const groupBy: {
|
|
|
2945
2857
|
* { name: "broccoli", category: "vegetable" }
|
|
2946
2858
|
* ]
|
|
2947
2859
|
* const byCategory = Iterable.groupBy(items, (item) => item.category)
|
|
2948
|
-
*
|
|
2949
|
-
* // {
|
|
2950
|
-
* // "fruit": [{ name: "apple", category: "fruit" }, { name: "banana", category: "fruit" }],
|
|
2951
|
-
* // "vegetable": [{ name: "carrot", category: "vegetable" }, { name: "broccoli", category: "vegetable" }]
|
|
2952
|
-
* // }
|
|
2860
|
+
* Object.keys(byCategory) // => ["fruit", "vegetable"]
|
|
2953
2861
|
*
|
|
2954
2862
|
* // Group numbers by even/odd
|
|
2955
2863
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
2956
2864
|
* const evenOdd = Iterable.groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd")
|
|
2957
|
-
*
|
|
2958
|
-
* // { "odd": [1, 3, 5], "even": [2, 4, 6] }
|
|
2865
|
+
* evenOdd // => { odd: [1, 3, 5], even: [2, 4, 6] }
|
|
2959
2866
|
* ```
|
|
2960
2867
|
*
|
|
2961
2868
|
* @category grouping
|
|
@@ -2973,20 +2880,18 @@ export const groupBy: {
|
|
|
2973
2880
|
*
|
|
2974
2881
|
* **Example** (Grouping by a key)
|
|
2975
2882
|
*
|
|
2976
|
-
* ```ts
|
|
2883
|
+
* ```ts import.meta.vitest
|
|
2977
2884
|
* import { Iterable } from "effect"
|
|
2978
2885
|
*
|
|
2979
2886
|
* // Group by string length
|
|
2980
2887
|
* const words = ["a", "bb", "ccc", "dd", "eee", "f"]
|
|
2981
2888
|
* const byLength = Iterable.groupBy(words, (word) => word.length.toString())
|
|
2982
|
-
*
|
|
2983
|
-
* // { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2889
|
+
* byLength // => { "1": ["a", "f"], "2": ["bb", "dd"], "3": ["ccc", "eee"] }
|
|
2984
2890
|
*
|
|
2985
2891
|
* // Group by first letter
|
|
2986
2892
|
* const names = ["Alice", "Bob", "Charlie", "David", "Anna", "Betty"]
|
|
2987
2893
|
* const byFirstLetter = Iterable.groupBy(names, (name) => name[0])
|
|
2988
|
-
*
|
|
2989
|
-
* // { "A": ["Alice", "Anna"], "B": ["Bob", "Betty"], "C": ["Charlie"], "D": ["David"] }
|
|
2894
|
+
* byFirstLetter // => { A: ["Alice", "Anna"], B: ["Bob", "Betty"], C: ["Charlie"], D: ["David"] }
|
|
2990
2895
|
*
|
|
2991
2896
|
* // Group by category
|
|
2992
2897
|
* const items = [
|
|
@@ -2996,17 +2901,12 @@ export const groupBy: {
|
|
|
2996
2901
|
* { name: "broccoli", category: "vegetable" }
|
|
2997
2902
|
* ]
|
|
2998
2903
|
* const byCategory = Iterable.groupBy(items, (item) => item.category)
|
|
2999
|
-
*
|
|
3000
|
-
* // {
|
|
3001
|
-
* // "fruit": [{ name: "apple", category: "fruit" }, { name: "banana", category: "fruit" }],
|
|
3002
|
-
* // "vegetable": [{ name: "carrot", category: "vegetable" }, { name: "broccoli", category: "vegetable" }]
|
|
3003
|
-
* // }
|
|
2904
|
+
* Object.keys(byCategory) // => ["fruit", "vegetable"]
|
|
3004
2905
|
*
|
|
3005
2906
|
* // Group numbers by even/odd
|
|
3006
2907
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3007
2908
|
* const evenOdd = Iterable.groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd")
|
|
3008
|
-
*
|
|
3009
|
-
* // { "odd": [1, 3, 5], "even": [2, 4, 6] }
|
|
2909
|
+
* evenOdd // => { odd: [1, 3, 5], even: [2, 4, 6] }
|
|
3010
2910
|
* ```
|
|
3011
2911
|
*
|
|
3012
2912
|
* @category grouping
|
|
@@ -3023,7 +2923,7 @@ export const groupBy: {
|
|
|
3023
2923
|
if (Object.hasOwn(out, k)) {
|
|
3024
2924
|
out[k].push(a)
|
|
3025
2925
|
} else {
|
|
3026
|
-
out
|
|
2926
|
+
InternalRecord.assignProperty(out, k, [a])
|
|
3027
2927
|
}
|
|
3028
2928
|
}
|
|
3029
2929
|
return out
|
|
@@ -3050,18 +2950,10 @@ const constEmptyIterator: Iterator<never> = {
|
|
|
3050
2950
|
*
|
|
3051
2951
|
* **Example** (Creating an empty iterable)
|
|
3052
2952
|
*
|
|
3053
|
-
* ```ts
|
|
2953
|
+
* ```ts import.meta.vitest
|
|
3054
2954
|
* import { Iterable } from "effect"
|
|
3055
2955
|
*
|
|
3056
|
-
*
|
|
3057
|
-
* console.log(Array.from(empty)) // []
|
|
3058
|
-
* console.log(Iterable.isEmpty(empty)) // true
|
|
3059
|
-
*
|
|
3060
|
-
* // Useful as base case for reductions
|
|
3061
|
-
* const hasData = true
|
|
3062
|
-
* const result = hasData
|
|
3063
|
-
* ? Iterable.range(1, 5)
|
|
3064
|
-
* : Iterable.empty<number>()
|
|
2956
|
+
* Array.from(Iterable.empty<string>()) // => []
|
|
3065
2957
|
* ```
|
|
3066
2958
|
*
|
|
3067
2959
|
* @category constructors
|
|
@@ -3079,11 +2971,11 @@ export const empty = <A = never>(): Iterable<A> => constEmpty
|
|
|
3079
2971
|
*
|
|
3080
2972
|
* **Example** (Wrapping a single value)
|
|
3081
2973
|
*
|
|
3082
|
-
* ```ts
|
|
2974
|
+
* ```ts import.meta.vitest
|
|
3083
2975
|
* import { Iterable } from "effect"
|
|
3084
2976
|
*
|
|
3085
2977
|
* const single = Iterable.of(42)
|
|
3086
|
-
*
|
|
2978
|
+
* Array.from(single) // => [42]
|
|
3087
2979
|
*
|
|
3088
2980
|
* // Useful for creating homogeneous sequences
|
|
3089
2981
|
* const sequences = [
|
|
@@ -3098,7 +2990,7 @@ export const empty = <A = never>(): Iterable<A> => constEmpty
|
|
|
3098
2990
|
* numbers,
|
|
3099
2991
|
* (n) => n % 2 === 0 ? Iterable.of(n) : Iterable.empty()
|
|
3100
2992
|
* )
|
|
3101
|
-
*
|
|
2993
|
+
* Array.from(evensOnly) // => [2, 4]
|
|
3102
2994
|
* ```
|
|
3103
2995
|
*
|
|
3104
2996
|
* @category constructors
|
|
@@ -3118,24 +3010,22 @@ export const of = <A>(a: A): Iterable<A> => [a]
|
|
|
3118
3010
|
*
|
|
3119
3011
|
* **Example** (Mapping elements)
|
|
3120
3012
|
*
|
|
3121
|
-
* ```ts
|
|
3013
|
+
* ```ts import.meta.vitest
|
|
3122
3014
|
* import { Iterable } from "effect"
|
|
3123
3015
|
*
|
|
3124
3016
|
* // Transform numbers to their squares
|
|
3125
3017
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3126
3018
|
* const squares = Iterable.map(numbers, (x) => x * x)
|
|
3127
|
-
*
|
|
3019
|
+
* Array.from(squares) // => [1, 4, 9, 16, 25]
|
|
3128
3020
|
*
|
|
3129
3021
|
* // Use index in transformation
|
|
3130
3022
|
* const indexed = Iterable.map(["a", "b", "c"], (char, i) => `${i}: ${char}`)
|
|
3131
|
-
*
|
|
3023
|
+
* Array.from(indexed) // => ["0: a", "1: b", "2: c"]
|
|
3132
3024
|
*
|
|
3133
|
-
*
|
|
3134
|
-
* const result = Iterable.map(
|
|
3025
|
+
* Array.from(Iterable.map(
|
|
3135
3026
|
* Iterable.map([1, 2, 3], (x) => x * 2),
|
|
3136
3027
|
* (x) => x + 1
|
|
3137
|
-
* )
|
|
3138
|
-
* console.log(Array.from(result)) // [3, 5, 7]
|
|
3028
|
+
* )) // => [3, 5, 7]
|
|
3139
3029
|
* ```
|
|
3140
3030
|
*
|
|
3141
3031
|
* @category mapping
|
|
@@ -3154,24 +3044,22 @@ export const map: {
|
|
|
3154
3044
|
*
|
|
3155
3045
|
* **Example** (Mapping elements)
|
|
3156
3046
|
*
|
|
3157
|
-
* ```ts
|
|
3047
|
+
* ```ts import.meta.vitest
|
|
3158
3048
|
* import { Iterable } from "effect"
|
|
3159
3049
|
*
|
|
3160
3050
|
* // Transform numbers to their squares
|
|
3161
3051
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3162
3052
|
* const squares = Iterable.map(numbers, (x) => x * x)
|
|
3163
|
-
*
|
|
3053
|
+
* Array.from(squares) // => [1, 4, 9, 16, 25]
|
|
3164
3054
|
*
|
|
3165
3055
|
* // Use index in transformation
|
|
3166
3056
|
* const indexed = Iterable.map(["a", "b", "c"], (char, i) => `${i}: ${char}`)
|
|
3167
|
-
*
|
|
3057
|
+
* Array.from(indexed) // => ["0: a", "1: b", "2: c"]
|
|
3168
3058
|
*
|
|
3169
|
-
*
|
|
3170
|
-
* const result = Iterable.map(
|
|
3059
|
+
* Array.from(Iterable.map(
|
|
3171
3060
|
* Iterable.map([1, 2, 3], (x) => x * 2),
|
|
3172
3061
|
* (x) => x + 1
|
|
3173
|
-
* )
|
|
3174
|
-
* console.log(Array.from(result)) // [3, 5, 7]
|
|
3062
|
+
* )) // => [3, 5, 7]
|
|
3175
3063
|
* ```
|
|
3176
3064
|
*
|
|
3177
3065
|
* @category mapping
|
|
@@ -3190,24 +3078,22 @@ export const map: {
|
|
|
3190
3078
|
*
|
|
3191
3079
|
* **Example** (Mapping elements)
|
|
3192
3080
|
*
|
|
3193
|
-
* ```ts
|
|
3081
|
+
* ```ts import.meta.vitest
|
|
3194
3082
|
* import { Iterable } from "effect"
|
|
3195
3083
|
*
|
|
3196
3084
|
* // Transform numbers to their squares
|
|
3197
3085
|
* const numbers = [1, 2, 3, 4, 5]
|
|
3198
3086
|
* const squares = Iterable.map(numbers, (x) => x * x)
|
|
3199
|
-
*
|
|
3087
|
+
* Array.from(squares) // => [1, 4, 9, 16, 25]
|
|
3200
3088
|
*
|
|
3201
3089
|
* // Use index in transformation
|
|
3202
3090
|
* const indexed = Iterable.map(["a", "b", "c"], (char, i) => `${i}: ${char}`)
|
|
3203
|
-
*
|
|
3091
|
+
* Array.from(indexed) // => ["0: a", "1: b", "2: c"]
|
|
3204
3092
|
*
|
|
3205
|
-
*
|
|
3206
|
-
* const result = Iterable.map(
|
|
3093
|
+
* Array.from(Iterable.map(
|
|
3207
3094
|
* Iterable.map([1, 2, 3], (x) => x * 2),
|
|
3208
3095
|
* (x) => x + 1
|
|
3209
|
-
* )
|
|
3210
|
-
* console.log(Array.from(result)) // [3, 5, 7]
|
|
3096
|
+
* )) // => [3, 5, 7]
|
|
3211
3097
|
* ```
|
|
3212
3098
|
*
|
|
3213
3099
|
* @category mapping
|
|
@@ -3235,18 +3121,18 @@ export const map: {
|
|
|
3235
3121
|
*
|
|
3236
3122
|
* **Example** (Flat mapping iterables)
|
|
3237
3123
|
*
|
|
3238
|
-
* ```ts
|
|
3124
|
+
* ```ts import.meta.vitest
|
|
3239
3125
|
* import { Iterable } from "effect"
|
|
3240
3126
|
*
|
|
3241
3127
|
* // Expand each number to a range
|
|
3242
3128
|
* const numbers = [1, 2, 3]
|
|
3243
3129
|
* const expanded = Iterable.flatMap(numbers, (n) => Iterable.range(1, n))
|
|
3244
|
-
*
|
|
3130
|
+
* Array.from(expanded) // => [1, 1, 2, 1, 2, 3]
|
|
3245
3131
|
*
|
|
3246
3132
|
* // Split strings into characters
|
|
3247
3133
|
* const words = ["hi", "bye"]
|
|
3248
3134
|
* const chars = Iterable.flatMap(words, (word) => word)
|
|
3249
|
-
*
|
|
3135
|
+
* Array.from(chars) // => ["h", "i", "b", "y", "e"]
|
|
3250
3136
|
*
|
|
3251
3137
|
* // Conditional expansion with empty iterables
|
|
3252
3138
|
* const values = [1, 2, 3, 4, 5]
|
|
@@ -3254,7 +3140,7 @@ export const map: {
|
|
|
3254
3140
|
* values,
|
|
3255
3141
|
* (n) => n % 2 === 0 ? [n, n * 2, n * 3] : []
|
|
3256
3142
|
* )
|
|
3257
|
-
*
|
|
3143
|
+
* Array.from(evenMultiples) // => [2, 4, 6, 4, 8, 12]
|
|
3258
3144
|
*
|
|
3259
3145
|
* // Use index in transformation
|
|
3260
3146
|
* const letters = ["a", "b", "c"]
|
|
@@ -3262,7 +3148,7 @@ export const map: {
|
|
|
3262
3148
|
* letters,
|
|
3263
3149
|
* (letter, i) => Iterable.replicate(letter, i + 1)
|
|
3264
3150
|
* )
|
|
3265
|
-
*
|
|
3151
|
+
* Array.from(indexed) // => ["a", "b", "b", "c", "c", "c"]
|
|
3266
3152
|
* ```
|
|
3267
3153
|
*
|
|
3268
3154
|
* @category sequencing
|
|
@@ -3274,18 +3160,18 @@ export const flatMap: {
|
|
|
3274
3160
|
*
|
|
3275
3161
|
* **Example** (Flat mapping iterables)
|
|
3276
3162
|
*
|
|
3277
|
-
* ```ts
|
|
3163
|
+
* ```ts import.meta.vitest
|
|
3278
3164
|
* import { Iterable } from "effect"
|
|
3279
3165
|
*
|
|
3280
3166
|
* // Expand each number to a range
|
|
3281
3167
|
* const numbers = [1, 2, 3]
|
|
3282
3168
|
* const expanded = Iterable.flatMap(numbers, (n) => Iterable.range(1, n))
|
|
3283
|
-
*
|
|
3169
|
+
* Array.from(expanded) // => [1, 1, 2, 1, 2, 3]
|
|
3284
3170
|
*
|
|
3285
3171
|
* // Split strings into characters
|
|
3286
3172
|
* const words = ["hi", "bye"]
|
|
3287
3173
|
* const chars = Iterable.flatMap(words, (word) => word)
|
|
3288
|
-
*
|
|
3174
|
+
* Array.from(chars) // => ["h", "i", "b", "y", "e"]
|
|
3289
3175
|
*
|
|
3290
3176
|
* // Conditional expansion with empty iterables
|
|
3291
3177
|
* const values = [1, 2, 3, 4, 5]
|
|
@@ -3293,7 +3179,7 @@ export const flatMap: {
|
|
|
3293
3179
|
* values,
|
|
3294
3180
|
* (n) => n % 2 === 0 ? [n, n * 2, n * 3] : []
|
|
3295
3181
|
* )
|
|
3296
|
-
*
|
|
3182
|
+
* Array.from(evenMultiples) // => [2, 4, 6, 4, 8, 12]
|
|
3297
3183
|
*
|
|
3298
3184
|
* // Use index in transformation
|
|
3299
3185
|
* const letters = ["a", "b", "c"]
|
|
@@ -3301,7 +3187,7 @@ export const flatMap: {
|
|
|
3301
3187
|
* letters,
|
|
3302
3188
|
* (letter, i) => Iterable.replicate(letter, i + 1)
|
|
3303
3189
|
* )
|
|
3304
|
-
*
|
|
3190
|
+
* Array.from(indexed) // => ["a", "b", "b", "c", "c", "c"]
|
|
3305
3191
|
* ```
|
|
3306
3192
|
*
|
|
3307
3193
|
* @category sequencing
|
|
@@ -3313,18 +3199,18 @@ export const flatMap: {
|
|
|
3313
3199
|
*
|
|
3314
3200
|
* **Example** (Flat mapping iterables)
|
|
3315
3201
|
*
|
|
3316
|
-
* ```ts
|
|
3202
|
+
* ```ts import.meta.vitest
|
|
3317
3203
|
* import { Iterable } from "effect"
|
|
3318
3204
|
*
|
|
3319
3205
|
* // Expand each number to a range
|
|
3320
3206
|
* const numbers = [1, 2, 3]
|
|
3321
3207
|
* const expanded = Iterable.flatMap(numbers, (n) => Iterable.range(1, n))
|
|
3322
|
-
*
|
|
3208
|
+
* Array.from(expanded) // => [1, 1, 2, 1, 2, 3]
|
|
3323
3209
|
*
|
|
3324
3210
|
* // Split strings into characters
|
|
3325
3211
|
* const words = ["hi", "bye"]
|
|
3326
3212
|
* const chars = Iterable.flatMap(words, (word) => word)
|
|
3327
|
-
*
|
|
3213
|
+
* Array.from(chars) // => ["h", "i", "b", "y", "e"]
|
|
3328
3214
|
*
|
|
3329
3215
|
* // Conditional expansion with empty iterables
|
|
3330
3216
|
* const values = [1, 2, 3, 4, 5]
|
|
@@ -3332,7 +3218,7 @@ export const flatMap: {
|
|
|
3332
3218
|
* values,
|
|
3333
3219
|
* (n) => n % 2 === 0 ? [n, n * 2, n * 3] : []
|
|
3334
3220
|
* )
|
|
3335
|
-
*
|
|
3221
|
+
* Array.from(evenMultiples) // => [2, 4, 6, 4, 8, 12]
|
|
3336
3222
|
*
|
|
3337
3223
|
* // Use index in transformation
|
|
3338
3224
|
* const letters = ["a", "b", "c"]
|
|
@@ -3340,7 +3226,7 @@ export const flatMap: {
|
|
|
3340
3226
|
* letters,
|
|
3341
3227
|
* (letter, i) => Iterable.replicate(letter, i + 1)
|
|
3342
3228
|
* )
|
|
3343
|
-
*
|
|
3229
|
+
* Array.from(indexed) // => ["a", "b", "b", "c", "c", "c"]
|
|
3344
3230
|
* ```
|
|
3345
3231
|
*
|
|
3346
3232
|
* @category sequencing
|
|
@@ -3357,29 +3243,29 @@ export const flatMap: {
|
|
|
3357
3243
|
*
|
|
3358
3244
|
* **Example** (Flattening nested iterables)
|
|
3359
3245
|
*
|
|
3360
|
-
* ```ts
|
|
3246
|
+
* ```ts import.meta.vitest
|
|
3361
3247
|
* import { Iterable } from "effect"
|
|
3362
3248
|
*
|
|
3363
3249
|
* // Flatten nested arrays
|
|
3364
3250
|
* const nested = [[1, 2], [3, 4], [5, 6]]
|
|
3365
3251
|
* const flat = Iterable.flatten(nested)
|
|
3366
|
-
*
|
|
3252
|
+
* Array.from(flat) // => [1, 2, 3, 4, 5, 6]
|
|
3367
3253
|
*
|
|
3368
3254
|
* // Flatten different iterable types
|
|
3369
3255
|
* const mixed: Array<Iterable<string>> = ["ab", "cd"]
|
|
3370
3256
|
* const flatMixed = Iterable.flatten(mixed)
|
|
3371
|
-
*
|
|
3257
|
+
* Array.from(flatMixed) // => ["a", "b", "c", "d"]
|
|
3372
3258
|
*
|
|
3373
3259
|
* // Flatten deeply nested (only one level)
|
|
3374
3260
|
* const deepNested = [[[1, 2]], [[3, 4]]]
|
|
3375
3261
|
* const oneLevelFlat = Iterable.flatten(deepNested)
|
|
3376
|
-
*
|
|
3262
|
+
* Array.from(oneLevelFlat) // => [[1, 2], [3, 4]]
|
|
3377
3263
|
* // [[1, 2], [3, 4]] (still contains arrays)
|
|
3378
3264
|
*
|
|
3379
3265
|
* // Empty iterables are handled correctly
|
|
3380
3266
|
* const withEmpty = [[1, 2], [], [3, 4], []]
|
|
3381
3267
|
* const flatWithEmpty = Iterable.flatten(withEmpty)
|
|
3382
|
-
*
|
|
3268
|
+
* Array.from(flatWithEmpty) // => [1, 2, 3, 4]
|
|
3383
3269
|
* ```
|
|
3384
3270
|
*
|
|
3385
3271
|
* @category sequencing
|
|
@@ -3390,19 +3276,20 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3390
3276
|
const outerIterator = self[Symbol.iterator]()
|
|
3391
3277
|
let innerIterator: Iterator<A> | undefined
|
|
3392
3278
|
function next() {
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3279
|
+
while (true) {
|
|
3280
|
+
if (innerIterator === undefined) {
|
|
3281
|
+
const next = outerIterator.next()
|
|
3282
|
+
if (next.done) {
|
|
3283
|
+
return next
|
|
3284
|
+
}
|
|
3285
|
+
innerIterator = next.value[Symbol.iterator]()
|
|
3286
|
+
}
|
|
3287
|
+
const result = innerIterator.next()
|
|
3288
|
+
if (!result.done) {
|
|
3289
|
+
return result
|
|
3397
3290
|
}
|
|
3398
|
-
innerIterator = next.value[Symbol.iterator]()
|
|
3399
|
-
}
|
|
3400
|
-
const result = innerIterator.next()
|
|
3401
|
-
if (result.done) {
|
|
3402
3291
|
innerIterator = undefined
|
|
3403
|
-
return next()
|
|
3404
3292
|
}
|
|
3405
|
-
return result
|
|
3406
3293
|
}
|
|
3407
3294
|
return { next }
|
|
3408
3295
|
}
|
|
@@ -3419,7 +3306,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3419
3306
|
*
|
|
3420
3307
|
* **Example** (Filtering and transforming Result values)
|
|
3421
3308
|
*
|
|
3422
|
-
* ```ts
|
|
3309
|
+
* ```ts import.meta.vitest
|
|
3423
3310
|
* import { Iterable, Result } from "effect"
|
|
3424
3311
|
*
|
|
3425
3312
|
* // Parse strings to numbers, keeping only valid ones
|
|
@@ -3428,7 +3315,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3428
3315
|
* const num = parseInt(s)
|
|
3429
3316
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3430
3317
|
* })
|
|
3431
|
-
*
|
|
3318
|
+
* Array.from(numbers) // => [1, 2, 4]
|
|
3432
3319
|
*
|
|
3433
3320
|
* // Extract specific properties from objects
|
|
3434
3321
|
* const users = [
|
|
@@ -3442,7 +3329,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3442
3329
|
* (user) =>
|
|
3443
3330
|
* user.age >= 18 && user.email ? Result.succeed(user.email) : Result.failVoid
|
|
3444
3331
|
* )
|
|
3445
|
-
*
|
|
3332
|
+
* Array.from(adultEmails) // => ["alice@example.com", "charlie@example.com"]
|
|
3446
3333
|
*
|
|
3447
3334
|
* // Use index in transformation
|
|
3448
3335
|
* const items = ["a", "b", "c", "d", "e"]
|
|
@@ -3450,7 +3337,7 @@ export const flatten = <A>(self: Iterable<Iterable<A>>): Iterable<A> => ({
|
|
|
3450
3337
|
* items,
|
|
3451
3338
|
* (item, i) => i % 2 === 0 ? Result.succeed(`${i}: ${item}`) : Result.failVoid
|
|
3452
3339
|
* )
|
|
3453
|
-
*
|
|
3340
|
+
* Array.from(evenIndexItems) // => ["0: a", "2: c", "4: e"]
|
|
3454
3341
|
* ```
|
|
3455
3342
|
*
|
|
3456
3343
|
* @category filtering
|
|
@@ -3468,7 +3355,7 @@ export const filterMap: {
|
|
|
3468
3355
|
*
|
|
3469
3356
|
* **Example** (Filtering and transforming Result values)
|
|
3470
3357
|
*
|
|
3471
|
-
* ```ts
|
|
3358
|
+
* ```ts import.meta.vitest
|
|
3472
3359
|
* import { Iterable, Result } from "effect"
|
|
3473
3360
|
*
|
|
3474
3361
|
* // Parse strings to numbers, keeping only valid ones
|
|
@@ -3477,7 +3364,7 @@ export const filterMap: {
|
|
|
3477
3364
|
* const num = parseInt(s)
|
|
3478
3365
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3479
3366
|
* })
|
|
3480
|
-
*
|
|
3367
|
+
* Array.from(numbers) // => [1, 2, 4]
|
|
3481
3368
|
*
|
|
3482
3369
|
* // Extract specific properties from objects
|
|
3483
3370
|
* const users = [
|
|
@@ -3491,7 +3378,7 @@ export const filterMap: {
|
|
|
3491
3378
|
* (user) =>
|
|
3492
3379
|
* user.age >= 18 && user.email ? Result.succeed(user.email) : Result.failVoid
|
|
3493
3380
|
* )
|
|
3494
|
-
*
|
|
3381
|
+
* Array.from(adultEmails) // => ["alice@example.com", "charlie@example.com"]
|
|
3495
3382
|
*
|
|
3496
3383
|
* // Use index in transformation
|
|
3497
3384
|
* const items = ["a", "b", "c", "d", "e"]
|
|
@@ -3499,7 +3386,7 @@ export const filterMap: {
|
|
|
3499
3386
|
* items,
|
|
3500
3387
|
* (item, i) => i % 2 === 0 ? Result.succeed(`${i}: ${item}`) : Result.failVoid
|
|
3501
3388
|
* )
|
|
3502
|
-
*
|
|
3389
|
+
* Array.from(evenIndexItems) // => ["0: a", "2: c", "4: e"]
|
|
3503
3390
|
* ```
|
|
3504
3391
|
*
|
|
3505
3392
|
* @category filtering
|
|
@@ -3517,7 +3404,7 @@ export const filterMap: {
|
|
|
3517
3404
|
*
|
|
3518
3405
|
* **Example** (Filtering and transforming Result values)
|
|
3519
3406
|
*
|
|
3520
|
-
* ```ts
|
|
3407
|
+
* ```ts import.meta.vitest
|
|
3521
3408
|
* import { Iterable, Result } from "effect"
|
|
3522
3409
|
*
|
|
3523
3410
|
* // Parse strings to numbers, keeping only valid ones
|
|
@@ -3526,7 +3413,7 @@ export const filterMap: {
|
|
|
3526
3413
|
* const num = parseInt(s)
|
|
3527
3414
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3528
3415
|
* })
|
|
3529
|
-
*
|
|
3416
|
+
* Array.from(numbers) // => [1, 2, 4]
|
|
3530
3417
|
*
|
|
3531
3418
|
* // Extract specific properties from objects
|
|
3532
3419
|
* const users = [
|
|
@@ -3540,7 +3427,7 @@ export const filterMap: {
|
|
|
3540
3427
|
* (user) =>
|
|
3541
3428
|
* user.age >= 18 && user.email ? Result.succeed(user.email) : Result.failVoid
|
|
3542
3429
|
* )
|
|
3543
|
-
*
|
|
3430
|
+
* Array.from(adultEmails) // => ["alice@example.com", "charlie@example.com"]
|
|
3544
3431
|
*
|
|
3545
3432
|
* // Use index in transformation
|
|
3546
3433
|
* const items = ["a", "b", "c", "d", "e"]
|
|
@@ -3548,7 +3435,7 @@ export const filterMap: {
|
|
|
3548
3435
|
* items,
|
|
3549
3436
|
* (item, i) => i % 2 === 0 ? Result.succeed(`${i}: ${item}`) : Result.failVoid
|
|
3550
3437
|
* )
|
|
3551
|
-
*
|
|
3438
|
+
* Array.from(evenIndexItems) // => ["0: a", "2: c", "4: e"]
|
|
3552
3439
|
* ```
|
|
3553
3440
|
*
|
|
3554
3441
|
* @category filtering
|
|
@@ -3583,7 +3470,7 @@ export const filterMap: {
|
|
|
3583
3470
|
*
|
|
3584
3471
|
* **Example** (Filtering and transforming until failure)
|
|
3585
3472
|
*
|
|
3586
|
-
* ```ts
|
|
3473
|
+
* ```ts import.meta.vitest
|
|
3587
3474
|
* import { Iterable, Result } from "effect"
|
|
3588
3475
|
*
|
|
3589
3476
|
* // Parse numbers until we hit an invalid one
|
|
@@ -3592,7 +3479,7 @@ export const filterMap: {
|
|
|
3592
3479
|
* const num = parseInt(s)
|
|
3593
3480
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3594
3481
|
* })
|
|
3595
|
-
*
|
|
3482
|
+
* Array.from(numbers) // => [1, 2, 3]
|
|
3596
3483
|
*
|
|
3597
3484
|
* // Take elements while they meet a condition and transform them
|
|
3598
3485
|
* const values = [2, 4, 6, 7, 8, 10]
|
|
@@ -3600,7 +3487,7 @@ export const filterMap: {
|
|
|
3600
3487
|
* values,
|
|
3601
3488
|
* (n) => n % 2 === 0 ? Result.succeed(n * 2) : Result.failVoid
|
|
3602
3489
|
* )
|
|
3603
|
-
*
|
|
3490
|
+
* Array.from(doubledEvens) // => [4, 8, 12]
|
|
3604
3491
|
*
|
|
3605
3492
|
* // Process with index until condition fails
|
|
3606
3493
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
@@ -3608,7 +3495,7 @@ export const filterMap: {
|
|
|
3608
3495
|
* letters,
|
|
3609
3496
|
* (letter, i) => letter !== "c" ? Result.succeed(`${i}: ${letter}`) : Result.failVoid
|
|
3610
3497
|
* )
|
|
3611
|
-
*
|
|
3498
|
+
* Array.from(indexedUntilC) // => ["0: a", "1: b"]
|
|
3612
3499
|
* ```
|
|
3613
3500
|
*
|
|
3614
3501
|
* @category filtering
|
|
@@ -3620,7 +3507,7 @@ export const filterMapWhile: {
|
|
|
3620
3507
|
*
|
|
3621
3508
|
* **Example** (Filtering and transforming until failure)
|
|
3622
3509
|
*
|
|
3623
|
-
* ```ts
|
|
3510
|
+
* ```ts import.meta.vitest
|
|
3624
3511
|
* import { Iterable, Result } from "effect"
|
|
3625
3512
|
*
|
|
3626
3513
|
* // Parse numbers until we hit an invalid one
|
|
@@ -3629,7 +3516,7 @@ export const filterMapWhile: {
|
|
|
3629
3516
|
* const num = parseInt(s)
|
|
3630
3517
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3631
3518
|
* })
|
|
3632
|
-
*
|
|
3519
|
+
* Array.from(numbers) // => [1, 2, 3]
|
|
3633
3520
|
*
|
|
3634
3521
|
* // Take elements while they meet a condition and transform them
|
|
3635
3522
|
* const values = [2, 4, 6, 7, 8, 10]
|
|
@@ -3637,7 +3524,7 @@ export const filterMapWhile: {
|
|
|
3637
3524
|
* values,
|
|
3638
3525
|
* (n) => n % 2 === 0 ? Result.succeed(n * 2) : Result.failVoid
|
|
3639
3526
|
* )
|
|
3640
|
-
*
|
|
3527
|
+
* Array.from(doubledEvens) // => [4, 8, 12]
|
|
3641
3528
|
*
|
|
3642
3529
|
* // Process with index until condition fails
|
|
3643
3530
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
@@ -3645,7 +3532,7 @@ export const filterMapWhile: {
|
|
|
3645
3532
|
* letters,
|
|
3646
3533
|
* (letter, i) => letter !== "c" ? Result.succeed(`${i}: ${letter}`) : Result.failVoid
|
|
3647
3534
|
* )
|
|
3648
|
-
*
|
|
3535
|
+
* Array.from(indexedUntilC) // => ["0: a", "1: b"]
|
|
3649
3536
|
* ```
|
|
3650
3537
|
*
|
|
3651
3538
|
* @category filtering
|
|
@@ -3657,7 +3544,7 @@ export const filterMapWhile: {
|
|
|
3657
3544
|
*
|
|
3658
3545
|
* **Example** (Filtering and transforming until failure)
|
|
3659
3546
|
*
|
|
3660
|
-
* ```ts
|
|
3547
|
+
* ```ts import.meta.vitest
|
|
3661
3548
|
* import { Iterable, Result } from "effect"
|
|
3662
3549
|
*
|
|
3663
3550
|
* // Parse numbers until we hit an invalid one
|
|
@@ -3666,7 +3553,7 @@ export const filterMapWhile: {
|
|
|
3666
3553
|
* const num = parseInt(s)
|
|
3667
3554
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
3668
3555
|
* })
|
|
3669
|
-
*
|
|
3556
|
+
* Array.from(numbers) // => [1, 2, 3]
|
|
3670
3557
|
*
|
|
3671
3558
|
* // Take elements while they meet a condition and transform them
|
|
3672
3559
|
* const values = [2, 4, 6, 7, 8, 10]
|
|
@@ -3674,7 +3561,7 @@ export const filterMapWhile: {
|
|
|
3674
3561
|
* values,
|
|
3675
3562
|
* (n) => n % 2 === 0 ? Result.succeed(n * 2) : Result.failVoid
|
|
3676
3563
|
* )
|
|
3677
|
-
*
|
|
3564
|
+
* Array.from(doubledEvens) // => [4, 8, 12]
|
|
3678
3565
|
*
|
|
3679
3566
|
* // Process with index until condition fails
|
|
3680
3567
|
* const letters = ["a", "b", "c", "d", "e"]
|
|
@@ -3682,7 +3569,7 @@ export const filterMapWhile: {
|
|
|
3682
3569
|
* letters,
|
|
3683
3570
|
* (letter, i) => letter !== "c" ? Result.succeed(`${i}: ${letter}`) : Result.failVoid
|
|
3684
3571
|
* )
|
|
3685
|
-
*
|
|
3572
|
+
* Array.from(indexedUntilC) // => ["0: a", "1: b"]
|
|
3686
3573
|
* ```
|
|
3687
3574
|
*
|
|
3688
3575
|
* @category filtering
|
|
@@ -3714,16 +3601,10 @@ export const filterMapWhile: {
|
|
|
3714
3601
|
*
|
|
3715
3602
|
* **Example** (Extracting Some values)
|
|
3716
3603
|
*
|
|
3717
|
-
* ```ts
|
|
3604
|
+
* ```ts import.meta.vitest
|
|
3718
3605
|
* import { Iterable, Option } from "effect"
|
|
3719
|
-
* import * as assert from "node:assert"
|
|
3720
3606
|
*
|
|
3721
|
-
*
|
|
3722
|
-
* Array.from(
|
|
3723
|
-
* Iterable.getSomes([Option.some(1), Option.none(), Option.some(2)])
|
|
3724
|
-
* ),
|
|
3725
|
-
* [1, 2]
|
|
3726
|
-
* )
|
|
3607
|
+
* Array.from(Iterable.getSomes([Option.some(1), Option.none(), Option.some(2)])) // => [1, 2]
|
|
3727
3608
|
* ```
|
|
3728
3609
|
*
|
|
3729
3610
|
* @category filtering
|
|
@@ -3755,20 +3636,14 @@ export const getSomes = <A>(self: Iterable<Option<A>>): Iterable<A> => {
|
|
|
3755
3636
|
*
|
|
3756
3637
|
* **Example** (Extracting failures)
|
|
3757
3638
|
*
|
|
3758
|
-
* ```ts
|
|
3639
|
+
* ```ts import.meta.vitest
|
|
3759
3640
|
* import { Iterable, Result } from "effect"
|
|
3760
|
-
*
|
|
3761
|
-
*
|
|
3762
|
-
*
|
|
3763
|
-
*
|
|
3764
|
-
*
|
|
3765
|
-
*
|
|
3766
|
-
* Result.fail("err"),
|
|
3767
|
-
* Result.succeed(2)
|
|
3768
|
-
* ])
|
|
3769
|
-
* ),
|
|
3770
|
-
* ["err"]
|
|
3771
|
-
* )
|
|
3641
|
+
*
|
|
3642
|
+
* Array.from(Iterable.getFailures([
|
|
3643
|
+
* Result.succeed(1),
|
|
3644
|
+
* Result.fail("err"),
|
|
3645
|
+
* Result.succeed(2)
|
|
3646
|
+
* ])) // => ["err"]
|
|
3772
3647
|
* ```
|
|
3773
3648
|
*
|
|
3774
3649
|
* @category filtering
|
|
@@ -3800,20 +3675,14 @@ export const getFailures = <R0, L>(self: Iterable<Result<R0, L>>): Iterable<L> =
|
|
|
3800
3675
|
*
|
|
3801
3676
|
* **Example** (Extracting successes)
|
|
3802
3677
|
*
|
|
3803
|
-
* ```ts
|
|
3678
|
+
* ```ts import.meta.vitest
|
|
3804
3679
|
* import { Iterable, Result } from "effect"
|
|
3805
|
-
*
|
|
3806
|
-
*
|
|
3807
|
-
*
|
|
3808
|
-
*
|
|
3809
|
-
*
|
|
3810
|
-
*
|
|
3811
|
-
* Result.fail("err"),
|
|
3812
|
-
* Result.succeed(2)
|
|
3813
|
-
* ])
|
|
3814
|
-
* ),
|
|
3815
|
-
* [1, 2]
|
|
3816
|
-
* )
|
|
3680
|
+
*
|
|
3681
|
+
* Array.from(Iterable.getSuccesses([
|
|
3682
|
+
* Result.succeed(1),
|
|
3683
|
+
* Result.fail("err"),
|
|
3684
|
+
* Result.succeed(2)
|
|
3685
|
+
* ])) // => [1, 2]
|
|
3817
3686
|
* ```
|
|
3818
3687
|
*
|
|
3819
3688
|
* @category filtering
|
|
@@ -3850,18 +3719,18 @@ export const getSuccesses = <R0, L>(self: Iterable<Result<R0, L>>): Iterable<R0>
|
|
|
3850
3719
|
*
|
|
3851
3720
|
* **Example** (Filtering elements)
|
|
3852
3721
|
*
|
|
3853
|
-
* ```ts
|
|
3722
|
+
* ```ts import.meta.vitest
|
|
3854
3723
|
* import { Iterable } from "effect"
|
|
3855
3724
|
*
|
|
3856
3725
|
* // Filter even numbers
|
|
3857
3726
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3858
3727
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3859
|
-
*
|
|
3728
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3860
3729
|
*
|
|
3861
3730
|
* // Filter with index
|
|
3862
3731
|
* const items = ["a", "b", "c", "d"]
|
|
3863
3732
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3864
|
-
*
|
|
3733
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3865
3734
|
*
|
|
3866
3735
|
* // Type refinement
|
|
3867
3736
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -3869,14 +3738,14 @@ export const getSuccesses = <R0, L>(self: Iterable<Result<R0, L>>): Iterable<R0>
|
|
|
3869
3738
|
* mixed,
|
|
3870
3739
|
* (x): x is string => typeof x === "string"
|
|
3871
3740
|
* )
|
|
3872
|
-
*
|
|
3741
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
3873
3742
|
*
|
|
3874
3743
|
* // Combine with map
|
|
3875
3744
|
* const processed = Iterable.map(
|
|
3876
3745
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
3877
3746
|
* (x) => x * 10
|
|
3878
3747
|
* )
|
|
3879
|
-
*
|
|
3748
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
3880
3749
|
* ```
|
|
3881
3750
|
*
|
|
3882
3751
|
* @category filtering
|
|
@@ -3894,18 +3763,18 @@ export const filter: {
|
|
|
3894
3763
|
*
|
|
3895
3764
|
* **Example** (Filtering elements)
|
|
3896
3765
|
*
|
|
3897
|
-
* ```ts
|
|
3766
|
+
* ```ts import.meta.vitest
|
|
3898
3767
|
* import { Iterable } from "effect"
|
|
3899
3768
|
*
|
|
3900
3769
|
* // Filter even numbers
|
|
3901
3770
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3902
3771
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3903
|
-
*
|
|
3772
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3904
3773
|
*
|
|
3905
3774
|
* // Filter with index
|
|
3906
3775
|
* const items = ["a", "b", "c", "d"]
|
|
3907
3776
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3908
|
-
*
|
|
3777
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3909
3778
|
*
|
|
3910
3779
|
* // Type refinement
|
|
3911
3780
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -3913,14 +3782,14 @@ export const filter: {
|
|
|
3913
3782
|
* mixed,
|
|
3914
3783
|
* (x): x is string => typeof x === "string"
|
|
3915
3784
|
* )
|
|
3916
|
-
*
|
|
3785
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
3917
3786
|
*
|
|
3918
3787
|
* // Combine with map
|
|
3919
3788
|
* const processed = Iterable.map(
|
|
3920
3789
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
3921
3790
|
* (x) => x * 10
|
|
3922
3791
|
* )
|
|
3923
|
-
*
|
|
3792
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
3924
3793
|
* ```
|
|
3925
3794
|
*
|
|
3926
3795
|
* @category filtering
|
|
@@ -3938,18 +3807,18 @@ export const filter: {
|
|
|
3938
3807
|
*
|
|
3939
3808
|
* **Example** (Filtering elements)
|
|
3940
3809
|
*
|
|
3941
|
-
* ```ts
|
|
3810
|
+
* ```ts import.meta.vitest
|
|
3942
3811
|
* import { Iterable } from "effect"
|
|
3943
3812
|
*
|
|
3944
3813
|
* // Filter even numbers
|
|
3945
3814
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3946
3815
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3947
|
-
*
|
|
3816
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3948
3817
|
*
|
|
3949
3818
|
* // Filter with index
|
|
3950
3819
|
* const items = ["a", "b", "c", "d"]
|
|
3951
3820
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3952
|
-
*
|
|
3821
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3953
3822
|
*
|
|
3954
3823
|
* // Type refinement
|
|
3955
3824
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -3957,14 +3826,14 @@ export const filter: {
|
|
|
3957
3826
|
* mixed,
|
|
3958
3827
|
* (x): x is string => typeof x === "string"
|
|
3959
3828
|
* )
|
|
3960
|
-
*
|
|
3829
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
3961
3830
|
*
|
|
3962
3831
|
* // Combine with map
|
|
3963
3832
|
* const processed = Iterable.map(
|
|
3964
3833
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
3965
3834
|
* (x) => x * 10
|
|
3966
3835
|
* )
|
|
3967
|
-
*
|
|
3836
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
3968
3837
|
* ```
|
|
3969
3838
|
*
|
|
3970
3839
|
* @category filtering
|
|
@@ -3982,18 +3851,18 @@ export const filter: {
|
|
|
3982
3851
|
*
|
|
3983
3852
|
* **Example** (Filtering elements)
|
|
3984
3853
|
*
|
|
3985
|
-
* ```ts
|
|
3854
|
+
* ```ts import.meta.vitest
|
|
3986
3855
|
* import { Iterable } from "effect"
|
|
3987
3856
|
*
|
|
3988
3857
|
* // Filter even numbers
|
|
3989
3858
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
3990
3859
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
3991
|
-
*
|
|
3860
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
3992
3861
|
*
|
|
3993
3862
|
* // Filter with index
|
|
3994
3863
|
* const items = ["a", "b", "c", "d"]
|
|
3995
3864
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
3996
|
-
*
|
|
3865
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
3997
3866
|
*
|
|
3998
3867
|
* // Type refinement
|
|
3999
3868
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -4001,14 +3870,14 @@ export const filter: {
|
|
|
4001
3870
|
* mixed,
|
|
4002
3871
|
* (x): x is string => typeof x === "string"
|
|
4003
3872
|
* )
|
|
4004
|
-
*
|
|
3873
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
4005
3874
|
*
|
|
4006
3875
|
* // Combine with map
|
|
4007
3876
|
* const processed = Iterable.map(
|
|
4008
3877
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
4009
3878
|
* (x) => x * 10
|
|
4010
3879
|
* )
|
|
4011
|
-
*
|
|
3880
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
4012
3881
|
* ```
|
|
4013
3882
|
*
|
|
4014
3883
|
* @category filtering
|
|
@@ -4026,18 +3895,18 @@ export const filter: {
|
|
|
4026
3895
|
*
|
|
4027
3896
|
* **Example** (Filtering elements)
|
|
4028
3897
|
*
|
|
4029
|
-
* ```ts
|
|
3898
|
+
* ```ts import.meta.vitest
|
|
4030
3899
|
* import { Iterable } from "effect"
|
|
4031
3900
|
*
|
|
4032
3901
|
* // Filter even numbers
|
|
4033
3902
|
* const numbers = [1, 2, 3, 4, 5, 6]
|
|
4034
3903
|
* const evens = Iterable.filter(numbers, (x) => x % 2 === 0)
|
|
4035
|
-
*
|
|
3904
|
+
* Array.from(evens) // => [2, 4, 6]
|
|
4036
3905
|
*
|
|
4037
3906
|
* // Filter with index
|
|
4038
3907
|
* const items = ["a", "b", "c", "d"]
|
|
4039
3908
|
* const oddPositions = Iterable.filter(items, (_, i) => i % 2 === 1)
|
|
4040
|
-
*
|
|
3909
|
+
* Array.from(oddPositions) // => ["b", "d"]
|
|
4041
3910
|
*
|
|
4042
3911
|
* // Type refinement
|
|
4043
3912
|
* const mixed: Array<string | number> = ["hello", 42, "world", 100]
|
|
@@ -4045,14 +3914,14 @@ export const filter: {
|
|
|
4045
3914
|
* mixed,
|
|
4046
3915
|
* (x): x is string => typeof x === "string"
|
|
4047
3916
|
* )
|
|
4048
|
-
*
|
|
3917
|
+
* Array.from(onlyStrings) // => ["hello", "world"]
|
|
4049
3918
|
*
|
|
4050
3919
|
* // Combine with map
|
|
4051
3920
|
* const processed = Iterable.map(
|
|
4052
3921
|
* Iterable.filter([1, 2, 3, 4, 5], (x) => x > 2),
|
|
4053
3922
|
* (x) => x * 10
|
|
4054
3923
|
* )
|
|
4055
|
-
*
|
|
3924
|
+
* Array.from(processed) // => [30, 40, 50]
|
|
4056
3925
|
* ```
|
|
4057
3926
|
*
|
|
4058
3927
|
* @category filtering
|
|
@@ -4091,7 +3960,7 @@ export const filter: {
|
|
|
4091
3960
|
*
|
|
4092
3961
|
* **Example** (Flat mapping nullable results)
|
|
4093
3962
|
*
|
|
4094
|
-
* ```ts
|
|
3963
|
+
* ```ts import.meta.vitest
|
|
4095
3964
|
* import { Iterable } from "effect"
|
|
4096
3965
|
*
|
|
4097
3966
|
* // Extract valid elements from nullable function results
|
|
@@ -4100,7 +3969,7 @@ export const filter: {
|
|
|
4100
3969
|
* const num = parseInt(s)
|
|
4101
3970
|
* return isNaN(num) ? null : num * 2
|
|
4102
3971
|
* })
|
|
4103
|
-
*
|
|
3972
|
+
* Array.from(parsed) // => [2, 4, 8]
|
|
4104
3973
|
*
|
|
4105
3974
|
* // Safe property access
|
|
4106
3975
|
* const objects = [
|
|
@@ -4110,7 +3979,7 @@ export const filter: {
|
|
|
4110
3979
|
* {}
|
|
4111
3980
|
* ]
|
|
4112
3981
|
* const values = Iterable.flatMapNullishOr(objects, (obj) => obj.nested?.value)
|
|
4113
|
-
*
|
|
3982
|
+
* Array.from(values) // => [10, 20]
|
|
4114
3983
|
*
|
|
4115
3984
|
* // Working with Map.get (returns undefined for missing keys)
|
|
4116
3985
|
* const map = new Map([
|
|
@@ -4120,7 +3989,7 @@ export const filter: {
|
|
|
4120
3989
|
* ])
|
|
4121
3990
|
* const keys = ["a", "x", "b", "y", "c"]
|
|
4122
3991
|
* const foundValues = Iterable.flatMapNullishOr(keys, (key) => map.get(key))
|
|
4123
|
-
*
|
|
3992
|
+
* Array.from(foundValues) // => [1, 2, 3]
|
|
4124
3993
|
* ```
|
|
4125
3994
|
*
|
|
4126
3995
|
* @category sequencing
|
|
@@ -4137,7 +4006,7 @@ export const flatMapNullishOr: {
|
|
|
4137
4006
|
*
|
|
4138
4007
|
* **Example** (Flat mapping nullable results)
|
|
4139
4008
|
*
|
|
4140
|
-
* ```ts
|
|
4009
|
+
* ```ts import.meta.vitest
|
|
4141
4010
|
* import { Iterable } from "effect"
|
|
4142
4011
|
*
|
|
4143
4012
|
* // Extract valid elements from nullable function results
|
|
@@ -4146,7 +4015,7 @@ export const flatMapNullishOr: {
|
|
|
4146
4015
|
* const num = parseInt(s)
|
|
4147
4016
|
* return isNaN(num) ? null : num * 2
|
|
4148
4017
|
* })
|
|
4149
|
-
*
|
|
4018
|
+
* Array.from(parsed) // => [2, 4, 8]
|
|
4150
4019
|
*
|
|
4151
4020
|
* // Safe property access
|
|
4152
4021
|
* const objects = [
|
|
@@ -4156,7 +4025,7 @@ export const flatMapNullishOr: {
|
|
|
4156
4025
|
* {}
|
|
4157
4026
|
* ]
|
|
4158
4027
|
* const values = Iterable.flatMapNullishOr(objects, (obj) => obj.nested?.value)
|
|
4159
|
-
*
|
|
4028
|
+
* Array.from(values) // => [10, 20]
|
|
4160
4029
|
*
|
|
4161
4030
|
* // Working with Map.get (returns undefined for missing keys)
|
|
4162
4031
|
* const map = new Map([
|
|
@@ -4166,7 +4035,7 @@ export const flatMapNullishOr: {
|
|
|
4166
4035
|
* ])
|
|
4167
4036
|
* const keys = ["a", "x", "b", "y", "c"]
|
|
4168
4037
|
* const foundValues = Iterable.flatMapNullishOr(keys, (key) => map.get(key))
|
|
4169
|
-
*
|
|
4038
|
+
* Array.from(foundValues) // => [1, 2, 3]
|
|
4170
4039
|
* ```
|
|
4171
4040
|
*
|
|
4172
4041
|
* @category sequencing
|
|
@@ -4183,7 +4052,7 @@ export const flatMapNullishOr: {
|
|
|
4183
4052
|
*
|
|
4184
4053
|
* **Example** (Flat mapping nullable results)
|
|
4185
4054
|
*
|
|
4186
|
-
* ```ts
|
|
4055
|
+
* ```ts import.meta.vitest
|
|
4187
4056
|
* import { Iterable } from "effect"
|
|
4188
4057
|
*
|
|
4189
4058
|
* // Extract valid elements from nullable function results
|
|
@@ -4192,7 +4061,7 @@ export const flatMapNullishOr: {
|
|
|
4192
4061
|
* const num = parseInt(s)
|
|
4193
4062
|
* return isNaN(num) ? null : num * 2
|
|
4194
4063
|
* })
|
|
4195
|
-
*
|
|
4064
|
+
* Array.from(parsed) // => [2, 4, 8]
|
|
4196
4065
|
*
|
|
4197
4066
|
* // Safe property access
|
|
4198
4067
|
* const objects = [
|
|
@@ -4202,7 +4071,7 @@ export const flatMapNullishOr: {
|
|
|
4202
4071
|
* {}
|
|
4203
4072
|
* ]
|
|
4204
4073
|
* const values = Iterable.flatMapNullishOr(objects, (obj) => obj.nested?.value)
|
|
4205
|
-
*
|
|
4074
|
+
* Array.from(values) // => [10, 20]
|
|
4206
4075
|
*
|
|
4207
4076
|
* // Working with Map.get (returns undefined for missing keys)
|
|
4208
4077
|
* const map = new Map([
|
|
@@ -4212,7 +4081,7 @@ export const flatMapNullishOr: {
|
|
|
4212
4081
|
* ])
|
|
4213
4082
|
* const keys = ["a", "x", "b", "y", "c"]
|
|
4214
4083
|
* const foundValues = Iterable.flatMapNullishOr(keys, (key) => map.get(key))
|
|
4215
|
-
*
|
|
4084
|
+
* Array.from(foundValues) // => [1, 2, 3]
|
|
4216
4085
|
* ```
|
|
4217
4086
|
*
|
|
4218
4087
|
* @category sequencing
|
|
@@ -4233,21 +4102,21 @@ export const flatMapNullishOr: {
|
|
|
4233
4102
|
*
|
|
4234
4103
|
* **Example** (Checking whether some element matches)
|
|
4235
4104
|
*
|
|
4236
|
-
* ```ts
|
|
4105
|
+
* ```ts import.meta.vitest
|
|
4237
4106
|
* import { Iterable } from "effect"
|
|
4238
4107
|
*
|
|
4239
4108
|
* const numbers = [1, 3, 5, 7, 8]
|
|
4240
4109
|
* const hasEven = Iterable.some(numbers, (x) => x % 2 === 0)
|
|
4241
|
-
*
|
|
4110
|
+
* hasEven // => true
|
|
4242
4111
|
*
|
|
4243
4112
|
* const allOdd = [1, 3, 5, 7]
|
|
4244
4113
|
* const hasEvenInAllOdd = Iterable.some(allOdd, (x) => x % 2 === 0)
|
|
4245
|
-
*
|
|
4114
|
+
* hasEvenInAllOdd // => false
|
|
4246
4115
|
*
|
|
4247
4116
|
* // With index
|
|
4248
4117
|
* const letters = ["a", "b", "c"]
|
|
4249
4118
|
* const hasElementAtIndex2 = Iterable.some(letters, (_, i) => i === 2)
|
|
4250
|
-
*
|
|
4119
|
+
* hasElementAtIndex2 // => true
|
|
4251
4120
|
*
|
|
4252
4121
|
* // Early termination - stops at first match
|
|
4253
4122
|
* const infiniteOdds = Iterable.filter(Iterable.range(1), (x) => x % 2 === 1)
|
|
@@ -4255,7 +4124,7 @@ export const flatMapNullishOr: {
|
|
|
4255
4124
|
* Iterable.take(infiniteOdds, 1000),
|
|
4256
4125
|
* (x) => x % 2 === 0
|
|
4257
4126
|
* )
|
|
4258
|
-
*
|
|
4127
|
+
* hasEvenInInfiniteOdds // => false
|
|
4259
4128
|
*
|
|
4260
4129
|
* // Type guard usage
|
|
4261
4130
|
* const mixed: Array<string | number> = [1, 2, "hello"]
|
|
@@ -4263,10 +4132,10 @@ export const flatMapNullishOr: {
|
|
|
4263
4132
|
* mixed,
|
|
4264
4133
|
* (x): x is string => typeof x === "string"
|
|
4265
4134
|
* )
|
|
4266
|
-
*
|
|
4135
|
+
* hasString // => true
|
|
4267
4136
|
* ```
|
|
4268
4137
|
*
|
|
4269
|
-
* @category
|
|
4138
|
+
* @category predicates
|
|
4270
4139
|
* @since 2.0.0
|
|
4271
4140
|
*/
|
|
4272
4141
|
export const some: {
|
|
@@ -4275,21 +4144,21 @@ export const some: {
|
|
|
4275
4144
|
*
|
|
4276
4145
|
* **Example** (Checking whether some element matches)
|
|
4277
4146
|
*
|
|
4278
|
-
* ```ts
|
|
4147
|
+
* ```ts import.meta.vitest
|
|
4279
4148
|
* import { Iterable } from "effect"
|
|
4280
4149
|
*
|
|
4281
4150
|
* const numbers = [1, 3, 5, 7, 8]
|
|
4282
4151
|
* const hasEven = Iterable.some(numbers, (x) => x % 2 === 0)
|
|
4283
|
-
*
|
|
4152
|
+
* hasEven // => true
|
|
4284
4153
|
*
|
|
4285
4154
|
* const allOdd = [1, 3, 5, 7]
|
|
4286
4155
|
* const hasEvenInAllOdd = Iterable.some(allOdd, (x) => x % 2 === 0)
|
|
4287
|
-
*
|
|
4156
|
+
* hasEvenInAllOdd // => false
|
|
4288
4157
|
*
|
|
4289
4158
|
* // With index
|
|
4290
4159
|
* const letters = ["a", "b", "c"]
|
|
4291
4160
|
* const hasElementAtIndex2 = Iterable.some(letters, (_, i) => i === 2)
|
|
4292
|
-
*
|
|
4161
|
+
* hasElementAtIndex2 // => true
|
|
4293
4162
|
*
|
|
4294
4163
|
* // Early termination - stops at first match
|
|
4295
4164
|
* const infiniteOdds = Iterable.filter(Iterable.range(1), (x) => x % 2 === 1)
|
|
@@ -4297,7 +4166,7 @@ export const some: {
|
|
|
4297
4166
|
* Iterable.take(infiniteOdds, 1000),
|
|
4298
4167
|
* (x) => x % 2 === 0
|
|
4299
4168
|
* )
|
|
4300
|
-
*
|
|
4169
|
+
* hasEvenInInfiniteOdds // => false
|
|
4301
4170
|
*
|
|
4302
4171
|
* // Type guard usage
|
|
4303
4172
|
* const mixed: Array<string | number> = [1, 2, "hello"]
|
|
@@ -4305,10 +4174,10 @@ export const some: {
|
|
|
4305
4174
|
* mixed,
|
|
4306
4175
|
* (x): x is string => typeof x === "string"
|
|
4307
4176
|
* )
|
|
4308
|
-
*
|
|
4177
|
+
* hasString // => true
|
|
4309
4178
|
* ```
|
|
4310
4179
|
*
|
|
4311
|
-
* @category
|
|
4180
|
+
* @category predicates
|
|
4312
4181
|
* @since 2.0.0
|
|
4313
4182
|
*/
|
|
4314
4183
|
<A>(predicate: (a: A, i: number) => boolean): (self: Iterable<A>) => boolean
|
|
@@ -4317,21 +4186,21 @@ export const some: {
|
|
|
4317
4186
|
*
|
|
4318
4187
|
* **Example** (Checking whether some element matches)
|
|
4319
4188
|
*
|
|
4320
|
-
* ```ts
|
|
4189
|
+
* ```ts import.meta.vitest
|
|
4321
4190
|
* import { Iterable } from "effect"
|
|
4322
4191
|
*
|
|
4323
4192
|
* const numbers = [1, 3, 5, 7, 8]
|
|
4324
4193
|
* const hasEven = Iterable.some(numbers, (x) => x % 2 === 0)
|
|
4325
|
-
*
|
|
4194
|
+
* hasEven // => true
|
|
4326
4195
|
*
|
|
4327
4196
|
* const allOdd = [1, 3, 5, 7]
|
|
4328
4197
|
* const hasEvenInAllOdd = Iterable.some(allOdd, (x) => x % 2 === 0)
|
|
4329
|
-
*
|
|
4198
|
+
* hasEvenInAllOdd // => false
|
|
4330
4199
|
*
|
|
4331
4200
|
* // With index
|
|
4332
4201
|
* const letters = ["a", "b", "c"]
|
|
4333
4202
|
* const hasElementAtIndex2 = Iterable.some(letters, (_, i) => i === 2)
|
|
4334
|
-
*
|
|
4203
|
+
* hasElementAtIndex2 // => true
|
|
4335
4204
|
*
|
|
4336
4205
|
* // Early termination - stops at first match
|
|
4337
4206
|
* const infiniteOdds = Iterable.filter(Iterable.range(1), (x) => x % 2 === 1)
|
|
@@ -4339,7 +4208,7 @@ export const some: {
|
|
|
4339
4208
|
* Iterable.take(infiniteOdds, 1000),
|
|
4340
4209
|
* (x) => x % 2 === 0
|
|
4341
4210
|
* )
|
|
4342
|
-
*
|
|
4211
|
+
* hasEvenInInfiniteOdds // => false
|
|
4343
4212
|
*
|
|
4344
4213
|
* // Type guard usage
|
|
4345
4214
|
* const mixed: Array<string | number> = [1, 2, "hello"]
|
|
@@ -4347,10 +4216,10 @@ export const some: {
|
|
|
4347
4216
|
* mixed,
|
|
4348
4217
|
* (x): x is string => typeof x === "string"
|
|
4349
4218
|
* )
|
|
4350
|
-
*
|
|
4219
|
+
* hasString // => true
|
|
4351
4220
|
* ```
|
|
4352
4221
|
*
|
|
4353
|
-
* @category
|
|
4222
|
+
* @category predicates
|
|
4354
4223
|
* @since 2.0.0
|
|
4355
4224
|
*/
|
|
4356
4225
|
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): boolean
|
|
@@ -4379,21 +4248,21 @@ export const some: {
|
|
|
4379
4248
|
*
|
|
4380
4249
|
* **Example** (Unfolding state into values)
|
|
4381
4250
|
*
|
|
4382
|
-
* ```ts
|
|
4251
|
+
* ```ts import.meta.vitest
|
|
4383
4252
|
* import { Iterable, Option } from "effect"
|
|
4384
4253
|
*
|
|
4385
4254
|
* // Generate Fibonacci sequence
|
|
4386
4255
|
* const fibonacci = Iterable.unfold([0, 1], ([a, b]) => Option.some([a, [b, a + b]]))
|
|
4387
4256
|
* const first10Fib = Iterable.take(fibonacci, 10)
|
|
4388
|
-
*
|
|
4257
|
+
* Array.from(first10Fib) // => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
|
4389
4258
|
*
|
|
4390
4259
|
* // Generate powers of 2 up to a limit
|
|
4391
4260
|
* const powersOf2 = Iterable.unfold(1, (n) => n <= 1000 ? Option.some([n, n * 2]) : Option.none())
|
|
4392
|
-
*
|
|
4261
|
+
* Array.from(powersOf2) // => [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
|
|
4393
4262
|
*
|
|
4394
4263
|
* // Generate countdown
|
|
4395
4264
|
* const countdown = Iterable.unfold(5, (n) => n > 0 ? Option.some([n, n - 1]) : Option.none())
|
|
4396
|
-
*
|
|
4265
|
+
* Array.from(countdown) // => [5, 4, 3, 2, 1]
|
|
4397
4266
|
*
|
|
4398
4267
|
* // Generate collatz sequence
|
|
4399
4268
|
* const collatz = Iterable.unfold(7, (n) => {
|
|
@@ -4401,7 +4270,7 @@ export const some: {
|
|
|
4401
4270
|
* const next = n % 2 === 0 ? n / 2 : n * 3 + 1
|
|
4402
4271
|
* return Option.some([n, next])
|
|
4403
4272
|
* })
|
|
4404
|
-
*
|
|
4273
|
+
* Array.from(collatz) // => [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]
|
|
4405
4274
|
* ```
|
|
4406
4275
|
*
|
|
4407
4276
|
* @category constructors
|
|
@@ -4429,37 +4298,40 @@ export const unfold = <B, A>(b: B, f: (b: B) => Option<readonly [A, B]>): Iterab
|
|
|
4429
4298
|
*
|
|
4430
4299
|
* **Example** (Iterating with side effects)
|
|
4431
4300
|
*
|
|
4432
|
-
* ```ts
|
|
4301
|
+
* ```ts import.meta.vitest
|
|
4433
4302
|
* import { Iterable } from "effect"
|
|
4434
4303
|
*
|
|
4435
|
-
* //
|
|
4304
|
+
* // Collect each visited element
|
|
4436
4305
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4437
|
-
*
|
|
4438
|
-
*
|
|
4306
|
+
* const visited: Array<number> = []
|
|
4307
|
+
* Iterable.forEach(numbers, (n) => visited.push(n))
|
|
4308
|
+
* visited // => [1, 2, 3, 4, 5]
|
|
4439
4309
|
*
|
|
4440
4310
|
* // Use index in the callback
|
|
4441
4311
|
* const letters = ["a", "b", "c"]
|
|
4312
|
+
* const indexed: Array<string> = []
|
|
4442
4313
|
* Iterable.forEach(letters, (letter, i) => {
|
|
4443
|
-
*
|
|
4314
|
+
* indexed.push(`${i}: ${letter}`)
|
|
4444
4315
|
* })
|
|
4445
|
-
* //
|
|
4316
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4446
4317
|
*
|
|
4447
4318
|
* // Side effects with any iterable
|
|
4448
4319
|
* const results: Array<number> = []
|
|
4449
4320
|
* Iterable.forEach(Iterable.range(1, 5), (n) => {
|
|
4450
4321
|
* results.push(n * n)
|
|
4451
4322
|
* })
|
|
4452
|
-
*
|
|
4323
|
+
* results // => [1, 4, 9, 16, 25]
|
|
4453
4324
|
*
|
|
4454
4325
|
* // Process in chunks
|
|
4455
4326
|
* const data = Iterable.chunksOf([1, 2, 3, 4, 5, 6], 2)
|
|
4327
|
+
* const processed: Array<Array<number>> = []
|
|
4456
4328
|
* Iterable.forEach(data, (chunk) => {
|
|
4457
|
-
*
|
|
4329
|
+
* processed.push(Array.from(chunk))
|
|
4458
4330
|
* })
|
|
4459
|
-
* //
|
|
4331
|
+
* processed // => [[1, 2], [3, 4], [5, 6]]
|
|
4460
4332
|
* ```
|
|
4461
4333
|
*
|
|
4462
|
-
* @category
|
|
4334
|
+
* @category traversing
|
|
4463
4335
|
* @since 2.0.0
|
|
4464
4336
|
*/
|
|
4465
4337
|
export const forEach: {
|
|
@@ -4468,37 +4340,40 @@ export const forEach: {
|
|
|
4468
4340
|
*
|
|
4469
4341
|
* **Example** (Iterating with side effects)
|
|
4470
4342
|
*
|
|
4471
|
-
* ```ts
|
|
4343
|
+
* ```ts import.meta.vitest
|
|
4472
4344
|
* import { Iterable } from "effect"
|
|
4473
4345
|
*
|
|
4474
|
-
* //
|
|
4346
|
+
* // Collect each visited element
|
|
4475
4347
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4476
|
-
*
|
|
4477
|
-
*
|
|
4348
|
+
* const visited: Array<number> = []
|
|
4349
|
+
* Iterable.forEach(numbers, (n) => visited.push(n))
|
|
4350
|
+
* visited // => [1, 2, 3, 4, 5]
|
|
4478
4351
|
*
|
|
4479
4352
|
* // Use index in the callback
|
|
4480
4353
|
* const letters = ["a", "b", "c"]
|
|
4354
|
+
* const indexed: Array<string> = []
|
|
4481
4355
|
* Iterable.forEach(letters, (letter, i) => {
|
|
4482
|
-
*
|
|
4356
|
+
* indexed.push(`${i}: ${letter}`)
|
|
4483
4357
|
* })
|
|
4484
|
-
* //
|
|
4358
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4485
4359
|
*
|
|
4486
4360
|
* // Side effects with any iterable
|
|
4487
4361
|
* const results: Array<number> = []
|
|
4488
4362
|
* Iterable.forEach(Iterable.range(1, 5), (n) => {
|
|
4489
4363
|
* results.push(n * n)
|
|
4490
4364
|
* })
|
|
4491
|
-
*
|
|
4365
|
+
* results // => [1, 4, 9, 16, 25]
|
|
4492
4366
|
*
|
|
4493
4367
|
* // Process in chunks
|
|
4494
4368
|
* const data = Iterable.chunksOf([1, 2, 3, 4, 5, 6], 2)
|
|
4369
|
+
* const processed: Array<Array<number>> = []
|
|
4495
4370
|
* Iterable.forEach(data, (chunk) => {
|
|
4496
|
-
*
|
|
4371
|
+
* processed.push(Array.from(chunk))
|
|
4497
4372
|
* })
|
|
4498
|
-
* //
|
|
4373
|
+
* processed // => [[1, 2], [3, 4], [5, 6]]
|
|
4499
4374
|
* ```
|
|
4500
4375
|
*
|
|
4501
|
-
* @category
|
|
4376
|
+
* @category traversing
|
|
4502
4377
|
* @since 2.0.0
|
|
4503
4378
|
*/
|
|
4504
4379
|
<A>(f: (a: A, i: number) => void): (self: Iterable<A>) => void
|
|
@@ -4507,37 +4382,40 @@ export const forEach: {
|
|
|
4507
4382
|
*
|
|
4508
4383
|
* **Example** (Iterating with side effects)
|
|
4509
4384
|
*
|
|
4510
|
-
* ```ts
|
|
4385
|
+
* ```ts import.meta.vitest
|
|
4511
4386
|
* import { Iterable } from "effect"
|
|
4512
4387
|
*
|
|
4513
|
-
* //
|
|
4388
|
+
* // Collect each visited element
|
|
4514
4389
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4515
|
-
*
|
|
4516
|
-
*
|
|
4390
|
+
* const visited: Array<number> = []
|
|
4391
|
+
* Iterable.forEach(numbers, (n) => visited.push(n))
|
|
4392
|
+
* visited // => [1, 2, 3, 4, 5]
|
|
4517
4393
|
*
|
|
4518
4394
|
* // Use index in the callback
|
|
4519
4395
|
* const letters = ["a", "b", "c"]
|
|
4396
|
+
* const indexed: Array<string> = []
|
|
4520
4397
|
* Iterable.forEach(letters, (letter, i) => {
|
|
4521
|
-
*
|
|
4398
|
+
* indexed.push(`${i}: ${letter}`)
|
|
4522
4399
|
* })
|
|
4523
|
-
* //
|
|
4400
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4524
4401
|
*
|
|
4525
4402
|
* // Side effects with any iterable
|
|
4526
4403
|
* const results: Array<number> = []
|
|
4527
4404
|
* Iterable.forEach(Iterable.range(1, 5), (n) => {
|
|
4528
4405
|
* results.push(n * n)
|
|
4529
4406
|
* })
|
|
4530
|
-
*
|
|
4407
|
+
* results // => [1, 4, 9, 16, 25]
|
|
4531
4408
|
*
|
|
4532
4409
|
* // Process in chunks
|
|
4533
4410
|
* const data = Iterable.chunksOf([1, 2, 3, 4, 5, 6], 2)
|
|
4411
|
+
* const processed: Array<Array<number>> = []
|
|
4534
4412
|
* Iterable.forEach(data, (chunk) => {
|
|
4535
|
-
*
|
|
4413
|
+
* processed.push(Array.from(chunk))
|
|
4536
4414
|
* })
|
|
4537
|
-
* //
|
|
4415
|
+
* processed // => [[1, 2], [3, 4], [5, 6]]
|
|
4538
4416
|
* ```
|
|
4539
4417
|
*
|
|
4540
|
-
* @category
|
|
4418
|
+
* @category traversing
|
|
4541
4419
|
* @since 2.0.0
|
|
4542
4420
|
*/
|
|
4543
4421
|
<A>(self: Iterable<A>, f: (a: A, i: number) => void): void
|
|
@@ -4558,18 +4436,17 @@ export const forEach: {
|
|
|
4558
4436
|
*
|
|
4559
4437
|
* **Example** (Reducing an iterable)
|
|
4560
4438
|
*
|
|
4561
|
-
* ```ts
|
|
4439
|
+
* ```ts import.meta.vitest
|
|
4562
4440
|
* import { Iterable } from "effect"
|
|
4563
4441
|
*
|
|
4564
4442
|
* // Sum all numbers
|
|
4565
4443
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4566
4444
|
* const sum = Iterable.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4567
|
-
*
|
|
4445
|
+
* sum // => 15
|
|
4568
4446
|
*
|
|
4569
4447
|
* // Find maximum value
|
|
4570
4448
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
4571
|
-
*
|
|
4572
|
-
* console.log(max) // 9
|
|
4449
|
+
* Iterable.reduce(values, -Infinity, (max, value) => Math.max(max, value)) // => 9
|
|
4573
4450
|
*
|
|
4574
4451
|
* // Build an object from key-value pairs
|
|
4575
4452
|
* const pairs = [["a", 1], ["b", 2], ["c", 3]] as const
|
|
@@ -4581,7 +4458,7 @@ export const forEach: {
|
|
|
4581
4458
|
* return acc
|
|
4582
4459
|
* }
|
|
4583
4460
|
* )
|
|
4584
|
-
*
|
|
4461
|
+
* obj // => { a: 1, b: 2, c: 3 }
|
|
4585
4462
|
*
|
|
4586
4463
|
* // Use index in the reducer
|
|
4587
4464
|
* const letters = ["a", "b", "c"]
|
|
@@ -4593,7 +4470,7 @@ export const forEach: {
|
|
|
4593
4470
|
* return acc
|
|
4594
4471
|
* }
|
|
4595
4472
|
* )
|
|
4596
|
-
*
|
|
4473
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4597
4474
|
* ```
|
|
4598
4475
|
*
|
|
4599
4476
|
* @category folding
|
|
@@ -4610,18 +4487,17 @@ export const reduce: {
|
|
|
4610
4487
|
*
|
|
4611
4488
|
* **Example** (Reducing an iterable)
|
|
4612
4489
|
*
|
|
4613
|
-
* ```ts
|
|
4490
|
+
* ```ts import.meta.vitest
|
|
4614
4491
|
* import { Iterable } from "effect"
|
|
4615
4492
|
*
|
|
4616
4493
|
* // Sum all numbers
|
|
4617
4494
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4618
4495
|
* const sum = Iterable.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4619
|
-
*
|
|
4496
|
+
* sum // => 15
|
|
4620
4497
|
*
|
|
4621
4498
|
* // Find maximum value
|
|
4622
4499
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
4623
|
-
*
|
|
4624
|
-
* console.log(max) // 9
|
|
4500
|
+
* Iterable.reduce(values, -Infinity, (max, value) => Math.max(max, value)) // => 9
|
|
4625
4501
|
*
|
|
4626
4502
|
* // Build an object from key-value pairs
|
|
4627
4503
|
* const pairs = [["a", 1], ["b", 2], ["c", 3]] as const
|
|
@@ -4633,7 +4509,7 @@ export const reduce: {
|
|
|
4633
4509
|
* return acc
|
|
4634
4510
|
* }
|
|
4635
4511
|
* )
|
|
4636
|
-
*
|
|
4512
|
+
* obj // => { a: 1, b: 2, c: 3 }
|
|
4637
4513
|
*
|
|
4638
4514
|
* // Use index in the reducer
|
|
4639
4515
|
* const letters = ["a", "b", "c"]
|
|
@@ -4645,7 +4521,7 @@ export const reduce: {
|
|
|
4645
4521
|
* return acc
|
|
4646
4522
|
* }
|
|
4647
4523
|
* )
|
|
4648
|
-
*
|
|
4524
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4649
4525
|
* ```
|
|
4650
4526
|
*
|
|
4651
4527
|
* @category folding
|
|
@@ -4662,18 +4538,17 @@ export const reduce: {
|
|
|
4662
4538
|
*
|
|
4663
4539
|
* **Example** (Reducing an iterable)
|
|
4664
4540
|
*
|
|
4665
|
-
* ```ts
|
|
4541
|
+
* ```ts import.meta.vitest
|
|
4666
4542
|
* import { Iterable } from "effect"
|
|
4667
4543
|
*
|
|
4668
4544
|
* // Sum all numbers
|
|
4669
4545
|
* const numbers = [1, 2, 3, 4, 5]
|
|
4670
4546
|
* const sum = Iterable.reduce(numbers, 0, (acc, n) => acc + n)
|
|
4671
|
-
*
|
|
4547
|
+
* sum // => 15
|
|
4672
4548
|
*
|
|
4673
4549
|
* // Find maximum value
|
|
4674
4550
|
* const values = [3, 1, 4, 1, 5, 9, 2]
|
|
4675
|
-
*
|
|
4676
|
-
* console.log(max) // 9
|
|
4551
|
+
* Iterable.reduce(values, -Infinity, (max, value) => Math.max(max, value)) // => 9
|
|
4677
4552
|
*
|
|
4678
4553
|
* // Build an object from key-value pairs
|
|
4679
4554
|
* const pairs = [["a", 1], ["b", 2], ["c", 3]] as const
|
|
@@ -4685,7 +4560,7 @@ export const reduce: {
|
|
|
4685
4560
|
* return acc
|
|
4686
4561
|
* }
|
|
4687
4562
|
* )
|
|
4688
|
-
*
|
|
4563
|
+
* obj // => { a: 1, b: 2, c: 3 }
|
|
4689
4564
|
*
|
|
4690
4565
|
* // Use index in the reducer
|
|
4691
4566
|
* const letters = ["a", "b", "c"]
|
|
@@ -4697,7 +4572,7 @@ export const reduce: {
|
|
|
4697
4572
|
* return acc
|
|
4698
4573
|
* }
|
|
4699
4574
|
* )
|
|
4700
|
-
*
|
|
4575
|
+
* indexed // => ["0: a", "1: b", "2: c"]
|
|
4701
4576
|
* ```
|
|
4702
4577
|
*
|
|
4703
4578
|
* @category folding
|
|
@@ -4721,20 +4596,20 @@ export const reduce: {
|
|
|
4721
4596
|
*
|
|
4722
4597
|
* **Example** (Deduplicating adjacent elements with custom equivalence)
|
|
4723
4598
|
*
|
|
4724
|
-
* ```ts
|
|
4599
|
+
* ```ts import.meta.vitest
|
|
4725
4600
|
* import { Iterable } from "effect"
|
|
4726
4601
|
*
|
|
4727
4602
|
* // Remove adjacent duplicates with custom equality
|
|
4728
4603
|
* const numbers = [1, 1, 2, 2, 3, 1, 1]
|
|
4729
4604
|
* const dedupedNumbers = Iterable.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
4730
|
-
*
|
|
4605
|
+
* Array.from(dedupedNumbers) // => [1, 2, 3, 1]
|
|
4731
4606
|
*
|
|
4732
4607
|
* // Case-insensitive deduplication
|
|
4733
4608
|
* const words = ["Hello", "HELLO", "world", "World", "test"]
|
|
4734
4609
|
* const caseInsensitive = (a: string, b: string) =>
|
|
4735
4610
|
* a.toLowerCase() === b.toLowerCase()
|
|
4736
4611
|
* const dedupedWords = Iterable.dedupeAdjacentWith(words, caseInsensitive)
|
|
4737
|
-
*
|
|
4612
|
+
* Array.from(dedupedWords) // => ["Hello", "world", "test"]
|
|
4738
4613
|
*
|
|
4739
4614
|
* // Deduplication by object property
|
|
4740
4615
|
* const users = [
|
|
@@ -4746,13 +4621,13 @@ export const reduce: {
|
|
|
4746
4621
|
* ]
|
|
4747
4622
|
* const byId = (a: typeof users[0], b: typeof users[0]) => a.id === b.id
|
|
4748
4623
|
* const dedupedUsers = Iterable.dedupeAdjacentWith(users, byId)
|
|
4749
|
-
*
|
|
4624
|
+
* Array.from(dedupedUsers, (user) => user.id) // => [1, 2, 3]
|
|
4750
4625
|
*
|
|
4751
4626
|
* // Approximate numeric equality
|
|
4752
4627
|
* const floats = [1.0, 1.01, 1.02, 2.0, 2.01, 3.0]
|
|
4753
4628
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
4754
4629
|
* const dedupedFloats = Iterable.dedupeAdjacentWith(floats, approxEqual)
|
|
4755
|
-
*
|
|
4630
|
+
* Array.from(dedupedFloats) // => [1, 2, 3]
|
|
4756
4631
|
* ```
|
|
4757
4632
|
*
|
|
4758
4633
|
* @category filtering
|
|
@@ -4764,20 +4639,20 @@ export const dedupeAdjacentWith: {
|
|
|
4764
4639
|
*
|
|
4765
4640
|
* **Example** (Deduplicating adjacent elements with custom equivalence)
|
|
4766
4641
|
*
|
|
4767
|
-
* ```ts
|
|
4642
|
+
* ```ts import.meta.vitest
|
|
4768
4643
|
* import { Iterable } from "effect"
|
|
4769
4644
|
*
|
|
4770
4645
|
* // Remove adjacent duplicates with custom equality
|
|
4771
4646
|
* const numbers = [1, 1, 2, 2, 3, 1, 1]
|
|
4772
4647
|
* const dedupedNumbers = Iterable.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
4773
|
-
*
|
|
4648
|
+
* Array.from(dedupedNumbers) // => [1, 2, 3, 1]
|
|
4774
4649
|
*
|
|
4775
4650
|
* // Case-insensitive deduplication
|
|
4776
4651
|
* const words = ["Hello", "HELLO", "world", "World", "test"]
|
|
4777
4652
|
* const caseInsensitive = (a: string, b: string) =>
|
|
4778
4653
|
* a.toLowerCase() === b.toLowerCase()
|
|
4779
4654
|
* const dedupedWords = Iterable.dedupeAdjacentWith(words, caseInsensitive)
|
|
4780
|
-
*
|
|
4655
|
+
* Array.from(dedupedWords) // => ["Hello", "world", "test"]
|
|
4781
4656
|
*
|
|
4782
4657
|
* // Deduplication by object property
|
|
4783
4658
|
* const users = [
|
|
@@ -4789,13 +4664,13 @@ export const dedupeAdjacentWith: {
|
|
|
4789
4664
|
* ]
|
|
4790
4665
|
* const byId = (a: typeof users[0], b: typeof users[0]) => a.id === b.id
|
|
4791
4666
|
* const dedupedUsers = Iterable.dedupeAdjacentWith(users, byId)
|
|
4792
|
-
*
|
|
4667
|
+
* Array.from(dedupedUsers, (user) => user.id) // => [1, 2, 3]
|
|
4793
4668
|
*
|
|
4794
4669
|
* // Approximate numeric equality
|
|
4795
4670
|
* const floats = [1.0, 1.01, 1.02, 2.0, 2.01, 3.0]
|
|
4796
4671
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
4797
4672
|
* const dedupedFloats = Iterable.dedupeAdjacentWith(floats, approxEqual)
|
|
4798
|
-
*
|
|
4673
|
+
* Array.from(dedupedFloats) // => [1, 2, 3]
|
|
4799
4674
|
* ```
|
|
4800
4675
|
*
|
|
4801
4676
|
* @category filtering
|
|
@@ -4807,20 +4682,20 @@ export const dedupeAdjacentWith: {
|
|
|
4807
4682
|
*
|
|
4808
4683
|
* **Example** (Deduplicating adjacent elements with custom equivalence)
|
|
4809
4684
|
*
|
|
4810
|
-
* ```ts
|
|
4685
|
+
* ```ts import.meta.vitest
|
|
4811
4686
|
* import { Iterable } from "effect"
|
|
4812
4687
|
*
|
|
4813
4688
|
* // Remove adjacent duplicates with custom equality
|
|
4814
4689
|
* const numbers = [1, 1, 2, 2, 3, 1, 1]
|
|
4815
4690
|
* const dedupedNumbers = Iterable.dedupeAdjacentWith(numbers, (a, b) => a === b)
|
|
4816
|
-
*
|
|
4691
|
+
* Array.from(dedupedNumbers) // => [1, 2, 3, 1]
|
|
4817
4692
|
*
|
|
4818
4693
|
* // Case-insensitive deduplication
|
|
4819
4694
|
* const words = ["Hello", "HELLO", "world", "World", "test"]
|
|
4820
4695
|
* const caseInsensitive = (a: string, b: string) =>
|
|
4821
4696
|
* a.toLowerCase() === b.toLowerCase()
|
|
4822
4697
|
* const dedupedWords = Iterable.dedupeAdjacentWith(words, caseInsensitive)
|
|
4823
|
-
*
|
|
4698
|
+
* Array.from(dedupedWords) // => ["Hello", "world", "test"]
|
|
4824
4699
|
*
|
|
4825
4700
|
* // Deduplication by object property
|
|
4826
4701
|
* const users = [
|
|
@@ -4832,13 +4707,13 @@ export const dedupeAdjacentWith: {
|
|
|
4832
4707
|
* ]
|
|
4833
4708
|
* const byId = (a: typeof users[0], b: typeof users[0]) => a.id === b.id
|
|
4834
4709
|
* const dedupedUsers = Iterable.dedupeAdjacentWith(users, byId)
|
|
4835
|
-
*
|
|
4710
|
+
* Array.from(dedupedUsers, (user) => user.id) // => [1, 2, 3]
|
|
4836
4711
|
*
|
|
4837
4712
|
* // Approximate numeric equality
|
|
4838
4713
|
* const floats = [1.0, 1.01, 1.02, 2.0, 2.01, 3.0]
|
|
4839
4714
|
* const approxEqual = (a: number, b: number) => Math.abs(a - b) < 0.1
|
|
4840
4715
|
* const dedupedFloats = Iterable.dedupeAdjacentWith(floats, approxEqual)
|
|
4841
|
-
*
|
|
4716
|
+
* Array.from(dedupedFloats) // => [1, 2, 3]
|
|
4842
4717
|
* ```
|
|
4843
4718
|
*
|
|
4844
4719
|
* @category filtering
|
|
@@ -4876,18 +4751,18 @@ export const dedupeAdjacentWith: {
|
|
|
4876
4751
|
*
|
|
4877
4752
|
* **Example** (Deduplicating adjacent elements)
|
|
4878
4753
|
*
|
|
4879
|
-
* ```ts
|
|
4754
|
+
* ```ts import.meta.vitest
|
|
4880
4755
|
* import { Iterable } from "effect"
|
|
4881
4756
|
*
|
|
4882
4757
|
* // Remove adjacent duplicate numbers
|
|
4883
4758
|
* const numbers = [1, 1, 2, 2, 2, 3, 1, 1]
|
|
4884
4759
|
* const deduped = Iterable.dedupeAdjacent(numbers)
|
|
4885
|
-
*
|
|
4760
|
+
* Array.from(deduped) // => [1, 2, 3, 1]
|
|
4886
4761
|
*
|
|
4887
4762
|
* // Remove adjacent duplicate characters
|
|
4888
4763
|
* const letters = "aabbccaa"
|
|
4889
4764
|
* const dedupedLetters = Iterable.dedupeAdjacent(letters)
|
|
4890
|
-
*
|
|
4765
|
+
* Array.from(dedupedLetters) // => ["a", "b", "c", "a"]
|
|
4891
4766
|
*
|
|
4892
4767
|
* // Works with objects using deep equality
|
|
4893
4768
|
* const objects = [
|
|
@@ -4898,12 +4773,12 @@ export const dedupeAdjacentWith: {
|
|
|
4898
4773
|
* { type: "A" }
|
|
4899
4774
|
* ]
|
|
4900
4775
|
* const dedupedObjects = Iterable.dedupeAdjacent(objects)
|
|
4901
|
-
*
|
|
4776
|
+
* Array.from(dedupedObjects, (object) => object.type) // => ["A", "B", "A"]
|
|
4902
4777
|
*
|
|
4903
4778
|
* // Clean up streaming data
|
|
4904
4779
|
* const sensorData = [100, 100, 100, 101, 101, 102, 102, 102, 100]
|
|
4905
4780
|
* const cleanedData = Iterable.dedupeAdjacent(sensorData)
|
|
4906
|
-
*
|
|
4781
|
+
* Array.from(cleanedData) // => [100, 101, 102, 100]
|
|
4907
4782
|
* ```
|
|
4908
4783
|
*
|
|
4909
4784
|
* @category filtering
|
|
@@ -4916,14 +4791,14 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Iterable<A> = dedupeAdjac
|
|
|
4916
4791
|
*
|
|
4917
4792
|
* **Example** (Combining cartesian products)
|
|
4918
4793
|
*
|
|
4919
|
-
* ```ts
|
|
4794
|
+
* ```ts import.meta.vitest
|
|
4920
4795
|
* import { Iterable } from "effect"
|
|
4921
4796
|
*
|
|
4922
4797
|
* // Create coordinate pairs
|
|
4923
4798
|
* const xs = [1, 2]
|
|
4924
4799
|
* const ys = ["a", "b", "c"]
|
|
4925
4800
|
* const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
|
|
4926
|
-
*
|
|
4801
|
+
* Array.from(coordinates) // => ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
|
|
4927
4802
|
*
|
|
4928
4803
|
* // Generate all combinations of options
|
|
4929
4804
|
* const sizes = ["S", "M", "L"]
|
|
@@ -4933,18 +4808,13 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Iterable<A> = dedupeAdjac
|
|
|
4933
4808
|
* colors,
|
|
4934
4809
|
* (size, color) => ({ size, color })
|
|
4935
4810
|
* )
|
|
4936
|
-
*
|
|
4937
|
-
* // [
|
|
4938
|
-
* // { size: "S", color: "red" }, { size: "S", color: "blue" },
|
|
4939
|
-
* // { size: "M", color: "red" }, { size: "M", color: "blue" },
|
|
4940
|
-
* // { size: "L", color: "red" }, { size: "L", color: "blue" }
|
|
4941
|
-
* // ]
|
|
4811
|
+
* Array.from(products, ({ color, size }) => `${size}:${color}`) // => ["S:red", "S:blue", "M:red", "M:blue", "L:red", "L:blue"]
|
|
4942
4812
|
*
|
|
4943
4813
|
* // Mathematical operations on all pairs
|
|
4944
4814
|
* const a = [1, 2, 3]
|
|
4945
4815
|
* const b = [10, 20]
|
|
4946
4816
|
* const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
|
|
4947
|
-
*
|
|
4817
|
+
* Array.from(mathProducts) // => [10, 20, 20, 40, 30, 60]
|
|
4948
4818
|
*
|
|
4949
4819
|
* // Create test data combinations
|
|
4950
4820
|
* const userTypes = ["admin", "user"]
|
|
@@ -4954,11 +4824,10 @@ export const dedupeAdjacent: <A>(self: Iterable<A>) => Iterable<A> = dedupeAdjac
|
|
|
4954
4824
|
* features,
|
|
4955
4825
|
* (user, feature) => `${user}_can_${feature}`
|
|
4956
4826
|
* )
|
|
4957
|
-
*
|
|
4958
|
-
* // ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4827
|
+
* Array.from(testCases) // => ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4959
4828
|
* ```
|
|
4960
4829
|
*
|
|
4961
|
-
* @category
|
|
4830
|
+
* @category combining
|
|
4962
4831
|
* @since 2.0.0
|
|
4963
4832
|
*/
|
|
4964
4833
|
export const cartesianWith: {
|
|
@@ -4967,14 +4836,14 @@ export const cartesianWith: {
|
|
|
4967
4836
|
*
|
|
4968
4837
|
* **Example** (Combining cartesian products)
|
|
4969
4838
|
*
|
|
4970
|
-
* ```ts
|
|
4839
|
+
* ```ts import.meta.vitest
|
|
4971
4840
|
* import { Iterable } from "effect"
|
|
4972
4841
|
*
|
|
4973
4842
|
* // Create coordinate pairs
|
|
4974
4843
|
* const xs = [1, 2]
|
|
4975
4844
|
* const ys = ["a", "b", "c"]
|
|
4976
4845
|
* const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
|
|
4977
|
-
*
|
|
4846
|
+
* Array.from(coordinates) // => ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
|
|
4978
4847
|
*
|
|
4979
4848
|
* // Generate all combinations of options
|
|
4980
4849
|
* const sizes = ["S", "M", "L"]
|
|
@@ -4984,18 +4853,13 @@ export const cartesianWith: {
|
|
|
4984
4853
|
* colors,
|
|
4985
4854
|
* (size, color) => ({ size, color })
|
|
4986
4855
|
* )
|
|
4987
|
-
*
|
|
4988
|
-
* // [
|
|
4989
|
-
* // { size: "S", color: "red" }, { size: "S", color: "blue" },
|
|
4990
|
-
* // { size: "M", color: "red" }, { size: "M", color: "blue" },
|
|
4991
|
-
* // { size: "L", color: "red" }, { size: "L", color: "blue" }
|
|
4992
|
-
* // ]
|
|
4856
|
+
* Array.from(products, ({ color, size }) => `${size}:${color}`) // => ["S:red", "S:blue", "M:red", "M:blue", "L:red", "L:blue"]
|
|
4993
4857
|
*
|
|
4994
4858
|
* // Mathematical operations on all pairs
|
|
4995
4859
|
* const a = [1, 2, 3]
|
|
4996
4860
|
* const b = [10, 20]
|
|
4997
4861
|
* const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
|
|
4998
|
-
*
|
|
4862
|
+
* Array.from(mathProducts) // => [10, 20, 20, 40, 30, 60]
|
|
4999
4863
|
*
|
|
5000
4864
|
* // Create test data combinations
|
|
5001
4865
|
* const userTypes = ["admin", "user"]
|
|
@@ -5005,11 +4869,10 @@ export const cartesianWith: {
|
|
|
5005
4869
|
* features,
|
|
5006
4870
|
* (user, feature) => `${user}_can_${feature}`
|
|
5007
4871
|
* )
|
|
5008
|
-
*
|
|
5009
|
-
* // ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4872
|
+
* Array.from(testCases) // => ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
5010
4873
|
* ```
|
|
5011
4874
|
*
|
|
5012
|
-
* @category
|
|
4875
|
+
* @category combining
|
|
5013
4876
|
* @since 2.0.0
|
|
5014
4877
|
*/
|
|
5015
4878
|
<A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>
|
|
@@ -5018,14 +4881,14 @@ export const cartesianWith: {
|
|
|
5018
4881
|
*
|
|
5019
4882
|
* **Example** (Combining cartesian products)
|
|
5020
4883
|
*
|
|
5021
|
-
* ```ts
|
|
4884
|
+
* ```ts import.meta.vitest
|
|
5022
4885
|
* import { Iterable } from "effect"
|
|
5023
4886
|
*
|
|
5024
4887
|
* // Create coordinate pairs
|
|
5025
4888
|
* const xs = [1, 2]
|
|
5026
4889
|
* const ys = ["a", "b", "c"]
|
|
5027
4890
|
* const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
|
|
5028
|
-
*
|
|
4891
|
+
* Array.from(coordinates) // => ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
|
|
5029
4892
|
*
|
|
5030
4893
|
* // Generate all combinations of options
|
|
5031
4894
|
* const sizes = ["S", "M", "L"]
|
|
@@ -5035,18 +4898,13 @@ export const cartesianWith: {
|
|
|
5035
4898
|
* colors,
|
|
5036
4899
|
* (size, color) => ({ size, color })
|
|
5037
4900
|
* )
|
|
5038
|
-
*
|
|
5039
|
-
* // [
|
|
5040
|
-
* // { size: "S", color: "red" }, { size: "S", color: "blue" },
|
|
5041
|
-
* // { size: "M", color: "red" }, { size: "M", color: "blue" },
|
|
5042
|
-
* // { size: "L", color: "red" }, { size: "L", color: "blue" }
|
|
5043
|
-
* // ]
|
|
4901
|
+
* Array.from(products, ({ color, size }) => `${size}:${color}`) // => ["S:red", "S:blue", "M:red", "M:blue", "L:red", "L:blue"]
|
|
5044
4902
|
*
|
|
5045
4903
|
* // Mathematical operations on all pairs
|
|
5046
4904
|
* const a = [1, 2, 3]
|
|
5047
4905
|
* const b = [10, 20]
|
|
5048
4906
|
* const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
|
|
5049
|
-
*
|
|
4907
|
+
* Array.from(mathProducts) // => [10, 20, 20, 40, 30, 60]
|
|
5050
4908
|
*
|
|
5051
4909
|
* // Create test data combinations
|
|
5052
4910
|
* const userTypes = ["admin", "user"]
|
|
@@ -5056,18 +4914,47 @@ export const cartesianWith: {
|
|
|
5056
4914
|
* features,
|
|
5057
4915
|
* (user, feature) => `${user}_can_${feature}`
|
|
5058
4916
|
* )
|
|
5059
|
-
*
|
|
5060
|
-
* // ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
4917
|
+
* Array.from(testCases) // => ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
|
|
5061
4918
|
* ```
|
|
5062
4919
|
*
|
|
5063
|
-
* @category
|
|
4920
|
+
* @category combining
|
|
5064
4921
|
* @since 2.0.0
|
|
5065
4922
|
*/
|
|
5066
4923
|
<A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>
|
|
5067
4924
|
} = dual(
|
|
5068
4925
|
3,
|
|
5069
|
-
<A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C> =>
|
|
5070
|
-
|
|
4926
|
+
<A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C> => ({
|
|
4927
|
+
[Symbol.iterator]() {
|
|
4928
|
+
const cache: Array<B> = []
|
|
4929
|
+
let iterator: Iterator<B> | undefined
|
|
4930
|
+
let done = false
|
|
4931
|
+
const replay: Iterable<B> = {
|
|
4932
|
+
[Symbol.iterator]() {
|
|
4933
|
+
let index = 0
|
|
4934
|
+
return {
|
|
4935
|
+
next(): IteratorResult<B> {
|
|
4936
|
+
if (index < cache.length) {
|
|
4937
|
+
return { done: false, value: cache[index++] }
|
|
4938
|
+
}
|
|
4939
|
+
if (done) {
|
|
4940
|
+
return { done: true, value: undefined }
|
|
4941
|
+
}
|
|
4942
|
+
iterator ??= that[Symbol.iterator]()
|
|
4943
|
+
const result = iterator.next()
|
|
4944
|
+
if (result.done) {
|
|
4945
|
+
done = true
|
|
4946
|
+
return { done: true, value: undefined }
|
|
4947
|
+
}
|
|
4948
|
+
cache.push(result.value)
|
|
4949
|
+
index++
|
|
4950
|
+
return result
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
return flatMap(self, (a) => map(replay, (b) => f(a, b)))[Symbol.iterator]()
|
|
4956
|
+
}
|
|
4957
|
+
})
|
|
5071
4958
|
)
|
|
5072
4959
|
|
|
5073
4960
|
/**
|
|
@@ -5075,40 +4962,34 @@ export const cartesianWith: {
|
|
|
5075
4962
|
*
|
|
5076
4963
|
* **Example** (Generating cartesian pairs)
|
|
5077
4964
|
*
|
|
5078
|
-
* ```ts
|
|
4965
|
+
* ```ts import.meta.vitest
|
|
5079
4966
|
* import { Iterable } from "effect"
|
|
5080
4967
|
*
|
|
5081
4968
|
* // All pairs of numbers and letters
|
|
5082
4969
|
* const numbers = [1, 2, 3]
|
|
5083
4970
|
* const letters = ["a", "b"]
|
|
5084
4971
|
* const pairs = Iterable.cartesian(numbers, letters)
|
|
5085
|
-
*
|
|
5086
|
-
* // [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
4972
|
+
* Array.from(pairs) // => [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5087
4973
|
*
|
|
5088
4974
|
* // Generate coordinate grid
|
|
5089
4975
|
* const x = [0, 1, 2]
|
|
5090
4976
|
* const y = [0, 1]
|
|
5091
4977
|
* const grid = Iterable.cartesian(x, y)
|
|
5092
|
-
*
|
|
5093
|
-
* // [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
4978
|
+
* Array.from(grid) // => [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5094
4979
|
*
|
|
5095
4980
|
* // All combinations for testing
|
|
5096
4981
|
* const browsers = ["chrome", "firefox"]
|
|
5097
4982
|
* const devices = ["desktop", "mobile", "tablet"]
|
|
5098
4983
|
* const testMatrix = Iterable.cartesian(browsers, devices)
|
|
5099
|
-
*
|
|
5100
|
-
* // [
|
|
5101
|
-
* // ["chrome", "desktop"], ["chrome", "mobile"], ["chrome", "tablet"],
|
|
5102
|
-
* // ["firefox", "desktop"], ["firefox", "mobile"], ["firefox", "tablet"]
|
|
5103
|
-
* // ]
|
|
4984
|
+
* Array.from(testMatrix, ([browser, device]) => `${browser}:${device}`) // => ["chrome:desktop", "chrome:mobile", "chrome:tablet", "firefox:desktop", "firefox:mobile", "firefox:tablet"]
|
|
5104
4985
|
*
|
|
5105
4986
|
* // Empty iterable results in empty cartesian product
|
|
5106
4987
|
* const empty = Iterable.empty<number>()
|
|
5107
4988
|
* const withEmpty = Iterable.cartesian([1, 2], empty)
|
|
5108
|
-
*
|
|
4989
|
+
* Array.from(withEmpty) // => []
|
|
5109
4990
|
* ```
|
|
5110
4991
|
*
|
|
5111
|
-
* @category
|
|
4992
|
+
* @category combining
|
|
5112
4993
|
* @since 2.0.0
|
|
5113
4994
|
*/
|
|
5114
4995
|
export const cartesian: {
|
|
@@ -5117,40 +4998,34 @@ export const cartesian: {
|
|
|
5117
4998
|
*
|
|
5118
4999
|
* **Example** (Generating cartesian pairs)
|
|
5119
5000
|
*
|
|
5120
|
-
* ```ts
|
|
5001
|
+
* ```ts import.meta.vitest
|
|
5121
5002
|
* import { Iterable } from "effect"
|
|
5122
5003
|
*
|
|
5123
5004
|
* // All pairs of numbers and letters
|
|
5124
5005
|
* const numbers = [1, 2, 3]
|
|
5125
5006
|
* const letters = ["a", "b"]
|
|
5126
5007
|
* const pairs = Iterable.cartesian(numbers, letters)
|
|
5127
|
-
*
|
|
5128
|
-
* // [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5008
|
+
* Array.from(pairs) // => [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5129
5009
|
*
|
|
5130
5010
|
* // Generate coordinate grid
|
|
5131
5011
|
* const x = [0, 1, 2]
|
|
5132
5012
|
* const y = [0, 1]
|
|
5133
5013
|
* const grid = Iterable.cartesian(x, y)
|
|
5134
|
-
*
|
|
5135
|
-
* // [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5014
|
+
* Array.from(grid) // => [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5136
5015
|
*
|
|
5137
5016
|
* // All combinations for testing
|
|
5138
5017
|
* const browsers = ["chrome", "firefox"]
|
|
5139
5018
|
* const devices = ["desktop", "mobile", "tablet"]
|
|
5140
5019
|
* const testMatrix = Iterable.cartesian(browsers, devices)
|
|
5141
|
-
*
|
|
5142
|
-
* // [
|
|
5143
|
-
* // ["chrome", "desktop"], ["chrome", "mobile"], ["chrome", "tablet"],
|
|
5144
|
-
* // ["firefox", "desktop"], ["firefox", "mobile"], ["firefox", "tablet"]
|
|
5145
|
-
* // ]
|
|
5020
|
+
* Array.from(testMatrix, ([browser, device]) => `${browser}:${device}`) // => ["chrome:desktop", "chrome:mobile", "chrome:tablet", "firefox:desktop", "firefox:mobile", "firefox:tablet"]
|
|
5146
5021
|
*
|
|
5147
5022
|
* // Empty iterable results in empty cartesian product
|
|
5148
5023
|
* const empty = Iterable.empty<number>()
|
|
5149
5024
|
* const withEmpty = Iterable.cartesian([1, 2], empty)
|
|
5150
|
-
*
|
|
5025
|
+
* Array.from(withEmpty) // => []
|
|
5151
5026
|
* ```
|
|
5152
5027
|
*
|
|
5153
|
-
* @category
|
|
5028
|
+
* @category combining
|
|
5154
5029
|
* @since 2.0.0
|
|
5155
5030
|
*/
|
|
5156
5031
|
<B>(that: Iterable<B>): <A>(self: Iterable<A>) => Iterable<[A, B]>
|
|
@@ -5159,40 +5034,34 @@ export const cartesian: {
|
|
|
5159
5034
|
*
|
|
5160
5035
|
* **Example** (Generating cartesian pairs)
|
|
5161
5036
|
*
|
|
5162
|
-
* ```ts
|
|
5037
|
+
* ```ts import.meta.vitest
|
|
5163
5038
|
* import { Iterable } from "effect"
|
|
5164
5039
|
*
|
|
5165
5040
|
* // All pairs of numbers and letters
|
|
5166
5041
|
* const numbers = [1, 2, 3]
|
|
5167
5042
|
* const letters = ["a", "b"]
|
|
5168
5043
|
* const pairs = Iterable.cartesian(numbers, letters)
|
|
5169
|
-
*
|
|
5170
|
-
* // [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5044
|
+
* Array.from(pairs) // => [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]
|
|
5171
5045
|
*
|
|
5172
5046
|
* // Generate coordinate grid
|
|
5173
5047
|
* const x = [0, 1, 2]
|
|
5174
5048
|
* const y = [0, 1]
|
|
5175
5049
|
* const grid = Iterable.cartesian(x, y)
|
|
5176
|
-
*
|
|
5177
|
-
* // [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5050
|
+
* Array.from(grid) // => [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]
|
|
5178
5051
|
*
|
|
5179
5052
|
* // All combinations for testing
|
|
5180
5053
|
* const browsers = ["chrome", "firefox"]
|
|
5181
5054
|
* const devices = ["desktop", "mobile", "tablet"]
|
|
5182
5055
|
* const testMatrix = Iterable.cartesian(browsers, devices)
|
|
5183
|
-
*
|
|
5184
|
-
* // [
|
|
5185
|
-
* // ["chrome", "desktop"], ["chrome", "mobile"], ["chrome", "tablet"],
|
|
5186
|
-
* // ["firefox", "desktop"], ["firefox", "mobile"], ["firefox", "tablet"]
|
|
5187
|
-
* // ]
|
|
5056
|
+
* Array.from(testMatrix, ([browser, device]) => `${browser}:${device}`) // => ["chrome:desktop", "chrome:mobile", "chrome:tablet", "firefox:desktop", "firefox:mobile", "firefox:tablet"]
|
|
5188
5057
|
*
|
|
5189
5058
|
* // Empty iterable results in empty cartesian product
|
|
5190
5059
|
* const empty = Iterable.empty<number>()
|
|
5191
5060
|
* const withEmpty = Iterable.cartesian([1, 2], empty)
|
|
5192
|
-
*
|
|
5061
|
+
* Array.from(withEmpty) // => []
|
|
5193
5062
|
* ```
|
|
5194
5063
|
*
|
|
5195
|
-
* @category
|
|
5064
|
+
* @category combining
|
|
5196
5065
|
* @since 2.0.0
|
|
5197
5066
|
*/
|
|
5198
5067
|
<A, B>(self: Iterable<A>, that: Iterable<B>): Iterable<[A, B]>
|
|
@@ -5206,11 +5075,10 @@ export const cartesian: {
|
|
|
5206
5075
|
*
|
|
5207
5076
|
* **Example** (Counting matching elements)
|
|
5208
5077
|
*
|
|
5209
|
-
* ```ts
|
|
5078
|
+
* ```ts import.meta.vitest
|
|
5210
5079
|
* import { Iterable } from "effect"
|
|
5211
5080
|
*
|
|
5212
|
-
*
|
|
5213
|
-
* console.log(result) // 2
|
|
5081
|
+
* Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
5214
5082
|
* ```
|
|
5215
5083
|
*
|
|
5216
5084
|
* @category folding
|
|
@@ -5222,11 +5090,10 @@ export const countBy: {
|
|
|
5222
5090
|
*
|
|
5223
5091
|
* **Example** (Counting matching elements)
|
|
5224
5092
|
*
|
|
5225
|
-
* ```ts
|
|
5093
|
+
* ```ts import.meta.vitest
|
|
5226
5094
|
* import { Iterable } from "effect"
|
|
5227
5095
|
*
|
|
5228
|
-
*
|
|
5229
|
-
* console.log(result) // 2
|
|
5096
|
+
* Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
5230
5097
|
* ```
|
|
5231
5098
|
*
|
|
5232
5099
|
* @category folding
|
|
@@ -5238,11 +5105,10 @@ export const countBy: {
|
|
|
5238
5105
|
*
|
|
5239
5106
|
* **Example** (Counting matching elements)
|
|
5240
5107
|
*
|
|
5241
|
-
* ```ts
|
|
5108
|
+
* ```ts import.meta.vitest
|
|
5242
5109
|
* import { Iterable } from "effect"
|
|
5243
5110
|
*
|
|
5244
|
-
*
|
|
5245
|
-
* console.log(result) // 2
|
|
5111
|
+
* Iterable.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
5246
5112
|
* ```
|
|
5247
5113
|
*
|
|
5248
5114
|
* @category folding
|