@clayroach/effect 3.19.14-source-capture.6 → 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/internal/stm/tSet.ts
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import * as RA from "../../Array.js"
|
|
2
|
-
import * as Chunk from "../../Chunk.js"
|
|
3
|
-
import { dual, pipe } from "../../Function.js"
|
|
4
|
-
import * as HashSet from "../../HashSet.js"
|
|
5
|
-
import type * as Option from "../../Option.js"
|
|
6
|
-
import { hasProperty, type Predicate } from "../../Predicate.js"
|
|
7
|
-
import * as STM from "../../STM.js"
|
|
8
|
-
import type * as TMap from "../../TMap.js"
|
|
9
|
-
import type * as TSet from "../../TSet.js"
|
|
10
|
-
import * as core from "./core.js"
|
|
11
|
-
import * as tMap from "./tMap.js"
|
|
12
|
-
|
|
13
|
-
/** @internal */
|
|
14
|
-
const TSetSymbolKey = "effect/TSet"
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export const TSetTypeId: TSet.TSetTypeId = Symbol.for(
|
|
18
|
-
TSetSymbolKey
|
|
19
|
-
) as TSet.TSetTypeId
|
|
20
|
-
|
|
21
|
-
const tSetVariance = {
|
|
22
|
-
/* c8 ignore next */
|
|
23
|
-
_A: (_: any) => _
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** @internal */
|
|
27
|
-
class TSetImpl<in out A> implements TSet.TSet<A> {
|
|
28
|
-
readonly [TSetTypeId] = tSetVariance
|
|
29
|
-
constructor(readonly tMap: TMap.TMap<A, void>) {}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const isTSet = (u: unknown) => hasProperty(u, TSetTypeId)
|
|
33
|
-
|
|
34
|
-
/** @internal */
|
|
35
|
-
export const add = dual<
|
|
36
|
-
<A>(value: A) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
37
|
-
<A>(self: TSet.TSet<A>, value: A) => STM.STM<void>
|
|
38
|
-
>(2, (self, value) => tMap.set(self.tMap, value, void 0 as void))
|
|
39
|
-
|
|
40
|
-
/** @internal */
|
|
41
|
-
export const difference = dual<
|
|
42
|
-
<A>(other: TSet.TSet<A>) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
43
|
-
<A>(self: TSet.TSet<A>, other: TSet.TSet<A>) => STM.STM<void>
|
|
44
|
-
>(2, (self, other) =>
|
|
45
|
-
core.flatMap(
|
|
46
|
-
toHashSet(other),
|
|
47
|
-
(values) => removeIf(self, (value) => HashSet.has(values, value), { discard: true })
|
|
48
|
-
))
|
|
49
|
-
|
|
50
|
-
/** @internal */
|
|
51
|
-
export const empty = <A>(): STM.STM<TSet.TSet<A>> => fromIterable<A>([])
|
|
52
|
-
|
|
53
|
-
/** @internal */
|
|
54
|
-
export const forEach = dual<
|
|
55
|
-
<A, R, E>(f: (value: A) => STM.STM<void, E, R>) => (self: TSet.TSet<A>) => STM.STM<void, E, R>,
|
|
56
|
-
<A, R, E>(self: TSet.TSet<A>, f: (value: A) => STM.STM<void, E, R>) => STM.STM<void, E, R>
|
|
57
|
-
>(2, (self, f) => reduceSTM(self, void 0 as void, (_, value) => f(value)))
|
|
58
|
-
|
|
59
|
-
/** @internal */
|
|
60
|
-
export const fromIterable = <A>(iterable: Iterable<A>): STM.STM<TSet.TSet<A>> =>
|
|
61
|
-
core.map(
|
|
62
|
-
tMap.fromIterable(Array.from(iterable).map((a): [A, void] => [a, void 0])),
|
|
63
|
-
(tMap) => new TSetImpl(tMap)
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
/** @internal */
|
|
67
|
-
export const has = dual<
|
|
68
|
-
<A>(value: A) => (self: TSet.TSet<A>) => STM.STM<boolean>,
|
|
69
|
-
<A>(self: TSet.TSet<A>, value: A) => STM.STM<boolean>
|
|
70
|
-
>(2, (self, value) => tMap.has(self.tMap, value))
|
|
71
|
-
|
|
72
|
-
/** @internal */
|
|
73
|
-
export const intersection = dual<
|
|
74
|
-
<A>(other: TSet.TSet<A>) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
75
|
-
<A>(self: TSet.TSet<A>, other: TSet.TSet<A>) => STM.STM<void>
|
|
76
|
-
>(2, (self, other) =>
|
|
77
|
-
core.flatMap(
|
|
78
|
-
toHashSet(other),
|
|
79
|
-
(values) => pipe(self, retainIf((value) => pipe(values, HashSet.has(value)), { discard: true }))
|
|
80
|
-
))
|
|
81
|
-
|
|
82
|
-
/** @internal */
|
|
83
|
-
export const isEmpty = <A>(self: TSet.TSet<A>): STM.STM<boolean> => tMap.isEmpty(self.tMap)
|
|
84
|
-
|
|
85
|
-
/** @internal */
|
|
86
|
-
export const make = <Elements extends Array<any>>(
|
|
87
|
-
...elements: Elements
|
|
88
|
-
): STM.STM<TSet.TSet<Elements[number]>> => fromIterable(elements)
|
|
89
|
-
|
|
90
|
-
/** @internal */
|
|
91
|
-
export const reduce = dual<
|
|
92
|
-
<Z, A>(zero: Z, f: (accumulator: Z, value: A) => Z) => (self: TSet.TSet<A>) => STM.STM<Z>,
|
|
93
|
-
<Z, A>(self: TSet.TSet<A>, zero: Z, f: (accumulator: Z, value: A) => Z) => STM.STM<Z>
|
|
94
|
-
>(3, (self, zero, f) =>
|
|
95
|
-
tMap.reduce(
|
|
96
|
-
self.tMap,
|
|
97
|
-
zero,
|
|
98
|
-
(acc, _, key) => f(acc, key)
|
|
99
|
-
))
|
|
100
|
-
|
|
101
|
-
/** @internal */
|
|
102
|
-
export const reduceSTM = dual<
|
|
103
|
-
<Z, A, R, E>(zero: Z, f: (accumulator: Z, value: A) => STM.STM<Z, E, R>) => (self: TSet.TSet<A>) => STM.STM<Z, E, R>,
|
|
104
|
-
<Z, A, R, E>(self: TSet.TSet<A>, zero: Z, f: (accumulator: Z, value: A) => STM.STM<Z, E, R>) => STM.STM<Z, E, R>
|
|
105
|
-
>(3, (self, zero, f) =>
|
|
106
|
-
tMap.reduceSTM(
|
|
107
|
-
self.tMap,
|
|
108
|
-
zero,
|
|
109
|
-
(acc, _, key) => f(acc, key)
|
|
110
|
-
))
|
|
111
|
-
|
|
112
|
-
/** @internal */
|
|
113
|
-
export const remove = dual<
|
|
114
|
-
<A>(value: A) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
115
|
-
<A>(self: TSet.TSet<A>, value: A) => STM.STM<void>
|
|
116
|
-
>(2, (self, value) => tMap.remove(self.tMap, value))
|
|
117
|
-
|
|
118
|
-
/** @internal */
|
|
119
|
-
export const removeAll = dual<
|
|
120
|
-
<A>(iterable: Iterable<A>) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
121
|
-
<A>(self: TSet.TSet<A>, iterable: Iterable<A>) => STM.STM<void>
|
|
122
|
-
>(2, (self, iterable) => tMap.removeAll(self.tMap, iterable))
|
|
123
|
-
|
|
124
|
-
/** @internal */
|
|
125
|
-
export const removeIf: {
|
|
126
|
-
<A>(predicate: Predicate<A>, options: {
|
|
127
|
-
readonly discard: true
|
|
128
|
-
}): (self: TSet.TSet<A>) => STM.STM<void>
|
|
129
|
-
<A>(
|
|
130
|
-
predicate: Predicate<A>,
|
|
131
|
-
options?: {
|
|
132
|
-
readonly discard: false
|
|
133
|
-
}
|
|
134
|
-
): (self: TSet.TSet<A>) => STM.STM<Array<A>>
|
|
135
|
-
<A>(self: TSet.TSet<A>, predicate: Predicate<A>, options: {
|
|
136
|
-
readonly discard: true
|
|
137
|
-
}): STM.STM<void>
|
|
138
|
-
<A>(
|
|
139
|
-
self: TSet.TSet<A>,
|
|
140
|
-
predicate: Predicate<A>,
|
|
141
|
-
options?: {
|
|
142
|
-
readonly discard: false
|
|
143
|
-
}
|
|
144
|
-
): STM.STM<Array<A>>
|
|
145
|
-
} = dual(
|
|
146
|
-
(args) => isTSet(args[0]),
|
|
147
|
-
(self, predicate, options) =>
|
|
148
|
-
options?.discard === true ? tMap.removeIf(self.tMap, (key) => predicate(key), { discard: true }) : pipe(
|
|
149
|
-
tMap.removeIf(self.tMap, (key) => predicate(key)),
|
|
150
|
-
core.map(RA.map((entry) => entry[0]))
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
/** @internal */
|
|
155
|
-
export const retainIf: {
|
|
156
|
-
<A>(predicate: Predicate<A>, options: {
|
|
157
|
-
readonly discard: true
|
|
158
|
-
}): (self: TSet.TSet<A>) => STM.STM<void>
|
|
159
|
-
<A>(
|
|
160
|
-
predicate: Predicate<A>,
|
|
161
|
-
options?: {
|
|
162
|
-
readonly discard: false
|
|
163
|
-
}
|
|
164
|
-
): (self: TSet.TSet<A>) => STM.STM<Array<A>>
|
|
165
|
-
<A>(self: TSet.TSet<A>, predicate: Predicate<A>, options: {
|
|
166
|
-
readonly discard: true
|
|
167
|
-
}): STM.STM<void>
|
|
168
|
-
<A>(
|
|
169
|
-
self: TSet.TSet<A>,
|
|
170
|
-
predicate: Predicate<A>,
|
|
171
|
-
options?: {
|
|
172
|
-
readonly discard: false
|
|
173
|
-
}
|
|
174
|
-
): STM.STM<Array<A>>
|
|
175
|
-
} = dual((args) => isTSet(args[0]), (self, predicate, options) =>
|
|
176
|
-
options?.discard === true ?
|
|
177
|
-
tMap.retainIf(self.tMap, (key) => predicate(key), { discard: true }) :
|
|
178
|
-
pipe(
|
|
179
|
-
tMap.retainIf(self.tMap, (key) => predicate(key)),
|
|
180
|
-
core.map(RA.map((entry) => entry[0]))
|
|
181
|
-
))
|
|
182
|
-
|
|
183
|
-
/** @internal */
|
|
184
|
-
export const size = <A>(self: TSet.TSet<A>): STM.STM<number> => core.map(toChunk(self), (chunk) => chunk.length)
|
|
185
|
-
|
|
186
|
-
/** @internal */
|
|
187
|
-
export const takeFirst = dual<
|
|
188
|
-
<A, B>(pf: (a: A) => Option.Option<B>) => (self: TSet.TSet<A>) => STM.STM<B>,
|
|
189
|
-
<A, B>(self: TSet.TSet<A>, pf: (a: A) => Option.Option<B>) => STM.STM<B>
|
|
190
|
-
>(2, (self, pf) => tMap.takeFirst(self.tMap, (key) => pf(key)))
|
|
191
|
-
|
|
192
|
-
/** @internal */
|
|
193
|
-
export const takeFirstSTM = dual<
|
|
194
|
-
<A, B, E, R>(pf: (a: A) => STM.STM<B, Option.Option<E>, R>) => (self: TSet.TSet<A>) => STM.STM<B, E, R>,
|
|
195
|
-
<A, B, E, R>(self: TSet.TSet<A>, pf: (a: A) => STM.STM<B, Option.Option<E>, R>) => STM.STM<B, E, R>
|
|
196
|
-
>(2, (self, pf) => tMap.takeFirstSTM(self.tMap, (key) => pf(key)))
|
|
197
|
-
|
|
198
|
-
/** @internal */
|
|
199
|
-
export const takeSome = dual<
|
|
200
|
-
<A, B>(pf: (a: A) => Option.Option<B>) => (self: TSet.TSet<A>) => STM.STM<RA.NonEmptyArray<B>>,
|
|
201
|
-
<A, B>(self: TSet.TSet<A>, pf: (a: A) => Option.Option<B>) => STM.STM<RA.NonEmptyArray<B>>
|
|
202
|
-
>(2, (self, pf) => tMap.takeSome(self.tMap, (key) => pf(key)))
|
|
203
|
-
|
|
204
|
-
/** @internal */
|
|
205
|
-
export const takeSomeSTM = dual<
|
|
206
|
-
<A, B, E, R>(
|
|
207
|
-
pf: (a: A) => STM.STM<B, Option.Option<E>, R>
|
|
208
|
-
) => (self: TSet.TSet<A>) => STM.STM<RA.NonEmptyArray<B>, E, R>,
|
|
209
|
-
<A, B, E, R>(
|
|
210
|
-
self: TSet.TSet<A>,
|
|
211
|
-
pf: (a: A) => STM.STM<B, Option.Option<E>, R>
|
|
212
|
-
) => STM.STM<RA.NonEmptyArray<B>, E, R>
|
|
213
|
-
>(2, (self, pf) => tMap.takeSomeSTM(self.tMap, (key) => pf(key)))
|
|
214
|
-
|
|
215
|
-
/** @internal */
|
|
216
|
-
export const toChunk = <A>(self: TSet.TSet<A>): STM.STM<Chunk.Chunk<A>> =>
|
|
217
|
-
tMap.keys(self.tMap).pipe(STM.map(Chunk.unsafeFromArray))
|
|
218
|
-
|
|
219
|
-
/** @internal */
|
|
220
|
-
export const toHashSet = <A>(self: TSet.TSet<A>): STM.STM<HashSet.HashSet<A>> =>
|
|
221
|
-
reduce(
|
|
222
|
-
self,
|
|
223
|
-
HashSet.empty<A>(),
|
|
224
|
-
(acc, value) => pipe(acc, HashSet.add(value))
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
/** @internal */
|
|
228
|
-
export const toArray = <A>(self: TSet.TSet<A>): STM.STM<Array<A>> =>
|
|
229
|
-
reduce<Array<A>, A>(
|
|
230
|
-
self,
|
|
231
|
-
[],
|
|
232
|
-
(acc, value) => [...acc, value]
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
/** @internal */
|
|
236
|
-
export const toReadonlySet = <A>(self: TSet.TSet<A>): STM.STM<ReadonlySet<A>> =>
|
|
237
|
-
core.map(toArray(self), (values) => new Set(values))
|
|
238
|
-
|
|
239
|
-
/** @internal */
|
|
240
|
-
export const transform = dual<
|
|
241
|
-
<A>(f: (a: A) => A) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
242
|
-
<A>(self: TSet.TSet<A>, f: (a: A) => A) => STM.STM<void>
|
|
243
|
-
>(2, (self, f) => tMap.transform(self.tMap, (key, value) => [f(key), value]))
|
|
244
|
-
|
|
245
|
-
/** @internal */
|
|
246
|
-
export const transformSTM = dual<
|
|
247
|
-
<A, R, E>(f: (a: A) => STM.STM<A, E, R>) => (self: TSet.TSet<A>) => STM.STM<void, E, R>,
|
|
248
|
-
<A, R, E>(self: TSet.TSet<A>, f: (a: A) => STM.STM<A, E, R>) => STM.STM<void, E, R>
|
|
249
|
-
>(2, (self, f) =>
|
|
250
|
-
tMap.transformSTM(
|
|
251
|
-
self.tMap,
|
|
252
|
-
(key, value) => core.map(f(key), (a) => [a, value])
|
|
253
|
-
))
|
|
254
|
-
|
|
255
|
-
/** @internal */
|
|
256
|
-
export const union = dual<
|
|
257
|
-
<A>(other: TSet.TSet<A>) => (self: TSet.TSet<A>) => STM.STM<void>,
|
|
258
|
-
<A>(self: TSet.TSet<A>, other: TSet.TSet<A>) => STM.STM<void>
|
|
259
|
-
>(2, (self, other) => forEach(other, (value) => add(self, value)))
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import * as Effect from "../../Effect.js"
|
|
2
|
-
import { dual, pipe } from "../../Function.js"
|
|
3
|
-
import * as Option from "../../Option.js"
|
|
4
|
-
import { pipeArguments } from "../../Pipeable.js"
|
|
5
|
-
import * as STM from "../../STM.js"
|
|
6
|
-
import * as TPubSub from "../../TPubSub.js"
|
|
7
|
-
import * as TQueue from "../../TQueue.js"
|
|
8
|
-
import * as TRef from "../../TRef.js"
|
|
9
|
-
import type * as TSubscriptionRef from "../../TSubscriptionRef.js"
|
|
10
|
-
import * as stream from "../stream.js"
|
|
11
|
-
import { tDequeueVariance } from "./tQueue.js"
|
|
12
|
-
import { tRefVariance } from "./tRef.js"
|
|
13
|
-
|
|
14
|
-
/** @internal */
|
|
15
|
-
const TSubscriptionRefSymbolKey = "effect/TSubscriptionRef"
|
|
16
|
-
|
|
17
|
-
/** @internal */
|
|
18
|
-
export const TSubscriptionRefTypeId: TSubscriptionRef.TSubscriptionRefTypeId = Symbol.for(
|
|
19
|
-
TSubscriptionRefSymbolKey
|
|
20
|
-
) as TSubscriptionRef.TSubscriptionRefTypeId
|
|
21
|
-
|
|
22
|
-
const TSubscriptionRefVariance = {
|
|
23
|
-
/* c8 ignore next */
|
|
24
|
-
_A: (_: any) => _
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class TDequeueMerge<A> implements TQueue.TDequeue<A> {
|
|
28
|
-
[TQueue.TDequeueTypeId] = tDequeueVariance
|
|
29
|
-
|
|
30
|
-
constructor(
|
|
31
|
-
readonly first: TQueue.TDequeue<A>,
|
|
32
|
-
readonly second: TQueue.TDequeue<A>
|
|
33
|
-
) {}
|
|
34
|
-
|
|
35
|
-
peek: STM.STM<A> = STM.gen(this, function*() {
|
|
36
|
-
const first = yield* this.peekOption
|
|
37
|
-
if (first._tag === "Some") {
|
|
38
|
-
return first.value
|
|
39
|
-
}
|
|
40
|
-
return yield* STM.retry
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
peekOption: STM.STM<Option.Option<A>> = STM.gen(this, function*() {
|
|
44
|
-
const first = yield* this.first.peekOption
|
|
45
|
-
if (first._tag === "Some") {
|
|
46
|
-
return first
|
|
47
|
-
}
|
|
48
|
-
const second = yield* this.second.peekOption
|
|
49
|
-
if (second._tag === "Some") {
|
|
50
|
-
return second
|
|
51
|
-
}
|
|
52
|
-
return Option.none()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
take: STM.STM<A> = STM.gen(this, function*() {
|
|
56
|
-
if (!(yield* this.first.isEmpty)) {
|
|
57
|
-
return yield* this.first.take
|
|
58
|
-
}
|
|
59
|
-
if (!(yield* this.second.isEmpty)) {
|
|
60
|
-
return yield* this.second.take
|
|
61
|
-
}
|
|
62
|
-
return yield* STM.retry
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
takeAll: STM.STM<Array<A>> = STM.gen(this, function*() {
|
|
66
|
-
return [...yield* this.first.takeAll, ...yield* this.second.takeAll]
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
takeUpTo(max: number): STM.STM<Array<A>> {
|
|
70
|
-
return STM.gen(this, function*() {
|
|
71
|
-
const first = yield* this.first.takeUpTo(max)
|
|
72
|
-
if (first.length >= max) {
|
|
73
|
-
return first
|
|
74
|
-
}
|
|
75
|
-
return [...first, ...yield* this.second.takeUpTo(max - first.length)]
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
capacity(): number {
|
|
80
|
-
return this.first.capacity() + this.second.capacity()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
size: STM.STM<number> = STM.gen(this, function*() {
|
|
84
|
-
return (yield* this.first.size) + (yield* this.second.size)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
isFull: STM.STM<boolean> = STM.gen(this, function*() {
|
|
88
|
-
return (yield* this.first.isFull) && (yield* this.second.isFull)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
isEmpty: STM.STM<boolean> = STM.gen(this, function*() {
|
|
92
|
-
return (yield* this.first.isEmpty) && (yield* this.second.isEmpty)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
shutdown: STM.STM<void> = STM.gen(this, function*() {
|
|
96
|
-
yield* this.first.shutdown
|
|
97
|
-
yield* this.second.shutdown
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
isShutdown: STM.STM<boolean> = STM.gen(this, function*() {
|
|
101
|
-
return (yield* this.first.isShutdown) && (yield* this.second.isShutdown)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
awaitShutdown: STM.STM<void> = STM.gen(this, function*() {
|
|
105
|
-
yield* this.first.awaitShutdown
|
|
106
|
-
yield* this.second.awaitShutdown
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** @internal */
|
|
111
|
-
class TSubscriptionRefImpl<in out A> implements TSubscriptionRef.TSubscriptionRef<A> {
|
|
112
|
-
readonly [TSubscriptionRefTypeId] = TSubscriptionRefVariance
|
|
113
|
-
readonly [TRef.TRefTypeId] = tRefVariance
|
|
114
|
-
|
|
115
|
-
constructor(
|
|
116
|
-
readonly ref: TRef.TRef<A>,
|
|
117
|
-
readonly pubsub: TPubSub.TPubSub<A>
|
|
118
|
-
) {}
|
|
119
|
-
|
|
120
|
-
get todos() {
|
|
121
|
-
return this.ref.todos
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
get versioned() {
|
|
125
|
-
return this.ref.versioned
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
pipe() {
|
|
129
|
-
return pipeArguments(this, arguments)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
get changes(): STM.STM<TQueue.TDequeue<A>> {
|
|
133
|
-
return STM.gen(this, function*() {
|
|
134
|
-
const first = yield* TQueue.unbounded<A>()
|
|
135
|
-
yield* TQueue.offer(first, yield* TRef.get(this.ref))
|
|
136
|
-
return new TDequeueMerge(first, yield* TPubSub.subscribe(this.pubsub))
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
modify<B>(f: (a: A) => readonly [B, A]): STM.STM<B> {
|
|
141
|
-
return pipe(
|
|
142
|
-
TRef.get(this.ref),
|
|
143
|
-
STM.map(f),
|
|
144
|
-
STM.flatMap(([b, a]) =>
|
|
145
|
-
pipe(
|
|
146
|
-
TRef.set(this.ref, a),
|
|
147
|
-
STM.as(b),
|
|
148
|
-
STM.zipLeft(TPubSub.publish(this.pubsub, a))
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** @internal */
|
|
156
|
-
export const make = <A>(value: A): STM.STM<TSubscriptionRef.TSubscriptionRef<A>> =>
|
|
157
|
-
pipe(
|
|
158
|
-
STM.all([
|
|
159
|
-
TPubSub.unbounded<A>(),
|
|
160
|
-
TRef.make(value)
|
|
161
|
-
]),
|
|
162
|
-
STM.map(([pubsub, ref]) => new TSubscriptionRefImpl(ref, pubsub))
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
/** @internal */
|
|
166
|
-
export const get = <A>(self: TSubscriptionRef.TSubscriptionRef<A>) => TRef.get(self.ref)
|
|
167
|
-
|
|
168
|
-
/** @internal */
|
|
169
|
-
export const set = dual<
|
|
170
|
-
<A>(value: A) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<void>,
|
|
171
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, value: A) => STM.STM<void>
|
|
172
|
-
>(
|
|
173
|
-
2,
|
|
174
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, value: A): STM.STM<void> =>
|
|
175
|
-
self.modify((): [void, A] => [void 0, value])
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
/** @internal */
|
|
179
|
-
export const getAndSet = dual<
|
|
180
|
-
<A>(value: A) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<A>,
|
|
181
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, value: A) => STM.STM<A>
|
|
182
|
-
>(2, (self, value) => self.modify((a) => [a, value]))
|
|
183
|
-
|
|
184
|
-
/** @internal */
|
|
185
|
-
export const getAndUpdate = dual<
|
|
186
|
-
<A>(f: (a: A) => A) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<A>,
|
|
187
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => A) => STM.STM<A>
|
|
188
|
-
>(2, (self, f) => self.modify((a) => [a, f(a)]))
|
|
189
|
-
|
|
190
|
-
/** @internal */
|
|
191
|
-
export const getAndUpdateSome = dual<
|
|
192
|
-
<A>(f: (a: A) => Option.Option<A>) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<A>,
|
|
193
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => Option.Option<A>) => STM.STM<A>
|
|
194
|
-
>(2, (self, f) =>
|
|
195
|
-
self.modify((a) =>
|
|
196
|
-
Option.match(f(a), {
|
|
197
|
-
onNone: () => [a, a],
|
|
198
|
-
onSome: (b) => [a, b]
|
|
199
|
-
})
|
|
200
|
-
))
|
|
201
|
-
|
|
202
|
-
/** @internal */
|
|
203
|
-
export const setAndGet = dual<
|
|
204
|
-
<A>(value: A) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<A>,
|
|
205
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, value: A) => STM.STM<A>
|
|
206
|
-
>(2, (self, value) => self.modify(() => [value, value]))
|
|
207
|
-
|
|
208
|
-
/** @internal */
|
|
209
|
-
export const modify = dual<
|
|
210
|
-
<A, B>(f: (a: A) => readonly [B, A]) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<B>,
|
|
211
|
-
<A, B>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => readonly [B, A]) => STM.STM<B>
|
|
212
|
-
>(2, (self, f) => self.modify(f))
|
|
213
|
-
|
|
214
|
-
/** @internal */
|
|
215
|
-
export const modifySome = dual<
|
|
216
|
-
<A, B>(
|
|
217
|
-
fallback: B,
|
|
218
|
-
f: (a: A) => Option.Option<readonly [B, A]>
|
|
219
|
-
) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<B>,
|
|
220
|
-
<A, B>(
|
|
221
|
-
self: TSubscriptionRef.TSubscriptionRef<A>,
|
|
222
|
-
fallback: B,
|
|
223
|
-
f: (a: A) => Option.Option<readonly [B, A]>
|
|
224
|
-
) => STM.STM<B>
|
|
225
|
-
>(3, (self, fallback, f) =>
|
|
226
|
-
self.modify((a) =>
|
|
227
|
-
Option.match(f(a), {
|
|
228
|
-
onNone: () => [fallback, a],
|
|
229
|
-
onSome: (b) => b
|
|
230
|
-
})
|
|
231
|
-
))
|
|
232
|
-
|
|
233
|
-
/** @internal */
|
|
234
|
-
export const update = dual<
|
|
235
|
-
<A>(f: (a: A) => A) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<void>,
|
|
236
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => A) => STM.STM<void>
|
|
237
|
-
>(2, (self, f) => self.modify((a) => [void 0, f(a)]))
|
|
238
|
-
|
|
239
|
-
/** @internal */
|
|
240
|
-
export const updateAndGet = dual<
|
|
241
|
-
<A>(f: (a: A) => A) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<A>,
|
|
242
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => A) => STM.STM<A>
|
|
243
|
-
>(2, (self, f) =>
|
|
244
|
-
self.modify((a) => {
|
|
245
|
-
const b = f(a)
|
|
246
|
-
return [b, b]
|
|
247
|
-
}))
|
|
248
|
-
|
|
249
|
-
/** @internal */
|
|
250
|
-
export const updateSome = dual<
|
|
251
|
-
<A>(f: (a: A) => Option.Option<A>) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<void>,
|
|
252
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => Option.Option<A>) => STM.STM<void>
|
|
253
|
-
>(
|
|
254
|
-
2,
|
|
255
|
-
(self, f) =>
|
|
256
|
-
self.modify((a) => [
|
|
257
|
-
void 0,
|
|
258
|
-
Option.match(f(a), {
|
|
259
|
-
onNone: () => a,
|
|
260
|
-
onSome: (b) => b
|
|
261
|
-
})
|
|
262
|
-
])
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
/** @internal */
|
|
266
|
-
export const updateSomeAndGet = dual<
|
|
267
|
-
<A>(f: (a: A) => Option.Option<A>) => (self: TSubscriptionRef.TSubscriptionRef<A>) => STM.STM<A>,
|
|
268
|
-
<A>(self: TSubscriptionRef.TSubscriptionRef<A>, f: (a: A) => Option.Option<A>) => STM.STM<A>
|
|
269
|
-
>(
|
|
270
|
-
2,
|
|
271
|
-
(self, f) =>
|
|
272
|
-
self.modify((a) =>
|
|
273
|
-
Option.match(f(a), {
|
|
274
|
-
onNone: () => [a, a],
|
|
275
|
-
onSome: (b) => [b, b]
|
|
276
|
-
})
|
|
277
|
-
)
|
|
278
|
-
)
|
|
279
|
-
|
|
280
|
-
/** @internal */
|
|
281
|
-
export const changesScoped = <A>(self: TSubscriptionRef.TSubscriptionRef<A>) =>
|
|
282
|
-
Effect.acquireRelease(self.changes, TQueue.shutdown)
|
|
283
|
-
|
|
284
|
-
/** @internal */
|
|
285
|
-
export const changesStream = <A>(self: TSubscriptionRef.TSubscriptionRef<A>) =>
|
|
286
|
-
stream.unwrap(Effect.map(self.changes, stream.fromTQueue))
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type * as Exit from "../../Exit.js"
|
|
2
|
-
import type * as Journal from "./journal.js"
|
|
3
|
-
import * as OpCodes from "./opCodes/tryCommit.js"
|
|
4
|
-
|
|
5
|
-
/** @internal */
|
|
6
|
-
export type TryCommit<A, E = never> = Done<A, E> | Suspend
|
|
7
|
-
|
|
8
|
-
/** @internal */
|
|
9
|
-
export interface Done<out A, out E> {
|
|
10
|
-
readonly _tag: OpCodes.OP_DONE
|
|
11
|
-
readonly exit: Exit.Exit<A, E>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** @internal */
|
|
15
|
-
export interface Suspend {
|
|
16
|
-
readonly _tag: OpCodes.OP_SUSPEND
|
|
17
|
-
readonly journal: Journal.Journal
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
export const done = <A, E>(exit: Exit.Exit<A, E>): TryCommit<A, E> => {
|
|
22
|
-
return {
|
|
23
|
-
_tag: OpCodes.OP_DONE,
|
|
24
|
-
exit
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @internal */
|
|
29
|
-
export const suspend = (journal: Journal.Journal): TryCommit<never> => {
|
|
30
|
-
return {
|
|
31
|
-
_tag: OpCodes.OP_SUSPEND,
|
|
32
|
-
journal
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** @internal */
|
|
2
|
-
export type TxnId = number & {
|
|
3
|
-
readonly TransactioId: unique symbol
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/** @internal */
|
|
7
|
-
const txnCounter = { ref: 0 }
|
|
8
|
-
|
|
9
|
-
/** @internal */
|
|
10
|
-
export const make = (): TxnId => {
|
|
11
|
-
const newId = txnCounter.ref + 1
|
|
12
|
-
txnCounter.ref = newId
|
|
13
|
-
return newId as TxnId
|
|
14
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type * as Chunk from "../../Chunk.js"
|
|
2
|
-
import type * as Fiber from "../../Fiber.js"
|
|
3
|
-
import type * as HandoffSignal from "./handoffSignal.js"
|
|
4
|
-
|
|
5
|
-
/** @internal */
|
|
6
|
-
export type DebounceState<A, E = never> = NotStarted | Previous<A> | Current<A, E>
|
|
7
|
-
|
|
8
|
-
/** @internal */
|
|
9
|
-
export const OP_NOT_STARTED = "NotStarted" as const
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export type OP_NOT_STARTED = typeof OP_NOT_STARTED
|
|
13
|
-
|
|
14
|
-
/** @internal */
|
|
15
|
-
export const OP_PREVIOUS = "Previous" as const
|
|
16
|
-
|
|
17
|
-
/** @internal */
|
|
18
|
-
export type OP_PREVIOUS = typeof OP_PREVIOUS
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
export const OP_CURRENT = "Current" as const
|
|
22
|
-
|
|
23
|
-
/** @internal */
|
|
24
|
-
export type OP_CURRENT = typeof OP_CURRENT
|
|
25
|
-
|
|
26
|
-
export interface NotStarted {
|
|
27
|
-
readonly _tag: OP_NOT_STARTED
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** @internal */
|
|
31
|
-
export interface Previous<out A> {
|
|
32
|
-
readonly _tag: OP_PREVIOUS
|
|
33
|
-
readonly fiber: Fiber.Fiber<Chunk.Chunk<A>>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @internal */
|
|
37
|
-
export interface Current<out A, out E = never> {
|
|
38
|
-
readonly _tag: OP_CURRENT
|
|
39
|
-
readonly fiber: Fiber.Fiber<HandoffSignal.HandoffSignal<A, E>, E>
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** @internal */
|
|
43
|
-
export const notStarted: DebounceState<never> = {
|
|
44
|
-
_tag: OP_NOT_STARTED
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** @internal */
|
|
48
|
-
export const previous = <A>(fiber: Fiber.Fiber<Chunk.Chunk<A>>): DebounceState<A> => ({
|
|
49
|
-
_tag: OP_PREVIOUS,
|
|
50
|
-
fiber
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
/** @internal */
|
|
54
|
-
export const current = <A, E>(fiber: Fiber.Fiber<HandoffSignal.HandoffSignal<A, E>, E>): DebounceState<A, E> => ({
|
|
55
|
-
_tag: OP_CURRENT,
|
|
56
|
-
fiber
|
|
57
|
-
})
|