@clayroach/effect 3.19.14-source-capture.8 → 3.19.14-source-trace.2
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/SourceLocation/package.json +6 -0
- package/dist/cjs/Effect.js +2 -28
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/FiberRef.js +12 -1
- package/dist/cjs/FiberRef.js.map +1 -1
- package/dist/cjs/Layer.js +2 -24
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/RuntimeFlags.js +1 -29
- package/dist/cjs/RuntimeFlags.js.map +1 -1
- package/dist/cjs/SourceLocation.js +60 -0
- package/dist/cjs/SourceLocation.js.map +1 -0
- package/dist/cjs/Tracer.js +1 -15
- package/dist/cjs/Tracer.js.map +1 -1
- package/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/cjs/internal/core.js +17 -50
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +18 -30
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +16 -65
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/layer/circular.js +1 -5
- package/dist/cjs/internal/layer/circular.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -3
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/logger.js +25 -2
- package/dist/cjs/internal/logger.js.map +1 -1
- package/dist/cjs/internal/runtimeFlags.js +2 -11
- package/dist/cjs/internal/runtimeFlags.js.map +1 -1
- package/dist/cjs/internal/tracer.js +1 -114
- package/dist/cjs/internal/tracer.js.map +1 -1
- package/dist/dts/Config.d.ts +2 -2
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +8 -29
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/FiberRef.d.ts +12 -0
- package/dist/dts/FiberRef.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +0 -22
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/RuntimeFlags.d.ts +0 -28
- package/dist/dts/RuntimeFlags.d.ts.map +1 -1
- package/dist/dts/SourceLocation.d.ts +88 -0
- package/dist/dts/SourceLocation.d.ts.map +1 -0
- package/dist/dts/Tracer.d.ts +0 -15
- package/dist/dts/Tracer.d.ts.map +1 -1
- package/dist/dts/index.d.ts +6 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/layer.d.ts.map +1 -1
- package/dist/dts/internal/runtimeFlags.d.ts.map +1 -1
- package/dist/esm/Effect.js +0 -26
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/FiberRef.js +11 -0
- package/dist/esm/FiberRef.js.map +1 -1
- package/dist/esm/Layer.js +0 -22
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/RuntimeFlags.js +0 -28
- package/dist/esm/RuntimeFlags.js.map +1 -1
- package/dist/esm/SourceLocation.js +51 -0
- package/dist/esm/SourceLocation.js.map +1 -0
- package/dist/esm/Tracer.js +0 -14
- package/dist/esm/Tracer.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/dist/esm/internal/core.js +12 -45
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +18 -30
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +13 -60
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/layer/circular.js +0 -4
- package/dist/esm/internal/layer/circular.js.map +1 -1
- package/dist/esm/internal/layer.js +0 -2
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/logger.js +25 -2
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/runtimeFlags.js +1 -9
- package/dist/esm/internal/runtimeFlags.js.map +1 -1
- package/dist/esm/internal/tracer.js +0 -111
- package/dist/esm/internal/tracer.js.map +1 -1
- package/package.json +12 -1
- package/src/Arbitrary.ts +1101 -0
- package/src/Array.ts +3589 -0
- package/src/BigDecimal.ts +1349 -0
- package/src/BigInt.ts +643 -0
- package/src/Boolean.ts +287 -0
- package/src/Brand.ts +360 -0
- package/src/Cache.ts +281 -0
- package/src/Cause.ts +1555 -0
- package/src/Channel.ts +2355 -0
- package/src/ChildExecutorDecision.ts +146 -0
- package/src/Chunk.ts +1495 -0
- package/src/Clock.ts +111 -0
- package/src/Config.ts +542 -0
- package/src/ConfigError.ts +270 -0
- package/src/ConfigProvider.ts +333 -0
- package/src/ConfigProviderPathPatch.ts +100 -0
- package/src/Console.ts +226 -0
- package/src/Context.ts +585 -0
- package/src/Cron.ts +706 -0
- package/src/Data.ts +596 -0
- package/src/DateTime.ts +1686 -0
- package/src/DefaultServices.ts +34 -0
- package/src/Deferred.ts +301 -0
- package/src/Differ.ts +450 -0
- package/src/Duration.ts +1000 -0
- package/src/Effect.ts +14817 -0
- package/src/Effectable.ts +107 -0
- package/src/Either.ts +1040 -0
- package/src/Encoding.ts +195 -0
- package/src/Equal.ts +98 -0
- package/src/Equivalence.ts +235 -0
- package/src/ExecutionPlan.ts +308 -0
- package/src/ExecutionStrategy.ts +119 -0
- package/src/Exit.ts +467 -0
- package/src/FastCheck.ts +9 -0
- package/src/Fiber.ts +744 -0
- package/src/FiberHandle.ts +540 -0
- package/src/FiberId.ts +195 -0
- package/src/FiberMap.ts +656 -0
- package/src/FiberRef.ts +444 -0
- package/src/FiberRefs.ts +204 -0
- package/src/FiberRefsPatch.ts +105 -0
- package/src/FiberSet.ts +491 -0
- package/src/FiberStatus.ts +108 -0
- package/src/Function.ts +1222 -0
- package/src/GlobalValue.ts +53 -0
- package/src/Graph.ts +3732 -0
- package/src/GroupBy.ts +103 -0
- package/src/HKT.ts +45 -0
- package/src/Hash.ts +195 -0
- package/src/HashMap.ts +519 -0
- package/src/HashRing.ts +317 -0
- package/src/HashSet.ts +2346 -0
- package/src/Inspectable.ts +287 -0
- package/src/Iterable.ts +1119 -0
- package/src/JSONSchema.ts +1044 -0
- package/src/KeyedPool.ts +167 -0
- package/src/Layer.ts +1228 -0
- package/src/LayerMap.ts +436 -0
- package/src/List.ts +977 -0
- package/src/LogLevel.ts +285 -0
- package/src/LogSpan.ts +25 -0
- package/src/Logger.ts +702 -0
- package/src/Mailbox.ts +268 -0
- package/src/ManagedRuntime.ts +180 -0
- package/src/Match.ts +1477 -0
- package/src/MergeDecision.ts +95 -0
- package/src/MergeState.ts +172 -0
- package/src/MergeStrategy.ts +107 -0
- package/src/Metric.ts +780 -0
- package/src/MetricBoundaries.ts +69 -0
- package/src/MetricHook.ts +151 -0
- package/src/MetricKey.ts +224 -0
- package/src/MetricKeyType.ts +262 -0
- package/src/MetricLabel.ts +47 -0
- package/src/MetricPair.ts +71 -0
- package/src/MetricPolling.ts +148 -0
- package/src/MetricRegistry.ts +48 -0
- package/src/MetricState.ts +257 -0
- package/src/Micro.ts +4405 -0
- package/src/ModuleVersion.ts +18 -0
- package/src/MutableHashMap.ts +411 -0
- package/src/MutableHashSet.ts +706 -0
- package/src/MutableList.ts +297 -0
- package/src/MutableQueue.ts +227 -0
- package/src/MutableRef.ts +202 -0
- package/src/NonEmptyIterable.ts +32 -0
- package/src/Number.ts +1071 -0
- package/src/Option.ts +2170 -0
- package/src/Order.ts +373 -0
- package/src/Ordering.ts +111 -0
- package/src/ParseResult.ts +2031 -0
- package/src/PartitionedSemaphore.ts +200 -0
- package/src/Pipeable.ts +566 -0
- package/src/Pool.ts +204 -0
- package/src/Predicate.ts +1405 -0
- package/src/Pretty.ts +205 -0
- package/src/PrimaryKey.ts +23 -0
- package/src/PubSub.ts +182 -0
- package/src/Queue.ts +644 -0
- package/src/Random.ts +204 -0
- package/src/RateLimiter.ts +138 -0
- package/src/RcMap.ts +141 -0
- package/src/RcRef.ts +122 -0
- package/src/Readable.ts +93 -0
- package/src/Record.ts +1274 -0
- package/src/RedBlackTree.ts +421 -0
- package/src/Redacted.ts +144 -0
- package/src/Ref.ts +180 -0
- package/src/RegExp.ts +38 -0
- package/src/Reloadable.ts +127 -0
- package/src/Request.ts +347 -0
- package/src/RequestBlock.ts +118 -0
- package/src/RequestResolver.ts +366 -0
- package/src/Resource.ts +119 -0
- package/src/Runtime.ts +383 -0
- package/src/RuntimeFlags.ts +336 -0
- package/src/RuntimeFlagsPatch.ts +183 -0
- package/src/STM.ts +2045 -0
- package/src/Schedule.ts +2219 -0
- package/src/ScheduleDecision.ts +62 -0
- package/src/ScheduleInterval.ts +151 -0
- package/src/ScheduleIntervals.ts +122 -0
- package/src/Scheduler.ts +353 -0
- package/src/Schema.ts +10914 -0
- package/src/SchemaAST.ts +3043 -0
- package/src/Scope.ts +204 -0
- package/src/ScopedCache.ts +151 -0
- package/src/ScopedRef.ts +117 -0
- package/src/Secret.ts +88 -0
- package/src/SingleProducerAsyncInput.ts +67 -0
- package/src/Sink.ts +1461 -0
- package/src/SortedMap.ts +287 -0
- package/src/SortedSet.ts +390 -0
- package/src/SourceLocation.ts +108 -0
- package/src/Stream.ts +6468 -0
- package/src/StreamEmit.ts +136 -0
- package/src/StreamHaltStrategy.ts +123 -0
- package/src/Streamable.ts +45 -0
- package/src/String.ts +778 -0
- package/src/Struct.ts +243 -0
- package/src/Subscribable.ts +100 -0
- package/src/SubscriptionRef.ts +298 -0
- package/src/Supervisor.ts +240 -0
- package/src/Symbol.ts +29 -0
- package/src/SynchronizedRef.ts +270 -0
- package/src/TArray.ts +495 -0
- package/src/TDeferred.ts +100 -0
- package/src/TMap.ts +515 -0
- package/src/TPriorityQueue.ts +223 -0
- package/src/TPubSub.ts +200 -0
- package/src/TQueue.ts +432 -0
- package/src/TRandom.ts +129 -0
- package/src/TReentrantLock.ts +224 -0
- package/src/TRef.ts +178 -0
- package/src/TSemaphore.ts +129 -0
- package/src/TSet.ts +365 -0
- package/src/TSubscriptionRef.ts +192 -0
- package/src/Take.ts +258 -0
- package/src/TestAnnotation.ts +158 -0
- package/src/TestAnnotationMap.ts +119 -0
- package/src/TestAnnotations.ts +117 -0
- package/src/TestClock.ts +556 -0
- package/src/TestConfig.ts +47 -0
- package/src/TestContext.ts +36 -0
- package/src/TestLive.ts +53 -0
- package/src/TestServices.ts +390 -0
- package/src/TestSized.ts +55 -0
- package/src/Tracer.ts +182 -0
- package/src/Trie.ts +840 -0
- package/src/Tuple.ts +305 -0
- package/src/Types.ts +353 -0
- package/src/Unify.ts +113 -0
- package/src/UpstreamPullRequest.ts +117 -0
- package/src/UpstreamPullStrategy.ts +121 -0
- package/src/Utils.ts +809 -0
- package/src/index.ts +1568 -0
- package/src/internal/array.ts +8 -0
- package/src/internal/blockedRequests.ts +520 -0
- package/src/internal/cache.ts +733 -0
- package/src/internal/cause.ts +1050 -0
- package/src/internal/channel/channelExecutor.ts +1200 -0
- package/src/internal/channel/channelState.ts +134 -0
- package/src/internal/channel/childExecutorDecision.ts +96 -0
- package/src/internal/channel/continuation.ts +200 -0
- package/src/internal/channel/mergeDecision.ts +113 -0
- package/src/internal/channel/mergeState.ts +120 -0
- package/src/internal/channel/mergeStrategy.ts +72 -0
- package/src/internal/channel/singleProducerAsyncInput.ts +259 -0
- package/src/internal/channel/subexecutor.ts +229 -0
- package/src/internal/channel/upstreamPullRequest.ts +84 -0
- package/src/internal/channel/upstreamPullStrategy.ts +87 -0
- package/src/internal/channel.ts +2603 -0
- package/src/internal/clock.ts +95 -0
- package/src/internal/completedRequestMap.ts +9 -0
- package/src/internal/concurrency.ts +54 -0
- package/src/internal/config.ts +716 -0
- package/src/internal/configError.ts +304 -0
- package/src/internal/configProvider/pathPatch.ts +97 -0
- package/src/internal/configProvider.ts +799 -0
- package/src/internal/console.ts +153 -0
- package/src/internal/context.ts +337 -0
- package/src/internal/core-effect.ts +2293 -0
- package/src/internal/core-stream.ts +998 -0
- package/src/internal/core.ts +3189 -0
- package/src/internal/data.ts +36 -0
- package/src/internal/dataSource.ts +327 -0
- package/src/internal/dateTime.ts +1277 -0
- package/src/internal/defaultServices/console.ts +100 -0
- package/src/internal/defaultServices.ts +163 -0
- package/src/internal/deferred.ts +46 -0
- package/src/internal/differ/chunkPatch.ts +211 -0
- package/src/internal/differ/contextPatch.ts +232 -0
- package/src/internal/differ/hashMapPatch.ts +220 -0
- package/src/internal/differ/hashSetPatch.ts +176 -0
- package/src/internal/differ/orPatch.ts +311 -0
- package/src/internal/differ/readonlyArrayPatch.ts +210 -0
- package/src/internal/differ.ts +200 -0
- package/src/internal/doNotation.ts +80 -0
- package/src/internal/effect/circular.ts +895 -0
- package/src/internal/effectable.ts +131 -0
- package/src/internal/either.ts +110 -0
- package/src/internal/encoding/base64.ts +286 -0
- package/src/internal/encoding/base64Url.ts +29 -0
- package/src/internal/encoding/common.ts +51 -0
- package/src/internal/encoding/hex.ts +315 -0
- package/src/internal/errors.ts +7 -0
- package/src/internal/executionPlan.ts +114 -0
- package/src/internal/executionStrategy.ts +74 -0
- package/src/internal/fiber.ts +388 -0
- package/src/internal/fiberId.ts +267 -0
- package/src/internal/fiberMessage.ts +82 -0
- package/src/internal/fiberRefs/patch.ts +144 -0
- package/src/internal/fiberRefs.ts +297 -0
- package/src/internal/fiberRuntime.ts +3842 -0
- package/src/internal/fiberScope.ts +71 -0
- package/src/internal/fiberStatus.ts +119 -0
- package/src/internal/groupBy.ts +530 -0
- package/src/internal/hashMap/array.ts +49 -0
- package/src/internal/hashMap/bitwise.ts +32 -0
- package/src/internal/hashMap/config.ts +14 -0
- package/src/internal/hashMap/keySet.ts +8 -0
- package/src/internal/hashMap/node.ts +391 -0
- package/src/internal/hashMap.ts +586 -0
- package/src/internal/hashSet.ts +323 -0
- package/src/internal/keyedPool.ts +244 -0
- package/src/internal/layer/circular.ts +214 -0
- package/src/internal/layer.ts +1483 -0
- package/src/internal/logSpan.ts +20 -0
- package/src/internal/logger-circular.ts +24 -0
- package/src/internal/logger.ts +522 -0
- package/src/internal/mailbox.ts +561 -0
- package/src/internal/managedRuntime/circular.ts +6 -0
- package/src/internal/managedRuntime.ts +134 -0
- package/src/internal/matcher.ts +652 -0
- package/src/internal/metric/boundaries.ts +75 -0
- package/src/internal/metric/hook.ts +483 -0
- package/src/internal/metric/key.ts +167 -0
- package/src/internal/metric/keyType.ts +238 -0
- package/src/internal/metric/label.ts +41 -0
- package/src/internal/metric/pair.ts +48 -0
- package/src/internal/metric/polling.ts +149 -0
- package/src/internal/metric/registry.ts +187 -0
- package/src/internal/metric/state.ts +290 -0
- package/src/internal/metric.ts +577 -0
- package/src/internal/opCodes/cause.ts +35 -0
- package/src/internal/opCodes/channel.ts +83 -0
- package/src/internal/opCodes/channelChildExecutorDecision.ts +17 -0
- package/src/internal/opCodes/channelMergeDecision.ts +11 -0
- package/src/internal/opCodes/channelMergeState.ts +17 -0
- package/src/internal/opCodes/channelMergeStrategy.ts +11 -0
- package/src/internal/opCodes/channelState.ts +23 -0
- package/src/internal/opCodes/channelUpstreamPullRequest.ts +11 -0
- package/src/internal/opCodes/channelUpstreamPullStrategy.ts +11 -0
- package/src/internal/opCodes/config.ts +65 -0
- package/src/internal/opCodes/configError.ts +35 -0
- package/src/internal/opCodes/continuation.ts +11 -0
- package/src/internal/opCodes/deferred.ts +11 -0
- package/src/internal/opCodes/effect.ts +89 -0
- package/src/internal/opCodes/layer.ts +59 -0
- package/src/internal/opCodes/streamHaltStrategy.ts +23 -0
- package/src/internal/option.ts +80 -0
- package/src/internal/pool.ts +432 -0
- package/src/internal/pubsub.ts +1762 -0
- package/src/internal/query.ts +204 -0
- package/src/internal/queue.ts +766 -0
- package/src/internal/random.ts +161 -0
- package/src/internal/rateLimiter.ts +93 -0
- package/src/internal/rcMap.ts +285 -0
- package/src/internal/rcRef.ts +192 -0
- package/src/internal/redBlackTree/iterator.ts +200 -0
- package/src/internal/redBlackTree/node.ts +68 -0
- package/src/internal/redBlackTree.ts +1245 -0
- package/src/internal/redacted.ts +73 -0
- package/src/internal/ref.ts +171 -0
- package/src/internal/reloadable.ts +140 -0
- package/src/internal/request.ts +177 -0
- package/src/internal/resource.ts +76 -0
- package/src/internal/ringBuffer.ts +68 -0
- package/src/internal/runtime.ts +558 -0
- package/src/internal/runtimeFlags.ts +178 -0
- package/src/internal/runtimeFlagsPatch.ts +103 -0
- package/src/internal/schedule/decision.ts +47 -0
- package/src/internal/schedule/interval.ts +101 -0
- package/src/internal/schedule/intervals.ts +180 -0
- package/src/internal/schedule.ts +2199 -0
- package/src/internal/schema/errors.ts +191 -0
- package/src/internal/schema/schemaId.ts +106 -0
- package/src/internal/schema/util.ts +50 -0
- package/src/internal/scopedCache.ts +644 -0
- package/src/internal/scopedRef.ts +118 -0
- package/src/internal/secret.ts +89 -0
- package/src/internal/singleShotGen.ts +35 -0
- package/src/internal/sink.ts +2120 -0
- package/src/internal/stack.ts +10 -0
- package/src/internal/stm/core.ts +817 -0
- package/src/internal/stm/entry.ts +59 -0
- package/src/internal/stm/journal.ts +123 -0
- package/src/internal/stm/opCodes/stm.ts +71 -0
- package/src/internal/stm/opCodes/stmState.ts +17 -0
- package/src/internal/stm/opCodes/strategy.ts +17 -0
- package/src/internal/stm/opCodes/tExit.ts +29 -0
- package/src/internal/stm/opCodes/tryCommit.ts +11 -0
- package/src/internal/stm/stm.ts +1453 -0
- package/src/internal/stm/stmState.ts +136 -0
- package/src/internal/stm/tArray.ts +550 -0
- package/src/internal/stm/tDeferred.ts +81 -0
- package/src/internal/stm/tExit.ts +190 -0
- package/src/internal/stm/tMap.ts +824 -0
- package/src/internal/stm/tPriorityQueue.ts +267 -0
- package/src/internal/stm/tPubSub.ts +551 -0
- package/src/internal/stm/tQueue.ts +393 -0
- package/src/internal/stm/tRandom.ts +140 -0
- package/src/internal/stm/tReentrantLock.ts +352 -0
- package/src/internal/stm/tRef.ts +195 -0
- package/src/internal/stm/tSemaphore.ts +113 -0
- package/src/internal/stm/tSet.ts +259 -0
- package/src/internal/stm/tSubscriptionRef.ts +286 -0
- package/src/internal/stm/tryCommit.ts +34 -0
- package/src/internal/stm/txnId.ts +14 -0
- package/src/internal/stm/versioned.ts +4 -0
- package/src/internal/stream/debounceState.ts +57 -0
- package/src/internal/stream/emit.ts +123 -0
- package/src/internal/stream/haltStrategy.ts +94 -0
- package/src/internal/stream/handoff.ts +187 -0
- package/src/internal/stream/handoffSignal.ts +59 -0
- package/src/internal/stream/pull.ts +34 -0
- package/src/internal/stream/sinkEndReason.ts +30 -0
- package/src/internal/stream/zipAllState.ts +88 -0
- package/src/internal/stream/zipChunksState.ts +56 -0
- package/src/internal/stream.ts +8801 -0
- package/src/internal/string-utils.ts +107 -0
- package/src/internal/subscriptionRef.ts +138 -0
- package/src/internal/supervisor/patch.ts +190 -0
- package/src/internal/supervisor.ts +303 -0
- package/src/internal/synchronizedRef.ts +114 -0
- package/src/internal/take.ts +199 -0
- package/src/internal/testing/sleep.ts +27 -0
- package/src/internal/testing/suspendedWarningData.ts +85 -0
- package/src/internal/testing/warningData.ts +94 -0
- package/src/internal/tracer.ts +150 -0
- package/src/internal/trie.ts +722 -0
- package/src/internal/version.ts +7 -0
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
import type * as Cause from "../../Cause.js"
|
|
2
|
+
import type * as Deferred from "../../Deferred.js"
|
|
3
|
+
import * as Duration from "../../Duration.js"
|
|
4
|
+
import type * as Effect from "../../Effect.js"
|
|
5
|
+
import * as Effectable from "../../Effectable.js"
|
|
6
|
+
import * as Equal from "../../Equal.js"
|
|
7
|
+
import type { Equivalence } from "../../Equivalence.js"
|
|
8
|
+
import * as Exit from "../../Exit.js"
|
|
9
|
+
import type * as Fiber from "../../Fiber.js"
|
|
10
|
+
import * as FiberId from "../../FiberId.js"
|
|
11
|
+
import type * as FiberRefsPatch from "../../FiberRefsPatch.js"
|
|
12
|
+
import type { LazyArg } from "../../Function.js"
|
|
13
|
+
import { dual, pipe } from "../../Function.js"
|
|
14
|
+
import * as Hash from "../../Hash.js"
|
|
15
|
+
import * as MutableHashMap from "../../MutableHashMap.js"
|
|
16
|
+
import * as Option from "../../Option.js"
|
|
17
|
+
import { pipeArguments } from "../../Pipeable.js"
|
|
18
|
+
import * as Predicate from "../../Predicate.js"
|
|
19
|
+
import * as Readable from "../../Readable.js"
|
|
20
|
+
import type * as Ref from "../../Ref.js"
|
|
21
|
+
import { currentScheduler } from "../../Scheduler.js"
|
|
22
|
+
import type * as Scope from "../../Scope.js"
|
|
23
|
+
import type * as Supervisor from "../../Supervisor.js"
|
|
24
|
+
import type * as Synchronized from "../../SynchronizedRef.js"
|
|
25
|
+
import type * as Types from "../../Types.js"
|
|
26
|
+
import * as internalCause from "../cause.js"
|
|
27
|
+
import * as effect from "../core-effect.js"
|
|
28
|
+
import * as core from "../core.js"
|
|
29
|
+
import * as internalFiber from "../fiber.js"
|
|
30
|
+
import * as fiberRuntime from "../fiberRuntime.js"
|
|
31
|
+
import { globalScope } from "../fiberScope.js"
|
|
32
|
+
import * as internalRef from "../ref.js"
|
|
33
|
+
import * as supervisor from "../supervisor.js"
|
|
34
|
+
|
|
35
|
+
/** @internal */
|
|
36
|
+
class Semaphore {
|
|
37
|
+
public waiters = new Set<() => void>()
|
|
38
|
+
public taken = 0
|
|
39
|
+
|
|
40
|
+
constructor(public permits: number) {}
|
|
41
|
+
|
|
42
|
+
get free() {
|
|
43
|
+
return this.permits - this.taken
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
readonly take = (n: number): Effect.Effect<number> =>
|
|
47
|
+
core.asyncInterrupt<number>((resume) => {
|
|
48
|
+
if (this.free < n) {
|
|
49
|
+
const observer = () => {
|
|
50
|
+
if (this.free < n) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
this.waiters.delete(observer)
|
|
54
|
+
this.taken += n
|
|
55
|
+
resume(core.succeed(n))
|
|
56
|
+
}
|
|
57
|
+
this.waiters.add(observer)
|
|
58
|
+
return core.sync(() => {
|
|
59
|
+
this.waiters.delete(observer)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
this.taken += n
|
|
63
|
+
return resume(core.succeed(n))
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
updateTakenUnsafe(fiber: Fiber.RuntimeFiber<any, any>, f: (n: number) => number): Effect.Effect<number> {
|
|
67
|
+
this.taken = f(this.taken)
|
|
68
|
+
if (this.waiters.size > 0) {
|
|
69
|
+
fiber.getFiberRef(currentScheduler).scheduleTask(() => {
|
|
70
|
+
const iter = this.waiters.values()
|
|
71
|
+
let item = iter.next()
|
|
72
|
+
while (item.done === false && this.free > 0) {
|
|
73
|
+
item.value()
|
|
74
|
+
item = iter.next()
|
|
75
|
+
}
|
|
76
|
+
}, fiber.getFiberRef(core.currentSchedulingPriority))
|
|
77
|
+
}
|
|
78
|
+
return core.succeed(this.free)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
updateTaken(f: (n: number) => number): Effect.Effect<number> {
|
|
82
|
+
return core.withFiberRuntime((fiber) => this.updateTakenUnsafe(fiber, f))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
readonly resize = (permits: number) =>
|
|
86
|
+
core.asVoid(
|
|
87
|
+
core.withFiberRuntime((fiber) => {
|
|
88
|
+
this.permits = permits
|
|
89
|
+
if (this.free < 0) {
|
|
90
|
+
return core.void
|
|
91
|
+
}
|
|
92
|
+
return this.updateTakenUnsafe(fiber, (taken) => taken)
|
|
93
|
+
})
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
readonly release = (n: number): Effect.Effect<number> => this.updateTaken((taken) => taken - n)
|
|
97
|
+
|
|
98
|
+
readonly releaseAll: Effect.Effect<number> = this.updateTaken((_) => 0)
|
|
99
|
+
|
|
100
|
+
readonly withPermits = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
101
|
+
core.uninterruptibleMask((restore) =>
|
|
102
|
+
core.flatMap(
|
|
103
|
+
restore(this.take(n)),
|
|
104
|
+
(permits) => fiberRuntime.ensuring(restore(self), this.release(permits))
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
readonly withPermitsIfAvailable = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
109
|
+
core.uninterruptibleMask((restore) =>
|
|
110
|
+
core.suspend(() => {
|
|
111
|
+
if (this.free < n) {
|
|
112
|
+
return effect.succeedNone
|
|
113
|
+
}
|
|
114
|
+
this.taken += n
|
|
115
|
+
return fiberRuntime.ensuring(restore(effect.asSome(self)), this.release(n))
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** @internal */
|
|
121
|
+
export const unsafeMakeSemaphore = (permits: number): Effect.Semaphore => new Semaphore(permits)
|
|
122
|
+
|
|
123
|
+
/** @internal */
|
|
124
|
+
export const makeSemaphore = (permits: number) => core.sync(() => unsafeMakeSemaphore(permits))
|
|
125
|
+
|
|
126
|
+
class Latch extends Effectable.Class<void> implements Effect.Latch {
|
|
127
|
+
waiters: Array<(_: Effect.Effect<void>) => void> = []
|
|
128
|
+
scheduled = false
|
|
129
|
+
constructor(private isOpen: boolean) {
|
|
130
|
+
super()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
commit() {
|
|
134
|
+
return this.await
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private unsafeSchedule(fiber: Fiber.RuntimeFiber<void>) {
|
|
138
|
+
if (this.scheduled || this.waiters.length === 0) {
|
|
139
|
+
return core.void
|
|
140
|
+
}
|
|
141
|
+
this.scheduled = true
|
|
142
|
+
fiber.currentScheduler.scheduleTask(this.flushWaiters, fiber.getFiberRef(core.currentSchedulingPriority))
|
|
143
|
+
return core.void
|
|
144
|
+
}
|
|
145
|
+
private flushWaiters = () => {
|
|
146
|
+
this.scheduled = false
|
|
147
|
+
const waiters = this.waiters
|
|
148
|
+
this.waiters = []
|
|
149
|
+
for (let i = 0; i < waiters.length; i++) {
|
|
150
|
+
waiters[i](core.exitVoid)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
open = core.withFiberRuntime<void>((fiber) => {
|
|
155
|
+
if (this.isOpen) {
|
|
156
|
+
return core.void
|
|
157
|
+
}
|
|
158
|
+
this.isOpen = true
|
|
159
|
+
return this.unsafeSchedule(fiber)
|
|
160
|
+
})
|
|
161
|
+
unsafeOpen() {
|
|
162
|
+
if (this.isOpen) return
|
|
163
|
+
this.isOpen = true
|
|
164
|
+
this.flushWaiters()
|
|
165
|
+
}
|
|
166
|
+
release = core.withFiberRuntime<void>((fiber) => {
|
|
167
|
+
if (this.isOpen) {
|
|
168
|
+
return core.void
|
|
169
|
+
}
|
|
170
|
+
return this.unsafeSchedule(fiber)
|
|
171
|
+
})
|
|
172
|
+
await = core.asyncInterrupt<void>((resume) => {
|
|
173
|
+
if (this.isOpen) {
|
|
174
|
+
return resume(core.void)
|
|
175
|
+
}
|
|
176
|
+
this.waiters.push(resume)
|
|
177
|
+
return core.sync(() => {
|
|
178
|
+
const index = this.waiters.indexOf(resume)
|
|
179
|
+
if (index !== -1) {
|
|
180
|
+
this.waiters.splice(index, 1)
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
unsafeClose() {
|
|
185
|
+
this.isOpen = false
|
|
186
|
+
}
|
|
187
|
+
close = core.sync(() => {
|
|
188
|
+
this.isOpen = false
|
|
189
|
+
})
|
|
190
|
+
whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => {
|
|
191
|
+
return core.zipRight(this.await, self)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** @internal */
|
|
196
|
+
export const unsafeMakeLatch = (open?: boolean | undefined): Effect.Latch => new Latch(open ?? false)
|
|
197
|
+
|
|
198
|
+
/** @internal */
|
|
199
|
+
export const makeLatch = (open?: boolean | undefined) => core.sync(() => unsafeMakeLatch(open))
|
|
200
|
+
|
|
201
|
+
/** @internal */
|
|
202
|
+
export const awaitAllChildren = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
203
|
+
ensuringChildren(self, fiberRuntime.fiberAwaitAll)
|
|
204
|
+
|
|
205
|
+
/** @internal */
|
|
206
|
+
export const cached: {
|
|
207
|
+
(
|
|
208
|
+
timeToLive: Duration.DurationInput
|
|
209
|
+
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Effect.Effect<A, E>, never, R>
|
|
210
|
+
<A, E, R>(
|
|
211
|
+
self: Effect.Effect<A, E, R>,
|
|
212
|
+
timeToLive: Duration.DurationInput
|
|
213
|
+
): Effect.Effect<Effect.Effect<A, E>, never, R>
|
|
214
|
+
} = dual(
|
|
215
|
+
2,
|
|
216
|
+
<A, E, R>(
|
|
217
|
+
self: Effect.Effect<A, E, R>,
|
|
218
|
+
timeToLive: Duration.DurationInput
|
|
219
|
+
): Effect.Effect<Effect.Effect<A, E>, never, R> =>
|
|
220
|
+
core.map(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0])
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
/** @internal */
|
|
224
|
+
export const cachedInvalidateWithTTL: {
|
|
225
|
+
(timeToLive: Duration.DurationInput): <A, E, R>(
|
|
226
|
+
self: Effect.Effect<A, E, R>
|
|
227
|
+
) => Effect.Effect<[Effect.Effect<A, E>, Effect.Effect<void>], never, R>
|
|
228
|
+
<A, E, R>(
|
|
229
|
+
self: Effect.Effect<A, E, R>,
|
|
230
|
+
timeToLive: Duration.DurationInput
|
|
231
|
+
): Effect.Effect<[Effect.Effect<A, E>, Effect.Effect<void>], never, R>
|
|
232
|
+
} = dual(
|
|
233
|
+
2,
|
|
234
|
+
<A, E, R>(
|
|
235
|
+
self: Effect.Effect<A, E, R>,
|
|
236
|
+
timeToLive: Duration.DurationInput
|
|
237
|
+
): Effect.Effect<[Effect.Effect<A, E>, Effect.Effect<void>], never, R> => {
|
|
238
|
+
const duration = Duration.decode(timeToLive)
|
|
239
|
+
return core.flatMap(
|
|
240
|
+
core.context<R>(),
|
|
241
|
+
(env) =>
|
|
242
|
+
core.map(
|
|
243
|
+
makeSynchronized<Option.Option<readonly [number, Deferred.Deferred<A, E>]>>(Option.none()),
|
|
244
|
+
(cache) =>
|
|
245
|
+
[
|
|
246
|
+
core.provideContext(getCachedValue(self, duration, cache), env),
|
|
247
|
+
invalidateCache(cache)
|
|
248
|
+
] as [Effect.Effect<A, E>, Effect.Effect<void>]
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
/** @internal */
|
|
255
|
+
const computeCachedValue = <A, E, R>(
|
|
256
|
+
self: Effect.Effect<A, E, R>,
|
|
257
|
+
timeToLive: Duration.DurationInput,
|
|
258
|
+
start: number
|
|
259
|
+
): Effect.Effect<Option.Option<[number, Deferred.Deferred<A, E>]>, never, R> => {
|
|
260
|
+
const timeToLiveMillis = Duration.toMillis(Duration.decode(timeToLive))
|
|
261
|
+
return pipe(
|
|
262
|
+
core.deferredMake<A, E>(),
|
|
263
|
+
core.tap((deferred) => core.intoDeferred(self, deferred)),
|
|
264
|
+
core.map((deferred) => Option.some([start + timeToLiveMillis, deferred]))
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** @internal */
|
|
269
|
+
const getCachedValue = <A, E, R>(
|
|
270
|
+
self: Effect.Effect<A, E, R>,
|
|
271
|
+
timeToLive: Duration.DurationInput,
|
|
272
|
+
cache: Synchronized.SynchronizedRef<Option.Option<readonly [number, Deferred.Deferred<A, E>]>>
|
|
273
|
+
): Effect.Effect<A, E, R> =>
|
|
274
|
+
core.uninterruptibleMask((restore) =>
|
|
275
|
+
pipe(
|
|
276
|
+
effect.clockWith((clock) => clock.currentTimeMillis),
|
|
277
|
+
core.flatMap((time) =>
|
|
278
|
+
updateSomeAndGetEffectSynchronized(cache, (option) => {
|
|
279
|
+
switch (option._tag) {
|
|
280
|
+
case "None": {
|
|
281
|
+
return Option.some(computeCachedValue(self, timeToLive, time))
|
|
282
|
+
}
|
|
283
|
+
case "Some": {
|
|
284
|
+
const [end] = option.value
|
|
285
|
+
return end - time <= 0
|
|
286
|
+
? Option.some(computeCachedValue(self, timeToLive, time))
|
|
287
|
+
: Option.none()
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
),
|
|
292
|
+
core.flatMap((option) =>
|
|
293
|
+
Option.isNone(option) ?
|
|
294
|
+
core.dieMessage(
|
|
295
|
+
"BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues"
|
|
296
|
+
) :
|
|
297
|
+
restore(core.deferredAwait(option.value[1]))
|
|
298
|
+
)
|
|
299
|
+
)
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
/** @internal */
|
|
303
|
+
const invalidateCache = <A, E>(
|
|
304
|
+
cache: Synchronized.SynchronizedRef<Option.Option<readonly [number, Deferred.Deferred<A, E>]>>
|
|
305
|
+
): Effect.Effect<void> => internalRef.set(cache, Option.none())
|
|
306
|
+
|
|
307
|
+
/** @internal */
|
|
308
|
+
export const ensuringChild = dual<
|
|
309
|
+
<X, R2>(
|
|
310
|
+
f: (fiber: Fiber.Fiber<ReadonlyArray<unknown>, any>) => Effect.Effect<X, never, R2>
|
|
311
|
+
) => <A, E, R>(
|
|
312
|
+
self: Effect.Effect<A, E, R>
|
|
313
|
+
) => Effect.Effect<A, E, R | R2>,
|
|
314
|
+
<A, E, R, X, R2>(
|
|
315
|
+
self: Effect.Effect<A, E, R>,
|
|
316
|
+
f: (fiber: Fiber.Fiber<ReadonlyArray<unknown>, any>) => Effect.Effect<X, never, R2>
|
|
317
|
+
) => Effect.Effect<A, E, R | R2>
|
|
318
|
+
>(2, (self, f) => ensuringChildren(self, (children) => f(fiberRuntime.fiberAll(children))))
|
|
319
|
+
|
|
320
|
+
/** @internal */
|
|
321
|
+
export const ensuringChildren = dual<
|
|
322
|
+
<X, R2>(
|
|
323
|
+
children: (fibers: ReadonlyArray<Fiber.RuntimeFiber<any, any>>) => Effect.Effect<X, never, R2>
|
|
324
|
+
) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R | R2>,
|
|
325
|
+
<A, E, R, X, R2>(
|
|
326
|
+
self: Effect.Effect<A, E, R>,
|
|
327
|
+
children: (fibers: ReadonlyArray<Fiber.RuntimeFiber<any, any>>) => Effect.Effect<X, never, R2>
|
|
328
|
+
) => Effect.Effect<A, E, R | R2>
|
|
329
|
+
>(2, (self, children) =>
|
|
330
|
+
core.flatMap(supervisor.track, (supervisor) =>
|
|
331
|
+
pipe(
|
|
332
|
+
supervised(self, supervisor),
|
|
333
|
+
fiberRuntime.ensuring(core.flatMap(supervisor.value, children))
|
|
334
|
+
)))
|
|
335
|
+
|
|
336
|
+
/** @internal */
|
|
337
|
+
export const forkAll: {
|
|
338
|
+
(
|
|
339
|
+
options?: {
|
|
340
|
+
readonly discard?: false | undefined
|
|
341
|
+
}
|
|
342
|
+
): <Eff extends Effect.Effect<any, any, any>>(
|
|
343
|
+
effects: Iterable<Eff>
|
|
344
|
+
) => Effect.Effect<
|
|
345
|
+
Fiber.Fiber<Array<Effect.Effect.Success<Eff>>, Effect.Effect.Error<Eff>>,
|
|
346
|
+
never,
|
|
347
|
+
Effect.Effect.Context<Eff>
|
|
348
|
+
>
|
|
349
|
+
(options: {
|
|
350
|
+
readonly discard: true
|
|
351
|
+
}): <Eff extends Effect.Effect<any, any, any>>(
|
|
352
|
+
effects: Iterable<Eff>
|
|
353
|
+
) => Effect.Effect<void, never, Effect.Effect.Context<Eff>>
|
|
354
|
+
<Eff extends Effect.Effect<any, any, any>>(
|
|
355
|
+
effects: Iterable<Eff>,
|
|
356
|
+
options?: {
|
|
357
|
+
readonly discard?: false | undefined
|
|
358
|
+
}
|
|
359
|
+
): Effect.Effect<
|
|
360
|
+
Fiber.Fiber<Array<Effect.Effect.Success<Eff>>, Effect.Effect.Error<Eff>>,
|
|
361
|
+
never,
|
|
362
|
+
Effect.Effect.Context<Eff>
|
|
363
|
+
>
|
|
364
|
+
<Eff extends Effect.Effect<any, any, any>>(effects: Iterable<Eff>, options: {
|
|
365
|
+
readonly discard: true
|
|
366
|
+
}): Effect.Effect<void, never, Effect.Effect.Context<Eff>>
|
|
367
|
+
} = dual((args) => Predicate.isIterable(args[0]), <A, E, R>(effects: Iterable<Effect.Effect<A, E, R>>, options: {
|
|
368
|
+
readonly discard: true
|
|
369
|
+
}): Effect.Effect<void, never, R> =>
|
|
370
|
+
options?.discard ?
|
|
371
|
+
core.forEachSequentialDiscard(effects, fiberRuntime.fork) :
|
|
372
|
+
core.map(core.forEachSequential(effects, fiberRuntime.fork), fiberRuntime.fiberAll))
|
|
373
|
+
|
|
374
|
+
/** @internal */
|
|
375
|
+
export const forkIn = dual<
|
|
376
|
+
(scope: Scope.Scope) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Fiber.RuntimeFiber<A, E>, never, R>,
|
|
377
|
+
<A, E, R>(self: Effect.Effect<A, E, R>, scope: Scope.Scope) => Effect.Effect<Fiber.RuntimeFiber<A, E>, never, R>
|
|
378
|
+
>(
|
|
379
|
+
2,
|
|
380
|
+
(self, scope) =>
|
|
381
|
+
core.withFiberRuntime((parent, parentStatus) => {
|
|
382
|
+
const scopeImpl = scope as fiberRuntime.ScopeImpl
|
|
383
|
+
const fiber = fiberRuntime.unsafeFork(self, parent, parentStatus.runtimeFlags, globalScope)
|
|
384
|
+
if (scopeImpl.state._tag === "Open") {
|
|
385
|
+
const finalizer = () =>
|
|
386
|
+
core.fiberIdWith((fiberId) =>
|
|
387
|
+
Equal.equals(fiberId, fiber.id()) ?
|
|
388
|
+
core.void :
|
|
389
|
+
core.asVoid(core.interruptFiber(fiber))
|
|
390
|
+
)
|
|
391
|
+
const key = {}
|
|
392
|
+
scopeImpl.state.finalizers.set(key, finalizer)
|
|
393
|
+
fiber.addObserver(() => {
|
|
394
|
+
if (scopeImpl.state._tag === "Closed") return
|
|
395
|
+
scopeImpl.state.finalizers.delete(key)
|
|
396
|
+
})
|
|
397
|
+
} else {
|
|
398
|
+
fiber.unsafeInterruptAsFork(parent.id())
|
|
399
|
+
}
|
|
400
|
+
return core.succeed(fiber)
|
|
401
|
+
})
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
/** @internal */
|
|
405
|
+
export const forkScoped = <A, E, R>(
|
|
406
|
+
self: Effect.Effect<A, E, R>
|
|
407
|
+
): Effect.Effect<Fiber.RuntimeFiber<A, E>, never, R | Scope.Scope> =>
|
|
408
|
+
fiberRuntime.scopeWith((scope) => forkIn(self, scope))
|
|
409
|
+
|
|
410
|
+
/** @internal */
|
|
411
|
+
export const fromFiber = <A, E>(fiber: Fiber.Fiber<A, E>): Effect.Effect<A, E> => internalFiber.join(fiber)
|
|
412
|
+
|
|
413
|
+
/** @internal */
|
|
414
|
+
export const fromFiberEffect = <A, E, R>(fiber: Effect.Effect<Fiber.Fiber<A, E>, E, R>): Effect.Effect<A, E, R> =>
|
|
415
|
+
core.suspend(() => core.flatMap(fiber, internalFiber.join))
|
|
416
|
+
|
|
417
|
+
const memoKeySymbol = Symbol.for("effect/Effect/memoizeFunction.key")
|
|
418
|
+
|
|
419
|
+
class Key<in out A> implements Equal.Equal {
|
|
420
|
+
[memoKeySymbol] = memoKeySymbol
|
|
421
|
+
constructor(readonly a: A, readonly eq?: Equivalence<A>) {}
|
|
422
|
+
[Equal.symbol](that: Equal.Equal) {
|
|
423
|
+
if (Predicate.hasProperty(that, memoKeySymbol)) {
|
|
424
|
+
if (this.eq) {
|
|
425
|
+
return this.eq(this.a, (that as unknown as Key<A>).a)
|
|
426
|
+
} else {
|
|
427
|
+
return Equal.equals(this.a, (that as unknown as Key<A>).a)
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return false
|
|
431
|
+
}
|
|
432
|
+
[Hash.symbol]() {
|
|
433
|
+
return this.eq ? 0 : Hash.cached(this, Hash.hash(this.a))
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** @internal */
|
|
438
|
+
export const cachedFunction = <A, B, E, R>(
|
|
439
|
+
f: (a: A) => Effect.Effect<B, E, R>,
|
|
440
|
+
eq?: Equivalence<A>
|
|
441
|
+
): Effect.Effect<(a: A) => Effect.Effect<B, E, R>> => {
|
|
442
|
+
return pipe(
|
|
443
|
+
core.sync(() => MutableHashMap.empty<Key<A>, Deferred.Deferred<readonly [FiberRefsPatch.FiberRefsPatch, B], E>>()),
|
|
444
|
+
core.flatMap(makeSynchronized),
|
|
445
|
+
core.map((ref) => (a: A) =>
|
|
446
|
+
pipe(
|
|
447
|
+
ref.modifyEffect((map) => {
|
|
448
|
+
const result = pipe(map, MutableHashMap.get(new Key(a, eq)))
|
|
449
|
+
if (Option.isNone(result)) {
|
|
450
|
+
return pipe(
|
|
451
|
+
core.deferredMake<readonly [FiberRefsPatch.FiberRefsPatch, B], E>(),
|
|
452
|
+
core.tap((deferred) =>
|
|
453
|
+
pipe(
|
|
454
|
+
effect.diffFiberRefs(f(a)),
|
|
455
|
+
core.intoDeferred(deferred),
|
|
456
|
+
fiberRuntime.fork
|
|
457
|
+
)
|
|
458
|
+
),
|
|
459
|
+
core.map((deferred) => [deferred, pipe(map, MutableHashMap.set(new Key(a, eq), deferred))] as const)
|
|
460
|
+
)
|
|
461
|
+
}
|
|
462
|
+
return core.succeed([result.value, map] as const)
|
|
463
|
+
}),
|
|
464
|
+
core.flatMap(core.deferredAwait),
|
|
465
|
+
core.flatMap(([patch, b]) => pipe(effect.patchFiberRefs(patch), core.as(b)))
|
|
466
|
+
)
|
|
467
|
+
)
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** @internal */
|
|
472
|
+
export const raceFirst = dual<
|
|
473
|
+
<A2, E2, R2>(
|
|
474
|
+
that: Effect.Effect<A2, E2, R2>
|
|
475
|
+
) => <A, E, R>(
|
|
476
|
+
self: Effect.Effect<A, E, R>
|
|
477
|
+
) => Effect.Effect<A2 | A, E2 | E, R | R2>,
|
|
478
|
+
<A, E, R, A2, E2, R2>(
|
|
479
|
+
self: Effect.Effect<A, E, R>,
|
|
480
|
+
that: Effect.Effect<A2, E2, R2>
|
|
481
|
+
) => Effect.Effect<A2 | A, E2 | E, R | R2>
|
|
482
|
+
>(2, <A, E, R, A2, E2, R2>(
|
|
483
|
+
self: Effect.Effect<A, E, R>,
|
|
484
|
+
that: Effect.Effect<A2, E2, R2>
|
|
485
|
+
) =>
|
|
486
|
+
pipe(
|
|
487
|
+
core.exit(self),
|
|
488
|
+
fiberRuntime.race(core.exit(that)),
|
|
489
|
+
(effect: Effect.Effect<Exit.Exit<A | A2, E | E2>, never, R | R2>) => core.flatten(effect)
|
|
490
|
+
))
|
|
491
|
+
|
|
492
|
+
/** @internal */
|
|
493
|
+
export const supervised = dual<
|
|
494
|
+
<X>(supervisor: Supervisor.Supervisor<X>) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
|
|
495
|
+
<A, E, R, X>(self: Effect.Effect<A, E, R>, supervisor: Supervisor.Supervisor<X>) => Effect.Effect<A, E, R>
|
|
496
|
+
>(2, (self, supervisor) => {
|
|
497
|
+
const supervise = core.fiberRefLocallyWith(fiberRuntime.currentSupervisor, (s) => s.zip(supervisor))
|
|
498
|
+
return supervise(self)
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
/** @internal */
|
|
502
|
+
export const timeout = dual<
|
|
503
|
+
(
|
|
504
|
+
duration: Duration.DurationInput
|
|
505
|
+
) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | Cause.TimeoutException, R>,
|
|
506
|
+
<A, E, R>(
|
|
507
|
+
self: Effect.Effect<A, E, R>,
|
|
508
|
+
duration: Duration.DurationInput
|
|
509
|
+
) => Effect.Effect<A, E | Cause.TimeoutException, R>
|
|
510
|
+
>(2, (self, duration) =>
|
|
511
|
+
timeoutFail(self, {
|
|
512
|
+
onTimeout: () => core.timeoutExceptionFromDuration(duration),
|
|
513
|
+
duration
|
|
514
|
+
}))
|
|
515
|
+
|
|
516
|
+
/** @internal */
|
|
517
|
+
export const timeoutFail = dual<
|
|
518
|
+
<E1>(
|
|
519
|
+
options: {
|
|
520
|
+
readonly onTimeout: LazyArg<E1>
|
|
521
|
+
readonly duration: Duration.DurationInput
|
|
522
|
+
}
|
|
523
|
+
) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1, R>,
|
|
524
|
+
<A, E, R, E1>(
|
|
525
|
+
self: Effect.Effect<A, E, R>,
|
|
526
|
+
options: {
|
|
527
|
+
readonly onTimeout: LazyArg<E1>
|
|
528
|
+
readonly duration: Duration.DurationInput
|
|
529
|
+
}
|
|
530
|
+
) => Effect.Effect<A, E | E1, R>
|
|
531
|
+
>(2, (self, { duration, onTimeout }) =>
|
|
532
|
+
core.flatten(timeoutTo(self, {
|
|
533
|
+
onTimeout: () => core.failSync(onTimeout),
|
|
534
|
+
onSuccess: core.succeed,
|
|
535
|
+
duration
|
|
536
|
+
})))
|
|
537
|
+
|
|
538
|
+
/** @internal */
|
|
539
|
+
export const timeoutFailCause = dual<
|
|
540
|
+
<E1>(
|
|
541
|
+
options: {
|
|
542
|
+
readonly onTimeout: LazyArg<Cause.Cause<E1>>
|
|
543
|
+
readonly duration: Duration.DurationInput
|
|
544
|
+
}
|
|
545
|
+
) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1, R>,
|
|
546
|
+
<A, E, R, E1>(
|
|
547
|
+
self: Effect.Effect<A, E, R>,
|
|
548
|
+
options: {
|
|
549
|
+
readonly onTimeout: LazyArg<Cause.Cause<E1>>
|
|
550
|
+
readonly duration: Duration.DurationInput
|
|
551
|
+
}
|
|
552
|
+
) => Effect.Effect<A, E | E1, R>
|
|
553
|
+
>(2, (self, { duration, onTimeout }) =>
|
|
554
|
+
core.flatten(timeoutTo(self, {
|
|
555
|
+
onTimeout: () => core.failCauseSync(onTimeout),
|
|
556
|
+
onSuccess: core.succeed,
|
|
557
|
+
duration
|
|
558
|
+
})))
|
|
559
|
+
|
|
560
|
+
/** @internal */
|
|
561
|
+
export const timeoutOption = dual<
|
|
562
|
+
(
|
|
563
|
+
duration: Duration.DurationInput
|
|
564
|
+
) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>,
|
|
565
|
+
<A, E, R>(
|
|
566
|
+
self: Effect.Effect<A, E, R>,
|
|
567
|
+
duration: Duration.DurationInput
|
|
568
|
+
) => Effect.Effect<Option.Option<A>, E, R>
|
|
569
|
+
>(2, (self, duration) =>
|
|
570
|
+
timeoutTo(self, {
|
|
571
|
+
duration,
|
|
572
|
+
onSuccess: Option.some,
|
|
573
|
+
onTimeout: Option.none
|
|
574
|
+
}))
|
|
575
|
+
|
|
576
|
+
/** @internal */
|
|
577
|
+
export const timeoutTo = dual<
|
|
578
|
+
<A, B, B1>(
|
|
579
|
+
options: {
|
|
580
|
+
readonly onTimeout: LazyArg<B1>
|
|
581
|
+
readonly onSuccess: (a: A) => B
|
|
582
|
+
readonly duration: Duration.DurationInput
|
|
583
|
+
}
|
|
584
|
+
) => <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B | B1, E, R>,
|
|
585
|
+
<A, E, R, B1, B>(
|
|
586
|
+
self: Effect.Effect<A, E, R>,
|
|
587
|
+
options: {
|
|
588
|
+
readonly onTimeout: LazyArg<B1>
|
|
589
|
+
readonly onSuccess: (a: A) => B
|
|
590
|
+
readonly duration: Duration.DurationInput
|
|
591
|
+
}
|
|
592
|
+
) => Effect.Effect<B | B1, E, R>
|
|
593
|
+
>(
|
|
594
|
+
2,
|
|
595
|
+
(self, { duration, onSuccess, onTimeout }) =>
|
|
596
|
+
core.fiberIdWith((parentFiberId) =>
|
|
597
|
+
core.uninterruptibleMask((restore) =>
|
|
598
|
+
fiberRuntime.raceFibersWith(
|
|
599
|
+
restore(self),
|
|
600
|
+
core.interruptible(effect.sleep(duration)),
|
|
601
|
+
{
|
|
602
|
+
onSelfWin: (winner, loser) =>
|
|
603
|
+
core.flatMap(
|
|
604
|
+
winner.await,
|
|
605
|
+
(exit) => {
|
|
606
|
+
if (exit._tag === "Success") {
|
|
607
|
+
return core.flatMap(
|
|
608
|
+
winner.inheritAll,
|
|
609
|
+
() =>
|
|
610
|
+
core.as(
|
|
611
|
+
core.interruptAsFiber(loser, parentFiberId),
|
|
612
|
+
onSuccess(exit.value)
|
|
613
|
+
)
|
|
614
|
+
)
|
|
615
|
+
} else {
|
|
616
|
+
return core.flatMap(
|
|
617
|
+
core.interruptAsFiber(loser, parentFiberId),
|
|
618
|
+
() => core.exitFailCause(exit.cause)
|
|
619
|
+
)
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
onOtherWin: (winner, loser) =>
|
|
624
|
+
core.flatMap(
|
|
625
|
+
winner.await,
|
|
626
|
+
(exit) => {
|
|
627
|
+
if (exit._tag === "Success") {
|
|
628
|
+
return core.flatMap(
|
|
629
|
+
winner.inheritAll,
|
|
630
|
+
() =>
|
|
631
|
+
core.as(
|
|
632
|
+
core.interruptAsFiber(loser, parentFiberId),
|
|
633
|
+
onTimeout()
|
|
634
|
+
)
|
|
635
|
+
)
|
|
636
|
+
} else {
|
|
637
|
+
return core.flatMap(
|
|
638
|
+
core.interruptAsFiber(loser, parentFiberId),
|
|
639
|
+
() => core.exitFailCause(exit.cause)
|
|
640
|
+
)
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
),
|
|
644
|
+
otherScope: globalScope
|
|
645
|
+
}
|
|
646
|
+
)
|
|
647
|
+
)
|
|
648
|
+
)
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
// circular with Synchronized
|
|
652
|
+
|
|
653
|
+
/** @internal */
|
|
654
|
+
const SynchronizedSymbolKey = "effect/Ref/SynchronizedRef"
|
|
655
|
+
|
|
656
|
+
/** @internal */
|
|
657
|
+
export const SynchronizedTypeId: Synchronized.SynchronizedRefTypeId = Symbol.for(
|
|
658
|
+
SynchronizedSymbolKey
|
|
659
|
+
) as Synchronized.SynchronizedRefTypeId
|
|
660
|
+
|
|
661
|
+
/** @internal */
|
|
662
|
+
export const synchronizedVariance = {
|
|
663
|
+
/* c8 ignore next */
|
|
664
|
+
_A: (_: any) => _
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** @internal */
|
|
668
|
+
class SynchronizedImpl<in out A> extends Effectable.Class<A> implements Synchronized.SynchronizedRef<A> {
|
|
669
|
+
readonly [SynchronizedTypeId] = synchronizedVariance
|
|
670
|
+
readonly [internalRef.RefTypeId] = internalRef.refVariance
|
|
671
|
+
readonly [Readable.TypeId]: Readable.TypeId = Readable.TypeId
|
|
672
|
+
constructor(
|
|
673
|
+
readonly ref: Ref.Ref<A>,
|
|
674
|
+
readonly withLock: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
675
|
+
) {
|
|
676
|
+
super()
|
|
677
|
+
this.get = internalRef.get(this.ref)
|
|
678
|
+
}
|
|
679
|
+
readonly get: Effect.Effect<A>
|
|
680
|
+
commit() {
|
|
681
|
+
return this.get
|
|
682
|
+
}
|
|
683
|
+
modify<B>(f: (a: A) => readonly [B, A]): Effect.Effect<B> {
|
|
684
|
+
return this.modifyEffect((a) => core.succeed(f(a)))
|
|
685
|
+
}
|
|
686
|
+
modifyEffect<B, E, R>(f: (a: A) => Effect.Effect<readonly [B, A], E, R>): Effect.Effect<B, E, R> {
|
|
687
|
+
return this.withLock(
|
|
688
|
+
pipe(
|
|
689
|
+
core.flatMap(internalRef.get(this.ref), f),
|
|
690
|
+
core.flatMap(([b, a]) => core.as(internalRef.set(this.ref, a), b))
|
|
691
|
+
)
|
|
692
|
+
)
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** @internal */
|
|
697
|
+
export const makeSynchronized = <A>(value: A): Effect.Effect<Synchronized.SynchronizedRef<A>> =>
|
|
698
|
+
core.sync(() => unsafeMakeSynchronized(value))
|
|
699
|
+
|
|
700
|
+
/** @internal */
|
|
701
|
+
export const unsafeMakeSynchronized = <A>(value: A): Synchronized.SynchronizedRef<A> => {
|
|
702
|
+
const ref = internalRef.unsafeMake(value)
|
|
703
|
+
const sem = unsafeMakeSemaphore(1)
|
|
704
|
+
return new SynchronizedImpl(ref, sem.withPermits(1))
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** @internal */
|
|
708
|
+
export const updateSomeAndGetEffectSynchronized = dual<
|
|
709
|
+
<A, R, E>(
|
|
710
|
+
pf: (a: A) => Option.Option<Effect.Effect<A, E, R>>
|
|
711
|
+
) => (self: Synchronized.SynchronizedRef<A>) => Effect.Effect<A, E, R>,
|
|
712
|
+
<A, R, E>(
|
|
713
|
+
self: Synchronized.SynchronizedRef<A>,
|
|
714
|
+
pf: (a: A) => Option.Option<Effect.Effect<A, E, R>>
|
|
715
|
+
) => Effect.Effect<A, E, R>
|
|
716
|
+
>(2, (self, pf) =>
|
|
717
|
+
self.modifyEffect((value) => {
|
|
718
|
+
const result = pf(value)
|
|
719
|
+
switch (result._tag) {
|
|
720
|
+
case "None": {
|
|
721
|
+
return core.succeed([value, value] as const)
|
|
722
|
+
}
|
|
723
|
+
case "Some": {
|
|
724
|
+
return core.map(result.value, (a) => [a, a] as const)
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}))
|
|
728
|
+
|
|
729
|
+
// circular with Fiber
|
|
730
|
+
|
|
731
|
+
/** @internal */
|
|
732
|
+
export const zipFiber = dual<
|
|
733
|
+
<A2, E2>(that: Fiber.Fiber<A2, E2>) => <A, E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<[A, A2], E | E2>,
|
|
734
|
+
<A, E, A2, E2>(self: Fiber.Fiber<A, E>, that: Fiber.Fiber<A2, E2>) => Fiber.Fiber<[A, A2], E | E2>
|
|
735
|
+
>(2, (self, that) => zipWithFiber(self, that, (a, b) => [a, b]))
|
|
736
|
+
|
|
737
|
+
/** @internal */
|
|
738
|
+
export const zipLeftFiber = dual<
|
|
739
|
+
<A2, E2>(that: Fiber.Fiber<A2, E2>) => <A, E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<A, E | E2>,
|
|
740
|
+
<A, E, A2, E2>(self: Fiber.Fiber<A, E>, that: Fiber.Fiber<A2, E2>) => Fiber.Fiber<A, E | E2>
|
|
741
|
+
>(2, (self, that) => zipWithFiber(self, that, (a, _) => a))
|
|
742
|
+
|
|
743
|
+
/** @internal */
|
|
744
|
+
export const zipRightFiber = dual<
|
|
745
|
+
<A2, E2>(that: Fiber.Fiber<A2, E2>) => <A, E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<A2, E | E2>,
|
|
746
|
+
<A, E, A2, E2>(self: Fiber.Fiber<A, E>, that: Fiber.Fiber<A2, E2>) => Fiber.Fiber<A2, E | E2>
|
|
747
|
+
>(2, (self, that) => zipWithFiber(self, that, (_, b) => b))
|
|
748
|
+
|
|
749
|
+
/** @internal */
|
|
750
|
+
export const zipWithFiber = dual<
|
|
751
|
+
<B, E2, A, C>(
|
|
752
|
+
that: Fiber.Fiber<B, E2>,
|
|
753
|
+
f: (a: A, b: B) => C
|
|
754
|
+
) => <E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<C, E | E2>,
|
|
755
|
+
<A, E, B, E2, C>(
|
|
756
|
+
self: Fiber.Fiber<A, E>,
|
|
757
|
+
that: Fiber.Fiber<B, E2>,
|
|
758
|
+
f: (a: A, b: B) => C
|
|
759
|
+
) => Fiber.Fiber<C, E | E2>
|
|
760
|
+
>(3, (self, that, f) => ({
|
|
761
|
+
...Effectable.CommitPrototype,
|
|
762
|
+
commit() {
|
|
763
|
+
return internalFiber.join(this)
|
|
764
|
+
},
|
|
765
|
+
[internalFiber.FiberTypeId]: internalFiber.fiberVariance,
|
|
766
|
+
id: () => pipe(self.id(), FiberId.getOrElse(that.id())),
|
|
767
|
+
await: pipe(
|
|
768
|
+
self.await,
|
|
769
|
+
core.flatten,
|
|
770
|
+
fiberRuntime.zipWithOptions(core.flatten(that.await), f, { concurrent: true }),
|
|
771
|
+
core.exit
|
|
772
|
+
),
|
|
773
|
+
children: self.children,
|
|
774
|
+
inheritAll: core.zipRight(
|
|
775
|
+
that.inheritAll,
|
|
776
|
+
self.inheritAll
|
|
777
|
+
),
|
|
778
|
+
poll: core.zipWith(
|
|
779
|
+
self.poll,
|
|
780
|
+
that.poll,
|
|
781
|
+
(optionA, optionB) =>
|
|
782
|
+
pipe(
|
|
783
|
+
optionA,
|
|
784
|
+
Option.flatMap((exitA) =>
|
|
785
|
+
pipe(
|
|
786
|
+
optionB,
|
|
787
|
+
Option.map((exitB) =>
|
|
788
|
+
Exit.zipWith(exitA, exitB, {
|
|
789
|
+
onSuccess: f,
|
|
790
|
+
onFailure: internalCause.parallel
|
|
791
|
+
})
|
|
792
|
+
)
|
|
793
|
+
)
|
|
794
|
+
)
|
|
795
|
+
)
|
|
796
|
+
),
|
|
797
|
+
interruptAsFork: (id) =>
|
|
798
|
+
core.zipRight(
|
|
799
|
+
self.interruptAsFork(id),
|
|
800
|
+
that.interruptAsFork(id)
|
|
801
|
+
),
|
|
802
|
+
pipe() {
|
|
803
|
+
return pipeArguments(this, arguments)
|
|
804
|
+
}
|
|
805
|
+
}))
|
|
806
|
+
|
|
807
|
+
/* @internal */
|
|
808
|
+
export const bindAll: {
|
|
809
|
+
<
|
|
810
|
+
A extends object,
|
|
811
|
+
X extends Record<string, Effect.Effect<any, any, any>>,
|
|
812
|
+
O extends Types.NoExcessProperties<{
|
|
813
|
+
readonly concurrency?: Types.Concurrency | undefined
|
|
814
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
815
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
816
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
817
|
+
}, O>
|
|
818
|
+
>(
|
|
819
|
+
f: (a: A) => [Extract<keyof X, keyof A>] extends [never] ? X : `Duplicate keys`,
|
|
820
|
+
options?: undefined | O
|
|
821
|
+
): <E1, R1>(
|
|
822
|
+
self: Effect.Effect<A, E1, R1>
|
|
823
|
+
) => [Effect.All.ReturnObject<X, false, Effect.All.ExtractMode<O>>] extends
|
|
824
|
+
[Effect.Effect<infer Success, infer Error, infer Context>] ? Effect.Effect<
|
|
825
|
+
{
|
|
826
|
+
[K in keyof A | keyof Success]: K extends keyof A ? A[K]
|
|
827
|
+
: K extends keyof Success ? Success[K]
|
|
828
|
+
: never
|
|
829
|
+
},
|
|
830
|
+
| E1
|
|
831
|
+
| Error,
|
|
832
|
+
R1 | Context
|
|
833
|
+
>
|
|
834
|
+
: never
|
|
835
|
+
|
|
836
|
+
<
|
|
837
|
+
A extends object,
|
|
838
|
+
X extends Record<string, Effect.Effect<any, any, any>>,
|
|
839
|
+
O extends Types.NoExcessProperties<{
|
|
840
|
+
readonly concurrency?: Types.Concurrency | undefined
|
|
841
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
842
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
843
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
844
|
+
}, O>,
|
|
845
|
+
E1,
|
|
846
|
+
R1
|
|
847
|
+
>(
|
|
848
|
+
self: Effect.Effect<A, E1, R1>,
|
|
849
|
+
f: (a: A) => [Extract<keyof X, keyof A>] extends [never] ? X : `Duplicate keys`,
|
|
850
|
+
options?: undefined | {
|
|
851
|
+
readonly concurrency?: Types.Concurrency | undefined
|
|
852
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
853
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
854
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
855
|
+
}
|
|
856
|
+
): [Effect.All.ReturnObject<X, false, Effect.All.ExtractMode<O>>] extends
|
|
857
|
+
[Effect.Effect<infer Success, infer Error, infer Context>] ? Effect.Effect<
|
|
858
|
+
{
|
|
859
|
+
[K in keyof A | keyof Success]: K extends keyof A ? A[K]
|
|
860
|
+
: K extends keyof Success ? Success[K]
|
|
861
|
+
: never
|
|
862
|
+
},
|
|
863
|
+
| E1
|
|
864
|
+
| Error,
|
|
865
|
+
R1 | Context
|
|
866
|
+
>
|
|
867
|
+
: never
|
|
868
|
+
} = dual((args) => core.isEffect(args[0]), <
|
|
869
|
+
A extends object,
|
|
870
|
+
X extends Record<string, Effect.Effect<any, any, any>>,
|
|
871
|
+
O extends Types.NoExcessProperties<{
|
|
872
|
+
readonly concurrency?: Types.Concurrency | undefined
|
|
873
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
874
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
875
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
876
|
+
}, O>,
|
|
877
|
+
E1,
|
|
878
|
+
R1
|
|
879
|
+
>(
|
|
880
|
+
self: Effect.Effect<A, E1, R1>,
|
|
881
|
+
f: (a: A) => X,
|
|
882
|
+
options?: undefined | O
|
|
883
|
+
) =>
|
|
884
|
+
core.flatMap(
|
|
885
|
+
self,
|
|
886
|
+
(a) =>
|
|
887
|
+
(fiberRuntime.all(f(a), options) as Effect.All.ReturnObject<
|
|
888
|
+
X,
|
|
889
|
+
Effect.All.IsDiscard<O>,
|
|
890
|
+
Effect.All.ExtractMode<O>
|
|
891
|
+
>)
|
|
892
|
+
.pipe(
|
|
893
|
+
core.map((record) => Object.assign({}, a, record))
|
|
894
|
+
)
|
|
895
|
+
))
|