@clayroach/effect 3.19.14-source-capture.7 → 3.19.14-source-capture.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +0 -1101
- package/src/Array.ts +0 -3589
- package/src/BigDecimal.ts +0 -1349
- package/src/BigInt.ts +0 -643
- package/src/Boolean.ts +0 -287
- package/src/Brand.ts +0 -360
- package/src/Cache.ts +0 -281
- package/src/Cause.ts +0 -1555
- package/src/Channel.ts +0 -2355
- package/src/ChildExecutorDecision.ts +0 -146
- package/src/Chunk.ts +0 -1495
- package/src/Clock.ts +0 -111
- package/src/Config.ts +0 -542
- package/src/ConfigError.ts +0 -270
- package/src/ConfigProvider.ts +0 -333
- package/src/ConfigProviderPathPatch.ts +0 -100
- package/src/Console.ts +0 -226
- package/src/Context.ts +0 -585
- package/src/Cron.ts +0 -706
- package/src/Data.ts +0 -596
- package/src/DateTime.ts +0 -1686
- package/src/DefaultServices.ts +0 -34
- package/src/Deferred.ts +0 -301
- package/src/Differ.ts +0 -450
- package/src/Duration.ts +0 -1000
- package/src/Effect.ts +0 -14839
- package/src/Effectable.ts +0 -107
- package/src/Either.ts +0 -1040
- package/src/Encoding.ts +0 -195
- package/src/Equal.ts +0 -98
- package/src/Equivalence.ts +0 -235
- package/src/ExecutionPlan.ts +0 -308
- package/src/ExecutionStrategy.ts +0 -119
- package/src/Exit.ts +0 -467
- package/src/FastCheck.ts +0 -9
- package/src/Fiber.ts +0 -744
- package/src/FiberHandle.ts +0 -540
- package/src/FiberId.ts +0 -195
- package/src/FiberMap.ts +0 -656
- package/src/FiberRef.ts +0 -431
- package/src/FiberRefs.ts +0 -204
- package/src/FiberRefsPatch.ts +0 -105
- package/src/FiberSet.ts +0 -491
- package/src/FiberStatus.ts +0 -108
- package/src/Function.ts +0 -1222
- package/src/GlobalValue.ts +0 -53
- package/src/Graph.ts +0 -3732
- package/src/GroupBy.ts +0 -103
- package/src/HKT.ts +0 -45
- package/src/Hash.ts +0 -195
- package/src/HashMap.ts +0 -519
- package/src/HashRing.ts +0 -317
- package/src/HashSet.ts +0 -2346
- package/src/Inspectable.ts +0 -287
- package/src/Iterable.ts +0 -1119
- package/src/JSONSchema.ts +0 -1044
- package/src/KeyedPool.ts +0 -167
- package/src/Layer.ts +0 -1251
- package/src/LayerMap.ts +0 -436
- package/src/List.ts +0 -977
- package/src/LogLevel.ts +0 -285
- package/src/LogSpan.ts +0 -25
- package/src/Logger.ts +0 -702
- package/src/Mailbox.ts +0 -268
- package/src/ManagedRuntime.ts +0 -180
- package/src/Match.ts +0 -1477
- package/src/MergeDecision.ts +0 -95
- package/src/MergeState.ts +0 -172
- package/src/MergeStrategy.ts +0 -107
- package/src/Metric.ts +0 -780
- package/src/MetricBoundaries.ts +0 -69
- package/src/MetricHook.ts +0 -151
- package/src/MetricKey.ts +0 -224
- package/src/MetricKeyType.ts +0 -262
- package/src/MetricLabel.ts +0 -47
- package/src/MetricPair.ts +0 -71
- package/src/MetricPolling.ts +0 -148
- package/src/MetricRegistry.ts +0 -48
- package/src/MetricState.ts +0 -257
- package/src/Micro.ts +0 -4405
- package/src/ModuleVersion.ts +0 -18
- package/src/MutableHashMap.ts +0 -411
- package/src/MutableHashSet.ts +0 -706
- package/src/MutableList.ts +0 -297
- package/src/MutableQueue.ts +0 -227
- package/src/MutableRef.ts +0 -202
- package/src/NonEmptyIterable.ts +0 -32
- package/src/Number.ts +0 -1071
- package/src/Option.ts +0 -2170
- package/src/Order.ts +0 -373
- package/src/Ordering.ts +0 -111
- package/src/ParseResult.ts +0 -2031
- package/src/PartitionedSemaphore.ts +0 -200
- package/src/Pipeable.ts +0 -566
- package/src/Pool.ts +0 -204
- package/src/Predicate.ts +0 -1405
- package/src/Pretty.ts +0 -205
- package/src/PrimaryKey.ts +0 -23
- package/src/PubSub.ts +0 -182
- package/src/Queue.ts +0 -644
- package/src/Random.ts +0 -204
- package/src/RateLimiter.ts +0 -138
- package/src/RcMap.ts +0 -141
- package/src/RcRef.ts +0 -122
- package/src/Readable.ts +0 -93
- package/src/Record.ts +0 -1274
- package/src/RedBlackTree.ts +0 -421
- package/src/Redacted.ts +0 -144
- package/src/Ref.ts +0 -180
- package/src/RegExp.ts +0 -38
- package/src/Reloadable.ts +0 -127
- package/src/Request.ts +0 -347
- package/src/RequestBlock.ts +0 -118
- package/src/RequestResolver.ts +0 -366
- package/src/Resource.ts +0 -119
- package/src/Runtime.ts +0 -383
- package/src/RuntimeFlags.ts +0 -368
- package/src/RuntimeFlagsPatch.ts +0 -183
- package/src/STM.ts +0 -2045
- package/src/Schedule.ts +0 -2219
- package/src/ScheduleDecision.ts +0 -62
- package/src/ScheduleInterval.ts +0 -151
- package/src/ScheduleIntervals.ts +0 -122
- package/src/Scheduler.ts +0 -353
- package/src/Schema.ts +0 -10914
- package/src/SchemaAST.ts +0 -3043
- package/src/Scope.ts +0 -204
- package/src/ScopedCache.ts +0 -151
- package/src/ScopedRef.ts +0 -117
- package/src/Secret.ts +0 -88
- package/src/SingleProducerAsyncInput.ts +0 -67
- package/src/Sink.ts +0 -1461
- package/src/SortedMap.ts +0 -287
- package/src/SortedSet.ts +0 -390
- package/src/Stream.ts +0 -6468
- package/src/StreamEmit.ts +0 -136
- package/src/StreamHaltStrategy.ts +0 -123
- package/src/Streamable.ts +0 -45
- package/src/String.ts +0 -778
- package/src/Struct.ts +0 -243
- package/src/Subscribable.ts +0 -100
- package/src/SubscriptionRef.ts +0 -298
- package/src/Supervisor.ts +0 -240
- package/src/Symbol.ts +0 -29
- package/src/SynchronizedRef.ts +0 -270
- package/src/TArray.ts +0 -495
- package/src/TDeferred.ts +0 -100
- package/src/TMap.ts +0 -515
- package/src/TPriorityQueue.ts +0 -223
- package/src/TPubSub.ts +0 -200
- package/src/TQueue.ts +0 -432
- package/src/TRandom.ts +0 -129
- package/src/TReentrantLock.ts +0 -224
- package/src/TRef.ts +0 -178
- package/src/TSemaphore.ts +0 -129
- package/src/TSet.ts +0 -365
- package/src/TSubscriptionRef.ts +0 -192
- package/src/Take.ts +0 -258
- package/src/TestAnnotation.ts +0 -158
- package/src/TestAnnotationMap.ts +0 -119
- package/src/TestAnnotations.ts +0 -117
- package/src/TestClock.ts +0 -556
- package/src/TestConfig.ts +0 -47
- package/src/TestContext.ts +0 -36
- package/src/TestLive.ts +0 -53
- package/src/TestServices.ts +0 -390
- package/src/TestSized.ts +0 -55
- package/src/Tracer.ts +0 -198
- package/src/Trie.ts +0 -840
- package/src/Tuple.ts +0 -305
- package/src/Types.ts +0 -353
- package/src/Unify.ts +0 -113
- package/src/UpstreamPullRequest.ts +0 -117
- package/src/UpstreamPullStrategy.ts +0 -121
- package/src/Utils.ts +0 -809
- package/src/index.ts +0 -1561
- package/src/internal/array.ts +0 -8
- package/src/internal/blockedRequests.ts +0 -520
- package/src/internal/cache.ts +0 -733
- package/src/internal/cause.ts +0 -1050
- package/src/internal/channel/channelExecutor.ts +0 -1200
- package/src/internal/channel/channelState.ts +0 -134
- package/src/internal/channel/childExecutorDecision.ts +0 -96
- package/src/internal/channel/continuation.ts +0 -200
- package/src/internal/channel/mergeDecision.ts +0 -113
- package/src/internal/channel/mergeState.ts +0 -120
- package/src/internal/channel/mergeStrategy.ts +0 -72
- package/src/internal/channel/singleProducerAsyncInput.ts +0 -259
- package/src/internal/channel/subexecutor.ts +0 -229
- package/src/internal/channel/upstreamPullRequest.ts +0 -84
- package/src/internal/channel/upstreamPullStrategy.ts +0 -87
- package/src/internal/channel.ts +0 -2603
- package/src/internal/clock.ts +0 -95
- package/src/internal/completedRequestMap.ts +0 -9
- package/src/internal/concurrency.ts +0 -54
- package/src/internal/config.ts +0 -716
- package/src/internal/configError.ts +0 -304
- package/src/internal/configProvider/pathPatch.ts +0 -97
- package/src/internal/configProvider.ts +0 -799
- package/src/internal/console.ts +0 -153
- package/src/internal/context.ts +0 -337
- package/src/internal/core-effect.ts +0 -2293
- package/src/internal/core-stream.ts +0 -998
- package/src/internal/core.ts +0 -3273
- package/src/internal/data.ts +0 -36
- package/src/internal/dataSource.ts +0 -327
- package/src/internal/dateTime.ts +0 -1277
- package/src/internal/defaultServices/console.ts +0 -100
- package/src/internal/defaultServices.ts +0 -163
- package/src/internal/deferred.ts +0 -46
- package/src/internal/differ/chunkPatch.ts +0 -211
- package/src/internal/differ/contextPatch.ts +0 -232
- package/src/internal/differ/hashMapPatch.ts +0 -220
- package/src/internal/differ/hashSetPatch.ts +0 -176
- package/src/internal/differ/orPatch.ts +0 -311
- package/src/internal/differ/readonlyArrayPatch.ts +0 -210
- package/src/internal/differ.ts +0 -200
- package/src/internal/doNotation.ts +0 -80
- package/src/internal/effect/circular.ts +0 -905
- package/src/internal/effectable.ts +0 -131
- package/src/internal/either.ts +0 -110
- package/src/internal/encoding/base64.ts +0 -286
- package/src/internal/encoding/base64Url.ts +0 -29
- package/src/internal/encoding/common.ts +0 -51
- package/src/internal/encoding/hex.ts +0 -315
- package/src/internal/errors.ts +0 -7
- package/src/internal/executionPlan.ts +0 -114
- package/src/internal/executionStrategy.ts +0 -74
- package/src/internal/fiber.ts +0 -388
- package/src/internal/fiberId.ts +0 -267
- package/src/internal/fiberMessage.ts +0 -82
- package/src/internal/fiberRefs/patch.ts +0 -144
- package/src/internal/fiberRefs.ts +0 -297
- package/src/internal/fiberRuntime.ts +0 -3915
- package/src/internal/fiberScope.ts +0 -71
- package/src/internal/fiberStatus.ts +0 -119
- package/src/internal/groupBy.ts +0 -530
- package/src/internal/hashMap/array.ts +0 -49
- package/src/internal/hashMap/bitwise.ts +0 -32
- package/src/internal/hashMap/config.ts +0 -14
- package/src/internal/hashMap/keySet.ts +0 -8
- package/src/internal/hashMap/node.ts +0 -391
- package/src/internal/hashMap.ts +0 -586
- package/src/internal/hashSet.ts +0 -323
- package/src/internal/keyedPool.ts +0 -244
- package/src/internal/layer/circular.ts +0 -228
- package/src/internal/layer.ts +0 -1487
- package/src/internal/logSpan.ts +0 -20
- package/src/internal/logger-circular.ts +0 -24
- package/src/internal/logger.ts +0 -485
- package/src/internal/mailbox.ts +0 -561
- package/src/internal/managedRuntime/circular.ts +0 -6
- package/src/internal/managedRuntime.ts +0 -134
- package/src/internal/matcher.ts +0 -652
- package/src/internal/metric/boundaries.ts +0 -75
- package/src/internal/metric/hook.ts +0 -483
- package/src/internal/metric/key.ts +0 -167
- package/src/internal/metric/keyType.ts +0 -238
- package/src/internal/metric/label.ts +0 -41
- package/src/internal/metric/pair.ts +0 -48
- package/src/internal/metric/polling.ts +0 -149
- package/src/internal/metric/registry.ts +0 -187
- package/src/internal/metric/state.ts +0 -290
- package/src/internal/metric.ts +0 -577
- package/src/internal/opCodes/cause.ts +0 -35
- package/src/internal/opCodes/channel.ts +0 -83
- package/src/internal/opCodes/channelChildExecutorDecision.ts +0 -17
- package/src/internal/opCodes/channelMergeDecision.ts +0 -11
- package/src/internal/opCodes/channelMergeState.ts +0 -17
- package/src/internal/opCodes/channelMergeStrategy.ts +0 -11
- package/src/internal/opCodes/channelState.ts +0 -23
- package/src/internal/opCodes/channelUpstreamPullRequest.ts +0 -11
- package/src/internal/opCodes/channelUpstreamPullStrategy.ts +0 -11
- package/src/internal/opCodes/config.ts +0 -65
- package/src/internal/opCodes/configError.ts +0 -35
- package/src/internal/opCodes/continuation.ts +0 -11
- package/src/internal/opCodes/deferred.ts +0 -11
- package/src/internal/opCodes/effect.ts +0 -89
- package/src/internal/opCodes/layer.ts +0 -59
- package/src/internal/opCodes/streamHaltStrategy.ts +0 -23
- package/src/internal/option.ts +0 -80
- package/src/internal/pool.ts +0 -432
- package/src/internal/pubsub.ts +0 -1762
- package/src/internal/query.ts +0 -204
- package/src/internal/queue.ts +0 -766
- package/src/internal/random.ts +0 -161
- package/src/internal/rateLimiter.ts +0 -93
- package/src/internal/rcMap.ts +0 -285
- package/src/internal/rcRef.ts +0 -192
- package/src/internal/redBlackTree/iterator.ts +0 -200
- package/src/internal/redBlackTree/node.ts +0 -68
- package/src/internal/redBlackTree.ts +0 -1245
- package/src/internal/redacted.ts +0 -73
- package/src/internal/ref.ts +0 -171
- package/src/internal/reloadable.ts +0 -140
- package/src/internal/request.ts +0 -177
- package/src/internal/resource.ts +0 -76
- package/src/internal/ringBuffer.ts +0 -68
- package/src/internal/runtime.ts +0 -558
- package/src/internal/runtimeFlags.ts +0 -188
- package/src/internal/runtimeFlagsPatch.ts +0 -103
- package/src/internal/schedule/decision.ts +0 -47
- package/src/internal/schedule/interval.ts +0 -101
- package/src/internal/schedule/intervals.ts +0 -180
- package/src/internal/schedule.ts +0 -2199
- package/src/internal/schema/errors.ts +0 -191
- package/src/internal/schema/schemaId.ts +0 -106
- package/src/internal/schema/util.ts +0 -50
- package/src/internal/scopedCache.ts +0 -644
- package/src/internal/scopedRef.ts +0 -118
- package/src/internal/secret.ts +0 -89
- package/src/internal/singleShotGen.ts +0 -35
- package/src/internal/sink.ts +0 -2120
- package/src/internal/stack.ts +0 -10
- package/src/internal/stm/core.ts +0 -817
- package/src/internal/stm/entry.ts +0 -59
- package/src/internal/stm/journal.ts +0 -123
- package/src/internal/stm/opCodes/stm.ts +0 -71
- package/src/internal/stm/opCodes/stmState.ts +0 -17
- package/src/internal/stm/opCodes/strategy.ts +0 -17
- package/src/internal/stm/opCodes/tExit.ts +0 -29
- package/src/internal/stm/opCodes/tryCommit.ts +0 -11
- package/src/internal/stm/stm.ts +0 -1453
- package/src/internal/stm/stmState.ts +0 -136
- package/src/internal/stm/tArray.ts +0 -550
- package/src/internal/stm/tDeferred.ts +0 -81
- package/src/internal/stm/tExit.ts +0 -190
- package/src/internal/stm/tMap.ts +0 -824
- package/src/internal/stm/tPriorityQueue.ts +0 -267
- package/src/internal/stm/tPubSub.ts +0 -551
- package/src/internal/stm/tQueue.ts +0 -393
- package/src/internal/stm/tRandom.ts +0 -140
- package/src/internal/stm/tReentrantLock.ts +0 -352
- package/src/internal/stm/tRef.ts +0 -195
- package/src/internal/stm/tSemaphore.ts +0 -113
- package/src/internal/stm/tSet.ts +0 -259
- package/src/internal/stm/tSubscriptionRef.ts +0 -286
- package/src/internal/stm/tryCommit.ts +0 -34
- package/src/internal/stm/txnId.ts +0 -14
- package/src/internal/stm/versioned.ts +0 -4
- package/src/internal/stream/debounceState.ts +0 -57
- package/src/internal/stream/emit.ts +0 -123
- package/src/internal/stream/haltStrategy.ts +0 -94
- package/src/internal/stream/handoff.ts +0 -187
- package/src/internal/stream/handoffSignal.ts +0 -59
- package/src/internal/stream/pull.ts +0 -34
- package/src/internal/stream/sinkEndReason.ts +0 -30
- package/src/internal/stream/zipAllState.ts +0 -88
- package/src/internal/stream/zipChunksState.ts +0 -56
- package/src/internal/stream.ts +0 -8801
- package/src/internal/string-utils.ts +0 -107
- package/src/internal/subscriptionRef.ts +0 -138
- package/src/internal/supervisor/patch.ts +0 -190
- package/src/internal/supervisor.ts +0 -303
- package/src/internal/synchronizedRef.ts +0 -114
- package/src/internal/take.ts +0 -199
- package/src/internal/testing/sleep.ts +0 -27
- package/src/internal/testing/suspendedWarningData.ts +0 -85
- package/src/internal/testing/warningData.ts +0 -94
- package/src/internal/tracer.ts +0 -293
- package/src/internal/trie.ts +0 -722
- package/src/internal/version.ts +0 -7
package/src/SortedMap.ts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 2.0.0
|
|
3
|
-
*/
|
|
4
|
-
import * as Equal from "./Equal.js"
|
|
5
|
-
import * as Dual from "./Function.js"
|
|
6
|
-
import { pipe } from "./Function.js"
|
|
7
|
-
import * as Hash from "./Hash.js"
|
|
8
|
-
import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js"
|
|
9
|
-
import * as Option from "./Option.js"
|
|
10
|
-
import type { Order } from "./Order.js"
|
|
11
|
-
import type { Pipeable } from "./Pipeable.js"
|
|
12
|
-
import { pipeArguments } from "./Pipeable.js"
|
|
13
|
-
import { hasProperty } from "./Predicate.js"
|
|
14
|
-
import * as RBT from "./RedBlackTree.js"
|
|
15
|
-
import type * as Types from "./Types.js"
|
|
16
|
-
|
|
17
|
-
const TypeId: unique symbol = Symbol.for("effect/SortedMap")
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @since 2.0.0
|
|
21
|
-
* @category symbol
|
|
22
|
-
*/
|
|
23
|
-
export type TypeId = typeof TypeId
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @since 2.0.0
|
|
27
|
-
* @category models
|
|
28
|
-
*/
|
|
29
|
-
export interface SortedMap<in out K, out V> extends Iterable<[K, V]>, Equal.Equal, Pipeable, Inspectable {
|
|
30
|
-
readonly [TypeId]: {
|
|
31
|
-
readonly _K: Types.Invariant<K>
|
|
32
|
-
readonly _V: Types.Covariant<V>
|
|
33
|
-
}
|
|
34
|
-
/** @internal */
|
|
35
|
-
readonly tree: RBT.RedBlackTree<K, V>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const SortedMapProto: Omit<SortedMap<unknown, unknown>, "tree"> = {
|
|
39
|
-
[TypeId]: {
|
|
40
|
-
_K: (_: any) => _,
|
|
41
|
-
_V: (_: never) => _
|
|
42
|
-
},
|
|
43
|
-
[Hash.symbol]<K, V>(this: SortedMap<K, V>): number {
|
|
44
|
-
return pipe(
|
|
45
|
-
Hash.hash(this.tree),
|
|
46
|
-
Hash.combine(Hash.hash("effect/SortedMap")),
|
|
47
|
-
Hash.cached(this)
|
|
48
|
-
)
|
|
49
|
-
},
|
|
50
|
-
[Equal.symbol]<K, V>(this: SortedMap<K, V>, that: unknown): boolean {
|
|
51
|
-
return isSortedMap(that) && Equal.equals(this.tree, that.tree)
|
|
52
|
-
},
|
|
53
|
-
[Symbol.iterator]<K, V>(this: SortedMap<K, V>): Iterator<[K, V]> {
|
|
54
|
-
return this.tree[Symbol.iterator]()
|
|
55
|
-
},
|
|
56
|
-
toString() {
|
|
57
|
-
return format(this.toJSON())
|
|
58
|
-
},
|
|
59
|
-
toJSON() {
|
|
60
|
-
return {
|
|
61
|
-
_id: "SortedMap",
|
|
62
|
-
values: Array.from(this).map(toJSON)
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[NodeInspectSymbol]() {
|
|
66
|
-
return this.toJSON()
|
|
67
|
-
},
|
|
68
|
-
pipe() {
|
|
69
|
-
return pipeArguments(this, arguments)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const makeImpl = <K, V>(tree: RBT.RedBlackTree<K, V>): SortedMap<K, V> => {
|
|
74
|
-
const self = Object.create(SortedMapProto)
|
|
75
|
-
self.tree = tree
|
|
76
|
-
return self
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @since 2.0.0
|
|
81
|
-
* @category refinements
|
|
82
|
-
*/
|
|
83
|
-
export const isSortedMap: {
|
|
84
|
-
<K, V>(u: Iterable<readonly [K, V]>): u is SortedMap<K, V>
|
|
85
|
-
(u: unknown): u is SortedMap<unknown, unknown>
|
|
86
|
-
} = (u: unknown): u is SortedMap<unknown, unknown> => hasProperty(u, TypeId)
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @since 2.0.0
|
|
90
|
-
* @category constructors
|
|
91
|
-
*/
|
|
92
|
-
export const empty = <K, V = never>(ord: Order<K>): SortedMap<K, V> => makeImpl<K, V>(RBT.empty<K, V>(ord))
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Creates a new `SortedMap` from an iterable collection of key/value pairs.
|
|
96
|
-
*
|
|
97
|
-
* @since 2.0.0
|
|
98
|
-
* @category constructors
|
|
99
|
-
*/
|
|
100
|
-
export const fromIterable: {
|
|
101
|
-
<B>(ord: Order<B>): <K extends B, V>(iterable: Iterable<readonly [K, V]>) => SortedMap<K, V>
|
|
102
|
-
<K extends B, V, B>(iterable: Iterable<readonly [K, V]>, ord: Order<B>): SortedMap<K, V>
|
|
103
|
-
} = Dual.dual(
|
|
104
|
-
2,
|
|
105
|
-
<K extends B, V, B>(iterable: Iterable<readonly [K, V]>, ord: Order<B>): SortedMap<K, V> =>
|
|
106
|
-
makeImpl(RBT.fromIterable(iterable, ord))
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @since 2.0.0
|
|
111
|
-
* @category constructors
|
|
112
|
-
*/
|
|
113
|
-
export const make =
|
|
114
|
-
<K>(ord: Order<K>) =>
|
|
115
|
-
<Entries extends ReadonlyArray<readonly [K, any]>>(...entries: Entries): SortedMap<
|
|
116
|
-
K,
|
|
117
|
-
Entries[number] extends (readonly [any, infer V]) ? V : never
|
|
118
|
-
> => fromIterable(ord)(entries)
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @since 2.0.0
|
|
122
|
-
* @category predicates
|
|
123
|
-
*/
|
|
124
|
-
export const isEmpty = <K, V>(self: SortedMap<K, V>): boolean => size(self) === 0
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @since 2.0.0
|
|
128
|
-
* @category predicates
|
|
129
|
-
*/
|
|
130
|
-
export const isNonEmpty = <K, V>(self: SortedMap<K, V>): boolean => size(self) > 0
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @since 2.0.0
|
|
134
|
-
* @category elements
|
|
135
|
-
*/
|
|
136
|
-
export const get: {
|
|
137
|
-
<K>(key: K): <V>(self: SortedMap<K, V>) => Option.Option<V>
|
|
138
|
-
<K, V>(self: SortedMap<K, V>, key: K): Option.Option<V>
|
|
139
|
-
} = Dual.dual<
|
|
140
|
-
<K>(key: K) => <V>(self: SortedMap<K, V>) => Option.Option<V>,
|
|
141
|
-
<K, V>(self: SortedMap<K, V>, key: K) => Option.Option<V>
|
|
142
|
-
>(2, (self, key) => RBT.findFirst(self.tree, key))
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Gets the `Order<K>` that the `SortedMap<K, V>` is using.
|
|
146
|
-
*
|
|
147
|
-
* @since 2.0.0
|
|
148
|
-
* @category getters
|
|
149
|
-
*/
|
|
150
|
-
export const getOrder = <K, V>(self: SortedMap<K, V>): Order<K> => RBT.getOrder(self.tree)
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @since 2.0.0
|
|
154
|
-
* @category elements
|
|
155
|
-
*/
|
|
156
|
-
export const has: {
|
|
157
|
-
<K>(key: K): <V>(self: SortedMap<K, V>) => boolean
|
|
158
|
-
<K, V>(self: SortedMap<K, V>, key: K): boolean
|
|
159
|
-
} = Dual.dual<
|
|
160
|
-
<K>(key: K) => <V>(self: SortedMap<K, V>) => boolean,
|
|
161
|
-
<K, V>(self: SortedMap<K, V>, key: K) => boolean
|
|
162
|
-
>(2, (self, key) => Option.isSome(get(self, key)))
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @since 2.0.0
|
|
166
|
-
* @category elements
|
|
167
|
-
*/
|
|
168
|
-
export const headOption = <K, V>(self: SortedMap<K, V>): Option.Option<[K, V]> => RBT.first(self.tree)
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @since 2.0.0
|
|
172
|
-
* @category mapping
|
|
173
|
-
*/
|
|
174
|
-
export const map: {
|
|
175
|
-
<A, K, B>(f: (a: A, k: K) => B): (self: SortedMap<K, A>) => SortedMap<K, B>
|
|
176
|
-
<K, A, B>(self: SortedMap<K, A>, f: (a: A, k: K) => B): SortedMap<K, B>
|
|
177
|
-
} = Dual.dual<
|
|
178
|
-
<A, K, B>(f: (a: A, k: K) => B) => (self: SortedMap<K, A>) => SortedMap<K, B>,
|
|
179
|
-
<K, A, B>(self: SortedMap<K, A>, f: (a: A, k: K) => B) => SortedMap<K, B>
|
|
180
|
-
>(2, <K, A, B>(self: SortedMap<K, A>, f: (a: A, k: K) => B) =>
|
|
181
|
-
reduce(
|
|
182
|
-
self,
|
|
183
|
-
empty<K, B>(RBT.getOrder(self.tree)),
|
|
184
|
-
(acc, v, k) => set(acc, k, f(v, k))
|
|
185
|
-
))
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @since 2.0.0
|
|
189
|
-
* @category folding
|
|
190
|
-
*/
|
|
191
|
-
export const reduce: {
|
|
192
|
-
<B, A, K>(zero: B, f: (acc: B, value: A, key: K) => B): (self: SortedMap<K, A>) => B
|
|
193
|
-
<K, A, B>(self: SortedMap<K, A>, zero: B, f: (acc: B, value: A, key: K) => B): B
|
|
194
|
-
} = Dual.dual<
|
|
195
|
-
<B, A, K>(zero: B, f: (acc: B, value: A, key: K) => B) => (self: SortedMap<K, A>) => B,
|
|
196
|
-
<K, A, B>(self: SortedMap<K, A>, zero: B, f: (acc: B, value: A, key: K) => B) => B
|
|
197
|
-
>(3, (self, zero, f) => RBT.reduce(self.tree, zero, f))
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @since 2.0.0
|
|
201
|
-
* @category elements
|
|
202
|
-
*/
|
|
203
|
-
export const remove: {
|
|
204
|
-
<K>(key: K): <V>(self: SortedMap<K, V>) => SortedMap<K, V>
|
|
205
|
-
<K, V>(self: SortedMap<K, V>, key: K): SortedMap<K, V>
|
|
206
|
-
} = Dual.dual<
|
|
207
|
-
<K>(key: K) => <V>(self: SortedMap<K, V>) => SortedMap<K, V>,
|
|
208
|
-
<K, V>(self: SortedMap<K, V>, key: K) => SortedMap<K, V>
|
|
209
|
-
>(2, (self, key) => makeImpl(RBT.removeFirst(self.tree, key)))
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @since 2.0.0
|
|
213
|
-
* @category elements
|
|
214
|
-
*/
|
|
215
|
-
export const set: {
|
|
216
|
-
<K, V>(key: K, value: V): (self: SortedMap<K, V>) => SortedMap<K, V>
|
|
217
|
-
<K, V>(self: SortedMap<K, V>, key: K, value: V): SortedMap<K, V>
|
|
218
|
-
} = Dual.dual<
|
|
219
|
-
<K, V>(key: K, value: V) => (self: SortedMap<K, V>) => SortedMap<K, V>,
|
|
220
|
-
<K, V>(self: SortedMap<K, V>, key: K, value: V) => SortedMap<K, V>
|
|
221
|
-
>(3, (self, key, value) =>
|
|
222
|
-
RBT.has(self.tree, key)
|
|
223
|
-
? makeImpl(RBT.insert(RBT.removeFirst(self.tree, key), key, value))
|
|
224
|
-
: makeImpl(RBT.insert(self.tree, key, value)))
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* @since 2.0.0
|
|
228
|
-
* @category getters
|
|
229
|
-
*/
|
|
230
|
-
export const size = <K, V>(self: SortedMap<K, V>): number => RBT.size(self.tree)
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @since 2.0.0
|
|
234
|
-
* @category getters
|
|
235
|
-
*/
|
|
236
|
-
export const keys = <K, V>(self: SortedMap<K, V>): IterableIterator<K> => RBT.keys(self.tree)
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* @since 2.0.0
|
|
240
|
-
* @category getters
|
|
241
|
-
*/
|
|
242
|
-
export const values = <K, V>(self: SortedMap<K, V>): IterableIterator<V> => RBT.values(self.tree)
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* @since 2.0.0
|
|
246
|
-
* @category getters
|
|
247
|
-
*/
|
|
248
|
-
export const entries = <K, V>(self: SortedMap<K, V>): IterableIterator<[K, V]> => {
|
|
249
|
-
const iterator: any = self.tree[Symbol.iterator]()
|
|
250
|
-
iterator[Symbol.iterator] = () => entries(self)
|
|
251
|
-
return iterator
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* @since 3.1.0
|
|
256
|
-
* @category elements
|
|
257
|
-
*/
|
|
258
|
-
export const lastOption = <K, V>(self: SortedMap<K, V>): Option.Option<[K, V]> => RBT.last(self.tree)
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* @since 3.1.0
|
|
262
|
-
* @category filtering
|
|
263
|
-
*/
|
|
264
|
-
export const partition: {
|
|
265
|
-
<K, V>(
|
|
266
|
-
predicate: (a: Types.NoInfer<K>) => boolean
|
|
267
|
-
): (self: SortedMap<K, V>) => [excluded: SortedMap<K, V>, satisfying: SortedMap<K, V>]
|
|
268
|
-
<K, V>(self: SortedMap<K, V>, predicate: (a: K) => boolean): [excluded: SortedMap<K, V>, satisfying: SortedMap<K, V>]
|
|
269
|
-
} = Dual.dual(
|
|
270
|
-
2,
|
|
271
|
-
<K, V>(
|
|
272
|
-
self: SortedMap<K, V>,
|
|
273
|
-
predicate: (a: K) => boolean
|
|
274
|
-
): [excluded: SortedMap<K, V>, satisfying: SortedMap<K, V>] => {
|
|
275
|
-
const ord = RBT.getOrder(self.tree)
|
|
276
|
-
let right = empty<K, V>(ord)
|
|
277
|
-
let left = empty<K, V>(ord)
|
|
278
|
-
for (const value of self) {
|
|
279
|
-
if (predicate(value[0])) {
|
|
280
|
-
right = set(right, value[0], value[1])
|
|
281
|
-
} else {
|
|
282
|
-
left = set(left, value[0], value[1])
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return [left, right]
|
|
286
|
-
}
|
|
287
|
-
)
|
package/src/SortedSet.ts
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 2.0.0
|
|
3
|
-
*/
|
|
4
|
-
import * as Equal from "./Equal.js"
|
|
5
|
-
import type * as Equivalence from "./Equivalence.js"
|
|
6
|
-
import * as Dual from "./Function.js"
|
|
7
|
-
import { pipe } from "./Function.js"
|
|
8
|
-
import * as Hash from "./Hash.js"
|
|
9
|
-
import type { Inspectable } from "./Inspectable.js"
|
|
10
|
-
import { format, NodeInspectSymbol, toJSON } from "./Inspectable.js"
|
|
11
|
-
import type { Order } from "./Order.js"
|
|
12
|
-
import type { Pipeable } from "./Pipeable.js"
|
|
13
|
-
import { pipeArguments } from "./Pipeable.js"
|
|
14
|
-
import type { Predicate } from "./Predicate.js"
|
|
15
|
-
import { hasProperty } from "./Predicate.js"
|
|
16
|
-
import * as RBT from "./RedBlackTree.js"
|
|
17
|
-
import type { Invariant, NoInfer } from "./Types.js"
|
|
18
|
-
|
|
19
|
-
const TypeId: unique symbol = Symbol.for("effect/SortedSet")
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @since 2.0.0
|
|
23
|
-
* @category symbol
|
|
24
|
-
*/
|
|
25
|
-
export type TypeId = typeof TypeId
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @since 2.0.0
|
|
29
|
-
* @category models
|
|
30
|
-
*/
|
|
31
|
-
export interface SortedSet<in out A> extends Iterable<A>, Equal.Equal, Pipeable, Inspectable {
|
|
32
|
-
readonly [TypeId]: {
|
|
33
|
-
readonly _A: Invariant<A>
|
|
34
|
-
}
|
|
35
|
-
/** @internal */
|
|
36
|
-
readonly keyTree: RBT.RedBlackTree<A, boolean>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const SortedSetProto: Omit<SortedSet<unknown>, "keyTree"> = {
|
|
40
|
-
[TypeId]: {
|
|
41
|
-
_A: (_: any) => _
|
|
42
|
-
},
|
|
43
|
-
[Hash.symbol]<A>(this: SortedSet<A>): number {
|
|
44
|
-
return pipe(
|
|
45
|
-
Hash.hash(this.keyTree),
|
|
46
|
-
Hash.combine(Hash.hash(TypeId)),
|
|
47
|
-
Hash.cached(this)
|
|
48
|
-
)
|
|
49
|
-
},
|
|
50
|
-
[Equal.symbol]<A>(this: SortedSet<A>, that: unknown): boolean {
|
|
51
|
-
return isSortedSet(that) && Equal.equals(this.keyTree, that.keyTree)
|
|
52
|
-
},
|
|
53
|
-
[Symbol.iterator]<A>(this: SortedSet<A>): Iterator<A> {
|
|
54
|
-
return RBT.keys(this.keyTree)
|
|
55
|
-
},
|
|
56
|
-
toString<A>(this: SortedSet<A>) {
|
|
57
|
-
return format(this.toJSON())
|
|
58
|
-
},
|
|
59
|
-
toJSON() {
|
|
60
|
-
return {
|
|
61
|
-
_id: "SortedSet",
|
|
62
|
-
values: Array.from(this).map(toJSON)
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[NodeInspectSymbol]() {
|
|
66
|
-
return this.toJSON()
|
|
67
|
-
},
|
|
68
|
-
pipe() {
|
|
69
|
-
return pipeArguments(this, arguments)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const fromTree = <A>(keyTree: RBT.RedBlackTree<A, boolean>): SortedSet<A> => {
|
|
74
|
-
const a = Object.create(SortedSetProto)
|
|
75
|
-
a.keyTree = keyTree
|
|
76
|
-
return a
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @since 2.0.0
|
|
81
|
-
* @category refinements
|
|
82
|
-
*/
|
|
83
|
-
export const isSortedSet: {
|
|
84
|
-
<A>(u: Iterable<A>): u is SortedSet<A>
|
|
85
|
-
(u: unknown): u is SortedSet<unknown>
|
|
86
|
-
} = (u: unknown): u is SortedSet<unknown> => hasProperty(u, TypeId)
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @since 2.0.0
|
|
90
|
-
* @category constructors
|
|
91
|
-
*/
|
|
92
|
-
export const empty = <A>(O: Order<A>): SortedSet<A> => fromTree(RBT.empty(O))
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Creates a new `SortedSet` from an iterable collection of values.
|
|
96
|
-
*
|
|
97
|
-
* @since 2.0.0
|
|
98
|
-
* @category constructors
|
|
99
|
-
*/
|
|
100
|
-
export const fromIterable: {
|
|
101
|
-
<B>(ord: Order<B>): <A extends B>(iterable: Iterable<A>) => SortedSet<A>
|
|
102
|
-
<A extends B, B>(iterable: Iterable<A>, ord: Order<B>): SortedSet<A>
|
|
103
|
-
} = Dual.dual(
|
|
104
|
-
2,
|
|
105
|
-
<A extends B, B>(iterable: Iterable<A>, ord: Order<B>): SortedSet<A> =>
|
|
106
|
-
fromTree(RBT.fromIterable(Array.from(iterable).map((k) => [k, true]), ord))
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @since 2.0.0
|
|
111
|
-
* @category constructors
|
|
112
|
-
*/
|
|
113
|
-
export const make =
|
|
114
|
-
<K>(ord: Order<K>) => <Entries extends ReadonlyArray<K>>(...entries: Entries): SortedSet<Entries[number]> =>
|
|
115
|
-
fromIterable(entries, ord)
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @since 2.0.0
|
|
119
|
-
* @category elements
|
|
120
|
-
*/
|
|
121
|
-
export const add: {
|
|
122
|
-
<A>(value: A): (self: SortedSet<A>) => SortedSet<A>
|
|
123
|
-
<A>(self: SortedSet<A>, value: A): SortedSet<A>
|
|
124
|
-
} = Dual.dual<
|
|
125
|
-
<A>(value: A) => (self: SortedSet<A>) => SortedSet<A>,
|
|
126
|
-
<A>(self: SortedSet<A>, value: A) => SortedSet<A>
|
|
127
|
-
>(2, (self, value) =>
|
|
128
|
-
RBT.has(self.keyTree, value)
|
|
129
|
-
? self
|
|
130
|
-
: fromTree(RBT.insert(self.keyTree, value, true)))
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @since 2.0.0
|
|
134
|
-
*/
|
|
135
|
-
export const difference: {
|
|
136
|
-
<A, B extends A>(that: Iterable<B>): (self: SortedSet<A>) => SortedSet<A>
|
|
137
|
-
<A, B extends A>(self: SortedSet<A>, that: Iterable<B>): SortedSet<A>
|
|
138
|
-
} = Dual.dual<
|
|
139
|
-
<A, B extends A>(that: Iterable<B>) => (self: SortedSet<A>) => SortedSet<A>,
|
|
140
|
-
<A, B extends A>(self: SortedSet<A>, that: Iterable<B>) => SortedSet<A>
|
|
141
|
-
>(2, <A, B extends A>(self: SortedSet<A>, that: Iterable<B>) => {
|
|
142
|
-
let out = self
|
|
143
|
-
for (const value of that) {
|
|
144
|
-
out = remove<A | B>(out, value)
|
|
145
|
-
}
|
|
146
|
-
return out
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Check if a predicate holds true for every `SortedSet` element.
|
|
151
|
-
*
|
|
152
|
-
* @since 2.0.0
|
|
153
|
-
* @category elements
|
|
154
|
-
*/
|
|
155
|
-
export const every: {
|
|
156
|
-
<A>(predicate: Predicate<A>): (self: SortedSet<A>) => boolean
|
|
157
|
-
<A>(self: SortedSet<A>, predicate: Predicate<A>): boolean
|
|
158
|
-
} = Dual.dual(2, <A>(self: SortedSet<A>, predicate: Predicate<A>): boolean => {
|
|
159
|
-
for (const value of self) {
|
|
160
|
-
if (!predicate(value)) {
|
|
161
|
-
return false
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return true
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @since 2.0.0
|
|
169
|
-
* @category filtering
|
|
170
|
-
*/
|
|
171
|
-
export const filter: {
|
|
172
|
-
<A, B extends A>(predicate: Predicate<B>): (self: SortedSet<A>) => SortedSet<A>
|
|
173
|
-
<A>(self: SortedSet<A>, predicate: Predicate<A>): SortedSet<A>
|
|
174
|
-
} = Dual.dual(2, <A>(self: SortedSet<A>, predicate: Predicate<A>): SortedSet<A> => {
|
|
175
|
-
const ord = RBT.getOrder(self.keyTree)
|
|
176
|
-
let out = empty<A>(ord)
|
|
177
|
-
for (const value of self) {
|
|
178
|
-
if (predicate(value)) {
|
|
179
|
-
out = add(out, value)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return out
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* @since 2.0.0
|
|
187
|
-
* @category sequencing
|
|
188
|
-
*/
|
|
189
|
-
export const flatMap: {
|
|
190
|
-
<B, A>(O: Order<B>, f: (a: A) => Iterable<B>): (self: SortedSet<A>) => SortedSet<B>
|
|
191
|
-
<A, B>(self: SortedSet<A>, O: Order<B>, f: (a: A) => Iterable<B>): SortedSet<B>
|
|
192
|
-
} = Dual.dual<
|
|
193
|
-
<B, A>(O: Order<B>, f: (a: A) => Iterable<B>) => (self: SortedSet<A>) => SortedSet<B>,
|
|
194
|
-
<A, B>(self: SortedSet<A>, O: Order<B>, f: (a: A) => Iterable<B>) => SortedSet<B>
|
|
195
|
-
>(3, (self, O, f) => {
|
|
196
|
-
let out = empty(O)
|
|
197
|
-
forEach(self, (a) => {
|
|
198
|
-
for (const b of f(a)) {
|
|
199
|
-
out = add(out, b)
|
|
200
|
-
}
|
|
201
|
-
})
|
|
202
|
-
return out
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* @since 2.0.0
|
|
207
|
-
* @category traversing
|
|
208
|
-
*/
|
|
209
|
-
export const forEach: {
|
|
210
|
-
<A>(f: (a: A) => void): (self: SortedSet<A>) => void
|
|
211
|
-
<A>(self: SortedSet<A>, f: (a: A) => void): void
|
|
212
|
-
} = Dual.dual<
|
|
213
|
-
<A>(f: (a: A) => void) => (self: SortedSet<A>) => void,
|
|
214
|
-
<A>(self: SortedSet<A>, f: (a: A) => void) => void
|
|
215
|
-
>(2, (self, f) => RBT.forEach(self.keyTree, f))
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @since 2.0.0
|
|
219
|
-
* @category elements
|
|
220
|
-
*/
|
|
221
|
-
export const has: {
|
|
222
|
-
<A>(value: A): (self: SortedSet<A>) => boolean
|
|
223
|
-
<A>(self: SortedSet<A>, value: A): boolean
|
|
224
|
-
} = Dual.dual<
|
|
225
|
-
<A>(value: A) => (self: SortedSet<A>) => boolean,
|
|
226
|
-
<A>(self: SortedSet<A>, value: A) => boolean
|
|
227
|
-
>(2, (self, value) => RBT.has(self.keyTree, value))
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @since 2.0.0
|
|
231
|
-
*/
|
|
232
|
-
export const intersection: {
|
|
233
|
-
<A>(that: Iterable<A>): (self: SortedSet<A>) => SortedSet<A>
|
|
234
|
-
<A>(self: SortedSet<A>, that: Iterable<A>): SortedSet<A>
|
|
235
|
-
} = Dual.dual<
|
|
236
|
-
<A>(that: Iterable<A>) => (self: SortedSet<A>) => SortedSet<A>,
|
|
237
|
-
<A>(self: SortedSet<A>, that: Iterable<A>) => SortedSet<A>
|
|
238
|
-
>(2, (self, that) => {
|
|
239
|
-
const ord = RBT.getOrder(self.keyTree)
|
|
240
|
-
let out = empty(ord)
|
|
241
|
-
for (const value of that) {
|
|
242
|
-
if (has(self, value)) {
|
|
243
|
-
out = add(out, value)
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return out
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* @since 2.0.0
|
|
251
|
-
* @category elements
|
|
252
|
-
*/
|
|
253
|
-
export const isSubset: {
|
|
254
|
-
<A>(that: SortedSet<A>): (self: SortedSet<A>) => boolean
|
|
255
|
-
<A>(self: SortedSet<A>, that: SortedSet<A>): boolean
|
|
256
|
-
} = Dual.dual<
|
|
257
|
-
<A>(that: SortedSet<A>) => (self: SortedSet<A>) => boolean,
|
|
258
|
-
<A>(self: SortedSet<A>, that: SortedSet<A>) => boolean
|
|
259
|
-
>(2, (self, that) => every(self, (a) => has(that, a)))
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @since 2.0.0
|
|
263
|
-
* @category mapping
|
|
264
|
-
*/
|
|
265
|
-
export const map: {
|
|
266
|
-
<B, A>(O: Order<B>, f: (a: A) => B): (self: SortedSet<A>) => SortedSet<B>
|
|
267
|
-
<B, A>(self: SortedSet<A>, O: Order<B>, f: (a: A) => B): SortedSet<B>
|
|
268
|
-
} = Dual.dual<
|
|
269
|
-
<B, A>(O: Order<B>, f: (a: A) => B) => (self: SortedSet<A>) => SortedSet<B>,
|
|
270
|
-
<B, A>(self: SortedSet<A>, O: Order<B>, f: (a: A) => B) => SortedSet<B>
|
|
271
|
-
>(3, (self, O, f) => {
|
|
272
|
-
let out = empty(O)
|
|
273
|
-
forEach(self, (a) => {
|
|
274
|
-
const b = f(a)
|
|
275
|
-
if (!has(out, b)) {
|
|
276
|
-
out = add(out, b)
|
|
277
|
-
}
|
|
278
|
-
})
|
|
279
|
-
return out
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* @since 2.0.0
|
|
284
|
-
* @category filtering
|
|
285
|
-
*/
|
|
286
|
-
export const partition: {
|
|
287
|
-
<A>(
|
|
288
|
-
predicate: (a: NoInfer<A>) => boolean
|
|
289
|
-
): (self: SortedSet<A>) => [excluded: SortedSet<A>, satisfying: SortedSet<A>]
|
|
290
|
-
<A>(self: SortedSet<A>, predicate: (a: A) => boolean): [excluded: SortedSet<A>, satisfying: SortedSet<A>]
|
|
291
|
-
} = Dual.dual(
|
|
292
|
-
2,
|
|
293
|
-
<A>(self: SortedSet<A>, predicate: (a: A) => boolean): [excluded: SortedSet<A>, satisfying: SortedSet<A>] => {
|
|
294
|
-
const ord = RBT.getOrder(self.keyTree)
|
|
295
|
-
let right = empty(ord)
|
|
296
|
-
let left = empty(ord)
|
|
297
|
-
for (const value of self) {
|
|
298
|
-
if (predicate(value)) {
|
|
299
|
-
right = add(right, value)
|
|
300
|
-
} else {
|
|
301
|
-
left = add(left, value)
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return [left, right]
|
|
305
|
-
}
|
|
306
|
-
)
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* @since 2.0.0
|
|
310
|
-
* @category elements
|
|
311
|
-
*/
|
|
312
|
-
export const remove: {
|
|
313
|
-
<A>(value: A): (self: SortedSet<A>) => SortedSet<A>
|
|
314
|
-
<A>(self: SortedSet<A>, value: A): SortedSet<A>
|
|
315
|
-
} = Dual.dual<
|
|
316
|
-
<A>(value: A) => (self: SortedSet<A>) => SortedSet<A>,
|
|
317
|
-
<A>(self: SortedSet<A>, value: A) => SortedSet<A>
|
|
318
|
-
>(2, (self, value) => fromTree(RBT.removeFirst(self.keyTree, value)))
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* @since 2.0.0
|
|
322
|
-
* @category getters
|
|
323
|
-
*/
|
|
324
|
-
export const size = <A>(self: SortedSet<A>): number => RBT.size(self.keyTree)
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Check if a predicate holds true for some `SortedSet` element.
|
|
328
|
-
*
|
|
329
|
-
* @since 2.0.0
|
|
330
|
-
* @category elements
|
|
331
|
-
*/
|
|
332
|
-
export const some: {
|
|
333
|
-
<A>(predicate: Predicate<A>): (self: SortedSet<A>) => boolean
|
|
334
|
-
<A>(self: SortedSet<A>, predicate: Predicate<A>): boolean
|
|
335
|
-
} = Dual.dual<
|
|
336
|
-
<A>(predicate: Predicate<A>) => (self: SortedSet<A>) => boolean,
|
|
337
|
-
<A>(self: SortedSet<A>, predicate: Predicate<A>) => boolean
|
|
338
|
-
>(2, (self, predicate) => {
|
|
339
|
-
for (const value of self) {
|
|
340
|
-
if (predicate(value)) {
|
|
341
|
-
return true
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return false
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* @since 2.0.0
|
|
349
|
-
* @category elements
|
|
350
|
-
*/
|
|
351
|
-
export const toggle: {
|
|
352
|
-
<A>(value: A): (self: SortedSet<A>) => SortedSet<A>
|
|
353
|
-
<A>(self: SortedSet<A>, value: A): SortedSet<A>
|
|
354
|
-
} = Dual.dual<
|
|
355
|
-
<A>(value: A) => (self: SortedSet<A>) => SortedSet<A>,
|
|
356
|
-
<A>(self: SortedSet<A>, value: A) => SortedSet<A>
|
|
357
|
-
>(2, (self, value) => has(self, value) ? remove(self, value) : add(self, value))
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* @since 2.0.0
|
|
361
|
-
*/
|
|
362
|
-
export const union: {
|
|
363
|
-
<A>(that: Iterable<A>): (self: SortedSet<A>) => SortedSet<A>
|
|
364
|
-
<A>(self: SortedSet<A>, that: Iterable<A>): SortedSet<A>
|
|
365
|
-
} = Dual.dual<
|
|
366
|
-
<A>(that: Iterable<A>) => (self: SortedSet<A>) => SortedSet<A>,
|
|
367
|
-
<A>(self: SortedSet<A>, that: Iterable<A>) => SortedSet<A>
|
|
368
|
-
>(2, <A>(self: SortedSet<A>, that: Iterable<A>) => {
|
|
369
|
-
const ord = RBT.getOrder(self.keyTree)
|
|
370
|
-
let out = empty<A>(ord)
|
|
371
|
-
for (const value of self) {
|
|
372
|
-
out = add(value)(out)
|
|
373
|
-
}
|
|
374
|
-
for (const value of that) {
|
|
375
|
-
out = add(value)(out)
|
|
376
|
-
}
|
|
377
|
-
return out
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* @since 2.0.0
|
|
382
|
-
* @category getters
|
|
383
|
-
*/
|
|
384
|
-
export const values = <A>(self: SortedSet<A>): IterableIterator<A> => RBT.keys(self.keyTree)
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* @since 2.0.0
|
|
388
|
-
* @category equivalence
|
|
389
|
-
*/
|
|
390
|
-
export const getEquivalence = <A>(): Equivalence.Equivalence<SortedSet<A>> => (a, b) => isSubset(a, b) && isSubset(b, a)
|