effect 4.0.0-beta.102 → 4.0.0-beta.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +971 -1037
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +381 -407
- 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.js.map +1 -1
- package/dist/Cache.d.ts +405 -254
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +166 -101
- 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 +729 -768
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +514 -440
- 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 +225 -173
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +336 -265
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +194 -68
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +115 -80
- 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 +151 -274
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +171 -214
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +68 -77
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +57 -66
- 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 +9 -10
- 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 +16 -23
- 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 +104 -96
- 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 +132 -186
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +2841 -3247
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1322 -1546
- 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 +29 -21
- 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 +13 -55
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +7 -28
- 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 +82 -146
- 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 +106 -73
- 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 +85 -59
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +153 -264
- 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 +25 -33
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +48 -49
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +76 -145
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +40 -57
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +360 -714
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +168 -297
- 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 +12 -12
- package/dist/Inspectable.js +8 -8
- 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 +228 -306
- 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 +44 -102
- 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 +297 -234
- 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 +195 -175
- 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 +204 -450
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +7 -5
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +7 -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 +198 -642
- 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 +59 -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 +97 -189
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +187 -290
- 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 +211 -392
- 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.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 +162 -132
- 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 +291 -488
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +111 -202
- 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 -168
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +102 -168
- 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 +16 -13
- 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 +133 -217
- 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 +290 -1636
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +162 -803
- 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 +644 -642
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +491 -527
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +27 -50
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +366 -279
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +7 -6
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +7 -6
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +217 -174
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +218 -185
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +62 -190
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +73 -265
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +2 -2
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +123 -75
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +22 -36
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +20 -26
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +114 -74
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +120 -85
- 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.map +1 -1
- package/dist/ScopedRef.d.ts +3 -3
- package/dist/ScopedRef.js +2 -2
- package/dist/ScopedRef.js.map +1 -1
- package/dist/Semaphore.d.ts +96 -10
- 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 +117 -107
- 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 +1 -1
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +2415 -2949
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1078 -1381
- 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 +41 -50
- 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.map +1 -1
- package/dist/Take.js.map +1 -1
- package/dist/Terminal.d.ts +2 -2
- package/dist/Terminal.js +1 -1
- 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 +92 -127
- 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 +160 -136
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +97 -66
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +67 -45
- 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 +126 -67
- 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.js.map +1 -1
- package/dist/internal/array.js.map +1 -1
- package/dist/internal/core.js +1 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +4 -0
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/doNotation.js.map +1 -1
- package/dist/internal/effect.js +77 -40
- 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.map +1 -1
- 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.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.map +1 -1
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/redacted.js.map +1 -1
- package/dist/internal/references.js +3 -0
- 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.map +1 -1
- package/dist/internal/schema/cause.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +13 -11
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +8 -15
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- 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.map +1 -1
- package/dist/internal/schema/toArbitrary.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +48 -6
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +87 -107
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- 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 +13 -9
- 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 +50 -18
- 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 +29 -29
- package/dist/testing/TestSchema.js +25 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +95 -118
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +94 -117
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +1 -1
- 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 +55 -51
- package/dist/unstable/ai/Chat.js.map +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 +107 -67
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +104 -64
- 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 +141 -75
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +58 -50
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +68 -59
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +694 -241
- 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 +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +112 -38
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +53 -17
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +28 -14
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +9 -4
- 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 +59 -44
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +48 -39
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +26 -8
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +18 -4
- 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.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.js +14 -15
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +273 -69
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +111 -33
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliConfig.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +69 -76
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +57 -61
- 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 +705 -107
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +238 -42
- 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 +1 -1
- 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 +292 -78
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +128 -46
- 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 +344 -136
- 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 +23 -14
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.js.map +1 -1
- 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.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- 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.js.map +1 -1
- 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 +2 -2
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- 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 +5 -1
- 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 +10 -10
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +8 -8
- 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 +4 -2
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +4 -2
- 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.js +3 -3
- 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.js +5 -5
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -4
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.js.map +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 +16 -16
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +2 -2
- package/dist/unstable/cluster/RunnerStorage.js +1 -1
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +6 -6
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +19 -10
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +3 -2
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +3 -3
- 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.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.js +1 -1
- 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 +20 -5
- 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 +5 -5
- 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.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -1
- package/dist/unstable/devtools/DevTools.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- 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/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +6 -8
- package/dist/unstable/encoding/Msgpack.js.map +1 -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 +58 -8
- package/dist/unstable/encoding/Sse.js.map +1 -1
- 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 +15 -15
- package/dist/unstable/eventlog/EventJournal.js +13 -13
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +3 -3
- package/dist/unstable/eventlog/EventLog.js +3 -3
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +2 -2
- package/dist/unstable/eventlog/EventLogMessage.js +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/eventlog/EventLogRemote.js +1 -1
- 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 +13 -5
- 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 +14 -6
- 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.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- 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 +30 -18
- 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/Headers.d.ts +2 -2
- package/dist/unstable/http/Headers.js +2 -2
- 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 +51 -44
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +46 -17
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +2 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +4 -4
- package/dist/unstable/http/HttpClientResponse.js +2 -2
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +6 -6
- package/dist/unstable/http/HttpEffect.js +3 -3
- 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 +32 -0
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +88 -89
- 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.js +4 -4
- 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 +10 -0
- 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 +6 -6
- package/dist/unstable/http/Multipart.js +5 -5
- package/dist/unstable/http/Multipart.js.map +1 -1
- 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 +9 -17
- package/dist/unstable/http/UrlParams.js.map +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/preResponseHandler.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +10 -11
- 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 +11 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +42 -42
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +13 -13
- package/dist/unstable/httpapi/HttpApiError.js +13 -13
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +15 -15
- 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 +6 -6
- package/dist/unstable/httpapi/HttpApiSchema.js +4 -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 +13 -13
- package/dist/unstable/httpapi/OpenApi.js +13 -13
- 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 +12 -14
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +17 -4
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- 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.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.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.js +6 -6
- 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 +91 -15
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +26 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +24 -13
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +2 -2
- package/dist/unstable/persistence/Redis.js +1 -1
- 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 +64 -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 +1 -1
- 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 +10 -10
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +25 -22
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +14 -13
- 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 +24 -3
- 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 +12 -12
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +12 -11
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- 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 +175 -96
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +13 -13
- package/dist/unstable/rpc/RpcServer.js +17 -13
- 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 +52 -50
- 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 +5 -5
- package/dist/unstable/schema/VariantSchema.js +2 -2
- 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 +11 -3
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +9 -4
- 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.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +2 -2
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- 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.js +2 -2
- 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.js +15 -15
- 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.js +2 -2
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +7 -7
- package/dist/unstable/workers/WorkerError.js +6 -6
- 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.js +5 -5
- 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 +1 -1
- 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 +5 -6
- package/src/Array.ts +982 -1045
- package/src/BigDecimal.ts +433 -756
- package/src/BigInt.ts +213 -269
- package/src/Boolean.ts +146 -188
- package/src/Cache.ts +409 -255
- package/src/Cause.ts +167 -277
- package/src/Channel.ts +891 -816
- 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 +615 -332
- package/src/ConfigProvider.ts +214 -120
- package/src/Console.ts +289 -39
- package/src/Context.ts +319 -378
- package/src/Cron.ts +68 -77
- package/src/Crypto.ts +13 -15
- package/src/Data.ts +60 -80
- package/src/DateTime.ts +564 -660
- package/src/Deferred.ts +253 -256
- package/src/Duration.ts +216 -308
- package/src/Effect.ts +2893 -3279
- package/src/Encoding.ts +22 -40
- package/src/Equal.ts +49 -39
- package/src/Equivalence.ts +103 -105
- package/src/ErrorReporter.ts +51 -27
- package/src/ExecutionPlan.ts +13 -55
- package/src/Exit.ts +116 -192
- package/src/Fiber.ts +81 -148
- package/src/FiberHandle.ts +152 -105
- package/src/FiberMap.ts +225 -174
- package/src/FiberSet.ts +124 -82
- package/src/FileSystem.ts +155 -263
- package/src/Filter.ts +61 -33
- package/src/Formatter.ts +54 -56
- package/src/Function.ts +76 -145
- package/src/Graph.ts +416 -770
- 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 +12 -12
- package/src/Iterable.ts +620 -786
- package/src/JsonPatch.ts +58 -112
- package/src/JsonPointer.ts +8 -8
- package/src/JsonSchema.ts +402 -244
- package/src/Latch.ts +23 -35
- package/src/Layer.ts +359 -260
- package/src/LayerMap.ts +49 -29
- package/src/LayerRef.ts +6 -2
- package/src/LogLevel.ts +114 -214
- package/src/Logger.ts +344 -697
- package/src/ManagedRuntime.ts +7 -5
- package/src/Match.ts +217 -252
- package/src/Metric.ts +516 -1089
- package/src/MutableHashMap.ts +218 -255
- package/src/MutableHashSet.ts +84 -89
- package/src/MutableList.ts +73 -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 +243 -383
- package/src/Option.ts +447 -812
- package/src/Order.ts +109 -109
- package/src/Ordering.ts +20 -23
- 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 +200 -159
- package/src/Random.ts +49 -74
- package/src/RcMap.ts +121 -63
- package/src/RcRef.ts +24 -13
- package/src/Record.ts +291 -488
- 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 -168
- package/src/RegExp.ts +10 -14
- package/src/Request.ts +31 -21
- package/src/RequestResolver.ts +202 -91
- package/src/Result.ts +312 -484
- package/src/Runtime.ts +50 -75
- package/src/Schedule.ts +308 -1734
- package/src/Scheduler.ts +20 -7
- package/src/Schema.ts +716 -745
- package/src/SchemaAST.ts +466 -358
- package/src/SchemaError.ts +7 -6
- package/src/SchemaGetter.ts +242 -190
- package/src/SchemaIssue.ts +89 -275
- package/src/SchemaParser.ts +180 -93
- package/src/SchemaRepresentation.ts +22 -40
- package/src/SchemaTransformation.ts +129 -88
- package/src/Scope.ts +123 -151
- package/src/ScopedRef.ts +4 -4
- package/src/Semaphore.ts +152 -51
- package/src/Sink.ts +128 -113
- package/src/Stdio.ts +1 -1
- package/src/Stream.ts +2602 -3123
- package/src/String.ts +275 -312
- package/src/Struct.ts +109 -114
- package/src/SubscriptionRef.ts +284 -252
- package/src/Symbol.ts +3 -3
- package/src/Terminal.ts +2 -2
- package/src/Tracer.ts +102 -55
- package/src/Trie.ts +287 -679
- package/src/Tuple.ts +92 -127
- 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 +214 -183
- package/src/TxReentrantLock.ts +97 -66
- package/src/TxRef.ts +51 -32
- package/src/TxSemaphore.ts +129 -95
- package/src/TxSubscriptionRef.ts +97 -70
- package/src/Types.ts +126 -67
- package/src/Unify.ts +45 -65
- package/src/Utils.ts +23 -16
- package/src/internal/core.ts +2 -2
- package/src/internal/dateTime.ts +6 -0
- package/src/internal/effect.ts +93 -48
- package/src/internal/persistence.ts +2 -0
- package/src/internal/references.ts +3 -2
- package/src/internal/schema/fromJsonSchemaDocument.ts +15 -13
- package/src/internal/schema/fromRepresentation.ts +10 -16
- package/src/internal/schema/parser.ts +22 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +60 -6
- package/src/internal/schema/toRepresentation.ts +104 -119
- package/src/internal/trie.ts +10 -11
- package/src/testing/FastCheck.ts +8 -7
- package/src/testing/TestClock.ts +72 -30
- package/src/testing/TestConsole.ts +32 -31
- package/src/testing/TestSchema.ts +29 -29
- package/src/unstable/ai/AiError.ts +95 -118
- package/src/unstable/ai/AnthropicStructuredOutput.ts +1 -1
- package/src/unstable/ai/Chat.ts +132 -97
- package/src/unstable/ai/IdGenerator.ts +32 -28
- package/src/unstable/ai/LanguageModel.ts +107 -67
- package/src/unstable/ai/McpProtocol.ts +48 -0
- package/src/unstable/ai/McpSchema.ts +60 -50
- package/src/unstable/ai/McpServer.ts +930 -304
- package/src/unstable/ai/Model.ts +9 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +1 -1
- package/src/unstable/ai/Prompt.ts +145 -43
- package/src/unstable/ai/Response.ts +28 -14
- package/src/unstable/ai/Telemetry.ts +46 -13
- package/src/unstable/ai/Tokenizer.ts +14 -3
- package/src/unstable/ai/Tool.ts +59 -44
- package/src/unstable/ai/Toolkit.ts +26 -8
- package/src/unstable/ai/index.ts +5 -0
- 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 +13 -18
- package/src/unstable/cli/Argument.ts +273 -69
- package/src/unstable/cli/CliError.ts +69 -76
- package/src/unstable/cli/CliOutput.ts +44 -58
- package/src/unstable/cli/Command.ts +705 -107
- package/src/unstable/cli/Flag.ts +418 -138
- package/src/unstable/cli/GlobalFlag.ts +1 -1
- package/src/unstable/cli/HelpDoc.ts +12 -4
- package/src/unstable/cli/Param.ts +292 -78
- package/src/unstable/cli/Primitive.ts +370 -149
- package/src/unstable/cli/Prompt.ts +28 -14
- package/src/unstable/cli/internal/lexer.ts +8 -2
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +8 -8
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -1
- package/src/unstable/cluster/Entity.ts +15 -16
- package/src/unstable/cluster/EntityProxy.ts +4 -2
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/Envelope.ts +3 -3
- package/src/unstable/cluster/HttpRunner.ts +6 -4
- package/src/unstable/cluster/Message.ts +9 -9
- package/src/unstable/cluster/MessageStorage.ts +15 -15
- package/src/unstable/cluster/Reply.ts +4 -6
- package/src/unstable/cluster/RunnerHealth.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +41 -8
- package/src/unstable/cluster/RunnerStorage.ts +2 -2
- package/src/unstable/cluster/Runners.ts +23 -12
- package/src/unstable/cluster/Sharding.ts +7 -8
- package/src/unstable/cluster/ShardingConfig.ts +3 -3
- package/src/unstable/cluster/SingletonAddress.ts +1 -1
- package/src/unstable/cluster/Snowflake.ts +8 -8
- package/src/unstable/cluster/SqlMessageStorage.ts +1 -1
- package/src/unstable/cluster/SqlRunnerStorage.ts +21 -5
- package/src/unstable/cluster/internal/entityManager.ts +11 -15
- package/src/unstable/encoding/Msgpack.ts +6 -8
- package/src/unstable/encoding/Sse.ts +98 -16
- package/src/unstable/eventlog/Event.ts +20 -20
- package/src/unstable/eventlog/EventGroup.ts +4 -4
- package/src/unstable/eventlog/EventJournal.ts +15 -15
- package/src/unstable/eventlog/EventLog.ts +3 -3
- package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
- package/src/unstable/eventlog/EventLogMessage.ts +2 -2
- package/src/unstable/eventlog/EventLogRemote.ts +1 -1
- package/src/unstable/eventlog/EventLogServer.ts +41 -7
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +13 -5
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +14 -6
- package/src/unstable/eventlog/EventLogSessionAuth.ts +1 -1
- package/src/unstable/http/Cookies.ts +35 -21
- package/src/unstable/http/Etag.ts +1 -1
- package/src/unstable/http/FetchHttpClient.ts +3 -1
- package/src/unstable/http/Headers.ts +2 -2
- package/src/unstable/http/HttpBody.ts +20 -5
- package/src/unstable/http/HttpClient.ts +83 -55
- package/src/unstable/http/HttpClientRequest.ts +2 -0
- package/src/unstable/http/HttpClientResponse.ts +4 -4
- package/src/unstable/http/HttpEffect.ts +8 -8
- package/src/unstable/http/HttpMethod.ts +6 -9
- package/src/unstable/http/HttpMiddleware.ts +202 -39
- package/src/unstable/http/HttpPlatform.ts +95 -0
- package/src/unstable/http/HttpRouter.ts +102 -98
- package/src/unstable/http/HttpServer.ts +13 -13
- package/src/unstable/http/HttpServerError.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +4 -4
- package/src/unstable/http/HttpServerResponse.ts +30 -0
- package/src/unstable/http/HttpStaticServer.ts +35 -7
- package/src/unstable/http/Multipart.ts +6 -6
- package/src/unstable/http/Url.ts +33 -63
- package/src/unstable/http/UrlParams.ts +10 -18
- package/src/unstable/http/internal/compression.ts +196 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +10 -9
- package/src/unstable/httpapi/HttpApiClient.ts +14 -14
- package/src/unstable/httpapi/HttpApiEndpoint.ts +42 -42
- package/src/unstable/httpapi/HttpApiError.ts +13 -13
- package/src/unstable/httpapi/HttpApiGroup.ts +15 -15
- package/src/unstable/httpapi/HttpApiMiddleware.ts +71 -24
- package/src/unstable/httpapi/HttpApiScalar.ts +0 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +6 -6
- package/src/unstable/httpapi/OpenApi.ts +13 -13
- package/src/unstable/observability/OtlpExporter.ts +31 -19
- package/src/unstable/observability/OtlpMetrics.ts +4 -1
- package/src/unstable/observability/OtlpResource.ts +26 -17
- 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 +8 -8
- package/src/unstable/persistence/PersistedQueue.ts +6 -6
- package/src/unstable/persistence/Persistence.ts +126 -19
- package/src/unstable/persistence/RateLimiter.ts +26 -15
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcess.ts +64 -21
- package/src/unstable/process/ChildProcessSpawner.ts +21 -10
- package/src/unstable/reactivity/AsyncResult.ts +12 -13
- package/src/unstable/reactivity/Atom.ts +28 -25
- package/src/unstable/reactivity/AtomHttpApi.ts +5 -4
- package/src/unstable/reactivity/AtomRegistry.ts +24 -3
- 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 +16 -15
- 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 +18 -15
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/schema/Model.ts +52 -50
- package/src/unstable/schema/VariantSchema.ts +5 -5
- package/src/unstable/socket/Socket.ts +17 -4
- package/src/unstable/sql/SqlClient.ts +5 -6
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +5 -5
- package/src/unstable/sql/Statement.ts +24 -23
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +2 -2
- package/src/unstable/workers/WorkerError.ts +7 -7
- 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 +10 -10
- package/src/unstable/workflow/DurableQueue.ts +22 -20
- package/src/unstable/workflow/Workflow.ts +23 -23
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
- package/src/unstable/workflow/WorkflowProxy.ts +4 -2
- 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/src/internal/version.ts +0 -2
package/src/Chunk.ts
CHANGED
|
@@ -37,12 +37,12 @@ const TypeId = "~effect/collections/Chunk"
|
|
|
37
37
|
*
|
|
38
38
|
* **Example** (Inspecting chunk values)
|
|
39
39
|
*
|
|
40
|
-
* ```ts
|
|
40
|
+
* ```ts import.meta.vitest
|
|
41
41
|
* import { Chunk } from "effect"
|
|
42
42
|
*
|
|
43
43
|
* const chunk: Chunk.Chunk<number> = Chunk.make(1, 2, 3)
|
|
44
|
-
*
|
|
45
|
-
*
|
|
44
|
+
* chunk.length // => 3
|
|
45
|
+
* Chunk.toArray(chunk) // => [1, 2, 3]
|
|
46
46
|
* ```
|
|
47
47
|
*
|
|
48
48
|
* @category models
|
|
@@ -64,12 +64,12 @@ export interface Chunk<out A> extends Iterable<A>, Equal.Equal, Pipeable, Inspec
|
|
|
64
64
|
*
|
|
65
65
|
* **Example** (Working with non-empty chunks)
|
|
66
66
|
*
|
|
67
|
-
* ```ts
|
|
67
|
+
* ```ts import.meta.vitest
|
|
68
68
|
* import { Chunk } from "effect"
|
|
69
69
|
*
|
|
70
70
|
* const nonEmptyChunk: Chunk.NonEmptyChunk<number> = Chunk.make(1, 2, 3)
|
|
71
|
-
*
|
|
72
|
-
*
|
|
71
|
+
* Chunk.headNonEmpty(nonEmptyChunk) // => 1
|
|
72
|
+
* Chunk.lastNonEmpty(nonEmptyChunk) // => 3
|
|
73
73
|
* ```
|
|
74
74
|
*
|
|
75
75
|
* @category models
|
|
@@ -82,7 +82,7 @@ export interface NonEmptyChunk<out A> extends Chunk<A>, NonEmptyIterable<A> {}
|
|
|
82
82
|
*
|
|
83
83
|
* **Example** (Applying the Chunk type lambda)
|
|
84
84
|
*
|
|
85
|
-
* ```ts
|
|
85
|
+
* ```ts import.meta.vitest
|
|
86
86
|
* import type { Chunk, HKT } from "effect"
|
|
87
87
|
*
|
|
88
88
|
* // Create a Chunk type using the type lambda
|
|
@@ -90,7 +90,7 @@ export interface NonEmptyChunk<out A> extends Chunk<A>, NonEmptyIterable<A> {}
|
|
|
90
90
|
* // Equivalent to: Chunk<number>
|
|
91
91
|
* ```
|
|
92
92
|
*
|
|
93
|
-
* @category
|
|
93
|
+
* @category utility types
|
|
94
94
|
* @since 2.0.0
|
|
95
95
|
*/
|
|
96
96
|
export interface ChunkTypeLambda extends TypeLambda {
|
|
@@ -152,7 +152,7 @@ const emptyArray: ReadonlyArray<never> = []
|
|
|
152
152
|
*
|
|
153
153
|
* **Example** (Comparing chunks for equivalence)
|
|
154
154
|
*
|
|
155
|
-
* ```ts
|
|
155
|
+
* ```ts import.meta.vitest
|
|
156
156
|
* import { Chunk, Equivalence } from "effect"
|
|
157
157
|
*
|
|
158
158
|
* const chunk1 = Chunk.make(1, 2, 3)
|
|
@@ -160,8 +160,8 @@ const emptyArray: ReadonlyArray<never> = []
|
|
|
160
160
|
* const chunk3 = Chunk.make(1, 2, 4)
|
|
161
161
|
*
|
|
162
162
|
* const eq = Chunk.makeEquivalence(Equivalence.strictEqual<number>())
|
|
163
|
-
*
|
|
164
|
-
*
|
|
163
|
+
* eq(chunk1, chunk2) // => true
|
|
164
|
+
* eq(chunk1, chunk3) // => false
|
|
165
165
|
* ```
|
|
166
166
|
*
|
|
167
167
|
* @category instances
|
|
@@ -262,18 +262,18 @@ const makeChunk = <A>(backing: Backing<A>): Chunk<A> => {
|
|
|
262
262
|
*
|
|
263
263
|
* **Example** (Checking for chunks)
|
|
264
264
|
*
|
|
265
|
-
* ```ts
|
|
265
|
+
* ```ts import.meta.vitest
|
|
266
266
|
* import { Chunk } from "effect"
|
|
267
267
|
*
|
|
268
268
|
* const chunk = Chunk.make(1, 2, 3)
|
|
269
269
|
* const array = [1, 2, 3]
|
|
270
270
|
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
271
|
+
* Chunk.isChunk(chunk) // => true
|
|
272
|
+
* Chunk.isChunk(array) // => false
|
|
273
|
+
* Chunk.isChunk("string") // => false
|
|
274
274
|
* ```
|
|
275
275
|
*
|
|
276
|
-
* @category
|
|
276
|
+
* @category guards
|
|
277
277
|
* @since 2.0.0
|
|
278
278
|
*/
|
|
279
279
|
export const isChunk: {
|
|
@@ -282,18 +282,18 @@ export const isChunk: {
|
|
|
282
282
|
*
|
|
283
283
|
* **Example** (Checking for chunks)
|
|
284
284
|
*
|
|
285
|
-
* ```ts
|
|
285
|
+
* ```ts import.meta.vitest
|
|
286
286
|
* import { Chunk } from "effect"
|
|
287
287
|
*
|
|
288
288
|
* const chunk = Chunk.make(1, 2, 3)
|
|
289
289
|
* const array = [1, 2, 3]
|
|
290
290
|
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
291
|
+
* Chunk.isChunk(chunk) // => true
|
|
292
|
+
* Chunk.isChunk(array) // => false
|
|
293
|
+
* Chunk.isChunk("string") // => false
|
|
294
294
|
* ```
|
|
295
295
|
*
|
|
296
|
-
* @category
|
|
296
|
+
* @category guards
|
|
297
297
|
* @since 2.0.0
|
|
298
298
|
*/
|
|
299
299
|
<A>(u: Iterable<A>): u is Chunk<A>
|
|
@@ -302,18 +302,18 @@ export const isChunk: {
|
|
|
302
302
|
*
|
|
303
303
|
* **Example** (Checking for chunks)
|
|
304
304
|
*
|
|
305
|
-
* ```ts
|
|
305
|
+
* ```ts import.meta.vitest
|
|
306
306
|
* import { Chunk } from "effect"
|
|
307
307
|
*
|
|
308
308
|
* const chunk = Chunk.make(1, 2, 3)
|
|
309
309
|
* const array = [1, 2, 3]
|
|
310
310
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
311
|
+
* Chunk.isChunk(chunk) // => true
|
|
312
|
+
* Chunk.isChunk(array) // => false
|
|
313
|
+
* Chunk.isChunk("string") // => false
|
|
314
314
|
* ```
|
|
315
315
|
*
|
|
316
|
-
* @category
|
|
316
|
+
* @category guards
|
|
317
317
|
* @since 2.0.0
|
|
318
318
|
*/
|
|
319
319
|
(u: unknown): u is Chunk<unknown>
|
|
@@ -326,11 +326,10 @@ const _empty = makeChunk<never>({ _tag: "IEmpty" })
|
|
|
326
326
|
*
|
|
327
327
|
* **Example** (Creating an empty chunk)
|
|
328
328
|
*
|
|
329
|
-
* ```ts
|
|
329
|
+
* ```ts import.meta.vitest
|
|
330
330
|
* import { Chunk } from "effect"
|
|
331
331
|
*
|
|
332
|
-
*
|
|
333
|
-
* console.log(Chunk.size(emptyChunk)) // 0
|
|
332
|
+
* Chunk.size(Chunk.empty()) // => 0
|
|
334
333
|
* ```
|
|
335
334
|
*
|
|
336
335
|
* @category constructors
|
|
@@ -343,11 +342,10 @@ export const empty: <A = never>() => Chunk<A> = () => _empty
|
|
|
343
342
|
*
|
|
344
343
|
* **Example** (Creating a non-empty chunk)
|
|
345
344
|
*
|
|
346
|
-
* ```ts
|
|
345
|
+
* ```ts import.meta.vitest
|
|
347
346
|
* import { Chunk } from "effect"
|
|
348
347
|
*
|
|
349
|
-
*
|
|
350
|
-
* console.log(Chunk.toArray(chunk)) // [1, 2, 3, 4]
|
|
348
|
+
* Chunk.toArray(Chunk.make(1, 2, 3, 4)) // => [1, 2, 3, 4]
|
|
351
349
|
* ```
|
|
352
350
|
*
|
|
353
351
|
* @category constructors
|
|
@@ -361,11 +359,10 @@ export const make = <As extends readonly [any, ...Array<any>]>(...as: As): NonEm
|
|
|
361
359
|
*
|
|
362
360
|
* **Example** (Creating a single-element chunk)
|
|
363
361
|
*
|
|
364
|
-
* ```ts
|
|
362
|
+
* ```ts import.meta.vitest
|
|
365
363
|
* import { Chunk } from "effect"
|
|
366
364
|
*
|
|
367
|
-
*
|
|
368
|
-
* console.log(Chunk.toArray(chunk)) // ["hello"]
|
|
365
|
+
* Chunk.toArray(Chunk.of("hello")) // => ["hello"]
|
|
369
366
|
* ```
|
|
370
367
|
*
|
|
371
368
|
* @category constructors
|
|
@@ -378,11 +375,10 @@ export const of = <A>(a: A): NonEmptyChunk<A> => makeChunk({ _tag: "ISingleton",
|
|
|
378
375
|
*
|
|
379
376
|
* **Example** (Creating chunks from iterables)
|
|
380
377
|
*
|
|
381
|
-
* ```ts
|
|
378
|
+
* ```ts import.meta.vitest
|
|
382
379
|
* import { Chunk } from "effect"
|
|
383
380
|
*
|
|
384
|
-
*
|
|
385
|
-
* console.log(Chunk.toArray(chunk)) // [1, 2, 3]
|
|
381
|
+
* Chunk.toArray(Chunk.fromIterable([1, 2, 3])) // => [1, 2, 3]
|
|
386
382
|
* ```
|
|
387
383
|
*
|
|
388
384
|
* @category constructors
|
|
@@ -428,17 +424,16 @@ const toArray_ = <A>(self: Chunk<A>): Array<A> => toReadonlyArray(self).slice()
|
|
|
428
424
|
*
|
|
429
425
|
* **Example** (Converting chunks to mutable arrays)
|
|
430
426
|
*
|
|
431
|
-
* ```ts
|
|
427
|
+
* ```ts import.meta.vitest
|
|
432
428
|
* import { Chunk } from "effect"
|
|
433
429
|
*
|
|
434
430
|
* const chunk = Chunk.make(1, 2, 3)
|
|
435
431
|
* const array = Chunk.toArray(chunk)
|
|
436
|
-
*
|
|
437
|
-
*
|
|
432
|
+
* array // => [1, 2, 3]
|
|
433
|
+
* Array.isArray(array) // => true
|
|
438
434
|
*
|
|
439
435
|
* // With empty chunk
|
|
440
|
-
*
|
|
441
|
-
* console.log(Chunk.toArray(emptyChunk)) // []
|
|
436
|
+
* Chunk.toArray(Chunk.empty<number>()) // => []
|
|
442
437
|
* ```
|
|
443
438
|
*
|
|
444
439
|
* @category converting
|
|
@@ -478,19 +473,18 @@ const toReadonlyArray_ = <A>(self: Chunk<A>): ReadonlyArray<A> => {
|
|
|
478
473
|
*
|
|
479
474
|
* **Example** (Converting chunks to readonly arrays)
|
|
480
475
|
*
|
|
481
|
-
* ```ts
|
|
476
|
+
* ```ts import.meta.vitest
|
|
482
477
|
* import { Chunk } from "effect"
|
|
483
478
|
*
|
|
484
479
|
* const chunk = Chunk.make(1, 2, 3)
|
|
485
480
|
* const readonlyArray = Chunk.toReadonlyArray(chunk)
|
|
486
|
-
*
|
|
481
|
+
* readonlyArray // => [1, 2, 3]
|
|
487
482
|
*
|
|
488
483
|
* // The result is read-only, modifications would cause TypeScript errors
|
|
489
484
|
* // readonlyArray[0] = 10 // TypeScript error
|
|
490
485
|
*
|
|
491
486
|
* // With empty chunk
|
|
492
|
-
*
|
|
493
|
-
* console.log(Chunk.toReadonlyArray(emptyChunk)) // []
|
|
487
|
+
* Chunk.toReadonlyArray(Chunk.empty<number>()) // => []
|
|
494
488
|
* ```
|
|
495
489
|
*
|
|
496
490
|
* @category converting
|
|
@@ -531,16 +525,14 @@ const reverseChunk = <A>(self: Chunk<A>): Chunk<A> => {
|
|
|
531
525
|
*
|
|
532
526
|
* **Example** (Reversing chunks)
|
|
533
527
|
*
|
|
534
|
-
* ```ts
|
|
528
|
+
* ```ts import.meta.vitest
|
|
535
529
|
* import { Chunk } from "effect"
|
|
536
530
|
*
|
|
537
531
|
* const chunk = Chunk.make(1, 2, 3)
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
* console.log(Chunk.toArray(result)) // [3, 2, 1]
|
|
532
|
+
* Chunk.toArray(Chunk.reverse(chunk)) // => [3, 2, 1]
|
|
541
533
|
* ```
|
|
542
534
|
*
|
|
543
|
-
* @category
|
|
535
|
+
* @category transforming
|
|
544
536
|
* @since 2.0.0
|
|
545
537
|
*/
|
|
546
538
|
export const reverse: <S extends Chunk<any>>(self: S) => Chunk.With<S, Chunk.Infer<S>> = reverseChunk as any
|
|
@@ -551,21 +543,20 @@ export const reverse: <S extends Chunk<any>>(self: S) => Chunk.With<S, Chunk.Inf
|
|
|
551
543
|
*
|
|
552
544
|
* **Example** (Accessing elements safely)
|
|
553
545
|
*
|
|
554
|
-
* ```ts
|
|
555
|
-
* import { Chunk } from "effect"
|
|
546
|
+
* ```ts import.meta.vitest
|
|
547
|
+
* import { Chunk, Option } from "effect"
|
|
556
548
|
*
|
|
557
549
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
558
550
|
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
551
|
+
* Chunk.get(chunk, 1) // => Option.some("b")
|
|
552
|
+
* Chunk.get(chunk, 10) // => Option.none()
|
|
553
|
+
* Chunk.get(chunk, -1) // => Option.none()
|
|
562
554
|
*
|
|
563
555
|
* // Using pipe syntax
|
|
564
|
-
*
|
|
565
|
-
* console.log(result) // Option.some("c")
|
|
556
|
+
* chunk.pipe(Chunk.get(2)) // => Option.some("c")
|
|
566
557
|
* ```
|
|
567
558
|
*
|
|
568
|
-
* @category
|
|
559
|
+
* @category getters
|
|
569
560
|
* @since 2.0.0
|
|
570
561
|
*/
|
|
571
562
|
export const get: {
|
|
@@ -575,21 +566,20 @@ export const get: {
|
|
|
575
566
|
*
|
|
576
567
|
* **Example** (Accessing elements safely)
|
|
577
568
|
*
|
|
578
|
-
* ```ts
|
|
579
|
-
* import { Chunk } from "effect"
|
|
569
|
+
* ```ts import.meta.vitest
|
|
570
|
+
* import { Chunk, Option } from "effect"
|
|
580
571
|
*
|
|
581
572
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
582
573
|
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
574
|
+
* Chunk.get(chunk, 1) // => Option.some("b")
|
|
575
|
+
* Chunk.get(chunk, 10) // => Option.none()
|
|
576
|
+
* Chunk.get(chunk, -1) // => Option.none()
|
|
586
577
|
*
|
|
587
578
|
* // Using pipe syntax
|
|
588
|
-
*
|
|
589
|
-
* console.log(result) // Option.some("c")
|
|
579
|
+
* chunk.pipe(Chunk.get(2)) // => Option.some("c")
|
|
590
580
|
* ```
|
|
591
581
|
*
|
|
592
|
-
* @category
|
|
582
|
+
* @category getters
|
|
593
583
|
* @since 2.0.0
|
|
594
584
|
*/
|
|
595
585
|
(index: number): <A>(self: Chunk<A>) => Option<A>
|
|
@@ -599,21 +589,20 @@ export const get: {
|
|
|
599
589
|
*
|
|
600
590
|
* **Example** (Accessing elements safely)
|
|
601
591
|
*
|
|
602
|
-
* ```ts
|
|
603
|
-
* import { Chunk } from "effect"
|
|
592
|
+
* ```ts import.meta.vitest
|
|
593
|
+
* import { Chunk, Option } from "effect"
|
|
604
594
|
*
|
|
605
595
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
606
596
|
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
597
|
+
* Chunk.get(chunk, 1) // => Option.some("b")
|
|
598
|
+
* Chunk.get(chunk, 10) // => Option.none()
|
|
599
|
+
* Chunk.get(chunk, -1) // => Option.none()
|
|
610
600
|
*
|
|
611
601
|
* // Using pipe syntax
|
|
612
|
-
*
|
|
613
|
-
* console.log(result) // Option.some("c")
|
|
602
|
+
* chunk.pipe(Chunk.get(2)) // => Option.some("c")
|
|
614
603
|
* ```
|
|
615
604
|
*
|
|
616
|
-
* @category
|
|
605
|
+
* @category getters
|
|
617
606
|
* @since 2.0.0
|
|
618
607
|
*/
|
|
619
608
|
<A>(self: Chunk<A>, index: number): Option<A>
|
|
@@ -637,16 +626,16 @@ export const get: {
|
|
|
637
626
|
*
|
|
638
627
|
* **Example** (Creating chunks without copying arrays)
|
|
639
628
|
*
|
|
640
|
-
* ```ts
|
|
629
|
+
* ```ts import.meta.vitest
|
|
641
630
|
* import { Chunk } from "effect"
|
|
642
631
|
*
|
|
643
632
|
* const array = [1, 2, 3, 4, 5]
|
|
644
633
|
* const chunk = Chunk.fromArrayUnsafe(array)
|
|
645
|
-
*
|
|
634
|
+
* Chunk.toArray(chunk) // => [1, 2, 3, 4, 5]
|
|
646
635
|
*
|
|
647
636
|
* // Warning: Since this doesn't copy the array, mutations affect the chunk
|
|
648
637
|
* array[0] = 999
|
|
649
|
-
*
|
|
638
|
+
* Chunk.toArray(chunk) // => [999, 2, 3, 4, 5]
|
|
650
639
|
* ```
|
|
651
640
|
*
|
|
652
641
|
* @category unsafe
|
|
@@ -669,15 +658,15 @@ export const fromArrayUnsafe = <A>(self: ReadonlyArray<A>): Chunk<A> =>
|
|
|
669
658
|
*
|
|
670
659
|
* **Example** (Creating non-empty chunks without copying arrays)
|
|
671
660
|
*
|
|
672
|
-
* ```ts
|
|
661
|
+
* ```ts import.meta.vitest
|
|
673
662
|
* import { Array, Chunk } from "effect"
|
|
674
663
|
*
|
|
675
664
|
* const nonEmptyArray = Array.make(1, 2, 3, 4, 5)
|
|
676
665
|
* const chunk = Chunk.fromNonEmptyArrayUnsafe(nonEmptyArray)
|
|
677
|
-
*
|
|
666
|
+
* Chunk.toArray(chunk) // => [1, 2, 3, 4, 5]
|
|
678
667
|
*
|
|
679
668
|
* // The result is guaranteed to be non-empty
|
|
680
|
-
*
|
|
669
|
+
* Chunk.isNonEmpty(chunk) // => true
|
|
681
670
|
* ```
|
|
682
671
|
*
|
|
683
672
|
* @category unsafe
|
|
@@ -700,16 +689,16 @@ export const fromNonEmptyArrayUnsafe = <A>(self: NonEmptyReadonlyArray<A>): NonE
|
|
|
700
689
|
*
|
|
701
690
|
* **Example** (Accessing elements unsafely)
|
|
702
691
|
*
|
|
703
|
-
* ```ts
|
|
692
|
+
* ```ts import.meta.vitest
|
|
704
693
|
* import { Chunk, Option } from "effect"
|
|
705
694
|
*
|
|
706
695
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
707
696
|
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
697
|
+
* Chunk.getUnsafe(chunk, 1) // => "b"
|
|
698
|
+
* Chunk.getUnsafe(chunk, 3) // => "d"
|
|
710
699
|
*
|
|
711
700
|
* // Use Chunk.get when the index may be out of bounds
|
|
712
|
-
*
|
|
701
|
+
* Option.isNone(Chunk.get(chunk, 10)) // => true
|
|
713
702
|
* ```
|
|
714
703
|
*
|
|
715
704
|
* @category unsafe
|
|
@@ -730,16 +719,16 @@ export const getUnsafe: {
|
|
|
730
719
|
*
|
|
731
720
|
* **Example** (Accessing elements unsafely)
|
|
732
721
|
*
|
|
733
|
-
* ```ts
|
|
722
|
+
* ```ts import.meta.vitest
|
|
734
723
|
* import { Chunk, Option } from "effect"
|
|
735
724
|
*
|
|
736
725
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
737
726
|
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
727
|
+
* Chunk.getUnsafe(chunk, 1) // => "b"
|
|
728
|
+
* Chunk.getUnsafe(chunk, 3) // => "d"
|
|
740
729
|
*
|
|
741
730
|
* // Use Chunk.get when the index may be out of bounds
|
|
742
|
-
*
|
|
731
|
+
* Option.isNone(Chunk.get(chunk, 10)) // => true
|
|
743
732
|
* ```
|
|
744
733
|
*
|
|
745
734
|
* @category unsafe
|
|
@@ -760,16 +749,16 @@ export const getUnsafe: {
|
|
|
760
749
|
*
|
|
761
750
|
* **Example** (Accessing elements unsafely)
|
|
762
751
|
*
|
|
763
|
-
* ```ts
|
|
752
|
+
* ```ts import.meta.vitest
|
|
764
753
|
* import { Chunk, Option } from "effect"
|
|
765
754
|
*
|
|
766
755
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
767
756
|
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
757
|
+
* Chunk.getUnsafe(chunk, 1) // => "b"
|
|
758
|
+
* Chunk.getUnsafe(chunk, 3) // => "d"
|
|
770
759
|
*
|
|
771
760
|
* // Use Chunk.get when the index may be out of bounds
|
|
772
|
-
*
|
|
761
|
+
* Option.isNone(Chunk.get(chunk, 10)) // => true
|
|
773
762
|
* ```
|
|
774
763
|
*
|
|
775
764
|
* @category unsafe
|
|
@@ -815,17 +804,15 @@ export const getUnsafe: {
|
|
|
815
804
|
*
|
|
816
805
|
* **Example** (Appending an element)
|
|
817
806
|
*
|
|
818
|
-
* ```ts
|
|
807
|
+
* ```ts import.meta.vitest
|
|
819
808
|
* import { Chunk } from "effect"
|
|
820
809
|
*
|
|
821
810
|
* const chunk = Chunk.make(1, 2, 3)
|
|
822
|
-
*
|
|
823
|
-
* console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]
|
|
811
|
+
* Chunk.toArray(Chunk.append(chunk, 4)) // => [1, 2, 3, 4]
|
|
824
812
|
*
|
|
825
813
|
* // Appending to empty chunk
|
|
826
814
|
* const emptyChunk = Chunk.empty<number>()
|
|
827
|
-
*
|
|
828
|
-
* console.log(Chunk.toArray(singleElement)) // [42]
|
|
815
|
+
* Chunk.toArray(Chunk.append(emptyChunk, 42)) // => [42]
|
|
829
816
|
* ```
|
|
830
817
|
*
|
|
831
818
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -845,17 +832,15 @@ export const append: {
|
|
|
845
832
|
*
|
|
846
833
|
* **Example** (Appending an element)
|
|
847
834
|
*
|
|
848
|
-
* ```ts
|
|
835
|
+
* ```ts import.meta.vitest
|
|
849
836
|
* import { Chunk } from "effect"
|
|
850
837
|
*
|
|
851
838
|
* const chunk = Chunk.make(1, 2, 3)
|
|
852
|
-
*
|
|
853
|
-
* console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]
|
|
839
|
+
* Chunk.toArray(Chunk.append(chunk, 4)) // => [1, 2, 3, 4]
|
|
854
840
|
*
|
|
855
841
|
* // Appending to empty chunk
|
|
856
842
|
* const emptyChunk = Chunk.empty<number>()
|
|
857
|
-
*
|
|
858
|
-
* console.log(Chunk.toArray(singleElement)) // [42]
|
|
843
|
+
* Chunk.toArray(Chunk.append(emptyChunk, 42)) // => [42]
|
|
859
844
|
* ```
|
|
860
845
|
*
|
|
861
846
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -875,17 +860,15 @@ export const append: {
|
|
|
875
860
|
*
|
|
876
861
|
* **Example** (Appending an element)
|
|
877
862
|
*
|
|
878
|
-
* ```ts
|
|
863
|
+
* ```ts import.meta.vitest
|
|
879
864
|
* import { Chunk } from "effect"
|
|
880
865
|
*
|
|
881
866
|
* const chunk = Chunk.make(1, 2, 3)
|
|
882
|
-
*
|
|
883
|
-
* console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]
|
|
867
|
+
* Chunk.toArray(Chunk.append(chunk, 4)) // => [1, 2, 3, 4]
|
|
884
868
|
*
|
|
885
869
|
* // Appending to empty chunk
|
|
886
870
|
* const emptyChunk = Chunk.empty<number>()
|
|
887
|
-
*
|
|
888
|
-
* console.log(Chunk.toArray(singleElement)) // [42]
|
|
871
|
+
* Chunk.toArray(Chunk.append(emptyChunk, 42)) // => [42]
|
|
889
872
|
* ```
|
|
890
873
|
*
|
|
891
874
|
* @see {@link prepend} for adding one element before the existing elements
|
|
@@ -902,17 +885,15 @@ export const append: {
|
|
|
902
885
|
*
|
|
903
886
|
* **Example** (Prepending an element)
|
|
904
887
|
*
|
|
905
|
-
* ```ts
|
|
888
|
+
* ```ts import.meta.vitest
|
|
906
889
|
* import { Chunk } from "effect"
|
|
907
890
|
*
|
|
908
891
|
* const chunk = Chunk.make(2, 3, 4)
|
|
909
|
-
*
|
|
910
|
-
* console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]
|
|
892
|
+
* Chunk.toArray(Chunk.prepend(chunk, 1)) // => [1, 2, 3, 4]
|
|
911
893
|
*
|
|
912
894
|
* // Prepending to empty chunk
|
|
913
895
|
* const emptyChunk = Chunk.empty<string>()
|
|
914
|
-
*
|
|
915
|
-
* console.log(Chunk.toArray(singleElement)) // ["first"]
|
|
896
|
+
* Chunk.toArray(Chunk.prepend(emptyChunk, "first")) // => ["first"]
|
|
916
897
|
* ```
|
|
917
898
|
*
|
|
918
899
|
* @category combining
|
|
@@ -924,17 +905,15 @@ export const prepend: {
|
|
|
924
905
|
*
|
|
925
906
|
* **Example** (Prepending an element)
|
|
926
907
|
*
|
|
927
|
-
* ```ts
|
|
908
|
+
* ```ts import.meta.vitest
|
|
928
909
|
* import { Chunk } from "effect"
|
|
929
910
|
*
|
|
930
911
|
* const chunk = Chunk.make(2, 3, 4)
|
|
931
|
-
*
|
|
932
|
-
* console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]
|
|
912
|
+
* Chunk.toArray(Chunk.prepend(chunk, 1)) // => [1, 2, 3, 4]
|
|
933
913
|
*
|
|
934
914
|
* // Prepending to empty chunk
|
|
935
915
|
* const emptyChunk = Chunk.empty<string>()
|
|
936
|
-
*
|
|
937
|
-
* console.log(Chunk.toArray(singleElement)) // ["first"]
|
|
916
|
+
* Chunk.toArray(Chunk.prepend(emptyChunk, "first")) // => ["first"]
|
|
938
917
|
* ```
|
|
939
918
|
*
|
|
940
919
|
* @category combining
|
|
@@ -946,17 +925,15 @@ export const prepend: {
|
|
|
946
925
|
*
|
|
947
926
|
* **Example** (Prepending an element)
|
|
948
927
|
*
|
|
949
|
-
* ```ts
|
|
928
|
+
* ```ts import.meta.vitest
|
|
950
929
|
* import { Chunk } from "effect"
|
|
951
930
|
*
|
|
952
931
|
* const chunk = Chunk.make(2, 3, 4)
|
|
953
|
-
*
|
|
954
|
-
* console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]
|
|
932
|
+
* Chunk.toArray(Chunk.prepend(chunk, 1)) // => [1, 2, 3, 4]
|
|
955
933
|
*
|
|
956
934
|
* // Prepending to empty chunk
|
|
957
935
|
* const emptyChunk = Chunk.empty<string>()
|
|
958
|
-
*
|
|
959
|
-
* console.log(Chunk.toArray(singleElement)) // ["first"]
|
|
936
|
+
* Chunk.toArray(Chunk.prepend(emptyChunk, "first")) // => ["first"]
|
|
960
937
|
* ```
|
|
961
938
|
*
|
|
962
939
|
* @category combining
|
|
@@ -970,15 +947,14 @@ export const prepend: {
|
|
|
970
947
|
*
|
|
971
948
|
* **Example** (Taking elements from the start)
|
|
972
949
|
*
|
|
973
|
-
* ```ts
|
|
950
|
+
* ```ts import.meta.vitest
|
|
974
951
|
* import { Chunk } from "effect"
|
|
975
952
|
*
|
|
976
953
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
977
|
-
*
|
|
978
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
954
|
+
* Chunk.toArray(Chunk.take(chunk, 3)) // => [1, 2, 3]
|
|
979
955
|
* ```
|
|
980
956
|
*
|
|
981
|
-
* @category
|
|
957
|
+
* @category filtering
|
|
982
958
|
* @since 2.0.0
|
|
983
959
|
*/
|
|
984
960
|
export const take: {
|
|
@@ -987,15 +963,14 @@ export const take: {
|
|
|
987
963
|
*
|
|
988
964
|
* **Example** (Taking elements from the start)
|
|
989
965
|
*
|
|
990
|
-
* ```ts
|
|
966
|
+
* ```ts import.meta.vitest
|
|
991
967
|
* import { Chunk } from "effect"
|
|
992
968
|
*
|
|
993
969
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
994
|
-
*
|
|
995
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
970
|
+
* Chunk.toArray(Chunk.take(chunk, 3)) // => [1, 2, 3]
|
|
996
971
|
* ```
|
|
997
972
|
*
|
|
998
|
-
* @category
|
|
973
|
+
* @category filtering
|
|
999
974
|
* @since 2.0.0
|
|
1000
975
|
*/
|
|
1001
976
|
(n: number): <A>(self: Chunk<A>) => Chunk<A>
|
|
@@ -1004,19 +979,19 @@ export const take: {
|
|
|
1004
979
|
*
|
|
1005
980
|
* **Example** (Taking elements from the start)
|
|
1006
981
|
*
|
|
1007
|
-
* ```ts
|
|
982
|
+
* ```ts import.meta.vitest
|
|
1008
983
|
* import { Chunk } from "effect"
|
|
1009
984
|
*
|
|
1010
985
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1011
|
-
*
|
|
1012
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
986
|
+
* Chunk.toArray(Chunk.take(chunk, 3)) // => [1, 2, 3]
|
|
1013
987
|
* ```
|
|
1014
988
|
*
|
|
1015
|
-
* @category
|
|
989
|
+
* @category filtering
|
|
1016
990
|
* @since 2.0.0
|
|
1017
991
|
*/
|
|
1018
992
|
<A>(self: Chunk<A>, n: number): Chunk<A>
|
|
1019
|
-
} = dual(2, <A>(self: Chunk<A>,
|
|
993
|
+
} = dual(2, <A>(self: Chunk<A>, _n: number): Chunk<A> => {
|
|
994
|
+
const n = Math.floor(_n)
|
|
1020
995
|
if (n <= 0) {
|
|
1021
996
|
return _empty
|
|
1022
997
|
} else if (n >= self.length) {
|
|
@@ -1059,15 +1034,14 @@ export const take: {
|
|
|
1059
1034
|
*
|
|
1060
1035
|
* **Example** (Dropping elements from the start)
|
|
1061
1036
|
*
|
|
1062
|
-
* ```ts
|
|
1037
|
+
* ```ts import.meta.vitest
|
|
1063
1038
|
* import { Chunk } from "effect"
|
|
1064
1039
|
*
|
|
1065
1040
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1066
|
-
*
|
|
1067
|
-
* console.log(Chunk.toArray(result)) // [3, 4, 5]
|
|
1041
|
+
* Chunk.toArray(Chunk.drop(chunk, 2)) // => [3, 4, 5]
|
|
1068
1042
|
* ```
|
|
1069
1043
|
*
|
|
1070
|
-
* @category
|
|
1044
|
+
* @category filtering
|
|
1071
1045
|
* @since 2.0.0
|
|
1072
1046
|
*/
|
|
1073
1047
|
export const drop: {
|
|
@@ -1076,15 +1050,14 @@ export const drop: {
|
|
|
1076
1050
|
*
|
|
1077
1051
|
* **Example** (Dropping elements from the start)
|
|
1078
1052
|
*
|
|
1079
|
-
* ```ts
|
|
1053
|
+
* ```ts import.meta.vitest
|
|
1080
1054
|
* import { Chunk } from "effect"
|
|
1081
1055
|
*
|
|
1082
1056
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1083
|
-
*
|
|
1084
|
-
* console.log(Chunk.toArray(result)) // [3, 4, 5]
|
|
1057
|
+
* Chunk.toArray(Chunk.drop(chunk, 2)) // => [3, 4, 5]
|
|
1085
1058
|
* ```
|
|
1086
1059
|
*
|
|
1087
|
-
* @category
|
|
1060
|
+
* @category filtering
|
|
1088
1061
|
* @since 2.0.0
|
|
1089
1062
|
*/
|
|
1090
1063
|
(n: number): <A>(self: Chunk<A>) => Chunk<A>
|
|
@@ -1093,19 +1066,19 @@ export const drop: {
|
|
|
1093
1066
|
*
|
|
1094
1067
|
* **Example** (Dropping elements from the start)
|
|
1095
1068
|
*
|
|
1096
|
-
* ```ts
|
|
1069
|
+
* ```ts import.meta.vitest
|
|
1097
1070
|
* import { Chunk } from "effect"
|
|
1098
1071
|
*
|
|
1099
1072
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1100
|
-
*
|
|
1101
|
-
* console.log(Chunk.toArray(result)) // [3, 4, 5]
|
|
1073
|
+
* Chunk.toArray(Chunk.drop(chunk, 2)) // => [3, 4, 5]
|
|
1102
1074
|
* ```
|
|
1103
1075
|
*
|
|
1104
|
-
* @category
|
|
1076
|
+
* @category filtering
|
|
1105
1077
|
* @since 2.0.0
|
|
1106
1078
|
*/
|
|
1107
1079
|
<A>(self: Chunk<A>, n: number): Chunk<A>
|
|
1108
|
-
} = dual(2, <A>(self: Chunk<A>,
|
|
1080
|
+
} = dual(2, <A>(self: Chunk<A>, _n: number): Chunk<A> => {
|
|
1081
|
+
const n = Math.floor(_n)
|
|
1109
1082
|
if (n <= 0) {
|
|
1110
1083
|
return self
|
|
1111
1084
|
} else if (n >= self.length) {
|
|
@@ -1147,15 +1120,14 @@ export const drop: {
|
|
|
1147
1120
|
*
|
|
1148
1121
|
* **Example** (Dropping elements from the end)
|
|
1149
1122
|
*
|
|
1150
|
-
* ```ts
|
|
1123
|
+
* ```ts import.meta.vitest
|
|
1151
1124
|
* import { Chunk } from "effect"
|
|
1152
1125
|
*
|
|
1153
1126
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1154
|
-
*
|
|
1155
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
1127
|
+
* Chunk.toArray(Chunk.dropRight(chunk, 2)) // => [1, 2, 3]
|
|
1156
1128
|
* ```
|
|
1157
1129
|
*
|
|
1158
|
-
* @category
|
|
1130
|
+
* @category filtering
|
|
1159
1131
|
* @since 2.0.0
|
|
1160
1132
|
*/
|
|
1161
1133
|
export const dropRight: {
|
|
@@ -1164,15 +1136,14 @@ export const dropRight: {
|
|
|
1164
1136
|
*
|
|
1165
1137
|
* **Example** (Dropping elements from the end)
|
|
1166
1138
|
*
|
|
1167
|
-
* ```ts
|
|
1139
|
+
* ```ts import.meta.vitest
|
|
1168
1140
|
* import { Chunk } from "effect"
|
|
1169
1141
|
*
|
|
1170
1142
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1171
|
-
*
|
|
1172
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
1143
|
+
* Chunk.toArray(Chunk.dropRight(chunk, 2)) // => [1, 2, 3]
|
|
1173
1144
|
* ```
|
|
1174
1145
|
*
|
|
1175
|
-
* @category
|
|
1146
|
+
* @category filtering
|
|
1176
1147
|
* @since 2.0.0
|
|
1177
1148
|
*/
|
|
1178
1149
|
(n: number): <A>(self: Chunk<A>) => Chunk<A>
|
|
@@ -1181,15 +1152,14 @@ export const dropRight: {
|
|
|
1181
1152
|
*
|
|
1182
1153
|
* **Example** (Dropping elements from the end)
|
|
1183
1154
|
*
|
|
1184
|
-
* ```ts
|
|
1155
|
+
* ```ts import.meta.vitest
|
|
1185
1156
|
* import { Chunk } from "effect"
|
|
1186
1157
|
*
|
|
1187
1158
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1188
|
-
*
|
|
1189
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
1159
|
+
* Chunk.toArray(Chunk.dropRight(chunk, 2)) // => [1, 2, 3]
|
|
1190
1160
|
* ```
|
|
1191
1161
|
*
|
|
1192
|
-
* @category
|
|
1162
|
+
* @category filtering
|
|
1193
1163
|
* @since 2.0.0
|
|
1194
1164
|
*/
|
|
1195
1165
|
<A>(self: Chunk<A>, n: number): Chunk<A>
|
|
@@ -1200,15 +1170,14 @@ export const dropRight: {
|
|
|
1200
1170
|
*
|
|
1201
1171
|
* **Example** (Dropping elements while a predicate matches)
|
|
1202
1172
|
*
|
|
1203
|
-
* ```ts
|
|
1173
|
+
* ```ts import.meta.vitest
|
|
1204
1174
|
* import { Chunk } from "effect"
|
|
1205
1175
|
*
|
|
1206
1176
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1207
|
-
*
|
|
1208
|
-
* console.log(Chunk.toArray(result)) // [3, 4, 5]
|
|
1177
|
+
* Chunk.toArray(Chunk.dropWhile(chunk, (n) => n < 3)) // => [3, 4, 5]
|
|
1209
1178
|
* ```
|
|
1210
1179
|
*
|
|
1211
|
-
* @category
|
|
1180
|
+
* @category filtering
|
|
1212
1181
|
* @since 2.0.0
|
|
1213
1182
|
*/
|
|
1214
1183
|
export const dropWhile: {
|
|
@@ -1217,15 +1186,14 @@ export const dropWhile: {
|
|
|
1217
1186
|
*
|
|
1218
1187
|
* **Example** (Dropping elements while a predicate matches)
|
|
1219
1188
|
*
|
|
1220
|
-
* ```ts
|
|
1189
|
+
* ```ts import.meta.vitest
|
|
1221
1190
|
* import { Chunk } from "effect"
|
|
1222
1191
|
*
|
|
1223
1192
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1224
|
-
*
|
|
1225
|
-
* console.log(Chunk.toArray(result)) // [3, 4, 5]
|
|
1193
|
+
* Chunk.toArray(Chunk.dropWhile(chunk, (n) => n < 3)) // => [3, 4, 5]
|
|
1226
1194
|
* ```
|
|
1227
1195
|
*
|
|
1228
|
-
* @category
|
|
1196
|
+
* @category filtering
|
|
1229
1197
|
* @since 2.0.0
|
|
1230
1198
|
*/
|
|
1231
1199
|
<A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => Chunk<A>
|
|
@@ -1234,15 +1202,14 @@ export const dropWhile: {
|
|
|
1234
1202
|
*
|
|
1235
1203
|
* **Example** (Dropping elements while a predicate matches)
|
|
1236
1204
|
*
|
|
1237
|
-
* ```ts
|
|
1205
|
+
* ```ts import.meta.vitest
|
|
1238
1206
|
* import { Chunk } from "effect"
|
|
1239
1207
|
*
|
|
1240
1208
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
1241
|
-
*
|
|
1242
|
-
* console.log(Chunk.toArray(result)) // [3, 4, 5]
|
|
1209
|
+
* Chunk.toArray(Chunk.dropWhile(chunk, (n) => n < 3)) // => [3, 4, 5]
|
|
1243
1210
|
* ```
|
|
1244
1211
|
*
|
|
1245
|
-
* @category
|
|
1212
|
+
* @category filtering
|
|
1246
1213
|
* @since 2.0.0
|
|
1247
1214
|
*/
|
|
1248
1215
|
<A>(self: Chunk<A>, predicate: Predicate<A>): Chunk<A>
|
|
@@ -1262,16 +1229,13 @@ export const dropWhile: {
|
|
|
1262
1229
|
*
|
|
1263
1230
|
* **Example** (Prepending all elements)
|
|
1264
1231
|
*
|
|
1265
|
-
* ```ts
|
|
1232
|
+
* ```ts import.meta.vitest
|
|
1266
1233
|
* import { Chunk } from "effect"
|
|
1267
1234
|
*
|
|
1268
|
-
*
|
|
1235
|
+
* Chunk.make(1, 2).pipe(
|
|
1269
1236
|
* Chunk.prependAll(Chunk.make("a", "b")),
|
|
1270
1237
|
* Chunk.toArray
|
|
1271
|
-
* )
|
|
1272
|
-
*
|
|
1273
|
-
* console.log(result)
|
|
1274
|
-
* // [ "a", "b", 1, 2 ]
|
|
1238
|
+
* ) // => ["a", "b", 1, 2]
|
|
1275
1239
|
* ```
|
|
1276
1240
|
*
|
|
1277
1241
|
* @category combining
|
|
@@ -1284,16 +1248,13 @@ export const prependAll: {
|
|
|
1284
1248
|
*
|
|
1285
1249
|
* **Example** (Prepending all elements)
|
|
1286
1250
|
*
|
|
1287
|
-
* ```ts
|
|
1251
|
+
* ```ts import.meta.vitest
|
|
1288
1252
|
* import { Chunk } from "effect"
|
|
1289
1253
|
*
|
|
1290
|
-
*
|
|
1254
|
+
* Chunk.make(1, 2).pipe(
|
|
1291
1255
|
* Chunk.prependAll(Chunk.make("a", "b")),
|
|
1292
1256
|
* Chunk.toArray
|
|
1293
|
-
* )
|
|
1294
|
-
*
|
|
1295
|
-
* console.log(result)
|
|
1296
|
-
* // [ "a", "b", 1, 2 ]
|
|
1257
|
+
* ) // => ["a", "b", 1, 2]
|
|
1297
1258
|
* ```
|
|
1298
1259
|
*
|
|
1299
1260
|
* @category combining
|
|
@@ -1306,16 +1267,13 @@ export const prependAll: {
|
|
|
1306
1267
|
*
|
|
1307
1268
|
* **Example** (Prepending all elements)
|
|
1308
1269
|
*
|
|
1309
|
-
* ```ts
|
|
1270
|
+
* ```ts import.meta.vitest
|
|
1310
1271
|
* import { Chunk } from "effect"
|
|
1311
1272
|
*
|
|
1312
|
-
*
|
|
1273
|
+
* Chunk.make(1, 2).pipe(
|
|
1313
1274
|
* Chunk.prependAll(Chunk.make("a", "b")),
|
|
1314
1275
|
* Chunk.toArray
|
|
1315
|
-
* )
|
|
1316
|
-
*
|
|
1317
|
-
* console.log(result)
|
|
1318
|
-
* // [ "a", "b", 1, 2 ]
|
|
1276
|
+
* ) // => ["a", "b", 1, 2]
|
|
1319
1277
|
* ```
|
|
1320
1278
|
*
|
|
1321
1279
|
* @category combining
|
|
@@ -1328,16 +1286,13 @@ export const prependAll: {
|
|
|
1328
1286
|
*
|
|
1329
1287
|
* **Example** (Prepending all elements)
|
|
1330
1288
|
*
|
|
1331
|
-
* ```ts
|
|
1289
|
+
* ```ts import.meta.vitest
|
|
1332
1290
|
* import { Chunk } from "effect"
|
|
1333
1291
|
*
|
|
1334
|
-
*
|
|
1292
|
+
* Chunk.make(1, 2).pipe(
|
|
1335
1293
|
* Chunk.prependAll(Chunk.make("a", "b")),
|
|
1336
1294
|
* Chunk.toArray
|
|
1337
|
-
* )
|
|
1338
|
-
*
|
|
1339
|
-
* console.log(result)
|
|
1340
|
-
* // [ "a", "b", 1, 2 ]
|
|
1295
|
+
* ) // => ["a", "b", 1, 2]
|
|
1341
1296
|
* ```
|
|
1342
1297
|
*
|
|
1343
1298
|
* @category combining
|
|
@@ -1350,16 +1305,13 @@ export const prependAll: {
|
|
|
1350
1305
|
*
|
|
1351
1306
|
* **Example** (Prepending all elements)
|
|
1352
1307
|
*
|
|
1353
|
-
* ```ts
|
|
1308
|
+
* ```ts import.meta.vitest
|
|
1354
1309
|
* import { Chunk } from "effect"
|
|
1355
1310
|
*
|
|
1356
|
-
*
|
|
1311
|
+
* Chunk.make(1, 2).pipe(
|
|
1357
1312
|
* Chunk.prependAll(Chunk.make("a", "b")),
|
|
1358
1313
|
* Chunk.toArray
|
|
1359
|
-
* )
|
|
1360
|
-
*
|
|
1361
|
-
* console.log(result)
|
|
1362
|
-
* // [ "a", "b", 1, 2 ]
|
|
1314
|
+
* ) // => ["a", "b", 1, 2]
|
|
1363
1315
|
* ```
|
|
1364
1316
|
*
|
|
1365
1317
|
* @category combining
|
|
@@ -1379,16 +1331,13 @@ export const prependAll: {
|
|
|
1379
1331
|
*
|
|
1380
1332
|
* **Example** (Appending all elements)
|
|
1381
1333
|
*
|
|
1382
|
-
* ```ts
|
|
1334
|
+
* ```ts import.meta.vitest
|
|
1383
1335
|
* import { Chunk } from "effect"
|
|
1384
1336
|
*
|
|
1385
|
-
*
|
|
1337
|
+
* Chunk.make(1, 2).pipe(
|
|
1386
1338
|
* Chunk.appendAll(Chunk.make("a", "b")),
|
|
1387
1339
|
* Chunk.toArray
|
|
1388
|
-
* )
|
|
1389
|
-
*
|
|
1390
|
-
* console.log(result)
|
|
1391
|
-
* // [ 1, 2, "a", "b" ]
|
|
1340
|
+
* ) // => [1, 2, "a", "b"]
|
|
1392
1341
|
* ```
|
|
1393
1342
|
*
|
|
1394
1343
|
* @see {@link prependAll} for concatenating chunks in the opposite order
|
|
@@ -1409,16 +1358,13 @@ export const appendAll: {
|
|
|
1409
1358
|
*
|
|
1410
1359
|
* **Example** (Appending all elements)
|
|
1411
1360
|
*
|
|
1412
|
-
* ```ts
|
|
1361
|
+
* ```ts import.meta.vitest
|
|
1413
1362
|
* import { Chunk } from "effect"
|
|
1414
1363
|
*
|
|
1415
|
-
*
|
|
1364
|
+
* Chunk.make(1, 2).pipe(
|
|
1416
1365
|
* Chunk.appendAll(Chunk.make("a", "b")),
|
|
1417
1366
|
* Chunk.toArray
|
|
1418
|
-
* )
|
|
1419
|
-
*
|
|
1420
|
-
* console.log(result)
|
|
1421
|
-
* // [ 1, 2, "a", "b" ]
|
|
1367
|
+
* ) // => [1, 2, "a", "b"]
|
|
1422
1368
|
* ```
|
|
1423
1369
|
*
|
|
1424
1370
|
* @see {@link prependAll} for concatenating chunks in the opposite order
|
|
@@ -1439,16 +1385,13 @@ export const appendAll: {
|
|
|
1439
1385
|
*
|
|
1440
1386
|
* **Example** (Appending all elements)
|
|
1441
1387
|
*
|
|
1442
|
-
* ```ts
|
|
1388
|
+
* ```ts import.meta.vitest
|
|
1443
1389
|
* import { Chunk } from "effect"
|
|
1444
1390
|
*
|
|
1445
|
-
*
|
|
1391
|
+
* Chunk.make(1, 2).pipe(
|
|
1446
1392
|
* Chunk.appendAll(Chunk.make("a", "b")),
|
|
1447
1393
|
* Chunk.toArray
|
|
1448
|
-
* )
|
|
1449
|
-
*
|
|
1450
|
-
* console.log(result)
|
|
1451
|
-
* // [ 1, 2, "a", "b" ]
|
|
1394
|
+
* ) // => [1, 2, "a", "b"]
|
|
1452
1395
|
* ```
|
|
1453
1396
|
*
|
|
1454
1397
|
* @see {@link prependAll} for concatenating chunks in the opposite order
|
|
@@ -1469,16 +1412,13 @@ export const appendAll: {
|
|
|
1469
1412
|
*
|
|
1470
1413
|
* **Example** (Appending all elements)
|
|
1471
1414
|
*
|
|
1472
|
-
* ```ts
|
|
1415
|
+
* ```ts import.meta.vitest
|
|
1473
1416
|
* import { Chunk } from "effect"
|
|
1474
1417
|
*
|
|
1475
|
-
*
|
|
1418
|
+
* Chunk.make(1, 2).pipe(
|
|
1476
1419
|
* Chunk.appendAll(Chunk.make("a", "b")),
|
|
1477
1420
|
* Chunk.toArray
|
|
1478
|
-
* )
|
|
1479
|
-
*
|
|
1480
|
-
* console.log(result)
|
|
1481
|
-
* // [ 1, 2, "a", "b" ]
|
|
1421
|
+
* ) // => [1, 2, "a", "b"]
|
|
1482
1422
|
* ```
|
|
1483
1423
|
*
|
|
1484
1424
|
* @see {@link prependAll} for concatenating chunks in the opposite order
|
|
@@ -1499,16 +1439,13 @@ export const appendAll: {
|
|
|
1499
1439
|
*
|
|
1500
1440
|
* **Example** (Appending all elements)
|
|
1501
1441
|
*
|
|
1502
|
-
* ```ts
|
|
1442
|
+
* ```ts import.meta.vitest
|
|
1503
1443
|
* import { Chunk } from "effect"
|
|
1504
1444
|
*
|
|
1505
|
-
*
|
|
1445
|
+
* Chunk.make(1, 2).pipe(
|
|
1506
1446
|
* Chunk.appendAll(Chunk.make("a", "b")),
|
|
1507
1447
|
* Chunk.toArray
|
|
1508
|
-
* )
|
|
1509
|
-
*
|
|
1510
|
-
* console.log(result)
|
|
1511
|
-
* // [ 1, 2, "a", "b" ]
|
|
1448
|
+
* ) // => [1, 2, "a", "b"]
|
|
1512
1449
|
* ```
|
|
1513
1450
|
*
|
|
1514
1451
|
* @see {@link prependAll} for concatenating chunks in the opposite order
|
|
@@ -1538,16 +1475,13 @@ export const appendAll: {
|
|
|
1538
1475
|
*
|
|
1539
1476
|
* **Example** (Appending all elements)
|
|
1540
1477
|
*
|
|
1541
|
-
* ```ts
|
|
1478
|
+
* ```ts import.meta.vitest
|
|
1542
1479
|
* import { Chunk } from "effect"
|
|
1543
1480
|
*
|
|
1544
|
-
*
|
|
1481
|
+
* Chunk.make(1, 2).pipe(
|
|
1545
1482
|
* Chunk.appendAll(Chunk.make("a", "b")),
|
|
1546
1483
|
* Chunk.toArray
|
|
1547
|
-
* )
|
|
1548
|
-
*
|
|
1549
|
-
* console.log(result)
|
|
1550
|
-
* // [ 1, 2, "a", "b" ]
|
|
1484
|
+
* ) // => [1, 2, "a", "b"]
|
|
1551
1485
|
* ```
|
|
1552
1486
|
*
|
|
1553
1487
|
* @see {@link prependAll} for concatenating chunks in the opposite order
|
|
@@ -1593,7 +1527,7 @@ export const appendAll: {
|
|
|
1593
1527
|
*
|
|
1594
1528
|
* **Example** (Filtering and mapping values)
|
|
1595
1529
|
*
|
|
1596
|
-
* ```ts
|
|
1530
|
+
* ```ts import.meta.vitest
|
|
1597
1531
|
* import { Chunk, Result } from "effect"
|
|
1598
1532
|
*
|
|
1599
1533
|
* const chunk = Chunk.make("1", "2", "hello", "3", "world")
|
|
@@ -1601,14 +1535,14 @@ export const appendAll: {
|
|
|
1601
1535
|
* const num = parseInt(str)
|
|
1602
1536
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
1603
1537
|
* })
|
|
1604
|
-
*
|
|
1538
|
+
* Chunk.toArray(numbers) // => [1, 2, 3]
|
|
1605
1539
|
*
|
|
1606
1540
|
* // With index parameter
|
|
1607
1541
|
* const evenIndexNumbers = Chunk.filterMap(chunk, (str, i) => {
|
|
1608
1542
|
* const num = parseInt(str)
|
|
1609
1543
|
* return isNaN(num) || i % 2 !== 0 ? Result.failVoid : Result.succeed(num)
|
|
1610
1544
|
* })
|
|
1611
|
-
*
|
|
1545
|
+
* Chunk.toArray(evenIndexNumbers) // => [1]
|
|
1612
1546
|
* ```
|
|
1613
1547
|
*
|
|
1614
1548
|
* @category filtering
|
|
@@ -1620,7 +1554,7 @@ export const filterMap: {
|
|
|
1620
1554
|
*
|
|
1621
1555
|
* **Example** (Filtering and mapping values)
|
|
1622
1556
|
*
|
|
1623
|
-
* ```ts
|
|
1557
|
+
* ```ts import.meta.vitest
|
|
1624
1558
|
* import { Chunk, Result } from "effect"
|
|
1625
1559
|
*
|
|
1626
1560
|
* const chunk = Chunk.make("1", "2", "hello", "3", "world")
|
|
@@ -1628,14 +1562,14 @@ export const filterMap: {
|
|
|
1628
1562
|
* const num = parseInt(str)
|
|
1629
1563
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
1630
1564
|
* })
|
|
1631
|
-
*
|
|
1565
|
+
* Chunk.toArray(numbers) // => [1, 2, 3]
|
|
1632
1566
|
*
|
|
1633
1567
|
* // With index parameter
|
|
1634
1568
|
* const evenIndexNumbers = Chunk.filterMap(chunk, (str, i) => {
|
|
1635
1569
|
* const num = parseInt(str)
|
|
1636
1570
|
* return isNaN(num) || i % 2 !== 0 ? Result.failVoid : Result.succeed(num)
|
|
1637
1571
|
* })
|
|
1638
|
-
*
|
|
1572
|
+
* Chunk.toArray(evenIndexNumbers) // => [1]
|
|
1639
1573
|
* ```
|
|
1640
1574
|
*
|
|
1641
1575
|
* @category filtering
|
|
@@ -1647,7 +1581,7 @@ export const filterMap: {
|
|
|
1647
1581
|
*
|
|
1648
1582
|
* **Example** (Filtering and mapping values)
|
|
1649
1583
|
*
|
|
1650
|
-
* ```ts
|
|
1584
|
+
* ```ts import.meta.vitest
|
|
1651
1585
|
* import { Chunk, Result } from "effect"
|
|
1652
1586
|
*
|
|
1653
1587
|
* const chunk = Chunk.make("1", "2", "hello", "3", "world")
|
|
@@ -1655,14 +1589,14 @@ export const filterMap: {
|
|
|
1655
1589
|
* const num = parseInt(str)
|
|
1656
1590
|
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
1657
1591
|
* })
|
|
1658
|
-
*
|
|
1592
|
+
* Chunk.toArray(numbers) // => [1, 2, 3]
|
|
1659
1593
|
*
|
|
1660
1594
|
* // With index parameter
|
|
1661
1595
|
* const evenIndexNumbers = Chunk.filterMap(chunk, (str, i) => {
|
|
1662
1596
|
* const num = parseInt(str)
|
|
1663
1597
|
* return isNaN(num) || i % 2 !== 0 ? Result.failVoid : Result.succeed(num)
|
|
1664
1598
|
* })
|
|
1665
|
-
*
|
|
1599
|
+
* Chunk.toArray(evenIndexNumbers) // => [1]
|
|
1666
1600
|
* ```
|
|
1667
1601
|
*
|
|
1668
1602
|
* @category filtering
|
|
@@ -1689,17 +1623,17 @@ export const filterMap: {
|
|
|
1689
1623
|
*
|
|
1690
1624
|
* **Example** (Filtering values)
|
|
1691
1625
|
*
|
|
1692
|
-
* ```ts
|
|
1626
|
+
* ```ts import.meta.vitest
|
|
1693
1627
|
* import { Chunk } from "effect"
|
|
1694
1628
|
*
|
|
1695
1629
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
1696
1630
|
* const evenNumbers = Chunk.filter(chunk, (n) => n % 2 === 0)
|
|
1697
|
-
*
|
|
1631
|
+
* Chunk.toArray(evenNumbers) // => [2, 4, 6]
|
|
1698
1632
|
*
|
|
1699
1633
|
* // With refinement
|
|
1700
1634
|
* const mixed = Chunk.make("hello", 42, "world", 100)
|
|
1701
1635
|
* const numbers = Chunk.filter(mixed, (x): x is number => typeof x === "number")
|
|
1702
|
-
*
|
|
1636
|
+
* Chunk.toArray(numbers) // => [42, 100]
|
|
1703
1637
|
* ```
|
|
1704
1638
|
*
|
|
1705
1639
|
* @category filtering
|
|
@@ -1711,17 +1645,17 @@ export const filter: {
|
|
|
1711
1645
|
*
|
|
1712
1646
|
* **Example** (Filtering values)
|
|
1713
1647
|
*
|
|
1714
|
-
* ```ts
|
|
1648
|
+
* ```ts import.meta.vitest
|
|
1715
1649
|
* import { Chunk } from "effect"
|
|
1716
1650
|
*
|
|
1717
1651
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
1718
1652
|
* const evenNumbers = Chunk.filter(chunk, (n) => n % 2 === 0)
|
|
1719
|
-
*
|
|
1653
|
+
* Chunk.toArray(evenNumbers) // => [2, 4, 6]
|
|
1720
1654
|
*
|
|
1721
1655
|
* // With refinement
|
|
1722
1656
|
* const mixed = Chunk.make("hello", 42, "world", 100)
|
|
1723
1657
|
* const numbers = Chunk.filter(mixed, (x): x is number => typeof x === "number")
|
|
1724
|
-
*
|
|
1658
|
+
* Chunk.toArray(numbers) // => [42, 100]
|
|
1725
1659
|
* ```
|
|
1726
1660
|
*
|
|
1727
1661
|
* @category filtering
|
|
@@ -1733,17 +1667,17 @@ export const filter: {
|
|
|
1733
1667
|
*
|
|
1734
1668
|
* **Example** (Filtering values)
|
|
1735
1669
|
*
|
|
1736
|
-
* ```ts
|
|
1670
|
+
* ```ts import.meta.vitest
|
|
1737
1671
|
* import { Chunk } from "effect"
|
|
1738
1672
|
*
|
|
1739
1673
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
1740
1674
|
* const evenNumbers = Chunk.filter(chunk, (n) => n % 2 === 0)
|
|
1741
|
-
*
|
|
1675
|
+
* Chunk.toArray(evenNumbers) // => [2, 4, 6]
|
|
1742
1676
|
*
|
|
1743
1677
|
* // With refinement
|
|
1744
1678
|
* const mixed = Chunk.make("hello", 42, "world", 100)
|
|
1745
1679
|
* const numbers = Chunk.filter(mixed, (x): x is number => typeof x === "number")
|
|
1746
|
-
*
|
|
1680
|
+
* Chunk.toArray(numbers) // => [42, 100]
|
|
1747
1681
|
* ```
|
|
1748
1682
|
*
|
|
1749
1683
|
* @category filtering
|
|
@@ -1755,17 +1689,17 @@ export const filter: {
|
|
|
1755
1689
|
*
|
|
1756
1690
|
* **Example** (Filtering values)
|
|
1757
1691
|
*
|
|
1758
|
-
* ```ts
|
|
1692
|
+
* ```ts import.meta.vitest
|
|
1759
1693
|
* import { Chunk } from "effect"
|
|
1760
1694
|
*
|
|
1761
1695
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
1762
1696
|
* const evenNumbers = Chunk.filter(chunk, (n) => n % 2 === 0)
|
|
1763
|
-
*
|
|
1697
|
+
* Chunk.toArray(evenNumbers) // => [2, 4, 6]
|
|
1764
1698
|
*
|
|
1765
1699
|
* // With refinement
|
|
1766
1700
|
* const mixed = Chunk.make("hello", 42, "world", 100)
|
|
1767
1701
|
* const numbers = Chunk.filter(mixed, (x): x is number => typeof x === "number")
|
|
1768
|
-
*
|
|
1702
|
+
* Chunk.toArray(numbers) // => [42, 100]
|
|
1769
1703
|
* ```
|
|
1770
1704
|
*
|
|
1771
1705
|
* @category filtering
|
|
@@ -1777,17 +1711,17 @@ export const filter: {
|
|
|
1777
1711
|
*
|
|
1778
1712
|
* **Example** (Filtering values)
|
|
1779
1713
|
*
|
|
1780
|
-
* ```ts
|
|
1714
|
+
* ```ts import.meta.vitest
|
|
1781
1715
|
* import { Chunk } from "effect"
|
|
1782
1716
|
*
|
|
1783
1717
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
1784
1718
|
* const evenNumbers = Chunk.filter(chunk, (n) => n % 2 === 0)
|
|
1785
|
-
*
|
|
1719
|
+
* Chunk.toArray(evenNumbers) // => [2, 4, 6]
|
|
1786
1720
|
*
|
|
1787
1721
|
* // With refinement
|
|
1788
1722
|
* const mixed = Chunk.make("hello", 42, "world", 100)
|
|
1789
1723
|
* const numbers = Chunk.filter(mixed, (x): x is number => typeof x === "number")
|
|
1790
|
-
*
|
|
1724
|
+
* Chunk.toArray(numbers) // => [42, 100]
|
|
1791
1725
|
* ```
|
|
1792
1726
|
*
|
|
1793
1727
|
* @category filtering
|
|
@@ -1804,23 +1738,19 @@ export const filter: {
|
|
|
1804
1738
|
*
|
|
1805
1739
|
* **Example** (Filtering and mapping while values match)
|
|
1806
1740
|
*
|
|
1807
|
-
* ```ts
|
|
1741
|
+
* ```ts import.meta.vitest
|
|
1808
1742
|
* import { Chunk, Result } from "effect"
|
|
1809
1743
|
*
|
|
1810
1744
|
* const chunk = Chunk.make("1", "2", "hello", "3", "4")
|
|
1811
|
-
*
|
|
1812
|
-
* const
|
|
1813
|
-
* return isNaN(
|
|
1814
|
-
* })
|
|
1815
|
-
*
|
|
1816
|
-
*
|
|
1817
|
-
*
|
|
1818
|
-
*
|
|
1819
|
-
*
|
|
1820
|
-
* const num = parseInt(s)
|
|
1821
|
-
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
1822
|
-
* })
|
|
1823
|
-
* console.log(Chunk.toArray(allNumbers)) // [1, 2, 3, 4]
|
|
1745
|
+
* Chunk.toArray(Chunk.filterMapWhile(chunk, (s) => {
|
|
1746
|
+
* const n = Number(s)
|
|
1747
|
+
* return Number.isNaN(n) ? Result.failVoid : Result.succeed(n)
|
|
1748
|
+
* })) // => [1, 2]
|
|
1749
|
+
*
|
|
1750
|
+
* Chunk.toArray(Chunk.filterMap(chunk, (s) => {
|
|
1751
|
+
* const n = Number(s)
|
|
1752
|
+
* return Number.isNaN(n) ? Result.failVoid : Result.succeed(n)
|
|
1753
|
+
* })) // => [1, 2, 3, 4]
|
|
1824
1754
|
* ```
|
|
1825
1755
|
*
|
|
1826
1756
|
* @category filtering
|
|
@@ -1832,23 +1762,19 @@ export const filterMapWhile: {
|
|
|
1832
1762
|
*
|
|
1833
1763
|
* **Example** (Filtering and mapping while values match)
|
|
1834
1764
|
*
|
|
1835
|
-
* ```ts
|
|
1765
|
+
* ```ts import.meta.vitest
|
|
1836
1766
|
* import { Chunk, Result } from "effect"
|
|
1837
1767
|
*
|
|
1838
1768
|
* const chunk = Chunk.make("1", "2", "hello", "3", "4")
|
|
1839
|
-
*
|
|
1840
|
-
* const
|
|
1841
|
-
* return isNaN(
|
|
1842
|
-
* })
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1845
|
-
*
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
* const num = parseInt(s)
|
|
1849
|
-
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
1850
|
-
* })
|
|
1851
|
-
* console.log(Chunk.toArray(allNumbers)) // [1, 2, 3, 4]
|
|
1769
|
+
* Chunk.toArray(Chunk.filterMapWhile(chunk, (s) => {
|
|
1770
|
+
* const n = Number(s)
|
|
1771
|
+
* return Number.isNaN(n) ? Result.failVoid : Result.succeed(n)
|
|
1772
|
+
* })) // => [1, 2]
|
|
1773
|
+
*
|
|
1774
|
+
* Chunk.toArray(Chunk.filterMap(chunk, (s) => {
|
|
1775
|
+
* const n = Number(s)
|
|
1776
|
+
* return Number.isNaN(n) ? Result.failVoid : Result.succeed(n)
|
|
1777
|
+
* })) // => [1, 2, 3, 4]
|
|
1852
1778
|
* ```
|
|
1853
1779
|
*
|
|
1854
1780
|
* @category filtering
|
|
@@ -1860,23 +1786,19 @@ export const filterMapWhile: {
|
|
|
1860
1786
|
*
|
|
1861
1787
|
* **Example** (Filtering and mapping while values match)
|
|
1862
1788
|
*
|
|
1863
|
-
* ```ts
|
|
1789
|
+
* ```ts import.meta.vitest
|
|
1864
1790
|
* import { Chunk, Result } from "effect"
|
|
1865
1791
|
*
|
|
1866
1792
|
* const chunk = Chunk.make("1", "2", "hello", "3", "4")
|
|
1867
|
-
*
|
|
1868
|
-
* const
|
|
1869
|
-
* return isNaN(
|
|
1870
|
-
* })
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1874
|
-
*
|
|
1875
|
-
*
|
|
1876
|
-
* const num = parseInt(s)
|
|
1877
|
-
* return isNaN(num) ? Result.failVoid : Result.succeed(num)
|
|
1878
|
-
* })
|
|
1879
|
-
* console.log(Chunk.toArray(allNumbers)) // [1, 2, 3, 4]
|
|
1793
|
+
* Chunk.toArray(Chunk.filterMapWhile(chunk, (s) => {
|
|
1794
|
+
* const n = Number(s)
|
|
1795
|
+
* return Number.isNaN(n) ? Result.failVoid : Result.succeed(n)
|
|
1796
|
+
* })) // => [1, 2]
|
|
1797
|
+
*
|
|
1798
|
+
* Chunk.toArray(Chunk.filterMap(chunk, (s) => {
|
|
1799
|
+
* const n = Number(s)
|
|
1800
|
+
* return Number.isNaN(n) ? Result.failVoid : Result.succeed(n)
|
|
1801
|
+
* })) // => [1, 2, 3, 4]
|
|
1880
1802
|
* ```
|
|
1881
1803
|
*
|
|
1882
1804
|
* @category filtering
|
|
@@ -1901,12 +1823,11 @@ export const filterMapWhile: {
|
|
|
1901
1823
|
*
|
|
1902
1824
|
* **Example** (Compacting optional values)
|
|
1903
1825
|
*
|
|
1904
|
-
* ```ts
|
|
1826
|
+
* ```ts import.meta.vitest
|
|
1905
1827
|
* import { Chunk, Option } from "effect"
|
|
1906
1828
|
*
|
|
1907
1829
|
* const chunk = Chunk.make(Option.some(1), Option.none(), Option.some(3))
|
|
1908
|
-
*
|
|
1909
|
-
* console.log(Chunk.toArray(result)) // [1, 3]
|
|
1830
|
+
* Chunk.toArray(Chunk.compact(chunk)) // => [1, 3]
|
|
1910
1831
|
* ```
|
|
1911
1832
|
*
|
|
1912
1833
|
* @category filtering
|
|
@@ -1927,12 +1848,12 @@ export const compact = <A>(self: Chunk<Option<A>>): Chunk<A> => {
|
|
|
1927
1848
|
*
|
|
1928
1849
|
* **Example** (Flat mapping chunks)
|
|
1929
1850
|
*
|
|
1930
|
-
* ```ts
|
|
1851
|
+
* ```ts import.meta.vitest
|
|
1931
1852
|
* import { Chunk } from "effect"
|
|
1932
1853
|
*
|
|
1933
1854
|
* const chunk = Chunk.make(1, 2, 3)
|
|
1934
1855
|
* const duplicated = Chunk.flatMap(chunk, (n) => Chunk.make(n, n))
|
|
1935
|
-
*
|
|
1856
|
+
* Chunk.toArray(duplicated) // => [1, 1, 2, 2, 3, 3]
|
|
1936
1857
|
*
|
|
1937
1858
|
* // Flattening nested arrays
|
|
1938
1859
|
* const words = Chunk.make("hello", "world")
|
|
@@ -1940,11 +1861,11 @@ export const compact = <A>(self: Chunk<Option<A>>): Chunk<A> => {
|
|
|
1940
1861
|
* words,
|
|
1941
1862
|
* (word) => Chunk.fromIterable(word.split(""))
|
|
1942
1863
|
* )
|
|
1943
|
-
*
|
|
1864
|
+
* Chunk.toArray(letters).join("") // => "helloworld"
|
|
1944
1865
|
*
|
|
1945
1866
|
* // With index parameter
|
|
1946
1867
|
* const indexed = Chunk.flatMap(chunk, (n, i) => Chunk.make(n + i))
|
|
1947
|
-
*
|
|
1868
|
+
* Chunk.toArray(indexed) // => [1, 3, 5]
|
|
1948
1869
|
* ```
|
|
1949
1870
|
*
|
|
1950
1871
|
* @category sequencing
|
|
@@ -1956,12 +1877,12 @@ export const flatMap: {
|
|
|
1956
1877
|
*
|
|
1957
1878
|
* **Example** (Flat mapping chunks)
|
|
1958
1879
|
*
|
|
1959
|
-
* ```ts
|
|
1880
|
+
* ```ts import.meta.vitest
|
|
1960
1881
|
* import { Chunk } from "effect"
|
|
1961
1882
|
*
|
|
1962
1883
|
* const chunk = Chunk.make(1, 2, 3)
|
|
1963
1884
|
* const duplicated = Chunk.flatMap(chunk, (n) => Chunk.make(n, n))
|
|
1964
|
-
*
|
|
1885
|
+
* Chunk.toArray(duplicated) // => [1, 1, 2, 2, 3, 3]
|
|
1965
1886
|
*
|
|
1966
1887
|
* // Flattening nested arrays
|
|
1967
1888
|
* const words = Chunk.make("hello", "world")
|
|
@@ -1969,11 +1890,11 @@ export const flatMap: {
|
|
|
1969
1890
|
* words,
|
|
1970
1891
|
* (word) => Chunk.fromIterable(word.split(""))
|
|
1971
1892
|
* )
|
|
1972
|
-
*
|
|
1893
|
+
* Chunk.toArray(letters).join("") // => "helloworld"
|
|
1973
1894
|
*
|
|
1974
1895
|
* // With index parameter
|
|
1975
1896
|
* const indexed = Chunk.flatMap(chunk, (n, i) => Chunk.make(n + i))
|
|
1976
|
-
*
|
|
1897
|
+
* Chunk.toArray(indexed) // => [1, 3, 5]
|
|
1977
1898
|
* ```
|
|
1978
1899
|
*
|
|
1979
1900
|
* @category sequencing
|
|
@@ -1985,12 +1906,12 @@ export const flatMap: {
|
|
|
1985
1906
|
*
|
|
1986
1907
|
* **Example** (Flat mapping chunks)
|
|
1987
1908
|
*
|
|
1988
|
-
* ```ts
|
|
1909
|
+
* ```ts import.meta.vitest
|
|
1989
1910
|
* import { Chunk } from "effect"
|
|
1990
1911
|
*
|
|
1991
1912
|
* const chunk = Chunk.make(1, 2, 3)
|
|
1992
1913
|
* const duplicated = Chunk.flatMap(chunk, (n) => Chunk.make(n, n))
|
|
1993
|
-
*
|
|
1914
|
+
* Chunk.toArray(duplicated) // => [1, 1, 2, 2, 3, 3]
|
|
1994
1915
|
*
|
|
1995
1916
|
* // Flattening nested arrays
|
|
1996
1917
|
* const words = Chunk.make("hello", "world")
|
|
@@ -1998,11 +1919,11 @@ export const flatMap: {
|
|
|
1998
1919
|
* words,
|
|
1999
1920
|
* (word) => Chunk.fromIterable(word.split(""))
|
|
2000
1921
|
* )
|
|
2001
|
-
*
|
|
1922
|
+
* Chunk.toArray(letters).join("") // => "helloworld"
|
|
2002
1923
|
*
|
|
2003
1924
|
* // With index parameter
|
|
2004
1925
|
* const indexed = Chunk.flatMap(chunk, (n, i) => Chunk.make(n + i))
|
|
2005
|
-
*
|
|
1926
|
+
* Chunk.toArray(indexed) // => [1, 3, 5]
|
|
2006
1927
|
* ```
|
|
2007
1928
|
*
|
|
2008
1929
|
* @category sequencing
|
|
@@ -2014,12 +1935,12 @@ export const flatMap: {
|
|
|
2014
1935
|
*
|
|
2015
1936
|
* **Example** (Flat mapping chunks)
|
|
2016
1937
|
*
|
|
2017
|
-
* ```ts
|
|
1938
|
+
* ```ts import.meta.vitest
|
|
2018
1939
|
* import { Chunk } from "effect"
|
|
2019
1940
|
*
|
|
2020
1941
|
* const chunk = Chunk.make(1, 2, 3)
|
|
2021
1942
|
* const duplicated = Chunk.flatMap(chunk, (n) => Chunk.make(n, n))
|
|
2022
|
-
*
|
|
1943
|
+
* Chunk.toArray(duplicated) // => [1, 1, 2, 2, 3, 3]
|
|
2023
1944
|
*
|
|
2024
1945
|
* // Flattening nested arrays
|
|
2025
1946
|
* const words = Chunk.make("hello", "world")
|
|
@@ -2027,11 +1948,11 @@ export const flatMap: {
|
|
|
2027
1948
|
* words,
|
|
2028
1949
|
* (word) => Chunk.fromIterable(word.split(""))
|
|
2029
1950
|
* )
|
|
2030
|
-
*
|
|
1951
|
+
* Chunk.toArray(letters).join("") // => "helloworld"
|
|
2031
1952
|
*
|
|
2032
1953
|
* // With index parameter
|
|
2033
1954
|
* const indexed = Chunk.flatMap(chunk, (n, i) => Chunk.make(n + i))
|
|
2034
|
-
*
|
|
1955
|
+
* Chunk.toArray(indexed) // => [1, 3, 5]
|
|
2035
1956
|
* ```
|
|
2036
1957
|
*
|
|
2037
1958
|
* @category sequencing
|
|
@@ -2062,26 +1983,19 @@ export const flatMap: {
|
|
|
2062
1983
|
*
|
|
2063
1984
|
* **Example** (Iterating over chunk values)
|
|
2064
1985
|
*
|
|
2065
|
-
* ```ts
|
|
1986
|
+
* ```ts import.meta.vitest
|
|
2066
1987
|
* import { Chunk } from "effect"
|
|
2067
1988
|
*
|
|
2068
1989
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
2069
1990
|
*
|
|
2070
|
-
*
|
|
2071
|
-
* Chunk.forEach(chunk, (n) =>
|
|
2072
|
-
* //
|
|
2073
|
-
* // Value: 1
|
|
2074
|
-
* // Value: 2
|
|
2075
|
-
* // Value: 3
|
|
2076
|
-
* // Value: 4
|
|
1991
|
+
* const values: Array<string> = []
|
|
1992
|
+
* Chunk.forEach(chunk, (n) => values.push(`Value: ${n}`))
|
|
1993
|
+
* values // => ["Value: 1", "Value: 2", "Value: 3", "Value: 4"]
|
|
2077
1994
|
*
|
|
2078
1995
|
* // With index parameter
|
|
2079
|
-
*
|
|
2080
|
-
*
|
|
2081
|
-
* // Index 0: 1
|
|
2082
|
-
* // Index 1: 2
|
|
2083
|
-
* // Index 2: 3
|
|
2084
|
-
* // Index 3: 4
|
|
1996
|
+
* const indexed: Array<string> = []
|
|
1997
|
+
* Chunk.forEach(chunk, (n, i) => indexed.push(`Index ${i}: ${n}`))
|
|
1998
|
+
* indexed // => ["Index 0: 1", "Index 1: 2", "Index 2: 3", "Index 3: 4"]
|
|
2085
1999
|
* ```
|
|
2086
2000
|
*
|
|
2087
2001
|
* @category combinators
|
|
@@ -2100,26 +2014,19 @@ export const forEach: {
|
|
|
2100
2014
|
*
|
|
2101
2015
|
* **Example** (Iterating over chunk values)
|
|
2102
2016
|
*
|
|
2103
|
-
* ```ts
|
|
2017
|
+
* ```ts import.meta.vitest
|
|
2104
2018
|
* import { Chunk } from "effect"
|
|
2105
2019
|
*
|
|
2106
2020
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
2107
2021
|
*
|
|
2108
|
-
*
|
|
2109
|
-
* Chunk.forEach(chunk, (n) =>
|
|
2110
|
-
* //
|
|
2111
|
-
* // Value: 1
|
|
2112
|
-
* // Value: 2
|
|
2113
|
-
* // Value: 3
|
|
2114
|
-
* // Value: 4
|
|
2022
|
+
* const values: Array<string> = []
|
|
2023
|
+
* Chunk.forEach(chunk, (n) => values.push(`Value: ${n}`))
|
|
2024
|
+
* values // => ["Value: 1", "Value: 2", "Value: 3", "Value: 4"]
|
|
2115
2025
|
*
|
|
2116
2026
|
* // With index parameter
|
|
2117
|
-
*
|
|
2118
|
-
*
|
|
2119
|
-
* // Index 0: 1
|
|
2120
|
-
* // Index 1: 2
|
|
2121
|
-
* // Index 2: 3
|
|
2122
|
-
* // Index 3: 4
|
|
2027
|
+
* const indexed: Array<string> = []
|
|
2028
|
+
* Chunk.forEach(chunk, (n, i) => indexed.push(`Index ${i}: ${n}`))
|
|
2029
|
+
* indexed // => ["Index 0: 1", "Index 1: 2", "Index 2: 3", "Index 3: 4"]
|
|
2123
2030
|
* ```
|
|
2124
2031
|
*
|
|
2125
2032
|
* @category combinators
|
|
@@ -2138,26 +2045,19 @@ export const forEach: {
|
|
|
2138
2045
|
*
|
|
2139
2046
|
* **Example** (Iterating over chunk values)
|
|
2140
2047
|
*
|
|
2141
|
-
* ```ts
|
|
2048
|
+
* ```ts import.meta.vitest
|
|
2142
2049
|
* import { Chunk } from "effect"
|
|
2143
2050
|
*
|
|
2144
2051
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
2145
2052
|
*
|
|
2146
|
-
*
|
|
2147
|
-
* Chunk.forEach(chunk, (n) =>
|
|
2148
|
-
* //
|
|
2149
|
-
* // Value: 1
|
|
2150
|
-
* // Value: 2
|
|
2151
|
-
* // Value: 3
|
|
2152
|
-
* // Value: 4
|
|
2053
|
+
* const values: Array<string> = []
|
|
2054
|
+
* Chunk.forEach(chunk, (n) => values.push(`Value: ${n}`))
|
|
2055
|
+
* values // => ["Value: 1", "Value: 2", "Value: 3", "Value: 4"]
|
|
2153
2056
|
*
|
|
2154
2057
|
* // With index parameter
|
|
2155
|
-
*
|
|
2156
|
-
*
|
|
2157
|
-
* // Index 0: 1
|
|
2158
|
-
* // Index 1: 2
|
|
2159
|
-
* // Index 2: 3
|
|
2160
|
-
* // Index 3: 4
|
|
2058
|
+
* const indexed: Array<string> = []
|
|
2059
|
+
* Chunk.forEach(chunk, (n, i) => indexed.push(`Index ${i}: ${n}`))
|
|
2060
|
+
* indexed // => ["Index 0: 1", "Index 1: 2", "Index 2: 3", "Index 3: 4"]
|
|
2161
2061
|
* ```
|
|
2162
2062
|
*
|
|
2163
2063
|
* @category combinators
|
|
@@ -2171,7 +2071,7 @@ export const forEach: {
|
|
|
2171
2071
|
*
|
|
2172
2072
|
* **Example** (Flattening nested chunks)
|
|
2173
2073
|
*
|
|
2174
|
-
* ```ts
|
|
2074
|
+
* ```ts import.meta.vitest
|
|
2175
2075
|
* import { Chunk } from "effect"
|
|
2176
2076
|
*
|
|
2177
2077
|
* const nested = Chunk.make(
|
|
@@ -2179,8 +2079,7 @@ export const forEach: {
|
|
|
2179
2079
|
* Chunk.make(3, 4, 5),
|
|
2180
2080
|
* Chunk.make(6)
|
|
2181
2081
|
* )
|
|
2182
|
-
*
|
|
2183
|
-
* console.log(Chunk.toArray(flattened)) // [1, 2, 3, 4, 5, 6]
|
|
2082
|
+
* Chunk.toArray(Chunk.flatten(nested)) // => [1, 2, 3, 4, 5, 6]
|
|
2184
2083
|
*
|
|
2185
2084
|
* // With empty chunks
|
|
2186
2085
|
* const withEmpty = Chunk.make(
|
|
@@ -2188,7 +2087,7 @@ export const forEach: {
|
|
|
2188
2087
|
* Chunk.empty<number>(),
|
|
2189
2088
|
* Chunk.make(3, 4)
|
|
2190
2089
|
* )
|
|
2191
|
-
*
|
|
2090
|
+
* Chunk.toArray(Chunk.flatten(withEmpty)) // => [1, 2, 3, 4]
|
|
2192
2091
|
* ```
|
|
2193
2092
|
*
|
|
2194
2093
|
* @category sequencing
|
|
@@ -2215,25 +2114,23 @@ export const flatten: <S extends Chunk<Chunk<any>>>(self: S) => Chunk.Flatten<S>
|
|
|
2215
2114
|
*
|
|
2216
2115
|
* **Example** (Splitting into fixed-size chunks)
|
|
2217
2116
|
*
|
|
2218
|
-
* ```ts
|
|
2117
|
+
* ```ts import.meta.vitest
|
|
2219
2118
|
* import { Chunk } from "effect"
|
|
2220
2119
|
*
|
|
2221
2120
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
2222
2121
|
* const chunked = Chunk.chunksOf(chunk, 3)
|
|
2223
2122
|
*
|
|
2224
|
-
*
|
|
2225
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2123
|
+
* Chunk.toArray(chunked).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2226
2124
|
*
|
|
2227
2125
|
* // When length is not evenly divisible
|
|
2228
2126
|
* const chunk2 = Chunk.make(1, 2, 3, 4, 5)
|
|
2229
2127
|
* const chunked2 = Chunk.chunksOf(chunk2, 2)
|
|
2230
|
-
*
|
|
2231
|
-
* // [[1, 2], [3, 4], [5]]
|
|
2128
|
+
* Chunk.toArray(chunked2).map(Chunk.toArray) // => [[1, 2], [3, 4], [5]]
|
|
2232
2129
|
* ```
|
|
2233
2130
|
*
|
|
2234
2131
|
* @see {@link split} for splitting into a target number of chunks instead of a fixed chunk size
|
|
2235
2132
|
*
|
|
2236
|
-
* @category
|
|
2133
|
+
* @category splitting
|
|
2237
2134
|
* @since 2.0.0
|
|
2238
2135
|
*/
|
|
2239
2136
|
export const chunksOf: {
|
|
@@ -2256,25 +2153,23 @@ export const chunksOf: {
|
|
|
2256
2153
|
*
|
|
2257
2154
|
* **Example** (Splitting into fixed-size chunks)
|
|
2258
2155
|
*
|
|
2259
|
-
* ```ts
|
|
2156
|
+
* ```ts import.meta.vitest
|
|
2260
2157
|
* import { Chunk } from "effect"
|
|
2261
2158
|
*
|
|
2262
2159
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
2263
2160
|
* const chunked = Chunk.chunksOf(chunk, 3)
|
|
2264
2161
|
*
|
|
2265
|
-
*
|
|
2266
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2162
|
+
* Chunk.toArray(chunked).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2267
2163
|
*
|
|
2268
2164
|
* // When length is not evenly divisible
|
|
2269
2165
|
* const chunk2 = Chunk.make(1, 2, 3, 4, 5)
|
|
2270
2166
|
* const chunked2 = Chunk.chunksOf(chunk2, 2)
|
|
2271
|
-
*
|
|
2272
|
-
* // [[1, 2], [3, 4], [5]]
|
|
2167
|
+
* Chunk.toArray(chunked2).map(Chunk.toArray) // => [[1, 2], [3, 4], [5]]
|
|
2273
2168
|
* ```
|
|
2274
2169
|
*
|
|
2275
2170
|
* @see {@link split} for splitting into a target number of chunks instead of a fixed chunk size
|
|
2276
2171
|
*
|
|
2277
|
-
* @category
|
|
2172
|
+
* @category splitting
|
|
2278
2173
|
* @since 2.0.0
|
|
2279
2174
|
*/
|
|
2280
2175
|
(n: number): <A>(self: Chunk<A>) => Chunk<Chunk<A>>
|
|
@@ -2297,25 +2192,23 @@ export const chunksOf: {
|
|
|
2297
2192
|
*
|
|
2298
2193
|
* **Example** (Splitting into fixed-size chunks)
|
|
2299
2194
|
*
|
|
2300
|
-
* ```ts
|
|
2195
|
+
* ```ts import.meta.vitest
|
|
2301
2196
|
* import { Chunk } from "effect"
|
|
2302
2197
|
*
|
|
2303
2198
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
2304
2199
|
* const chunked = Chunk.chunksOf(chunk, 3)
|
|
2305
2200
|
*
|
|
2306
|
-
*
|
|
2307
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2201
|
+
* Chunk.toArray(chunked).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
2308
2202
|
*
|
|
2309
2203
|
* // When length is not evenly divisible
|
|
2310
2204
|
* const chunk2 = Chunk.make(1, 2, 3, 4, 5)
|
|
2311
2205
|
* const chunked2 = Chunk.chunksOf(chunk2, 2)
|
|
2312
|
-
*
|
|
2313
|
-
* // [[1, 2], [3, 4], [5]]
|
|
2206
|
+
* Chunk.toArray(chunked2).map(Chunk.toArray) // => [[1, 2], [3, 4], [5]]
|
|
2314
2207
|
* ```
|
|
2315
2208
|
*
|
|
2316
2209
|
* @see {@link split} for splitting into a target number of chunks instead of a fixed chunk size
|
|
2317
2210
|
*
|
|
2318
|
-
* @category
|
|
2211
|
+
* @category splitting
|
|
2319
2212
|
* @since 2.0.0
|
|
2320
2213
|
*/
|
|
2321
2214
|
<A>(self: Chunk<A>, n: number): Chunk<Chunk<A>>
|
|
@@ -2344,26 +2237,25 @@ export const chunksOf: {
|
|
|
2344
2237
|
*
|
|
2345
2238
|
* **Example** (Intersecting chunks)
|
|
2346
2239
|
*
|
|
2347
|
-
* ```ts
|
|
2240
|
+
* ```ts import.meta.vitest
|
|
2348
2241
|
* import { Chunk } from "effect"
|
|
2349
2242
|
*
|
|
2350
2243
|
* const chunk1 = Chunk.make(1, 2, 3, 4)
|
|
2351
2244
|
* const chunk2 = Chunk.make(3, 4, 5, 6)
|
|
2352
|
-
*
|
|
2353
|
-
* console.log(Chunk.toArray(result)) // [3, 4]
|
|
2245
|
+
* Chunk.toArray(Chunk.intersection(chunk1, chunk2)) // => [3, 4]
|
|
2354
2246
|
*
|
|
2355
2247
|
* // With strings
|
|
2356
2248
|
* const words1 = Chunk.make("hello", "world", "foo")
|
|
2357
2249
|
* const words2 = Chunk.make("world", "bar", "foo")
|
|
2358
|
-
*
|
|
2250
|
+
* Chunk.toArray(Chunk.intersection(words1, words2)) // => ["world", "foo"]
|
|
2359
2251
|
*
|
|
2360
2252
|
* // No intersection
|
|
2361
2253
|
* const chunk3 = Chunk.make(1, 2)
|
|
2362
2254
|
* const chunk4 = Chunk.make(3, 4)
|
|
2363
|
-
*
|
|
2255
|
+
* Chunk.toArray(Chunk.intersection(chunk3, chunk4)) // => []
|
|
2364
2256
|
* ```
|
|
2365
2257
|
*
|
|
2366
|
-
* @category
|
|
2258
|
+
* @category set operations
|
|
2367
2259
|
* @since 2.0.0
|
|
2368
2260
|
*/
|
|
2369
2261
|
export const intersection: {
|
|
@@ -2376,26 +2268,25 @@ export const intersection: {
|
|
|
2376
2268
|
*
|
|
2377
2269
|
* **Example** (Intersecting chunks)
|
|
2378
2270
|
*
|
|
2379
|
-
* ```ts
|
|
2271
|
+
* ```ts import.meta.vitest
|
|
2380
2272
|
* import { Chunk } from "effect"
|
|
2381
2273
|
*
|
|
2382
2274
|
* const chunk1 = Chunk.make(1, 2, 3, 4)
|
|
2383
2275
|
* const chunk2 = Chunk.make(3, 4, 5, 6)
|
|
2384
|
-
*
|
|
2385
|
-
* console.log(Chunk.toArray(result)) // [3, 4]
|
|
2276
|
+
* Chunk.toArray(Chunk.intersection(chunk1, chunk2)) // => [3, 4]
|
|
2386
2277
|
*
|
|
2387
2278
|
* // With strings
|
|
2388
2279
|
* const words1 = Chunk.make("hello", "world", "foo")
|
|
2389
2280
|
* const words2 = Chunk.make("world", "bar", "foo")
|
|
2390
|
-
*
|
|
2281
|
+
* Chunk.toArray(Chunk.intersection(words1, words2)) // => ["world", "foo"]
|
|
2391
2282
|
*
|
|
2392
2283
|
* // No intersection
|
|
2393
2284
|
* const chunk3 = Chunk.make(1, 2)
|
|
2394
2285
|
* const chunk4 = Chunk.make(3, 4)
|
|
2395
|
-
*
|
|
2286
|
+
* Chunk.toArray(Chunk.intersection(chunk3, chunk4)) // => []
|
|
2396
2287
|
* ```
|
|
2397
2288
|
*
|
|
2398
|
-
* @category
|
|
2289
|
+
* @category set operations
|
|
2399
2290
|
* @since 2.0.0
|
|
2400
2291
|
*/
|
|
2401
2292
|
<A>(that: Chunk<A>): <B>(self: Chunk<B>) => Chunk<A & B>
|
|
@@ -2408,26 +2299,25 @@ export const intersection: {
|
|
|
2408
2299
|
*
|
|
2409
2300
|
* **Example** (Intersecting chunks)
|
|
2410
2301
|
*
|
|
2411
|
-
* ```ts
|
|
2302
|
+
* ```ts import.meta.vitest
|
|
2412
2303
|
* import { Chunk } from "effect"
|
|
2413
2304
|
*
|
|
2414
2305
|
* const chunk1 = Chunk.make(1, 2, 3, 4)
|
|
2415
2306
|
* const chunk2 = Chunk.make(3, 4, 5, 6)
|
|
2416
|
-
*
|
|
2417
|
-
* console.log(Chunk.toArray(result)) // [3, 4]
|
|
2307
|
+
* Chunk.toArray(Chunk.intersection(chunk1, chunk2)) // => [3, 4]
|
|
2418
2308
|
*
|
|
2419
2309
|
* // With strings
|
|
2420
2310
|
* const words1 = Chunk.make("hello", "world", "foo")
|
|
2421
2311
|
* const words2 = Chunk.make("world", "bar", "foo")
|
|
2422
|
-
*
|
|
2312
|
+
* Chunk.toArray(Chunk.intersection(words1, words2)) // => ["world", "foo"]
|
|
2423
2313
|
*
|
|
2424
2314
|
* // No intersection
|
|
2425
2315
|
* const chunk3 = Chunk.make(1, 2)
|
|
2426
2316
|
* const chunk4 = Chunk.make(3, 4)
|
|
2427
|
-
*
|
|
2317
|
+
* Chunk.toArray(Chunk.intersection(chunk3, chunk4)) // => []
|
|
2428
2318
|
* ```
|
|
2429
2319
|
*
|
|
2430
|
-
* @category
|
|
2320
|
+
* @category set operations
|
|
2431
2321
|
* @since 2.0.0
|
|
2432
2322
|
*/
|
|
2433
2323
|
<A, B>(self: Chunk<A>, that: Chunk<B>): Chunk<A & B>
|
|
@@ -2442,14 +2332,14 @@ export const intersection: {
|
|
|
2442
2332
|
*
|
|
2443
2333
|
* **Example** (Checking for empty chunks)
|
|
2444
2334
|
*
|
|
2445
|
-
* ```ts
|
|
2335
|
+
* ```ts import.meta.vitest
|
|
2446
2336
|
* import { Chunk } from "effect"
|
|
2447
2337
|
*
|
|
2448
|
-
*
|
|
2449
|
-
*
|
|
2338
|
+
* Chunk.isEmpty(Chunk.empty()) // => true
|
|
2339
|
+
* Chunk.isEmpty(Chunk.make(1, 2, 3)) // => false
|
|
2450
2340
|
* ```
|
|
2451
2341
|
*
|
|
2452
|
-
* @category
|
|
2342
|
+
* @category predicates
|
|
2453
2343
|
* @since 2.0.0
|
|
2454
2344
|
*/
|
|
2455
2345
|
export const isEmpty = <A>(self: Chunk<A>): boolean => self.length === 0
|
|
@@ -2459,14 +2349,14 @@ export const isEmpty = <A>(self: Chunk<A>): boolean => self.length === 0
|
|
|
2459
2349
|
*
|
|
2460
2350
|
* **Example** (Checking for non-empty chunks)
|
|
2461
2351
|
*
|
|
2462
|
-
* ```ts
|
|
2352
|
+
* ```ts import.meta.vitest
|
|
2463
2353
|
* import { Chunk } from "effect"
|
|
2464
2354
|
*
|
|
2465
|
-
*
|
|
2466
|
-
*
|
|
2355
|
+
* Chunk.isNonEmpty(Chunk.empty()) // => false
|
|
2356
|
+
* Chunk.isNonEmpty(Chunk.make(1, 2, 3)) // => true
|
|
2467
2357
|
* ```
|
|
2468
2358
|
*
|
|
2469
|
-
* @category
|
|
2359
|
+
* @category guards
|
|
2470
2360
|
* @since 2.0.0
|
|
2471
2361
|
*/
|
|
2472
2362
|
export const isNonEmpty = <A>(self: Chunk<A>): self is NonEmptyChunk<A> => self.length > 0
|
|
@@ -2476,14 +2366,14 @@ export const isNonEmpty = <A>(self: Chunk<A>): self is NonEmptyChunk<A> => self.
|
|
|
2476
2366
|
*
|
|
2477
2367
|
* **Example** (Getting the first element)
|
|
2478
2368
|
*
|
|
2479
|
-
* ```ts
|
|
2480
|
-
* import { Chunk } from "effect"
|
|
2369
|
+
* ```ts import.meta.vitest
|
|
2370
|
+
* import { Chunk, Option } from "effect"
|
|
2481
2371
|
*
|
|
2482
|
-
*
|
|
2483
|
-
*
|
|
2372
|
+
* Chunk.head(Chunk.empty()) // => Option.none()
|
|
2373
|
+
* Chunk.head(Chunk.make(1, 2, 3)) // => Option.some(1)
|
|
2484
2374
|
* ```
|
|
2485
2375
|
*
|
|
2486
|
-
* @category
|
|
2376
|
+
* @category getters
|
|
2487
2377
|
* @since 2.0.0
|
|
2488
2378
|
*/
|
|
2489
2379
|
export const head: <A>(self: Chunk<A>) => Option<A> = get(0)
|
|
@@ -2502,17 +2392,17 @@ export const head: <A>(self: Chunk<A>) => Option<A> = get(0)
|
|
|
2502
2392
|
*
|
|
2503
2393
|
* **Example** (Getting the first element unsafely)
|
|
2504
2394
|
*
|
|
2505
|
-
* ```ts
|
|
2395
|
+
* ```ts import.meta.vitest
|
|
2506
2396
|
* import { Chunk, Option } from "effect"
|
|
2507
2397
|
*
|
|
2508
2398
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
2509
|
-
*
|
|
2399
|
+
* Chunk.headUnsafe(chunk) // => 1
|
|
2510
2400
|
*
|
|
2511
2401
|
* const singleElement = Chunk.make("hello")
|
|
2512
|
-
*
|
|
2402
|
+
* Chunk.headUnsafe(singleElement) // => "hello"
|
|
2513
2403
|
*
|
|
2514
2404
|
* // Use Chunk.head when the chunk may be empty
|
|
2515
|
-
*
|
|
2405
|
+
* Option.isNone(Chunk.head(Chunk.empty())) // => true
|
|
2516
2406
|
* ```
|
|
2517
2407
|
*
|
|
2518
2408
|
* @category unsafe
|
|
@@ -2525,20 +2415,20 @@ export const headUnsafe = <A>(self: Chunk<A>): A => getUnsafe(self, 0)
|
|
|
2525
2415
|
*
|
|
2526
2416
|
* **Example** (Getting the first element of a non-empty chunk)
|
|
2527
2417
|
*
|
|
2528
|
-
* ```ts
|
|
2418
|
+
* ```ts import.meta.vitest
|
|
2529
2419
|
* import { Chunk } from "effect"
|
|
2530
2420
|
*
|
|
2531
2421
|
* const nonEmptyChunk = Chunk.make(1, 2, 3, 4)
|
|
2532
|
-
*
|
|
2422
|
+
* Chunk.headNonEmpty(nonEmptyChunk) // => 1
|
|
2533
2423
|
*
|
|
2534
2424
|
* const singleElement = Chunk.make("hello")
|
|
2535
|
-
*
|
|
2425
|
+
* Chunk.headNonEmpty(singleElement) // => "hello"
|
|
2536
2426
|
*
|
|
2537
2427
|
* // Type safety: this function only accepts NonEmptyChunk
|
|
2538
2428
|
* // Chunk.headNonEmpty(Chunk.empty()) // TypeScript error
|
|
2539
2429
|
* ```
|
|
2540
2430
|
*
|
|
2541
|
-
* @category
|
|
2431
|
+
* @category getters
|
|
2542
2432
|
* @since 2.0.0
|
|
2543
2433
|
*/
|
|
2544
2434
|
export const headNonEmpty: <A>(self: NonEmptyChunk<A>) => A = headUnsafe
|
|
@@ -2548,14 +2438,14 @@ export const headNonEmpty: <A>(self: NonEmptyChunk<A>) => A = headUnsafe
|
|
|
2548
2438
|
*
|
|
2549
2439
|
* **Example** (Getting the last element)
|
|
2550
2440
|
*
|
|
2551
|
-
* ```ts
|
|
2552
|
-
* import { Chunk } from "effect"
|
|
2441
|
+
* ```ts import.meta.vitest
|
|
2442
|
+
* import { Chunk, Option } from "effect"
|
|
2553
2443
|
*
|
|
2554
|
-
*
|
|
2555
|
-
*
|
|
2444
|
+
* Chunk.last(Chunk.empty()) // => Option.none()
|
|
2445
|
+
* Chunk.last(Chunk.make(1, 2, 3)) // => Option.some(3)
|
|
2556
2446
|
* ```
|
|
2557
2447
|
*
|
|
2558
|
-
* @category
|
|
2448
|
+
* @category getters
|
|
2559
2449
|
* @since 2.0.0
|
|
2560
2450
|
*/
|
|
2561
2451
|
export const last = <A>(self: Chunk<A>): Option<A> => get(self, self.length - 1)
|
|
@@ -2574,17 +2464,17 @@ export const last = <A>(self: Chunk<A>): Option<A> => get(self, self.length - 1)
|
|
|
2574
2464
|
*
|
|
2575
2465
|
* **Example** (Getting the last element unsafely)
|
|
2576
2466
|
*
|
|
2577
|
-
* ```ts
|
|
2467
|
+
* ```ts import.meta.vitest
|
|
2578
2468
|
* import { Chunk, Option } from "effect"
|
|
2579
2469
|
*
|
|
2580
2470
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
2581
|
-
*
|
|
2471
|
+
* Chunk.lastUnsafe(chunk) // => 4
|
|
2582
2472
|
*
|
|
2583
2473
|
* const singleElement = Chunk.make("hello")
|
|
2584
|
-
*
|
|
2474
|
+
* Chunk.lastUnsafe(singleElement) // => "hello"
|
|
2585
2475
|
*
|
|
2586
2476
|
* // Use Chunk.last when the chunk may be empty
|
|
2587
|
-
*
|
|
2477
|
+
* Option.isNone(Chunk.last(Chunk.empty())) // => true
|
|
2588
2478
|
* ```
|
|
2589
2479
|
*
|
|
2590
2480
|
* @category unsafe
|
|
@@ -2597,20 +2487,20 @@ export const lastUnsafe = <A>(self: Chunk<A>): A => getUnsafe(self, self.length
|
|
|
2597
2487
|
*
|
|
2598
2488
|
* **Example** (Getting the last element of a non-empty chunk)
|
|
2599
2489
|
*
|
|
2600
|
-
* ```ts
|
|
2490
|
+
* ```ts import.meta.vitest
|
|
2601
2491
|
* import { Chunk } from "effect"
|
|
2602
2492
|
*
|
|
2603
2493
|
* const nonEmptyChunk = Chunk.make(1, 2, 3, 4)
|
|
2604
|
-
*
|
|
2494
|
+
* Chunk.lastNonEmpty(nonEmptyChunk) // => 4
|
|
2605
2495
|
*
|
|
2606
2496
|
* const singleElement = Chunk.make("hello")
|
|
2607
|
-
*
|
|
2497
|
+
* Chunk.lastNonEmpty(singleElement) // => "hello"
|
|
2608
2498
|
*
|
|
2609
2499
|
* // Type safety: this function only accepts NonEmptyChunk
|
|
2610
2500
|
* // Chunk.lastNonEmpty(Chunk.empty()) // TypeScript error
|
|
2611
2501
|
* ```
|
|
2612
2502
|
*
|
|
2613
|
-
* @category
|
|
2503
|
+
* @category getters
|
|
2614
2504
|
* @since 3.4.0
|
|
2615
2505
|
*/
|
|
2616
2506
|
export const lastNonEmpty: <A>(self: NonEmptyChunk<A>) => A = lastUnsafe
|
|
@@ -2620,7 +2510,7 @@ export const lastNonEmpty: <A>(self: NonEmptyChunk<A>) => A = lastUnsafe
|
|
|
2620
2510
|
*
|
|
2621
2511
|
* **Example** (Working with Chunk utility types)
|
|
2622
2512
|
*
|
|
2623
|
-
* ```ts
|
|
2513
|
+
* ```ts import.meta.vitest
|
|
2624
2514
|
* import type { Chunk } from "effect"
|
|
2625
2515
|
*
|
|
2626
2516
|
* // Extract the element type from a Chunk
|
|
@@ -2640,7 +2530,7 @@ export declare namespace Chunk {
|
|
|
2640
2530
|
*
|
|
2641
2531
|
* **Example** (Inferring element types)
|
|
2642
2532
|
*
|
|
2643
|
-
* ```ts
|
|
2533
|
+
* ```ts import.meta.vitest
|
|
2644
2534
|
* import type { Chunk } from "effect"
|
|
2645
2535
|
*
|
|
2646
2536
|
* declare const numberChunk: Chunk.Chunk<number>
|
|
@@ -2650,7 +2540,7 @@ export declare namespace Chunk {
|
|
|
2650
2540
|
* type StringType = Chunk.Chunk.Infer<typeof stringChunk> // string
|
|
2651
2541
|
* ```
|
|
2652
2542
|
*
|
|
2653
|
-
* @category types
|
|
2543
|
+
* @category utility types
|
|
2654
2544
|
* @since 2.0.0
|
|
2655
2545
|
*/
|
|
2656
2546
|
export type Infer<S extends Chunk<any>> = S extends Chunk<infer A> ? A : never
|
|
@@ -2660,7 +2550,7 @@ export declare namespace Chunk {
|
|
|
2660
2550
|
*
|
|
2661
2551
|
* **Example** (Preserving non-emptiness)
|
|
2662
2552
|
*
|
|
2663
|
-
* ```ts
|
|
2553
|
+
* ```ts import.meta.vitest
|
|
2664
2554
|
* import type { Chunk } from "effect"
|
|
2665
2555
|
*
|
|
2666
2556
|
* declare const regularChunk: Chunk.Chunk<number>
|
|
@@ -2670,7 +2560,7 @@ export declare namespace Chunk {
|
|
|
2670
2560
|
* type WithString2 = Chunk.Chunk.With<typeof nonEmptyChunk, string> // Chunk.NonEmptyChunk<string>
|
|
2671
2561
|
* ```
|
|
2672
2562
|
*
|
|
2673
|
-
* @category types
|
|
2563
|
+
* @category utility types
|
|
2674
2564
|
* @since 2.0.0
|
|
2675
2565
|
*/
|
|
2676
2566
|
export type With<S extends Chunk<any>, A> = S extends NonEmptyChunk<any> ? NonEmptyChunk<A> : Chunk<A>
|
|
@@ -2680,7 +2570,7 @@ export declare namespace Chunk {
|
|
|
2680
2570
|
*
|
|
2681
2571
|
* **Example** (Preserving non-emptiness from either input)
|
|
2682
2572
|
*
|
|
2683
|
-
* ```ts
|
|
2573
|
+
* ```ts import.meta.vitest
|
|
2684
2574
|
* import type { Chunk } from "effect"
|
|
2685
2575
|
*
|
|
2686
2576
|
* declare const emptyChunk: Chunk.Chunk<number>
|
|
@@ -2703,7 +2593,7 @@ export declare namespace Chunk {
|
|
|
2703
2593
|
* > // Chunk.NonEmptyChunk<string>
|
|
2704
2594
|
* ```
|
|
2705
2595
|
*
|
|
2706
|
-
* @category types
|
|
2596
|
+
* @category utility types
|
|
2707
2597
|
* @since 2.0.0
|
|
2708
2598
|
*/
|
|
2709
2599
|
export type OrNonEmpty<S extends Chunk<any>, T extends Chunk<any>, A> = S extends NonEmptyChunk<any> ?
|
|
@@ -2716,7 +2606,7 @@ export declare namespace Chunk {
|
|
|
2716
2606
|
*
|
|
2717
2607
|
* **Example** (Requiring non-emptiness from both inputs)
|
|
2718
2608
|
*
|
|
2719
|
-
* ```ts
|
|
2609
|
+
* ```ts import.meta.vitest
|
|
2720
2610
|
* import type { Chunk } from "effect"
|
|
2721
2611
|
*
|
|
2722
2612
|
* declare const emptyChunk: Chunk.Chunk<number>
|
|
@@ -2739,7 +2629,7 @@ export declare namespace Chunk {
|
|
|
2739
2629
|
* > // Chunk.NonEmptyChunk<string>
|
|
2740
2630
|
* ```
|
|
2741
2631
|
*
|
|
2742
|
-
* @category types
|
|
2632
|
+
* @category utility types
|
|
2743
2633
|
* @since 2.0.0
|
|
2744
2634
|
*/
|
|
2745
2635
|
export type AndNonEmpty<S extends Chunk<any>, T extends Chunk<any>, A> = S extends NonEmptyChunk<any> ?
|
|
@@ -2752,7 +2642,7 @@ export declare namespace Chunk {
|
|
|
2752
2642
|
*
|
|
2753
2643
|
* **Example** (Flattening nested chunk types)
|
|
2754
2644
|
*
|
|
2755
|
-
* ```ts
|
|
2645
|
+
* ```ts import.meta.vitest
|
|
2756
2646
|
* import type { Chunk } from "effect"
|
|
2757
2647
|
*
|
|
2758
2648
|
* declare const nestedChunk: Chunk.Chunk<Chunk.Chunk<number>>
|
|
@@ -2762,7 +2652,7 @@ export declare namespace Chunk {
|
|
|
2762
2652
|
* type Flattened2 = Chunk.Chunk.Flatten<typeof nestedNonEmpty> // Chunk.NonEmptyChunk<string>
|
|
2763
2653
|
* ```
|
|
2764
2654
|
*
|
|
2765
|
-
* @category types
|
|
2655
|
+
* @category utility types
|
|
2766
2656
|
* @since 2.0.0
|
|
2767
2657
|
*/
|
|
2768
2658
|
export type Flatten<T extends Chunk<Chunk<any>>> = T extends NonEmptyChunk<NonEmptyChunk<infer A>> ? NonEmptyChunk<A>
|
|
@@ -2776,12 +2666,10 @@ export declare namespace Chunk {
|
|
|
2776
2666
|
*
|
|
2777
2667
|
* **Example** (Mapping values)
|
|
2778
2668
|
*
|
|
2779
|
-
* ```ts
|
|
2669
|
+
* ```ts import.meta.vitest
|
|
2780
2670
|
* import { Chunk } from "effect"
|
|
2781
2671
|
*
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
2784
|
-
* console.log(Chunk.toArray(result)) // [2, 3]
|
|
2672
|
+
* Chunk.toArray(Chunk.map(Chunk.make(1, 2), (n) => n + 1)) // => [2, 3]
|
|
2785
2673
|
* ```
|
|
2786
2674
|
*
|
|
2787
2675
|
* @category mapping
|
|
@@ -2794,12 +2682,10 @@ export const map: {
|
|
|
2794
2682
|
*
|
|
2795
2683
|
* **Example** (Mapping values)
|
|
2796
2684
|
*
|
|
2797
|
-
* ```ts
|
|
2685
|
+
* ```ts import.meta.vitest
|
|
2798
2686
|
* import { Chunk } from "effect"
|
|
2799
2687
|
*
|
|
2800
|
-
*
|
|
2801
|
-
*
|
|
2802
|
-
* console.log(Chunk.toArray(result)) // [2, 3]
|
|
2688
|
+
* Chunk.toArray(Chunk.map(Chunk.make(1, 2), (n) => n + 1)) // => [2, 3]
|
|
2803
2689
|
* ```
|
|
2804
2690
|
*
|
|
2805
2691
|
* @category mapping
|
|
@@ -2812,12 +2698,10 @@ export const map: {
|
|
|
2812
2698
|
*
|
|
2813
2699
|
* **Example** (Mapping values)
|
|
2814
2700
|
*
|
|
2815
|
-
* ```ts
|
|
2701
|
+
* ```ts import.meta.vitest
|
|
2816
2702
|
* import { Chunk } from "effect"
|
|
2817
2703
|
*
|
|
2818
|
-
*
|
|
2819
|
-
*
|
|
2820
|
-
* console.log(Chunk.toArray(result)) // [2, 3]
|
|
2704
|
+
* Chunk.toArray(Chunk.map(Chunk.make(1, 2), (n) => n + 1)) // => [2, 3]
|
|
2821
2705
|
* ```
|
|
2822
2706
|
*
|
|
2823
2707
|
* @category mapping
|
|
@@ -2830,12 +2714,10 @@ export const map: {
|
|
|
2830
2714
|
*
|
|
2831
2715
|
* **Example** (Mapping values)
|
|
2832
2716
|
*
|
|
2833
|
-
* ```ts
|
|
2717
|
+
* ```ts import.meta.vitest
|
|
2834
2718
|
* import { Chunk } from "effect"
|
|
2835
2719
|
*
|
|
2836
|
-
*
|
|
2837
|
-
*
|
|
2838
|
-
* console.log(Chunk.toArray(result)) // [2, 3]
|
|
2720
|
+
* Chunk.toArray(Chunk.map(Chunk.make(1, 2), (n) => n + 1)) // => [2, 3]
|
|
2839
2721
|
* ```
|
|
2840
2722
|
*
|
|
2841
2723
|
* @category mapping
|
|
@@ -2852,7 +2734,7 @@ export const map: {
|
|
|
2852
2734
|
*
|
|
2853
2735
|
* **Example** (Mapping with accumulated state)
|
|
2854
2736
|
*
|
|
2855
|
-
* ```ts
|
|
2737
|
+
* ```ts import.meta.vitest
|
|
2856
2738
|
* import { Chunk } from "effect"
|
|
2857
2739
|
*
|
|
2858
2740
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
@@ -2861,8 +2743,8 @@ export const map: {
|
|
|
2861
2743
|
* state + current // output running sum
|
|
2862
2744
|
* ])
|
|
2863
2745
|
*
|
|
2864
|
-
*
|
|
2865
|
-
*
|
|
2746
|
+
* finalState // => 15
|
|
2747
|
+
* Chunk.toArray(mapped) // => [1, 3, 6, 10, 15]
|
|
2866
2748
|
*
|
|
2867
2749
|
* // Building a string with indices
|
|
2868
2750
|
* const words = Chunk.make("hello", "world", "effect")
|
|
@@ -2870,8 +2752,8 @@ export const map: {
|
|
|
2870
2752
|
* index + 1,
|
|
2871
2753
|
* `${index}: ${word}`
|
|
2872
2754
|
* ])
|
|
2873
|
-
*
|
|
2874
|
-
*
|
|
2755
|
+
* count // => 3
|
|
2756
|
+
* Chunk.toArray(indexed) // => ["0: hello", "1: world", "2: effect"]
|
|
2875
2757
|
* ```
|
|
2876
2758
|
*
|
|
2877
2759
|
* @category folding
|
|
@@ -2883,7 +2765,7 @@ export const mapAccum: {
|
|
|
2883
2765
|
*
|
|
2884
2766
|
* **Example** (Mapping with accumulated state)
|
|
2885
2767
|
*
|
|
2886
|
-
* ```ts
|
|
2768
|
+
* ```ts import.meta.vitest
|
|
2887
2769
|
* import { Chunk } from "effect"
|
|
2888
2770
|
*
|
|
2889
2771
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
@@ -2892,8 +2774,8 @@ export const mapAccum: {
|
|
|
2892
2774
|
* state + current // output running sum
|
|
2893
2775
|
* ])
|
|
2894
2776
|
*
|
|
2895
|
-
*
|
|
2896
|
-
*
|
|
2777
|
+
* finalState // => 15
|
|
2778
|
+
* Chunk.toArray(mapped) // => [1, 3, 6, 10, 15]
|
|
2897
2779
|
*
|
|
2898
2780
|
* // Building a string with indices
|
|
2899
2781
|
* const words = Chunk.make("hello", "world", "effect")
|
|
@@ -2901,8 +2783,8 @@ export const mapAccum: {
|
|
|
2901
2783
|
* index + 1,
|
|
2902
2784
|
* `${index}: ${word}`
|
|
2903
2785
|
* ])
|
|
2904
|
-
*
|
|
2905
|
-
*
|
|
2786
|
+
* count // => 3
|
|
2787
|
+
* Chunk.toArray(indexed) // => ["0: hello", "1: world", "2: effect"]
|
|
2906
2788
|
* ```
|
|
2907
2789
|
*
|
|
2908
2790
|
* @category folding
|
|
@@ -2914,7 +2796,7 @@ export const mapAccum: {
|
|
|
2914
2796
|
*
|
|
2915
2797
|
* **Example** (Mapping with accumulated state)
|
|
2916
2798
|
*
|
|
2917
|
-
* ```ts
|
|
2799
|
+
* ```ts import.meta.vitest
|
|
2918
2800
|
* import { Chunk } from "effect"
|
|
2919
2801
|
*
|
|
2920
2802
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
@@ -2923,8 +2805,8 @@ export const mapAccum: {
|
|
|
2923
2805
|
* state + current // output running sum
|
|
2924
2806
|
* ])
|
|
2925
2807
|
*
|
|
2926
|
-
*
|
|
2927
|
-
*
|
|
2808
|
+
* finalState // => 15
|
|
2809
|
+
* Chunk.toArray(mapped) // => [1, 3, 6, 10, 15]
|
|
2928
2810
|
*
|
|
2929
2811
|
* // Building a string with indices
|
|
2930
2812
|
* const words = Chunk.make("hello", "world", "effect")
|
|
@@ -2932,8 +2814,8 @@ export const mapAccum: {
|
|
|
2932
2814
|
* index + 1,
|
|
2933
2815
|
* `${index}: ${word}`
|
|
2934
2816
|
* ])
|
|
2935
|
-
*
|
|
2936
|
-
*
|
|
2817
|
+
* count // => 3
|
|
2818
|
+
* Chunk.toArray(indexed) // => ["0: hello", "1: world", "2: effect"]
|
|
2937
2819
|
* ```
|
|
2938
2820
|
*
|
|
2939
2821
|
* @category folding
|
|
@@ -2954,15 +2836,15 @@ export const mapAccum: {
|
|
|
2954
2836
|
*
|
|
2955
2837
|
* **Example** (Partitioning with a Result)
|
|
2956
2838
|
*
|
|
2957
|
-
* ```ts
|
|
2839
|
+
* ```ts import.meta.vitest
|
|
2958
2840
|
* import { Chunk, Result } from "effect"
|
|
2959
2841
|
*
|
|
2960
2842
|
* const [excluded, satisfying] = Chunk.partition(Chunk.make(1, -2, 3), (n, i) =>
|
|
2961
2843
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
2962
2844
|
* )
|
|
2963
2845
|
*
|
|
2964
|
-
*
|
|
2965
|
-
*
|
|
2846
|
+
* Chunk.toArray(excluded) // => ["negative:-2"]
|
|
2847
|
+
* Chunk.toArray(satisfying) // => [1, 5]
|
|
2966
2848
|
* ```
|
|
2967
2849
|
*
|
|
2968
2850
|
* @category filtering
|
|
@@ -2978,15 +2860,15 @@ export const partition: {
|
|
|
2978
2860
|
*
|
|
2979
2861
|
* **Example** (Partitioning with a Result)
|
|
2980
2862
|
*
|
|
2981
|
-
* ```ts
|
|
2863
|
+
* ```ts import.meta.vitest
|
|
2982
2864
|
* import { Chunk, Result } from "effect"
|
|
2983
2865
|
*
|
|
2984
2866
|
* const [excluded, satisfying] = Chunk.partition(Chunk.make(1, -2, 3), (n, i) =>
|
|
2985
2867
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
2986
2868
|
* )
|
|
2987
2869
|
*
|
|
2988
|
-
*
|
|
2989
|
-
*
|
|
2870
|
+
* Chunk.toArray(excluded) // => ["negative:-2"]
|
|
2871
|
+
* Chunk.toArray(satisfying) // => [1, 5]
|
|
2990
2872
|
* ```
|
|
2991
2873
|
*
|
|
2992
2874
|
* @category filtering
|
|
@@ -3002,15 +2884,15 @@ export const partition: {
|
|
|
3002
2884
|
*
|
|
3003
2885
|
* **Example** (Partitioning with a Result)
|
|
3004
2886
|
*
|
|
3005
|
-
* ```ts
|
|
2887
|
+
* ```ts import.meta.vitest
|
|
3006
2888
|
* import { Chunk, Result } from "effect"
|
|
3007
2889
|
*
|
|
3008
2890
|
* const [excluded, satisfying] = Chunk.partition(Chunk.make(1, -2, 3), (n, i) =>
|
|
3009
2891
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
3010
2892
|
* )
|
|
3011
2893
|
*
|
|
3012
|
-
*
|
|
3013
|
-
*
|
|
2894
|
+
* Chunk.toArray(excluded) // => ["negative:-2"]
|
|
2895
|
+
* Chunk.toArray(satisfying) // => [1, 5]
|
|
3014
2896
|
* ```
|
|
3015
2897
|
*
|
|
3016
2898
|
* @category filtering
|
|
@@ -3039,7 +2921,7 @@ export const partition: {
|
|
|
3039
2921
|
*
|
|
3040
2922
|
* **Example** (Separating failures and successes)
|
|
3041
2923
|
*
|
|
3042
|
-
* ```ts
|
|
2924
|
+
* ```ts import.meta.vitest
|
|
3043
2925
|
* import { Chunk, Result } from "effect"
|
|
3044
2926
|
*
|
|
3045
2927
|
* const chunk = Chunk.make(
|
|
@@ -3051,14 +2933,14 @@ export const partition: {
|
|
|
3051
2933
|
* )
|
|
3052
2934
|
*
|
|
3053
2935
|
* const [errors, values] = Chunk.separate(chunk)
|
|
3054
|
-
*
|
|
3055
|
-
*
|
|
2936
|
+
* Chunk.toArray(errors) // => ["error1", "error2"]
|
|
2937
|
+
* Chunk.toArray(values) // => [1, 2, 3]
|
|
3056
2938
|
*
|
|
3057
2939
|
* // All successes
|
|
3058
2940
|
* const allSuccesses = Chunk.make(Result.succeed(1), Result.succeed(2))
|
|
3059
2941
|
* const [noErrors, allValues] = Chunk.separate(allSuccesses)
|
|
3060
|
-
*
|
|
3061
|
-
*
|
|
2942
|
+
* Chunk.toArray(noErrors) // => []
|
|
2943
|
+
* Chunk.toArray(allValues) // => [1, 2]
|
|
3062
2944
|
* ```
|
|
3063
2945
|
*
|
|
3064
2946
|
* @category filtering
|
|
@@ -3075,14 +2957,13 @@ export const separate = <A, B>(self: Chunk<Result<B, A>>): [Chunk<A>, Chunk<B>]
|
|
|
3075
2957
|
*
|
|
3076
2958
|
* **Example** (Getting chunk size)
|
|
3077
2959
|
*
|
|
3078
|
-
* ```ts
|
|
2960
|
+
* ```ts import.meta.vitest
|
|
3079
2961
|
* import { Chunk } from "effect"
|
|
3080
2962
|
*
|
|
3081
|
-
*
|
|
3082
|
-
* console.log(Chunk.size(chunk)) // 3
|
|
2963
|
+
* Chunk.size(Chunk.make(1, 2, 3)) // => 3
|
|
3083
2964
|
* ```
|
|
3084
2965
|
*
|
|
3085
|
-
* @category
|
|
2966
|
+
* @category getters
|
|
3086
2967
|
* @since 2.0.0
|
|
3087
2968
|
*/
|
|
3088
2969
|
export const size = <A>(self: Chunk<A>): number => self.length
|
|
@@ -3092,21 +2973,18 @@ export const size = <A>(self: Chunk<A>): number => self.length
|
|
|
3092
2973
|
*
|
|
3093
2974
|
* **Example** (Sorting chunks)
|
|
3094
2975
|
*
|
|
3095
|
-
* ```ts
|
|
2976
|
+
* ```ts import.meta.vitest
|
|
3096
2977
|
* import { Chunk, Order } from "effect"
|
|
3097
2978
|
*
|
|
3098
2979
|
* const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6)
|
|
3099
|
-
*
|
|
3100
|
-
* console.log(Chunk.toArray(sorted)) // [1, 1, 2, 3, 4, 5, 6, 9]
|
|
2980
|
+
* Chunk.toArray(Chunk.sort(numbers, Order.Number)) // => [1, 1, 2, 3, 4, 5, 6, 9]
|
|
3101
2981
|
*
|
|
3102
2982
|
* // Reverse order
|
|
3103
|
-
*
|
|
3104
|
-
* console.log(Chunk.toArray(reverseSorted)) // [9, 6, 5, 4, 3, 2, 1, 1]
|
|
2983
|
+
* Chunk.toArray(Chunk.sort(numbers, Order.flip(Order.Number))) // => [9, 6, 5, 4, 3, 2, 1, 1]
|
|
3105
2984
|
*
|
|
3106
2985
|
* // String sorting
|
|
3107
2986
|
* const words = Chunk.make("banana", "apple", "cherry")
|
|
3108
|
-
*
|
|
3109
|
-
* console.log(Chunk.toArray(sortedWords)) // ["apple", "banana", "cherry"]
|
|
2987
|
+
* Chunk.toArray(Chunk.sort(words, Order.String)) // => ["apple", "banana", "cherry"]
|
|
3110
2988
|
* ```
|
|
3111
2989
|
*
|
|
3112
2990
|
* @category sorting
|
|
@@ -3118,21 +2996,18 @@ export const sort: {
|
|
|
3118
2996
|
*
|
|
3119
2997
|
* **Example** (Sorting chunks)
|
|
3120
2998
|
*
|
|
3121
|
-
* ```ts
|
|
2999
|
+
* ```ts import.meta.vitest
|
|
3122
3000
|
* import { Chunk, Order } from "effect"
|
|
3123
3001
|
*
|
|
3124
3002
|
* const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6)
|
|
3125
|
-
*
|
|
3126
|
-
* console.log(Chunk.toArray(sorted)) // [1, 1, 2, 3, 4, 5, 6, 9]
|
|
3003
|
+
* Chunk.toArray(Chunk.sort(numbers, Order.Number)) // => [1, 1, 2, 3, 4, 5, 6, 9]
|
|
3127
3004
|
*
|
|
3128
3005
|
* // Reverse order
|
|
3129
|
-
*
|
|
3130
|
-
* console.log(Chunk.toArray(reverseSorted)) // [9, 6, 5, 4, 3, 2, 1, 1]
|
|
3006
|
+
* Chunk.toArray(Chunk.sort(numbers, Order.flip(Order.Number))) // => [9, 6, 5, 4, 3, 2, 1, 1]
|
|
3131
3007
|
*
|
|
3132
3008
|
* // String sorting
|
|
3133
3009
|
* const words = Chunk.make("banana", "apple", "cherry")
|
|
3134
|
-
*
|
|
3135
|
-
* console.log(Chunk.toArray(sortedWords)) // ["apple", "banana", "cherry"]
|
|
3010
|
+
* Chunk.toArray(Chunk.sort(words, Order.String)) // => ["apple", "banana", "cherry"]
|
|
3136
3011
|
* ```
|
|
3137
3012
|
*
|
|
3138
3013
|
* @category sorting
|
|
@@ -3144,21 +3019,18 @@ export const sort: {
|
|
|
3144
3019
|
*
|
|
3145
3020
|
* **Example** (Sorting chunks)
|
|
3146
3021
|
*
|
|
3147
|
-
* ```ts
|
|
3022
|
+
* ```ts import.meta.vitest
|
|
3148
3023
|
* import { Chunk, Order } from "effect"
|
|
3149
3024
|
*
|
|
3150
3025
|
* const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6)
|
|
3151
|
-
*
|
|
3152
|
-
* console.log(Chunk.toArray(sorted)) // [1, 1, 2, 3, 4, 5, 6, 9]
|
|
3026
|
+
* Chunk.toArray(Chunk.sort(numbers, Order.Number)) // => [1, 1, 2, 3, 4, 5, 6, 9]
|
|
3153
3027
|
*
|
|
3154
3028
|
* // Reverse order
|
|
3155
|
-
*
|
|
3156
|
-
* console.log(Chunk.toArray(reverseSorted)) // [9, 6, 5, 4, 3, 2, 1, 1]
|
|
3029
|
+
* Chunk.toArray(Chunk.sort(numbers, Order.flip(Order.Number))) // => [9, 6, 5, 4, 3, 2, 1, 1]
|
|
3157
3030
|
*
|
|
3158
3031
|
* // String sorting
|
|
3159
3032
|
* const words = Chunk.make("banana", "apple", "cherry")
|
|
3160
|
-
*
|
|
3161
|
-
* console.log(Chunk.toArray(sortedWords)) // ["apple", "banana", "cherry"]
|
|
3033
|
+
* Chunk.toArray(Chunk.sort(words, Order.String)) // => ["apple", "banana", "cherry"]
|
|
3162
3034
|
* ```
|
|
3163
3035
|
*
|
|
3164
3036
|
* @category sorting
|
|
@@ -3175,7 +3047,7 @@ export const sort: {
|
|
|
3175
3047
|
*
|
|
3176
3048
|
* **Example** (Sorting chunks by a derived value)
|
|
3177
3049
|
*
|
|
3178
|
-
* ```ts
|
|
3050
|
+
* ```ts import.meta.vitest
|
|
3179
3051
|
* import { Chunk, Order } from "effect"
|
|
3180
3052
|
*
|
|
3181
3053
|
* const people = Chunk.make(
|
|
@@ -3186,18 +3058,15 @@ export const sort: {
|
|
|
3186
3058
|
*
|
|
3187
3059
|
* // Sort by age
|
|
3188
3060
|
* const byAge = Chunk.sortWith(people, (person) => person.age, Order.Number)
|
|
3189
|
-
*
|
|
3190
|
-
* // [{ name: "Bob", age: 25 }, { name: "Alice", age: 30 }, { name: "Charlie", age: 35 }]
|
|
3061
|
+
* Chunk.toArray(byAge).map((person) => person.name) // => ["Bob", "Alice", "Charlie"]
|
|
3191
3062
|
*
|
|
3192
3063
|
* // Sort by name
|
|
3193
3064
|
* const byName = Chunk.sortWith(people, (person) => person.name, Order.String)
|
|
3194
|
-
*
|
|
3195
|
-
* // [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }, { name: "Charlie", age: 35 }]
|
|
3065
|
+
* Chunk.toArray(byName).map((person) => person.name) // => ["Alice", "Bob", "Charlie"]
|
|
3196
3066
|
*
|
|
3197
3067
|
* // Sort by string length
|
|
3198
3068
|
* const words = Chunk.make("a", "abc", "ab")
|
|
3199
|
-
*
|
|
3200
|
-
* console.log(Chunk.toArray(byLength)) // ["a", "ab", "abc"]
|
|
3069
|
+
* Chunk.toArray(Chunk.sortWith(words, (word) => word.length, Order.Number)) // => ["a", "ab", "abc"]
|
|
3201
3070
|
* ```
|
|
3202
3071
|
*
|
|
3203
3072
|
* @category sorting
|
|
@@ -3209,7 +3078,7 @@ export const sortWith: {
|
|
|
3209
3078
|
*
|
|
3210
3079
|
* **Example** (Sorting chunks by a derived value)
|
|
3211
3080
|
*
|
|
3212
|
-
* ```ts
|
|
3081
|
+
* ```ts import.meta.vitest
|
|
3213
3082
|
* import { Chunk, Order } from "effect"
|
|
3214
3083
|
*
|
|
3215
3084
|
* const people = Chunk.make(
|
|
@@ -3220,18 +3089,15 @@ export const sortWith: {
|
|
|
3220
3089
|
*
|
|
3221
3090
|
* // Sort by age
|
|
3222
3091
|
* const byAge = Chunk.sortWith(people, (person) => person.age, Order.Number)
|
|
3223
|
-
*
|
|
3224
|
-
* // [{ name: "Bob", age: 25 }, { name: "Alice", age: 30 }, { name: "Charlie", age: 35 }]
|
|
3092
|
+
* Chunk.toArray(byAge).map((person) => person.name) // => ["Bob", "Alice", "Charlie"]
|
|
3225
3093
|
*
|
|
3226
3094
|
* // Sort by name
|
|
3227
3095
|
* const byName = Chunk.sortWith(people, (person) => person.name, Order.String)
|
|
3228
|
-
*
|
|
3229
|
-
* // [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }, { name: "Charlie", age: 35 }]
|
|
3096
|
+
* Chunk.toArray(byName).map((person) => person.name) // => ["Alice", "Bob", "Charlie"]
|
|
3230
3097
|
*
|
|
3231
3098
|
* // Sort by string length
|
|
3232
3099
|
* const words = Chunk.make("a", "abc", "ab")
|
|
3233
|
-
*
|
|
3234
|
-
* console.log(Chunk.toArray(byLength)) // ["a", "ab", "abc"]
|
|
3100
|
+
* Chunk.toArray(Chunk.sortWith(words, (word) => word.length, Order.Number)) // => ["a", "ab", "abc"]
|
|
3235
3101
|
* ```
|
|
3236
3102
|
*
|
|
3237
3103
|
* @category sorting
|
|
@@ -3243,7 +3109,7 @@ export const sortWith: {
|
|
|
3243
3109
|
*
|
|
3244
3110
|
* **Example** (Sorting chunks by a derived value)
|
|
3245
3111
|
*
|
|
3246
|
-
* ```ts
|
|
3112
|
+
* ```ts import.meta.vitest
|
|
3247
3113
|
* import { Chunk, Order } from "effect"
|
|
3248
3114
|
*
|
|
3249
3115
|
* const people = Chunk.make(
|
|
@@ -3254,18 +3120,15 @@ export const sortWith: {
|
|
|
3254
3120
|
*
|
|
3255
3121
|
* // Sort by age
|
|
3256
3122
|
* const byAge = Chunk.sortWith(people, (person) => person.age, Order.Number)
|
|
3257
|
-
*
|
|
3258
|
-
* // [{ name: "Bob", age: 25 }, { name: "Alice", age: 30 }, { name: "Charlie", age: 35 }]
|
|
3123
|
+
* Chunk.toArray(byAge).map((person) => person.name) // => ["Bob", "Alice", "Charlie"]
|
|
3259
3124
|
*
|
|
3260
3125
|
* // Sort by name
|
|
3261
3126
|
* const byName = Chunk.sortWith(people, (person) => person.name, Order.String)
|
|
3262
|
-
*
|
|
3263
|
-
* // [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }, { name: "Charlie", age: 35 }]
|
|
3127
|
+
* Chunk.toArray(byName).map((person) => person.name) // => ["Alice", "Bob", "Charlie"]
|
|
3264
3128
|
*
|
|
3265
3129
|
* // Sort by string length
|
|
3266
3130
|
* const words = Chunk.make("a", "abc", "ab")
|
|
3267
|
-
*
|
|
3268
|
-
* console.log(Chunk.toArray(byLength)) // ["a", "ab", "abc"]
|
|
3131
|
+
* Chunk.toArray(Chunk.sortWith(words, (word) => word.length, Order.Number)) // => ["a", "ab", "abc"]
|
|
3269
3132
|
* ```
|
|
3270
3133
|
*
|
|
3271
3134
|
* @category sorting
|
|
@@ -3282,23 +3145,23 @@ export const sortWith: {
|
|
|
3282
3145
|
*
|
|
3283
3146
|
* **Example** (Splitting at an index)
|
|
3284
3147
|
*
|
|
3285
|
-
* ```ts
|
|
3148
|
+
* ```ts import.meta.vitest
|
|
3286
3149
|
* import { Chunk } from "effect"
|
|
3287
3150
|
*
|
|
3288
3151
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3289
3152
|
* const [before, after] = Chunk.splitAt(chunk, 3)
|
|
3290
|
-
*
|
|
3291
|
-
*
|
|
3153
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3154
|
+
* Chunk.toArray(after) // => [4, 5, 6]
|
|
3292
3155
|
*
|
|
3293
3156
|
* // Split at index 0
|
|
3294
3157
|
* const [empty, all] = Chunk.splitAt(chunk, 0)
|
|
3295
|
-
*
|
|
3296
|
-
*
|
|
3158
|
+
* Chunk.toArray(empty) // => []
|
|
3159
|
+
* Chunk.toArray(all) // => [1, 2, 3, 4, 5, 6]
|
|
3297
3160
|
*
|
|
3298
3161
|
* // Split beyond length
|
|
3299
3162
|
* const [allElements, empty2] = Chunk.splitAt(chunk, 10)
|
|
3300
|
-
*
|
|
3301
|
-
*
|
|
3163
|
+
* Chunk.toArray(allElements) // => [1, 2, 3, 4, 5, 6]
|
|
3164
|
+
* Chunk.toArray(empty2) // => []
|
|
3302
3165
|
* ```
|
|
3303
3166
|
*
|
|
3304
3167
|
* @category splitting
|
|
@@ -3310,23 +3173,23 @@ export const splitAt: {
|
|
|
3310
3173
|
*
|
|
3311
3174
|
* **Example** (Splitting at an index)
|
|
3312
3175
|
*
|
|
3313
|
-
* ```ts
|
|
3176
|
+
* ```ts import.meta.vitest
|
|
3314
3177
|
* import { Chunk } from "effect"
|
|
3315
3178
|
*
|
|
3316
3179
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3317
3180
|
* const [before, after] = Chunk.splitAt(chunk, 3)
|
|
3318
|
-
*
|
|
3319
|
-
*
|
|
3181
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3182
|
+
* Chunk.toArray(after) // => [4, 5, 6]
|
|
3320
3183
|
*
|
|
3321
3184
|
* // Split at index 0
|
|
3322
3185
|
* const [empty, all] = Chunk.splitAt(chunk, 0)
|
|
3323
|
-
*
|
|
3324
|
-
*
|
|
3186
|
+
* Chunk.toArray(empty) // => []
|
|
3187
|
+
* Chunk.toArray(all) // => [1, 2, 3, 4, 5, 6]
|
|
3325
3188
|
*
|
|
3326
3189
|
* // Split beyond length
|
|
3327
3190
|
* const [allElements, empty2] = Chunk.splitAt(chunk, 10)
|
|
3328
|
-
*
|
|
3329
|
-
*
|
|
3191
|
+
* Chunk.toArray(allElements) // => [1, 2, 3, 4, 5, 6]
|
|
3192
|
+
* Chunk.toArray(empty2) // => []
|
|
3330
3193
|
* ```
|
|
3331
3194
|
*
|
|
3332
3195
|
* @category splitting
|
|
@@ -3338,23 +3201,23 @@ export const splitAt: {
|
|
|
3338
3201
|
*
|
|
3339
3202
|
* **Example** (Splitting at an index)
|
|
3340
3203
|
*
|
|
3341
|
-
* ```ts
|
|
3204
|
+
* ```ts import.meta.vitest
|
|
3342
3205
|
* import { Chunk } from "effect"
|
|
3343
3206
|
*
|
|
3344
3207
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3345
3208
|
* const [before, after] = Chunk.splitAt(chunk, 3)
|
|
3346
|
-
*
|
|
3347
|
-
*
|
|
3209
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3210
|
+
* Chunk.toArray(after) // => [4, 5, 6]
|
|
3348
3211
|
*
|
|
3349
3212
|
* // Split at index 0
|
|
3350
3213
|
* const [empty, all] = Chunk.splitAt(chunk, 0)
|
|
3351
|
-
*
|
|
3352
|
-
*
|
|
3214
|
+
* Chunk.toArray(empty) // => []
|
|
3215
|
+
* Chunk.toArray(all) // => [1, 2, 3, 4, 5, 6]
|
|
3353
3216
|
*
|
|
3354
3217
|
* // Split beyond length
|
|
3355
3218
|
* const [allElements, empty2] = Chunk.splitAt(chunk, 10)
|
|
3356
|
-
*
|
|
3357
|
-
*
|
|
3219
|
+
* Chunk.toArray(allElements) // => [1, 2, 3, 4, 5, 6]
|
|
3220
|
+
* Chunk.toArray(empty2) // => []
|
|
3358
3221
|
* ```
|
|
3359
3222
|
*
|
|
3360
3223
|
* @category splitting
|
|
@@ -3375,18 +3238,18 @@ export const splitAt: {
|
|
|
3375
3238
|
*
|
|
3376
3239
|
* **Example** (Splitting non-empty chunks at an index)
|
|
3377
3240
|
*
|
|
3378
|
-
* ```ts
|
|
3241
|
+
* ```ts import.meta.vitest
|
|
3379
3242
|
* import { Chunk } from "effect"
|
|
3380
3243
|
*
|
|
3381
3244
|
* const nonEmptyChunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3382
3245
|
* const [before, after] = Chunk.splitNonEmptyAt(nonEmptyChunk, 3)
|
|
3383
|
-
*
|
|
3384
|
-
*
|
|
3246
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3247
|
+
* Chunk.toArray(after) // => [4, 5, 6]
|
|
3385
3248
|
*
|
|
3386
3249
|
* // Split at 1 (minimum)
|
|
3387
3250
|
* const [first, rest] = Chunk.splitNonEmptyAt(nonEmptyChunk, 1)
|
|
3388
|
-
*
|
|
3389
|
-
*
|
|
3251
|
+
* Chunk.toArray(first) // => [1]
|
|
3252
|
+
* Chunk.toArray(rest) // => [2, 3, 4, 5, 6]
|
|
3390
3253
|
*
|
|
3391
3254
|
* // The first part is guaranteed to be NonEmptyChunk
|
|
3392
3255
|
* // while the second part may be empty
|
|
@@ -3408,18 +3271,18 @@ export const splitNonEmptyAt: {
|
|
|
3408
3271
|
*
|
|
3409
3272
|
* **Example** (Splitting non-empty chunks at an index)
|
|
3410
3273
|
*
|
|
3411
|
-
* ```ts
|
|
3274
|
+
* ```ts import.meta.vitest
|
|
3412
3275
|
* import { Chunk } from "effect"
|
|
3413
3276
|
*
|
|
3414
3277
|
* const nonEmptyChunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3415
3278
|
* const [before, after] = Chunk.splitNonEmptyAt(nonEmptyChunk, 3)
|
|
3416
|
-
*
|
|
3417
|
-
*
|
|
3279
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3280
|
+
* Chunk.toArray(after) // => [4, 5, 6]
|
|
3418
3281
|
*
|
|
3419
3282
|
* // Split at 1 (minimum)
|
|
3420
3283
|
* const [first, rest] = Chunk.splitNonEmptyAt(nonEmptyChunk, 1)
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3284
|
+
* Chunk.toArray(first) // => [1]
|
|
3285
|
+
* Chunk.toArray(rest) // => [2, 3, 4, 5, 6]
|
|
3423
3286
|
*
|
|
3424
3287
|
* // The first part is guaranteed to be NonEmptyChunk
|
|
3425
3288
|
* // while the second part may be empty
|
|
@@ -3441,18 +3304,18 @@ export const splitNonEmptyAt: {
|
|
|
3441
3304
|
*
|
|
3442
3305
|
* **Example** (Splitting non-empty chunks at an index)
|
|
3443
3306
|
*
|
|
3444
|
-
* ```ts
|
|
3307
|
+
* ```ts import.meta.vitest
|
|
3445
3308
|
* import { Chunk } from "effect"
|
|
3446
3309
|
*
|
|
3447
3310
|
* const nonEmptyChunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3448
3311
|
* const [before, after] = Chunk.splitNonEmptyAt(nonEmptyChunk, 3)
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3312
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3313
|
+
* Chunk.toArray(after) // => [4, 5, 6]
|
|
3451
3314
|
*
|
|
3452
3315
|
* // Split at 1 (minimum)
|
|
3453
3316
|
* const [first, rest] = Chunk.splitNonEmptyAt(nonEmptyChunk, 1)
|
|
3454
|
-
*
|
|
3455
|
-
*
|
|
3317
|
+
* Chunk.toArray(first) // => [1]
|
|
3318
|
+
* Chunk.toArray(rest) // => [2, 3, 4, 5, 6]
|
|
3456
3319
|
*
|
|
3457
3320
|
* // The first part is guaranteed to be NonEmptyChunk
|
|
3458
3321
|
* // while the second part may be empty
|
|
@@ -3479,24 +3342,21 @@ export const splitNonEmptyAt: {
|
|
|
3479
3342
|
*
|
|
3480
3343
|
* **Example** (Splitting chunks into groups)
|
|
3481
3344
|
*
|
|
3482
|
-
* ```ts
|
|
3345
|
+
* ```ts import.meta.vitest
|
|
3483
3346
|
* import { Chunk } from "effect"
|
|
3484
3347
|
*
|
|
3485
3348
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
3486
3349
|
* const chunks = Chunk.split(chunk, 3)
|
|
3487
|
-
*
|
|
3488
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
3350
|
+
* Chunk.toArray(chunks).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
3489
3351
|
*
|
|
3490
3352
|
* // Uneven split
|
|
3491
3353
|
* const chunk2 = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8)
|
|
3492
3354
|
* const chunks2 = Chunk.split(chunk2, 3)
|
|
3493
|
-
*
|
|
3494
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
3355
|
+
* Chunk.toArray(chunks2).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
3495
3356
|
*
|
|
3496
3357
|
* // Split into 1 chunk
|
|
3497
3358
|
* const chunks3 = Chunk.split(chunk, 1)
|
|
3498
|
-
*
|
|
3499
|
-
* // [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
|
|
3359
|
+
* Chunk.toArray(chunks3).map(Chunk.toArray) // => [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
|
|
3500
3360
|
* ```
|
|
3501
3361
|
*
|
|
3502
3362
|
* @category splitting
|
|
@@ -3513,24 +3373,21 @@ export const split: {
|
|
|
3513
3373
|
*
|
|
3514
3374
|
* **Example** (Splitting chunks into groups)
|
|
3515
3375
|
*
|
|
3516
|
-
* ```ts
|
|
3376
|
+
* ```ts import.meta.vitest
|
|
3517
3377
|
* import { Chunk } from "effect"
|
|
3518
3378
|
*
|
|
3519
3379
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
3520
3380
|
* const chunks = Chunk.split(chunk, 3)
|
|
3521
|
-
*
|
|
3522
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
3381
|
+
* Chunk.toArray(chunks).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
3523
3382
|
*
|
|
3524
3383
|
* // Uneven split
|
|
3525
3384
|
* const chunk2 = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8)
|
|
3526
3385
|
* const chunks2 = Chunk.split(chunk2, 3)
|
|
3527
|
-
*
|
|
3528
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
3386
|
+
* Chunk.toArray(chunks2).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
3529
3387
|
*
|
|
3530
3388
|
* // Split into 1 chunk
|
|
3531
3389
|
* const chunks3 = Chunk.split(chunk, 1)
|
|
3532
|
-
*
|
|
3533
|
-
* // [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
|
|
3390
|
+
* Chunk.toArray(chunks3).map(Chunk.toArray) // => [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
|
|
3534
3391
|
* ```
|
|
3535
3392
|
*
|
|
3536
3393
|
* @category splitting
|
|
@@ -3547,24 +3404,21 @@ export const split: {
|
|
|
3547
3404
|
*
|
|
3548
3405
|
* **Example** (Splitting chunks into groups)
|
|
3549
3406
|
*
|
|
3550
|
-
* ```ts
|
|
3407
|
+
* ```ts import.meta.vitest
|
|
3551
3408
|
* import { Chunk } from "effect"
|
|
3552
3409
|
*
|
|
3553
3410
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
3554
3411
|
* const chunks = Chunk.split(chunk, 3)
|
|
3555
|
-
*
|
|
3556
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
3412
|
+
* Chunk.toArray(chunks).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
3557
3413
|
*
|
|
3558
3414
|
* // Uneven split
|
|
3559
3415
|
* const chunk2 = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8)
|
|
3560
3416
|
* const chunks2 = Chunk.split(chunk2, 3)
|
|
3561
|
-
*
|
|
3562
|
-
* // [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
3417
|
+
* Chunk.toArray(chunks2).map(Chunk.toArray) // => [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
3563
3418
|
*
|
|
3564
3419
|
* // Split into 1 chunk
|
|
3565
3420
|
* const chunks3 = Chunk.split(chunk, 1)
|
|
3566
|
-
*
|
|
3567
|
-
* // [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
|
|
3421
|
+
* Chunk.toArray(chunks3).map(Chunk.toArray) // => [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
|
|
3568
3422
|
* ```
|
|
3569
3423
|
*
|
|
3570
3424
|
* @category splitting
|
|
@@ -3579,23 +3433,23 @@ export const split: {
|
|
|
3579
3433
|
*
|
|
3580
3434
|
* **Example** (Splitting at a matching element)
|
|
3581
3435
|
*
|
|
3582
|
-
* ```ts
|
|
3436
|
+
* ```ts import.meta.vitest
|
|
3583
3437
|
* import { Chunk } from "effect"
|
|
3584
3438
|
*
|
|
3585
3439
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3586
3440
|
* const [before, fromMatch] = Chunk.splitWhere(chunk, (n) => n > 3)
|
|
3587
|
-
*
|
|
3588
|
-
*
|
|
3441
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3442
|
+
* Chunk.toArray(fromMatch) // => [4, 5, 6]
|
|
3589
3443
|
*
|
|
3590
3444
|
* // No match found
|
|
3591
3445
|
* const [all, empty] = Chunk.splitWhere(chunk, (n) => n > 10)
|
|
3592
|
-
*
|
|
3593
|
-
*
|
|
3446
|
+
* Chunk.toArray(all) // => [1, 2, 3, 4, 5, 6]
|
|
3447
|
+
* Chunk.toArray(empty) // => []
|
|
3594
3448
|
*
|
|
3595
3449
|
* // Match on first element
|
|
3596
3450
|
* const [emptyBefore, allFromFirst] = Chunk.splitWhere(chunk, (n) => n === 1)
|
|
3597
|
-
*
|
|
3598
|
-
*
|
|
3451
|
+
* Chunk.toArray(emptyBefore) // => []
|
|
3452
|
+
* Chunk.toArray(allFromFirst) // => [1, 2, 3, 4, 5, 6]
|
|
3599
3453
|
* ```
|
|
3600
3454
|
*
|
|
3601
3455
|
* @category splitting
|
|
@@ -3608,23 +3462,23 @@ export const splitWhere: {
|
|
|
3608
3462
|
*
|
|
3609
3463
|
* **Example** (Splitting at a matching element)
|
|
3610
3464
|
*
|
|
3611
|
-
* ```ts
|
|
3465
|
+
* ```ts import.meta.vitest
|
|
3612
3466
|
* import { Chunk } from "effect"
|
|
3613
3467
|
*
|
|
3614
3468
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3615
3469
|
* const [before, fromMatch] = Chunk.splitWhere(chunk, (n) => n > 3)
|
|
3616
|
-
*
|
|
3617
|
-
*
|
|
3470
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3471
|
+
* Chunk.toArray(fromMatch) // => [4, 5, 6]
|
|
3618
3472
|
*
|
|
3619
3473
|
* // No match found
|
|
3620
3474
|
* const [all, empty] = Chunk.splitWhere(chunk, (n) => n > 10)
|
|
3621
|
-
*
|
|
3622
|
-
*
|
|
3475
|
+
* Chunk.toArray(all) // => [1, 2, 3, 4, 5, 6]
|
|
3476
|
+
* Chunk.toArray(empty) // => []
|
|
3623
3477
|
*
|
|
3624
3478
|
* // Match on first element
|
|
3625
3479
|
* const [emptyBefore, allFromFirst] = Chunk.splitWhere(chunk, (n) => n === 1)
|
|
3626
|
-
*
|
|
3627
|
-
*
|
|
3480
|
+
* Chunk.toArray(emptyBefore) // => []
|
|
3481
|
+
* Chunk.toArray(allFromFirst) // => [1, 2, 3, 4, 5, 6]
|
|
3628
3482
|
* ```
|
|
3629
3483
|
*
|
|
3630
3484
|
* @category splitting
|
|
@@ -3637,23 +3491,23 @@ export const splitWhere: {
|
|
|
3637
3491
|
*
|
|
3638
3492
|
* **Example** (Splitting at a matching element)
|
|
3639
3493
|
*
|
|
3640
|
-
* ```ts
|
|
3494
|
+
* ```ts import.meta.vitest
|
|
3641
3495
|
* import { Chunk } from "effect"
|
|
3642
3496
|
*
|
|
3643
3497
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3644
3498
|
* const [before, fromMatch] = Chunk.splitWhere(chunk, (n) => n > 3)
|
|
3645
|
-
*
|
|
3646
|
-
*
|
|
3499
|
+
* Chunk.toArray(before) // => [1, 2, 3]
|
|
3500
|
+
* Chunk.toArray(fromMatch) // => [4, 5, 6]
|
|
3647
3501
|
*
|
|
3648
3502
|
* // No match found
|
|
3649
3503
|
* const [all, empty] = Chunk.splitWhere(chunk, (n) => n > 10)
|
|
3650
|
-
*
|
|
3651
|
-
*
|
|
3504
|
+
* Chunk.toArray(all) // => [1, 2, 3, 4, 5, 6]
|
|
3505
|
+
* Chunk.toArray(empty) // => []
|
|
3652
3506
|
*
|
|
3653
3507
|
* // Match on first element
|
|
3654
3508
|
* const [emptyBefore, allFromFirst] = Chunk.splitWhere(chunk, (n) => n === 1)
|
|
3655
|
-
*
|
|
3656
|
-
*
|
|
3509
|
+
* Chunk.toArray(emptyBefore) // => []
|
|
3510
|
+
* Chunk.toArray(allFromFirst) // => [1, 2, 3, 4, 5, 6]
|
|
3657
3511
|
* ```
|
|
3658
3512
|
*
|
|
3659
3513
|
* @category splitting
|
|
@@ -3677,20 +3531,19 @@ export const splitWhere: {
|
|
|
3677
3531
|
*
|
|
3678
3532
|
* **Example** (Getting the tail safely)
|
|
3679
3533
|
*
|
|
3680
|
-
* ```ts
|
|
3681
|
-
* import { Chunk } from "effect"
|
|
3534
|
+
* ```ts import.meta.vitest
|
|
3535
|
+
* import { Chunk, Option } from "effect"
|
|
3682
3536
|
*
|
|
3683
3537
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
3684
|
-
*
|
|
3538
|
+
* Chunk.tail(chunk) // => Option.some(Chunk.make(2, 3, 4))
|
|
3685
3539
|
*
|
|
3686
3540
|
* const singleElement = Chunk.make(1)
|
|
3687
|
-
*
|
|
3541
|
+
* Chunk.tail(singleElement) // => Option.some(Chunk.empty())
|
|
3688
3542
|
*
|
|
3689
|
-
*
|
|
3690
|
-
* console.log(Chunk.tail(empty)) // Option.none()
|
|
3543
|
+
* Chunk.tail(Chunk.empty<number>()) // => Option.none()
|
|
3691
3544
|
* ```
|
|
3692
3545
|
*
|
|
3693
|
-
* @category
|
|
3546
|
+
* @category getters
|
|
3694
3547
|
* @since 2.0.0
|
|
3695
3548
|
*/
|
|
3696
3549
|
export const tail = <A>(self: Chunk<A>): O.Option<Chunk<A>> => self.length > 0 ? O.some(drop(self, 1)) : O.none()
|
|
@@ -3700,22 +3553,20 @@ export const tail = <A>(self: Chunk<A>): O.Option<Chunk<A>> => self.length > 0 ?
|
|
|
3700
3553
|
*
|
|
3701
3554
|
* **Example** (Getting the tail of a non-empty chunk)
|
|
3702
3555
|
*
|
|
3703
|
-
* ```ts
|
|
3556
|
+
* ```ts import.meta.vitest
|
|
3704
3557
|
* import { Chunk } from "effect"
|
|
3705
3558
|
*
|
|
3706
3559
|
* const nonEmptyChunk = Chunk.make(1, 2, 3, 4)
|
|
3707
|
-
*
|
|
3708
|
-
* console.log(Chunk.toArray(result)) // [2, 3, 4]
|
|
3560
|
+
* Chunk.toArray(Chunk.tailNonEmpty(nonEmptyChunk)) // => [2, 3, 4]
|
|
3709
3561
|
*
|
|
3710
3562
|
* const singleElement = Chunk.make(1)
|
|
3711
|
-
*
|
|
3712
|
-
* console.log(Chunk.toArray(resultSingle)) // []
|
|
3563
|
+
* Chunk.toArray(Chunk.tailNonEmpty(singleElement)) // => []
|
|
3713
3564
|
*
|
|
3714
3565
|
* // Type safety: this function only accepts NonEmptyChunk
|
|
3715
3566
|
* // Chunk.tailNonEmpty(Chunk.empty()) // TypeScript error
|
|
3716
3567
|
* ```
|
|
3717
3568
|
*
|
|
3718
|
-
* @category
|
|
3569
|
+
* @category getters
|
|
3719
3570
|
* @since 2.0.0
|
|
3720
3571
|
*/
|
|
3721
3572
|
export const tailNonEmpty = <A>(self: NonEmptyChunk<A>): Chunk<A> => drop(self, 1)
|
|
@@ -3725,23 +3576,20 @@ export const tailNonEmpty = <A>(self: NonEmptyChunk<A>): Chunk<A> => drop(self,
|
|
|
3725
3576
|
*
|
|
3726
3577
|
* **Example** (Taking elements from the end)
|
|
3727
3578
|
*
|
|
3728
|
-
* ```ts
|
|
3579
|
+
* ```ts import.meta.vitest
|
|
3729
3580
|
* import { Chunk } from "effect"
|
|
3730
3581
|
*
|
|
3731
3582
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3732
|
-
*
|
|
3733
|
-
* console.log(Chunk.toArray(lastThree)) // [4, 5, 6]
|
|
3583
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 3)) // => [4, 5, 6]
|
|
3734
3584
|
*
|
|
3735
3585
|
* // Take more than available
|
|
3736
|
-
*
|
|
3737
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3, 4, 5, 6]
|
|
3586
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 10)) // => [1, 2, 3, 4, 5, 6]
|
|
3738
3587
|
*
|
|
3739
3588
|
* // Take zero
|
|
3740
|
-
*
|
|
3741
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3589
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 0)) // => []
|
|
3742
3590
|
* ```
|
|
3743
3591
|
*
|
|
3744
|
-
* @category
|
|
3592
|
+
* @category filtering
|
|
3745
3593
|
* @since 2.0.0
|
|
3746
3594
|
*/
|
|
3747
3595
|
export const takeRight: {
|
|
@@ -3750,23 +3598,20 @@ export const takeRight: {
|
|
|
3750
3598
|
*
|
|
3751
3599
|
* **Example** (Taking elements from the end)
|
|
3752
3600
|
*
|
|
3753
|
-
* ```ts
|
|
3601
|
+
* ```ts import.meta.vitest
|
|
3754
3602
|
* import { Chunk } from "effect"
|
|
3755
3603
|
*
|
|
3756
3604
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3757
|
-
*
|
|
3758
|
-
* console.log(Chunk.toArray(lastThree)) // [4, 5, 6]
|
|
3605
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 3)) // => [4, 5, 6]
|
|
3759
3606
|
*
|
|
3760
3607
|
* // Take more than available
|
|
3761
|
-
*
|
|
3762
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3, 4, 5, 6]
|
|
3608
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 10)) // => [1, 2, 3, 4, 5, 6]
|
|
3763
3609
|
*
|
|
3764
3610
|
* // Take zero
|
|
3765
|
-
*
|
|
3766
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3611
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 0)) // => []
|
|
3767
3612
|
* ```
|
|
3768
3613
|
*
|
|
3769
|
-
* @category
|
|
3614
|
+
* @category filtering
|
|
3770
3615
|
* @since 2.0.0
|
|
3771
3616
|
*/
|
|
3772
3617
|
(n: number): <A>(self: Chunk<A>) => Chunk<A>
|
|
@@ -3775,23 +3620,20 @@ export const takeRight: {
|
|
|
3775
3620
|
*
|
|
3776
3621
|
* **Example** (Taking elements from the end)
|
|
3777
3622
|
*
|
|
3778
|
-
* ```ts
|
|
3623
|
+
* ```ts import.meta.vitest
|
|
3779
3624
|
* import { Chunk } from "effect"
|
|
3780
3625
|
*
|
|
3781
3626
|
* const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
|
|
3782
|
-
*
|
|
3783
|
-
* console.log(Chunk.toArray(lastThree)) // [4, 5, 6]
|
|
3627
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 3)) // => [4, 5, 6]
|
|
3784
3628
|
*
|
|
3785
3629
|
* // Take more than available
|
|
3786
|
-
*
|
|
3787
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3, 4, 5, 6]
|
|
3630
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 10)) // => [1, 2, 3, 4, 5, 6]
|
|
3788
3631
|
*
|
|
3789
3632
|
* // Take zero
|
|
3790
|
-
*
|
|
3791
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3633
|
+
* Chunk.toArray(Chunk.takeRight(chunk, 0)) // => []
|
|
3792
3634
|
* ```
|
|
3793
3635
|
*
|
|
3794
|
-
* @category
|
|
3636
|
+
* @category filtering
|
|
3795
3637
|
* @since 2.0.0
|
|
3796
3638
|
*/
|
|
3797
3639
|
<A>(self: Chunk<A>, n: number): Chunk<A>
|
|
@@ -3802,24 +3644,21 @@ export const takeRight: {
|
|
|
3802
3644
|
*
|
|
3803
3645
|
* **Example** (Taking elements while a predicate matches)
|
|
3804
3646
|
*
|
|
3805
|
-
* ```ts
|
|
3647
|
+
* ```ts import.meta.vitest
|
|
3806
3648
|
* import { Chunk } from "effect"
|
|
3807
3649
|
*
|
|
3808
3650
|
* const chunk = Chunk.make(1, 2, 3, 4, 3, 2, 1)
|
|
3809
|
-
*
|
|
3810
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
3651
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n < 4)) // => [1, 2, 3]
|
|
3811
3652
|
*
|
|
3812
3653
|
* // Empty if first element doesn't match
|
|
3813
|
-
*
|
|
3814
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3654
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n > 5)) // => []
|
|
3815
3655
|
*
|
|
3816
3656
|
* // Takes all if all match
|
|
3817
3657
|
* const small = Chunk.make(1, 2, 3)
|
|
3818
|
-
*
|
|
3819
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3]
|
|
3658
|
+
* Chunk.toArray(Chunk.takeWhile(small, (n) => n < 10)) // => [1, 2, 3]
|
|
3820
3659
|
* ```
|
|
3821
3660
|
*
|
|
3822
|
-
* @category
|
|
3661
|
+
* @category filtering
|
|
3823
3662
|
* @since 2.0.0
|
|
3824
3663
|
*/
|
|
3825
3664
|
export const takeWhile: {
|
|
@@ -3828,24 +3667,21 @@ export const takeWhile: {
|
|
|
3828
3667
|
*
|
|
3829
3668
|
* **Example** (Taking elements while a predicate matches)
|
|
3830
3669
|
*
|
|
3831
|
-
* ```ts
|
|
3670
|
+
* ```ts import.meta.vitest
|
|
3832
3671
|
* import { Chunk } from "effect"
|
|
3833
3672
|
*
|
|
3834
3673
|
* const chunk = Chunk.make(1, 2, 3, 4, 3, 2, 1)
|
|
3835
|
-
*
|
|
3836
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
3674
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n < 4)) // => [1, 2, 3]
|
|
3837
3675
|
*
|
|
3838
3676
|
* // Empty if first element doesn't match
|
|
3839
|
-
*
|
|
3840
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3677
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n > 5)) // => []
|
|
3841
3678
|
*
|
|
3842
3679
|
* // Takes all if all match
|
|
3843
3680
|
* const small = Chunk.make(1, 2, 3)
|
|
3844
|
-
*
|
|
3845
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3]
|
|
3681
|
+
* Chunk.toArray(Chunk.takeWhile(small, (n) => n < 10)) // => [1, 2, 3]
|
|
3846
3682
|
* ```
|
|
3847
3683
|
*
|
|
3848
|
-
* @category
|
|
3684
|
+
* @category filtering
|
|
3849
3685
|
* @since 2.0.0
|
|
3850
3686
|
*/
|
|
3851
3687
|
<A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Chunk<A>) => Chunk<B>
|
|
@@ -3854,24 +3690,21 @@ export const takeWhile: {
|
|
|
3854
3690
|
*
|
|
3855
3691
|
* **Example** (Taking elements while a predicate matches)
|
|
3856
3692
|
*
|
|
3857
|
-
* ```ts
|
|
3693
|
+
* ```ts import.meta.vitest
|
|
3858
3694
|
* import { Chunk } from "effect"
|
|
3859
3695
|
*
|
|
3860
3696
|
* const chunk = Chunk.make(1, 2, 3, 4, 3, 2, 1)
|
|
3861
|
-
*
|
|
3862
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
3697
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n < 4)) // => [1, 2, 3]
|
|
3863
3698
|
*
|
|
3864
3699
|
* // Empty if first element doesn't match
|
|
3865
|
-
*
|
|
3866
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3700
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n > 5)) // => []
|
|
3867
3701
|
*
|
|
3868
3702
|
* // Takes all if all match
|
|
3869
3703
|
* const small = Chunk.make(1, 2, 3)
|
|
3870
|
-
*
|
|
3871
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3]
|
|
3704
|
+
* Chunk.toArray(Chunk.takeWhile(small, (n) => n < 10)) // => [1, 2, 3]
|
|
3872
3705
|
* ```
|
|
3873
3706
|
*
|
|
3874
|
-
* @category
|
|
3707
|
+
* @category filtering
|
|
3875
3708
|
* @since 2.0.0
|
|
3876
3709
|
*/
|
|
3877
3710
|
<A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => Chunk<A>
|
|
@@ -3880,24 +3713,21 @@ export const takeWhile: {
|
|
|
3880
3713
|
*
|
|
3881
3714
|
* **Example** (Taking elements while a predicate matches)
|
|
3882
3715
|
*
|
|
3883
|
-
* ```ts
|
|
3716
|
+
* ```ts import.meta.vitest
|
|
3884
3717
|
* import { Chunk } from "effect"
|
|
3885
3718
|
*
|
|
3886
3719
|
* const chunk = Chunk.make(1, 2, 3, 4, 3, 2, 1)
|
|
3887
|
-
*
|
|
3888
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
3720
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n < 4)) // => [1, 2, 3]
|
|
3889
3721
|
*
|
|
3890
3722
|
* // Empty if first element doesn't match
|
|
3891
|
-
*
|
|
3892
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3723
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n > 5)) // => []
|
|
3893
3724
|
*
|
|
3894
3725
|
* // Takes all if all match
|
|
3895
3726
|
* const small = Chunk.make(1, 2, 3)
|
|
3896
|
-
*
|
|
3897
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3]
|
|
3727
|
+
* Chunk.toArray(Chunk.takeWhile(small, (n) => n < 10)) // => [1, 2, 3]
|
|
3898
3728
|
* ```
|
|
3899
3729
|
*
|
|
3900
|
-
* @category
|
|
3730
|
+
* @category filtering
|
|
3901
3731
|
* @since 2.0.0
|
|
3902
3732
|
*/
|
|
3903
3733
|
<A, B extends A>(self: Chunk<A>, refinement: Refinement<A, B>): Chunk<B>
|
|
@@ -3906,24 +3736,21 @@ export const takeWhile: {
|
|
|
3906
3736
|
*
|
|
3907
3737
|
* **Example** (Taking elements while a predicate matches)
|
|
3908
3738
|
*
|
|
3909
|
-
* ```ts
|
|
3739
|
+
* ```ts import.meta.vitest
|
|
3910
3740
|
* import { Chunk } from "effect"
|
|
3911
3741
|
*
|
|
3912
3742
|
* const chunk = Chunk.make(1, 2, 3, 4, 3, 2, 1)
|
|
3913
|
-
*
|
|
3914
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3]
|
|
3743
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n < 4)) // => [1, 2, 3]
|
|
3915
3744
|
*
|
|
3916
3745
|
* // Empty if first element doesn't match
|
|
3917
|
-
*
|
|
3918
|
-
* console.log(Chunk.toArray(none)) // []
|
|
3746
|
+
* Chunk.toArray(Chunk.takeWhile(chunk, (n) => n > 5)) // => []
|
|
3919
3747
|
*
|
|
3920
3748
|
* // Takes all if all match
|
|
3921
3749
|
* const small = Chunk.make(1, 2, 3)
|
|
3922
|
-
*
|
|
3923
|
-
* console.log(Chunk.toArray(all)) // [1, 2, 3]
|
|
3750
|
+
* Chunk.toArray(Chunk.takeWhile(small, (n) => n < 10)) // => [1, 2, 3]
|
|
3924
3751
|
* ```
|
|
3925
3752
|
*
|
|
3926
|
-
* @category
|
|
3753
|
+
* @category filtering
|
|
3927
3754
|
* @since 2.0.0
|
|
3928
3755
|
*/
|
|
3929
3756
|
<A>(self: Chunk<A>, predicate: Predicate<A>): Chunk<A>
|
|
@@ -3944,22 +3771,20 @@ export const takeWhile: {
|
|
|
3944
3771
|
*
|
|
3945
3772
|
* **Example** (Unioning chunks)
|
|
3946
3773
|
*
|
|
3947
|
-
* ```ts
|
|
3774
|
+
* ```ts import.meta.vitest
|
|
3948
3775
|
* import { Chunk } from "effect"
|
|
3949
3776
|
*
|
|
3950
3777
|
* const chunk1 = Chunk.make(1, 2, 3)
|
|
3951
3778
|
* const chunk2 = Chunk.make(3, 4, 5)
|
|
3952
|
-
*
|
|
3953
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3, 4, 5]
|
|
3779
|
+
* Chunk.toArray(Chunk.union(chunk1, chunk2)) // => [1, 2, 3, 4, 5]
|
|
3954
3780
|
*
|
|
3955
3781
|
* // Handles duplicates within the same chunk
|
|
3956
3782
|
* const withDupes1 = Chunk.make(1, 1, 2)
|
|
3957
3783
|
* const withDupes2 = Chunk.make(2, 3, 3)
|
|
3958
|
-
*
|
|
3959
|
-
* console.log(Chunk.toArray(unified)) // [1, 2, 3]
|
|
3784
|
+
* Chunk.toArray(Chunk.union(withDupes1, withDupes2)) // => [1, 2, 3]
|
|
3960
3785
|
* ```
|
|
3961
3786
|
*
|
|
3962
|
-
* @category
|
|
3787
|
+
* @category set operations
|
|
3963
3788
|
* @since 2.0.0
|
|
3964
3789
|
*/
|
|
3965
3790
|
export const union: {
|
|
@@ -3968,22 +3793,20 @@ export const union: {
|
|
|
3968
3793
|
*
|
|
3969
3794
|
* **Example** (Unioning chunks)
|
|
3970
3795
|
*
|
|
3971
|
-
* ```ts
|
|
3796
|
+
* ```ts import.meta.vitest
|
|
3972
3797
|
* import { Chunk } from "effect"
|
|
3973
3798
|
*
|
|
3974
3799
|
* const chunk1 = Chunk.make(1, 2, 3)
|
|
3975
3800
|
* const chunk2 = Chunk.make(3, 4, 5)
|
|
3976
|
-
*
|
|
3977
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3, 4, 5]
|
|
3801
|
+
* Chunk.toArray(Chunk.union(chunk1, chunk2)) // => [1, 2, 3, 4, 5]
|
|
3978
3802
|
*
|
|
3979
3803
|
* // Handles duplicates within the same chunk
|
|
3980
3804
|
* const withDupes1 = Chunk.make(1, 1, 2)
|
|
3981
3805
|
* const withDupes2 = Chunk.make(2, 3, 3)
|
|
3982
|
-
*
|
|
3983
|
-
* console.log(Chunk.toArray(unified)) // [1, 2, 3]
|
|
3806
|
+
* Chunk.toArray(Chunk.union(withDupes1, withDupes2)) // => [1, 2, 3]
|
|
3984
3807
|
* ```
|
|
3985
3808
|
*
|
|
3986
|
-
* @category
|
|
3809
|
+
* @category set operations
|
|
3987
3810
|
* @since 2.0.0
|
|
3988
3811
|
*/
|
|
3989
3812
|
<A>(that: Chunk<A>): <B>(self: Chunk<B>) => Chunk<A | B>
|
|
@@ -3992,22 +3815,20 @@ export const union: {
|
|
|
3992
3815
|
*
|
|
3993
3816
|
* **Example** (Unioning chunks)
|
|
3994
3817
|
*
|
|
3995
|
-
* ```ts
|
|
3818
|
+
* ```ts import.meta.vitest
|
|
3996
3819
|
* import { Chunk } from "effect"
|
|
3997
3820
|
*
|
|
3998
3821
|
* const chunk1 = Chunk.make(1, 2, 3)
|
|
3999
3822
|
* const chunk2 = Chunk.make(3, 4, 5)
|
|
4000
|
-
*
|
|
4001
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3, 4, 5]
|
|
3823
|
+
* Chunk.toArray(Chunk.union(chunk1, chunk2)) // => [1, 2, 3, 4, 5]
|
|
4002
3824
|
*
|
|
4003
3825
|
* // Handles duplicates within the same chunk
|
|
4004
3826
|
* const withDupes1 = Chunk.make(1, 1, 2)
|
|
4005
3827
|
* const withDupes2 = Chunk.make(2, 3, 3)
|
|
4006
|
-
*
|
|
4007
|
-
* console.log(Chunk.toArray(unified)) // [1, 2, 3]
|
|
3828
|
+
* Chunk.toArray(Chunk.union(withDupes1, withDupes2)) // => [1, 2, 3]
|
|
4008
3829
|
* ```
|
|
4009
3830
|
*
|
|
4010
|
-
* @category
|
|
3831
|
+
* @category set operations
|
|
4011
3832
|
* @since 2.0.0
|
|
4012
3833
|
*/
|
|
4013
3834
|
<A, B>(self: Chunk<A>, that: Chunk<B>): Chunk<A | B>
|
|
@@ -4022,25 +3843,22 @@ export const union: {
|
|
|
4022
3843
|
*
|
|
4023
3844
|
* **Example** (Removing duplicate values)
|
|
4024
3845
|
*
|
|
4025
|
-
* ```ts
|
|
3846
|
+
* ```ts import.meta.vitest
|
|
4026
3847
|
* import { Chunk } from "effect"
|
|
4027
3848
|
*
|
|
4028
3849
|
* const chunk = Chunk.make(1, 2, 2, 3, 1, 4, 3)
|
|
4029
|
-
*
|
|
4030
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3, 4]
|
|
3850
|
+
* Chunk.toArray(Chunk.dedupe(chunk)) // => [1, 2, 3, 4]
|
|
4031
3851
|
*
|
|
4032
3852
|
* // Empty chunk
|
|
4033
3853
|
* const empty = Chunk.empty<number>()
|
|
4034
|
-
*
|
|
4035
|
-
* console.log(Chunk.toArray(emptyDeduped)) // []
|
|
3854
|
+
* Chunk.toArray(Chunk.dedupe(empty)) // => []
|
|
4036
3855
|
*
|
|
4037
3856
|
* // No duplicates
|
|
4038
3857
|
* const unique = Chunk.make(1, 2, 3)
|
|
4039
|
-
*
|
|
4040
|
-
* console.log(Chunk.toArray(uniqueDeduped)) // [1, 2, 3]
|
|
3858
|
+
* Chunk.toArray(Chunk.dedupe(unique)) // => [1, 2, 3]
|
|
4041
3859
|
* ```
|
|
4042
3860
|
*
|
|
4043
|
-
* @category
|
|
3861
|
+
* @category deduplication
|
|
4044
3862
|
* @since 2.0.0
|
|
4045
3863
|
*/
|
|
4046
3864
|
export const dedupe = <A>(self: Chunk<A>): Chunk<A> => fromArrayUnsafe(RA.dedupe(toReadonlyArray(self)))
|
|
@@ -4050,17 +3868,15 @@ export const dedupe = <A>(self: Chunk<A>): Chunk<A> => fromArrayUnsafe(RA.dedupe
|
|
|
4050
3868
|
*
|
|
4051
3869
|
* **Example** (Removing adjacent duplicates)
|
|
4052
3870
|
*
|
|
4053
|
-
* ```ts
|
|
3871
|
+
* ```ts import.meta.vitest
|
|
4054
3872
|
* import { Chunk } from "effect"
|
|
4055
3873
|
*
|
|
4056
3874
|
* const chunk = Chunk.make(1, 1, 2, 2, 2, 3, 1, 1)
|
|
4057
|
-
*
|
|
4058
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 3, 1]
|
|
3875
|
+
* Chunk.toArray(Chunk.dedupeAdjacent(chunk)) // => [1, 2, 3, 1]
|
|
4059
3876
|
*
|
|
4060
3877
|
* // Only removes adjacent duplicates, not all duplicates
|
|
4061
3878
|
* const mixed = Chunk.make("a", "a", "b", "a", "a")
|
|
4062
|
-
*
|
|
4063
|
-
* console.log(Chunk.toArray(mixedResult)) // ["a", "b", "a"]
|
|
3879
|
+
* Chunk.toArray(Chunk.dedupeAdjacent(mixed)) // => ["a", "b", "a"]
|
|
4064
3880
|
* ```
|
|
4065
3881
|
*
|
|
4066
3882
|
* @category filtering
|
|
@@ -4077,7 +3893,7 @@ export const dedupeAdjacent = <A>(self: Chunk<A>): Chunk<A> => fromArrayUnsafe(R
|
|
|
4077
3893
|
*
|
|
4078
3894
|
* **Example** (Unzipping pairs)
|
|
4079
3895
|
*
|
|
4080
|
-
* ```ts
|
|
3896
|
+
* ```ts import.meta.vitest
|
|
4081
3897
|
* import { Chunk } from "effect"
|
|
4082
3898
|
*
|
|
4083
3899
|
* const pairs = Chunk.make(
|
|
@@ -4086,17 +3902,17 @@ export const dedupeAdjacent = <A>(self: Chunk<A>): Chunk<A> => fromArrayUnsafe(R
|
|
|
4086
3902
|
* [3, "c"] as const
|
|
4087
3903
|
* )
|
|
4088
3904
|
* const [numbers, letters] = Chunk.unzip(pairs)
|
|
4089
|
-
*
|
|
4090
|
-
*
|
|
3905
|
+
* Chunk.toArray(numbers) // => [1, 2, 3]
|
|
3906
|
+
* Chunk.toArray(letters) // => ["a", "b", "c"]
|
|
4091
3907
|
*
|
|
4092
3908
|
* // Empty chunk
|
|
4093
3909
|
* const empty = Chunk.empty<[number, string]>()
|
|
4094
3910
|
* const [emptyNums, emptyStrs] = Chunk.unzip(empty)
|
|
4095
|
-
*
|
|
4096
|
-
*
|
|
3911
|
+
* Chunk.toArray(emptyNums) // => []
|
|
3912
|
+
* Chunk.toArray(emptyStrs) // => []
|
|
4097
3913
|
* ```
|
|
4098
3914
|
*
|
|
4099
|
-
* @category
|
|
3915
|
+
* @category splitting
|
|
4100
3916
|
* @since 2.0.0
|
|
4101
3917
|
*/
|
|
4102
3918
|
export const unzip = <A, B>(self: Chunk<readonly [A, B]>): [Chunk<A>, Chunk<B>] => {
|
|
@@ -4109,19 +3925,17 @@ export const unzip = <A, B>(self: Chunk<readonly [A, B]>): [Chunk<A>, Chunk<B>]
|
|
|
4109
3925
|
*
|
|
4110
3926
|
* **Example** (Zipping chunks with a function)
|
|
4111
3927
|
*
|
|
4112
|
-
* ```ts
|
|
3928
|
+
* ```ts import.meta.vitest
|
|
4113
3929
|
* import { Chunk } from "effect"
|
|
4114
3930
|
*
|
|
4115
3931
|
* const numbers = Chunk.make(1, 2, 3)
|
|
4116
3932
|
* const letters = Chunk.make("a", "b", "c")
|
|
4117
|
-
*
|
|
4118
|
-
* console.log(Chunk.toArray(result)) // ["1-a", "2-b", "3-c"]
|
|
3933
|
+
* Chunk.toArray(Chunk.zipWith(numbers, letters, (n, l) => `${n}-${l}`)) // => ["1-a", "2-b", "3-c"]
|
|
4119
3934
|
*
|
|
4120
3935
|
* // Different lengths - takes minimum
|
|
4121
3936
|
* const short = Chunk.make(1, 2)
|
|
4122
3937
|
* const long = Chunk.make("a", "b", "c", "d")
|
|
4123
|
-
*
|
|
4124
|
-
* console.log(Chunk.toArray(mixed)) // [[1, "a"], [2, "b"]]
|
|
3938
|
+
* Chunk.toArray(Chunk.zipWith(short, long, (n, l) => [n, l])) // => [[1, "a"], [2, "b"]]
|
|
4125
3939
|
* ```
|
|
4126
3940
|
*
|
|
4127
3941
|
* @category zipping
|
|
@@ -4133,19 +3947,17 @@ export const zipWith: {
|
|
|
4133
3947
|
*
|
|
4134
3948
|
* **Example** (Zipping chunks with a function)
|
|
4135
3949
|
*
|
|
4136
|
-
* ```ts
|
|
3950
|
+
* ```ts import.meta.vitest
|
|
4137
3951
|
* import { Chunk } from "effect"
|
|
4138
3952
|
*
|
|
4139
3953
|
* const numbers = Chunk.make(1, 2, 3)
|
|
4140
3954
|
* const letters = Chunk.make("a", "b", "c")
|
|
4141
|
-
*
|
|
4142
|
-
* console.log(Chunk.toArray(result)) // ["1-a", "2-b", "3-c"]
|
|
3955
|
+
* Chunk.toArray(Chunk.zipWith(numbers, letters, (n, l) => `${n}-${l}`)) // => ["1-a", "2-b", "3-c"]
|
|
4143
3956
|
*
|
|
4144
3957
|
* // Different lengths - takes minimum
|
|
4145
3958
|
* const short = Chunk.make(1, 2)
|
|
4146
3959
|
* const long = Chunk.make("a", "b", "c", "d")
|
|
4147
|
-
*
|
|
4148
|
-
* console.log(Chunk.toArray(mixed)) // [[1, "a"], [2, "b"]]
|
|
3960
|
+
* Chunk.toArray(Chunk.zipWith(short, long, (n, l) => [n, l])) // => [[1, "a"], [2, "b"]]
|
|
4149
3961
|
* ```
|
|
4150
3962
|
*
|
|
4151
3963
|
* @category zipping
|
|
@@ -4157,19 +3969,17 @@ export const zipWith: {
|
|
|
4157
3969
|
*
|
|
4158
3970
|
* **Example** (Zipping chunks with a function)
|
|
4159
3971
|
*
|
|
4160
|
-
* ```ts
|
|
3972
|
+
* ```ts import.meta.vitest
|
|
4161
3973
|
* import { Chunk } from "effect"
|
|
4162
3974
|
*
|
|
4163
3975
|
* const numbers = Chunk.make(1, 2, 3)
|
|
4164
3976
|
* const letters = Chunk.make("a", "b", "c")
|
|
4165
|
-
*
|
|
4166
|
-
* console.log(Chunk.toArray(result)) // ["1-a", "2-b", "3-c"]
|
|
3977
|
+
* Chunk.toArray(Chunk.zipWith(numbers, letters, (n, l) => `${n}-${l}`)) // => ["1-a", "2-b", "3-c"]
|
|
4167
3978
|
*
|
|
4168
3979
|
* // Different lengths - takes minimum
|
|
4169
3980
|
* const short = Chunk.make(1, 2)
|
|
4170
3981
|
* const long = Chunk.make("a", "b", "c", "d")
|
|
4171
|
-
*
|
|
4172
|
-
* console.log(Chunk.toArray(mixed)) // [[1, "a"], [2, "b"]]
|
|
3982
|
+
* Chunk.toArray(Chunk.zipWith(short, long, (n, l) => [n, l])) // => [[1, "a"], [2, "b"]]
|
|
4173
3983
|
* ```
|
|
4174
3984
|
*
|
|
4175
3985
|
* @category zipping
|
|
@@ -4187,19 +3997,17 @@ export const zipWith: {
|
|
|
4187
3997
|
*
|
|
4188
3998
|
* **Example** (Zipping chunks)
|
|
4189
3999
|
*
|
|
4190
|
-
* ```ts
|
|
4000
|
+
* ```ts import.meta.vitest
|
|
4191
4001
|
* import { Chunk } from "effect"
|
|
4192
4002
|
*
|
|
4193
4003
|
* const numbers = Chunk.make(1, 2, 3)
|
|
4194
4004
|
* const letters = Chunk.make("a", "b", "c")
|
|
4195
|
-
*
|
|
4196
|
-
* console.log(Chunk.toArray(result)) // [[1, "a"], [2, "b"], [3, "c"]]
|
|
4005
|
+
* Chunk.toArray(Chunk.zip(numbers, letters)) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
4197
4006
|
*
|
|
4198
4007
|
* // Different lengths - takes minimum length
|
|
4199
4008
|
* const short = Chunk.make(1, 2)
|
|
4200
4009
|
* const long = Chunk.make("a", "b", "c", "d")
|
|
4201
|
-
*
|
|
4202
|
-
* console.log(Chunk.toArray(zipped)) // [[1, "a"], [2, "b"]]
|
|
4010
|
+
* Chunk.toArray(Chunk.zip(short, long)) // => [[1, "a"], [2, "b"]]
|
|
4203
4011
|
* ```
|
|
4204
4012
|
*
|
|
4205
4013
|
* @category zipping
|
|
@@ -4211,19 +4019,17 @@ export const zip: {
|
|
|
4211
4019
|
*
|
|
4212
4020
|
* **Example** (Zipping chunks)
|
|
4213
4021
|
*
|
|
4214
|
-
* ```ts
|
|
4022
|
+
* ```ts import.meta.vitest
|
|
4215
4023
|
* import { Chunk } from "effect"
|
|
4216
4024
|
*
|
|
4217
4025
|
* const numbers = Chunk.make(1, 2, 3)
|
|
4218
4026
|
* const letters = Chunk.make("a", "b", "c")
|
|
4219
|
-
*
|
|
4220
|
-
* console.log(Chunk.toArray(result)) // [[1, "a"], [2, "b"], [3, "c"]]
|
|
4027
|
+
* Chunk.toArray(Chunk.zip(numbers, letters)) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
4221
4028
|
*
|
|
4222
4029
|
* // Different lengths - takes minimum length
|
|
4223
4030
|
* const short = Chunk.make(1, 2)
|
|
4224
4031
|
* const long = Chunk.make("a", "b", "c", "d")
|
|
4225
|
-
*
|
|
4226
|
-
* console.log(Chunk.toArray(zipped)) // [[1, "a"], [2, "b"]]
|
|
4032
|
+
* Chunk.toArray(Chunk.zip(short, long)) // => [[1, "a"], [2, "b"]]
|
|
4227
4033
|
* ```
|
|
4228
4034
|
*
|
|
4229
4035
|
* @category zipping
|
|
@@ -4235,19 +4041,17 @@ export const zip: {
|
|
|
4235
4041
|
*
|
|
4236
4042
|
* **Example** (Zipping chunks)
|
|
4237
4043
|
*
|
|
4238
|
-
* ```ts
|
|
4044
|
+
* ```ts import.meta.vitest
|
|
4239
4045
|
* import { Chunk } from "effect"
|
|
4240
4046
|
*
|
|
4241
4047
|
* const numbers = Chunk.make(1, 2, 3)
|
|
4242
4048
|
* const letters = Chunk.make("a", "b", "c")
|
|
4243
|
-
*
|
|
4244
|
-
* console.log(Chunk.toArray(result)) // [[1, "a"], [2, "b"], [3, "c"]]
|
|
4049
|
+
* Chunk.toArray(Chunk.zip(numbers, letters)) // => [[1, "a"], [2, "b"], [3, "c"]]
|
|
4245
4050
|
*
|
|
4246
4051
|
* // Different lengths - takes minimum length
|
|
4247
4052
|
* const short = Chunk.make(1, 2)
|
|
4248
4053
|
* const long = Chunk.make("a", "b", "c", "d")
|
|
4249
|
-
*
|
|
4250
|
-
* console.log(Chunk.toArray(zipped)) // [[1, "a"], [2, "b"]]
|
|
4054
|
+
* Chunk.toArray(Chunk.zip(short, long)) // => [[1, "a"], [2, "b"]]
|
|
4251
4055
|
* ```
|
|
4252
4056
|
*
|
|
4253
4057
|
* @category zipping
|
|
@@ -4264,23 +4068,20 @@ export const zip: {
|
|
|
4264
4068
|
*
|
|
4265
4069
|
* **Example** (Removing an element)
|
|
4266
4070
|
*
|
|
4267
|
-
* ```ts
|
|
4071
|
+
* ```ts import.meta.vitest
|
|
4268
4072
|
* import { Chunk } from "effect"
|
|
4269
4073
|
*
|
|
4270
4074
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
4271
|
-
*
|
|
4272
|
-
* console.log(Chunk.toArray(result)) // ["a", "c", "d"]
|
|
4075
|
+
* Chunk.toArray(Chunk.remove(chunk, 1)) // => ["a", "c", "d"]
|
|
4273
4076
|
*
|
|
4274
4077
|
* // Remove first element
|
|
4275
|
-
*
|
|
4276
|
-
* console.log(Chunk.toArray(removeFirst)) // ["b", "c", "d"]
|
|
4078
|
+
* Chunk.toArray(Chunk.remove(chunk, 0)) // => ["b", "c", "d"]
|
|
4277
4079
|
*
|
|
4278
4080
|
* // Index out of bounds returns same chunk
|
|
4279
|
-
*
|
|
4280
|
-
* console.log(Chunk.toArray(outOfBounds)) // ["a", "b", "c", "d"]
|
|
4081
|
+
* Chunk.toArray(Chunk.remove(chunk, 10)) // => ["a", "b", "c", "d"]
|
|
4281
4082
|
* ```
|
|
4282
4083
|
*
|
|
4283
|
-
* @category
|
|
4084
|
+
* @category transforming
|
|
4284
4085
|
* @since 2.0.0
|
|
4285
4086
|
*/
|
|
4286
4087
|
export const remove: {
|
|
@@ -4289,23 +4090,20 @@ export const remove: {
|
|
|
4289
4090
|
*
|
|
4290
4091
|
* **Example** (Removing an element)
|
|
4291
4092
|
*
|
|
4292
|
-
* ```ts
|
|
4093
|
+
* ```ts import.meta.vitest
|
|
4293
4094
|
* import { Chunk } from "effect"
|
|
4294
4095
|
*
|
|
4295
4096
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
4296
|
-
*
|
|
4297
|
-
* console.log(Chunk.toArray(result)) // ["a", "c", "d"]
|
|
4097
|
+
* Chunk.toArray(Chunk.remove(chunk, 1)) // => ["a", "c", "d"]
|
|
4298
4098
|
*
|
|
4299
4099
|
* // Remove first element
|
|
4300
|
-
*
|
|
4301
|
-
* console.log(Chunk.toArray(removeFirst)) // ["b", "c", "d"]
|
|
4100
|
+
* Chunk.toArray(Chunk.remove(chunk, 0)) // => ["b", "c", "d"]
|
|
4302
4101
|
*
|
|
4303
4102
|
* // Index out of bounds returns same chunk
|
|
4304
|
-
*
|
|
4305
|
-
* console.log(Chunk.toArray(outOfBounds)) // ["a", "b", "c", "d"]
|
|
4103
|
+
* Chunk.toArray(Chunk.remove(chunk, 10)) // => ["a", "b", "c", "d"]
|
|
4306
4104
|
* ```
|
|
4307
4105
|
*
|
|
4308
|
-
* @category
|
|
4106
|
+
* @category transforming
|
|
4309
4107
|
* @since 2.0.0
|
|
4310
4108
|
*/
|
|
4311
4109
|
(i: number): <A>(self: Chunk<A>) => Chunk<A>
|
|
@@ -4314,23 +4112,20 @@ export const remove: {
|
|
|
4314
4112
|
*
|
|
4315
4113
|
* **Example** (Removing an element)
|
|
4316
4114
|
*
|
|
4317
|
-
* ```ts
|
|
4115
|
+
* ```ts import.meta.vitest
|
|
4318
4116
|
* import { Chunk } from "effect"
|
|
4319
4117
|
*
|
|
4320
4118
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
4321
|
-
*
|
|
4322
|
-
* console.log(Chunk.toArray(result)) // ["a", "c", "d"]
|
|
4119
|
+
* Chunk.toArray(Chunk.remove(chunk, 1)) // => ["a", "c", "d"]
|
|
4323
4120
|
*
|
|
4324
4121
|
* // Remove first element
|
|
4325
|
-
*
|
|
4326
|
-
* console.log(Chunk.toArray(removeFirst)) // ["b", "c", "d"]
|
|
4122
|
+
* Chunk.toArray(Chunk.remove(chunk, 0)) // => ["b", "c", "d"]
|
|
4327
4123
|
*
|
|
4328
4124
|
* // Index out of bounds returns same chunk
|
|
4329
|
-
*
|
|
4330
|
-
* console.log(Chunk.toArray(outOfBounds)) // ["a", "b", "c", "d"]
|
|
4125
|
+
* Chunk.toArray(Chunk.remove(chunk, 10)) // => ["a", "b", "c", "d"]
|
|
4331
4126
|
* ```
|
|
4332
4127
|
*
|
|
4333
|
-
* @category
|
|
4128
|
+
* @category transforming
|
|
4334
4129
|
* @since 2.0.0
|
|
4335
4130
|
*/
|
|
4336
4131
|
<A>(self: Chunk<A>, i: number): Chunk<A>
|
|
@@ -4345,23 +4140,20 @@ export const remove: {
|
|
|
4345
4140
|
*
|
|
4346
4141
|
* **Example** (Modifying an element)
|
|
4347
4142
|
*
|
|
4348
|
-
* ```ts
|
|
4349
|
-
* import { Chunk } from "effect"
|
|
4143
|
+
* ```ts import.meta.vitest
|
|
4144
|
+
* import { Chunk, Option } from "effect"
|
|
4350
4145
|
*
|
|
4351
4146
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
4352
|
-
*
|
|
4353
|
-
* console.log(result) // Option.some(Chunk.make(1, 20, 3, 4))
|
|
4147
|
+
* Chunk.modify(chunk, 1, (n) => n * 10) // => Option.some(Chunk.make(1, 20, 3, 4))
|
|
4354
4148
|
*
|
|
4355
4149
|
* // Index out of bounds returns None
|
|
4356
|
-
*
|
|
4357
|
-
* console.log(outOfBounds) // Option.none()
|
|
4150
|
+
* chunk.pipe(Chunk.modify(10, (n) => n * 10)) // => Option.none()
|
|
4358
4151
|
*
|
|
4359
4152
|
* // Negative index returns None
|
|
4360
|
-
*
|
|
4361
|
-
* console.log(negative) // Option.none()
|
|
4153
|
+
* chunk.pipe(Chunk.modify(-1, (n) => n * 10)) // => Option.none()
|
|
4362
4154
|
* ```
|
|
4363
4155
|
*
|
|
4364
|
-
* @category
|
|
4156
|
+
* @category transforming
|
|
4365
4157
|
* @since 2.0.0
|
|
4366
4158
|
*/
|
|
4367
4159
|
export const modify: {
|
|
@@ -4371,23 +4163,20 @@ export const modify: {
|
|
|
4371
4163
|
*
|
|
4372
4164
|
* **Example** (Modifying an element)
|
|
4373
4165
|
*
|
|
4374
|
-
* ```ts
|
|
4375
|
-
* import { Chunk } from "effect"
|
|
4166
|
+
* ```ts import.meta.vitest
|
|
4167
|
+
* import { Chunk, Option } from "effect"
|
|
4376
4168
|
*
|
|
4377
4169
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
4378
|
-
*
|
|
4379
|
-
* console.log(result) // Option.some(Chunk.make(1, 20, 3, 4))
|
|
4170
|
+
* Chunk.modify(chunk, 1, (n) => n * 10) // => Option.some(Chunk.make(1, 20, 3, 4))
|
|
4380
4171
|
*
|
|
4381
4172
|
* // Index out of bounds returns None
|
|
4382
|
-
*
|
|
4383
|
-
* console.log(outOfBounds) // Option.none()
|
|
4173
|
+
* chunk.pipe(Chunk.modify(10, (n) => n * 10)) // => Option.none()
|
|
4384
4174
|
*
|
|
4385
4175
|
* // Negative index returns None
|
|
4386
|
-
*
|
|
4387
|
-
* console.log(negative) // Option.none()
|
|
4176
|
+
* chunk.pipe(Chunk.modify(-1, (n) => n * 10)) // => Option.none()
|
|
4388
4177
|
* ```
|
|
4389
4178
|
*
|
|
4390
|
-
* @category
|
|
4179
|
+
* @category transforming
|
|
4391
4180
|
* @since 2.0.0
|
|
4392
4181
|
*/
|
|
4393
4182
|
<A, B>(i: number, f: (a: A) => B): (self: Chunk<A>) => O.Option<Chunk<A | B>>
|
|
@@ -4397,23 +4186,20 @@ export const modify: {
|
|
|
4397
4186
|
*
|
|
4398
4187
|
* **Example** (Modifying an element)
|
|
4399
4188
|
*
|
|
4400
|
-
* ```ts
|
|
4401
|
-
* import { Chunk } from "effect"
|
|
4189
|
+
* ```ts import.meta.vitest
|
|
4190
|
+
* import { Chunk, Option } from "effect"
|
|
4402
4191
|
*
|
|
4403
4192
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
4404
|
-
*
|
|
4405
|
-
* console.log(result) // Option.some(Chunk.make(1, 20, 3, 4))
|
|
4193
|
+
* Chunk.modify(chunk, 1, (n) => n * 10) // => Option.some(Chunk.make(1, 20, 3, 4))
|
|
4406
4194
|
*
|
|
4407
4195
|
* // Index out of bounds returns None
|
|
4408
|
-
*
|
|
4409
|
-
* console.log(outOfBounds) // Option.none()
|
|
4196
|
+
* chunk.pipe(Chunk.modify(10, (n) => n * 10)) // => Option.none()
|
|
4410
4197
|
*
|
|
4411
4198
|
* // Negative index returns None
|
|
4412
|
-
*
|
|
4413
|
-
* console.log(negative) // Option.none()
|
|
4199
|
+
* chunk.pipe(Chunk.modify(-1, (n) => n * 10)) // => Option.none()
|
|
4414
4200
|
* ```
|
|
4415
4201
|
*
|
|
4416
|
-
* @category
|
|
4202
|
+
* @category transforming
|
|
4417
4203
|
* @since 2.0.0
|
|
4418
4204
|
*/
|
|
4419
4205
|
<A, B>(self: Chunk<A>, i: number, f: (a: A) => B): O.Option<Chunk<A | B>>
|
|
@@ -4429,23 +4215,20 @@ export const modify: {
|
|
|
4429
4215
|
*
|
|
4430
4216
|
* **Example** (Replacing an element)
|
|
4431
4217
|
*
|
|
4432
|
-
* ```ts
|
|
4433
|
-
* import { Chunk } from "effect"
|
|
4218
|
+
* ```ts import.meta.vitest
|
|
4219
|
+
* import { Chunk, Option } from "effect"
|
|
4434
4220
|
*
|
|
4435
4221
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
4436
|
-
*
|
|
4437
|
-
* console.log(result) // Option.some(Chunk.make("a", "X", "c", "d"))
|
|
4222
|
+
* Chunk.replace(chunk, 1, "X") // => Option.some(Chunk.make("a", "X", "c", "d"))
|
|
4438
4223
|
*
|
|
4439
4224
|
* // Index out of bounds returns None
|
|
4440
|
-
*
|
|
4441
|
-
* console.log(outOfBounds) // Option.none()
|
|
4225
|
+
* chunk.pipe(Chunk.replace(10, "Y")) // => Option.none()
|
|
4442
4226
|
*
|
|
4443
4227
|
* // Negative index returns None
|
|
4444
|
-
*
|
|
4445
|
-
* console.log(negative) // Option.none()
|
|
4228
|
+
* chunk.pipe(Chunk.replace(-1, "Z")) // => Option.none()
|
|
4446
4229
|
* ```
|
|
4447
4230
|
*
|
|
4448
|
-
* @category
|
|
4231
|
+
* @category transforming
|
|
4449
4232
|
* @since 2.0.0
|
|
4450
4233
|
*/
|
|
4451
4234
|
export const replace: {
|
|
@@ -4455,23 +4238,20 @@ export const replace: {
|
|
|
4455
4238
|
*
|
|
4456
4239
|
* **Example** (Replacing an element)
|
|
4457
4240
|
*
|
|
4458
|
-
* ```ts
|
|
4459
|
-
* import { Chunk } from "effect"
|
|
4241
|
+
* ```ts import.meta.vitest
|
|
4242
|
+
* import { Chunk, Option } from "effect"
|
|
4460
4243
|
*
|
|
4461
4244
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
4462
|
-
*
|
|
4463
|
-
* console.log(result) // Option.some(Chunk.make("a", "X", "c", "d"))
|
|
4245
|
+
* Chunk.replace(chunk, 1, "X") // => Option.some(Chunk.make("a", "X", "c", "d"))
|
|
4464
4246
|
*
|
|
4465
4247
|
* // Index out of bounds returns None
|
|
4466
|
-
*
|
|
4467
|
-
* console.log(outOfBounds) // Option.none()
|
|
4248
|
+
* chunk.pipe(Chunk.replace(10, "Y")) // => Option.none()
|
|
4468
4249
|
*
|
|
4469
4250
|
* // Negative index returns None
|
|
4470
|
-
*
|
|
4471
|
-
* console.log(negative) // Option.none()
|
|
4251
|
+
* chunk.pipe(Chunk.replace(-1, "Z")) // => Option.none()
|
|
4472
4252
|
* ```
|
|
4473
4253
|
*
|
|
4474
|
-
* @category
|
|
4254
|
+
* @category transforming
|
|
4475
4255
|
* @since 2.0.0
|
|
4476
4256
|
*/
|
|
4477
4257
|
<B>(i: number, b: B): <A>(self: Chunk<A>) => O.Option<Chunk<B | A>>
|
|
@@ -4481,23 +4261,20 @@ export const replace: {
|
|
|
4481
4261
|
*
|
|
4482
4262
|
* **Example** (Replacing an element)
|
|
4483
4263
|
*
|
|
4484
|
-
* ```ts
|
|
4485
|
-
* import { Chunk } from "effect"
|
|
4264
|
+
* ```ts import.meta.vitest
|
|
4265
|
+
* import { Chunk, Option } from "effect"
|
|
4486
4266
|
*
|
|
4487
4267
|
* const chunk = Chunk.make("a", "b", "c", "d")
|
|
4488
|
-
*
|
|
4489
|
-
* console.log(result) // Option.some(Chunk.make("a", "X", "c", "d"))
|
|
4268
|
+
* Chunk.replace(chunk, 1, "X") // => Option.some(Chunk.make("a", "X", "c", "d"))
|
|
4490
4269
|
*
|
|
4491
4270
|
* // Index out of bounds returns None
|
|
4492
|
-
*
|
|
4493
|
-
* console.log(outOfBounds) // Option.none()
|
|
4271
|
+
* chunk.pipe(Chunk.replace(10, "Y")) // => Option.none()
|
|
4494
4272
|
*
|
|
4495
4273
|
* // Negative index returns None
|
|
4496
|
-
*
|
|
4497
|
-
* console.log(negative) // Option.none()
|
|
4274
|
+
* chunk.pipe(Chunk.replace(-1, "Z")) // => Option.none()
|
|
4498
4275
|
* ```
|
|
4499
4276
|
*
|
|
4500
|
-
* @category
|
|
4277
|
+
* @category transforming
|
|
4501
4278
|
* @since 2.0.0
|
|
4502
4279
|
*/
|
|
4503
4280
|
<A, B>(self: Chunk<A>, i: number, b: B): O.Option<Chunk<B | A>>
|
|
@@ -4512,11 +4289,10 @@ export const replace: {
|
|
|
4512
4289
|
*
|
|
4513
4290
|
* **Example** (Generating chunks from indices)
|
|
4514
4291
|
*
|
|
4515
|
-
* ```ts
|
|
4292
|
+
* ```ts import.meta.vitest
|
|
4516
4293
|
* import { Chunk } from "effect"
|
|
4517
4294
|
*
|
|
4518
|
-
*
|
|
4519
|
-
* console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8]
|
|
4295
|
+
* Chunk.toArray(Chunk.makeBy(5, (i) => i * 2)) // => [0, 2, 4, 6, 8]
|
|
4520
4296
|
* ```
|
|
4521
4297
|
*
|
|
4522
4298
|
* @category constructors
|
|
@@ -4532,11 +4308,10 @@ export const makeBy: {
|
|
|
4532
4308
|
*
|
|
4533
4309
|
* **Example** (Generating chunks from indices)
|
|
4534
4310
|
*
|
|
4535
|
-
* ```ts
|
|
4311
|
+
* ```ts import.meta.vitest
|
|
4536
4312
|
* import { Chunk } from "effect"
|
|
4537
4313
|
*
|
|
4538
|
-
*
|
|
4539
|
-
* console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8]
|
|
4314
|
+
* Chunk.toArray(Chunk.makeBy(5, (i) => i * 2)) // => [0, 2, 4, 6, 8]
|
|
4540
4315
|
* ```
|
|
4541
4316
|
*
|
|
4542
4317
|
* @category constructors
|
|
@@ -4552,11 +4327,10 @@ export const makeBy: {
|
|
|
4552
4327
|
*
|
|
4553
4328
|
* **Example** (Generating chunks from indices)
|
|
4554
4329
|
*
|
|
4555
|
-
* ```ts
|
|
4330
|
+
* ```ts import.meta.vitest
|
|
4556
4331
|
* import { Chunk } from "effect"
|
|
4557
4332
|
*
|
|
4558
|
-
*
|
|
4559
|
-
* console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8]
|
|
4333
|
+
* Chunk.toArray(Chunk.makeBy(5, (i) => i * 2)) // => [0, 2, 4, 6, 8]
|
|
4560
4334
|
* ```
|
|
4561
4335
|
*
|
|
4562
4336
|
* @category constructors
|
|
@@ -4576,11 +4350,10 @@ export const makeBy: {
|
|
|
4576
4350
|
*
|
|
4577
4351
|
* **Example** (Creating a range)
|
|
4578
4352
|
*
|
|
4579
|
-
* ```ts
|
|
4353
|
+
* ```ts import.meta.vitest
|
|
4580
4354
|
* import { Chunk } from "effect"
|
|
4581
4355
|
*
|
|
4582
|
-
*
|
|
4583
|
-
* console.log(Chunk.toArray(chunk)) // [1, 2, 3, 4, 5]
|
|
4356
|
+
* Chunk.toArray(Chunk.range(1, 5)) // => [1, 2, 3, 4, 5]
|
|
4584
4357
|
* ```
|
|
4585
4358
|
*
|
|
4586
4359
|
* @category constructors
|
|
@@ -4598,24 +4371,23 @@ export const range = (start: number, end: number): NonEmptyChunk<number> =>
|
|
|
4598
4371
|
*
|
|
4599
4372
|
* **Example** (Checking membership)
|
|
4600
4373
|
*
|
|
4601
|
-
* ```ts
|
|
4374
|
+
* ```ts import.meta.vitest
|
|
4602
4375
|
* import { Chunk } from "effect"
|
|
4603
4376
|
*
|
|
4604
4377
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4605
|
-
*
|
|
4606
|
-
*
|
|
4378
|
+
* Chunk.contains(chunk, 3) // => true
|
|
4379
|
+
* Chunk.contains(chunk, 6) // => false
|
|
4607
4380
|
*
|
|
4608
4381
|
* // Works with strings
|
|
4609
4382
|
* const words = Chunk.make("apple", "banana", "cherry")
|
|
4610
|
-
*
|
|
4611
|
-
*
|
|
4383
|
+
* Chunk.contains(words, "banana") // => true
|
|
4384
|
+
* Chunk.contains(words, "grape") // => false
|
|
4612
4385
|
*
|
|
4613
4386
|
* // Empty chunk
|
|
4614
|
-
*
|
|
4615
|
-
* console.log(Chunk.contains(empty, 1)) // false
|
|
4387
|
+
* Chunk.contains(Chunk.empty<number>(), 1) // => false
|
|
4616
4388
|
* ```
|
|
4617
4389
|
*
|
|
4618
|
-
* @category
|
|
4390
|
+
* @category predicates
|
|
4619
4391
|
* @since 2.0.0
|
|
4620
4392
|
*/
|
|
4621
4393
|
export const contains: {
|
|
@@ -4628,24 +4400,23 @@ export const contains: {
|
|
|
4628
4400
|
*
|
|
4629
4401
|
* **Example** (Checking membership)
|
|
4630
4402
|
*
|
|
4631
|
-
* ```ts
|
|
4403
|
+
* ```ts import.meta.vitest
|
|
4632
4404
|
* import { Chunk } from "effect"
|
|
4633
4405
|
*
|
|
4634
4406
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4635
|
-
*
|
|
4636
|
-
*
|
|
4407
|
+
* Chunk.contains(chunk, 3) // => true
|
|
4408
|
+
* Chunk.contains(chunk, 6) // => false
|
|
4637
4409
|
*
|
|
4638
4410
|
* // Works with strings
|
|
4639
4411
|
* const words = Chunk.make("apple", "banana", "cherry")
|
|
4640
|
-
*
|
|
4641
|
-
*
|
|
4412
|
+
* Chunk.contains(words, "banana") // => true
|
|
4413
|
+
* Chunk.contains(words, "grape") // => false
|
|
4642
4414
|
*
|
|
4643
4415
|
* // Empty chunk
|
|
4644
|
-
*
|
|
4645
|
-
* console.log(Chunk.contains(empty, 1)) // false
|
|
4416
|
+
* Chunk.contains(Chunk.empty<number>(), 1) // => false
|
|
4646
4417
|
* ```
|
|
4647
4418
|
*
|
|
4648
|
-
* @category
|
|
4419
|
+
* @category predicates
|
|
4649
4420
|
* @since 2.0.0
|
|
4650
4421
|
*/
|
|
4651
4422
|
<A>(a: A): (self: Chunk<A>) => boolean
|
|
@@ -4658,24 +4429,23 @@ export const contains: {
|
|
|
4658
4429
|
*
|
|
4659
4430
|
* **Example** (Checking membership)
|
|
4660
4431
|
*
|
|
4661
|
-
* ```ts
|
|
4432
|
+
* ```ts import.meta.vitest
|
|
4662
4433
|
* import { Chunk } from "effect"
|
|
4663
4434
|
*
|
|
4664
4435
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4665
|
-
*
|
|
4666
|
-
*
|
|
4436
|
+
* Chunk.contains(chunk, 3) // => true
|
|
4437
|
+
* Chunk.contains(chunk, 6) // => false
|
|
4667
4438
|
*
|
|
4668
4439
|
* // Works with strings
|
|
4669
4440
|
* const words = Chunk.make("apple", "banana", "cherry")
|
|
4670
|
-
*
|
|
4671
|
-
*
|
|
4441
|
+
* Chunk.contains(words, "banana") // => true
|
|
4442
|
+
* Chunk.contains(words, "grape") // => false
|
|
4672
4443
|
*
|
|
4673
4444
|
* // Empty chunk
|
|
4674
|
-
*
|
|
4675
|
-
* console.log(Chunk.contains(empty, 1)) // false
|
|
4445
|
+
* Chunk.contains(Chunk.empty<number>(), 1) // => false
|
|
4676
4446
|
* ```
|
|
4677
4447
|
*
|
|
4678
|
-
* @category
|
|
4448
|
+
* @category predicates
|
|
4679
4449
|
* @since 2.0.0
|
|
4680
4450
|
*/
|
|
4681
4451
|
<A>(self: Chunk<A>, a: A): boolean
|
|
@@ -4686,7 +4456,7 @@ export const contains: {
|
|
|
4686
4456
|
*
|
|
4687
4457
|
* **Example** (Checking membership with custom equivalence)
|
|
4688
4458
|
*
|
|
4689
|
-
* ```ts
|
|
4459
|
+
* ```ts import.meta.vitest
|
|
4690
4460
|
* import { Chunk } from "effect"
|
|
4691
4461
|
*
|
|
4692
4462
|
* const chunk = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" })
|
|
@@ -4695,19 +4465,19 @@ export const contains: {
|
|
|
4695
4465
|
* const containsById = Chunk.containsWith<{ id: number; name: string }>((a, b) =>
|
|
4696
4466
|
* a.id === b.id
|
|
4697
4467
|
* )
|
|
4698
|
-
*
|
|
4699
|
-
*
|
|
4468
|
+
* containsById(chunk, { id: 1, name: "Different" }) // => true
|
|
4469
|
+
* containsById(chunk, { id: 3, name: "Charlie" }) // => false
|
|
4700
4470
|
*
|
|
4701
4471
|
* // Case-insensitive string comparison
|
|
4702
4472
|
* const words = Chunk.make("Apple", "Banana", "Cherry")
|
|
4703
4473
|
* const containsCaseInsensitive = Chunk.containsWith<string>((a, b) =>
|
|
4704
4474
|
* a.toLowerCase() === b.toLowerCase()
|
|
4705
4475
|
* )
|
|
4706
|
-
*
|
|
4707
|
-
*
|
|
4476
|
+
* containsCaseInsensitive(words, "apple") // => true
|
|
4477
|
+
* containsCaseInsensitive(words, "grape") // => false
|
|
4708
4478
|
* ```
|
|
4709
4479
|
*
|
|
4710
|
-
* @category
|
|
4480
|
+
* @category predicates
|
|
4711
4481
|
* @since 2.0.0
|
|
4712
4482
|
*/
|
|
4713
4483
|
export const containsWith: <A>(
|
|
@@ -4723,17 +4493,14 @@ export const containsWith: <A>(
|
|
|
4723
4493
|
*
|
|
4724
4494
|
* **Example** (Finding the first matching element)
|
|
4725
4495
|
*
|
|
4726
|
-
* ```ts
|
|
4496
|
+
* ```ts import.meta.vitest
|
|
4727
4497
|
* import { Chunk, Option } from "effect"
|
|
4728
4498
|
*
|
|
4729
4499
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4730
|
-
*
|
|
4731
|
-
* console.log(Option.isSome(result)) // true
|
|
4732
|
-
* console.log(Option.getOrElse(result, () => 0)) // 4
|
|
4500
|
+
* Chunk.findFirst(chunk, (n) => n > 3) // => Option.some(4)
|
|
4733
4501
|
*
|
|
4734
4502
|
* // No match found
|
|
4735
|
-
*
|
|
4736
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4503
|
+
* Chunk.findFirst(chunk, (n) => n > 10) // => Option.none()
|
|
4737
4504
|
*
|
|
4738
4505
|
* // With type refinement
|
|
4739
4506
|
* const mixed = Chunk.make(1, "hello", 2, "world", 3)
|
|
@@ -4741,10 +4508,10 @@ export const containsWith: <A>(
|
|
|
4741
4508
|
* mixed,
|
|
4742
4509
|
* (x): x is string => typeof x === "string"
|
|
4743
4510
|
* )
|
|
4744
|
-
*
|
|
4511
|
+
* firstString // => Option.some("hello")
|
|
4745
4512
|
* ```
|
|
4746
4513
|
*
|
|
4747
|
-
* @category
|
|
4514
|
+
* @category searching
|
|
4748
4515
|
* @since 2.0.0
|
|
4749
4516
|
*/
|
|
4750
4517
|
export const findFirst: {
|
|
@@ -4754,17 +4521,14 @@ export const findFirst: {
|
|
|
4754
4521
|
*
|
|
4755
4522
|
* **Example** (Finding the first matching element)
|
|
4756
4523
|
*
|
|
4757
|
-
* ```ts
|
|
4524
|
+
* ```ts import.meta.vitest
|
|
4758
4525
|
* import { Chunk, Option } from "effect"
|
|
4759
4526
|
*
|
|
4760
4527
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4761
|
-
*
|
|
4762
|
-
* console.log(Option.isSome(result)) // true
|
|
4763
|
-
* console.log(Option.getOrElse(result, () => 0)) // 4
|
|
4528
|
+
* Chunk.findFirst(chunk, (n) => n > 3) // => Option.some(4)
|
|
4764
4529
|
*
|
|
4765
4530
|
* // No match found
|
|
4766
|
-
*
|
|
4767
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4531
|
+
* Chunk.findFirst(chunk, (n) => n > 10) // => Option.none()
|
|
4768
4532
|
*
|
|
4769
4533
|
* // With type refinement
|
|
4770
4534
|
* const mixed = Chunk.make(1, "hello", 2, "world", 3)
|
|
@@ -4772,10 +4536,10 @@ export const findFirst: {
|
|
|
4772
4536
|
* mixed,
|
|
4773
4537
|
* (x): x is string => typeof x === "string"
|
|
4774
4538
|
* )
|
|
4775
|
-
*
|
|
4539
|
+
* firstString // => Option.some("hello")
|
|
4776
4540
|
* ```
|
|
4777
4541
|
*
|
|
4778
|
-
* @category
|
|
4542
|
+
* @category searching
|
|
4779
4543
|
* @since 2.0.0
|
|
4780
4544
|
*/
|
|
4781
4545
|
<A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Chunk<A>) => Option<B>
|
|
@@ -4785,17 +4549,14 @@ export const findFirst: {
|
|
|
4785
4549
|
*
|
|
4786
4550
|
* **Example** (Finding the first matching element)
|
|
4787
4551
|
*
|
|
4788
|
-
* ```ts
|
|
4552
|
+
* ```ts import.meta.vitest
|
|
4789
4553
|
* import { Chunk, Option } from "effect"
|
|
4790
4554
|
*
|
|
4791
4555
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4792
|
-
*
|
|
4793
|
-
* console.log(Option.isSome(result)) // true
|
|
4794
|
-
* console.log(Option.getOrElse(result, () => 0)) // 4
|
|
4556
|
+
* Chunk.findFirst(chunk, (n) => n > 3) // => Option.some(4)
|
|
4795
4557
|
*
|
|
4796
4558
|
* // No match found
|
|
4797
|
-
*
|
|
4798
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4559
|
+
* Chunk.findFirst(chunk, (n) => n > 10) // => Option.none()
|
|
4799
4560
|
*
|
|
4800
4561
|
* // With type refinement
|
|
4801
4562
|
* const mixed = Chunk.make(1, "hello", 2, "world", 3)
|
|
@@ -4803,10 +4564,10 @@ export const findFirst: {
|
|
|
4803
4564
|
* mixed,
|
|
4804
4565
|
* (x): x is string => typeof x === "string"
|
|
4805
4566
|
* )
|
|
4806
|
-
*
|
|
4567
|
+
* firstString // => Option.some("hello")
|
|
4807
4568
|
* ```
|
|
4808
4569
|
*
|
|
4809
|
-
* @category
|
|
4570
|
+
* @category searching
|
|
4810
4571
|
* @since 2.0.0
|
|
4811
4572
|
*/
|
|
4812
4573
|
<A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => Option<A>
|
|
@@ -4816,17 +4577,14 @@ export const findFirst: {
|
|
|
4816
4577
|
*
|
|
4817
4578
|
* **Example** (Finding the first matching element)
|
|
4818
4579
|
*
|
|
4819
|
-
* ```ts
|
|
4580
|
+
* ```ts import.meta.vitest
|
|
4820
4581
|
* import { Chunk, Option } from "effect"
|
|
4821
4582
|
*
|
|
4822
4583
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4823
|
-
*
|
|
4824
|
-
* console.log(Option.isSome(result)) // true
|
|
4825
|
-
* console.log(Option.getOrElse(result, () => 0)) // 4
|
|
4584
|
+
* Chunk.findFirst(chunk, (n) => n > 3) // => Option.some(4)
|
|
4826
4585
|
*
|
|
4827
4586
|
* // No match found
|
|
4828
|
-
*
|
|
4829
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4587
|
+
* Chunk.findFirst(chunk, (n) => n > 10) // => Option.none()
|
|
4830
4588
|
*
|
|
4831
4589
|
* // With type refinement
|
|
4832
4590
|
* const mixed = Chunk.make(1, "hello", 2, "world", 3)
|
|
@@ -4834,10 +4592,10 @@ export const findFirst: {
|
|
|
4834
4592
|
* mixed,
|
|
4835
4593
|
* (x): x is string => typeof x === "string"
|
|
4836
4594
|
* )
|
|
4837
|
-
*
|
|
4595
|
+
* firstString // => Option.some("hello")
|
|
4838
4596
|
* ```
|
|
4839
4597
|
*
|
|
4840
|
-
* @category
|
|
4598
|
+
* @category searching
|
|
4841
4599
|
* @since 2.0.0
|
|
4842
4600
|
*/
|
|
4843
4601
|
<A, B extends A>(self: Chunk<A>, refinement: Refinement<A, B>): Option<B>
|
|
@@ -4847,17 +4605,14 @@ export const findFirst: {
|
|
|
4847
4605
|
*
|
|
4848
4606
|
* **Example** (Finding the first matching element)
|
|
4849
4607
|
*
|
|
4850
|
-
* ```ts
|
|
4608
|
+
* ```ts import.meta.vitest
|
|
4851
4609
|
* import { Chunk, Option } from "effect"
|
|
4852
4610
|
*
|
|
4853
4611
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4854
|
-
*
|
|
4855
|
-
* console.log(Option.isSome(result)) // true
|
|
4856
|
-
* console.log(Option.getOrElse(result, () => 0)) // 4
|
|
4612
|
+
* Chunk.findFirst(chunk, (n) => n > 3) // => Option.some(4)
|
|
4857
4613
|
*
|
|
4858
4614
|
* // No match found
|
|
4859
|
-
*
|
|
4860
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4615
|
+
* Chunk.findFirst(chunk, (n) => n > 10) // => Option.none()
|
|
4861
4616
|
*
|
|
4862
4617
|
* // With type refinement
|
|
4863
4618
|
* const mixed = Chunk.make(1, "hello", 2, "world", 3)
|
|
@@ -4865,10 +4620,10 @@ export const findFirst: {
|
|
|
4865
4620
|
* mixed,
|
|
4866
4621
|
* (x): x is string => typeof x === "string"
|
|
4867
4622
|
* )
|
|
4868
|
-
*
|
|
4623
|
+
* firstString // => Option.some("hello")
|
|
4869
4624
|
* ```
|
|
4870
4625
|
*
|
|
4871
|
-
* @category
|
|
4626
|
+
* @category searching
|
|
4872
4627
|
* @since 2.0.0
|
|
4873
4628
|
*/
|
|
4874
4629
|
<A>(self: Chunk<A>, predicate: Predicate<A>): Option<A>
|
|
@@ -4879,23 +4634,20 @@ export const findFirst: {
|
|
|
4879
4634
|
*
|
|
4880
4635
|
* **Example** (Finding the first matching index)
|
|
4881
4636
|
*
|
|
4882
|
-
* ```ts
|
|
4883
|
-
* import { Chunk } from "effect"
|
|
4637
|
+
* ```ts import.meta.vitest
|
|
4638
|
+
* import { Chunk, Option } from "effect"
|
|
4884
4639
|
*
|
|
4885
4640
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4886
|
-
*
|
|
4887
|
-
* console.log(result) // Option.some(3)
|
|
4641
|
+
* Chunk.findFirstIndex(chunk, (n) => n > 3) // => Option.some(3)
|
|
4888
4642
|
*
|
|
4889
4643
|
* // No match found
|
|
4890
|
-
*
|
|
4891
|
-
* console.log(notFound) // Option.none()
|
|
4644
|
+
* Chunk.findFirstIndex(chunk, (n) => n > 10) // => Option.none()
|
|
4892
4645
|
*
|
|
4893
4646
|
* // Find first even number
|
|
4894
|
-
*
|
|
4895
|
-
* console.log(firstEven) // Option.some(1)
|
|
4647
|
+
* Chunk.findFirstIndex(chunk, (n) => n % 2 === 0) // => Option.some(1)
|
|
4896
4648
|
* ```
|
|
4897
4649
|
*
|
|
4898
|
-
* @category
|
|
4650
|
+
* @category searching
|
|
4899
4651
|
* @since 2.0.0
|
|
4900
4652
|
*/
|
|
4901
4653
|
export const findFirstIndex: {
|
|
@@ -4904,23 +4656,20 @@ export const findFirstIndex: {
|
|
|
4904
4656
|
*
|
|
4905
4657
|
* **Example** (Finding the first matching index)
|
|
4906
4658
|
*
|
|
4907
|
-
* ```ts
|
|
4908
|
-
* import { Chunk } from "effect"
|
|
4659
|
+
* ```ts import.meta.vitest
|
|
4660
|
+
* import { Chunk, Option } from "effect"
|
|
4909
4661
|
*
|
|
4910
4662
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4911
|
-
*
|
|
4912
|
-
* console.log(result) // Option.some(3)
|
|
4663
|
+
* Chunk.findFirstIndex(chunk, (n) => n > 3) // => Option.some(3)
|
|
4913
4664
|
*
|
|
4914
4665
|
* // No match found
|
|
4915
|
-
*
|
|
4916
|
-
* console.log(notFound) // Option.none()
|
|
4666
|
+
* Chunk.findFirstIndex(chunk, (n) => n > 10) // => Option.none()
|
|
4917
4667
|
*
|
|
4918
4668
|
* // Find first even number
|
|
4919
|
-
*
|
|
4920
|
-
* console.log(firstEven) // Option.some(1)
|
|
4669
|
+
* Chunk.findFirstIndex(chunk, (n) => n % 2 === 0) // => Option.some(1)
|
|
4921
4670
|
* ```
|
|
4922
4671
|
*
|
|
4923
|
-
* @category
|
|
4672
|
+
* @category searching
|
|
4924
4673
|
* @since 2.0.0
|
|
4925
4674
|
*/
|
|
4926
4675
|
<A>(predicate: Predicate<A>): (self: Chunk<A>) => O.Option<number>
|
|
@@ -4929,23 +4678,20 @@ export const findFirstIndex: {
|
|
|
4929
4678
|
*
|
|
4930
4679
|
* **Example** (Finding the first matching index)
|
|
4931
4680
|
*
|
|
4932
|
-
* ```ts
|
|
4933
|
-
* import { Chunk } from "effect"
|
|
4681
|
+
* ```ts import.meta.vitest
|
|
4682
|
+
* import { Chunk, Option } from "effect"
|
|
4934
4683
|
*
|
|
4935
4684
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4936
|
-
*
|
|
4937
|
-
* console.log(result) // Option.some(3)
|
|
4685
|
+
* Chunk.findFirstIndex(chunk, (n) => n > 3) // => Option.some(3)
|
|
4938
4686
|
*
|
|
4939
4687
|
* // No match found
|
|
4940
|
-
*
|
|
4941
|
-
* console.log(notFound) // Option.none()
|
|
4688
|
+
* Chunk.findFirstIndex(chunk, (n) => n > 10) // => Option.none()
|
|
4942
4689
|
*
|
|
4943
4690
|
* // Find first even number
|
|
4944
|
-
*
|
|
4945
|
-
* console.log(firstEven) // Option.some(1)
|
|
4691
|
+
* Chunk.findFirstIndex(chunk, (n) => n % 2 === 0) // => Option.some(1)
|
|
4946
4692
|
* ```
|
|
4947
4693
|
*
|
|
4948
|
-
* @category
|
|
4694
|
+
* @category searching
|
|
4949
4695
|
* @since 2.0.0
|
|
4950
4696
|
*/
|
|
4951
4697
|
<A>(self: Chunk<A>, predicate: Predicate<A>): O.Option<number>
|
|
@@ -4959,24 +4705,20 @@ export const findFirstIndex: {
|
|
|
4959
4705
|
*
|
|
4960
4706
|
* **Example** (Finding the last matching element)
|
|
4961
4707
|
*
|
|
4962
|
-
* ```ts
|
|
4708
|
+
* ```ts import.meta.vitest
|
|
4963
4709
|
* import { Chunk, Option } from "effect"
|
|
4964
4710
|
*
|
|
4965
4711
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4966
|
-
*
|
|
4967
|
-
* console.log(Option.isSome(result)) // true
|
|
4968
|
-
* console.log(Option.getOrElse(result, () => 0)) // 3
|
|
4712
|
+
* Chunk.findLast(chunk, (n) => n < 4) // => Option.some(3)
|
|
4969
4713
|
*
|
|
4970
4714
|
* // No match found
|
|
4971
|
-
*
|
|
4972
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4715
|
+
* Chunk.findLast(chunk, (n) => n > 10) // => Option.none()
|
|
4973
4716
|
*
|
|
4974
4717
|
* // Find last even number
|
|
4975
|
-
*
|
|
4976
|
-
* console.log(Option.getOrElse(lastEven, () => 0)) // 4
|
|
4718
|
+
* Chunk.findLast(chunk, (n) => n % 2 === 0) // => Option.some(4)
|
|
4977
4719
|
* ```
|
|
4978
4720
|
*
|
|
4979
|
-
* @category
|
|
4721
|
+
* @category searching
|
|
4980
4722
|
* @since 2.0.0
|
|
4981
4723
|
*/
|
|
4982
4724
|
export const findLast: {
|
|
@@ -4985,24 +4727,20 @@ export const findLast: {
|
|
|
4985
4727
|
*
|
|
4986
4728
|
* **Example** (Finding the last matching element)
|
|
4987
4729
|
*
|
|
4988
|
-
* ```ts
|
|
4730
|
+
* ```ts import.meta.vitest
|
|
4989
4731
|
* import { Chunk, Option } from "effect"
|
|
4990
4732
|
*
|
|
4991
4733
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
4992
|
-
*
|
|
4993
|
-
* console.log(Option.isSome(result)) // true
|
|
4994
|
-
* console.log(Option.getOrElse(result, () => 0)) // 3
|
|
4734
|
+
* Chunk.findLast(chunk, (n) => n < 4) // => Option.some(3)
|
|
4995
4735
|
*
|
|
4996
4736
|
* // No match found
|
|
4997
|
-
*
|
|
4998
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4737
|
+
* Chunk.findLast(chunk, (n) => n > 10) // => Option.none()
|
|
4999
4738
|
*
|
|
5000
4739
|
* // Find last even number
|
|
5001
|
-
*
|
|
5002
|
-
* console.log(Option.getOrElse(lastEven, () => 0)) // 4
|
|
4740
|
+
* Chunk.findLast(chunk, (n) => n % 2 === 0) // => Option.some(4)
|
|
5003
4741
|
* ```
|
|
5004
4742
|
*
|
|
5005
|
-
* @category
|
|
4743
|
+
* @category searching
|
|
5006
4744
|
* @since 2.0.0
|
|
5007
4745
|
*/
|
|
5008
4746
|
<A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Chunk<A>) => Option<B>
|
|
@@ -5011,24 +4749,20 @@ export const findLast: {
|
|
|
5011
4749
|
*
|
|
5012
4750
|
* **Example** (Finding the last matching element)
|
|
5013
4751
|
*
|
|
5014
|
-
* ```ts
|
|
4752
|
+
* ```ts import.meta.vitest
|
|
5015
4753
|
* import { Chunk, Option } from "effect"
|
|
5016
4754
|
*
|
|
5017
4755
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5018
|
-
*
|
|
5019
|
-
* console.log(Option.isSome(result)) // true
|
|
5020
|
-
* console.log(Option.getOrElse(result, () => 0)) // 3
|
|
4756
|
+
* Chunk.findLast(chunk, (n) => n < 4) // => Option.some(3)
|
|
5021
4757
|
*
|
|
5022
4758
|
* // No match found
|
|
5023
|
-
*
|
|
5024
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4759
|
+
* Chunk.findLast(chunk, (n) => n > 10) // => Option.none()
|
|
5025
4760
|
*
|
|
5026
4761
|
* // Find last even number
|
|
5027
|
-
*
|
|
5028
|
-
* console.log(Option.getOrElse(lastEven, () => 0)) // 4
|
|
4762
|
+
* Chunk.findLast(chunk, (n) => n % 2 === 0) // => Option.some(4)
|
|
5029
4763
|
* ```
|
|
5030
4764
|
*
|
|
5031
|
-
* @category
|
|
4765
|
+
* @category searching
|
|
5032
4766
|
* @since 2.0.0
|
|
5033
4767
|
*/
|
|
5034
4768
|
<A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => Option<A>
|
|
@@ -5037,24 +4771,20 @@ export const findLast: {
|
|
|
5037
4771
|
*
|
|
5038
4772
|
* **Example** (Finding the last matching element)
|
|
5039
4773
|
*
|
|
5040
|
-
* ```ts
|
|
4774
|
+
* ```ts import.meta.vitest
|
|
5041
4775
|
* import { Chunk, Option } from "effect"
|
|
5042
4776
|
*
|
|
5043
4777
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5044
|
-
*
|
|
5045
|
-
* console.log(Option.isSome(result)) // true
|
|
5046
|
-
* console.log(Option.getOrElse(result, () => 0)) // 3
|
|
4778
|
+
* Chunk.findLast(chunk, (n) => n < 4) // => Option.some(3)
|
|
5047
4779
|
*
|
|
5048
4780
|
* // No match found
|
|
5049
|
-
*
|
|
5050
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4781
|
+
* Chunk.findLast(chunk, (n) => n > 10) // => Option.none()
|
|
5051
4782
|
*
|
|
5052
4783
|
* // Find last even number
|
|
5053
|
-
*
|
|
5054
|
-
* console.log(Option.getOrElse(lastEven, () => 0)) // 4
|
|
4784
|
+
* Chunk.findLast(chunk, (n) => n % 2 === 0) // => Option.some(4)
|
|
5055
4785
|
* ```
|
|
5056
4786
|
*
|
|
5057
|
-
* @category
|
|
4787
|
+
* @category searching
|
|
5058
4788
|
* @since 2.0.0
|
|
5059
4789
|
*/
|
|
5060
4790
|
<A, B extends A>(self: Chunk<A>, refinement: Refinement<A, B>): Option<B>
|
|
@@ -5063,24 +4793,20 @@ export const findLast: {
|
|
|
5063
4793
|
*
|
|
5064
4794
|
* **Example** (Finding the last matching element)
|
|
5065
4795
|
*
|
|
5066
|
-
* ```ts
|
|
4796
|
+
* ```ts import.meta.vitest
|
|
5067
4797
|
* import { Chunk, Option } from "effect"
|
|
5068
4798
|
*
|
|
5069
4799
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5070
|
-
*
|
|
5071
|
-
* console.log(Option.isSome(result)) // true
|
|
5072
|
-
* console.log(Option.getOrElse(result, () => 0)) // 3
|
|
4800
|
+
* Chunk.findLast(chunk, (n) => n < 4) // => Option.some(3)
|
|
5073
4801
|
*
|
|
5074
4802
|
* // No match found
|
|
5075
|
-
*
|
|
5076
|
-
* console.log(Option.isNone(notFound)) // true
|
|
4803
|
+
* Chunk.findLast(chunk, (n) => n > 10) // => Option.none()
|
|
5077
4804
|
*
|
|
5078
4805
|
* // Find last even number
|
|
5079
|
-
*
|
|
5080
|
-
* console.log(Option.getOrElse(lastEven, () => 0)) // 4
|
|
4806
|
+
* Chunk.findLast(chunk, (n) => n % 2 === 0) // => Option.some(4)
|
|
5081
4807
|
* ```
|
|
5082
4808
|
*
|
|
5083
|
-
* @category
|
|
4809
|
+
* @category searching
|
|
5084
4810
|
* @since 2.0.0
|
|
5085
4811
|
*/
|
|
5086
4812
|
<A>(self: Chunk<A>, predicate: Predicate<A>): Option<A>
|
|
@@ -5091,23 +4817,20 @@ export const findLast: {
|
|
|
5091
4817
|
*
|
|
5092
4818
|
* **Example** (Finding the last matching index)
|
|
5093
4819
|
*
|
|
5094
|
-
* ```ts
|
|
5095
|
-
* import { Chunk } from "effect"
|
|
4820
|
+
* ```ts import.meta.vitest
|
|
4821
|
+
* import { Chunk, Option } from "effect"
|
|
5096
4822
|
*
|
|
5097
4823
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5098
|
-
*
|
|
5099
|
-
* console.log(result) // Option.some(2)
|
|
4824
|
+
* Chunk.findLastIndex(chunk, (n) => n < 4) // => Option.some(2)
|
|
5100
4825
|
*
|
|
5101
4826
|
* // No match found
|
|
5102
|
-
*
|
|
5103
|
-
* console.log(notFound) // Option.none()
|
|
4827
|
+
* Chunk.findLastIndex(chunk, (n) => n > 10) // => Option.none()
|
|
5104
4828
|
*
|
|
5105
4829
|
* // Find last even number index
|
|
5106
|
-
*
|
|
5107
|
-
* console.log(lastEven) // Option.some(3)
|
|
4830
|
+
* Chunk.findLastIndex(chunk, (n) => n % 2 === 0) // => Option.some(3)
|
|
5108
4831
|
* ```
|
|
5109
4832
|
*
|
|
5110
|
-
* @category
|
|
4833
|
+
* @category searching
|
|
5111
4834
|
* @since 2.0.0
|
|
5112
4835
|
*/
|
|
5113
4836
|
export const findLastIndex: {
|
|
@@ -5116,23 +4839,20 @@ export const findLastIndex: {
|
|
|
5116
4839
|
*
|
|
5117
4840
|
* **Example** (Finding the last matching index)
|
|
5118
4841
|
*
|
|
5119
|
-
* ```ts
|
|
5120
|
-
* import { Chunk } from "effect"
|
|
4842
|
+
* ```ts import.meta.vitest
|
|
4843
|
+
* import { Chunk, Option } from "effect"
|
|
5121
4844
|
*
|
|
5122
4845
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5123
|
-
*
|
|
5124
|
-
* console.log(result) // Option.some(2)
|
|
4846
|
+
* Chunk.findLastIndex(chunk, (n) => n < 4) // => Option.some(2)
|
|
5125
4847
|
*
|
|
5126
4848
|
* // No match found
|
|
5127
|
-
*
|
|
5128
|
-
* console.log(notFound) // Option.none()
|
|
4849
|
+
* Chunk.findLastIndex(chunk, (n) => n > 10) // => Option.none()
|
|
5129
4850
|
*
|
|
5130
4851
|
* // Find last even number index
|
|
5131
|
-
*
|
|
5132
|
-
* console.log(lastEven) // Option.some(3)
|
|
4852
|
+
* Chunk.findLastIndex(chunk, (n) => n % 2 === 0) // => Option.some(3)
|
|
5133
4853
|
* ```
|
|
5134
4854
|
*
|
|
5135
|
-
* @category
|
|
4855
|
+
* @category searching
|
|
5136
4856
|
* @since 2.0.0
|
|
5137
4857
|
*/
|
|
5138
4858
|
<A>(predicate: Predicate<A>): (self: Chunk<A>) => O.Option<number>
|
|
@@ -5141,23 +4861,20 @@ export const findLastIndex: {
|
|
|
5141
4861
|
*
|
|
5142
4862
|
* **Example** (Finding the last matching index)
|
|
5143
4863
|
*
|
|
5144
|
-
* ```ts
|
|
5145
|
-
* import { Chunk } from "effect"
|
|
4864
|
+
* ```ts import.meta.vitest
|
|
4865
|
+
* import { Chunk, Option } from "effect"
|
|
5146
4866
|
*
|
|
5147
4867
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5148
|
-
*
|
|
5149
|
-
* console.log(result) // Option.some(2)
|
|
4868
|
+
* Chunk.findLastIndex(chunk, (n) => n < 4) // => Option.some(2)
|
|
5150
4869
|
*
|
|
5151
4870
|
* // No match found
|
|
5152
|
-
*
|
|
5153
|
-
* console.log(notFound) // Option.none()
|
|
4871
|
+
* Chunk.findLastIndex(chunk, (n) => n > 10) // => Option.none()
|
|
5154
4872
|
*
|
|
5155
4873
|
* // Find last even number index
|
|
5156
|
-
*
|
|
5157
|
-
* console.log(lastEven) // Option.some(3)
|
|
4874
|
+
* Chunk.findLastIndex(chunk, (n) => n % 2 === 0) // => Option.some(3)
|
|
5158
4875
|
* ```
|
|
5159
4876
|
*
|
|
5160
|
-
* @category
|
|
4877
|
+
* @category searching
|
|
5161
4878
|
* @since 2.0.0
|
|
5162
4879
|
*/
|
|
5163
4880
|
<A>(self: Chunk<A>, predicate: Predicate<A>): O.Option<number>
|
|
@@ -5171,26 +4888,24 @@ export const findLastIndex: {
|
|
|
5171
4888
|
*
|
|
5172
4889
|
* **Example** (Checking every element)
|
|
5173
4890
|
*
|
|
5174
|
-
* ```ts
|
|
4891
|
+
* ```ts import.meta.vitest
|
|
5175
4892
|
* import { Chunk } from "effect"
|
|
5176
4893
|
*
|
|
5177
4894
|
* const allPositive = Chunk.make(1, 2, 3, 4, 5)
|
|
5178
|
-
*
|
|
5179
|
-
*
|
|
4895
|
+
* Chunk.every(allPositive, (n) => n > 0) // => true
|
|
4896
|
+
* Chunk.every(allPositive, (n) => n > 3) // => false
|
|
5180
4897
|
*
|
|
5181
4898
|
* // Empty chunk returns true
|
|
5182
|
-
*
|
|
5183
|
-
* console.log(Chunk.every(empty, (n) => n > 0)) // true
|
|
4899
|
+
* Chunk.every(Chunk.empty<number>(), (n) => n > 0) // => true
|
|
5184
4900
|
*
|
|
5185
4901
|
* // Type refinement
|
|
5186
4902
|
* const mixed = Chunk.make(1, 2, 3)
|
|
5187
4903
|
* if (Chunk.every(mixed, (x): x is number => typeof x === "number")) {
|
|
5188
4904
|
* // mixed is now typed as Chunk<number>
|
|
5189
|
-
* console.log("All elements are numbers")
|
|
5190
4905
|
* }
|
|
5191
4906
|
* ```
|
|
5192
4907
|
*
|
|
5193
|
-
* @category
|
|
4908
|
+
* @category guards
|
|
5194
4909
|
* @since 2.0.0
|
|
5195
4910
|
*/
|
|
5196
4911
|
export const every: {
|
|
@@ -5199,26 +4914,24 @@ export const every: {
|
|
|
5199
4914
|
*
|
|
5200
4915
|
* **Example** (Checking every element)
|
|
5201
4916
|
*
|
|
5202
|
-
* ```ts
|
|
4917
|
+
* ```ts import.meta.vitest
|
|
5203
4918
|
* import { Chunk } from "effect"
|
|
5204
4919
|
*
|
|
5205
4920
|
* const allPositive = Chunk.make(1, 2, 3, 4, 5)
|
|
5206
|
-
*
|
|
5207
|
-
*
|
|
4921
|
+
* Chunk.every(allPositive, (n) => n > 0) // => true
|
|
4922
|
+
* Chunk.every(allPositive, (n) => n > 3) // => false
|
|
5208
4923
|
*
|
|
5209
4924
|
* // Empty chunk returns true
|
|
5210
|
-
*
|
|
5211
|
-
* console.log(Chunk.every(empty, (n) => n > 0)) // true
|
|
4925
|
+
* Chunk.every(Chunk.empty<number>(), (n) => n > 0) // => true
|
|
5212
4926
|
*
|
|
5213
4927
|
* // Type refinement
|
|
5214
4928
|
* const mixed = Chunk.make(1, 2, 3)
|
|
5215
4929
|
* if (Chunk.every(mixed, (x): x is number => typeof x === "number")) {
|
|
5216
4930
|
* // mixed is now typed as Chunk<number>
|
|
5217
|
-
* console.log("All elements are numbers")
|
|
5218
4931
|
* }
|
|
5219
4932
|
* ```
|
|
5220
4933
|
*
|
|
5221
|
-
* @category
|
|
4934
|
+
* @category guards
|
|
5222
4935
|
* @since 2.0.0
|
|
5223
4936
|
*/
|
|
5224
4937
|
<A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Chunk<A>) => self is Chunk<B>
|
|
@@ -5227,26 +4940,24 @@ export const every: {
|
|
|
5227
4940
|
*
|
|
5228
4941
|
* **Example** (Checking every element)
|
|
5229
4942
|
*
|
|
5230
|
-
* ```ts
|
|
4943
|
+
* ```ts import.meta.vitest
|
|
5231
4944
|
* import { Chunk } from "effect"
|
|
5232
4945
|
*
|
|
5233
4946
|
* const allPositive = Chunk.make(1, 2, 3, 4, 5)
|
|
5234
|
-
*
|
|
5235
|
-
*
|
|
4947
|
+
* Chunk.every(allPositive, (n) => n > 0) // => true
|
|
4948
|
+
* Chunk.every(allPositive, (n) => n > 3) // => false
|
|
5236
4949
|
*
|
|
5237
4950
|
* // Empty chunk returns true
|
|
5238
|
-
*
|
|
5239
|
-
* console.log(Chunk.every(empty, (n) => n > 0)) // true
|
|
4951
|
+
* Chunk.every(Chunk.empty<number>(), (n) => n > 0) // => true
|
|
5240
4952
|
*
|
|
5241
4953
|
* // Type refinement
|
|
5242
4954
|
* const mixed = Chunk.make(1, 2, 3)
|
|
5243
4955
|
* if (Chunk.every(mixed, (x): x is number => typeof x === "number")) {
|
|
5244
4956
|
* // mixed is now typed as Chunk<number>
|
|
5245
|
-
* console.log("All elements are numbers")
|
|
5246
4957
|
* }
|
|
5247
4958
|
* ```
|
|
5248
4959
|
*
|
|
5249
|
-
* @category
|
|
4960
|
+
* @category guards
|
|
5250
4961
|
* @since 2.0.0
|
|
5251
4962
|
*/
|
|
5252
4963
|
<A>(predicate: Predicate<A>): (self: Chunk<A>) => boolean
|
|
@@ -5255,26 +4966,24 @@ export const every: {
|
|
|
5255
4966
|
*
|
|
5256
4967
|
* **Example** (Checking every element)
|
|
5257
4968
|
*
|
|
5258
|
-
* ```ts
|
|
4969
|
+
* ```ts import.meta.vitest
|
|
5259
4970
|
* import { Chunk } from "effect"
|
|
5260
4971
|
*
|
|
5261
4972
|
* const allPositive = Chunk.make(1, 2, 3, 4, 5)
|
|
5262
|
-
*
|
|
5263
|
-
*
|
|
4973
|
+
* Chunk.every(allPositive, (n) => n > 0) // => true
|
|
4974
|
+
* Chunk.every(allPositive, (n) => n > 3) // => false
|
|
5264
4975
|
*
|
|
5265
4976
|
* // Empty chunk returns true
|
|
5266
|
-
*
|
|
5267
|
-
* console.log(Chunk.every(empty, (n) => n > 0)) // true
|
|
4977
|
+
* Chunk.every(Chunk.empty<number>(), (n) => n > 0) // => true
|
|
5268
4978
|
*
|
|
5269
4979
|
* // Type refinement
|
|
5270
4980
|
* const mixed = Chunk.make(1, 2, 3)
|
|
5271
4981
|
* if (Chunk.every(mixed, (x): x is number => typeof x === "number")) {
|
|
5272
4982
|
* // mixed is now typed as Chunk<number>
|
|
5273
|
-
* console.log("All elements are numbers")
|
|
5274
4983
|
* }
|
|
5275
4984
|
* ```
|
|
5276
4985
|
*
|
|
5277
|
-
* @category
|
|
4986
|
+
* @category guards
|
|
5278
4987
|
* @since 2.0.0
|
|
5279
4988
|
*/
|
|
5280
4989
|
<A, B extends A>(self: Chunk<A>, refinement: Refinement<A, B>): self is Chunk<B>
|
|
@@ -5283,26 +4992,24 @@ export const every: {
|
|
|
5283
4992
|
*
|
|
5284
4993
|
* **Example** (Checking every element)
|
|
5285
4994
|
*
|
|
5286
|
-
* ```ts
|
|
4995
|
+
* ```ts import.meta.vitest
|
|
5287
4996
|
* import { Chunk } from "effect"
|
|
5288
4997
|
*
|
|
5289
4998
|
* const allPositive = Chunk.make(1, 2, 3, 4, 5)
|
|
5290
|
-
*
|
|
5291
|
-
*
|
|
4999
|
+
* Chunk.every(allPositive, (n) => n > 0) // => true
|
|
5000
|
+
* Chunk.every(allPositive, (n) => n > 3) // => false
|
|
5292
5001
|
*
|
|
5293
5002
|
* // Empty chunk returns true
|
|
5294
|
-
*
|
|
5295
|
-
* console.log(Chunk.every(empty, (n) => n > 0)) // true
|
|
5003
|
+
* Chunk.every(Chunk.empty<number>(), (n) => n > 0) // => true
|
|
5296
5004
|
*
|
|
5297
5005
|
* // Type refinement
|
|
5298
5006
|
* const mixed = Chunk.make(1, 2, 3)
|
|
5299
5007
|
* if (Chunk.every(mixed, (x): x is number => typeof x === "number")) {
|
|
5300
5008
|
* // mixed is now typed as Chunk<number>
|
|
5301
|
-
* console.log("All elements are numbers")
|
|
5302
5009
|
* }
|
|
5303
5010
|
* ```
|
|
5304
5011
|
*
|
|
5305
|
-
* @category
|
|
5012
|
+
* @category guards
|
|
5306
5013
|
* @since 2.0.0
|
|
5307
5014
|
*/
|
|
5308
5015
|
<A>(self: Chunk<A>, predicate: Predicate<A>): boolean
|
|
@@ -5317,23 +5024,22 @@ export const every: {
|
|
|
5317
5024
|
*
|
|
5318
5025
|
* **Example** (Checking for some matching element)
|
|
5319
5026
|
*
|
|
5320
|
-
* ```ts
|
|
5027
|
+
* ```ts import.meta.vitest
|
|
5321
5028
|
* import { Chunk } from "effect"
|
|
5322
5029
|
*
|
|
5323
5030
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5324
|
-
*
|
|
5325
|
-
*
|
|
5031
|
+
* Chunk.some(chunk, (n) => n > 4) // => true
|
|
5032
|
+
* Chunk.some(chunk, (n) => n > 10) // => false
|
|
5326
5033
|
*
|
|
5327
5034
|
* // Empty chunk returns false
|
|
5328
|
-
*
|
|
5329
|
-
* console.log(Chunk.some(empty, (n) => n > 0)) // false
|
|
5035
|
+
* Chunk.some(Chunk.empty<number>(), (n) => n > 0) // => false
|
|
5330
5036
|
*
|
|
5331
5037
|
* // Check for specific value
|
|
5332
5038
|
* const words = Chunk.make("apple", "banana", "cherry")
|
|
5333
|
-
*
|
|
5039
|
+
* Chunk.some(words, (word) => word.includes("ban")) // => true
|
|
5334
5040
|
* ```
|
|
5335
5041
|
*
|
|
5336
|
-
* @category
|
|
5042
|
+
* @category guards
|
|
5337
5043
|
* @since 2.0.0
|
|
5338
5044
|
*/
|
|
5339
5045
|
export const some: {
|
|
@@ -5342,23 +5048,22 @@ export const some: {
|
|
|
5342
5048
|
*
|
|
5343
5049
|
* **Example** (Checking for some matching element)
|
|
5344
5050
|
*
|
|
5345
|
-
* ```ts
|
|
5051
|
+
* ```ts import.meta.vitest
|
|
5346
5052
|
* import { Chunk } from "effect"
|
|
5347
5053
|
*
|
|
5348
5054
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5349
|
-
*
|
|
5350
|
-
*
|
|
5055
|
+
* Chunk.some(chunk, (n) => n > 4) // => true
|
|
5056
|
+
* Chunk.some(chunk, (n) => n > 10) // => false
|
|
5351
5057
|
*
|
|
5352
5058
|
* // Empty chunk returns false
|
|
5353
|
-
*
|
|
5354
|
-
* console.log(Chunk.some(empty, (n) => n > 0)) // false
|
|
5059
|
+
* Chunk.some(Chunk.empty<number>(), (n) => n > 0) // => false
|
|
5355
5060
|
*
|
|
5356
5061
|
* // Check for specific value
|
|
5357
5062
|
* const words = Chunk.make("apple", "banana", "cherry")
|
|
5358
|
-
*
|
|
5063
|
+
* Chunk.some(words, (word) => word.includes("ban")) // => true
|
|
5359
5064
|
* ```
|
|
5360
5065
|
*
|
|
5361
|
-
* @category
|
|
5066
|
+
* @category guards
|
|
5362
5067
|
* @since 2.0.0
|
|
5363
5068
|
*/
|
|
5364
5069
|
<A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => self is NonEmptyChunk<A>
|
|
@@ -5367,23 +5072,22 @@ export const some: {
|
|
|
5367
5072
|
*
|
|
5368
5073
|
* **Example** (Checking for some matching element)
|
|
5369
5074
|
*
|
|
5370
|
-
* ```ts
|
|
5075
|
+
* ```ts import.meta.vitest
|
|
5371
5076
|
* import { Chunk } from "effect"
|
|
5372
5077
|
*
|
|
5373
5078
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5374
|
-
*
|
|
5375
|
-
*
|
|
5079
|
+
* Chunk.some(chunk, (n) => n > 4) // => true
|
|
5080
|
+
* Chunk.some(chunk, (n) => n > 10) // => false
|
|
5376
5081
|
*
|
|
5377
5082
|
* // Empty chunk returns false
|
|
5378
|
-
*
|
|
5379
|
-
* console.log(Chunk.some(empty, (n) => n > 0)) // false
|
|
5083
|
+
* Chunk.some(Chunk.empty<number>(), (n) => n > 0) // => false
|
|
5380
5084
|
*
|
|
5381
5085
|
* // Check for specific value
|
|
5382
5086
|
* const words = Chunk.make("apple", "banana", "cherry")
|
|
5383
|
-
*
|
|
5087
|
+
* Chunk.some(words, (word) => word.includes("ban")) // => true
|
|
5384
5088
|
* ```
|
|
5385
5089
|
*
|
|
5386
|
-
* @category
|
|
5090
|
+
* @category guards
|
|
5387
5091
|
* @since 2.0.0
|
|
5388
5092
|
*/
|
|
5389
5093
|
<A>(self: Chunk<A>, predicate: Predicate<A>): self is NonEmptyChunk<A>
|
|
@@ -5397,24 +5101,20 @@ export const some: {
|
|
|
5397
5101
|
*
|
|
5398
5102
|
* **Example** (Joining chunks into a string)
|
|
5399
5103
|
*
|
|
5400
|
-
* ```ts
|
|
5104
|
+
* ```ts import.meta.vitest
|
|
5401
5105
|
* import { Chunk } from "effect"
|
|
5402
5106
|
*
|
|
5403
5107
|
* const chunk = Chunk.make("apple", "banana", "cherry")
|
|
5404
|
-
*
|
|
5405
|
-
* console.log(result) // "apple, banana, cherry"
|
|
5108
|
+
* Chunk.join(chunk, ", ") // => "apple, banana, cherry"
|
|
5406
5109
|
*
|
|
5407
5110
|
* // With different separator
|
|
5408
|
-
*
|
|
5409
|
-
* console.log(withPipe) // "apple | banana | cherry"
|
|
5111
|
+
* Chunk.join(chunk, " | ") // => "apple | banana | cherry"
|
|
5410
5112
|
*
|
|
5411
5113
|
* // Empty chunk
|
|
5412
|
-
*
|
|
5413
|
-
* console.log(Chunk.join(empty, ", ")) // ""
|
|
5114
|
+
* Chunk.join(Chunk.empty<string>(), ", ") // => ""
|
|
5414
5115
|
*
|
|
5415
5116
|
* // Single element
|
|
5416
|
-
*
|
|
5417
|
-
* console.log(Chunk.join(single, ", ")) // "hello"
|
|
5117
|
+
* Chunk.join(Chunk.make("hello"), ", ") // => "hello"
|
|
5418
5118
|
* ```
|
|
5419
5119
|
*
|
|
5420
5120
|
* @category folding
|
|
@@ -5426,24 +5126,20 @@ export const join: {
|
|
|
5426
5126
|
*
|
|
5427
5127
|
* **Example** (Joining chunks into a string)
|
|
5428
5128
|
*
|
|
5429
|
-
* ```ts
|
|
5129
|
+
* ```ts import.meta.vitest
|
|
5430
5130
|
* import { Chunk } from "effect"
|
|
5431
5131
|
*
|
|
5432
5132
|
* const chunk = Chunk.make("apple", "banana", "cherry")
|
|
5433
|
-
*
|
|
5434
|
-
* console.log(result) // "apple, banana, cherry"
|
|
5133
|
+
* Chunk.join(chunk, ", ") // => "apple, banana, cherry"
|
|
5435
5134
|
*
|
|
5436
5135
|
* // With different separator
|
|
5437
|
-
*
|
|
5438
|
-
* console.log(withPipe) // "apple | banana | cherry"
|
|
5136
|
+
* Chunk.join(chunk, " | ") // => "apple | banana | cherry"
|
|
5439
5137
|
*
|
|
5440
5138
|
* // Empty chunk
|
|
5441
|
-
*
|
|
5442
|
-
* console.log(Chunk.join(empty, ", ")) // ""
|
|
5139
|
+
* Chunk.join(Chunk.empty<string>(), ", ") // => ""
|
|
5443
5140
|
*
|
|
5444
5141
|
* // Single element
|
|
5445
|
-
*
|
|
5446
|
-
* console.log(Chunk.join(single, ", ")) // "hello"
|
|
5142
|
+
* Chunk.join(Chunk.make("hello"), ", ") // => "hello"
|
|
5447
5143
|
* ```
|
|
5448
5144
|
*
|
|
5449
5145
|
* @category folding
|
|
@@ -5455,24 +5151,20 @@ export const join: {
|
|
|
5455
5151
|
*
|
|
5456
5152
|
* **Example** (Joining chunks into a string)
|
|
5457
5153
|
*
|
|
5458
|
-
* ```ts
|
|
5154
|
+
* ```ts import.meta.vitest
|
|
5459
5155
|
* import { Chunk } from "effect"
|
|
5460
5156
|
*
|
|
5461
5157
|
* const chunk = Chunk.make("apple", "banana", "cherry")
|
|
5462
|
-
*
|
|
5463
|
-
* console.log(result) // "apple, banana, cherry"
|
|
5158
|
+
* Chunk.join(chunk, ", ") // => "apple, banana, cherry"
|
|
5464
5159
|
*
|
|
5465
5160
|
* // With different separator
|
|
5466
|
-
*
|
|
5467
|
-
* console.log(withPipe) // "apple | banana | cherry"
|
|
5161
|
+
* Chunk.join(chunk, " | ") // => "apple | banana | cherry"
|
|
5468
5162
|
*
|
|
5469
5163
|
* // Empty chunk
|
|
5470
|
-
*
|
|
5471
|
-
* console.log(Chunk.join(empty, ", ")) // ""
|
|
5164
|
+
* Chunk.join(Chunk.empty<string>(), ", ") // => ""
|
|
5472
5165
|
*
|
|
5473
5166
|
* // Single element
|
|
5474
|
-
*
|
|
5475
|
-
* console.log(Chunk.join(single, ", ")) // "hello"
|
|
5167
|
+
* Chunk.join(Chunk.make("hello"), ", ") // => "hello"
|
|
5476
5168
|
* ```
|
|
5477
5169
|
*
|
|
5478
5170
|
* @category folding
|
|
@@ -5486,21 +5178,18 @@ export const join: {
|
|
|
5486
5178
|
*
|
|
5487
5179
|
* **Example** (Reducing from the left)
|
|
5488
5180
|
*
|
|
5489
|
-
* ```ts
|
|
5181
|
+
* ```ts import.meta.vitest
|
|
5490
5182
|
* import { Chunk } from "effect"
|
|
5491
5183
|
*
|
|
5492
5184
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5493
|
-
*
|
|
5494
|
-
* console.log(sum) // 15
|
|
5185
|
+
* Chunk.reduce(chunk, 0, (acc, n) => acc + n) // => 15
|
|
5495
5186
|
*
|
|
5496
5187
|
* // String concatenation with index
|
|
5497
5188
|
* const words = Chunk.make("a", "b", "c")
|
|
5498
|
-
*
|
|
5499
|
-
* console.log(result) // "0:a 1:b 2:c "
|
|
5189
|
+
* Chunk.reduce(words, "", (acc, word, i) => acc + `${i}:${word} `).trimEnd() // => "0:a 1:b 2:c"
|
|
5500
5190
|
*
|
|
5501
5191
|
* // Find maximum
|
|
5502
|
-
*
|
|
5503
|
-
* console.log(max) // 5
|
|
5192
|
+
* Chunk.reduce(chunk, -Infinity, (acc, n) => Math.max(acc, n)) // => 5
|
|
5504
5193
|
* ```
|
|
5505
5194
|
*
|
|
5506
5195
|
* @category folding
|
|
@@ -5512,21 +5201,18 @@ export const reduce: {
|
|
|
5512
5201
|
*
|
|
5513
5202
|
* **Example** (Reducing from the left)
|
|
5514
5203
|
*
|
|
5515
|
-
* ```ts
|
|
5204
|
+
* ```ts import.meta.vitest
|
|
5516
5205
|
* import { Chunk } from "effect"
|
|
5517
5206
|
*
|
|
5518
5207
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5519
|
-
*
|
|
5520
|
-
* console.log(sum) // 15
|
|
5208
|
+
* Chunk.reduce(chunk, 0, (acc, n) => acc + n) // => 15
|
|
5521
5209
|
*
|
|
5522
5210
|
* // String concatenation with index
|
|
5523
5211
|
* const words = Chunk.make("a", "b", "c")
|
|
5524
|
-
*
|
|
5525
|
-
* console.log(result) // "0:a 1:b 2:c "
|
|
5212
|
+
* Chunk.reduce(words, "", (acc, word, i) => acc + `${i}:${word} `).trimEnd() // => "0:a 1:b 2:c"
|
|
5526
5213
|
*
|
|
5527
5214
|
* // Find maximum
|
|
5528
|
-
*
|
|
5529
|
-
* console.log(max) // 5
|
|
5215
|
+
* Chunk.reduce(chunk, -Infinity, (acc, n) => Math.max(acc, n)) // => 5
|
|
5530
5216
|
* ```
|
|
5531
5217
|
*
|
|
5532
5218
|
* @category folding
|
|
@@ -5538,21 +5224,18 @@ export const reduce: {
|
|
|
5538
5224
|
*
|
|
5539
5225
|
* **Example** (Reducing from the left)
|
|
5540
5226
|
*
|
|
5541
|
-
* ```ts
|
|
5227
|
+
* ```ts import.meta.vitest
|
|
5542
5228
|
* import { Chunk } from "effect"
|
|
5543
5229
|
*
|
|
5544
5230
|
* const chunk = Chunk.make(1, 2, 3, 4, 5)
|
|
5545
|
-
*
|
|
5546
|
-
* console.log(sum) // 15
|
|
5231
|
+
* Chunk.reduce(chunk, 0, (acc, n) => acc + n) // => 15
|
|
5547
5232
|
*
|
|
5548
5233
|
* // String concatenation with index
|
|
5549
5234
|
* const words = Chunk.make("a", "b", "c")
|
|
5550
|
-
*
|
|
5551
|
-
* console.log(result) // "0:a 1:b 2:c "
|
|
5235
|
+
* Chunk.reduce(words, "", (acc, word, i) => acc + `${i}:${word} `).trimEnd() // => "0:a 1:b 2:c"
|
|
5552
5236
|
*
|
|
5553
5237
|
* // Find maximum
|
|
5554
|
-
*
|
|
5555
|
-
* console.log(max) // 5
|
|
5238
|
+
* Chunk.reduce(chunk, -Infinity, (acc, n) => Math.max(acc, n)) // => 5
|
|
5556
5239
|
* ```
|
|
5557
5240
|
*
|
|
5558
5241
|
* @category folding
|
|
@@ -5566,25 +5249,22 @@ export const reduce: {
|
|
|
5566
5249
|
*
|
|
5567
5250
|
* **Example** (Reducing from the right)
|
|
5568
5251
|
*
|
|
5569
|
-
* ```ts
|
|
5252
|
+
* ```ts import.meta.vitest
|
|
5570
5253
|
* import { Chunk } from "effect"
|
|
5571
5254
|
*
|
|
5572
5255
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
5573
|
-
*
|
|
5574
|
-
* console.log(result) // 10
|
|
5256
|
+
* Chunk.reduceRight(chunk, 0, (acc, n) => acc + n) // => 10
|
|
5575
5257
|
*
|
|
5576
5258
|
* // String building (right to left)
|
|
5577
5259
|
* const words = Chunk.make("a", "b", "c")
|
|
5578
|
-
*
|
|
5260
|
+
* Chunk.reduceRight(
|
|
5579
5261
|
* words,
|
|
5580
5262
|
* "",
|
|
5581
5263
|
* (acc, word, i) => acc + `${i}:${word} `
|
|
5582
|
-
* )
|
|
5583
|
-
* console.log(reversed) // "2:c 1:b 0:a "
|
|
5264
|
+
* ).trim() // => "2:c 1:b 0:a"
|
|
5584
5265
|
*
|
|
5585
5266
|
* // Subtract from right to left
|
|
5586
|
-
*
|
|
5587
|
-
* console.log(subtraction) // -2 (4 - (3 - (2 - (1 - 0))))
|
|
5267
|
+
* Chunk.reduceRight(chunk, 0, (acc, n) => n - acc) // => -2
|
|
5588
5268
|
* ```
|
|
5589
5269
|
*
|
|
5590
5270
|
* @category folding
|
|
@@ -5596,25 +5276,22 @@ export const reduceRight: {
|
|
|
5596
5276
|
*
|
|
5597
5277
|
* **Example** (Reducing from the right)
|
|
5598
5278
|
*
|
|
5599
|
-
* ```ts
|
|
5279
|
+
* ```ts import.meta.vitest
|
|
5600
5280
|
* import { Chunk } from "effect"
|
|
5601
5281
|
*
|
|
5602
5282
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
5603
|
-
*
|
|
5604
|
-
* console.log(result) // 10
|
|
5283
|
+
* Chunk.reduceRight(chunk, 0, (acc, n) => acc + n) // => 10
|
|
5605
5284
|
*
|
|
5606
5285
|
* // String building (right to left)
|
|
5607
5286
|
* const words = Chunk.make("a", "b", "c")
|
|
5608
|
-
*
|
|
5287
|
+
* Chunk.reduceRight(
|
|
5609
5288
|
* words,
|
|
5610
5289
|
* "",
|
|
5611
5290
|
* (acc, word, i) => acc + `${i}:${word} `
|
|
5612
|
-
* )
|
|
5613
|
-
* console.log(reversed) // "2:c 1:b 0:a "
|
|
5291
|
+
* ).trim() // => "2:c 1:b 0:a"
|
|
5614
5292
|
*
|
|
5615
5293
|
* // Subtract from right to left
|
|
5616
|
-
*
|
|
5617
|
-
* console.log(subtraction) // -2 (4 - (3 - (2 - (1 - 0))))
|
|
5294
|
+
* Chunk.reduceRight(chunk, 0, (acc, n) => n - acc) // => -2
|
|
5618
5295
|
* ```
|
|
5619
5296
|
*
|
|
5620
5297
|
* @category folding
|
|
@@ -5626,25 +5303,22 @@ export const reduceRight: {
|
|
|
5626
5303
|
*
|
|
5627
5304
|
* **Example** (Reducing from the right)
|
|
5628
5305
|
*
|
|
5629
|
-
* ```ts
|
|
5306
|
+
* ```ts import.meta.vitest
|
|
5630
5307
|
* import { Chunk } from "effect"
|
|
5631
5308
|
*
|
|
5632
5309
|
* const chunk = Chunk.make(1, 2, 3, 4)
|
|
5633
|
-
*
|
|
5634
|
-
* console.log(result) // 10
|
|
5310
|
+
* Chunk.reduceRight(chunk, 0, (acc, n) => acc + n) // => 10
|
|
5635
5311
|
*
|
|
5636
5312
|
* // String building (right to left)
|
|
5637
5313
|
* const words = Chunk.make("a", "b", "c")
|
|
5638
|
-
*
|
|
5314
|
+
* Chunk.reduceRight(
|
|
5639
5315
|
* words,
|
|
5640
5316
|
* "",
|
|
5641
5317
|
* (acc, word, i) => acc + `${i}:${word} `
|
|
5642
|
-
* )
|
|
5643
|
-
* console.log(reversed) // "2:c 1:b 0:a "
|
|
5318
|
+
* ).trim() // => "2:c 1:b 0:a"
|
|
5644
5319
|
*
|
|
5645
5320
|
* // Subtract from right to left
|
|
5646
|
-
*
|
|
5647
|
-
* console.log(subtraction) // -2 (4 - (3 - (2 - (1 - 0))))
|
|
5321
|
+
* Chunk.reduceRight(chunk, 0, (acc, n) => n - acc) // => -2
|
|
5648
5322
|
* ```
|
|
5649
5323
|
*
|
|
5650
5324
|
* @category folding
|
|
@@ -5659,7 +5333,7 @@ export const reduceRight: {
|
|
|
5659
5333
|
*
|
|
5660
5334
|
* **Example** (Computing difference with custom equivalence)
|
|
5661
5335
|
*
|
|
5662
|
-
* ```ts
|
|
5336
|
+
* ```ts import.meta.vitest
|
|
5663
5337
|
* import { Chunk } from "effect"
|
|
5664
5338
|
*
|
|
5665
5339
|
* const chunk1 = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" })
|
|
@@ -5669,8 +5343,7 @@ export const reduceRight: {
|
|
|
5669
5343
|
* const byId = Chunk.differenceWith<{ id: number; name: string }>((a, b) =>
|
|
5670
5344
|
* a.id === b.id
|
|
5671
5345
|
* )
|
|
5672
|
-
*
|
|
5673
|
-
* console.log(Chunk.toArray(result)) // [{ id: 2, name: "Bob" }]
|
|
5346
|
+
* Chunk.toArray(byId(chunk1, chunk2)) // => [{ id: 2, name: "Bob" }]
|
|
5674
5347
|
*
|
|
5675
5348
|
* // String comparison case-insensitive
|
|
5676
5349
|
* const words1 = Chunk.make("Apple", "Banana", "Cherry")
|
|
@@ -5678,8 +5351,7 @@ export const reduceRight: {
|
|
|
5678
5351
|
* const caseInsensitive = Chunk.differenceWith<string>((a, b) =>
|
|
5679
5352
|
* a.toLowerCase() === b.toLowerCase()
|
|
5680
5353
|
* )
|
|
5681
|
-
*
|
|
5682
|
-
* console.log(Chunk.toArray(wordDiff)) // ["Banana", "Cherry"]
|
|
5354
|
+
* Chunk.toArray(caseInsensitive(words1, words2)) // => ["Banana", "Cherry"]
|
|
5683
5355
|
* ```
|
|
5684
5356
|
*
|
|
5685
5357
|
* @category filtering
|
|
@@ -5701,24 +5373,20 @@ export const differenceWith = <A>(isEquivalent: (self: A, that: A) => boolean):
|
|
|
5701
5373
|
*
|
|
5702
5374
|
* **Example** (Computing chunk difference)
|
|
5703
5375
|
*
|
|
5704
|
-
* ```ts
|
|
5376
|
+
* ```ts import.meta.vitest
|
|
5705
5377
|
* import { Chunk } from "effect"
|
|
5706
5378
|
*
|
|
5707
5379
|
* const chunk1 = Chunk.make(1, 2, 3, 4, 5)
|
|
5708
5380
|
* const chunk2 = Chunk.make(3, 4, 6, 7)
|
|
5709
|
-
*
|
|
5710
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 5]
|
|
5381
|
+
* Chunk.toArray(Chunk.difference(chunk1, chunk2)) // => [1, 2, 5]
|
|
5711
5382
|
*
|
|
5712
5383
|
* // String difference
|
|
5713
5384
|
* const words1 = Chunk.make("apple", "banana", "cherry")
|
|
5714
5385
|
* const words2 = Chunk.make("banana", "grape")
|
|
5715
|
-
*
|
|
5716
|
-
* console.log(Chunk.toArray(wordDiff)) // ["apple", "cherry"]
|
|
5386
|
+
* Chunk.toArray(Chunk.difference(words1, words2)) // => ["apple", "cherry"]
|
|
5717
5387
|
*
|
|
5718
5388
|
* // Empty second chunk returns original
|
|
5719
|
-
*
|
|
5720
|
-
* const unchanged = Chunk.difference(chunk1, empty)
|
|
5721
|
-
* console.log(Chunk.toArray(unchanged)) // [1, 2, 3, 4, 5]
|
|
5389
|
+
* Chunk.toArray(Chunk.difference(chunk1, Chunk.empty<number>())) // => [1, 2, 3, 4, 5]
|
|
5722
5390
|
* ```
|
|
5723
5391
|
*
|
|
5724
5392
|
* @category filtering
|
|
@@ -5731,24 +5399,20 @@ export const difference: {
|
|
|
5731
5399
|
*
|
|
5732
5400
|
* **Example** (Computing chunk difference)
|
|
5733
5401
|
*
|
|
5734
|
-
* ```ts
|
|
5402
|
+
* ```ts import.meta.vitest
|
|
5735
5403
|
* import { Chunk } from "effect"
|
|
5736
5404
|
*
|
|
5737
5405
|
* const chunk1 = Chunk.make(1, 2, 3, 4, 5)
|
|
5738
5406
|
* const chunk2 = Chunk.make(3, 4, 6, 7)
|
|
5739
|
-
*
|
|
5740
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 5]
|
|
5407
|
+
* Chunk.toArray(Chunk.difference(chunk1, chunk2)) // => [1, 2, 5]
|
|
5741
5408
|
*
|
|
5742
5409
|
* // String difference
|
|
5743
5410
|
* const words1 = Chunk.make("apple", "banana", "cherry")
|
|
5744
5411
|
* const words2 = Chunk.make("banana", "grape")
|
|
5745
|
-
*
|
|
5746
|
-
* console.log(Chunk.toArray(wordDiff)) // ["apple", "cherry"]
|
|
5412
|
+
* Chunk.toArray(Chunk.difference(words1, words2)) // => ["apple", "cherry"]
|
|
5747
5413
|
*
|
|
5748
5414
|
* // Empty second chunk returns original
|
|
5749
|
-
*
|
|
5750
|
-
* const unchanged = Chunk.difference(chunk1, empty)
|
|
5751
|
-
* console.log(Chunk.toArray(unchanged)) // [1, 2, 3, 4, 5]
|
|
5415
|
+
* Chunk.toArray(Chunk.difference(chunk1, Chunk.empty<number>())) // => [1, 2, 3, 4, 5]
|
|
5752
5416
|
* ```
|
|
5753
5417
|
*
|
|
5754
5418
|
* @category filtering
|
|
@@ -5761,24 +5425,20 @@ export const difference: {
|
|
|
5761
5425
|
*
|
|
5762
5426
|
* **Example** (Computing chunk difference)
|
|
5763
5427
|
*
|
|
5764
|
-
* ```ts
|
|
5428
|
+
* ```ts import.meta.vitest
|
|
5765
5429
|
* import { Chunk } from "effect"
|
|
5766
5430
|
*
|
|
5767
5431
|
* const chunk1 = Chunk.make(1, 2, 3, 4, 5)
|
|
5768
5432
|
* const chunk2 = Chunk.make(3, 4, 6, 7)
|
|
5769
|
-
*
|
|
5770
|
-
* console.log(Chunk.toArray(result)) // [1, 2, 5]
|
|
5433
|
+
* Chunk.toArray(Chunk.difference(chunk1, chunk2)) // => [1, 2, 5]
|
|
5771
5434
|
*
|
|
5772
5435
|
* // String difference
|
|
5773
5436
|
* const words1 = Chunk.make("apple", "banana", "cherry")
|
|
5774
5437
|
* const words2 = Chunk.make("banana", "grape")
|
|
5775
|
-
*
|
|
5776
|
-
* console.log(Chunk.toArray(wordDiff)) // ["apple", "cherry"]
|
|
5438
|
+
* Chunk.toArray(Chunk.difference(words1, words2)) // => ["apple", "cherry"]
|
|
5777
5439
|
*
|
|
5778
5440
|
* // Empty second chunk returns original
|
|
5779
|
-
*
|
|
5780
|
-
* const unchanged = Chunk.difference(chunk1, empty)
|
|
5781
|
-
* console.log(Chunk.toArray(unchanged)) // [1, 2, 3, 4, 5]
|
|
5441
|
+
* Chunk.toArray(Chunk.difference(chunk1, Chunk.empty<number>())) // => [1, 2, 3, 4, 5]
|
|
5782
5442
|
* ```
|
|
5783
5443
|
*
|
|
5784
5444
|
* @category filtering
|