@fncts/io 0.0.20 → 0.0.22
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/Cached/api.d.ts +2 -2
- package/Channel/ChildExecutorDecision/api.d.ts +2 -2
- package/Channel/UpstreamPullRequest/api.d.ts +2 -2
- package/Channel/api/interruptWhen.d.ts +5 -5
- package/Channel/api/mapOutConcurrentIO.d.ts +8 -0
- package/Channel/api/mergeAll.d.ts +2 -2
- package/Channel/api/mergeAllUnboundedWith.d.ts +2 -2
- package/Channel/api/mergeAllWith.d.ts +2 -2
- package/Channel/api/mergeMap.d.ts +2 -2
- package/Channel/api/mergeWith.d.ts +2 -2
- package/Channel/api/zipConcurrent.d.ts +16 -0
- package/Channel/api.d.ts +62 -62
- package/Channel/core-api.d.ts +11 -11
- package/Channel/definition.d.ts +35 -21
- package/Channel/internal/SingleProducerAsyncInput.d.ts +1 -1
- package/CountdownLatch.d.ts +25 -0
- package/Fiber/FiberMessage.d.ts +67 -0
- package/Fiber/FiberRuntime.d.ts +116 -0
- package/Fiber/api/interrupt.d.ts +1 -1
- package/Fiber/api/interruptAs.d.ts +6 -1
- package/Fiber/api/location.d.ts +1 -2
- package/Fiber/api/mapFiber.d.ts +2 -2
- package/Fiber/api/mapIO.d.ts +5 -5
- package/Fiber/api/zipWith.d.ts +2 -2
- package/Fiber/definition.d.ts +17 -16
- package/Fiber.d.ts +2 -3
- package/FiberDescriptor.d.ts +3 -6
- package/FiberRef/api/locallyScoped.d.ts +2 -2
- package/FiberRef/api/locallyScopedWith.d.ts +2 -2
- package/FiberRef/api.d.ts +18 -18
- package/FiberRef/definition.d.ts +2 -2
- package/FiberRef/unsafe.d.ts +5 -0
- package/FiberRefs/api.d.ts +30 -2
- package/FiberRefs/definition.d.ts +14 -7
- package/FiberRefs/join.d.ts +3 -3
- package/FiberScope/constructors.d.ts +2 -2
- package/FiberScope/definition.d.ts +8 -5
- package/FiberStatus/constructors.d.ts +3 -7
- package/FiberStatus/definition.d.ts +16 -28
- package/Future/api.d.ts +21 -21
- package/Hub/api.d.ts +27 -25
- package/Hub/definition.d.ts +13 -9
- package/IO/api/acquireRelease.d.ts +1 -1
- package/IO/api/acquireReleaseExit.d.ts +1 -1
- package/IO/api/asyncInterrupt.d.ts +39 -0
- package/IO/api/bracket.d.ts +1 -1
- package/IO/api/bracketExit.d.ts +1 -1
- package/IO/api/concurrency.d.ts +2 -2
- package/IO/api/core-scope.d.ts +7 -43
- package/IO/api/delay.d.ts +8 -0
- package/IO/api/ensuringChildren.d.ts +3 -3
- package/IO/api/environment.d.ts +11 -15
- package/IO/api/{foreachC.d.ts → foreachConcurrent.d.ts} +8 -8
- package/IO/api/foreachExec.d.ts +1 -1
- package/IO/api/fork.d.ts +36 -0
- package/IO/api/forkIn.d.ts +3 -3
- package/IO/api/fulfill.d.ts +3 -3
- package/IO/api/interrupt.d.ts +9 -13
- package/IO/api/onExit.d.ts +3 -3
- package/IO/api/onTermination.d.ts +4 -4
- package/IO/api/provideLayer.d.ts +3 -3
- package/IO/api/provideSomeLayer.d.ts +3 -7
- package/IO/api/race.d.ts +2 -2
- package/IO/api/raceFirst.d.ts +2 -2
- package/IO/api/repeat.d.ts +3 -3
- package/IO/api/retry.d.ts +7 -7
- package/IO/api/schedule.d.ts +5 -5
- package/IO/api/scoped.d.ts +2 -2
- package/IO/api/supervised.d.ts +2 -4
- package/IO/api/timeout.d.ts +5 -5
- package/IO/api/withFinalizer.d.ts +3 -3
- package/IO/api/withFinalizerExit.d.ts +3 -3
- package/IO/api/zipConcurrent.d.ts +13 -0
- package/IO/api.d.ts +208 -306
- package/IO/definition.d.ts +111 -130
- package/IO/runtime.d.ts +19 -22
- package/IO.d.ts +5 -3
- package/Layer/MemoMap.d.ts +5 -5
- package/Layer/api.d.ts +28 -28
- package/LogLevel.d.ts +12 -12
- package/LogSpan.d.ts +2 -2
- package/Logger/api.d.ts +5 -5
- package/Push/api.d.ts +232 -0
- package/Push/definition.d.ts +34 -0
- package/Push/internal.d.ts +11 -0
- package/Push.d.ts +3 -0
- package/Queue/api/dimapIO.d.ts +70 -13
- package/Queue/api/filterInputIO.d.ts +12 -20
- package/Queue/api/filterOutputIO.d.ts +10 -21
- package/Queue/api/operations.d.ts +15 -14
- package/Queue/api/poll.d.ts +2 -2
- package/Queue/api/takeBetween.d.ts +3 -3
- package/Queue/api/zipWithIO.d.ts +7 -24
- package/Queue/definition.d.ts +112 -8
- package/Queue/internal.d.ts +7 -7
- package/Ref/Atomic.d.ts +22 -2
- package/Ref/Derived.d.ts +4 -2
- package/Ref/DerivedAll.d.ts +7 -3
- package/Ref/Synchronized/api.d.ts +31 -29
- package/Ref/Synchronized/constructors.d.ts +1 -1
- package/Ref/Synchronized/definition.d.ts +6 -4
- package/Ref/Synchronized.d.ts +3 -0
- package/Ref/api/collect.d.ts +3 -3
- package/Ref/api/dimap.d.ts +21 -21
- package/Ref/api/filter.d.ts +7 -6
- package/Ref/api/get.d.ts +1 -1
- package/Ref/api/match.d.ts +3 -3
- package/Ref/api/matchAll.d.ts +1 -1
- package/Ref/api/modify.d.ts +27 -27
- package/Ref/api/set.d.ts +3 -3
- package/Ref/constructors.d.ts +1 -1
- package/Ref/definition.d.ts +46 -20
- package/Ref/symbols.d.ts +30 -0
- package/Ref.d.ts +2 -0
- package/RefSubject/Atomic.d.ts +36 -0
- package/RefSubject/Synchronized/api.d.ts +9 -0
- package/RefSubject/Synchronized/definition.d.ts +40 -0
- package/RefSubject/api.d.ts +116 -0
- package/RefSubject/definition.d.ts +45 -0
- package/RefSubject.d.ts +3 -0
- package/RuntimeConfig.d.ts +0 -24
- package/RuntimeFlag.d.ts +10 -0
- package/RuntimeFlags/Patch.d.ts +53 -0
- package/RuntimeFlags/RuntimeFlags.d.ts +82 -0
- package/RuntimeFlags.d.ts +2 -0
- package/STM/api/core-api.d.ts +10 -10
- package/STM/api.d.ts +61 -61
- package/STM/internal/Journal.d.ts +4 -4
- package/Schedule/Decision.d.ts +2 -2
- package/Schedule/api.d.ts +121 -105
- package/Scope/ReleaseMap/api/releaseAll.d.ts +2 -2
- package/Scope/ReleaseMap/api.d.ts +10 -10
- package/Scope/ReleaseMap/definition.d.ts +1 -1
- package/Scope/api.d.ts +8 -8
- package/ScopedRef/api.d.ts +1 -1
- package/Sink/api.d.ts +66 -66
- package/State/api.d.ts +4 -4
- package/State/internal.d.ts +1 -1
- package/Stream/api/zipAllWith.d.ts +2 -2
- package/Stream/api/zipWith.d.ts +2 -2
- package/Stream/api/zipWithChunks.d.ts +2 -2
- package/Stream/api.d.ts +217 -205
- package/Stream/internal/DebounceState.d.ts +3 -3
- package/Stream/internal/Handoff.d.ts +6 -6
- package/Stream/internal/SinkEndReason.d.ts +3 -3
- package/Stream/internal/Take.d.ts +8 -8
- package/Subject/Atomic.d.ts +18 -0
- package/Subject/api.d.ts +13 -0
- package/Subject/definition.d.ts +15 -0
- package/Subject.d.ts +3 -0
- package/SubscriptionRef.d.ts +38 -0
- package/Supervisor/api.d.ts +4 -4
- package/SupervisorPatch.d.ts +4 -4
- package/TExit/definition.d.ts +2 -2
- package/TFuture/api.d.ts +7 -7
- package/TFuture/definition.d.ts +2 -2
- package/TReentrantLock/api.d.ts +4 -4
- package/TReentrantLock/definition.d.ts +3 -3
- package/TRef/api.d.ts +26 -27
- package/TRef/constructors.d.ts +6 -6
- package/TRef/definition.d.ts +47 -34
- package/TRef/symbols.d.ts +20 -0
- package/TRef.d.ts +1 -0
- package/TSemaphore/api.d.ts +4 -4
- package/TSemaphore/constructors.d.ts +6 -0
- package/TSemaphore/definition.d.ts +2 -2
- package/_cjs/Cached/api.cjs +9 -32
- package/_cjs/Cached/api.cjs.map +1 -1
- package/_cjs/Cached/definition.cjs +2 -7
- package/_cjs/Cached/definition.cjs.map +1 -1
- package/_cjs/Cached/internal.cjs +0 -3
- package/_cjs/Cached/internal.cjs.map +1 -1
- package/_cjs/Cached.cjs +0 -6
- package/_cjs/Cached.cjs.map +1 -1
- package/_cjs/CancellerState.cjs +3 -22
- package/_cjs/CancellerState.cjs.map +1 -1
- package/_cjs/Channel/ChildExecutorDecision/api.cjs +19 -20
- package/_cjs/Channel/ChildExecutorDecision/api.cjs.map +1 -1
- package/_cjs/Channel/ChildExecutorDecision/definition.cjs +0 -5
- package/_cjs/Channel/ChildExecutorDecision/definition.cjs.map +1 -1
- package/_cjs/Channel/ChildExecutorDecision.cjs +0 -4
- package/_cjs/Channel/ChildExecutorDecision.cjs.map +1 -1
- package/_cjs/Channel/UpstreamPullRequest/api.cjs +15 -20
- package/_cjs/Channel/UpstreamPullRequest/api.cjs.map +1 -1
- package/_cjs/Channel/UpstreamPullRequest/definition.cjs +0 -6
- package/_cjs/Channel/UpstreamPullRequest/definition.cjs.map +1 -1
- package/_cjs/Channel/UpstreamPullRequest.cjs +0 -4
- package/_cjs/Channel/UpstreamPullRequest.cjs.map +1 -1
- package/_cjs/Channel/UpstreamPullStrategy/definition.cjs +0 -4
- package/_cjs/Channel/UpstreamPullStrategy/definition.cjs.map +1 -1
- package/_cjs/Channel/UpstreamPullStrategy.cjs +0 -2
- package/_cjs/Channel/UpstreamPullStrategy.cjs.map +1 -1
- package/_cjs/Channel/api/interruptWhen.cjs +14 -22
- package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +42 -0
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -0
- package/_cjs/Channel/api/mergeAll.cjs +6 -8
- package/_cjs/Channel/api/mergeAll.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +6 -8
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +40 -71
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeMap.cjs +6 -9
- package/_cjs/Channel/api/mergeMap.cjs.map +1 -1
- package/_cjs/Channel/api/mergeWith.cjs +35 -67
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
- package/_cjs/Channel/api/run.cjs +1 -7
- package/_cjs/Channel/api/run.cjs.map +1 -1
- package/_cjs/Channel/api/runCollect.cjs +0 -5
- package/_cjs/Channel/api/runCollect.cjs.map +1 -1
- package/_cjs/Channel/api/runDrain.cjs +0 -5
- package/_cjs/Channel/api/runDrain.cjs.map +1 -1
- package/_cjs/Channel/api/runScoped.cjs +6 -28
- package/_cjs/Channel/api/runScoped.cjs.map +1 -1
- package/_cjs/Channel/api/toPull.cjs +7 -29
- package/_cjs/Channel/api/toPull.cjs.map +1 -1
- package/_cjs/Channel/api/{zipC.cjs → zipConcurrent.cjs} +22 -30
- package/_cjs/Channel/api/zipConcurrent.cjs.map +1 -0
- package/_cjs/Channel/api.cjs +242 -367
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/core-api.cjs +34 -48
- package/_cjs/Channel/core-api.cjs.map +1 -1
- package/_cjs/Channel/definition.cjs +20 -106
- package/_cjs/Channel/definition.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelExecutor.cjs +161 -371
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelState.cjs +5 -37
- package/_cjs/Channel/internal/ChannelState.cjs.map +1 -1
- package/_cjs/Channel/internal/MergeDecision.cjs +4 -27
- package/_cjs/Channel/internal/MergeDecision.cjs.map +1 -1
- package/_cjs/Channel/internal/MergeState.cjs +3 -24
- package/_cjs/Channel/internal/MergeState.cjs.map +1 -1
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +37 -131
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
- package/_cjs/Channel.cjs +0 -6
- package/_cjs/Channel.cjs.map +1 -1
- package/_cjs/Clock/api.cjs +0 -7
- package/_cjs/Clock/api.cjs.map +1 -1
- package/_cjs/Clock/definition.cjs +0 -6
- package/_cjs/Clock/definition.cjs.map +1 -1
- package/_cjs/Clock/live.cjs +2 -12
- package/_cjs/Clock/live.cjs.map +1 -1
- package/_cjs/Clock.cjs +0 -6
- package/_cjs/Clock.cjs.map +1 -1
- package/_cjs/Console/api.cjs +0 -7
- package/_cjs/Console/api.cjs.map +1 -1
- package/_cjs/Console/definition.cjs +0 -6
- package/_cjs/Console/definition.cjs.map +1 -1
- package/_cjs/Console/live.cjs +0 -11
- package/_cjs/Console/live.cjs.map +1 -1
- package/_cjs/Console.cjs +0 -6
- package/_cjs/Console.cjs.map +1 -1
- package/_cjs/CountdownLatch.cjs +50 -0
- package/_cjs/CountdownLatch.cjs.map +1 -0
- package/_cjs/Differ/api.cjs +5 -28
- package/_cjs/Differ/api.cjs.map +1 -1
- package/_cjs/Differ/definition.cjs +0 -4
- package/_cjs/Differ/definition.cjs.map +1 -1
- package/_cjs/Fiber/FiberMessage.cjs +72 -0
- package/_cjs/Fiber/FiberMessage.cjs.map +1 -0
- package/_cjs/Fiber/FiberRuntime.cjs +735 -0
- package/_cjs/Fiber/FiberRuntime.cjs.map +1 -0
- package/_cjs/Fiber/api/await.cjs +0 -1
- package/_cjs/Fiber/api/await.cjs.map +1 -1
- package/_cjs/Fiber/api/awaitAll.cjs +2 -8
- package/_cjs/Fiber/api/awaitAll.cjs.map +1 -1
- package/_cjs/Fiber/api/children.cjs +0 -1
- package/_cjs/Fiber/api/children.cjs.map +1 -1
- package/_cjs/Fiber/api/collectAll.cjs +3 -25
- package/_cjs/Fiber/api/collectAll.cjs.map +1 -1
- package/_cjs/Fiber/api/fromIO.cjs +1 -6
- package/_cjs/Fiber/api/fromIO.cjs.map +1 -1
- package/_cjs/Fiber/api/id.cjs +0 -1
- package/_cjs/Fiber/api/id.cjs.map +1 -1
- package/_cjs/Fiber/api/inheritRefs.cjs +1 -2
- package/_cjs/Fiber/api/inheritRefs.cjs.map +1 -1
- package/_cjs/Fiber/api/interrupt.cjs +3 -8
- package/_cjs/Fiber/api/interrupt.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptAll.cjs +3 -13
- package/_cjs/Fiber/api/interruptAll.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptAs.cjs +15 -8
- package/_cjs/Fiber/api/interruptAs.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptFork.cjs +2 -9
- package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
- package/_cjs/Fiber/api/join.cjs +3 -6
- package/_cjs/Fiber/api/join.cjs.map +1 -1
- package/_cjs/Fiber/api/joinAll.cjs +1 -7
- package/_cjs/Fiber/api/joinAll.cjs.map +1 -1
- package/_cjs/Fiber/api/location.cjs +1 -8
- package/_cjs/Fiber/api/location.cjs.map +1 -1
- package/_cjs/Fiber/api/mapFiber.cjs +6 -11
- package/_cjs/Fiber/api/mapFiber.cjs.map +1 -1
- package/_cjs/Fiber/api/mapIO.cjs +14 -27
- package/_cjs/Fiber/api/mapIO.cjs.map +1 -1
- package/_cjs/Fiber/api/poll.cjs +0 -1
- package/_cjs/Fiber/api/poll.cjs.map +1 -1
- package/_cjs/Fiber/api/zipWith.cjs +7 -21
- package/_cjs/Fiber/api/zipWith.cjs.map +1 -1
- package/_cjs/Fiber/constructors.cjs +0 -18
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/Fiber/definition.cjs +11 -14
- package/_cjs/Fiber/definition.cjs.map +1 -1
- package/_cjs/Fiber.cjs +15 -72
- package/_cjs/Fiber.cjs.map +1 -1
- package/_cjs/FiberDescriptor.cjs +1 -6
- package/_cjs/FiberDescriptor.cjs.map +1 -1
- package/_cjs/FiberRef/api/locallyScoped.cjs +6 -10
- package/_cjs/FiberRef/api/locallyScoped.cjs.map +1 -1
- package/_cjs/FiberRef/api/locallyScopedWith.cjs +5 -8
- package/_cjs/FiberRef/api/locallyScopedWith.cjs.map +1 -1
- package/_cjs/FiberRef/api.cjs +78 -97
- package/_cjs/FiberRef/api.cjs.map +1 -1
- package/_cjs/FiberRef/constructors.cjs +1 -11
- package/_cjs/FiberRef/constructors.cjs.map +1 -1
- package/_cjs/FiberRef/definition.cjs +5 -23
- package/_cjs/FiberRef/definition.cjs.map +1 -1
- package/_cjs/FiberRef/unsafe.cjs +20 -48
- package/_cjs/FiberRef/unsafe.cjs.map +1 -1
- package/_cjs/FiberRef.cjs +0 -12
- package/_cjs/FiberRef.cjs.map +1 -1
- package/_cjs/FiberRefs/api.cjs +74 -32
- package/_cjs/FiberRefs/api.cjs.map +1 -1
- package/_cjs/FiberRefs/definition.cjs +5 -17
- package/_cjs/FiberRefs/definition.cjs.map +1 -1
- package/_cjs/FiberRefs/join.cjs +51 -71
- package/_cjs/FiberRefs/join.cjs.map +1 -1
- package/_cjs/FiberRefs.cjs +0 -6
- package/_cjs/FiberRefs.cjs.map +1 -1
- package/_cjs/FiberScope/constructors.cjs +0 -4
- package/_cjs/FiberScope/constructors.cjs.map +1 -1
- package/_cjs/FiberScope/definition.cjs +15 -20
- package/_cjs/FiberScope/definition.cjs.map +1 -1
- package/_cjs/FiberScope.cjs +0 -4
- package/_cjs/FiberScope.cjs.map +1 -1
- package/_cjs/FiberStatus/constructors.cjs +5 -20
- package/_cjs/FiberStatus/constructors.cjs.map +1 -1
- package/_cjs/FiberStatus/definition.cjs +18 -77
- package/_cjs/FiberStatus/definition.cjs.map +1 -1
- package/_cjs/FiberStatus.cjs +0 -4
- package/_cjs/FiberStatus.cjs.map +1 -1
- package/_cjs/Future/api.cjs +99 -141
- package/_cjs/Future/api.cjs.map +1 -1
- package/_cjs/Future/constructors.cjs +1 -12
- package/_cjs/Future/constructors.cjs.map +1 -1
- package/_cjs/Future/definition.cjs +2 -15
- package/_cjs/Future/definition.cjs.map +1 -1
- package/_cjs/Future.cjs +0 -6
- package/_cjs/Future.cjs.map +1 -1
- package/_cjs/Hub/api.cjs +112 -172
- package/_cjs/Hub/api.cjs.map +1 -1
- package/_cjs/Hub/definition.cjs +14 -7
- package/_cjs/Hub/definition.cjs.map +1 -1
- package/_cjs/Hub/internal.cjs +30 -122
- package/_cjs/Hub/internal.cjs.map +1 -1
- package/_cjs/Hub.cjs +0 -4
- package/_cjs/Hub.cjs.map +1 -1
- package/_cjs/IO/api/acquireRelease.cjs +0 -4
- package/_cjs/IO/api/acquireRelease.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseExit.cjs +1 -7
- package/_cjs/IO/api/acquireReleaseExit.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs +0 -4
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +2 -6
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs.map +1 -1
- package/_cjs/IO/api/addFinalizer.cjs +0 -4
- package/_cjs/IO/api/addFinalizer.cjs.map +1 -1
- package/_cjs/IO/api/addFinalizerExit.cjs +1 -8
- package/_cjs/IO/api/addFinalizerExit.cjs.map +1 -1
- package/_cjs/IO/api/asyncIO.cjs +8 -16
- package/_cjs/IO/api/asyncIO.cjs.map +1 -1
- package/_cjs/IO/api/asyncInterrupt.cjs +77 -0
- package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -0
- package/_cjs/IO/api/bracket.cjs +3 -7
- package/_cjs/IO/api/bracket.cjs.map +1 -1
- package/_cjs/IO/api/bracketExit.cjs +3 -10
- package/_cjs/IO/api/bracketExit.cjs.map +1 -1
- package/_cjs/IO/api/clockWith.cjs +2 -14
- package/_cjs/IO/api/clockWith.cjs.map +1 -1
- package/_cjs/IO/api/concurrency.cjs +9 -22
- package/_cjs/IO/api/concurrency.cjs.map +1 -1
- package/_cjs/IO/api/concurrentFinalizers.cjs +1 -8
- package/_cjs/IO/api/concurrentFinalizers.cjs.map +1 -1
- package/_cjs/IO/api/consoleWith.cjs +2 -14
- package/_cjs/IO/api/consoleWith.cjs.map +1 -1
- package/_cjs/IO/api/core-scope.cjs +60 -126
- package/_cjs/IO/api/core-scope.cjs.map +1 -1
- package/_cjs/{Fiber/api/evalOn.cjs → IO/api/delay.cjs} +10 -18
- package/_cjs/IO/api/delay.cjs.map +1 -0
- package/_cjs/IO/api/ensuringChildren.cjs +7 -10
- package/_cjs/IO/api/ensuringChildren.cjs.map +1 -1
- package/_cjs/IO/api/environment.cjs +35 -64
- package/_cjs/IO/api/environment.cjs.map +1 -1
- package/_cjs/IO/api/{foreachC.cjs → foreachConcurrent.cjs} +36 -73
- package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -0
- package/_cjs/IO/api/foreachExec.cjs +4 -11
- package/_cjs/IO/api/foreachExec.cjs.map +1 -1
- package/_cjs/IO/api/fork.cjs +75 -0
- package/_cjs/IO/api/fork.cjs.map +1 -0
- package/_cjs/IO/api/forkAll.cjs +3 -7
- package/_cjs/IO/api/forkAll.cjs.map +1 -1
- package/_cjs/IO/api/forkIn.cjs +8 -14
- package/_cjs/IO/api/forkIn.cjs.map +1 -1
- package/_cjs/IO/api/forkScoped.cjs +1 -9
- package/_cjs/IO/api/forkScoped.cjs.map +1 -1
- package/_cjs/IO/api/fulfill.cjs +8 -12
- package/_cjs/IO/api/fulfill.cjs.map +1 -1
- package/_cjs/IO/api/interrupt.cjs +51 -77
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/memoize.cjs +1 -8
- package/_cjs/IO/api/memoize.cjs.map +1 -1
- package/_cjs/IO/api/onExit.cjs +6 -9
- package/_cjs/IO/api/onExit.cjs.map +1 -1
- package/_cjs/IO/api/onTermination.cjs +5 -11
- package/_cjs/IO/api/onTermination.cjs.map +1 -1
- package/_cjs/IO/api/once.cjs +1 -7
- package/_cjs/IO/api/once.cjs.map +1 -1
- package/_cjs/IO/api/provideLayer.cjs +6 -12
- package/_cjs/IO/api/provideLayer.cjs.map +1 -1
- package/_cjs/IO/api/provideSomeLayer.cjs +5 -20
- package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -1
- package/_cjs/IO/api/race.cjs +8 -17
- package/_cjs/IO/api/race.cjs.map +1 -1
- package/_cjs/IO/api/raceFirst.cjs +6 -9
- package/_cjs/IO/api/raceFirst.cjs.map +1 -1
- package/_cjs/IO/api/randomWith.cjs +1 -13
- package/_cjs/IO/api/randomWith.cjs.map +1 -1
- package/_cjs/IO/api/repeat.cjs +12 -27
- package/_cjs/IO/api/repeat.cjs.map +1 -1
- package/_cjs/IO/api/retry.cjs +14 -29
- package/_cjs/IO/api/retry.cjs.map +1 -1
- package/_cjs/IO/api/schedule.cjs +15 -21
- package/_cjs/IO/api/schedule.cjs.map +1 -1
- package/_cjs/IO/api/scope.cjs +0 -6
- package/_cjs/IO/api/scope.cjs.map +1 -1
- package/_cjs/IO/api/scopeWith.cjs +0 -5
- package/_cjs/IO/api/scopeWith.cjs.map +1 -1
- package/_cjs/IO/api/scoped.cjs +6 -15
- package/_cjs/IO/api/scoped.cjs.map +1 -1
- package/_cjs/IO/api/sequenceT.cjs +1 -7
- package/_cjs/IO/api/sequenceT.cjs.map +1 -1
- package/_cjs/IO/api/sleep.cjs +0 -4
- package/_cjs/IO/api/sleep.cjs.map +1 -1
- package/_cjs/IO/api/stateful.cjs +0 -6
- package/_cjs/IO/api/stateful.cjs.map +1 -1
- package/_cjs/IO/api/supervised.cjs +6 -14
- package/_cjs/IO/api/supervised.cjs.map +1 -1
- package/_cjs/IO/api/timeout.cjs +10 -18
- package/_cjs/IO/api/timeout.cjs.map +1 -1
- package/_cjs/IO/api/withChildren.cjs +2 -10
- package/_cjs/IO/api/withChildren.cjs.map +1 -1
- package/_cjs/IO/api/withEarlyRelease.cjs +1 -8
- package/_cjs/IO/api/withEarlyRelease.cjs.map +1 -1
- package/_cjs/IO/api/withFinalizer.cjs +6 -8
- package/_cjs/IO/api/withFinalizer.cjs.map +1 -1
- package/_cjs/IO/api/withFinalizerExit.cjs +6 -8
- package/_cjs/IO/api/withFinalizerExit.cjs.map +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs +51 -0
- package/_cjs/IO/api/zipConcurrent.cjs.map +1 -0
- package/_cjs/IO/api.cjs +669 -1057
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +121 -213
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +51 -119
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +41 -123
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/IOEnv/definition.cjs +1 -12
- package/_cjs/IOEnv/definition.cjs.map +1 -1
- package/_cjs/IOEnv/live.cjs +1 -12
- package/_cjs/IOEnv/live.cjs.map +1 -1
- package/_cjs/IOEnv/services.cjs +0 -5
- package/_cjs/IOEnv/services.cjs.map +1 -1
- package/_cjs/IOEnv.cjs +0 -6
- package/_cjs/IOEnv.cjs.map +1 -1
- package/_cjs/InterruptStatus/constructors.cjs +0 -5
- package/_cjs/InterruptStatus/constructors.cjs.map +1 -1
- package/_cjs/InterruptStatus/definition.cjs +0 -5
- package/_cjs/InterruptStatus/definition.cjs.map +1 -1
- package/_cjs/InterruptStatus.cjs +0 -4
- package/_cjs/InterruptStatus.cjs.map +1 -1
- package/_cjs/Layer/MemoMap.cjs +54 -111
- package/_cjs/Layer/MemoMap.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +112 -184
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Layer/definition.cjs +9 -51
- package/_cjs/Layer/definition.cjs.map +1 -1
- package/_cjs/Layer.cjs +0 -6
- package/_cjs/Layer.cjs.map +1 -1
- package/_cjs/LogLevel.cjs +24 -36
- package/_cjs/LogLevel.cjs.map +1 -1
- package/_cjs/LogSpan.cjs +16 -21
- package/_cjs/LogSpan.cjs.map +1 -1
- package/_cjs/Logger/api.cjs +18 -21
- package/_cjs/Logger/api.cjs.map +1 -1
- package/_cjs/Logger/constructors.cjs +3 -18
- package/_cjs/Logger/constructors.cjs.map +1 -1
- package/_cjs/Logger/definition.cjs +0 -3
- package/_cjs/Logger/definition.cjs.map +1 -1
- package/_cjs/Logger.cjs +0 -6
- package/_cjs/Logger.cjs.map +1 -1
- package/_cjs/Push/api.cjs +474 -0
- package/_cjs/Push/api.cjs.map +1 -0
- package/_cjs/Push/definition.cjs +43 -0
- package/_cjs/Push/definition.cjs.map +1 -0
- package/_cjs/Push/internal.cjs +40 -0
- package/_cjs/Push/internal.cjs.map +1 -0
- package/_cjs/Push.cjs +39 -0
- package/_cjs/Push.cjs.map +1 -0
- package/_cjs/Queue/api/dimapIO.cjs +109 -55
- package/_cjs/Queue/api/dimapIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterInputIO.cjs +61 -36
- package/_cjs/Queue/api/filterInputIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterOutputIO.cjs +72 -44
- package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -1
- package/_cjs/Queue/api/operations.cjs +21 -35
- package/_cjs/Queue/api/operations.cjs.map +1 -1
- package/_cjs/Queue/api/poll.cjs +1 -7
- package/_cjs/Queue/api/poll.cjs.map +1 -1
- package/_cjs/Queue/api/takeBetween.cjs +24 -34
- package/_cjs/Queue/api/takeBetween.cjs.map +1 -1
- package/_cjs/Queue/api/zipWithIO.cjs +33 -48
- package/_cjs/Queue/api/zipWithIO.cjs.map +1 -1
- package/_cjs/Queue/api.cjs +0 -14
- package/_cjs/Queue/api.cjs.map +1 -1
- package/_cjs/Queue/constructors.cjs +4 -17
- package/_cjs/Queue/constructors.cjs.map +1 -1
- package/_cjs/Queue/definition.cjs +18 -11
- package/_cjs/Queue/definition.cjs.map +1 -1
- package/_cjs/Queue/internal.cjs +63 -117
- package/_cjs/Queue/internal.cjs.map +1 -1
- package/_cjs/Queue/strategy.cjs +27 -68
- package/_cjs/Queue/strategy.cjs.map +1 -1
- package/_cjs/Queue.cjs +0 -10
- package/_cjs/Queue.cjs.map +1 -1
- package/_cjs/Random/api.cjs +0 -17
- package/_cjs/Random/api.cjs.map +1 -1
- package/_cjs/Random/definition.cjs +0 -7
- package/_cjs/Random/definition.cjs.map +1 -1
- package/_cjs/Random/live.cjs +2 -16
- package/_cjs/Random/live.cjs.map +1 -1
- package/_cjs/Random.cjs +0 -6
- package/_cjs/Random.cjs.map +1 -1
- package/_cjs/Ref/Atomic.cjs +54 -26
- package/_cjs/Ref/Atomic.cjs.map +1 -1
- package/_cjs/Ref/Derived.cjs +11 -20
- package/_cjs/Ref/Derived.cjs.map +1 -1
- package/_cjs/Ref/DerivedAll.cjs +17 -23
- package/_cjs/Ref/DerivedAll.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/api.cjs +99 -103
- package/_cjs/Ref/Synchronized/api.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/constructors.cjs +1 -11
- package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +16 -39
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
- package/_cjs/{FiberState.cjs → Ref/Synchronized.cjs} +4 -10
- package/_cjs/Ref/Synchronized.cjs.map +1 -0
- package/_cjs/Ref/api/collect.cjs +7 -12
- package/_cjs/Ref/api/collect.cjs.map +1 -1
- package/_cjs/Ref/api/dimap.cjs +55 -60
- package/_cjs/Ref/api/dimap.cjs.map +1 -1
- package/_cjs/Ref/api/filter.cjs +14 -19
- package/_cjs/Ref/api/filter.cjs.map +1 -1
- package/_cjs/Ref/api/get.cjs +0 -2
- package/_cjs/Ref/api/get.cjs.map +1 -1
- package/_cjs/Ref/api/match.cjs +8 -10
- package/_cjs/Ref/api/match.cjs.map +1 -1
- package/_cjs/Ref/api/matchAll.cjs +6 -8
- package/_cjs/Ref/api/matchAll.cjs.map +1 -1
- package/_cjs/Ref/api/modify.cjs +73 -171
- package/_cjs/Ref/api/modify.cjs.map +1 -1
- package/_cjs/Ref/api/set.cjs +8 -8
- package/_cjs/Ref/api/set.cjs.map +1 -1
- package/_cjs/Ref/api.cjs +2 -26
- package/_cjs/Ref/api.cjs.map +1 -1
- package/_cjs/Ref/constructors.cjs +2 -9
- package/_cjs/Ref/constructors.cjs.map +1 -1
- package/_cjs/Ref/definition.cjs +11 -7
- package/_cjs/Ref/definition.cjs.map +1 -1
- package/_cjs/Ref/symbols.cjs +37 -0
- package/_cjs/Ref/symbols.cjs.map +1 -0
- package/_cjs/Ref.cjs +22 -18
- package/_cjs/Ref.cjs.map +1 -1
- package/_cjs/RefSubject/Atomic.cjs +109 -0
- package/_cjs/RefSubject/Atomic.cjs.map +1 -0
- package/_cjs/{FiberState/constructors.cjs → RefSubject/Synchronized/api.cjs} +13 -34
- package/_cjs/RefSubject/Synchronized/api.cjs.map +1 -0
- package/_cjs/RefSubject/Synchronized/definition.cjs +56 -0
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -0
- package/_cjs/RefSubject/api.cjs +245 -0
- package/_cjs/RefSubject/api.cjs.map +1 -0
- package/_cjs/{FiberState/api.cjs → RefSubject/definition.cjs} +12 -16
- package/_cjs/RefSubject/definition.cjs.map +1 -0
- package/_cjs/RefSubject.cjs +39 -0
- package/_cjs/RefSubject.cjs.map +1 -0
- package/_cjs/Reloadable/api.cjs +3 -18
- package/_cjs/Reloadable/api.cjs.map +1 -1
- package/_cjs/Reloadable/constructors.cjs +14 -41
- package/_cjs/Reloadable/constructors.cjs.map +1 -1
- package/_cjs/Reloadable/definition.cjs +0 -14
- package/_cjs/Reloadable/definition.cjs.map +1 -1
- package/_cjs/Reloadable.cjs +0 -6
- package/_cjs/Reloadable.cjs.map +1 -1
- package/_cjs/RuntimeConfig.cjs +1 -44
- package/_cjs/RuntimeConfig.cjs.map +1 -1
- package/_cjs/RuntimeFlag.cjs +6 -0
- package/_cjs/RuntimeFlag.cjs.map +1 -0
- package/_cjs/RuntimeFlags/Patch.cjs +76 -0
- package/_cjs/RuntimeFlags/Patch.cjs.map +1 -0
- package/_cjs/RuntimeFlags/RuntimeFlags.cjs +107 -0
- package/_cjs/RuntimeFlags/RuntimeFlags.cjs.map +1 -0
- package/_cjs/RuntimeFlags.cjs +28 -0
- package/_cjs/RuntimeFlags.cjs.map +1 -0
- package/_cjs/STM/api/core-api.cjs +36 -42
- package/_cjs/STM/api/core-api.cjs.map +1 -1
- package/_cjs/STM/api/core-constructors.cjs +0 -15
- package/_cjs/STM/api/core-constructors.cjs.map +1 -1
- package/_cjs/STM/api.cjs +218 -302
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs +9 -72
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/STM/driver.cjs +12 -65
- package/_cjs/STM/driver.cjs.map +1 -1
- package/_cjs/STM/internal/CommitState.cjs +5 -32
- package/_cjs/STM/internal/CommitState.cjs.map +1 -1
- package/_cjs/STM/internal/Entry.cjs +0 -20
- package/_cjs/STM/internal/Entry.cjs.map +1 -1
- package/_cjs/STM/internal/Journal.cjs +50 -142
- package/_cjs/STM/internal/Journal.cjs.map +1 -1
- package/_cjs/STM/internal/TryCommit.cjs +2 -12
- package/_cjs/STM/internal/TryCommit.cjs.map +1 -1
- package/_cjs/STM/internal/Versioned.cjs +0 -3
- package/_cjs/STM/internal/Versioned.cjs.map +1 -1
- package/_cjs/STM.cjs +0 -10
- package/_cjs/STM.cjs.map +1 -1
- package/_cjs/Schedule/Decision.cjs +13 -37
- package/_cjs/Schedule/Decision.cjs.map +1 -1
- package/_cjs/Schedule/Driver.cjs +0 -5
- package/_cjs/Schedule/Driver.cjs.map +1 -1
- package/_cjs/Schedule/api/driver.cjs +6 -22
- package/_cjs/Schedule/api/driver.cjs.map +1 -1
- package/_cjs/Schedule/api.cjs +440 -492
- package/_cjs/Schedule/api.cjs.map +1 -1
- package/_cjs/Schedule/definition.cjs +0 -2
- package/_cjs/Schedule/definition.cjs.map +1 -1
- package/_cjs/Schedule.cjs +0 -8
- package/_cjs/Schedule.cjs.map +1 -1
- package/_cjs/Scope/Finalizer/definition.cjs +0 -6
- package/_cjs/Scope/Finalizer/definition.cjs.map +1 -1
- package/_cjs/Scope/Finalizer.cjs +0 -2
- package/_cjs/Scope/Finalizer.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +13 -24
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/api.cjs +65 -79
- package/_cjs/Scope/ReleaseMap/api.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/constructors.cjs +1 -12
- package/_cjs/Scope/ReleaseMap/constructors.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/definition.cjs +0 -9
- package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap.cjs +0 -6
- package/_cjs/Scope/ReleaseMap.cjs.map +1 -1
- package/_cjs/Scope/api.cjs +34 -69
- package/_cjs/Scope/api.cjs.map +1 -1
- package/_cjs/Scope/definition.cjs +0 -12
- package/_cjs/Scope/definition.cjs.map +1 -1
- package/_cjs/Scope.cjs +0 -4
- package/_cjs/Scope.cjs.map +1 -1
- package/_cjs/ScopedRef/api.cjs +7 -26
- package/_cjs/ScopedRef/api.cjs.map +1 -1
- package/_cjs/ScopedRef/definition.cjs +1 -5
- package/_cjs/ScopedRef/definition.cjs.map +1 -1
- package/_cjs/ScopedRef.cjs +0 -4
- package/_cjs/ScopedRef.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +292 -484
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Sink/definition.cjs +0 -3
- package/_cjs/Sink/definition.cjs.map +1 -1
- package/_cjs/Sink.cjs +0 -4
- package/_cjs/Sink.cjs.map +1 -1
- package/_cjs/State/api.cjs +18 -32
- package/_cjs/State/api.cjs.map +1 -1
- package/_cjs/State/definition.cjs +2 -7
- package/_cjs/State/definition.cjs.map +1 -1
- package/_cjs/State/internal.cjs +0 -3
- package/_cjs/State/internal.cjs.map +1 -1
- package/_cjs/State.cjs +0 -4
- package/_cjs/State.cjs.map +1 -1
- package/_cjs/Stream/api/zipAllWith.cjs +16 -43
- package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWith.cjs +6 -9
- package/_cjs/Stream/api/zipWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWithChunks.cjs +14 -32
- package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +961 -1205
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/Stream/definition.cjs +0 -8
- package/_cjs/Stream/definition.cjs.map +1 -1
- package/_cjs/Stream/internal/DebounceState.cjs +16 -44
- package/_cjs/Stream/internal/DebounceState.cjs.map +1 -1
- package/_cjs/Stream/internal/Handoff.cjs +34 -80
- package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
- package/_cjs/Stream/internal/Pull.cjs +2 -25
- package/_cjs/Stream/internal/Pull.cjs.map +1 -1
- package/_cjs/Stream/internal/SinkEndReason.cjs +13 -28
- package/_cjs/Stream/internal/SinkEndReason.cjs.map +1 -1
- package/_cjs/Stream/internal/Take.cjs +32 -75
- package/_cjs/Stream/internal/Take.cjs.map +1 -1
- package/_cjs/Stream/internal/util.cjs +3 -13
- package/_cjs/Stream/internal/util.cjs.map +1 -1
- package/_cjs/Stream.cjs +0 -4
- package/_cjs/Stream.cjs.map +1 -1
- package/_cjs/{FiberState/definition.cjs → Subject/Atomic.cjs} +21 -36
- package/_cjs/Subject/Atomic.cjs.map +1 -0
- package/_cjs/{IO/api/withRuntimeConfig.cjs → Subject/api.cjs} +17 -14
- package/_cjs/Subject/api.cjs.map +1 -0
- package/_cjs/Subject/definition.cjs +11 -0
- package/_cjs/Subject/definition.cjs.map +1 -0
- package/_cjs/Subject.cjs +39 -0
- package/_cjs/Subject.cjs.map +1 -0
- package/_cjs/SubscriptionRef.cjs +54 -0
- package/_cjs/SubscriptionRef.cjs.map +1 -0
- package/_cjs/Supervisor/api.cjs +24 -37
- package/_cjs/Supervisor/api.cjs.map +1 -1
- package/_cjs/Supervisor/constructors.cjs +2 -26
- package/_cjs/Supervisor/constructors.cjs.map +1 -1
- package/_cjs/Supervisor/definition.cjs +6 -44
- package/_cjs/Supervisor/definition.cjs.map +1 -1
- package/_cjs/Supervisor.cjs +0 -6
- package/_cjs/Supervisor.cjs.map +1 -1
- package/_cjs/SupervisorPatch.cjs +25 -75
- package/_cjs/SupervisorPatch.cjs.map +1 -1
- package/_cjs/TExit/constructors.cjs +0 -12
- package/_cjs/TExit/constructors.cjs.map +1 -1
- package/_cjs/TExit/definition.cjs +14 -76
- package/_cjs/TExit/definition.cjs.map +1 -1
- package/_cjs/TExit.cjs +0 -4
- package/_cjs/TExit.cjs.map +1 -1
- package/_cjs/TFuture/api.cjs +21 -37
- package/_cjs/TFuture/api.cjs.map +1 -1
- package/_cjs/TFuture/constructors.cjs +1 -13
- package/_cjs/TFuture/constructors.cjs.map +1 -1
- package/_cjs/TFuture/definition.cjs +0 -4
- package/_cjs/TFuture/definition.cjs.map +1 -1
- package/_cjs/TFuture.cjs +0 -6
- package/_cjs/TFuture.cjs.map +1 -1
- package/_cjs/TReentrantLock/api.cjs +41 -111
- package/_cjs/TReentrantLock/api.cjs.map +1 -1
- package/_cjs/TReentrantLock/definition.cjs +7 -38
- package/_cjs/TReentrantLock/definition.cjs.map +1 -1
- package/_cjs/TReentrantLock.cjs +0 -4
- package/_cjs/TReentrantLock.cjs.map +1 -1
- package/_cjs/TRef/api.cjs +95 -296
- package/_cjs/TRef/api.cjs.map +1 -1
- package/_cjs/TRef/constructors.cjs +0 -19
- package/_cjs/TRef/constructors.cjs.map +1 -1
- package/_cjs/TRef/definition.cjs +84 -34
- package/_cjs/TRef/definition.cjs.map +1 -1
- package/_cjs/TRef/symbols.cjs +27 -0
- package/_cjs/TRef/symbols.cjs.map +1 -0
- package/_cjs/TRef.cjs +11 -6
- package/_cjs/TRef.cjs.map +1 -1
- package/_cjs/TSemaphore/api.cjs +30 -49
- package/_cjs/TSemaphore/api.cjs.map +1 -1
- package/_cjs/TSemaphore/constructors.cjs +13 -11
- package/_cjs/TSemaphore/constructors.cjs.map +1 -1
- package/_cjs/TSemaphore/definition.cjs +0 -4
- package/_cjs/TSemaphore/definition.cjs.map +1 -1
- package/_cjs/TSemaphore.cjs +0 -6
- package/_cjs/TSemaphore.cjs.map +1 -1
- package/_cjs/TxnId.cjs +0 -3
- package/_cjs/TxnId.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +19 -24
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +19 -24
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/filterIO.cjs +14 -19
- package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/findIO.cjs +18 -28
- package/_cjs/collection/immutable/Conc/findIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/mapIO.cjs +11 -14
- package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +29 -36
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc.cjs +0 -12
- package/_cjs/collection/immutable/Conc.cjs.map +1 -1
- package/_cjs/data/Exit/foreachIO.cjs +6 -10
- package/_cjs/data/Exit/foreachIO.cjs.map +1 -1
- package/_cjs/internal/HashedPair.cjs +4 -15
- package/_cjs/internal/HashedPair.cjs.map +1 -1
- package/_cjs/internal/Hub.cjs +13 -175
- package/_cjs/internal/Hub.cjs.map +1 -1
- package/_cjs/internal/IsFatal.cjs +22 -62
- package/_cjs/internal/IsFatal.cjs.map +1 -1
- package/_cjs/internal/MutableQueue.cjs +11 -77
- package/_cjs/internal/MutableQueue.cjs.map +1 -1
- package/_cjs/internal/Scheduler.cjs +0 -18
- package/_cjs/internal/Scheduler.cjs.map +1 -1
- package/_cjs/internal/StackTraceBuilder.cjs +0 -9
- package/_cjs/internal/StackTraceBuilder.cjs.map +1 -1
- package/_mjs/Cached/api.mjs +6 -13
- package/_mjs/Cached/api.mjs.map +1 -1
- package/_mjs/Cached/definition.mjs +2 -4
- package/_mjs/Cached/definition.mjs.map +1 -1
- package/_mjs/Cached/internal.mjs +0 -1
- package/_mjs/Cached/internal.mjs.map +1 -1
- package/_mjs/Cached.mjs.map +1 -1
- package/_mjs/CancellerState.mjs +6 -15
- package/_mjs/CancellerState.mjs.map +1 -1
- package/_mjs/Channel/ChildExecutorDecision/api.mjs +18 -18
- package/_mjs/Channel/ChildExecutorDecision/api.mjs.map +1 -1
- package/_mjs/Channel/ChildExecutorDecision/definition.mjs +0 -2
- package/_mjs/Channel/ChildExecutorDecision/definition.mjs.map +1 -1
- package/_mjs/Channel/ChildExecutorDecision.mjs.map +1 -1
- package/_mjs/Channel/UpstreamPullRequest/api.mjs +14 -16
- package/_mjs/Channel/UpstreamPullRequest/api.mjs.map +1 -1
- package/_mjs/Channel/UpstreamPullRequest/definition.mjs +0 -2
- package/_mjs/Channel/UpstreamPullRequest/definition.mjs.map +1 -1
- package/_mjs/Channel/UpstreamPullRequest.mjs.map +1 -1
- package/_mjs/Channel/UpstreamPullStrategy/definition.mjs +0 -1
- package/_mjs/Channel/UpstreamPullStrategy/definition.mjs.map +1 -1
- package/_mjs/Channel/UpstreamPullStrategy.mjs.map +1 -1
- package/_mjs/Channel/api/interruptWhen.mjs +11 -10
- package/_mjs/Channel/api/interruptWhen.mjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +34 -0
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs.map +1 -0
- package/_mjs/Channel/api/mergeAll.mjs +5 -4
- package/_mjs/Channel/api/mergeAll.mjs.map +1 -1
- package/_mjs/Channel/api/mergeAllUnboundedWith.mjs +5 -4
- package/_mjs/Channel/api/mergeAllUnboundedWith.mjs.map +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +39 -39
- package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
- package/_mjs/Channel/api/mergeMap.mjs +5 -4
- package/_mjs/Channel/api/mergeMap.mjs.map +1 -1
- package/_mjs/Channel/api/mergeWith.mjs +34 -50
- package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
- package/_mjs/Channel/api/run.mjs +1 -2
- package/_mjs/Channel/api/run.mjs.map +1 -1
- package/_mjs/Channel/api/runCollect.mjs +0 -1
- package/_mjs/Channel/api/runCollect.mjs.map +1 -1
- package/_mjs/Channel/api/runDrain.mjs +0 -1
- package/_mjs/Channel/api/runDrain.mjs.map +1 -1
- package/_mjs/Channel/api/runScoped.mjs +6 -21
- package/_mjs/Channel/api/runScoped.mjs.map +1 -1
- package/_mjs/Channel/api/toPull.mjs +7 -20
- package/_mjs/Channel/api/toPull.mjs.map +1 -1
- package/_mjs/Channel/api/zipConcurrent.mjs +32 -0
- package/_mjs/Channel/api/zipConcurrent.mjs.map +1 -0
- package/_mjs/Channel/api.mjs +201 -267
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/core-api.mjs +28 -35
- package/_mjs/Channel/core-api.mjs.map +1 -1
- package/_mjs/Channel/definition.mjs +32 -67
- package/_mjs/Channel/definition.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelExecutor.mjs +161 -340
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelState.mjs +5 -20
- package/_mjs/Channel/internal/ChannelState.mjs.map +1 -1
- package/_mjs/Channel/internal/MergeDecision.mjs +5 -16
- package/_mjs/Channel/internal/MergeDecision.mjs.map +1 -1
- package/_mjs/Channel/internal/MergeState.mjs +6 -15
- package/_mjs/Channel/internal/MergeState.mjs.map +1 -1
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +40 -103
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
- package/_mjs/Channel.mjs.map +1 -1
- package/_mjs/Clock/api.mjs +0 -2
- package/_mjs/Clock/api.mjs.map +1 -1
- package/_mjs/Clock/definition.mjs +0 -2
- package/_mjs/Clock/definition.mjs.map +1 -1
- package/_mjs/Clock/live.mjs +2 -6
- package/_mjs/Clock/live.mjs.map +1 -1
- package/_mjs/Clock.mjs.map +1 -1
- package/_mjs/Console/api.mjs +0 -2
- package/_mjs/Console/api.mjs.map +1 -1
- package/_mjs/Console/definition.mjs +0 -2
- package/_mjs/Console/definition.mjs.map +1 -1
- package/_mjs/Console/live.mjs +0 -4
- package/_mjs/Console/live.mjs.map +1 -1
- package/_mjs/Console.mjs.map +1 -1
- package/_mjs/CountdownLatch.mjs +39 -0
- package/_mjs/CountdownLatch.mjs.map +1 -0
- package/_mjs/Differ/api.mjs +5 -20
- package/_mjs/Differ/api.mjs.map +1 -1
- package/_mjs/Differ/definition.mjs +0 -2
- package/_mjs/Differ/definition.mjs.map +1 -1
- package/_mjs/Fiber/FiberMessage.mjs +56 -0
- package/_mjs/Fiber/FiberMessage.mjs.map +1 -0
- package/_mjs/Fiber/FiberRuntime.mjs +728 -0
- package/_mjs/Fiber/FiberRuntime.mjs.map +1 -0
- package/_mjs/Fiber/api/await.mjs.map +1 -1
- package/_mjs/Fiber/api/awaitAll.mjs +2 -3
- package/_mjs/Fiber/api/awaitAll.mjs.map +1 -1
- package/_mjs/Fiber/api/children.mjs.map +1 -1
- package/_mjs/Fiber/api/collectAll.mjs +3 -4
- package/_mjs/Fiber/api/collectAll.mjs.map +1 -1
- package/_mjs/Fiber/api/fromIO.mjs +1 -2
- package/_mjs/Fiber/api/fromIO.mjs.map +1 -1
- package/_mjs/Fiber/api/id.mjs.map +1 -1
- package/_mjs/Fiber/api/inheritRefs.mjs +1 -1
- package/_mjs/Fiber/api/inheritRefs.mjs.map +1 -1
- package/_mjs/Fiber/api/interrupt.mjs +3 -4
- package/_mjs/Fiber/api/interrupt.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptAll.mjs +3 -6
- package/_mjs/Fiber/api/interruptAll.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptAs.mjs +13 -5
- package/_mjs/Fiber/api/interruptAs.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptFork.mjs +2 -5
- package/_mjs/Fiber/api/interruptFork.mjs.map +1 -1
- package/_mjs/Fiber/api/join.mjs +3 -3
- package/_mjs/Fiber/api/join.mjs.map +1 -1
- package/_mjs/Fiber/api/joinAll.mjs +1 -2
- package/_mjs/Fiber/api/joinAll.mjs.map +1 -1
- package/_mjs/Fiber/api/location.mjs +1 -3
- package/_mjs/Fiber/api/location.mjs.map +1 -1
- package/_mjs/Fiber/api/mapFiber.mjs +5 -4
- package/_mjs/Fiber/api/mapFiber.mjs.map +1 -1
- package/_mjs/Fiber/api/mapIO.mjs +11 -10
- package/_mjs/Fiber/api/mapIO.mjs.map +1 -1
- package/_mjs/Fiber/api/poll.mjs.map +1 -1
- package/_mjs/Fiber/api/zipWith.mjs +6 -5
- package/_mjs/Fiber/api/zipWith.mjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +0 -6
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/Fiber/definition.mjs +9 -5
- package/_mjs/Fiber/definition.mjs.map +1 -1
- package/_mjs/Fiber.mjs +3 -4
- package/_mjs/Fiber.mjs.map +1 -1
- package/_mjs/FiberDescriptor.mjs +1 -4
- package/_mjs/FiberDescriptor.mjs.map +1 -1
- package/_mjs/FiberRef/api/locallyScoped.mjs +5 -4
- package/_mjs/FiberRef/api/locallyScoped.mjs.map +1 -1
- package/_mjs/FiberRef/api/locallyScopedWith.mjs +5 -4
- package/_mjs/FiberRef/api/locallyScopedWith.mjs.map +1 -1
- package/_mjs/FiberRef/api.mjs +64 -66
- package/_mjs/FiberRef/api.mjs.map +1 -1
- package/_mjs/FiberRef/constructors.mjs +1 -4
- package/_mjs/FiberRef/constructors.mjs.map +1 -1
- package/_mjs/FiberRef/definition.mjs +5 -10
- package/_mjs/FiberRef/definition.mjs.map +1 -1
- package/_mjs/FiberRef/unsafe.mjs +17 -30
- package/_mjs/FiberRef/unsafe.mjs.map +1 -1
- package/_mjs/FiberRef.mjs +2 -2
- package/_mjs/FiberRef.mjs.map +1 -1
- package/_mjs/FiberRefs/api.mjs +70 -24
- package/_mjs/FiberRefs/api.mjs.map +1 -1
- package/_mjs/FiberRefs/definition.mjs +2 -13
- package/_mjs/FiberRefs/definition.mjs.map +1 -1
- package/_mjs/FiberRefs/join.mjs +51 -61
- package/_mjs/FiberRefs/join.mjs.map +1 -1
- package/_mjs/FiberRefs.mjs.map +1 -1
- package/_mjs/FiberScope/constructors.mjs +0 -2
- package/_mjs/FiberScope/constructors.mjs.map +1 -1
- package/_mjs/FiberScope/definition.mjs +15 -12
- package/_mjs/FiberScope/definition.mjs.map +1 -1
- package/_mjs/FiberScope.mjs.map +1 -1
- package/_mjs/FiberStatus/constructors.mjs +5 -15
- package/_mjs/FiberStatus/constructors.mjs.map +1 -1
- package/_mjs/FiberStatus/definition.mjs +14 -66
- package/_mjs/FiberStatus/definition.mjs.map +1 -1
- package/_mjs/FiberStatus.mjs.map +1 -1
- package/_mjs/Future/api.mjs +87 -110
- package/_mjs/Future/api.mjs.map +1 -1
- package/_mjs/Future/constructors.mjs +1 -5
- package/_mjs/Future/constructors.mjs.map +1 -1
- package/_mjs/Future/definition.mjs +3 -9
- package/_mjs/Future/definition.mjs.map +1 -1
- package/_mjs/Future.mjs.map +1 -1
- package/_mjs/Hub/api.mjs +98 -123
- package/_mjs/Hub/api.mjs.map +1 -1
- package/_mjs/Hub/definition.mjs +13 -3
- package/_mjs/Hub/definition.mjs.map +1 -1
- package/_mjs/Hub/internal.mjs +30 -90
- package/_mjs/Hub/internal.mjs.map +1 -1
- package/_mjs/Hub.mjs.map +1 -1
- package/_mjs/IO/api/acquireRelease.mjs +0 -1
- package/_mjs/IO/api/acquireRelease.mjs.map +1 -1
- package/_mjs/IO/api/acquireReleaseExit.mjs +1 -2
- package/_mjs/IO/api/acquireReleaseExit.mjs.map +1 -1
- package/_mjs/IO/api/acquireReleaseInterruptible.mjs +0 -1
- package/_mjs/IO/api/acquireReleaseInterruptible.mjs.map +1 -1
- package/_mjs/IO/api/acquireReleaseInterruptibleExit.mjs +2 -2
- package/_mjs/IO/api/acquireReleaseInterruptibleExit.mjs.map +1 -1
- package/_mjs/IO/api/addFinalizer.mjs +0 -1
- package/_mjs/IO/api/addFinalizer.mjs.map +1 -1
- package/_mjs/IO/api/addFinalizerExit.mjs +1 -2
- package/_mjs/IO/api/addFinalizerExit.mjs.map +1 -1
- package/_mjs/IO/api/asyncIO.mjs +8 -8
- package/_mjs/IO/api/asyncIO.mjs.map +1 -1
- package/_mjs/IO/api/asyncInterrupt.mjs +65 -0
- package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -0
- package/_mjs/IO/api/bracket.mjs +2 -3
- package/_mjs/IO/api/bracket.mjs.map +1 -1
- package/_mjs/IO/api/bracketExit.mjs +2 -3
- package/_mjs/IO/api/bracketExit.mjs.map +1 -1
- package/_mjs/IO/api/clockWith.mjs +2 -5
- package/_mjs/IO/api/clockWith.mjs.map +1 -1
- package/_mjs/IO/api/concurrency.mjs +8 -11
- package/_mjs/IO/api/concurrency.mjs.map +1 -1
- package/_mjs/IO/api/concurrentFinalizers.mjs +1 -2
- package/_mjs/IO/api/concurrentFinalizers.mjs.map +1 -1
- package/_mjs/IO/api/consoleWith.mjs +2 -5
- package/_mjs/IO/api/consoleWith.mjs.map +1 -1
- package/_mjs/IO/api/core-scope.mjs +56 -94
- package/_mjs/IO/api/core-scope.mjs.map +1 -1
- package/_mjs/IO/api/delay.mjs +12 -0
- package/_mjs/IO/api/delay.mjs.map +1 -0
- package/_mjs/IO/api/ensuringChildren.mjs +7 -5
- package/_mjs/IO/api/ensuringChildren.mjs.map +1 -1
- package/_mjs/IO/api/environment.mjs +29 -42
- package/_mjs/IO/api/environment.mjs.map +1 -1
- package/_mjs/IO/api/foreachConcurrent.mjs +104 -0
- package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -0
- package/_mjs/IO/api/foreachExec.mjs +3 -4
- package/_mjs/IO/api/foreachExec.mjs.map +1 -1
- package/_mjs/IO/api/fork.mjs +64 -0
- package/_mjs/IO/api/fork.mjs.map +1 -0
- package/_mjs/IO/api/forkAll.mjs +3 -3
- package/_mjs/IO/api/forkAll.mjs.map +1 -1
- package/_mjs/IO/api/forkIn.mjs +7 -6
- package/_mjs/IO/api/forkIn.mjs.map +1 -1
- package/_mjs/IO/api/forkScoped.mjs +1 -2
- package/_mjs/IO/api/forkScoped.mjs.map +1 -1
- package/_mjs/IO/api/fulfill.mjs +7 -6
- package/_mjs/IO/api/fulfill.mjs.map +1 -1
- package/_mjs/IO/api/interrupt.mjs +45 -58
- package/_mjs/IO/api/interrupt.mjs.map +1 -1
- package/_mjs/IO/api/memoize.mjs +1 -2
- package/_mjs/IO/api/memoize.mjs.map +1 -1
- package/_mjs/IO/api/onExit.mjs +5 -4
- package/_mjs/IO/api/onExit.mjs.map +1 -1
- package/_mjs/IO/api/onTermination.mjs +5 -4
- package/_mjs/IO/api/onTermination.mjs.map +1 -1
- package/_mjs/IO/api/once.mjs +1 -2
- package/_mjs/IO/api/once.mjs.map +1 -1
- package/_mjs/IO/api/provideLayer.mjs +5 -4
- package/_mjs/IO/api/provideLayer.mjs.map +1 -1
- package/_mjs/IO/api/provideSomeLayer.mjs +5 -12
- package/_mjs/IO/api/provideSomeLayer.mjs.map +1 -1
- package/_mjs/IO/api/race.mjs +7 -7
- package/_mjs/IO/api/race.mjs.map +1 -1
- package/_mjs/IO/api/raceFirst.mjs +5 -4
- package/_mjs/IO/api/raceFirst.mjs.map +1 -1
- package/_mjs/IO/api/randomWith.mjs +1 -4
- package/_mjs/IO/api/randomWith.mjs.map +1 -1
- package/_mjs/IO/api/repeat.mjs +8 -13
- package/_mjs/IO/api/repeat.mjs.map +1 -1
- package/_mjs/IO/api/retry.mjs +12 -18
- package/_mjs/IO/api/retry.mjs.map +1 -1
- package/_mjs/IO/api/schedule.mjs +15 -15
- package/_mjs/IO/api/schedule.mjs.map +1 -1
- package/_mjs/IO/api/scope.mjs +0 -1
- package/_mjs/IO/api/scope.mjs.map +1 -1
- package/_mjs/IO/api/scopeWith.mjs +0 -1
- package/_mjs/IO/api/scopeWith.mjs.map +1 -1
- package/_mjs/IO/api/scoped.mjs +3 -6
- package/_mjs/IO/api/scoped.mjs.map +1 -1
- package/_mjs/IO/api/sequenceT.mjs +1 -2
- package/_mjs/IO/api/sequenceT.mjs.map +1 -1
- package/_mjs/IO/api/sleep.mjs +0 -1
- package/_mjs/IO/api/sleep.mjs.map +1 -1
- package/_mjs/IO/api/stateful.mjs +0 -1
- package/_mjs/IO/api/stateful.mjs.map +1 -1
- package/_mjs/IO/api/supervised.mjs +5 -9
- package/_mjs/IO/api/supervised.mjs.map +1 -1
- package/_mjs/IO/api/timeout.mjs +10 -9
- package/_mjs/IO/api/timeout.mjs.map +1 -1
- package/_mjs/IO/api/withChildren.mjs +2 -4
- package/_mjs/IO/api/withChildren.mjs.map +1 -1
- package/_mjs/IO/api/withEarlyRelease.mjs +1 -2
- package/_mjs/IO/api/withEarlyRelease.mjs.map +1 -1
- package/_mjs/IO/api/withFinalizer.mjs +5 -4
- package/_mjs/IO/api/withFinalizer.mjs.map +1 -1
- package/_mjs/IO/api/withFinalizerExit.mjs +5 -4
- package/_mjs/IO/api/withFinalizerExit.mjs.map +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs +41 -0
- package/_mjs/IO/api/zipConcurrent.mjs.map +1 -0
- package/_mjs/IO/api.mjs +545 -797
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +107 -150
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +51 -86
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +7 -5
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/IOEnv/definition.mjs +1 -2
- package/_mjs/IOEnv/definition.mjs.map +1 -1
- package/_mjs/IOEnv/live.mjs +1 -2
- package/_mjs/IOEnv/live.mjs.map +1 -1
- package/_mjs/IOEnv/services.mjs +0 -1
- package/_mjs/IOEnv/services.mjs.map +1 -1
- package/_mjs/IOEnv.mjs.map +1 -1
- package/_mjs/InterruptStatus/constructors.mjs +0 -3
- package/_mjs/InterruptStatus/constructors.mjs.map +1 -1
- package/_mjs/InterruptStatus/definition.mjs +0 -3
- package/_mjs/InterruptStatus/definition.mjs.map +1 -1
- package/_mjs/InterruptStatus.mjs.map +1 -1
- package/_mjs/Layer/MemoMap.mjs +54 -82
- package/_mjs/Layer/MemoMap.mjs.map +1 -1
- package/_mjs/Layer/api.mjs +93 -130
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Layer/definition.mjs +15 -34
- package/_mjs/Layer/definition.mjs.map +1 -1
- package/_mjs/Layer.mjs.map +1 -1
- package/_mjs/LogLevel.mjs +24 -29
- package/_mjs/LogLevel.mjs.map +1 -1
- package/_mjs/LogSpan.mjs +16 -18
- package/_mjs/LogSpan.mjs.map +1 -1
- package/_mjs/Logger/api.mjs +16 -14
- package/_mjs/Logger/api.mjs.map +1 -1
- package/_mjs/Logger/constructors.mjs +3 -11
- package/_mjs/Logger/constructors.mjs.map +1 -1
- package/_mjs/Logger/definition.mjs +0 -1
- package/_mjs/Logger/definition.mjs.map +1 -1
- package/_mjs/Logger.mjs.map +1 -1
- package/_mjs/Push/api.mjs +417 -0
- package/_mjs/Push/api.mjs.map +1 -0
- package/_mjs/Push/definition.mjs +33 -0
- package/_mjs/Push/definition.mjs.map +1 -0
- package/_mjs/Push/internal.mjs +26 -0
- package/_mjs/Push/internal.mjs.map +1 -0
- package/_mjs/Push.mjs +5 -0
- package/_mjs/Push.mjs.map +1 -0
- package/_mjs/Queue/api/dimapIO.mjs +101 -42
- package/_mjs/Queue/api/dimapIO.mjs.map +1 -1
- package/_mjs/Queue/api/filterInputIO.mjs +59 -24
- package/_mjs/Queue/api/filterInputIO.mjs.map +1 -1
- package/_mjs/Queue/api/filterOutputIO.mjs +70 -32
- package/_mjs/Queue/api/filterOutputIO.mjs.map +1 -1
- package/_mjs/Queue/api/operations.mjs +18 -22
- package/_mjs/Queue/api/operations.mjs.map +1 -1
- package/_mjs/Queue/api/poll.mjs +1 -2
- package/_mjs/Queue/api/poll.mjs.map +1 -1
- package/_mjs/Queue/api/takeBetween.mjs +23 -27
- package/_mjs/Queue/api/takeBetween.mjs.map +1 -1
- package/_mjs/Queue/api/zipWithIO.mjs +30 -33
- package/_mjs/Queue/api/zipWithIO.mjs.map +1 -1
- package/_mjs/Queue/api.mjs.map +1 -1
- package/_mjs/Queue/constructors.mjs +5 -9
- package/_mjs/Queue/constructors.mjs.map +1 -1
- package/_mjs/Queue/definition.mjs +14 -7
- package/_mjs/Queue/definition.mjs.map +1 -1
- package/_mjs/Queue/internal.mjs +57 -93
- package/_mjs/Queue/internal.mjs.map +1 -1
- package/_mjs/Queue/strategy.mjs +28 -55
- package/_mjs/Queue/strategy.mjs.map +1 -1
- package/_mjs/Queue.mjs.map +1 -1
- package/_mjs/Random/api.mjs +0 -8
- package/_mjs/Random/api.mjs.map +1 -1
- package/_mjs/Random/definition.mjs +0 -2
- package/_mjs/Random/definition.mjs.map +1 -1
- package/_mjs/Random/live.mjs +2 -9
- package/_mjs/Random/live.mjs.map +1 -1
- package/_mjs/Random.mjs.map +1 -1
- package/_mjs/Ref/Atomic.mjs +49 -3
- package/_mjs/Ref/Atomic.mjs.map +1 -1
- package/_mjs/Ref/Derived.mjs +11 -9
- package/_mjs/Ref/Derived.mjs.map +1 -1
- package/_mjs/Ref/DerivedAll.mjs +15 -11
- package/_mjs/Ref/DerivedAll.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/api.mjs +82 -68
- package/_mjs/Ref/Synchronized/api.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/constructors.mjs +1 -2
- package/_mjs/Ref/Synchronized/constructors.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs +16 -28
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/Ref/Synchronized.mjs +5 -0
- package/_mjs/Ref/Synchronized.mjs.map +1 -0
- package/_mjs/Ref/api/collect.mjs +6 -5
- package/_mjs/Ref/api/collect.mjs.map +1 -1
- package/_mjs/Ref/api/dimap.mjs +45 -41
- package/_mjs/Ref/api/dimap.mjs.map +1 -1
- package/_mjs/Ref/api/filter.mjs +12 -10
- package/_mjs/Ref/api/filter.mjs.map +1 -1
- package/_mjs/Ref/api/get.mjs +0 -1
- package/_mjs/Ref/api/get.mjs.map +1 -1
- package/_mjs/Ref/api/match.mjs +7 -7
- package/_mjs/Ref/api/match.mjs.map +1 -1
- package/_mjs/Ref/api/matchAll.mjs +5 -5
- package/_mjs/Ref/api/matchAll.mjs.map +1 -1
- package/_mjs/Ref/api/modify.mjs +63 -143
- package/_mjs/Ref/api/modify.mjs.map +1 -1
- package/_mjs/Ref/api/set.mjs +7 -6
- package/_mjs/Ref/api/set.mjs.map +1 -1
- package/_mjs/Ref/api.mjs +5 -7
- package/_mjs/Ref/api.mjs.map +1 -1
- package/_mjs/Ref/constructors.mjs +2 -3
- package/_mjs/Ref/constructors.mjs.map +1 -1
- package/_mjs/Ref/definition.mjs +10 -3
- package/_mjs/Ref/definition.mjs.map +1 -1
- package/_mjs/Ref/symbols.mjs +25 -0
- package/_mjs/Ref/symbols.mjs.map +1 -0
- package/_mjs/Ref.mjs +4 -2
- package/_mjs/Ref.mjs.map +1 -1
- package/_mjs/RefSubject/Atomic.mjs +100 -0
- package/_mjs/RefSubject/Atomic.mjs.map +1 -0
- package/_mjs/RefSubject/Synchronized/api.mjs +15 -0
- package/_mjs/RefSubject/Synchronized/api.mjs.map +1 -0
- package/_mjs/RefSubject/Synchronized/definition.mjs +45 -0
- package/_mjs/RefSubject/Synchronized/definition.mjs.map +1 -0
- package/_mjs/RefSubject/api.mjs +220 -0
- package/_mjs/RefSubject/api.mjs.map +1 -0
- package/_mjs/RefSubject/definition.mjs +11 -0
- package/_mjs/RefSubject/definition.mjs.map +1 -0
- package/_mjs/RefSubject.mjs +5 -0
- package/_mjs/RefSubject.mjs.map +1 -0
- package/_mjs/Reloadable/api.mjs +3 -12
- package/_mjs/Reloadable/api.mjs.map +1 -1
- package/_mjs/Reloadable/constructors.mjs +14 -26
- package/_mjs/Reloadable/constructors.mjs.map +1 -1
- package/_mjs/Reloadable/definition.mjs +0 -6
- package/_mjs/Reloadable/definition.mjs.map +1 -1
- package/_mjs/Reloadable.mjs.map +1 -1
- package/_mjs/RuntimeConfig.mjs +0 -31
- package/_mjs/RuntimeConfig.mjs.map +1 -1
- package/_mjs/RuntimeFlag.mjs +2 -0
- package/_mjs/RuntimeFlag.mjs.map +1 -0
- package/_mjs/RuntimeFlags/Patch.mjs +58 -0
- package/_mjs/RuntimeFlags/Patch.mjs.map +1 -0
- package/_mjs/RuntimeFlags/RuntimeFlags.mjs +82 -0
- package/_mjs/RuntimeFlags/RuntimeFlags.mjs.map +1 -0
- package/_mjs/RuntimeFlags.mjs +4 -0
- package/_mjs/RuntimeFlags.mjs.map +1 -0
- package/_mjs/STM/api/core-api.mjs +29 -27
- package/_mjs/STM/api/core-api.mjs.map +1 -1
- package/_mjs/STM/api/core-constructors.mjs +0 -8
- package/_mjs/STM/api/core-constructors.mjs.map +1 -1
- package/_mjs/STM/api.mjs +182 -212
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/STM/definition.mjs +14 -36
- package/_mjs/STM/definition.mjs.map +1 -1
- package/_mjs/STM/driver.mjs +12 -54
- package/_mjs/STM/driver.mjs.map +1 -1
- package/_mjs/STM/internal/CommitState.mjs +5 -25
- package/_mjs/STM/internal/CommitState.mjs.map +1 -1
- package/_mjs/STM/internal/Entry.mjs +0 -12
- package/_mjs/STM/internal/Entry.mjs.map +1 -1
- package/_mjs/STM/internal/Journal.mjs +50 -128
- package/_mjs/STM/internal/Journal.mjs.map +1 -1
- package/_mjs/STM/internal/TryCommit.mjs +3 -8
- package/_mjs/STM/internal/TryCommit.mjs.map +1 -1
- package/_mjs/STM/internal/Versioned.mjs +0 -1
- package/_mjs/STM/internal/Versioned.mjs.map +1 -1
- package/_mjs/STM.mjs +2 -2
- package/_mjs/STM.mjs.map +1 -1
- package/_mjs/Schedule/Decision.mjs +14 -25
- package/_mjs/Schedule/Decision.mjs.map +1 -1
- package/_mjs/Schedule/Driver.mjs +0 -2
- package/_mjs/Schedule/Driver.mjs.map +1 -1
- package/_mjs/Schedule/api/driver.mjs +6 -8
- package/_mjs/Schedule/api/driver.mjs.map +1 -1
- package/_mjs/Schedule/api.mjs +379 -374
- package/_mjs/Schedule/api.mjs.map +1 -1
- package/_mjs/Schedule/definition.mjs.map +1 -1
- package/_mjs/Schedule.mjs.map +1 -1
- package/_mjs/Scope/Finalizer/definition.mjs +0 -1
- package/_mjs/Scope/Finalizer/definition.mjs.map +1 -1
- package/_mjs/Scope/Finalizer.mjs.map +1 -1
- package/_mjs/Scope/ReleaseMap/api/releaseAll.mjs +12 -12
- package/_mjs/Scope/ReleaseMap/api/releaseAll.mjs.map +1 -1
- package/_mjs/Scope/ReleaseMap/api.mjs +59 -60
- package/_mjs/Scope/ReleaseMap/api.mjs.map +1 -1
- package/_mjs/Scope/ReleaseMap/constructors.mjs +1 -4
- package/_mjs/Scope/ReleaseMap/constructors.mjs.map +1 -1
- package/_mjs/Scope/ReleaseMap/definition.mjs +0 -2
- package/_mjs/Scope/ReleaseMap/definition.mjs.map +1 -1
- package/_mjs/Scope/ReleaseMap.mjs.map +1 -1
- package/_mjs/Scope/api.mjs +28 -45
- package/_mjs/Scope/api.mjs.map +1 -1
- package/_mjs/Scope/definition.mjs +0 -4
- package/_mjs/Scope/definition.mjs.map +1 -1
- package/_mjs/Scope.mjs.map +1 -1
- package/_mjs/ScopedRef/api.mjs +7 -11
- package/_mjs/ScopedRef/api.mjs.map +1 -1
- package/_mjs/ScopedRef/definition.mjs +1 -3
- package/_mjs/ScopedRef/definition.mjs.map +1 -1
- package/_mjs/ScopedRef.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +282 -383
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Sink/definition.mjs +0 -1
- package/_mjs/Sink/definition.mjs.map +1 -1
- package/_mjs/Sink.mjs.map +1 -1
- package/_mjs/State/api.mjs +16 -19
- package/_mjs/State/api.mjs.map +1 -1
- package/_mjs/State/definition.mjs +2 -4
- package/_mjs/State/definition.mjs.map +1 -1
- package/_mjs/State/internal.mjs +0 -1
- package/_mjs/State/internal.mjs.map +1 -1
- package/_mjs/State.mjs.map +1 -1
- package/_mjs/Stream/api/zipAllWith.mjs +15 -30
- package/_mjs/Stream/api/zipAllWith.mjs.map +1 -1
- package/_mjs/Stream/api/zipWith.mjs +5 -4
- package/_mjs/Stream/api/zipWith.mjs.map +1 -1
- package/_mjs/Stream/api/zipWithChunks.mjs +13 -23
- package/_mjs/Stream/api/zipWithChunks.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +827 -936
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/Stream/definition.mjs +0 -4
- package/_mjs/Stream/definition.mjs.map +1 -1
- package/_mjs/Stream/internal/DebounceState.mjs +18 -34
- package/_mjs/Stream/internal/DebounceState.mjs.map +1 -1
- package/_mjs/Stream/internal/Handoff.mjs +33 -51
- package/_mjs/Stream/internal/Handoff.mjs.map +1 -1
- package/_mjs/Stream/internal/Pull.mjs +2 -9
- package/_mjs/Stream/internal/Pull.mjs.map +1 -1
- package/_mjs/Stream/internal/SinkEndReason.mjs +13 -22
- package/_mjs/Stream/internal/SinkEndReason.mjs.map +1 -1
- package/_mjs/Stream/internal/Take.mjs +28 -42
- package/_mjs/Stream/internal/Take.mjs.map +1 -1
- package/_mjs/Stream/internal/util.mjs +3 -6
- package/_mjs/Stream/internal/util.mjs.map +1 -1
- package/_mjs/Stream.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +22 -0
- package/_mjs/Subject/Atomic.mjs.map +1 -0
- package/_mjs/Subject/api.mjs +18 -0
- package/_mjs/Subject/api.mjs.map +1 -0
- package/_mjs/Subject/definition.mjs +3 -0
- package/_mjs/Subject/definition.mjs.map +1 -0
- package/_mjs/Subject.mjs +5 -0
- package/_mjs/Subject.mjs.map +1 -0
- package/_mjs/SubscriptionRef.mjs +41 -0
- package/_mjs/SubscriptionRef.mjs.map +1 -0
- package/_mjs/Supervisor/api.mjs +22 -29
- package/_mjs/Supervisor/api.mjs.map +1 -1
- package/_mjs/Supervisor/constructors.mjs +2 -14
- package/_mjs/Supervisor/constructors.mjs.map +1 -1
- package/_mjs/Supervisor/definition.mjs +6 -32
- package/_mjs/Supervisor/definition.mjs.map +1 -1
- package/_mjs/Supervisor.mjs.map +1 -1
- package/_mjs/SupervisorPatch.mjs +28 -55
- package/_mjs/SupervisorPatch.mjs.map +1 -1
- package/_mjs/TExit/constructors.mjs +0 -6
- package/_mjs/TExit/constructors.mjs.map +1 -1
- package/_mjs/TExit/definition.mjs +14 -57
- package/_mjs/TExit/definition.mjs.map +1 -1
- package/_mjs/TExit.mjs.map +1 -1
- package/_mjs/TFuture/api.mjs +17 -17
- package/_mjs/TFuture/api.mjs.map +1 -1
- package/_mjs/TFuture/constructors.mjs +1 -4
- package/_mjs/TFuture/constructors.mjs.map +1 -1
- package/_mjs/TFuture/definition.mjs.map +1 -1
- package/_mjs/TFuture.mjs.map +1 -1
- package/_mjs/TReentrantLock/api.mjs +41 -85
- package/_mjs/TReentrantLock/api.mjs.map +1 -1
- package/_mjs/TReentrantLock/definition.mjs +7 -26
- package/_mjs/TReentrantLock/definition.mjs.map +1 -1
- package/_mjs/TReentrantLock.mjs.map +1 -1
- package/_mjs/TRef/api.mjs +79 -257
- package/_mjs/TRef/api.mjs.map +1 -1
- package/_mjs/TRef/constructors.mjs +0 -7
- package/_mjs/TRef/constructors.mjs.map +1 -1
- package/_mjs/TRef/definition.mjs +84 -19
- package/_mjs/TRef/definition.mjs.map +1 -1
- package/_mjs/TRef/symbols.mjs +17 -0
- package/_mjs/TRef/symbols.mjs.map +1 -0
- package/_mjs/TRef.mjs +1 -0
- package/_mjs/TRef.mjs.map +1 -1
- package/_mjs/TSemaphore/api.mjs +26 -32
- package/_mjs/TSemaphore/api.mjs.map +1 -1
- package/_mjs/TSemaphore/constructors.mjs +10 -4
- package/_mjs/TSemaphore/constructors.mjs.map +1 -1
- package/_mjs/TSemaphore/definition.mjs.map +1 -1
- package/_mjs/TSemaphore.mjs.map +1 -1
- package/_mjs/TxnId.mjs +0 -1
- package/_mjs/TxnId.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/dropUntilIO.mjs +19 -20
- package/_mjs/collection/immutable/Conc/dropUntilIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/dropWhileIO.mjs +19 -20
- package/_mjs/collection/immutable/Conc/dropWhileIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/filterIO.mjs +14 -15
- package/_mjs/collection/immutable/Conc/filterIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/findIO.mjs +17 -22
- package/_mjs/collection/immutable/Conc/findIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/mapIO.mjs +10 -9
- package/_mjs/collection/immutable/Conc/mapIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/takeWhileIO.mjs +28 -30
- package/_mjs/collection/immutable/Conc/takeWhileIO.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc.mjs.map +1 -1
- package/_mjs/data/Exit/foreachIO.mjs +5 -4
- package/_mjs/data/Exit/foreachIO.mjs.map +1 -1
- package/_mjs/internal/HashedPair.mjs +4 -7
- package/_mjs/internal/HashedPair.mjs.map +1 -1
- package/_mjs/internal/Hub.mjs +13 -158
- package/_mjs/internal/Hub.mjs.map +1 -1
- package/_mjs/internal/IsFatal.mjs +24 -51
- package/_mjs/internal/IsFatal.mjs.map +1 -1
- package/_mjs/internal/MutableQueue.mjs +10 -57
- package/_mjs/internal/MutableQueue.mjs.map +1 -1
- package/_mjs/internal/Scheduler.mjs +0 -11
- package/_mjs/internal/Scheduler.mjs.map +1 -1
- package/_mjs/internal/StackTraceBuilder.mjs +0 -3
- package/_mjs/internal/StackTraceBuilder.mjs.map +1 -1
- package/_src/Cached/api.ts +2 -2
- package/_src/Channel/ChildExecutorDecision/api.ts +14 -17
- package/_src/Channel/UpstreamPullRequest/api.ts +11 -13
- package/_src/Channel/api/interruptWhen.ts +18 -17
- package/_src/Channel/api/mapOutConcurrentIO.ts +66 -0
- package/_src/Channel/api/mergeAll.ts +15 -16
- package/_src/Channel/api/mergeAllUnboundedWith.ts +15 -27
- package/_src/Channel/api/mergeAllWith.ts +114 -126
- package/_src/Channel/api/mergeMap.ts +8 -18
- package/_src/Channel/api/mergeWith.ts +154 -158
- package/_src/Channel/api/toPull.ts +1 -1
- package/_src/Channel/api/zipConcurrent.ts +68 -0
- package/_src/Channel/api.ts +354 -414
- package/_src/Channel/core-api.ts +75 -122
- package/_src/Channel/definition.ts +49 -7
- package/_src/Channel/internal/ChannelExecutor.ts +12 -16
- package/_src/Channel/internal/SingleProducerAsyncInput.ts +2 -4
- package/_src/CountdownLatch.ts +39 -0
- package/_src/Fiber/FiberMessage.ts +78 -0
- package/_src/Fiber/FiberRuntime.ts +822 -0
- package/_src/Fiber/api/awaitAll.ts +1 -1
- package/_src/Fiber/api/collectAll.ts +2 -2
- package/_src/Fiber/api/inheritRefs.ts +1 -1
- package/_src/Fiber/api/interrupt.ts +1 -2
- package/_src/Fiber/api/interruptAll.ts +1 -2
- package/_src/Fiber/api/interruptAs.ts +9 -2
- package/_src/Fiber/api/interruptFork.ts +1 -1
- package/_src/Fiber/api/location.ts +2 -2
- package/_src/Fiber/api/mapFiber.ts +5 -7
- package/_src/Fiber/api/mapIO.ts +21 -21
- package/_src/Fiber/api/zipWith.ts +14 -17
- package/_src/Fiber/definition.ts +17 -16
- package/_src/Fiber.ts +2 -4
- package/_src/FiberDescriptor.ts +1 -8
- package/_src/FiberRef/api/locallyScoped.ts +8 -6
- package/_src/FiberRef/api/locallyScopedWith.ts +5 -7
- package/_src/FiberRef/api.ts +59 -52
- package/_src/FiberRef/unsafe.ts +6 -1
- package/_src/FiberRef.ts +0 -1
- package/_src/FiberRefs/api.ts +69 -14
- package/_src/FiberRefs/definition.ts +15 -7
- package/_src/FiberRefs/join.ts +39 -48
- package/_src/FiberScope/constructors.ts +2 -2
- package/_src/FiberScope/definition.ts +21 -9
- package/_src/FiberStatus/constructors.ts +6 -18
- package/_src/FiberStatus/definition.ts +13 -54
- package/_src/Future/api.ts +67 -53
- package/_src/Hub/api.ts +84 -96
- package/_src/Hub/definition.ts +22 -7
- package/_src/Hub/internal.ts +8 -8
- package/_src/IO/api/acquireRelease.ts +1 -1
- package/_src/IO/api/acquireReleaseExit.ts +1 -1
- package/_src/IO/api/asyncInterrupt.ts +77 -0
- package/_src/IO/api/bracket.ts +1 -1
- package/_src/IO/api/bracketExit.ts +1 -1
- package/_src/IO/api/clockWith.ts +0 -1
- package/_src/IO/api/concurrency.ts +5 -7
- package/_src/IO/api/consoleWith.ts +0 -2
- package/_src/IO/api/core-scope.ts +74 -90
- package/_src/IO/api/delay.ts +8 -0
- package/_src/IO/api/ensuringChildren.ts +8 -7
- package/_src/IO/api/environment.ts +24 -42
- package/_src/IO/api/{foreachC.ts → foreachConcurrent.ts} +30 -18
- package/_src/IO/api/foreachExec.ts +3 -3
- package/_src/IO/api/fork.ts +83 -0
- package/_src/IO/api/forkIn.ts +7 -9
- package/_src/IO/api/fulfill.ts +5 -3
- package/_src/IO/api/interrupt.ts +49 -32
- package/_src/IO/api/onExit.ts +8 -10
- package/_src/IO/api/onTermination.ts +12 -14
- package/_src/IO/api/provideLayer.ts +8 -10
- package/_src/IO/api/provideSomeLayer.ts +5 -14
- package/_src/IO/api/race.ts +19 -21
- package/_src/IO/api/raceFirst.ts +5 -7
- package/_src/IO/api/repeat.ts +3 -5
- package/_src/IO/api/retry.ts +19 -21
- package/_src/IO/api/schedule.ts +20 -21
- package/_src/IO/api/scoped.ts +2 -2
- package/_src/IO/api/sequenceT.ts +7 -1
- package/_src/IO/api/stateful.ts +0 -2
- package/_src/IO/api/supervised.ts +4 -8
- package/_src/IO/api/timeout.ts +10 -16
- package/_src/IO/api/withChildren.ts +2 -4
- package/_src/IO/api/withFinalizer.ts +5 -7
- package/_src/IO/api/withFinalizerExit.ts +6 -5
- package/_src/IO/api/zipConcurrent.ts +69 -0
- package/_src/IO/api.ts +576 -782
- package/_src/IO/definition.ts +150 -137
- package/_src/IO/runtime.ts +53 -64
- package/_src/IO.ts +5 -3
- package/_src/Layer/MemoMap.ts +62 -64
- package/_src/Layer/api.ts +95 -104
- package/_src/Layer/definition.ts +0 -1
- package/_src/LogLevel.ts +24 -16
- package/_src/LogSpan.ts +16 -16
- package/_src/Logger/api.ts +18 -17
- package/_src/Logger/constructors.ts +9 -15
- package/_src/Push/api.ts +702 -0
- package/_src/Push/definition.ts +42 -0
- package/_src/Push/internal.ts +39 -0
- package/_src/Push.ts +5 -0
- package/_src/Queue/api/dimapIO.ts +124 -47
- package/_src/Queue/api/filterInputIO.ts +69 -24
- package/_src/Queue/api/filterOutputIO.ts +77 -17
- package/_src/Queue/api/operations.ts +33 -31
- package/_src/Queue/api/poll.ts +3 -1
- package/_src/Queue/api/takeBetween.ts +29 -30
- package/_src/Queue/api/zipWithIO.ts +47 -36
- package/_src/Queue/constructors.ts +5 -5
- package/_src/Queue/definition.ts +129 -8
- package/_src/Queue/internal.ts +24 -38
- package/_src/Queue/strategy.ts +12 -26
- package/_src/Ref/Atomic.ts +70 -4
- package/_src/Ref/Derived.ts +22 -1
- package/_src/Ref/DerivedAll.ts +26 -2
- package/_src/Ref/Synchronized/api.ts +129 -130
- package/_src/Ref/Synchronized/constructors.ts +1 -1
- package/_src/Ref/Synchronized/definition.ts +21 -14
- package/_src/Ref/Synchronized.ts +5 -0
- package/_src/Ref/api/collect.ts +6 -8
- package/_src/Ref/api/dimap.ts +51 -64
- package/_src/Ref/api/filter.ts +12 -16
- package/_src/Ref/api/get.ts +2 -5
- package/_src/Ref/api/match.ts +8 -7
- package/_src/Ref/api/matchAll.ts +6 -5
- package/_src/Ref/api/modify.ts +61 -165
- package/_src/Ref/api/set.ts +7 -9
- package/_src/Ref/constructors.ts +3 -1
- package/_src/Ref/definition.ts +56 -23
- package/_src/Ref/symbols.ts +29 -0
- package/_src/Ref.ts +2 -0
- package/_src/RefSubject/Atomic.ts +120 -0
- package/_src/RefSubject/Synchronized/api.ts +14 -0
- package/_src/RefSubject/Synchronized/definition.ts +72 -0
- package/_src/RefSubject/api.ts +240 -0
- package/_src/RefSubject/definition.ts +62 -0
- package/_src/RefSubject.ts +5 -0
- package/_src/Reloadable/constructors.ts +2 -2
- package/_src/RuntimeConfig.ts +0 -31
- package/_src/RuntimeFlag.ts +10 -0
- package/_src/RuntimeFlags/Patch.ts +79 -0
- package/_src/RuntimeFlags/RuntimeFlags.ts +112 -0
- package/_src/RuntimeFlags.ts +4 -0
- package/_src/STM/api/core-api.ts +32 -35
- package/_src/STM/api.ts +211 -201
- package/_src/STM/internal/Entry.ts +0 -10
- package/_src/STM/internal/Journal.ts +24 -27
- package/_src/STM.ts +0 -1
- package/_src/Schedule/Decision.ts +10 -8
- package/_src/Schedule/api/driver.ts +2 -6
- package/_src/Schedule/api.ts +471 -474
- package/_src/Schedule/definition.ts +0 -1
- package/_src/Scope/ReleaseMap/api/releaseAll.ts +24 -26
- package/_src/Scope/ReleaseMap/api.ts +77 -74
- package/_src/Scope/ReleaseMap/constructors.ts +1 -1
- package/_src/Scope/api.ts +16 -18
- package/_src/ScopedRef/api.ts +0 -3
- package/_src/ScopedRef/definition.ts +1 -2
- package/_src/Sink/api.ts +326 -354
- package/_src/State/api.ts +12 -8
- package/_src/State/internal.ts +1 -1
- package/_src/Stream/api/zipAllWith.ts +7 -6
- package/_src/Stream/api/zipWith.ts +5 -8
- package/_src/Stream/api/zipWithChunks.ts +7 -6
- package/_src/Stream/api.ts +1086 -1203
- package/_src/Stream/definition.ts +0 -2
- package/_src/Stream/internal/DebounceState.ts +16 -17
- package/_src/Stream/internal/Handoff.ts +32 -36
- package/_src/Stream/internal/SinkEndReason.ts +13 -14
- package/_src/Stream/internal/Take.ts +21 -21
- package/_src/Stream/internal/util.ts +0 -2
- package/_src/Subject/Atomic.ts +28 -0
- package/_src/Subject/api.ts +18 -0
- package/_src/Subject/definition.ts +18 -0
- package/_src/Subject.ts +5 -0
- package/_src/SubscriptionRef.ts +58 -0
- package/_src/Supervisor/api.ts +20 -16
- package/_src/Supervisor/definition.ts +0 -1
- package/_src/SupervisorPatch.ts +10 -6
- package/_src/TExit/definition.ts +0 -8
- package/_src/TFuture/api.ts +23 -17
- package/_src/TFuture/definition.ts +2 -3
- package/_src/TReentrantLock/api.ts +18 -14
- package/_src/TReentrantLock/definition.ts +1 -8
- package/_src/TRef/api.ts +80 -250
- package/_src/TRef/constructors.ts +6 -6
- package/_src/TRef/definition.ts +161 -45
- package/_src/TRef/symbols.ts +19 -0
- package/_src/TRef.ts +1 -0
- package/_src/TSemaphore/api.ts +20 -19
- package/_src/TSemaphore/constructors.ts +7 -0
- package/_src/TSemaphore/definition.ts +1 -1
- package/_src/collection/immutable/Conc/dropUntilIO.ts +19 -21
- package/_src/collection/immutable/Conc/dropWhileIO.ts +21 -23
- package/_src/collection/immutable/Conc/filterIO.ts +15 -17
- package/_src/collection/immutable/Conc/findIO.ts +17 -19
- package/_src/collection/immutable/Conc/mapIO.ts +12 -10
- package/_src/collection/immutable/Conc/takeWhileIO.ts +27 -29
- package/_src/data/Exit/foreachIO.ts +8 -10
- package/_src/global.ts +11 -3
- package/_src/index.ts +10 -1
- package/_src/internal/Hub.ts +17 -27
- package/_src/internal/IsFatal.ts +14 -12
- package/_src/internal/MutableQueue.ts +8 -8
- package/_src/internal/StackTraceBuilder.ts +1 -2
- package/collection/immutable/Conc/dropUntilIO.d.ts +3 -3
- package/collection/immutable/Conc/dropWhileIO.d.ts +3 -3
- package/collection/immutable/Conc/filterIO.d.ts +3 -3
- package/collection/immutable/Conc/findIO.d.ts +2 -2
- package/collection/immutable/Conc/mapIO.d.ts +3 -3
- package/collection/immutable/Conc/takeWhileIO.d.ts +3 -3
- package/data/Exit/foreachIO.d.ts +3 -3
- package/global.d.ts +11 -3
- package/index.d.ts +10 -1
- package/internal/HashedPair.d.ts +2 -2
- package/internal/Hub.d.ts +2 -2
- package/internal/IsFatal.d.ts +3 -3
- package/internal/MutableQueue.d.ts +3 -3
- package/package.json +4 -4
- package/Channel/api/mapOutIOC.d.ts +0 -8
- package/Channel/api/zipC.d.ts +0 -16
- package/Fiber/FiberContext.d.ts +0 -153
- package/Fiber/api/evalOn.d.ts +0 -7
- package/Fiber/api/evalOnIO.d.ts +0 -9
- package/Fiber/api/interruptAsFork.d.ts +0 -8
- package/FiberState/api.d.ts +0 -7
- package/FiberState/constructors.d.ts +0 -22
- package/FiberState/definition.d.ts +0 -38
- package/FiberState.d.ts +0 -3
- package/IO/api/withRuntimeConfig.d.ts +0 -10
- package/IO/api/zipC.d.ts +0 -13
- package/Ref/Atomic/Atomic.d.ts +0 -18
- package/Ref/Atomic/api.d.ts +0 -53
- package/_cjs/Channel/api/mapOutIOC.cjs +0 -63
- package/_cjs/Channel/api/mapOutIOC.cjs.map +0 -1
- package/_cjs/Channel/api/zipC.cjs.map +0 -1
- package/_cjs/Fiber/FiberContext.cjs +0 -1088
- package/_cjs/Fiber/FiberContext.cjs.map +0 -1
- package/_cjs/Fiber/api/evalOn.cjs.map +0 -1
- package/_cjs/Fiber/api/evalOnIO.cjs +0 -31
- package/_cjs/Fiber/api/evalOnIO.cjs.map +0 -1
- package/_cjs/Fiber/api/interruptAsFork.cjs +0 -15
- package/_cjs/Fiber/api/interruptAsFork.cjs.map +0 -1
- package/_cjs/FiberState/api.cjs.map +0 -1
- package/_cjs/FiberState/constructors.cjs.map +0 -1
- package/_cjs/FiberState/definition.cjs.map +0 -1
- package/_cjs/FiberState.cjs.map +0 -1
- package/_cjs/IO/api/foreachC.cjs.map +0 -1
- package/_cjs/IO/api/withRuntimeConfig.cjs.map +0 -1
- package/_cjs/IO/api/zipC.cjs +0 -67
- package/_cjs/IO/api/zipC.cjs.map +0 -1
- package/_cjs/Ref/Atomic/Atomic.cjs +0 -64
- package/_cjs/Ref/Atomic/Atomic.cjs.map +0 -1
- package/_cjs/Ref/Atomic/api.cjs +0 -156
- package/_cjs/Ref/Atomic/api.cjs.map +0 -1
- package/_mjs/Channel/api/mapOutIOC.mjs +0 -32
- package/_mjs/Channel/api/mapOutIOC.mjs.map +0 -1
- package/_mjs/Channel/api/zipC.mjs +0 -30
- package/_mjs/Channel/api/zipC.mjs.map +0 -1
- package/_mjs/Fiber/FiberContext.mjs +0 -1013
- package/_mjs/Fiber/FiberContext.mjs.map +0 -1
- package/_mjs/Fiber/api/evalOn.mjs +0 -17
- package/_mjs/Fiber/api/evalOn.mjs.map +0 -1
- package/_mjs/Fiber/api/evalOnIO.mjs +0 -16
- package/_mjs/Fiber/api/evalOnIO.mjs.map +0 -1
- package/_mjs/Fiber/api/interruptAsFork.mjs +0 -8
- package/_mjs/Fiber/api/interruptAsFork.mjs.map +0 -1
- package/_mjs/FiberState/api.mjs +0 -15
- package/_mjs/FiberState/api.mjs.map +0 -1
- package/_mjs/FiberState/constructors.mjs +0 -26
- package/_mjs/FiberState/constructors.mjs.map +0 -1
- package/_mjs/FiberState/definition.mjs +0 -26
- package/_mjs/FiberState/definition.mjs.map +0 -1
- package/_mjs/FiberState.mjs +0 -5
- package/_mjs/FiberState.mjs.map +0 -1
- package/_mjs/IO/api/foreachC.mjs +0 -118
- package/_mjs/IO/api/foreachC.mjs.map +0 -1
- package/_mjs/IO/api/withRuntimeConfig.mjs +0 -13
- package/_mjs/IO/api/withRuntimeConfig.mjs.map +0 -1
- package/_mjs/IO/api/zipC.mjs +0 -39
- package/_mjs/IO/api/zipC.mjs.map +0 -1
- package/_mjs/Ref/Atomic/Atomic.mjs +0 -47
- package/_mjs/Ref/Atomic/Atomic.mjs.map +0 -1
- package/_mjs/Ref/Atomic/api.mjs +0 -127
- package/_mjs/Ref/Atomic/api.mjs.map +0 -1
- package/_src/Channel/api/mapOutIOC.ts +0 -63
- package/_src/Channel/api/zipC.ts +0 -104
- package/_src/Fiber/FiberContext.ts +0 -1019
- package/_src/Fiber/api/evalOn.ts +0 -17
- package/_src/Fiber/api/evalOnIO.ts +0 -19
- package/_src/Fiber/api/interruptAsFork.ts +0 -7
- package/_src/FiberState/api.ts +0 -12
- package/_src/FiberState/constructors.ts +0 -33
- package/_src/FiberState/definition.ts +0 -44
- package/_src/FiberState.ts +0 -5
- package/_src/IO/api/withRuntimeConfig.ts +0 -20
- package/_src/IO/api/zipC.ts +0 -74
- package/_src/Ref/Atomic/Atomic.ts +0 -56
- package/_src/Ref/Atomic/api.ts +0 -124
package/_src/Stream/api.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { PHub } from "../Hub.js";
|
|
2
2
|
import type { Canceler } from "../IO.js";
|
|
3
|
-
import type { PQueue } from "../Queue.js";
|
|
3
|
+
import type { PDequeue, PEnqueue, PQueue } from "../Queue.js";
|
|
4
4
|
import type { SinkEndReason } from "./internal/SinkEndReason.js";
|
|
5
|
-
import type { Erase } from "@fncts/typelevel/Intersection.js";
|
|
6
5
|
|
|
7
6
|
import { constVoid, identity, tuple } from "@fncts/base/data/function";
|
|
8
7
|
|
|
9
8
|
import { MergeDecision } from "../Channel/internal/MergeDecision.js";
|
|
9
|
+
import { Hub } from "../Hub.js";
|
|
10
10
|
import { Queue } from "../Queue.js";
|
|
11
11
|
import { DEFAULT_CHUNK_SIZE, Stream } from "./definition.js";
|
|
12
12
|
import { DebounceState } from "./internal/DebounceState.js";
|
|
@@ -37,28 +37,27 @@ export function absolve<R, E, E2, A>(self: Stream<R, E, Either<E2, A>>, __tsplus
|
|
|
37
37
|
* Any sink can be used here, but see `Sink.foldWeightedM` and `Sink.foldUntilM` for
|
|
38
38
|
* sinks that cover the common usecases.
|
|
39
39
|
*
|
|
40
|
-
* @tsplus
|
|
40
|
+
* @tsplus pipeable fncts.io.Stream aggregateAsync
|
|
41
41
|
*/
|
|
42
|
-
export function
|
|
43
|
-
stream: Stream<R, E, A
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
): Stream<R | R1, E | E1, B> {
|
|
47
|
-
return stream.aggregateAsyncWithin(sink, Schedule.forever);
|
|
42
|
+
export function aggregateAsync<R1, E1, A1, B>(sink: Sink<R1, E1, A1, A1, B>, __tsplusTrace?: string) {
|
|
43
|
+
return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
44
|
+
return stream.aggregateAsyncWithin(sink, Schedule.forever);
|
|
45
|
+
};
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
49
|
* Like `aggregateAsyncWithinEither`, but only returns the `Right` results.
|
|
52
50
|
*
|
|
53
|
-
* @tsplus
|
|
51
|
+
* @tsplus pipeable fncts.io.Stream aggregateAsyncWithin
|
|
54
52
|
*/
|
|
55
|
-
export function
|
|
56
|
-
stream: Stream<R, E, A>,
|
|
53
|
+
export function aggregateAsyncWithin<R1, E1, A1, B, R2, C>(
|
|
57
54
|
sink: Sink<R1, E1, A1, A1, B>,
|
|
58
55
|
schedule: Schedule<R2, Maybe<B>, C>,
|
|
59
56
|
__tsplusTrace?: string,
|
|
60
|
-
)
|
|
61
|
-
return
|
|
57
|
+
) {
|
|
58
|
+
return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, B> => {
|
|
59
|
+
return stream.aggregateAsyncWithinEither(sink, schedule).filterMap((cb) => cb.match(() => Nothing(), Maybe.just));
|
|
60
|
+
};
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
/**
|
|
@@ -73,131 +72,124 @@ export function aggregateAsyncWithin_<R, E, A extends A1, R1, E1, A1, B, R2, C>(
|
|
|
73
72
|
* Aggregated elements will be fed into the schedule to determine the delays between
|
|
74
73
|
* pulls.
|
|
75
74
|
*
|
|
76
|
-
* @tsplus
|
|
75
|
+
* @tsplus pipeable fncts.io.Stream aggregateAsyncWithinEither
|
|
77
76
|
*/
|
|
78
|
-
export function
|
|
79
|
-
stream: Stream<R, E, A>,
|
|
77
|
+
export function aggregateAsyncWithinEither<R1, E1, A1, B, R2, C>(
|
|
80
78
|
sink: Sink<R1, E1, A1, A1, B>,
|
|
81
79
|
schedule: Schedule<R2, Maybe<B>, C>,
|
|
82
80
|
__tsplusTrace?: string,
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return Stream.fromIO(deps).flatMap(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver, consumed]) => {
|
|
95
|
-
const handoffProducer: Channel<never, E | E1, Conc<A1>, unknown, never, never, any> = Channel.readWithCause(
|
|
96
|
-
(_in: Conc<A1>) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(_in))).apSecond(handoffProducer),
|
|
97
|
-
(cause: Cause<E | E1>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
|
|
98
|
-
(_: any) => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
|
|
81
|
+
) {
|
|
82
|
+
return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, Either<C, B>> => {
|
|
83
|
+
type LocalHandoffSignal = HandoffSignal<E | E1, A1>;
|
|
84
|
+
const deps = IO.sequenceT(
|
|
85
|
+
Handoff<LocalHandoffSignal>(),
|
|
86
|
+
Ref.make<SinkEndReason>(new ScheduleEnd()),
|
|
87
|
+
Ref.make(Conc.empty<A1>()),
|
|
88
|
+
schedule.driver,
|
|
89
|
+
Ref.make(false),
|
|
99
90
|
);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
91
|
+
return Stream.fromIO(deps).flatMap(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver, consumed]) => {
|
|
92
|
+
const handoffProducer: Channel<never, E | E1, Conc<A1>, unknown, never, never, any> = Channel.readWithCause(
|
|
93
|
+
(_in: Conc<A1>) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(_in))).zipRight(handoffProducer),
|
|
94
|
+
(cause: Cause<E | E1>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
|
|
95
|
+
(_: any) => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
|
|
96
|
+
);
|
|
97
|
+
const handoffConsumer: Channel<never, unknown, unknown, unknown, E | E1, Conc<A1>, void> = Channel.unwrap(
|
|
98
|
+
sinkLeftovers.getAndSet(Conc.empty<A>()).flatMap((leftovers) => {
|
|
99
|
+
if (leftovers.isNonEmpty) {
|
|
100
|
+
return consumed.set(true) > IO.succeedNow(Channel.writeNow(leftovers) > handoffConsumer);
|
|
101
|
+
} else {
|
|
102
|
+
return handoff.take.map((signal) =>
|
|
103
|
+
signal.match({
|
|
104
|
+
Emit: ({ els }) => Channel.fromIO(consumed.set(true)) > Channel.writeNow(els) > handoffConsumer,
|
|
105
|
+
Halt: ({ error }) => Channel.failCause(error),
|
|
106
|
+
End: ({ reason }) => {
|
|
107
|
+
if (reason._tag === SinkEndReasonTag.ScheduleEnd) {
|
|
108
|
+
return Channel.unwrap(
|
|
109
|
+
consumed.get.map((p) =>
|
|
110
|
+
p
|
|
111
|
+
? Channel.fromIO(sinkEndReason.set(new ScheduleEnd()))
|
|
112
|
+
: Channel.fromIO(sinkEndReason.set(new ScheduleEnd())) > handoffConsumer,
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
} else {
|
|
116
|
+
return Channel.fromIO(sinkEndReason.set(reason));
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
function timeout(lastB: Maybe<B>, __tsplusTrace?: string): IO<R2, Nothing, C> {
|
|
125
|
+
return scheduleDriver.next(lastB);
|
|
126
|
+
}
|
|
127
|
+
const scheduledAggregator = (
|
|
128
|
+
sinkFiber: Fiber.Runtime<E | E1, readonly [Conc<Conc<A1>>, B]>,
|
|
129
|
+
scheduleFiber: Fiber.Runtime<Nothing, C>,
|
|
130
|
+
): Channel<R1 | R2, unknown, unknown, unknown, E | E1, Conc<Either<C, B>>, any> => {
|
|
131
|
+
const forkSink =
|
|
132
|
+
consumed.set(false) > handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped;
|
|
133
|
+
function handleSide(leftovers: Conc<Conc<A1>>, b: B, c: Maybe<C>, __tsplusTrace?: string) {
|
|
134
|
+
return Channel.unwrap(
|
|
135
|
+
sinkLeftovers.set(leftovers.flatten) >
|
|
136
|
+
sinkEndReason.get.map((reason) =>
|
|
137
|
+
reason.match({
|
|
138
|
+
ScheduleEnd: () =>
|
|
139
|
+
Channel.unwrapScoped(
|
|
140
|
+
Do((Δ) => {
|
|
141
|
+
const consumed_ = Δ(consumed.get);
|
|
142
|
+
const sinkFiber = Δ(forkSink);
|
|
143
|
+
const scheduleFiber = Δ(timeout(Just(b)).forkScoped);
|
|
144
|
+
const toWrite = c.match(
|
|
145
|
+
() => Conc(Either.right(b)),
|
|
146
|
+
(c) => Conc(Either.right(b), Either.left(c)),
|
|
147
|
+
);
|
|
148
|
+
return consumed_
|
|
149
|
+
? Channel.write(toWrite) > scheduledAggregator(sinkFiber, scheduleFiber)
|
|
150
|
+
: scheduledAggregator(sinkFiber, scheduleFiber);
|
|
151
|
+
}),
|
|
117
152
|
),
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
}),
|
|
153
|
+
UpstreamEnd: () =>
|
|
154
|
+
Channel.unwrap(consumed.get.map((p) => (p ? Channel.write(Conc(Either.right(b))) : Channel.unit))),
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
124
157
|
);
|
|
125
158
|
}
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
function timeout(lastB: Maybe<B>, __tsplusTrace?: string): IO<R2, Nothing, C> {
|
|
130
|
-
return scheduleDriver.next(lastB);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const scheduledAggregator = (
|
|
134
|
-
sinkFiber: Fiber.Runtime<E | E1, readonly [Conc<Conc<A1>>, B]>,
|
|
135
|
-
scheduleFiber: Fiber.Runtime<Nothing, C>,
|
|
136
|
-
): Channel<R1 | R2, unknown, unknown, unknown, E | E1, Conc<Either<C, B>>, any> => {
|
|
137
|
-
const forkSink =
|
|
138
|
-
consumed.set(false) > handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped;
|
|
139
|
-
|
|
140
|
-
function handleSide(leftovers: Conc<Conc<A1>>, b: B, c: Maybe<C>, __tsplusTrace?: string) {
|
|
141
159
|
return Channel.unwrap(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
: scheduledAggregator(sinkFiber, scheduleFiber);
|
|
158
|
-
}),
|
|
160
|
+
sinkFiber.join.raceWith(
|
|
161
|
+
scheduleFiber.join,
|
|
162
|
+
(sinkExit, scheduleFiber) =>
|
|
163
|
+
scheduleFiber.interrupt >
|
|
164
|
+
IO.fromExit(sinkExit).map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
|
165
|
+
(scheduleExit, sinkFiber) =>
|
|
166
|
+
IO.fromExit(scheduleExit).matchCauseIO(
|
|
167
|
+
(cause) =>
|
|
168
|
+
cause.failureOrCause.match(
|
|
169
|
+
() =>
|
|
170
|
+
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
|
171
|
+
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
|
172
|
+
(cause) =>
|
|
173
|
+
handoff.offer(HandoffSignal.Halt(cause)).forkDaemon >
|
|
174
|
+
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
|
159
175
|
),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
176
|
+
(c) =>
|
|
177
|
+
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
|
178
|
+
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Just(c))),
|
|
179
|
+
),
|
|
180
|
+
),
|
|
164
181
|
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
(scheduleExit, sinkFiber) =>
|
|
174
|
-
IO.fromExit(scheduleExit).matchCauseIO(
|
|
175
|
-
(cause) =>
|
|
176
|
-
cause.failureOrCause.match(
|
|
177
|
-
() =>
|
|
178
|
-
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
|
179
|
-
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
|
180
|
-
(cause) =>
|
|
181
|
-
handoff.offer(HandoffSignal.Halt(cause)).forkDaemon >
|
|
182
|
-
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
|
183
|
-
),
|
|
184
|
-
(c) =>
|
|
185
|
-
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
|
186
|
-
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Just(c))),
|
|
187
|
-
),
|
|
188
|
-
),
|
|
182
|
+
};
|
|
183
|
+
return Stream.unwrapScoped(
|
|
184
|
+
Do((Δ) => {
|
|
185
|
+
Δ(stream.channel.pipeTo(handoffProducer).runScoped.forkScoped);
|
|
186
|
+
const sinkFiber = Δ(handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped);
|
|
187
|
+
const scheduleFiber = Δ(timeout(Nothing()).forkScoped);
|
|
188
|
+
return new Stream(scheduledAggregator(sinkFiber, scheduleFiber));
|
|
189
|
+
}),
|
|
189
190
|
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return Stream.unwrapScoped(
|
|
193
|
-
Do((Δ) => {
|
|
194
|
-
Δ(stream.channel.pipeTo(handoffProducer).runScoped.forkScoped);
|
|
195
|
-
const sinkFiber = Δ(handoffConsumer.pipeToOrFail(sink.channel).doneCollect.runScoped.forkScoped);
|
|
196
|
-
const scheduleFiber = Δ(timeout(Nothing()).forkScoped);
|
|
197
|
-
return new Stream(scheduledAggregator(sinkFiber, scheduleFiber));
|
|
198
|
-
}),
|
|
199
|
-
);
|
|
200
|
-
});
|
|
191
|
+
});
|
|
192
|
+
};
|
|
201
193
|
}
|
|
202
194
|
|
|
203
195
|
/**
|
|
@@ -205,14 +197,12 @@ export function aggregateAsyncWithinEither_<R, E, A extends A1, R1, E1, A1, B, R
|
|
|
205
197
|
* but keeps only elements from this stream.
|
|
206
198
|
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
|
207
199
|
*
|
|
208
|
-
* @tsplus
|
|
200
|
+
* @tsplus pipeable fncts.io.Stream zipLeft
|
|
209
201
|
*/
|
|
210
|
-
export function
|
|
211
|
-
stream: Stream<R, E, A
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
): Stream<R | R1, E | E1, A> {
|
|
215
|
-
return stream.crossWith(that, (a, _) => a);
|
|
202
|
+
export function zipLeft<R1, E1, A1>(that: Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
|
203
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
204
|
+
return stream.crossWith(that, (a, _) => a);
|
|
205
|
+
};
|
|
216
206
|
}
|
|
217
207
|
|
|
218
208
|
/**
|
|
@@ -220,23 +210,23 @@ export function apFirst_<R, R1, E, E1, A, A1>(
|
|
|
220
210
|
* but keeps only elements from the other stream.
|
|
221
211
|
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
|
222
212
|
*
|
|
223
|
-
* @tsplus
|
|
213
|
+
* @tsplus pipeable fncts.io.Stream zipRight
|
|
224
214
|
*/
|
|
225
|
-
export function
|
|
226
|
-
stream: Stream<R, E, A
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
): Stream<R | R1, E | E1, A1> {
|
|
230
|
-
return stream.crossWith(that, (_, b) => b);
|
|
215
|
+
export function zipRight<R1, E1, A1>(that: Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
|
216
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A1> => {
|
|
217
|
+
return stream.crossWith(that, (_, b) => b);
|
|
218
|
+
};
|
|
231
219
|
}
|
|
232
220
|
|
|
233
221
|
/**
|
|
234
222
|
* Maps the success values of this stream to the specified constant value.
|
|
235
223
|
*
|
|
236
|
-
* @tsplus
|
|
224
|
+
* @tsplus pipeable fncts.io.Stream as
|
|
237
225
|
*/
|
|
238
|
-
export function
|
|
239
|
-
return stream
|
|
226
|
+
export function as<B>(b: Lazy<B>, __tsplusTrace?: string) {
|
|
227
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, B> => {
|
|
228
|
+
return stream.map(() => b());
|
|
229
|
+
};
|
|
240
230
|
}
|
|
241
231
|
|
|
242
232
|
/**
|
|
@@ -357,14 +347,11 @@ export function asyncIO<R, E, A, R1 = R, E1 = E>(
|
|
|
357
347
|
/**
|
|
358
348
|
* Returns a stream whose failure and success channels have been mapped by
|
|
359
349
|
* the specified pair of functions, `f` and `g`.
|
|
350
|
+
*
|
|
351
|
+
* @tsplus pipeable fncts.io.Stream bimap
|
|
360
352
|
*/
|
|
361
|
-
export function
|
|
362
|
-
stream: Stream<R, E, A
|
|
363
|
-
f: (e: E) => E1,
|
|
364
|
-
g: (a: A) => A1,
|
|
365
|
-
__tsplusTrace?: string,
|
|
366
|
-
): Stream<R, E1, A1> {
|
|
367
|
-
return stream.mapError(f).map(g);
|
|
353
|
+
export function bimap<E, E1, A, A1>(f: (e: E) => E1, g: (a: A) => A1, __tsplusTrace?: string) {
|
|
354
|
+
return <R>(stream: Stream<R, E, A>): Stream<R, E1, A1> => stream.mapError(f).map(g);
|
|
368
355
|
}
|
|
369
356
|
|
|
370
357
|
/**
|
|
@@ -373,7 +360,7 @@ export function bimap_<R, E, E1, A, A1>(
|
|
|
373
360
|
*
|
|
374
361
|
* @tsplus static fncts.io.StreamOps acquireRelease
|
|
375
362
|
*/
|
|
376
|
-
export function
|
|
363
|
+
export function acquireRelease<R, E, A, R1>(
|
|
377
364
|
acquire: IO<R, E, A>,
|
|
378
365
|
release: (a: A) => IO<R1, never, unknown>,
|
|
379
366
|
__tsplusTrace?: string,
|
|
@@ -387,7 +374,7 @@ export function acquireRelease_<R, E, A, R1>(
|
|
|
387
374
|
*
|
|
388
375
|
* @tsplus static fncts.io.StreamOps acquireReleaseExit
|
|
389
376
|
*/
|
|
390
|
-
export function
|
|
377
|
+
export function acquireReleaseExit<R, E, A, R1>(
|
|
391
378
|
acquire: IO<R, E, A>,
|
|
392
379
|
release: (a: A, exit: Exit<any, any>) => IO<R1, never, unknown>,
|
|
393
380
|
__tsplusTrace?: string,
|
|
@@ -400,17 +387,14 @@ export function acquireReleaseExit_<R, E, A, R1>(
|
|
|
400
387
|
* The driver stream will only ever advance of the `maximumLag` chunks before the
|
|
401
388
|
* slowest downstream stream.
|
|
402
389
|
*
|
|
403
|
-
* @tsplus
|
|
390
|
+
* @tsplus pipeable fncts.io.Stream broadcast
|
|
404
391
|
*/
|
|
405
|
-
export function
|
|
406
|
-
stream: Stream<R, E, A
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return stream
|
|
412
|
-
.broadcastedQueues(n, maximumLag)
|
|
413
|
-
.map((c) => c.map((hub) => Stream.fromQueueWithShutdown(hub).flattenTake));
|
|
392
|
+
export function broadcast(n: number, maximumLag: number, __tsplusTrace?: string) {
|
|
393
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Conc<Stream<unknown, E, A>>> => {
|
|
394
|
+
return stream
|
|
395
|
+
.broadcastedQueues(n, maximumLag)
|
|
396
|
+
.map((c) => c.map((hub) => Stream.fromQueueWithShutdown(hub).flattenTake));
|
|
397
|
+
};
|
|
414
398
|
}
|
|
415
399
|
|
|
416
400
|
/**
|
|
@@ -418,16 +402,14 @@ export function broadcast_<R, E, A>(
|
|
|
418
402
|
* The driver stream will only ever advance of the `maximumLag` chunks before the
|
|
419
403
|
* slowest downstream stream.
|
|
420
404
|
*
|
|
421
|
-
* @tsplus
|
|
405
|
+
* @tsplus pipeable fncts.io.Stream broadcastDynamic
|
|
422
406
|
*/
|
|
423
|
-
export function
|
|
424
|
-
stream: Stream<R, E, A
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
)
|
|
428
|
-
|
|
429
|
-
.broadcastedQueuesDynamic(maximumLag)
|
|
430
|
-
.map((scoped) => Stream.scoped(scoped).flatMap(Stream.fromQueue).flattenTake);
|
|
407
|
+
export function broadcastDynamic(maximumLag: number, __tsplusTrace?: string) {
|
|
408
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Stream<unknown, E, A>> => {
|
|
409
|
+
return stream
|
|
410
|
+
.broadcastedQueuesDynamic(maximumLag)
|
|
411
|
+
.map((scoped) => Stream.scoped(scoped).flatMap(Stream.fromQueue).flattenTake);
|
|
412
|
+
};
|
|
431
413
|
}
|
|
432
414
|
|
|
433
415
|
/**
|
|
@@ -436,20 +418,17 @@ export function broadcastDynamic_<R, E, A>(
|
|
|
436
418
|
*
|
|
437
419
|
* Queues can unsubscribe from upstream by shutting down.
|
|
438
420
|
*
|
|
439
|
-
* @tsplus
|
|
421
|
+
* @tsplus pipeable fncts.io.Stream broadcastedQueues
|
|
440
422
|
*/
|
|
441
|
-
export function
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
)
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
Δ(stream.runIntoHubScoped(hub).fork);
|
|
451
|
-
return queues;
|
|
452
|
-
});
|
|
423
|
+
export function broadcastedQueues(n: number, maximumLag: number, __tsplusTrace?: string) {
|
|
424
|
+
return <R, E, A>(self: Stream<R, E, A>): IO<R | Scope, never, Conc<Queue.Dequeue<Take<E, A>>>> => {
|
|
425
|
+
return Do((Δ) => {
|
|
426
|
+
const hub = Δ(Hub.makeBounded<Take<E, A>>(maximumLag));
|
|
427
|
+
const queues = Δ(IO.sequenceIterable(Conc.replicate(n, hub.subscribe)));
|
|
428
|
+
Δ(self.runIntoHubScoped(hub).fork);
|
|
429
|
+
return queues;
|
|
430
|
+
});
|
|
431
|
+
};
|
|
453
432
|
}
|
|
454
433
|
|
|
455
434
|
/**
|
|
@@ -458,62 +437,62 @@ export function broadcastedQueues_<R, E, A>(
|
|
|
458
437
|
*
|
|
459
438
|
* Queues can unsubscribe from upstream by shutting down.
|
|
460
439
|
*
|
|
461
|
-
* @tsplus
|
|
440
|
+
* @tsplus pipeable fncts.io.Stream broadcastedQueuesDynamic
|
|
462
441
|
*/
|
|
463
|
-
export function
|
|
464
|
-
stream: Stream<R, E, A
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
): IO<R | Scope, never, IO<Scope, never, Hub.Dequeue<never, never, Take<E, A>>>> {
|
|
468
|
-
return stream.toHub(maximumLag).map((hub) => hub.subscribe);
|
|
442
|
+
export function broadcastedQueuesDynamic(maximumLag: number, __tsplusTrace?: string) {
|
|
443
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, IO<Scope, never, Queue.Dequeue<Take<E, A>>>> => {
|
|
444
|
+
return stream.toHub(maximumLag).map((hub) => hub.subscribe);
|
|
445
|
+
};
|
|
469
446
|
}
|
|
470
447
|
|
|
471
448
|
/**
|
|
472
449
|
* Allows a faster producer to progress independently of a slower consumer by buffering
|
|
473
450
|
* up to `capacity` elements in a queue.
|
|
474
451
|
*
|
|
475
|
-
* @tsplus
|
|
476
|
-
*/
|
|
477
|
-
export function
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
452
|
+
* @tsplus pipeable fncts.io.Stream buffer
|
|
453
|
+
*/
|
|
454
|
+
export function buffer(capacity: number, __tsplusTrace?: string) {
|
|
455
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
456
|
+
const queue = stream.toQueueOfElements(capacity);
|
|
457
|
+
return new Stream(
|
|
458
|
+
Channel.unwrapScoped(
|
|
459
|
+
queue.map((queue) => {
|
|
460
|
+
const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
|
|
461
|
+
queue.take,
|
|
462
|
+
).flatMap((exit: Exit<Maybe<E>, A>) =>
|
|
484
463
|
exit.match(
|
|
485
464
|
(cause) => cause.flipCauseMaybe.match(() => Channel.endNow(undefined), Channel.failCauseNow),
|
|
486
|
-
(value) => Channel.writeNow(Conc.single(value)).
|
|
465
|
+
(value) => Channel.writeNow(Conc.single(value)).zipRight(process),
|
|
487
466
|
),
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
467
|
+
);
|
|
468
|
+
return process;
|
|
469
|
+
}),
|
|
470
|
+
),
|
|
471
|
+
);
|
|
472
|
+
};
|
|
493
473
|
}
|
|
494
474
|
|
|
495
475
|
/**
|
|
496
|
-
* @tsplus
|
|
476
|
+
* @tsplus pipeable fncts.io.Stream bufferChunks
|
|
497
477
|
*/
|
|
498
|
-
export function
|
|
499
|
-
stream: Stream<R, E, A
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(queue.take).flatMap(
|
|
508
|
-
(take: Take<E, A>) =>
|
|
478
|
+
export function bufferChunks(capacity: number, __tsplusTrace?: string) {
|
|
479
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
480
|
+
const queue = stream.toQueue(capacity);
|
|
481
|
+
return new Stream(
|
|
482
|
+
Channel.unwrapScoped(
|
|
483
|
+
queue.map((queue) => {
|
|
484
|
+
const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
|
|
485
|
+
queue.take,
|
|
486
|
+
).flatMap((take: Take<E, A>) =>
|
|
509
487
|
take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
|
|
510
|
-
Channel.writeNow(value).
|
|
488
|
+
Channel.writeNow(value).zipRight(process),
|
|
511
489
|
),
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
490
|
+
);
|
|
491
|
+
return process;
|
|
492
|
+
}),
|
|
493
|
+
),
|
|
494
|
+
);
|
|
495
|
+
};
|
|
517
496
|
}
|
|
518
497
|
|
|
519
498
|
/**
|
|
@@ -524,17 +503,15 @@ export function bufferChunks_<R, E, A>(
|
|
|
524
503
|
*/
|
|
525
504
|
export function bufferUnbounded<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?: string): Stream<R, E, A> {
|
|
526
505
|
const queue = stream.toQueueUnbounded;
|
|
527
|
-
|
|
528
506
|
return new Stream(
|
|
529
507
|
Channel.unwrapScoped(
|
|
530
508
|
queue.map((queue) => {
|
|
531
509
|
const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(queue.take).flatMap(
|
|
532
510
|
(take) =>
|
|
533
511
|
take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
|
|
534
|
-
Channel.writeNow(value).
|
|
512
|
+
Channel.writeNow(value).zipRight(process),
|
|
535
513
|
),
|
|
536
514
|
);
|
|
537
|
-
|
|
538
515
|
return process;
|
|
539
516
|
}),
|
|
540
517
|
),
|
|
@@ -577,9 +554,9 @@ function bufferSignalConsumer<R, E, A>(
|
|
|
577
554
|
): Channel<R, unknown, unknown, unknown, E, Conc<A>, void> {
|
|
578
555
|
const process: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(queue.take).flatMap(
|
|
579
556
|
([take, promise]) =>
|
|
580
|
-
Channel.fromIO(promise.succeed(undefined)).
|
|
557
|
+
Channel.fromIO(promise.succeed(undefined)).zipRight(
|
|
581
558
|
take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
|
|
582
|
-
Channel.writeNow(value).
|
|
559
|
+
Channel.writeNow(value).zipRight(process),
|
|
583
560
|
),
|
|
584
561
|
),
|
|
585
562
|
);
|
|
@@ -590,14 +567,12 @@ function bufferSignalConsumer<R, E, A>(
|
|
|
590
567
|
* Switches over to the stream produced by the provided function in case this one
|
|
591
568
|
* fails with a typed error.
|
|
592
569
|
*
|
|
593
|
-
* @tsplus
|
|
570
|
+
* @tsplus pipeable fncts.io.Stream catchAll
|
|
594
571
|
*/
|
|
595
|
-
export function
|
|
596
|
-
stream: Stream<R, E, A
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
): Stream<R | R1, E1, A | A1> {
|
|
600
|
-
return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
|
|
572
|
+
export function catchAll<R1, E, E1, A1>(f: (e: E) => Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
|
573
|
+
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
|
|
574
|
+
return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
|
|
575
|
+
};
|
|
601
576
|
}
|
|
602
577
|
|
|
603
578
|
/**
|
|
@@ -605,31 +580,27 @@ export function catchAll_<R, R1, E, E1, A, A1>(
|
|
|
605
580
|
* fails. Allows recovery from all causes of failure, including interruption if the
|
|
606
581
|
* stream is uninterruptible.
|
|
607
582
|
*
|
|
608
|
-
* @tsplus
|
|
583
|
+
* @tsplus pipeable fncts.io.Stream catchAllCause
|
|
609
584
|
*/
|
|
610
|
-
export function
|
|
611
|
-
stream: Stream<R, E, A
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
)
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
);
|
|
618
|
-
return new Stream(channel);
|
|
585
|
+
export function catchAllCause<R1, E, E1, A1>(f: (cause: Cause<E>) => Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
|
586
|
+
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
|
|
587
|
+
const channel: Channel<R | R1, unknown, unknown, unknown, E1, Conc<A | A1>, unknown> = stream.channel.catchAllCause(
|
|
588
|
+
(cause) => f(cause).channel,
|
|
589
|
+
);
|
|
590
|
+
return new Stream(channel);
|
|
591
|
+
};
|
|
619
592
|
}
|
|
620
593
|
|
|
621
594
|
/**
|
|
622
595
|
* Switches over to the stream produced by the provided function in case this one
|
|
623
596
|
* fails with some typed error.
|
|
624
597
|
*
|
|
625
|
-
* @tsplus
|
|
598
|
+
* @tsplus pipeable fncts.io.Stream catchJust
|
|
626
599
|
*/
|
|
627
|
-
export function
|
|
628
|
-
stream: Stream<R, E, A
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
): Stream<R | R1, E | E1, A | A1> {
|
|
632
|
-
return stream.catchAll((e) => pf(e).getOrElse(Stream.failNow(e)));
|
|
600
|
+
export function catchJust<R1, E, E1, A1>(pf: (e: E) => Maybe<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
|
|
601
|
+
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A | A1> => {
|
|
602
|
+
return stream.catchAll((e) => pf(e).getOrElse(Stream.failNow(e)));
|
|
603
|
+
};
|
|
633
604
|
}
|
|
634
605
|
|
|
635
606
|
/**
|
|
@@ -637,36 +608,32 @@ export function catchJust_<R, R1, E, E1, A, A1>(
|
|
|
637
608
|
* fails with some errors. Allows recovery from all causes of failure, including interruption if the
|
|
638
609
|
* stream is uninterruptible.
|
|
639
610
|
*
|
|
640
|
-
* @tsplus
|
|
611
|
+
* @tsplus pipeable fncts.io.Stream catchJustCause
|
|
641
612
|
*/
|
|
642
|
-
export function
|
|
643
|
-
stream: Stream<R, E, A
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
): Stream<R | R1, E | E1, A | A1> {
|
|
647
|
-
return stream.catchAllCause((cause) => pf(cause).getOrElse(Stream.failCauseNow(cause)));
|
|
613
|
+
export function catchJustCause<R1, E, E1, A1>(pf: (e: Cause<E>) => Maybe<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
|
|
614
|
+
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A | A1> => {
|
|
615
|
+
return stream.catchAllCause((cause) => pf(cause).getOrElse(Stream.failCauseNow(cause)));
|
|
616
|
+
};
|
|
648
617
|
}
|
|
649
618
|
|
|
650
619
|
/**
|
|
651
620
|
* Returns a stream made of the concatenation in strict order of all the streams
|
|
652
621
|
* produced by passing each element of this stream to `f`
|
|
653
622
|
*
|
|
654
|
-
* @tsplus
|
|
623
|
+
* @tsplus pipeable fncts.io.Stream flatMap
|
|
655
624
|
*/
|
|
656
|
-
export function
|
|
657
|
-
stream: Stream<R, E, A
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
),
|
|
669
|
-
);
|
|
625
|
+
export function flatMap<A, R1, E1, B>(f: (a: A) => Stream<R1, E1, B>, __tsplusTrace?: string) {
|
|
626
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
627
|
+
return new Stream(
|
|
628
|
+
stream.channel.concatMap((as) =>
|
|
629
|
+
as
|
|
630
|
+
.map((a) => f(a).channel)
|
|
631
|
+
.foldLeft(Channel.unit as Channel<R1, unknown, unknown, unknown, E1, Conc<B>, unknown>, (s, a) =>
|
|
632
|
+
s.flatMap(() => a),
|
|
633
|
+
),
|
|
634
|
+
),
|
|
635
|
+
);
|
|
636
|
+
};
|
|
670
637
|
}
|
|
671
638
|
|
|
672
639
|
/**
|
|
@@ -682,14 +649,15 @@ export function chunks<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?: string)
|
|
|
682
649
|
* Performs the specified stream transformation with the chunk structure of
|
|
683
650
|
* the stream exposed.
|
|
684
651
|
*
|
|
685
|
-
* @tsplus
|
|
652
|
+
* @tsplus pipeable fncts.io.Stream chunksWith
|
|
686
653
|
*/
|
|
687
654
|
export function chunksWith<R, E, A, R1, E1, B>(
|
|
688
|
-
self: Stream<R, E, A>,
|
|
689
655
|
f: (_: Stream<R, E, Conc<A>>) => Stream<R1, E1, Conc<B>>,
|
|
690
656
|
__tsplusTrace?: string,
|
|
691
|
-
)
|
|
692
|
-
return
|
|
657
|
+
) {
|
|
658
|
+
return (self: Stream<R, E, A>): Stream<R1, E1, B> => {
|
|
659
|
+
return f(self.chunks).flattenChunks;
|
|
660
|
+
};
|
|
693
661
|
}
|
|
694
662
|
|
|
695
663
|
function changesWithWriter<R, E, A>(
|
|
@@ -705,7 +673,7 @@ function changesWithWriter<R, E, A>(
|
|
|
705
673
|
(o) => (f(o, o1) ? [Just(o1), os] : [Just(o1), os.append(o1)]),
|
|
706
674
|
),
|
|
707
675
|
);
|
|
708
|
-
return Channel.writeNow(newChunk).
|
|
676
|
+
return Channel.writeNow(newChunk).zipRight(changesWithWriter(f, newLast));
|
|
709
677
|
},
|
|
710
678
|
Channel.failCauseNow,
|
|
711
679
|
() => Channel.unit,
|
|
@@ -717,47 +685,41 @@ function changesWithWriter<R, E, A>(
|
|
|
717
685
|
* previous element emitted, using the specified function to determine
|
|
718
686
|
* whether two elements are equal.
|
|
719
687
|
*
|
|
720
|
-
* @tsplus
|
|
688
|
+
* @tsplus pipeable fncts.io.Stream changesWith
|
|
721
689
|
*/
|
|
722
|
-
export function
|
|
723
|
-
stream: Stream<R, E, A
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
): Stream<R, E, A> {
|
|
727
|
-
return new Stream(stream.channel.pipeTo(changesWithWriter<R, E, A>(f, Nothing())));
|
|
690
|
+
export function changesWith<A>(f: (x: A, y: A) => boolean, __tsplusTrace?: string) {
|
|
691
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
692
|
+
return new Stream(stream.channel.pipeTo(changesWithWriter<R, E, A>(f, Nothing())));
|
|
693
|
+
};
|
|
728
694
|
}
|
|
729
695
|
|
|
730
696
|
/**
|
|
731
697
|
* Transforms all elements of the stream for as long as the specified partial function is defined.
|
|
732
698
|
*
|
|
733
|
-
* @tsplus
|
|
699
|
+
* @tsplus pipeable fncts.io.Stream collectWhile
|
|
734
700
|
*/
|
|
735
|
-
export function
|
|
736
|
-
stream: Stream<R, E, A
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
Channel.succeedNow,
|
|
752
|
-
);
|
|
753
|
-
|
|
754
|
-
return new Stream(stream.channel.pipeTo(loop));
|
|
701
|
+
export function collectWhile<A, A1>(pf: (a: A) => Maybe<A1>, __tsplusTrace?: string) {
|
|
702
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A1> => {
|
|
703
|
+
const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A1>, any> = Channel.readWith(
|
|
704
|
+
(inp) => {
|
|
705
|
+
const mapped = inp.collectWhile(pf);
|
|
706
|
+
if (mapped.length === inp.length) {
|
|
707
|
+
return Channel.writeNow(mapped).zipRight(loop);
|
|
708
|
+
} else {
|
|
709
|
+
return Channel.writeNow(mapped);
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
Channel.failNow,
|
|
713
|
+
Channel.succeedNow,
|
|
714
|
+
);
|
|
715
|
+
return new Stream(stream.channel.pipeTo(loop));
|
|
716
|
+
};
|
|
755
717
|
}
|
|
756
718
|
|
|
757
719
|
/**
|
|
758
720
|
* Effectfully transforms all elements of the stream for as long as the specified partial function is defined.
|
|
759
721
|
*/
|
|
760
|
-
export function
|
|
722
|
+
export function collectWhileIO<R, E, A, R1, E1, B>(
|
|
761
723
|
stream: Stream<R, E, A>,
|
|
762
724
|
pf: (a: A) => Maybe<IO<R1, E1, B>>,
|
|
763
725
|
__tsplusTrace?: string,
|
|
@@ -792,11 +754,11 @@ function combineProducer<Err, Elem>(
|
|
|
792
754
|
latch: Handoff<void>,
|
|
793
755
|
__tsplusTrace?: string,
|
|
794
756
|
): Channel<never, Err, Elem, unknown, never, never, any> {
|
|
795
|
-
return Channel.fromIO(latch.take).
|
|
757
|
+
return Channel.fromIO(latch.take).zipRight(
|
|
796
758
|
Channel.readWithCause(
|
|
797
|
-
(value) => Channel.fromIO(handoff.offer(Exit.succeed(value))).
|
|
759
|
+
(value) => Channel.fromIO(handoff.offer(Exit.succeed(value))).zipRight(combineProducer(handoff, latch)),
|
|
798
760
|
(cause) => Channel.fromIO(handoff.offer(Exit.failCause(cause.map(Maybe.just)))),
|
|
799
|
-
() => Channel.fromIO(handoff.offer(Exit.fail(Nothing()))).
|
|
761
|
+
() => Channel.fromIO(handoff.offer(Exit.fail(Nothing()))).zipRight(combineProducer(handoff, latch)),
|
|
800
762
|
),
|
|
801
763
|
);
|
|
802
764
|
}
|
|
@@ -809,10 +771,9 @@ function combineProducer<Err, Elem>(
|
|
|
809
771
|
*
|
|
810
772
|
* Where possible, prefer `Stream#combineChunks` for a more efficient implementation.
|
|
811
773
|
*
|
|
812
|
-
* @tsplus
|
|
774
|
+
* @tsplus pipeable fncts.io.Stream combine
|
|
813
775
|
*/
|
|
814
|
-
export function
|
|
815
|
-
stream: Stream<R, E, A>,
|
|
776
|
+
export function combine<R, E, A, R1, E1, A1, S, R2, A2>(
|
|
816
777
|
that: Stream<R1, E1, A1>,
|
|
817
778
|
s: S,
|
|
818
779
|
f: (
|
|
@@ -821,25 +782,27 @@ export function combine_<R, E, A, R1, E1, A1, S, R2, A2>(
|
|
|
821
782
|
eff2: IO<R1, Maybe<E1>, A1>,
|
|
822
783
|
) => IO<R2, never, Exit<Maybe<E | E1>, readonly [A2, S]>>,
|
|
823
784
|
__tsplusTrace?: string,
|
|
824
|
-
)
|
|
825
|
-
return
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
.
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
785
|
+
) {
|
|
786
|
+
return (stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, A2> => {
|
|
787
|
+
return new Stream(
|
|
788
|
+
Channel.unwrapScoped(
|
|
789
|
+
Do((Δ) => {
|
|
790
|
+
const left = Δ(Handoff<Exit<Maybe<E>, A>>());
|
|
791
|
+
const right = Δ(Handoff<Exit<Maybe<E1>, A1>>());
|
|
792
|
+
const latchL = Δ(Handoff<void>());
|
|
793
|
+
const latchR = Δ(Handoff<void>());
|
|
794
|
+
Δ(stream.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(left, latchL)).runScoped.fork);
|
|
795
|
+
Δ(that.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(right, latchR)).runScoped.fork);
|
|
796
|
+
return tuple(left, right, latchL, latchR);
|
|
797
|
+
}).map(([left, right, latchL, latchR]) => {
|
|
798
|
+
const pullLeft = latchL.offer(undefined).zipRight(left.take).flatMap(IO.fromExitNow);
|
|
799
|
+
const pullRight = latchR.offer(undefined).zipRight(right.take).flatMap(IO.fromExitNow);
|
|
800
|
+
return Stream.unfoldIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExitNow(exit).optional))
|
|
801
|
+
.channel;
|
|
802
|
+
}),
|
|
803
|
+
),
|
|
804
|
+
);
|
|
805
|
+
};
|
|
843
806
|
}
|
|
844
807
|
|
|
845
808
|
function combineChunksProducer<Err, Elem>(
|
|
@@ -847,11 +810,11 @@ function combineChunksProducer<Err, Elem>(
|
|
|
847
810
|
latch: Handoff<void>,
|
|
848
811
|
__tsplusTrace?: string,
|
|
849
812
|
): Channel<never, Err, Conc<Elem>, unknown, never, never, any> {
|
|
850
|
-
return Channel.fromIO(latch.take).
|
|
813
|
+
return Channel.fromIO(latch.take).zipRight(
|
|
851
814
|
Channel.readWithCause(
|
|
852
|
-
(chunk) => Channel.fromIO(handoff.offer(Take.chunk(chunk))).
|
|
815
|
+
(chunk) => Channel.fromIO(handoff.offer(Take.chunk(chunk))).zipRight(combineChunksProducer(handoff, latch)),
|
|
853
816
|
(cause) => Channel.fromIO(handoff.offer(Take.failCause(cause))),
|
|
854
|
-
() => Channel.fromIO(handoff.offer(Take.end)).
|
|
817
|
+
() => Channel.fromIO(handoff.offer(Take.end)).zipRight(combineChunksProducer(handoff, latch)),
|
|
855
818
|
),
|
|
856
819
|
);
|
|
857
820
|
}
|
|
@@ -862,10 +825,9 @@ function combineChunksProducer<Err, Elem>(
|
|
|
862
825
|
* it to the destination stream. `f` can maintain some internal state to control
|
|
863
826
|
* the combining process, with the initial state being specified by `s`.
|
|
864
827
|
*
|
|
865
|
-
* @tsplus
|
|
828
|
+
* @tsplus pipeable fncts.io.Stream combineChunks
|
|
866
829
|
*/
|
|
867
|
-
export function
|
|
868
|
-
stream: Stream<R, E, A>,
|
|
830
|
+
export function combineChunks<R, E, A, R1, E1, A1, S, R2, A2>(
|
|
869
831
|
that: Stream<R1, E1, A1>,
|
|
870
832
|
s: S,
|
|
871
833
|
f: (
|
|
@@ -874,61 +836,59 @@ export function combineChunks_<R, E, A, R1, E1, A1, S, R2, A2>(
|
|
|
874
836
|
r: IO<R1, Maybe<E1>, Conc<A1>>,
|
|
875
837
|
) => IO<R2, never, Exit<Maybe<E | E1>, readonly [Conc<A2>, S]>>,
|
|
876
838
|
__tsplusTrace?: string,
|
|
877
|
-
)
|
|
878
|
-
return
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
.
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
839
|
+
) {
|
|
840
|
+
return (stream: Stream<R, E, A>): Stream<R1 | R | R2, E | E1, A2> => {
|
|
841
|
+
return new Stream(
|
|
842
|
+
Channel.unwrapScoped(
|
|
843
|
+
Do((Δ) => {
|
|
844
|
+
const left = Δ(Handoff<Take<E, A>>());
|
|
845
|
+
const right = Δ(Handoff<Take<E1, A1>>());
|
|
846
|
+
const latchL = Δ(Handoff<void>());
|
|
847
|
+
const latchR = Δ(Handoff<void>());
|
|
848
|
+
Δ(stream.channel.pipeTo(combineChunksProducer(left, latchL)).runScoped.fork);
|
|
849
|
+
Δ(that.channel.pipeTo(combineChunksProducer(right, latchR)).runScoped.fork);
|
|
850
|
+
return tuple(left, right, latchL, latchR);
|
|
851
|
+
}).map(([left, right, latchL, latchR]) => {
|
|
852
|
+
const pullLeft = latchL
|
|
853
|
+
.offer(undefined)
|
|
854
|
+
.zipRight(left.take)
|
|
855
|
+
.flatMap((take) => take.done);
|
|
856
|
+
const pullRight = latchR
|
|
857
|
+
.offer(undefined)
|
|
858
|
+
.zipRight(right.take)
|
|
859
|
+
.flatMap((take) => take.done);
|
|
860
|
+
return Stream.unfoldChunkIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExit(exit).optional))
|
|
861
|
+
.channel;
|
|
862
|
+
}),
|
|
863
|
+
),
|
|
864
|
+
);
|
|
865
|
+
};
|
|
902
866
|
}
|
|
903
867
|
|
|
904
868
|
/**
|
|
905
869
|
* Concatenates the specified stream with this stream, resulting in a stream
|
|
906
870
|
* that emits the elements from this stream and then the elements from the specified stream.
|
|
907
871
|
*
|
|
908
|
-
* @tsplus
|
|
872
|
+
* @tsplus pipeable fncts.io.Stream concat
|
|
909
873
|
*/
|
|
910
|
-
export function
|
|
911
|
-
stream: Stream<R, E, A
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
): Stream<R | R1, E | E1, A | A1> {
|
|
915
|
-
return new Stream<R | R1, E | E1, A | A1>(stream.channel.apSecond(that.channel));
|
|
874
|
+
export function concat<R1, E1, A1>(that: Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
|
875
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A | A1> => {
|
|
876
|
+
return new Stream<R | R1, E | E1, A | A1>(stream.channel.zipRight(that.channel));
|
|
877
|
+
};
|
|
916
878
|
}
|
|
917
879
|
|
|
918
880
|
/**
|
|
919
881
|
* Composes this stream with the specified stream to create a cartesian product of elements.
|
|
920
882
|
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
|
921
883
|
*
|
|
922
|
-
* @tsplus
|
|
884
|
+
* @tsplus pipeable fncts.io.Stream cross
|
|
923
885
|
*/
|
|
924
|
-
export function
|
|
925
|
-
stream: Stream<R, E, A
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
)
|
|
929
|
-
|
|
930
|
-
stream.channel.concatMap((as) => that.channel.mapOut((bs) => as.flatMap((a) => bs.map((b) => tuple(a, b))))),
|
|
931
|
-
);
|
|
886
|
+
export function cross<R1, E1, B>(that: Stream<R1, E1, B>, __tsplusTrace?: string) {
|
|
887
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, readonly [A, B]> => {
|
|
888
|
+
return new Stream(
|
|
889
|
+
stream.channel.concatMap((as) => that.channel.mapOut((bs) => as.flatMap((a) => bs.map((b) => tuple(a, b))))),
|
|
890
|
+
);
|
|
891
|
+
};
|
|
932
892
|
}
|
|
933
893
|
|
|
934
894
|
/**
|
|
@@ -936,107 +896,99 @@ export function cross_<R, E, A, R1, E1, B>(
|
|
|
936
896
|
* with a specified function.
|
|
937
897
|
* The `fb` stream would be run multiple times, for every element in the `fa` stream.
|
|
938
898
|
*
|
|
939
|
-
* @tsplus
|
|
899
|
+
* @tsplus pipeable fncts.io.Stream crossWith
|
|
940
900
|
*/
|
|
941
|
-
export function
|
|
942
|
-
fa: Stream<R, E, A
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
__tsplusTrace?: string,
|
|
946
|
-
): Stream<R | R1, E | E1, C> {
|
|
947
|
-
return fa.flatMap((a) => fb.map((b) => f(a, b)));
|
|
901
|
+
export function crossWith<A, R1, E1, B, C>(fb: Stream<R1, E1, B>, f: (a: A, b: B) => C, __tsplusTrace?: string) {
|
|
902
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, C> => {
|
|
903
|
+
return fa.flatMap((a) => fb.map((b) => f(a, b)));
|
|
904
|
+
};
|
|
948
905
|
}
|
|
949
906
|
|
|
950
907
|
/**
|
|
951
908
|
* Provides some of the environment required to run this effect,
|
|
952
909
|
* leaving the remainder `R0`.
|
|
953
910
|
*
|
|
954
|
-
* @tsplus
|
|
911
|
+
* @tsplus pipeable fncts.io.Stream contramapEnvironment
|
|
955
912
|
*/
|
|
956
|
-
export function
|
|
957
|
-
ra: Stream<R, E, A
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
): Stream<R0, E, A> {
|
|
961
|
-
return Stream.environment<R0>().flatMap((r0) => ra.provideEnvironment(f(r0)));
|
|
913
|
+
export function contramapEnvironment<R, R0>(f: (r0: Environment<R0>) => Environment<R>, __tsplusTrace?: string) {
|
|
914
|
+
return <E, A>(ra: Stream<R, E, A>): Stream<R0, E, A> => {
|
|
915
|
+
return Stream.environment<R0>().flatMap((r0) => ra.provideEnvironment(f(r0)));
|
|
916
|
+
};
|
|
962
917
|
}
|
|
963
918
|
|
|
964
919
|
/**
|
|
965
|
-
* @tsplus
|
|
920
|
+
* @tsplus pipeable fncts.io.Stream debounce
|
|
966
921
|
*/
|
|
967
|
-
export function
|
|
968
|
-
stream: Stream<R, E, A
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
)
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
),
|
|
985
|
-
(cause: Cause<E>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
|
|
986
|
-
() => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
|
|
987
|
-
);
|
|
988
|
-
function consumer(
|
|
989
|
-
state: DebounceState<E, A>,
|
|
990
|
-
__tsplusTrace?: string,
|
|
991
|
-
): Channel<R, unknown, unknown, unknown, E, Conc<A>, unknown> {
|
|
992
|
-
return Channel.unwrap(
|
|
993
|
-
state.match({
|
|
994
|
-
NotStarted: () =>
|
|
995
|
-
handoff.take.map((signal) =>
|
|
996
|
-
signal.match({
|
|
997
|
-
Emit: ({ els }) => Channel.unwrap(enqueue(els)),
|
|
998
|
-
Halt: ({ error }) => Channel.failCauseNow(error),
|
|
999
|
-
End: () => Channel.unit,
|
|
1000
|
-
}),
|
|
1001
|
-
),
|
|
1002
|
-
Current: ({ fiber }) =>
|
|
1003
|
-
fiber.join.map((signal) =>
|
|
1004
|
-
signal.match({
|
|
1005
|
-
Emit: ({ els }) => Channel.unwrap(enqueue(els)),
|
|
1006
|
-
Halt: ({ error }) => Channel.failCauseNow(error),
|
|
1007
|
-
End: () => Channel.unit,
|
|
1008
|
-
}),
|
|
1009
|
-
),
|
|
1010
|
-
Previous: ({ fiber }) =>
|
|
1011
|
-
fiber.join.raceWith(
|
|
1012
|
-
handoff.take,
|
|
1013
|
-
(ex, current) =>
|
|
1014
|
-
ex.match(
|
|
1015
|
-
(cause) => current.interrupt.as(Channel.failCauseNow(cause)),
|
|
1016
|
-
(chunk) =>
|
|
1017
|
-
IO.succeedNow(Channel.writeNow(chunk).apSecond(consumer(DebounceState.Current(current)))),
|
|
1018
|
-
),
|
|
1019
|
-
(ex, previous) =>
|
|
1020
|
-
ex.match(
|
|
1021
|
-
(cause) => previous.interrupt.as(Channel.failCauseNow(cause)),
|
|
1022
|
-
(signal) =>
|
|
1023
|
-
signal.match({
|
|
1024
|
-
Emit: ({ els }) => previous.interrupt.apSecond(enqueue(els)),
|
|
1025
|
-
Halt: ({ error }) => previous.interrupt.as(Channel.failCauseNow(error)),
|
|
1026
|
-
End: () => previous.join.map((chunk) => Channel.writeNow(chunk).apSecond(Channel.unit)),
|
|
1027
|
-
}),
|
|
1028
|
-
),
|
|
1029
|
-
),
|
|
1030
|
-
}),
|
|
922
|
+
export function debounce(duration: Lazy<Duration>, __tsplusTrace?: string) {
|
|
923
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
924
|
+
return Stream.unwrap(
|
|
925
|
+
IO.transplant((grafter) =>
|
|
926
|
+
Do((Δ) => {
|
|
927
|
+
const handoff = Δ(Handoff<HandoffSignal<E, A>>());
|
|
928
|
+
function enqueue(last: Conc<A>, __tsplusTrace?: string) {
|
|
929
|
+
return grafter(Clock.sleep(duration).as(last).fork).map((f) => consumer(DebounceState.Previous(f)));
|
|
930
|
+
}
|
|
931
|
+
const producer: Channel<R, E, Conc<A>, unknown, E, never, unknown> = Channel.readWithCause(
|
|
932
|
+
(inp: Conc<A>) =>
|
|
933
|
+
inp.last.match(
|
|
934
|
+
() => producer,
|
|
935
|
+
(last) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(Conc.single(last)))).zipRight(producer),
|
|
936
|
+
),
|
|
937
|
+
(cause: Cause<E>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
|
|
938
|
+
() => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
|
|
1031
939
|
);
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
940
|
+
function consumer(
|
|
941
|
+
state: DebounceState<E, A>,
|
|
942
|
+
__tsplusTrace?: string,
|
|
943
|
+
): Channel<R, unknown, unknown, unknown, E, Conc<A>, unknown> {
|
|
944
|
+
return Channel.unwrap(
|
|
945
|
+
state.match({
|
|
946
|
+
NotStarted: () =>
|
|
947
|
+
handoff.take.map((signal) =>
|
|
948
|
+
signal.match({
|
|
949
|
+
Emit: ({ els }) => Channel.unwrap(enqueue(els)),
|
|
950
|
+
Halt: ({ error }) => Channel.failCauseNow(error),
|
|
951
|
+
End: () => Channel.unit,
|
|
952
|
+
}),
|
|
953
|
+
),
|
|
954
|
+
Current: ({ fiber }) =>
|
|
955
|
+
fiber.join.map((signal) =>
|
|
956
|
+
signal.match({
|
|
957
|
+
Emit: ({ els }) => Channel.unwrap(enqueue(els)),
|
|
958
|
+
Halt: ({ error }) => Channel.failCauseNow(error),
|
|
959
|
+
End: () => Channel.unit,
|
|
960
|
+
}),
|
|
961
|
+
),
|
|
962
|
+
Previous: ({ fiber }) =>
|
|
963
|
+
fiber.join.raceWith(
|
|
964
|
+
handoff.take,
|
|
965
|
+
(ex, current) =>
|
|
966
|
+
ex.match(
|
|
967
|
+
(cause) => current.interrupt.as(Channel.failCauseNow(cause)),
|
|
968
|
+
(chunk) =>
|
|
969
|
+
IO.succeedNow(Channel.writeNow(chunk).zipRight(consumer(DebounceState.Current(current)))),
|
|
970
|
+
),
|
|
971
|
+
(ex, previous) =>
|
|
972
|
+
ex.match(
|
|
973
|
+
(cause) => previous.interrupt.as(Channel.failCauseNow(cause)),
|
|
974
|
+
(signal) =>
|
|
975
|
+
signal.match({
|
|
976
|
+
Emit: ({ els }) => previous.interrupt.zipRight(enqueue(els)),
|
|
977
|
+
Halt: ({ error }) => previous.interrupt.as(Channel.failCauseNow(error)),
|
|
978
|
+
End: () => previous.join.map((chunk) => Channel.writeNow(chunk).zipRight(Channel.unit)),
|
|
979
|
+
}),
|
|
980
|
+
),
|
|
981
|
+
),
|
|
982
|
+
}),
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
return Stream.scoped(stream.channel.pipeTo(producer).runScoped.fork).zipRight(
|
|
986
|
+
new Stream(consumer(DebounceState.NotStarted)),
|
|
987
|
+
);
|
|
988
|
+
}),
|
|
989
|
+
),
|
|
990
|
+
);
|
|
991
|
+
};
|
|
1040
992
|
}
|
|
1041
993
|
|
|
1042
994
|
function defaultIfEmptyWriter<R, E, A, R1, E1, B>(
|
|
@@ -1045,7 +997,7 @@ function defaultIfEmptyWriter<R, E, A, R1, E1, B>(
|
|
|
1045
997
|
): Channel<R | R1, E, Conc<A>, unknown, E | E1, Conc<A | B>, unknown> {
|
|
1046
998
|
return Channel.readWith(
|
|
1047
999
|
(i: Conc<A>) =>
|
|
1048
|
-
i.isEmpty ? defaultIfEmptyWriter(fb) : Channel.writeNow(i).
|
|
1000
|
+
i.isEmpty ? defaultIfEmptyWriter(fb) : Channel.writeNow(i).zipRight(Channel.id<E, Conc<A>, unknown>()),
|
|
1049
1001
|
Channel.failNow,
|
|
1050
1002
|
() => fb.channel,
|
|
1051
1003
|
);
|
|
@@ -1054,14 +1006,12 @@ function defaultIfEmptyWriter<R, E, A, R1, E1, B>(
|
|
|
1054
1006
|
/**
|
|
1055
1007
|
* Switches to the provided stream in case this one is empty.
|
|
1056
1008
|
*
|
|
1057
|
-
* @tsplus
|
|
1009
|
+
* @tsplus pipeable fncts.io.Stream defaultIfEmpty
|
|
1058
1010
|
*/
|
|
1059
|
-
export function
|
|
1060
|
-
fa: Stream<R, E, A
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
): Stream<R | R1, E | E1, A | B> {
|
|
1064
|
-
return new Stream(fa.channel.pipeTo(defaultIfEmptyWriter(fb)));
|
|
1011
|
+
export function defaultIfEmpty<R1, E1, B>(fb: Stream<R1, E1, B>, __tsplusTrace?: string) {
|
|
1012
|
+
return <R, E, A>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, A | B> => {
|
|
1013
|
+
return new Stream(fa.channel.pipeTo(defaultIfEmptyWriter(fb)));
|
|
1014
|
+
};
|
|
1065
1015
|
}
|
|
1066
1016
|
|
|
1067
1017
|
/**
|
|
@@ -1069,34 +1019,35 @@ export function defaultIfEmpty_<R, E, A, R1, E1, B>(
|
|
|
1069
1019
|
* queues should receive which elements. The decide function will receive the indices of the queues
|
|
1070
1020
|
* in the resulting list.
|
|
1071
1021
|
*
|
|
1072
|
-
* @tsplus
|
|
1022
|
+
* @tsplus pipeable fncts.io.Stream distributedWith
|
|
1073
1023
|
*/
|
|
1074
|
-
export function
|
|
1075
|
-
self: Stream<R, E, A>,
|
|
1024
|
+
export function distributedWith<A>(
|
|
1076
1025
|
n: number,
|
|
1077
1026
|
maximumLag: number,
|
|
1078
1027
|
decide: (_: A) => UIO<(_: number) => boolean>,
|
|
1079
1028
|
__tsplusTrace?: string,
|
|
1080
|
-
)
|
|
1081
|
-
return
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
[
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1029
|
+
) {
|
|
1030
|
+
return <R, E>(self: Stream<R, E, A>): IO<R | Scope, never, Conc<Queue.Dequeue<Exit<Maybe<E>, A>>>> => {
|
|
1031
|
+
return Future.make<never, (a: A) => UIO<(_: symbol) => boolean>>().flatMap((p) =>
|
|
1032
|
+
self
|
|
1033
|
+
.distributedWithDynamic(
|
|
1034
|
+
maximumLag,
|
|
1035
|
+
(a) => p.await.flatMap((f) => f(a)),
|
|
1036
|
+
() => IO.unit,
|
|
1037
|
+
)
|
|
1038
|
+
.flatMap((next) =>
|
|
1039
|
+
IO.sequenceIterable(
|
|
1040
|
+
Conc.range(0, n).map((id) => next.map(([key, queue]) => [[key, id], queue] as const)),
|
|
1041
|
+
).flatMap((entries) => {
|
|
1042
|
+
const [mappings, queues] = entries.foldRight(
|
|
1043
|
+
[HashMap.empty<symbol, number>(), Conc.empty<Queue.Dequeue<Exit<Maybe<E>, A>>>()] as const,
|
|
1044
|
+
([mapping, queue], [mappings, queues]) => [mappings.set(mapping[0], mapping[1]), queues.append(queue)],
|
|
1045
|
+
);
|
|
1046
|
+
return p.succeed((a) => decide(a).map((f) => (key: symbol) => f(mappings.get(key).value!))).as(queues);
|
|
1047
|
+
}),
|
|
1048
|
+
),
|
|
1049
|
+
);
|
|
1050
|
+
};
|
|
1100
1051
|
}
|
|
1101
1052
|
|
|
1102
1053
|
/**
|
|
@@ -1107,93 +1058,89 @@ export function distributedWith_<R, E, A>(
|
|
|
1107
1058
|
* Downstream users can also shutdown queues manually. In this case the driver will
|
|
1108
1059
|
* continue but no longer backpressure on them.
|
|
1109
1060
|
*
|
|
1110
|
-
* @tsplus
|
|
1061
|
+
* @tsplus pipeable fncts.io.Stream distributedWithDynamic
|
|
1111
1062
|
*/
|
|
1112
|
-
export function
|
|
1113
|
-
self: Stream<R, E, A>,
|
|
1063
|
+
export function distributedWithDynamic<E, A>(
|
|
1114
1064
|
maximumLag: number,
|
|
1115
1065
|
decide: (a: A) => UIO<(_: symbol) => boolean>,
|
|
1116
1066
|
done: (exit: Exit<Maybe<E>, never>) => UIO<any> = () => IO.unit,
|
|
1117
1067
|
__tsplusTrace?: string,
|
|
1118
|
-
)
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
const shouldProcess = Δ(decide(a));
|
|
1122
|
-
const queues = Δ(queuesRef.get);
|
|
1123
|
-
return Δ(
|
|
1124
|
-
IO.foldLeft(queues, Conc.empty<symbol>(), (b, [id, queue]) => {
|
|
1125
|
-
if (shouldProcess(id)) {
|
|
1126
|
-
return queue.offer(Exit.succeed(a)).matchCauseIO(
|
|
1127
|
-
(c) => (c.interrupted ? IO.succeedNow(b.append(id)) : IO.failCauseNow(c)),
|
|
1128
|
-
() => IO.succeedNow(b),
|
|
1129
|
-
);
|
|
1130
|
-
} else {
|
|
1131
|
-
return IO.succeedNow(b);
|
|
1132
|
-
}
|
|
1133
|
-
}).flatMap((ids) => (ids.isNonEmpty ? queuesRef.update((map) => map.removeMany(ids)) : IO.unit)),
|
|
1134
|
-
);
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
|
-
return Do((Δ) => {
|
|
1138
|
-
const queuesRef = Δ(
|
|
1139
|
-
IO.acquireRelease(Ref.make<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>(HashMap.makeDefault()), (ref) =>
|
|
1140
|
-
ref.get.flatMap((qs) => IO.foreach(qs.values, (q) => q.shutdown)),
|
|
1141
|
-
),
|
|
1142
|
-
);
|
|
1143
|
-
|
|
1144
|
-
const add = Δ(
|
|
1068
|
+
) {
|
|
1069
|
+
return <R>(self: Stream<R, E, A>): IO<R | Scope, never, UIO<readonly [symbol, Queue.Dequeue<Exit<Maybe<E>, A>>]>> => {
|
|
1070
|
+
const offer = (queuesRef: Ref<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>) => (a: A) =>
|
|
1145
1071
|
Do((Δ) => {
|
|
1146
|
-
const
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1072
|
+
const shouldProcess = Δ(decide(a));
|
|
1073
|
+
const queues = Δ(queuesRef.get);
|
|
1074
|
+
return Δ(
|
|
1075
|
+
IO.foldLeft(queues, Conc.empty<symbol>(), (b, [id, queue]) => {
|
|
1076
|
+
if (shouldProcess(id)) {
|
|
1077
|
+
return queue.offer(Exit.succeed(a)).matchCauseIO(
|
|
1078
|
+
(c) => (c.interrupted ? IO.succeedNow(b.append(id)) : IO.failCauseNow(c)),
|
|
1079
|
+
() => IO.succeedNow(b),
|
|
1080
|
+
);
|
|
1081
|
+
} else {
|
|
1082
|
+
return IO.succeedNow(b);
|
|
1083
|
+
}
|
|
1084
|
+
}).flatMap((ids) => (ids.isNonEmpty ? queuesRef.update((map) => map.removeMany(ids)) : IO.unit)),
|
|
1156
1085
|
);
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
.catchJustCause((c) => (c.interrupted ? Just(IO.unit) : Nothing<UIO<void>>())),
|
|
1177
|
-
),
|
|
1178
|
-
);
|
|
1179
|
-
Δ(done(endTake));
|
|
1180
|
-
}),
|
|
1181
|
-
).asUnit,
|
|
1086
|
+
});
|
|
1087
|
+
return Do((Δ) => {
|
|
1088
|
+
const queuesRef = Δ(
|
|
1089
|
+
IO.acquireRelease(Ref.make<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>(HashMap.empty()), (ref) =>
|
|
1090
|
+
ref.get.flatMap((qs) => IO.foreach(qs.values, (q) => q.shutdown)),
|
|
1091
|
+
),
|
|
1092
|
+
);
|
|
1093
|
+
const add = Δ(
|
|
1094
|
+
Do((Δ) => {
|
|
1095
|
+
const queuesLock = Δ(TSemaphore.make(1).commit);
|
|
1096
|
+
const newQueue = Δ(
|
|
1097
|
+
Ref.make<UIO<readonly [symbol, Queue<Exit<Maybe<E>, A>>]>>(
|
|
1098
|
+
Do((Δ) => {
|
|
1099
|
+
const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(maximumLag));
|
|
1100
|
+
const id = Δ(IO.succeed(Symbol()));
|
|
1101
|
+
Δ(queuesRef.update((map) => map.set(id, queue)));
|
|
1102
|
+
return tuple(id, queue);
|
|
1103
|
+
}),
|
|
1104
|
+
),
|
|
1182
1105
|
);
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1106
|
+
const finalize = (endTake: Exit<Maybe<E>, never>): UIO<void> =>
|
|
1107
|
+
queuesLock.withPermit(
|
|
1108
|
+
newQueue
|
|
1109
|
+
.set(
|
|
1110
|
+
Do((Δ) => {
|
|
1111
|
+
const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(1));
|
|
1112
|
+
Δ(queue.offer(endTake));
|
|
1113
|
+
const id = Symbol();
|
|
1114
|
+
Δ(queuesRef.update((map) => map.set(id, queue)));
|
|
1115
|
+
return tuple(id, queue);
|
|
1116
|
+
}),
|
|
1117
|
+
)
|
|
1118
|
+
.flatMap(() =>
|
|
1119
|
+
Do((Δ) => {
|
|
1120
|
+
const queues = Δ(queuesRef.get.map((map) => map.values));
|
|
1121
|
+
Δ(
|
|
1122
|
+
IO.foreach(queues, (queue) =>
|
|
1123
|
+
queue
|
|
1124
|
+
.offer(endTake)
|
|
1125
|
+
.catchJustCause((c) => (c.interrupted ? Just(IO.unit) : Nothing<UIO<void>>())),
|
|
1126
|
+
),
|
|
1127
|
+
);
|
|
1128
|
+
Δ(done(endTake));
|
|
1129
|
+
}),
|
|
1130
|
+
).asUnit,
|
|
1131
|
+
);
|
|
1132
|
+
Δ(
|
|
1133
|
+
self.runForeachScoped(offer(queuesRef)).matchCauseIO(
|
|
1134
|
+
(cause) => finalize(Exit.failCause(cause.map(Maybe.just))),
|
|
1135
|
+
() => finalize(Exit.fail(Nothing())),
|
|
1136
|
+
).fork,
|
|
1137
|
+
);
|
|
1138
|
+
return queuesLock.withPermit(newQueue.get.flatten);
|
|
1139
|
+
}),
|
|
1140
|
+
);
|
|
1141
|
+
return add;
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1197
1144
|
}
|
|
1198
1145
|
|
|
1199
1146
|
/**
|
|
@@ -1212,7 +1159,7 @@ function dropLoop<R, E, A>(r: number, __tsplusTrace?: string): Channel<R, E, Con
|
|
|
1212
1159
|
const dropped = inp.drop(r);
|
|
1213
1160
|
const leftover = Math.max(0, r - inp.length);
|
|
1214
1161
|
const more = inp.isEmpty || leftover > 0;
|
|
1215
|
-
return more ? dropLoop(leftover) : Channel.write(dropped).
|
|
1162
|
+
return more ? dropLoop(leftover) : Channel.write(dropped).zipRight(Channel.id());
|
|
1216
1163
|
},
|
|
1217
1164
|
Channel.failNow,
|
|
1218
1165
|
() => Channel.unit,
|
|
@@ -1222,30 +1169,36 @@ function dropLoop<R, E, A>(r: number, __tsplusTrace?: string): Channel<R, E, Con
|
|
|
1222
1169
|
/**
|
|
1223
1170
|
* Drops the specified number of elements from this stream.
|
|
1224
1171
|
*
|
|
1225
|
-
* @tsplus
|
|
1172
|
+
* @tsplus pipeable fncts.io.Stream drop
|
|
1226
1173
|
*/
|
|
1227
|
-
export function
|
|
1228
|
-
return
|
|
1174
|
+
export function drop(n: number, __tsplusTrace?: string) {
|
|
1175
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
1176
|
+
return new Stream(stream.channel.pipeTo(dropLoop(n)));
|
|
1177
|
+
};
|
|
1229
1178
|
}
|
|
1230
1179
|
|
|
1231
1180
|
/**
|
|
1232
1181
|
* Drops all elements of the stream for as long as the specified predicate
|
|
1233
1182
|
* evaluates to `true`.
|
|
1234
1183
|
*
|
|
1235
|
-
* @tsplus
|
|
1184
|
+
* @tsplus pipeable fncts.io.Stream dropWhile
|
|
1236
1185
|
*/
|
|
1237
|
-
export function
|
|
1238
|
-
return stream
|
|
1186
|
+
export function dropWhile<A>(p: Predicate<A>, __tsplusTrace?: string) {
|
|
1187
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
1188
|
+
return stream.pipeThrough(Sink.dropWhile(p));
|
|
1189
|
+
};
|
|
1239
1190
|
}
|
|
1240
1191
|
|
|
1241
1192
|
/**
|
|
1242
1193
|
* Drops all elements of the stream until the specified predicate evaluates
|
|
1243
1194
|
* to `true`.
|
|
1244
1195
|
*
|
|
1245
|
-
* @tsplus
|
|
1196
|
+
* @tsplus pipeable fncts.io.Stream dropUntil
|
|
1246
1197
|
*/
|
|
1247
|
-
export function
|
|
1248
|
-
return stream
|
|
1198
|
+
export function dropUntil<A>(p: Predicate<A>, __tsplusTrace?: string) {
|
|
1199
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
1200
|
+
return stream.dropWhile(p.invert).drop(1);
|
|
1201
|
+
};
|
|
1249
1202
|
}
|
|
1250
1203
|
|
|
1251
1204
|
/**
|
|
@@ -1275,7 +1228,7 @@ function endWhenWriter<E, A, E1>(
|
|
|
1275
1228
|
maybeExit.match(
|
|
1276
1229
|
() =>
|
|
1277
1230
|
Channel.readWith(
|
|
1278
|
-
(inp: Conc<A>) => Channel.writeNow(inp).
|
|
1231
|
+
(inp: Conc<A>) => Channel.writeNow(inp).zipRight(endWhenWriter<E, A, E1>(fiber)),
|
|
1279
1232
|
Channel.failNow,
|
|
1280
1233
|
() => Channel.unit,
|
|
1281
1234
|
),
|
|
@@ -1294,25 +1247,21 @@ function endWhenWriter<E, A, E1>(
|
|
|
1294
1247
|
*
|
|
1295
1248
|
* If the IO completes with a failure, the stream will emit that failure.
|
|
1296
1249
|
*
|
|
1297
|
-
* @tsplus
|
|
1250
|
+
* @tsplus pipeable fncts.io.Stream endWhen
|
|
1298
1251
|
*/
|
|
1299
|
-
export function
|
|
1300
|
-
stream: Stream<R, E, A
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
): Stream<R | R1, E | E1, A> {
|
|
1304
|
-
return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => stream.channel.pipeTo(endWhenWriter(fiber)))));
|
|
1252
|
+
export function endWhen<R1, E1>(io: IO<R1, E1, any>, __tsplusTrace?: string) {
|
|
1253
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
1254
|
+
return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => stream.channel.pipeTo(endWhenWriter(fiber)))));
|
|
1255
|
+
};
|
|
1305
1256
|
}
|
|
1306
1257
|
|
|
1307
1258
|
/**
|
|
1308
|
-
* @tsplus
|
|
1259
|
+
* @tsplus pipeable fncts.io.Stream ensuring
|
|
1309
1260
|
*/
|
|
1310
|
-
export function
|
|
1311
|
-
self: Stream<R, E, A
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
): Stream<R | R1, E, A> {
|
|
1315
|
-
return new Stream(self.channel.ensuring(finalizer));
|
|
1261
|
+
export function ensuring<R1>(finalizer: IO<R1, never, any>, __tsplusTrace?: string) {
|
|
1262
|
+
return <R, E, A>(self: Stream<R, E, A>): Stream<R | R1, E, A> => {
|
|
1263
|
+
return new Stream(self.channel.ensuring(finalizer));
|
|
1264
|
+
};
|
|
1316
1265
|
}
|
|
1317
1266
|
|
|
1318
1267
|
/**
|
|
@@ -1392,27 +1341,23 @@ export function failCause<E>(cause: Lazy<Cause<E>>, __tsplusTrace?: string): Str
|
|
|
1392
1341
|
}
|
|
1393
1342
|
|
|
1394
1343
|
/**
|
|
1395
|
-
* @tsplus
|
|
1344
|
+
* @tsplus pipeable fncts.io.Stream filter
|
|
1396
1345
|
*/
|
|
1397
|
-
export function
|
|
1398
|
-
export function
|
|
1399
|
-
export function
|
|
1400
|
-
fa: Stream<R, E, A
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
): Stream<R, E, A> {
|
|
1404
|
-
return fa.mapChunks((chunk) => chunk.filter(predicate));
|
|
1346
|
+
export function filter<A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Stream<R, E, A>) => Stream<R, E, B>;
|
|
1347
|
+
export function filter<A>(predicate: Predicate<A>): <R, E>(fa: Stream<R, E, A>) => Stream<R, E, A>;
|
|
1348
|
+
export function filter<A>(predicate: Predicate<A>, __tsplusTrace?: string) {
|
|
1349
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R, E, A> => {
|
|
1350
|
+
return fa.mapChunks((chunk) => chunk.filter(predicate));
|
|
1351
|
+
};
|
|
1405
1352
|
}
|
|
1406
1353
|
|
|
1407
1354
|
/**
|
|
1408
|
-
* @tsplus
|
|
1355
|
+
* @tsplus pipeable fncts.io.Stream filterIO
|
|
1409
1356
|
*/
|
|
1410
|
-
export function
|
|
1411
|
-
fa: Stream<R, E, A
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
): Stream<R | R1, E | E1, A> {
|
|
1415
|
-
return new Stream(fa.channel.pipeTo(filterIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
|
|
1357
|
+
export function filterIO<A, R1, E1>(f: (a: A) => IO<R1, E1, boolean>, __tsplusTrace?: string) {
|
|
1358
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
1359
|
+
return new Stream(fa.channel.pipeTo(filterIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
|
|
1360
|
+
};
|
|
1416
1361
|
}
|
|
1417
1362
|
|
|
1418
1363
|
function filterIOLoop<R, E, A, R1, E1>(
|
|
@@ -1439,25 +1384,23 @@ function filterIOLoop<R, E, A, R1, E1>(
|
|
|
1439
1384
|
}
|
|
1440
1385
|
|
|
1441
1386
|
/**
|
|
1442
|
-
* @tsplus
|
|
1387
|
+
* @tsplus pipeable fncts.io.Stream filterMap
|
|
1443
1388
|
*/
|
|
1444
|
-
export function
|
|
1445
|
-
fa: Stream<R, E, A
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
): Stream<R, E, B> {
|
|
1449
|
-
return fa.mapChunks((chunk) => chunk.filterMap(f));
|
|
1389
|
+
export function filterMap<A, B>(f: (a: A) => Maybe<B>, __tsplusTrace?: string) {
|
|
1390
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R, E, B> => {
|
|
1391
|
+
return fa.mapChunks((chunk) => chunk.filterMap(f));
|
|
1392
|
+
};
|
|
1450
1393
|
}
|
|
1451
1394
|
|
|
1452
1395
|
/**
|
|
1453
|
-
* @tsplus
|
|
1396
|
+
* @tsplus pipeable fncts.io.Stream filterMapIO
|
|
1454
1397
|
*/
|
|
1455
|
-
export function
|
|
1456
|
-
fa: Stream<R, E, A
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
)
|
|
1460
|
-
|
|
1398
|
+
export function filterMapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Maybe<B>>, __tsplusTrace?: string) {
|
|
1399
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
1400
|
+
return new Stream(
|
|
1401
|
+
fa.channel.pipeTo(filterMapIOLoop<R, E, A, R1, E1, B>(Iterable.empty<A>()[Symbol.iterator](), f)),
|
|
1402
|
+
);
|
|
1403
|
+
};
|
|
1461
1404
|
}
|
|
1462
1405
|
|
|
1463
1406
|
function filterMapIOLoop<R, E, A, R1, E1, B>(
|
|
@@ -1487,45 +1430,45 @@ function filterMapIOLoop<R, E, A, R1, E1, B>(
|
|
|
1487
1430
|
/**
|
|
1488
1431
|
* Finds the first element emitted by this stream that satisfies the provided predicate.
|
|
1489
1432
|
*
|
|
1490
|
-
* @tsplus
|
|
1433
|
+
* @tsplus pipeable fncts.io.Stream find
|
|
1491
1434
|
*/
|
|
1492
|
-
export function
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
inp
|
|
1496
|
-
()
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1435
|
+
export function find<A>(p: Predicate<A>, __tsplusTrace?: string) {
|
|
1436
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
1437
|
+
const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A>, unknown> = Channel.readWith(
|
|
1438
|
+
(inp: Conc<A>) =>
|
|
1439
|
+
inp.find(p).match(
|
|
1440
|
+
() => loop,
|
|
1441
|
+
(a) => Channel.writeNow(Conc.single(a)),
|
|
1442
|
+
),
|
|
1443
|
+
Channel.failNow,
|
|
1444
|
+
() => Channel.unit,
|
|
1445
|
+
);
|
|
1446
|
+
return new Stream(stream.channel.pipeTo(loop));
|
|
1447
|
+
};
|
|
1503
1448
|
}
|
|
1504
1449
|
|
|
1505
1450
|
/**
|
|
1506
1451
|
* Finds the first element emitted by this stream that satisfies the provided effectful predicate.
|
|
1507
1452
|
*
|
|
1508
|
-
* @tsplus
|
|
1453
|
+
* @tsplus pipeable fncts.io.Stream findIO
|
|
1509
1454
|
*/
|
|
1510
|
-
export function
|
|
1511
|
-
stream: Stream<R, E, A
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
() => loop,
|
|
1521
|
-
(a) => Channel.writeNow(Conc.single(a)),
|
|
1455
|
+
export function findIO<A, R1, E1>(f: (a: A) => IO<R1, E1, boolean>, __tsplusTrace?: string) {
|
|
1456
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
1457
|
+
const loop: Channel<R | R1, E, Conc<A>, unknown, E | E1, Conc<A>, unknown> = Channel.readWith(
|
|
1458
|
+
(inp: Conc<A>) =>
|
|
1459
|
+
Channel.unwrap(
|
|
1460
|
+
inp.findIO(f).map((maybeA) =>
|
|
1461
|
+
maybeA.match(
|
|
1462
|
+
() => loop,
|
|
1463
|
+
(a) => Channel.writeNow(Conc.single(a)),
|
|
1464
|
+
),
|
|
1522
1465
|
),
|
|
1523
1466
|
),
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1467
|
+
Channel.failNow,
|
|
1468
|
+
() => Channel.unit,
|
|
1469
|
+
);
|
|
1470
|
+
return new Stream(stream.channel.pipeTo(loop));
|
|
1471
|
+
};
|
|
1529
1472
|
}
|
|
1530
1473
|
|
|
1531
1474
|
/**
|
|
@@ -1565,16 +1508,13 @@ export function flattenExitOption<R, E, E1, A>(
|
|
|
1565
1508
|
() => Channel.endNow<void>(undefined),
|
|
1566
1509
|
),
|
|
1567
1510
|
);
|
|
1568
|
-
|
|
1569
|
-
return Channel.writeNow(toEmit.filterMap((exit) => exit.match(() => Nothing(), Maybe.just))).apSecond(next);
|
|
1511
|
+
return Channel.writeNow(toEmit.filterMap((exit) => exit.match(() => Nothing(), Maybe.just))).zipRight(next);
|
|
1570
1512
|
};
|
|
1571
|
-
|
|
1572
1513
|
const process: Channel<R, E, Conc<Exit<Maybe<E1>, A>>, unknown, E | E1, Conc<A>, any> = Channel.readWithCause(
|
|
1573
1514
|
(chunk) => processChunk(chunk, process),
|
|
1574
1515
|
Channel.failCauseNow,
|
|
1575
1516
|
(_) => Channel.endNow(undefined),
|
|
1576
1517
|
);
|
|
1577
|
-
|
|
1578
1518
|
return new Stream(stream.channel.pipeTo(process));
|
|
1579
1519
|
}
|
|
1580
1520
|
|
|
@@ -1632,8 +1572,8 @@ export function fromChunk<O>(c: Lazy<Conc<O>>, __tsplusTrace?: string): Stream<n
|
|
|
1632
1572
|
*
|
|
1633
1573
|
* @tsplus static fncts.io.StreamOps scoped
|
|
1634
1574
|
*/
|
|
1635
|
-
export function scoped<R, E, A>(stream: IO<R, E, A
|
|
1636
|
-
return new Stream(Channel.scoped(stream.map(Conc.single)));
|
|
1575
|
+
export function scoped<R, E, A>(stream: Lazy<IO<R, E, A>>, __tsplusTrace?: string): Stream<Exclude<R, Scope>, E, A> {
|
|
1576
|
+
return new Stream(Channel.scoped(stream().map(Conc.single)));
|
|
1637
1577
|
}
|
|
1638
1578
|
|
|
1639
1579
|
/**
|
|
@@ -1672,7 +1612,7 @@ function fromAsyncIterableLoop<A>(
|
|
|
1672
1612
|
.then((result) =>
|
|
1673
1613
|
result.done
|
|
1674
1614
|
? k(IO.succeedNow(Channel.end(undefined)))
|
|
1675
|
-
: k(IO.succeedNow(Channel.writeNow(Conc.single(result.value)).
|
|
1615
|
+
: k(IO.succeedNow(Channel.writeNow(Conc.single(result.value)).zipRight(fromAsyncIterableLoop(iterator)))),
|
|
1676
1616
|
);
|
|
1677
1617
|
}),
|
|
1678
1618
|
);
|
|
@@ -1703,7 +1643,7 @@ export function fromIterable<A>(
|
|
|
1703
1643
|
return Channel.unit;
|
|
1704
1644
|
}
|
|
1705
1645
|
if (maxChunkSize === 1) {
|
|
1706
|
-
return Channel.writeNow(Conc.single(result.value)).
|
|
1646
|
+
return Channel.writeNow(Conc.single(result.value)).zipRight(loop(iterator));
|
|
1707
1647
|
} else {
|
|
1708
1648
|
const out = Array<A>(maxChunkSize);
|
|
1709
1649
|
out[0] = result.value;
|
|
@@ -1712,7 +1652,7 @@ export function fromIterable<A>(
|
|
|
1712
1652
|
out[count] = result.value;
|
|
1713
1653
|
count++;
|
|
1714
1654
|
}
|
|
1715
|
-
return Channel.writeNow(Conc.from(out)).
|
|
1655
|
+
return Channel.writeNow(Conc.from(out)).zipRight(loop(iterator));
|
|
1716
1656
|
}
|
|
1717
1657
|
}),
|
|
1718
1658
|
);
|
|
@@ -1758,11 +1698,11 @@ export function fromPull<R, E, A>(
|
|
|
1758
1698
|
*
|
|
1759
1699
|
* @tsplus static fncts.io.StreamOps fromQueue
|
|
1760
1700
|
*/
|
|
1761
|
-
export function
|
|
1762
|
-
queue:
|
|
1701
|
+
export function fromQueue<RA, RB, EA, EB, A, B>(
|
|
1702
|
+
queue: PDequeue<RA, RB, EA, EB, A, B>,
|
|
1763
1703
|
maxChunkSize: number = DEFAULT_CHUNK_SIZE,
|
|
1764
1704
|
__tsplusTrace?: string,
|
|
1765
|
-
): Stream<
|
|
1705
|
+
): Stream<RB, EB, B> {
|
|
1766
1706
|
return repeatIOChunkMaybe(
|
|
1767
1707
|
queue
|
|
1768
1708
|
.takeBetween(1, maxChunkSize)
|
|
@@ -1782,14 +1722,36 @@ export function fromQueue_<R, E, O>(
|
|
|
1782
1722
|
/**
|
|
1783
1723
|
* @tsplus static fncts.io.StreamOps fromQueueWithShutdown
|
|
1784
1724
|
*/
|
|
1785
|
-
export function fromQueueWithShutdown<
|
|
1786
|
-
queue:
|
|
1725
|
+
export function fromQueueWithShutdown<RA, RB, EA, EB, A, B>(
|
|
1726
|
+
queue: PDequeue<RA, RB, EA, EB, A, B>,
|
|
1787
1727
|
maxChunkSize: number = DEFAULT_CHUNK_SIZE,
|
|
1788
1728
|
__tsplusTrace?: string,
|
|
1789
|
-
): Stream<
|
|
1729
|
+
): Stream<RB, EB, B> {
|
|
1790
1730
|
return Stream.fromQueue(queue, maxChunkSize).ensuring(queue.shutdown);
|
|
1791
1731
|
}
|
|
1792
1732
|
|
|
1733
|
+
/**
|
|
1734
|
+
* @tsplus static fncts.io.StreamOps fromHub
|
|
1735
|
+
*/
|
|
1736
|
+
export function fromHub<A>(
|
|
1737
|
+
hub: Lazy<Hub<A>>,
|
|
1738
|
+
maxChunkSize = DEFAULT_CHUNK_SIZE,
|
|
1739
|
+
__tsplusTrace?: string,
|
|
1740
|
+
): Stream<never, never, A> {
|
|
1741
|
+
return Stream.scoped(hub().subscribe).flatMap((queue) => Stream.fromQueueWithShutdown(queue, maxChunkSize));
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* @tsplus static fncts.io.StreamOps fromHubScoped
|
|
1746
|
+
*/
|
|
1747
|
+
export function fromHubScoped<A>(
|
|
1748
|
+
hub: Lazy<Hub<A>>,
|
|
1749
|
+
maxChunkSize = DEFAULT_CHUNK_SIZE,
|
|
1750
|
+
__tsplusTrace?: string,
|
|
1751
|
+
): IO<Scope, never, Stream<never, never, A>> {
|
|
1752
|
+
return IO.defer(hub().subscribe.map((queue) => Stream.fromQueueWithShutdown(queue, maxChunkSize)));
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1793
1755
|
/**
|
|
1794
1756
|
* Halt a stream with the specified exception
|
|
1795
1757
|
*
|
|
@@ -1817,7 +1779,7 @@ function haltWhenWriter<E, A, E1>(
|
|
|
1817
1779
|
maybeExit.match(
|
|
1818
1780
|
() =>
|
|
1819
1781
|
Channel.readWith(
|
|
1820
|
-
(i: Conc<A>) => Channel.writeNow(i).
|
|
1782
|
+
(i: Conc<A>) => Channel.writeNow(i).zipRight(haltWhenWriter<E, A, E1>(fiber)),
|
|
1821
1783
|
Channel.failNow,
|
|
1822
1784
|
() => Channel.unit,
|
|
1823
1785
|
),
|
|
@@ -1837,14 +1799,12 @@ function haltWhenWriter<E, A, E1>(
|
|
|
1837
1799
|
*
|
|
1838
1800
|
* If the IO completes with a failure, the stream will emit that failure.
|
|
1839
1801
|
*
|
|
1840
|
-
* @tsplus
|
|
1802
|
+
* @tsplus pipeable fncts.io.Stream haltWhen
|
|
1841
1803
|
*/
|
|
1842
|
-
export function
|
|
1843
|
-
fa: Stream<R, E, A
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
): Stream<R | R1, E | E1, A> {
|
|
1847
|
-
return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => fa.channel.pipeTo(haltWhenWriter(fiber)))));
|
|
1804
|
+
export function haltWhen<R1, E1>(io: IO<R1, E1, any>, __tsplusTrace?: string) {
|
|
1805
|
+
return <R, E, A>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
1806
|
+
return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => fa.channel.pipeTo(haltWhenWriter(fiber)))));
|
|
1807
|
+
};
|
|
1848
1808
|
}
|
|
1849
1809
|
|
|
1850
1810
|
function haltWhenFutureWriter<R, E, A, E1>(
|
|
@@ -1856,7 +1816,7 @@ function haltWhenFutureWriter<R, E, A, E1>(
|
|
|
1856
1816
|
maybeIO.match(
|
|
1857
1817
|
() =>
|
|
1858
1818
|
Channel.readWith(
|
|
1859
|
-
(i: Conc<A>) => Channel.writeNow(i).
|
|
1819
|
+
(i: Conc<A>) => Channel.writeNow(i).zipRight(haltWhenFutureWriter<R, E, A, E1>(future)),
|
|
1860
1820
|
Channel.failNow,
|
|
1861
1821
|
() => Channel.unit,
|
|
1862
1822
|
),
|
|
@@ -1871,25 +1831,21 @@ function haltWhenFutureWriter<R, E, A, E1>(
|
|
|
1871
1831
|
*
|
|
1872
1832
|
* If the promise completes with a failure, the stream will emit that failure.
|
|
1873
1833
|
*
|
|
1874
|
-
* @tsplus
|
|
1834
|
+
* @tsplus pipeable fncts.io.Stream haltWhen
|
|
1875
1835
|
*/
|
|
1876
|
-
export function
|
|
1877
|
-
fa: Stream<R, E, A
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
): Stream<R, E | E1, A> {
|
|
1881
|
-
return new Stream(fa.channel.pipeTo(haltWhenFutureWriter(future)));
|
|
1836
|
+
export function haltWhenFuture<E1>(future: Future<E1, any>, __tsplusTrace?: string) {
|
|
1837
|
+
return <R, E, A>(fa: Stream<R, E, A>): Stream<R, E | E1, A> => {
|
|
1838
|
+
return new Stream(fa.channel.pipeTo(haltWhenFutureWriter(future)));
|
|
1839
|
+
};
|
|
1882
1840
|
}
|
|
1883
1841
|
|
|
1884
1842
|
/**
|
|
1885
|
-
* @tsplus
|
|
1843
|
+
* @tsplus pipeable fncts.io.Stream interleave
|
|
1886
1844
|
*/
|
|
1887
|
-
export function
|
|
1888
|
-
sa: Stream<R, E, A
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
): Stream<R | R1, E | E1, A | B> {
|
|
1892
|
-
return sa.interleaveWith(sb, Stream.fromChunk(Conc(true, false)).forever);
|
|
1845
|
+
export function interleave<R1, E1, B>(sb: Stream<R1, E1, B>, __tsplusTrace?: string) {
|
|
1846
|
+
return <R, E, A>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, A | B> => {
|
|
1847
|
+
return sa.interleaveWith(sb, Stream.fromChunk(Conc(true, false)).forever);
|
|
1848
|
+
};
|
|
1893
1849
|
}
|
|
1894
1850
|
|
|
1895
1851
|
function interleaveWithProducer<E, A>(
|
|
@@ -1897,7 +1853,7 @@ function interleaveWithProducer<E, A>(
|
|
|
1897
1853
|
__tsplusTrace?: string,
|
|
1898
1854
|
): Channel<never, E, A, unknown, never, never, void> {
|
|
1899
1855
|
return Channel.readWithCause(
|
|
1900
|
-
(value: A) => Channel.fromIO(handoff.offer(Take.single(value))).
|
|
1856
|
+
(value: A) => Channel.fromIO(handoff.offer(Take.single(value))).zipRight(interleaveWithProducer(handoff)),
|
|
1901
1857
|
(cause) => Channel.fromIO(handoff.offer(Take.failCause(cause))),
|
|
1902
1858
|
() => Channel.fromIO(handoff.offer(Take.end)),
|
|
1903
1859
|
);
|
|
@@ -1911,52 +1867,53 @@ function interleaveWithProducer<E, A>(
|
|
|
1911
1867
|
* `b`. If either this stream or the specified stream are exhausted further
|
|
1912
1868
|
* requests for values from that stream will be ignored.
|
|
1913
1869
|
*
|
|
1914
|
-
* @tsplus
|
|
1870
|
+
* @tsplus pipeable fncts.io.Stream interleaveWith
|
|
1915
1871
|
*/
|
|
1916
|
-
export function
|
|
1917
|
-
sa: Stream<R, E, A>,
|
|
1872
|
+
export function interleaveWith<R1, E1, B, R2, E2>(
|
|
1918
1873
|
sb: Stream<R1, E1, B>,
|
|
1919
1874
|
b: Stream<R2, E2, boolean>,
|
|
1920
1875
|
__tsplusTrace?: string,
|
|
1921
|
-
)
|
|
1922
|
-
return
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
Channel
|
|
1936
|
-
(
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1876
|
+
) {
|
|
1877
|
+
return <R, E, A>(sa: Stream<R, E, A>): Stream<R | R1 | R2, E | E1 | E2, A | B> => {
|
|
1878
|
+
return new Stream(
|
|
1879
|
+
Channel.unwrapScoped(
|
|
1880
|
+
Do((Δ) => {
|
|
1881
|
+
const left = Δ(Handoff<Take<E, A>>());
|
|
1882
|
+
const right = Δ(Handoff<Take<E1, B>>());
|
|
1883
|
+
Δ(sa.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(left)).runScoped.fork);
|
|
1884
|
+
Δ(sb.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(right)).runScoped.fork);
|
|
1885
|
+
return tuple(left, right);
|
|
1886
|
+
}).map(([left, right]) => {
|
|
1887
|
+
const process = (
|
|
1888
|
+
leftDone: boolean,
|
|
1889
|
+
rightDone: boolean,
|
|
1890
|
+
): Channel<R | R1 | R2, E | E1 | E2, boolean, unknown, E | E1 | E2, Conc<A | B>, void> =>
|
|
1891
|
+
Channel.readWithCause(
|
|
1892
|
+
(b: boolean) => {
|
|
1893
|
+
if (b && !leftDone) {
|
|
1894
|
+
return Channel.fromIO(left.take).flatMap((take) =>
|
|
1895
|
+
take.match(rightDone ? Channel.unit : process(true, rightDone), Channel.failCauseNow, (chunk) =>
|
|
1896
|
+
Channel.writeNow(chunk).zipRight(process(leftDone, rightDone)),
|
|
1897
|
+
),
|
|
1898
|
+
);
|
|
1899
|
+
}
|
|
1900
|
+
if (!b && !rightDone) {
|
|
1901
|
+
return Channel.fromIO(right.take).flatMap((take) =>
|
|
1902
|
+
take.match(leftDone ? Channel.unit : process(leftDone, true), Channel.failCauseNow, (chunk) =>
|
|
1903
|
+
Channel.writeNow(chunk).zipRight(process(leftDone, rightDone)),
|
|
1904
|
+
),
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
return process(leftDone, rightDone);
|
|
1908
|
+
},
|
|
1909
|
+
Channel.failCauseNow,
|
|
1910
|
+
() => Channel.unit,
|
|
1911
|
+
);
|
|
1912
|
+
return b.channel.concatMap(Channel.writeChunk).pipeTo(process(false, false));
|
|
1913
|
+
}),
|
|
1914
|
+
),
|
|
1915
|
+
);
|
|
1916
|
+
};
|
|
1960
1917
|
}
|
|
1961
1918
|
|
|
1962
1919
|
function intersperseWriter<R, E, A, A1>(
|
|
@@ -1977,7 +1934,7 @@ function intersperseWriter<R, E, A, A1>(
|
|
|
1977
1934
|
builder.append(a);
|
|
1978
1935
|
}
|
|
1979
1936
|
});
|
|
1980
|
-
return Channel.writeNow(builder.result()).
|
|
1937
|
+
return Channel.writeNow(builder.result()).zipRight(intersperseWriter(middle, flagResult));
|
|
1981
1938
|
},
|
|
1982
1939
|
Channel.failNow,
|
|
1983
1940
|
() => Channel.unit,
|
|
@@ -1987,7 +1944,7 @@ function intersperseWriter<R, E, A, A1>(
|
|
|
1987
1944
|
/**
|
|
1988
1945
|
* Intersperse stream with provided element
|
|
1989
1946
|
*/
|
|
1990
|
-
export function
|
|
1947
|
+
export function intersperse<R, E, A, A1>(
|
|
1991
1948
|
stream: Stream<R, E, A>,
|
|
1992
1949
|
middle: A1,
|
|
1993
1950
|
__tsplusTrace?: string,
|
|
@@ -2003,34 +1960,32 @@ export function intersperse_<R, E, A, A1>(
|
|
|
2003
1960
|
* If the IO completes with a failure before the stream completes, the returned stream
|
|
2004
1961
|
* will emit that failure.
|
|
2005
1962
|
*
|
|
2006
|
-
* @tsplus
|
|
1963
|
+
* @tsplus pipeable fncts.io.Stream interruptWhen
|
|
2007
1964
|
*/
|
|
2008
|
-
export function
|
|
2009
|
-
stream: Stream<R, E, A
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
): Stream<R | R1, E | E1, A> {
|
|
2013
|
-
return new Stream(stream.channel.interruptWhen(io));
|
|
1965
|
+
export function interruptWhen<R1, E1>(io: IO<R1, E1, any>, __tsplusTrace?: string) {
|
|
1966
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
1967
|
+
return new Stream(stream.channel.interruptWhen(io));
|
|
1968
|
+
};
|
|
2014
1969
|
}
|
|
2015
1970
|
|
|
2016
1971
|
/**
|
|
2017
|
-
* @tsplus
|
|
1972
|
+
* @tsplus pipeable fncts.io.Stream interruptWhen
|
|
2018
1973
|
*/
|
|
2019
|
-
export function
|
|
2020
|
-
fa: Stream<R, E, A
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
): Stream<R, E | E1, A> {
|
|
2024
|
-
return new Stream(fa.channel.interruptWhen(future));
|
|
1974
|
+
export function interruptWhenFuture<E1>(future: Future<E1, unknown>, __tsplusTrace?: string) {
|
|
1975
|
+
return <R, E, A>(fa: Stream<R, E, A>): Stream<R, E | E1, A> => {
|
|
1976
|
+
return new Stream(fa.channel.interruptWhen(future));
|
|
1977
|
+
};
|
|
2025
1978
|
}
|
|
2026
1979
|
|
|
2027
1980
|
/**
|
|
2028
1981
|
* Transforms the elements of this stream using the supplied function.
|
|
2029
1982
|
*
|
|
2030
|
-
* @tsplus
|
|
1983
|
+
* @tsplus pipeable fncts.io.Stream map
|
|
2031
1984
|
*/
|
|
2032
|
-
export function
|
|
2033
|
-
return
|
|
1985
|
+
export function map<A, B>(f: (o: A) => B, __tsplusTrace?: string) {
|
|
1986
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
|
|
1987
|
+
return new Stream(stream.channel.mapOut((as) => as.map(f)));
|
|
1988
|
+
};
|
|
2034
1989
|
}
|
|
2035
1990
|
|
|
2036
1991
|
function mapAccumAccumulator<S, E = never, A = never, B = never>(
|
|
@@ -2041,7 +1996,7 @@ function mapAccumAccumulator<S, E = never, A = never, B = never>(
|
|
|
2041
1996
|
return Channel.readWith(
|
|
2042
1997
|
(inp: Conc<A>) => {
|
|
2043
1998
|
const [nextS, bs] = inp.mapAccum(currS, f);
|
|
2044
|
-
return Channel.writeNow(bs).
|
|
1999
|
+
return Channel.writeNow(bs).zipRight(mapAccumAccumulator(nextS, f));
|
|
2045
2000
|
},
|
|
2046
2001
|
Channel.failNow,
|
|
2047
2002
|
() => Channel.unit,
|
|
@@ -2051,15 +2006,12 @@ function mapAccumAccumulator<S, E = never, A = never, B = never>(
|
|
|
2051
2006
|
/**
|
|
2052
2007
|
* Statefully maps over the elements of this stream to produce new elements.
|
|
2053
2008
|
*
|
|
2054
|
-
* @tsplus
|
|
2009
|
+
* @tsplus pipeable fncts.io.Stream mapAccum
|
|
2055
2010
|
*/
|
|
2056
|
-
export function
|
|
2057
|
-
stream: Stream<R, E, A
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
__tsplusTrace?: string,
|
|
2061
|
-
): Stream<R, E, B> {
|
|
2062
|
-
return new Stream(stream.channel.pipeTo(mapAccumAccumulator(s, f)));
|
|
2011
|
+
export function mapAccum<A, S, B>(s: S, f: (s: S, a: A) => readonly [S, B], __tsplusTrace?: string) {
|
|
2012
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
|
|
2013
|
+
return new Stream(stream.channel.pipeTo(mapAccumAccumulator(s, f)));
|
|
2014
|
+
};
|
|
2063
2015
|
}
|
|
2064
2016
|
|
|
2065
2017
|
function mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(
|
|
@@ -2080,10 +2032,10 @@ function mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(
|
|
|
2080
2032
|
(e) => {
|
|
2081
2033
|
const partialResult = outputChunk.result();
|
|
2082
2034
|
return partialResult.isNonEmpty
|
|
2083
|
-
? Channel.writeNow(partialResult).
|
|
2035
|
+
? Channel.writeNow(partialResult).zipRight(Channel.failNow(e))
|
|
2084
2036
|
: Channel.failNow(e);
|
|
2085
2037
|
},
|
|
2086
|
-
(s) => Channel.writeNow(outputChunk.result()).
|
|
2038
|
+
(s) => Channel.writeNow(outputChunk.result()).zipRight(mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(s, f)),
|
|
2087
2039
|
);
|
|
2088
2040
|
}),
|
|
2089
2041
|
),
|
|
@@ -2096,136 +2048,119 @@ function mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(
|
|
|
2096
2048
|
* Statefully and effectfully maps over the elements of this stream to produce
|
|
2097
2049
|
* new elements.
|
|
2098
2050
|
*
|
|
2099
|
-
* @tsplus
|
|
2051
|
+
* @tsplus pipeable fncts.io.Stream mapAccumIO
|
|
2100
2052
|
*/
|
|
2101
|
-
export function
|
|
2102
|
-
stream: Stream<R, E, A>,
|
|
2053
|
+
export function mapAccumIO<A, R1, E1, S, B>(
|
|
2103
2054
|
s: S,
|
|
2104
2055
|
f: (s: S, a: A) => IO<R1, E1, readonly [B, S]>,
|
|
2105
2056
|
__tsplusTrace?: string,
|
|
2106
|
-
)
|
|
2107
|
-
return
|
|
2057
|
+
) {
|
|
2058
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2059
|
+
return new Stream(stream.channel.pipeTo(mapAccumIOAccumulator(s, f)));
|
|
2060
|
+
};
|
|
2108
2061
|
}
|
|
2109
2062
|
|
|
2110
2063
|
/**
|
|
2111
2064
|
* Transforms the chunks emitted by this stream.
|
|
2112
2065
|
*
|
|
2113
|
-
* @tsplus
|
|
2066
|
+
* @tsplus pipeable fncts.io.Stream mapChunks
|
|
2114
2067
|
*/
|
|
2115
|
-
export function
|
|
2116
|
-
stream: Stream<R, E, A
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
): Stream<R, E, A1> {
|
|
2120
|
-
return new Stream(stream.channel.mapOut(f));
|
|
2068
|
+
export function mapChunks<A, A1>(f: (chunk: Conc<A>) => Conc<A1>, __tsplusTrace?: string) {
|
|
2069
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, A1> => {
|
|
2070
|
+
return new Stream(stream.channel.mapOut(f));
|
|
2071
|
+
};
|
|
2121
2072
|
}
|
|
2122
2073
|
|
|
2123
2074
|
/**
|
|
2124
2075
|
* Effectfully transforms the chunks emitted by this stream.
|
|
2125
2076
|
*
|
|
2126
|
-
* @tsplus
|
|
2077
|
+
* @tsplus pipeable fncts.io.Stream mapChunksIO
|
|
2127
2078
|
*/
|
|
2128
|
-
export function
|
|
2129
|
-
stream: Stream<R, E, A
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
): Stream<R | R1, E | E1, B> {
|
|
2133
|
-
return new Stream(stream.channel.mapOutIO(f));
|
|
2079
|
+
export function mapChunksIO<A, R1, E1, B>(f: (chunk: Conc<A>) => IO<R1, E1, Conc<B>>, __tsplusTrace?: string) {
|
|
2080
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2081
|
+
return new Stream(stream.channel.mapOutIO(f));
|
|
2082
|
+
};
|
|
2134
2083
|
}
|
|
2135
2084
|
|
|
2136
2085
|
/**
|
|
2137
2086
|
* Maps each element to an iterable, and flattens the iterables into the
|
|
2138
2087
|
* output of this stream.
|
|
2139
2088
|
*
|
|
2140
|
-
* @tsplus
|
|
2089
|
+
* @tsplus pipeable fncts.io.Stream mapConcat
|
|
2141
2090
|
*/
|
|
2142
|
-
export function
|
|
2143
|
-
stream: Stream<R, E, A
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
): Stream<R, E, B> {
|
|
2147
|
-
return stream.mapConcatChunk((a) => Conc.from(f(a)));
|
|
2091
|
+
export function mapConcat<A, B>(f: (a: A) => Iterable<B>, __tsplusTrace?: string) {
|
|
2092
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
|
|
2093
|
+
return stream.mapConcatChunk((a) => Conc.from(f(a)));
|
|
2094
|
+
};
|
|
2148
2095
|
}
|
|
2149
2096
|
|
|
2150
2097
|
/**
|
|
2151
2098
|
* Maps each element to a chunk, and flattens the chunks into the output of
|
|
2152
2099
|
* this stream.
|
|
2153
2100
|
*
|
|
2154
|
-
* @tsplus
|
|
2101
|
+
* @tsplus pipeable fncts.io.Stream mapConcatChunk
|
|
2155
2102
|
*/
|
|
2156
|
-
export function
|
|
2157
|
-
stream: Stream<R, E, A
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
): Stream<R, E, B> {
|
|
2161
|
-
return stream.mapChunks((c) => c.flatMap(f));
|
|
2103
|
+
export function mapConcatChunk<A, B>(f: (a: A) => Conc<B>, __tsplusTrace?: string) {
|
|
2104
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R, E, B> => {
|
|
2105
|
+
return stream.mapChunks((c) => c.flatMap(f));
|
|
2106
|
+
};
|
|
2162
2107
|
}
|
|
2163
2108
|
|
|
2164
2109
|
/**
|
|
2165
2110
|
* Effectfully maps each element to a chunk, and flattens the chunks into
|
|
2166
2111
|
* the output of this stream.
|
|
2167
2112
|
*
|
|
2168
|
-
* @tsplus
|
|
2113
|
+
* @tsplus pipeable fncts.io.Stream mapConcatChunkIO
|
|
2169
2114
|
*/
|
|
2170
|
-
export function
|
|
2171
|
-
stream: Stream<R, E, A
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
): Stream<R | R1, E | E1, B> {
|
|
2175
|
-
return stream.mapIO(f).mapConcatChunk(identity);
|
|
2115
|
+
export function mapConcatChunkIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Conc<B>>, __tsplusTrace?: string) {
|
|
2116
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2117
|
+
return stream.mapIO(f).mapConcatChunk(identity);
|
|
2118
|
+
};
|
|
2176
2119
|
}
|
|
2177
2120
|
|
|
2178
2121
|
/**
|
|
2179
2122
|
* Effectfully maps each element to an iterable, and flattens the iterables into
|
|
2180
2123
|
* the output of this stream.
|
|
2181
2124
|
*
|
|
2182
|
-
* @tsplus
|
|
2125
|
+
* @tsplus pipeable fncts.io.Stream mapConcatIO
|
|
2183
2126
|
*/
|
|
2184
|
-
export function
|
|
2185
|
-
stream: Stream<R, E, A
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
): Stream<R | R1, E | E1, B> {
|
|
2189
|
-
return stream.mapIO((a) => f(a).map(Conc.from)).mapConcatChunk(identity);
|
|
2127
|
+
export function mapConcatIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, Iterable<B>>, __tsplusTrace?: string) {
|
|
2128
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2129
|
+
return stream.mapIO((a) => f(a).map(Conc.from)).mapConcatChunk(identity);
|
|
2130
|
+
};
|
|
2190
2131
|
}
|
|
2191
2132
|
|
|
2192
2133
|
/**
|
|
2193
2134
|
* Transforms the errors emitted by this stream using `f`.
|
|
2194
2135
|
*
|
|
2195
|
-
* @tsplus
|
|
2136
|
+
* @tsplus pipeable fncts.io.Stream mapError
|
|
2196
2137
|
*/
|
|
2197
|
-
export function
|
|
2198
|
-
stream: Stream<R, E, A
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
): Stream<R, E1, A> {
|
|
2202
|
-
return new Stream(stream.channel.mapError(f));
|
|
2138
|
+
export function mapError<E, E1>(f: (e: E) => E1, __tsplusTrace?: string) {
|
|
2139
|
+
return <R, A>(stream: Stream<R, E, A>): Stream<R, E1, A> => {
|
|
2140
|
+
return new Stream(stream.channel.mapError(f));
|
|
2141
|
+
};
|
|
2203
2142
|
}
|
|
2204
2143
|
|
|
2205
2144
|
/**
|
|
2206
2145
|
* Transforms the full causes of failures emitted by this stream.
|
|
2207
2146
|
*
|
|
2208
|
-
* @tsplus
|
|
2147
|
+
* @tsplus pipeable fncts.io.Stream mapErrorCause
|
|
2209
2148
|
*/
|
|
2210
|
-
export function
|
|
2211
|
-
fa: Stream<R, E, A
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
): Stream<R, E1, A> {
|
|
2215
|
-
return new Stream(fa.channel.mapErrorCause(f));
|
|
2149
|
+
export function mapErrorCause<E, E1>(f: (e: Cause<E>) => Cause<E1>, __tsplusTrace?: string) {
|
|
2150
|
+
return <R, A>(fa: Stream<R, E, A>): Stream<R, E1, A> => {
|
|
2151
|
+
return new Stream(fa.channel.mapErrorCause(f));
|
|
2152
|
+
};
|
|
2216
2153
|
}
|
|
2217
2154
|
|
|
2218
2155
|
/**
|
|
2219
2156
|
* Maps over elements of the stream with the specified effectful function.
|
|
2220
2157
|
*
|
|
2221
|
-
* @tsplus
|
|
2158
|
+
* @tsplus pipeable fncts.io.Stream mapIO
|
|
2222
2159
|
*/
|
|
2223
|
-
export function
|
|
2224
|
-
stream: Stream<R, E, A
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
): Stream<R | R1, E | E1, B> {
|
|
2228
|
-
return new Stream(stream.channel.pipeTo(mapIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
|
|
2160
|
+
export function mapIO<A, R1, E1, B>(f: (a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
|
|
2161
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2162
|
+
return new Stream(stream.channel.pipeTo(mapIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
|
|
2163
|
+
};
|
|
2229
2164
|
}
|
|
2230
2165
|
|
|
2231
2166
|
function mapIOLoop<R, E, A, R1, E1, B>(
|
|
@@ -2254,15 +2189,12 @@ function mapIOLoop<R, E, A, R1, E1, B>(
|
|
|
2254
2189
|
*
|
|
2255
2190
|
* @note This combinator destroys the chunking structure. It's recommended to use chunkN afterwards.
|
|
2256
2191
|
*
|
|
2257
|
-
* @tsplus
|
|
2192
|
+
* @tsplus pipeable fncts.io.Stream mapIOC
|
|
2258
2193
|
*/
|
|
2259
|
-
export function
|
|
2260
|
-
stream: Stream<R, E, A
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
__tsplusTrace?: string,
|
|
2264
|
-
): Stream<R | R1, E | E1, B> {
|
|
2265
|
-
return new Stream(stream.channel.concatMap(Channel.writeChunk).mapOutIOC(n, f).mapOut(Conc.single));
|
|
2194
|
+
export function mapIOC<A, R1, E1, B>(n: number, f: (a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
|
|
2195
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2196
|
+
return new Stream(stream.channel.concatMap(Channel.writeChunk).mapOutConcurrentIO(n, f).mapOut(Conc.single));
|
|
2197
|
+
};
|
|
2266
2198
|
}
|
|
2267
2199
|
|
|
2268
2200
|
/**
|
|
@@ -2271,16 +2203,17 @@ export function mapIOC_<R, E, A, R1, E1, B>(
|
|
|
2271
2203
|
* concurrently. Up to `bufferSize` elements of the produced streams may be
|
|
2272
2204
|
* buffered in memory by this operator.
|
|
2273
2205
|
*
|
|
2274
|
-
* @tsplus
|
|
2206
|
+
* @tsplus pipeable fncts.io.Stream mergeMap
|
|
2275
2207
|
*/
|
|
2276
|
-
export function
|
|
2277
|
-
ma: Stream<R, E, A>,
|
|
2208
|
+
export function mergeMap<A, R1, E1, B>(
|
|
2278
2209
|
f: (a: A) => Stream<R1, E1, B>,
|
|
2279
2210
|
n: number,
|
|
2280
2211
|
bufferSize = 16,
|
|
2281
2212
|
__tsplusTrace?: string,
|
|
2282
|
-
)
|
|
2283
|
-
return
|
|
2213
|
+
) {
|
|
2214
|
+
return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2215
|
+
return new Stream(ma.channel.concatMap(Channel.writeChunk).mergeMap((a) => f(a).channel, n, bufferSize));
|
|
2216
|
+
};
|
|
2284
2217
|
}
|
|
2285
2218
|
|
|
2286
2219
|
/**
|
|
@@ -2288,27 +2221,26 @@ export function mergeMap_<R, E, A, R1, E1, B>(
|
|
|
2288
2221
|
* executing up to `n` invocations of `f` concurrently. The element order
|
|
2289
2222
|
* is not enforced by this combinator, and elements may be reordered.
|
|
2290
2223
|
*
|
|
2291
|
-
* @tsplus
|
|
2224
|
+
* @tsplus pipeable fncts.io.Stream mergeMapIO
|
|
2292
2225
|
*/
|
|
2293
|
-
export function
|
|
2294
|
-
stream: Stream<R, E, A>,
|
|
2226
|
+
export function mergeMapIO<A, R1, E1, B>(
|
|
2295
2227
|
f: (a: A) => IO<R1, E1, B>,
|
|
2296
2228
|
n: number,
|
|
2297
2229
|
bufferSize = 16,
|
|
2298
2230
|
__tsplusTrace?: string,
|
|
2299
|
-
)
|
|
2300
|
-
return stream
|
|
2231
|
+
) {
|
|
2232
|
+
return <R, E>(stream: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2233
|
+
return stream.mergeMap((a) => Stream.fromIO(f(a)), n, bufferSize);
|
|
2234
|
+
};
|
|
2301
2235
|
}
|
|
2302
2236
|
|
|
2303
2237
|
/**
|
|
2304
|
-
* @tsplus
|
|
2238
|
+
* @tsplus pipeable fncts.io.Stream mergeEither
|
|
2305
2239
|
*/
|
|
2306
|
-
export function
|
|
2307
|
-
fa: Stream<R, E, A
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
): Stream<R | R1, E | E1, Either<A, B>> {
|
|
2311
|
-
return fa.mergeWith(fb, Either.left, Either.right);
|
|
2240
|
+
export function mergeEither<R1, E1, B>(fb: Stream<R1, E1, B>, __tsplusTrace?: string) {
|
|
2241
|
+
return <R, E, A>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, Either<A, B>> => {
|
|
2242
|
+
return fa.mergeWith(fb, Either.left, Either.right);
|
|
2243
|
+
};
|
|
2312
2244
|
}
|
|
2313
2245
|
|
|
2314
2246
|
export function mergeWithHandler<R, E>(
|
|
@@ -2322,25 +2254,26 @@ export function mergeWithHandler<R, E>(
|
|
|
2322
2254
|
export type TerminationStrategy = "Left" | "Right" | "Both" | "Either";
|
|
2323
2255
|
|
|
2324
2256
|
/**
|
|
2325
|
-
* @tsplus
|
|
2257
|
+
* @tsplus pipeable fncts.io.Stream mergeWith
|
|
2326
2258
|
*/
|
|
2327
|
-
export function
|
|
2328
|
-
sa: Stream<R, E, A>,
|
|
2259
|
+
export function mergeWith<A, R1, E1, A1, B, C>(
|
|
2329
2260
|
sb: Stream<R1, E1, A1>,
|
|
2330
2261
|
l: (a: A) => B,
|
|
2331
2262
|
r: (b: A1) => C,
|
|
2332
2263
|
strategy: TerminationStrategy = "Both",
|
|
2333
2264
|
__tsplusTrace?: string,
|
|
2334
|
-
)
|
|
2335
|
-
return
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2265
|
+
) {
|
|
2266
|
+
return <R, E>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, B | C> => {
|
|
2267
|
+
return new Stream<R | R1, E | E1, B | C>(
|
|
2268
|
+
sa
|
|
2269
|
+
.map(l)
|
|
2270
|
+
.channel.mergeWith(
|
|
2271
|
+
sb.map(r).channel,
|
|
2272
|
+
mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Left"),
|
|
2273
|
+
mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Right"),
|
|
2274
|
+
),
|
|
2275
|
+
);
|
|
2276
|
+
};
|
|
2344
2277
|
}
|
|
2345
2278
|
|
|
2346
2279
|
/**
|
|
@@ -2348,14 +2281,12 @@ export function mergeWith_<R, E, A, R1, E1, A1, B, C>(
|
|
|
2348
2281
|
*
|
|
2349
2282
|
* Note: Unlike `IO.onError`, there is no guarantee that the provided effect will not be interrupted.
|
|
2350
2283
|
*
|
|
2351
|
-
* @tsplus
|
|
2284
|
+
* @tsplus pipeable fncts.io.Stream onError
|
|
2352
2285
|
*/
|
|
2353
|
-
export function
|
|
2354
|
-
stream: Stream<R, E, A
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
): Stream<R | R1, E, A> {
|
|
2358
|
-
return stream.catchAllCause((cause) => fromIO(cleanup(cause).apSecond(IO.failCauseNow(cause))));
|
|
2286
|
+
export function onError<E, R1>(cleanup: (e: Cause<E>) => IO<R1, never, any>, __tsplusTrace?: string) {
|
|
2287
|
+
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E, A> => {
|
|
2288
|
+
return stream.catchAllCause((cause) => fromIO(cleanup(cause).zipRight(IO.failCauseNow(cause))));
|
|
2289
|
+
};
|
|
2359
2290
|
}
|
|
2360
2291
|
|
|
2361
2292
|
/**
|
|
@@ -2363,14 +2294,12 @@ export function onError_<R, E, A, R1>(
|
|
|
2363
2294
|
*
|
|
2364
2295
|
* See also Stream#catchAll
|
|
2365
2296
|
*
|
|
2366
|
-
* @tsplus
|
|
2297
|
+
* @tsplus pipeable fncts.io.Stream orElse
|
|
2367
2298
|
*/
|
|
2368
|
-
export function
|
|
2369
|
-
stream: Stream<R, E, A
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
): Stream<R | R1, E1, A | A1> {
|
|
2373
|
-
return new Stream<R | R1, E1, A | A1>(stream.channel.orElse(that().channel));
|
|
2299
|
+
export function orElse<R1, E1, A1>(that: Lazy<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
|
|
2300
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
|
|
2301
|
+
return new Stream<R | R1, E1, A | A1>(stream.channel.orElse(that().channel));
|
|
2302
|
+
};
|
|
2374
2303
|
}
|
|
2375
2304
|
|
|
2376
2305
|
/**
|
|
@@ -2378,14 +2307,12 @@ export function orElse_<R, E, A, R1, E1, A1>(
|
|
|
2378
2307
|
*
|
|
2379
2308
|
* See also ZStream#catchAll
|
|
2380
2309
|
*
|
|
2381
|
-
* @tsplus
|
|
2310
|
+
* @tsplus pipeable fncts.io.Stream orElseEither
|
|
2382
2311
|
*/
|
|
2383
|
-
export function
|
|
2384
|
-
stream: Stream<R, E, A
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
): Stream<R | R1, E1, Either<A, A1>> {
|
|
2388
|
-
return stream.map(Either.left).orElse(that().map(Either.right));
|
|
2312
|
+
export function orElseEither<R1, E1, A1>(that: Lazy<Stream<R1, E1, A1>>, __tsplusTrace?: string) {
|
|
2313
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, Either<A, A1>> => {
|
|
2314
|
+
return stream.map(Either.left).orElse(that().map(Either.right));
|
|
2315
|
+
};
|
|
2389
2316
|
}
|
|
2390
2317
|
|
|
2391
2318
|
/**
|
|
@@ -2393,14 +2320,12 @@ export function orElseEither_<R, E, A, R1, E1, A1>(
|
|
|
2393
2320
|
*
|
|
2394
2321
|
* See also Stream#catchAll
|
|
2395
2322
|
*
|
|
2396
|
-
* @tsplus
|
|
2323
|
+
* @tsplus pipeable fncts.io.Stream orElseFail
|
|
2397
2324
|
*/
|
|
2398
|
-
export function
|
|
2399
|
-
stream: Stream<R, E, A
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
): Stream<R, E1, A> {
|
|
2403
|
-
return stream.orElse(Stream.failNow(e()));
|
|
2325
|
+
export function orElseFail<E1>(e: Lazy<E1>, __tsplusTrace?: string) {
|
|
2326
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E1, A> => {
|
|
2327
|
+
return stream.orElse(Stream.failNow(e()));
|
|
2328
|
+
};
|
|
2404
2329
|
}
|
|
2405
2330
|
|
|
2406
2331
|
/**
|
|
@@ -2408,7 +2333,7 @@ export function orElseFail_<R, E, A, E1>(
|
|
|
2408
2333
|
*
|
|
2409
2334
|
* See also Stream#catchAll.
|
|
2410
2335
|
*/
|
|
2411
|
-
export function
|
|
2336
|
+
export function orElseOptional<R, E, A, R1, E1, A1>(
|
|
2412
2337
|
stream: Stream<R, Maybe<E>, A>,
|
|
2413
2338
|
that: Lazy<Stream<R1, Maybe<E1>, A1>>,
|
|
2414
2339
|
__tsplusTrace?: string,
|
|
@@ -2424,85 +2349,69 @@ export function orElseOptional_<R, E, A, R1, E1, A1>(
|
|
|
2424
2349
|
/**
|
|
2425
2350
|
* Succeeds with the specified value if this one fails with a typed error.
|
|
2426
2351
|
*
|
|
2427
|
-
* @tsplus
|
|
2352
|
+
* @tsplus pipeable fncts.io.Stream orElseSucceed
|
|
2428
2353
|
*/
|
|
2429
|
-
export function
|
|
2430
|
-
stream: Stream<R, E, A
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
): Stream<R, never, A | A1> {
|
|
2434
|
-
return stream.orElse(Stream.succeedNow(a()));
|
|
2354
|
+
export function orElseSucceed<A1>(a: Lazy<A1>, __tsplusTrace?: string) {
|
|
2355
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, never, A | A1> => {
|
|
2356
|
+
return stream.orElse(Stream.succeedNow(a()));
|
|
2357
|
+
};
|
|
2435
2358
|
}
|
|
2436
2359
|
|
|
2437
2360
|
/**
|
|
2438
|
-
* @tsplus
|
|
2361
|
+
* @tsplus pipeable fncts.io.Stream pipeThrough
|
|
2439
2362
|
*/
|
|
2440
|
-
export function
|
|
2441
|
-
ma: Stream<R, E, A
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
): Stream<R | R1, E | E1, L> {
|
|
2445
|
-
return new Stream(ma.channel.pipeToOrFail(sa.channel));
|
|
2363
|
+
export function pipeThrough<A, R1, E1, L, Z>(sa: Sink<R1, E1, A, L, Z>, __tsplusTrace?: string) {
|
|
2364
|
+
return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, L> => {
|
|
2365
|
+
return new Stream(ma.channel.pipeToOrFail(sa.channel));
|
|
2366
|
+
};
|
|
2446
2367
|
}
|
|
2447
2368
|
|
|
2448
2369
|
/**
|
|
2449
2370
|
* Provides the stream with its required environment, which eliminates
|
|
2450
2371
|
* its dependency on `R`.
|
|
2451
2372
|
*
|
|
2452
|
-
* @tsplus
|
|
2373
|
+
* @tsplus pipeable fncts.io.Stream provideEnvironment
|
|
2453
2374
|
*/
|
|
2454
|
-
export function
|
|
2455
|
-
ra: Stream<R, E, A
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
): Stream<never, E, A> {
|
|
2459
|
-
return new Stream(ra.channel.provideEnvironment(r));
|
|
2375
|
+
export function provideEnvironment<R>(r: Environment<R>, __tsplusTrace?: string) {
|
|
2376
|
+
return <E, A>(ra: Stream<R, E, A>): Stream<never, E, A> => {
|
|
2377
|
+
return new Stream(ra.channel.provideEnvironment(r));
|
|
2378
|
+
};
|
|
2460
2379
|
}
|
|
2461
2380
|
|
|
2462
2381
|
/**
|
|
2463
|
-
* @tsplus
|
|
2382
|
+
* @tsplus pipeable fncts.io.Stream provideLayer
|
|
2464
2383
|
*/
|
|
2465
|
-
export function
|
|
2466
|
-
self: Stream<ROut, E, A
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
): Stream<RIn, E | E1, A> {
|
|
2470
|
-
return new Stream(Channel.unwrapScoped(layer.build.map((r) => self.channel.provideEnvironment(r))));
|
|
2384
|
+
export function provideLayer<RIn, ROut, E1>(layer: Layer<RIn, E1, ROut>, __tsplusTrace?: string) {
|
|
2385
|
+
return <E, A>(self: Stream<ROut, E, A>): Stream<RIn, E | E1, A> => {
|
|
2386
|
+
return new Stream(Channel.unwrapScoped(layer.build.map((r) => self.channel.provideEnvironment(r))));
|
|
2387
|
+
};
|
|
2471
2388
|
}
|
|
2472
2389
|
|
|
2473
2390
|
/**
|
|
2474
|
-
* @tsplus
|
|
2391
|
+
* @tsplus pipeable fncts.io.Stream provideSomeLayer
|
|
2475
2392
|
*/
|
|
2476
|
-
export function
|
|
2477
|
-
self: Stream<R, E, A>,
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
// @ts-expect-error
|
|
2482
|
-
return self.provideLayer(Layer.environment<RIn>().and(layer));
|
|
2393
|
+
export function provideSomeLayer<RIn, E1, ROut>(layer: Layer<RIn, E1, ROut>, __tsplusTrace?: string) {
|
|
2394
|
+
return <R, E, A>(self: Stream<R, E, A>): Stream<RIn | Exclude<R, ROut>, E | E1, A> => {
|
|
2395
|
+
// @ts-expect-error
|
|
2396
|
+
return self.provideLayer(Layer.environment<RIn>().and(layer));
|
|
2397
|
+
};
|
|
2483
2398
|
}
|
|
2484
2399
|
|
|
2485
2400
|
class Rechunker<A> {
|
|
2486
2401
|
private builder: Array<A> = [];
|
|
2487
2402
|
private pos = 0;
|
|
2488
|
-
|
|
2489
2403
|
constructor(readonly n: number) {}
|
|
2490
|
-
|
|
2491
2404
|
write(elem: A) {
|
|
2492
2405
|
this.builder.push(elem);
|
|
2493
2406
|
this.pos += 1;
|
|
2494
|
-
|
|
2495
2407
|
if (this.pos === this.n) {
|
|
2496
2408
|
const result = this.builder;
|
|
2497
2409
|
this.builder = [];
|
|
2498
2410
|
this.pos = 0;
|
|
2499
|
-
|
|
2500
2411
|
return Conc.from(result);
|
|
2501
2412
|
}
|
|
2502
|
-
|
|
2503
2413
|
return null;
|
|
2504
2414
|
}
|
|
2505
|
-
|
|
2506
2415
|
emitOfNotEmpty(): Channel<never, unknown, unknown, unknown, never, Conc<A>, void> {
|
|
2507
2416
|
if (this.pos !== 0) {
|
|
2508
2417
|
return Channel.writeNow(Conc.from(this.builder));
|
|
@@ -2510,11 +2419,9 @@ class Rechunker<A> {
|
|
|
2510
2419
|
return Channel.unit;
|
|
2511
2420
|
}
|
|
2512
2421
|
}
|
|
2513
|
-
|
|
2514
2422
|
get isEmpty(): boolean {
|
|
2515
2423
|
return this.pos === 0;
|
|
2516
2424
|
}
|
|
2517
|
-
/* eslint-enable */
|
|
2518
2425
|
}
|
|
2519
2426
|
|
|
2520
2427
|
function rechunkProcess<E, In>(
|
|
@@ -2525,7 +2432,7 @@ function rechunkProcess<E, In>(
|
|
|
2525
2432
|
return Channel.readWithCause(
|
|
2526
2433
|
(chunk: Conc<In>) => {
|
|
2527
2434
|
if (chunk.length === target && rechunker.isEmpty) {
|
|
2528
|
-
return Channel.writeNow(chunk).
|
|
2435
|
+
return Channel.writeNow(chunk).zipRight(rechunkProcess<E, In>(rechunker, target));
|
|
2529
2436
|
} else if (chunk.length > 0) {
|
|
2530
2437
|
const chunks: Array<Conc<In>> = [];
|
|
2531
2438
|
let result: Conc<In> | null = null;
|
|
@@ -2540,13 +2447,12 @@ function rechunkProcess<E, In>(
|
|
|
2540
2447
|
result = null;
|
|
2541
2448
|
}
|
|
2542
2449
|
}
|
|
2543
|
-
|
|
2544
|
-
return Channel.writeAll(chunks).apSecond(rechunkProcess<E, In>(rechunker, target));
|
|
2450
|
+
return Channel.writeAll(chunks).zipRight(rechunkProcess<E, In>(rechunker, target));
|
|
2545
2451
|
} else {
|
|
2546
2452
|
return rechunkProcess<E, In>(rechunker, target);
|
|
2547
2453
|
}
|
|
2548
2454
|
},
|
|
2549
|
-
(cause) => rechunker.emitOfNotEmpty().
|
|
2455
|
+
(cause) => rechunker.emitOfNotEmpty().zipRight(Channel.failCauseNow(cause)),
|
|
2550
2456
|
() => rechunker.emitOfNotEmpty(),
|
|
2551
2457
|
);
|
|
2552
2458
|
}
|
|
@@ -2556,10 +2462,12 @@ function rechunkProcess<E, In>(
|
|
|
2556
2462
|
* `n` elements each.
|
|
2557
2463
|
* The last chunk might contain less than `n` elements
|
|
2558
2464
|
*
|
|
2559
|
-
* @tsplus
|
|
2465
|
+
* @tsplus pipeable fncts.io.Stream rechunk
|
|
2560
2466
|
*/
|
|
2561
|
-
export function
|
|
2562
|
-
return
|
|
2467
|
+
export function rechunk(n: number, __tsplusTrace?: string) {
|
|
2468
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
2469
|
+
return new Stream(stream.channel.pipeTo(rechunkProcess(new Rechunker(n), n)));
|
|
2470
|
+
};
|
|
2563
2471
|
}
|
|
2564
2472
|
|
|
2565
2473
|
/**
|
|
@@ -2614,14 +2522,12 @@ export function repeatIOChunkMaybe<R, E, A>(fa: IO<R, Maybe<E>, Conc<A>>, __tspl
|
|
|
2614
2522
|
/**
|
|
2615
2523
|
* Runs the sink on the stream to produce either the sink's result or an error.
|
|
2616
2524
|
*
|
|
2617
|
-
* @tsplus
|
|
2525
|
+
* @tsplus pipeable fncts.io.Stream run
|
|
2618
2526
|
*/
|
|
2619
|
-
export function
|
|
2620
|
-
stream: Stream<R, E, A
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
): IO<R | R2, E | E2, Z> {
|
|
2624
|
-
return stream.channel.pipeToOrFail(sink.channel).runDrain;
|
|
2527
|
+
export function run<A, R2, E2, Z>(sink: Sink<R2, E2, A, unknown, Z>, __tsplusTrace?: string) {
|
|
2528
|
+
return <R, E>(stream: Stream<R, E, A>): IO<R | R2, E | E2, Z> => {
|
|
2529
|
+
return stream.channel.pipeToOrFail(sink.channel).runDrain;
|
|
2530
|
+
};
|
|
2625
2531
|
}
|
|
2626
2532
|
|
|
2627
2533
|
/**
|
|
@@ -2643,149 +2549,137 @@ export function runDrain<R, E, A>(stream: Stream<R, E, A>, __tsplusTrace?: strin
|
|
|
2643
2549
|
}
|
|
2644
2550
|
|
|
2645
2551
|
/**
|
|
2646
|
-
* @tsplus
|
|
2552
|
+
* @tsplus pipeable fncts.io.Stream runForeachScoped
|
|
2647
2553
|
*/
|
|
2648
|
-
export function
|
|
2649
|
-
self: Stream<R, E, A
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
): IO<R | R2 | Scope, E | E2, void> {
|
|
2653
|
-
return self.runScoped(Sink.foreach(f));
|
|
2554
|
+
export function runForeachScoped<A, R2, E2>(f: (a: A) => IO<R2, E2, any>, __tsplusTrace?: string) {
|
|
2555
|
+
return <R, E>(self: Stream<R, E, A>): IO<R | R2 | Scope, E | E2, void> => {
|
|
2556
|
+
return self.runScoped(Sink.foreach(f));
|
|
2557
|
+
};
|
|
2654
2558
|
}
|
|
2655
2559
|
|
|
2656
2560
|
/**
|
|
2657
2561
|
* Like `into`, but provides the result as a `Managed` to allow for scope
|
|
2658
2562
|
* composition.
|
|
2659
2563
|
*
|
|
2660
|
-
* @tsplus
|
|
2564
|
+
* @tsplus pipeable fncts.io.Stream runIntoElementsScoped
|
|
2661
2565
|
*/
|
|
2662
|
-
export function runIntoElementsScoped_<
|
|
2663
|
-
stream: Stream<R, E, A>,
|
|
2566
|
+
export function runIntoElementsScoped_<E, A, R1, E1>(
|
|
2664
2567
|
queue: PQueue<R1, unknown, never, never, Exit<Maybe<E | E1>, A>, unknown>,
|
|
2665
2568
|
__tsplusTrace?: string,
|
|
2666
|
-
)
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
inp
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2569
|
+
) {
|
|
2570
|
+
return <R>(stream: Stream<R, E, A>): IO<R | R1 | Scope, E | E1, void> => {
|
|
2571
|
+
const writer: Channel<R | R1, E, Conc<A>, unknown, never, Exit<Maybe<E | E1>, A>, unknown> = Channel.readWith(
|
|
2572
|
+
(inp: Conc<A>) =>
|
|
2573
|
+
inp
|
|
2574
|
+
.foldLeft(
|
|
2575
|
+
Channel.unit as Channel<R1, unknown, unknown, unknown, never, Exit<Maybe<E | E1>, A>, unknown>,
|
|
2576
|
+
(channel, a) => channel.zipRight(Channel.writeNow(Exit.succeed(a))),
|
|
2577
|
+
)
|
|
2578
|
+
.zipRight(writer),
|
|
2579
|
+
(err) => Channel.writeNow(Exit.fail(Just(err))),
|
|
2580
|
+
() => Channel.writeNow(Exit.fail(Nothing())),
|
|
2581
|
+
);
|
|
2582
|
+
return stream.channel.pipeTo(writer).mapOutIO((exit) => queue.offer(exit)).drain.runScoped.asUnit;
|
|
2583
|
+
};
|
|
2679
2584
|
}
|
|
2680
2585
|
|
|
2681
2586
|
/**
|
|
2682
2587
|
* Like `Stream#into`, but provides the result as a `Managed` to allow for scope
|
|
2683
2588
|
* composition.
|
|
2684
2589
|
*
|
|
2685
|
-
* @tsplus
|
|
2590
|
+
* @tsplus pipeable fncts.io.Stream runIntoQueueScoped
|
|
2686
2591
|
*/
|
|
2687
|
-
export function
|
|
2688
|
-
|
|
2689
|
-
queue: PQueue<R1, never, never, unknown, Take<E1, A>, any>,
|
|
2592
|
+
export function runIntoQueueScoped<RA, RB, EA, EB, E1, A, B>(
|
|
2593
|
+
queue: PEnqueue<RA, RB, EA, EB, Take<E1, A>, B>,
|
|
2690
2594
|
__tsplusTrace?: string,
|
|
2691
|
-
)
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2595
|
+
) {
|
|
2596
|
+
return <R, E extends E1>(stream: Stream<R, E, A>): IO<R | RA | Scope, E | EA | E1, void> => {
|
|
2597
|
+
const writer: Channel<R, E, Conc<A>, unknown, E, Take<E | E1, A>, any> = Channel.readWithCause(
|
|
2598
|
+
(inp) => Channel.writeNow(Take.chunk(inp)).zipRight(writer),
|
|
2599
|
+
(cause) => Channel.writeNow(Take.failCause(cause)),
|
|
2600
|
+
(_) => Channel.writeNow(Take.end),
|
|
2601
|
+
);
|
|
2602
|
+
return stream.channel.pipeTo(writer).mapOutIO((take) => queue.offer(take)).drain.runScoped.asUnit;
|
|
2603
|
+
};
|
|
2699
2604
|
}
|
|
2700
2605
|
|
|
2701
2606
|
/**
|
|
2702
2607
|
* Like `Stream#runIntoHub`, but provides the result as a `Managed` to allow for scope
|
|
2703
2608
|
* composition.
|
|
2704
2609
|
*
|
|
2705
|
-
* @tsplus
|
|
2610
|
+
* @tsplus pipeable fncts.io.Stream runIntoHubScoped
|
|
2706
2611
|
*/
|
|
2707
|
-
export function
|
|
2708
|
-
|
|
2709
|
-
hub: PHub<R1, never, never, unknown, Take<E1, A>, any>,
|
|
2612
|
+
export function runIntoHubScoped<RA, RB, EA, EB, E1, A, B>(
|
|
2613
|
+
hub: PHub<RA, RB, EA, EB, Take<E1, A>, B>,
|
|
2710
2614
|
__tsplusTrace?: string,
|
|
2711
|
-
)
|
|
2712
|
-
return stream
|
|
2615
|
+
) {
|
|
2616
|
+
return <R, E extends E1>(stream: Stream<R, E, A>): IO<R | RA | Scope, E | EA | E1, void> => {
|
|
2617
|
+
return stream.runIntoQueueScoped(hub);
|
|
2618
|
+
};
|
|
2713
2619
|
}
|
|
2714
2620
|
|
|
2715
2621
|
/**
|
|
2716
2622
|
* Runs the sink on the stream to produce either the sink's result or an error.
|
|
2717
2623
|
*
|
|
2718
|
-
* @tsplus
|
|
2624
|
+
* @tsplus pipeable fncts.io.Stream runScoped
|
|
2719
2625
|
*/
|
|
2720
|
-
export function
|
|
2721
|
-
stream: Stream<R, E, A
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
): IO<R | R2 | Scope, E | E2, Z> {
|
|
2725
|
-
return stream.channel.pipeToOrFail(sink.channel).drain.runScoped;
|
|
2626
|
+
export function runScoped<A, R2, E2, Z>(sink: Sink<R2, E2, A, unknown, Z>, __tsplusTrace?: string) {
|
|
2627
|
+
return <R, E>(stream: Stream<R, E, A>): IO<R | R2 | Scope, E | E2, Z> => {
|
|
2628
|
+
return stream.channel.pipeToOrFail(sink.channel).drain.runScoped;
|
|
2629
|
+
};
|
|
2726
2630
|
}
|
|
2727
2631
|
|
|
2728
2632
|
/**
|
|
2729
2633
|
* Statefully maps over the elements of this stream to produce all intermediate results
|
|
2730
2634
|
* of type `B` given an initial B.
|
|
2731
2635
|
*
|
|
2732
|
-
* @tsplus
|
|
2636
|
+
* @tsplus pipeable fncts.io.Stream scan
|
|
2733
2637
|
*/
|
|
2734
|
-
export function
|
|
2735
|
-
sa: Stream<R, E, A
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
__tsplusTrace?: string,
|
|
2739
|
-
): Stream<R, E, B> {
|
|
2740
|
-
return sa.scanIO(b, (b, a) => IO.succeedNow(f(b, a)));
|
|
2638
|
+
export function scan<A, B>(b: B, f: (b: B, a: A) => B, __tsplusTrace?: string) {
|
|
2639
|
+
return <R, E>(sa: Stream<R, E, A>): Stream<R, E, B> => {
|
|
2640
|
+
return sa.scanIO(b, (b, a) => IO.succeedNow(f(b, a)));
|
|
2641
|
+
};
|
|
2741
2642
|
}
|
|
2742
2643
|
|
|
2743
2644
|
/**
|
|
2744
2645
|
* Statefully and effectfully maps over the elements of this stream to produce all
|
|
2745
2646
|
* intermediate results of type `B` given an initial B.
|
|
2746
2647
|
*
|
|
2747
|
-
* @tsplus
|
|
2648
|
+
* @tsplus pipeable fncts.io.Stream scanIO
|
|
2748
2649
|
*/
|
|
2749
|
-
export function
|
|
2750
|
-
sa: Stream<R, E, A
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
__tsplusTrace?: string,
|
|
2754
|
-
): Stream<R | R1, E | E1, B> {
|
|
2755
|
-
return Stream.succeedNow(b).concat(sa.mapAccumIO(b, (b, a) => f(b, a).map((b) => [b, b])));
|
|
2650
|
+
export function scanIO<A, R1, E1, B>(b: B, f: (b: B, a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
|
|
2651
|
+
return <R, E>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2652
|
+
return Stream.succeedNow(b).concat(sa.mapAccumIO(b, (b, a) => f(b, a).map((b) => [b, b])));
|
|
2653
|
+
};
|
|
2756
2654
|
}
|
|
2757
2655
|
|
|
2758
2656
|
/**
|
|
2759
2657
|
* Statefully maps over the elements of this stream to produce all
|
|
2760
2658
|
* intermediate results.
|
|
2761
2659
|
*
|
|
2762
|
-
* @tsplus
|
|
2660
|
+
* @tsplus pipeable fncts.io.Stream scanReduce
|
|
2763
2661
|
*/
|
|
2764
|
-
export function
|
|
2765
|
-
fa: Stream<R, E, A
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
): Stream<R, E, B> {
|
|
2769
|
-
return fa.scanReduceIO((b, a) => IO.succeedNow(f(b, a)));
|
|
2662
|
+
export function scanReduce<A extends B, B>(f: (b: B, a: A) => B, __tsplusTrace?: string) {
|
|
2663
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R, E, B> => {
|
|
2664
|
+
return fa.scanReduceIO((b, a) => IO.succeedNow(f(b, a)));
|
|
2665
|
+
};
|
|
2770
2666
|
}
|
|
2771
2667
|
|
|
2772
2668
|
/**
|
|
2773
2669
|
* Statefully and effectfully maps over the elements of this stream to produce
|
|
2774
2670
|
* all intermediate results.
|
|
2775
2671
|
*
|
|
2776
|
-
* @tsplus
|
|
2672
|
+
* @tsplus pipeable fncts.io.Stream scanReduceIO
|
|
2777
2673
|
*/
|
|
2778
|
-
export function
|
|
2779
|
-
fa: Stream<R, E, A
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
)
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
),
|
|
2788
|
-
);
|
|
2674
|
+
export function scanReduceIO<A extends B, R1, E1, B>(f: (b: B, a: A) => IO<R1, E1, B>, __tsplusTrace?: string) {
|
|
2675
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, B> => {
|
|
2676
|
+
return fa.mapAccumIO(Nothing<B>(), (s, a) =>
|
|
2677
|
+
s.match(
|
|
2678
|
+
() => IO.succeedNow([a, Just(a)]),
|
|
2679
|
+
(b) => f(b, a).map((b) => [b, Just(b)]),
|
|
2680
|
+
),
|
|
2681
|
+
);
|
|
2682
|
+
};
|
|
2789
2683
|
}
|
|
2790
2684
|
|
|
2791
2685
|
/**
|
|
@@ -2812,7 +2706,7 @@ function takeLoop<E, A>(n: number, __tsplusTrace?: string): Channel<never, E, Co
|
|
|
2812
2706
|
const taken = inp.take(n);
|
|
2813
2707
|
const left = Math.max(n - taken.length, 0);
|
|
2814
2708
|
if (left > 0) {
|
|
2815
|
-
return Channel.writeNow(taken).
|
|
2709
|
+
return Channel.writeNow(taken).zipRight(takeLoop(left));
|
|
2816
2710
|
} else {
|
|
2817
2711
|
return Channel.writeNow(taken);
|
|
2818
2712
|
}
|
|
@@ -2825,27 +2719,27 @@ function takeLoop<E, A>(n: number, __tsplusTrace?: string): Channel<never, E, Co
|
|
|
2825
2719
|
/**
|
|
2826
2720
|
* Takes the specified number of elements from this stream.
|
|
2827
2721
|
*
|
|
2828
|
-
* @tsplus
|
|
2722
|
+
* @tsplus pipeable fncts.io.Stream take
|
|
2829
2723
|
*/
|
|
2830
|
-
export function
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2724
|
+
export function take(n: number, __tsplusTrace?: string) {
|
|
2725
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> => {
|
|
2726
|
+
if (n <= 0) {
|
|
2727
|
+
return empty;
|
|
2728
|
+
}
|
|
2729
|
+
if (!Number.isInteger(n)) {
|
|
2730
|
+
return halt(new IllegalArgumentError(`${n} should be an integer`, "Stream.take"));
|
|
2731
|
+
}
|
|
2732
|
+
return new Stream(stream.channel.pipeTo(takeLoop(n)));
|
|
2733
|
+
};
|
|
2838
2734
|
}
|
|
2839
2735
|
|
|
2840
2736
|
/**
|
|
2841
|
-
* @tsplus
|
|
2737
|
+
* @tsplus pipeable fncts.io.Stream takeUntilIO
|
|
2842
2738
|
*/
|
|
2843
|
-
export function
|
|
2844
|
-
ma: Stream<R, E, A
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
): Stream<R | R1, E | E1, A> {
|
|
2848
|
-
return new Stream(ma.channel.pipeTo(takeUntilIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
|
|
2739
|
+
export function takeUntilIO<A, R1, E1>(f: (a: A) => IO<R1, E1, boolean>, __tsplusTrace?: string) {
|
|
2740
|
+
return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
2741
|
+
return new Stream(ma.channel.pipeTo(takeUntilIOLoop(Iterable.empty<A>()[Symbol.iterator](), f)));
|
|
2742
|
+
};
|
|
2849
2743
|
}
|
|
2850
2744
|
|
|
2851
2745
|
function takeUntilIOLoop<E, A, R1, E1>(
|
|
@@ -2880,7 +2774,7 @@ function takeUntilLoop<R, E, A>(
|
|
|
2880
2774
|
const taken = chunk.takeWhile(p.invert);
|
|
2881
2775
|
const last = chunk.drop(taken.length).take(1);
|
|
2882
2776
|
if (last.isEmpty) {
|
|
2883
|
-
return Channel.writeNow(taken).
|
|
2777
|
+
return Channel.writeNow(taken).zipRight(takeUntilLoop<R, E, A>(p));
|
|
2884
2778
|
} else {
|
|
2885
2779
|
return Channel.writeNow(taken.concat(last));
|
|
2886
2780
|
}
|
|
@@ -2894,21 +2788,21 @@ function takeUntilLoop<R, E, A>(
|
|
|
2894
2788
|
* Takes all elements of the stream until the specified predicate evaluates
|
|
2895
2789
|
* to `true`.
|
|
2896
2790
|
*
|
|
2897
|
-
* @tsplus
|
|
2791
|
+
* @tsplus pipeable fncts.io.Stream takeUntil
|
|
2898
2792
|
*/
|
|
2899
|
-
export function
|
|
2900
|
-
return
|
|
2793
|
+
export function takeUntil<A>(p: Predicate<A>, __tsplusTrace?: string) {
|
|
2794
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R, E, A> => {
|
|
2795
|
+
return new Stream(fa.channel.pipeTo(takeUntilLoop(p)));
|
|
2796
|
+
};
|
|
2901
2797
|
}
|
|
2902
2798
|
|
|
2903
2799
|
/**
|
|
2904
|
-
* @tsplus
|
|
2800
|
+
* @tsplus pipeable fncts.io.Stream tap
|
|
2905
2801
|
*/
|
|
2906
|
-
export function
|
|
2907
|
-
ma: Stream<R, E, A
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
): Stream<R | R1, E | E1, A> {
|
|
2911
|
-
return ma.mapIO((a) => f(a).as(a));
|
|
2802
|
+
export function tap<A, R1, E1>(f: (a: A) => IO<R1, E1, any>, __tsplusTrace?: string) {
|
|
2803
|
+
return <R, E>(ma: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
2804
|
+
return ma.mapIO((a) => f(a).as(a));
|
|
2805
|
+
};
|
|
2912
2806
|
}
|
|
2913
2807
|
|
|
2914
2808
|
/**
|
|
@@ -2917,17 +2811,18 @@ export function tap_<R, E, A, R1, E1>(
|
|
|
2917
2811
|
* tokens up to a `units + burst` threshold. Chunks that do not meet the bandwidth constraints are dropped.
|
|
2918
2812
|
* The weight of each chunk is determined by the `costFn` function.
|
|
2919
2813
|
*
|
|
2920
|
-
* @tsplus
|
|
2814
|
+
* @tsplus pipeable fncts.io.Stream throttleEnforce
|
|
2921
2815
|
*/
|
|
2922
|
-
export function
|
|
2923
|
-
sa: Stream<R, E, A>,
|
|
2816
|
+
export function throttleEnforce<A>(
|
|
2924
2817
|
costFn: (chunk: Conc<A>) => number,
|
|
2925
2818
|
units: number,
|
|
2926
2819
|
duration: number,
|
|
2927
2820
|
burst = 0,
|
|
2928
2821
|
__tsplusTrace?: string,
|
|
2929
|
-
)
|
|
2930
|
-
return sa
|
|
2822
|
+
) {
|
|
2823
|
+
return <R, E>(sa: Stream<R, E, A>): Stream<R, E, A> => {
|
|
2824
|
+
return sa.throttleEnforceIO((chunk) => IO.succeedNow(costFn(chunk)), units, duration, burst);
|
|
2825
|
+
};
|
|
2931
2826
|
}
|
|
2932
2827
|
|
|
2933
2828
|
function throttleEnforceIOLoop<E, A, R1, E1>(
|
|
@@ -2948,12 +2843,10 @@ function throttleEnforceIOLoop<E, A, R1, E1>(
|
|
|
2948
2843
|
const available = (() => {
|
|
2949
2844
|
const sum = tokens + cycles * units;
|
|
2950
2845
|
const max = units + burst < 0 ? Number.MAX_SAFE_INTEGER : units + burst;
|
|
2951
|
-
|
|
2952
2846
|
return sum < 0 ? max : Math.min(sum, max);
|
|
2953
2847
|
})();
|
|
2954
|
-
|
|
2955
2848
|
return weight <= available
|
|
2956
|
-
? Channel.writeNow(inp).
|
|
2849
|
+
? Channel.writeNow(inp).zipRight(
|
|
2957
2850
|
throttleEnforceIOLoop<E, A, R1, E1>(costFn, units, duration, burst, available - weight, current),
|
|
2958
2851
|
)
|
|
2959
2852
|
: throttleEnforceIOLoop<E, A, R1, E1>(costFn, units, duration, burst, available - weight, current);
|
|
@@ -2970,39 +2863,38 @@ function throttleEnforceIOLoop<E, A, R1, E1>(
|
|
|
2970
2863
|
* tokens up to a `units + burst` threshold. Chunks that do not meet the bandwidth constraints are dropped.
|
|
2971
2864
|
* The weight of each chunk is determined by the `costFn` effectful function.
|
|
2972
2865
|
*
|
|
2973
|
-
* @tsplus
|
|
2866
|
+
* @tsplus pipeable fncts.io.Stream throttleEnforceIO
|
|
2974
2867
|
*/
|
|
2975
|
-
export function
|
|
2976
|
-
sa: Stream<R, E, A>,
|
|
2868
|
+
export function throttleEnforceIO<A, R1, E1>(
|
|
2977
2869
|
costFn: (chunk: Conc<A>) => IO<R1, E1, number>,
|
|
2978
2870
|
units: number,
|
|
2979
2871
|
duration: number,
|
|
2980
2872
|
burst = 0,
|
|
2981
2873
|
__tsplusTrace?: string,
|
|
2982
|
-
)
|
|
2983
|
-
return
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2874
|
+
) {
|
|
2875
|
+
return <R, E>(sa: Stream<R, E, A>): Stream<R | R1, E | E1, A> => {
|
|
2876
|
+
return new Stream(
|
|
2877
|
+
Channel.fromIO(Clock.currentTime).flatMap((current) =>
|
|
2878
|
+
sa.channel.pipeTo(throttleEnforceIOLoop(costFn, units, duration, burst, units, current)),
|
|
2879
|
+
),
|
|
2880
|
+
);
|
|
2881
|
+
};
|
|
2988
2882
|
}
|
|
2989
2883
|
|
|
2990
2884
|
/**
|
|
2991
2885
|
* Converts the stream to a managed hub of chunks. After the managed hub is used,
|
|
2992
2886
|
* the hub will never again produce values and should be discarded.
|
|
2993
2887
|
*
|
|
2994
|
-
* @tsplus
|
|
2888
|
+
* @tsplus pipeable fncts.io.Stream toHub
|
|
2995
2889
|
*/
|
|
2996
|
-
export function
|
|
2997
|
-
stream: Stream<R, E, A
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
)
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
return hub;
|
|
3005
|
-
});
|
|
2890
|
+
export function toHub(capacity: number, __tsplusTrace?: string) {
|
|
2891
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Hub<Take<E, A>>> => {
|
|
2892
|
+
return Do((Δ) => {
|
|
2893
|
+
const hub = Δ(IO.acquireRelease(Hub.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
|
|
2894
|
+
Δ(stream.runIntoHubScoped(hub).fork);
|
|
2895
|
+
return hub;
|
|
2896
|
+
});
|
|
2897
|
+
};
|
|
3006
2898
|
}
|
|
3007
2899
|
|
|
3008
2900
|
/**
|
|
@@ -3023,63 +2915,55 @@ export function toPull<R, E, A>(
|
|
|
3023
2915
|
* Converts the stream to a managed queue of chunks. After the managed queue is used,
|
|
3024
2916
|
* the queue will never again produce values and should be discarded.
|
|
3025
2917
|
*
|
|
3026
|
-
* @tsplus
|
|
2918
|
+
* @tsplus pipeable fncts.io.Stream toQueue
|
|
3027
2919
|
*/
|
|
3028
|
-
export function
|
|
3029
|
-
stream: Stream<R, E, A
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
)
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
return queue;
|
|
3037
|
-
});
|
|
2920
|
+
export function toQueue(capacity = 2, __tsplusTrace?: string) {
|
|
2921
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Queue.Dequeue<Take<E, A>>> => {
|
|
2922
|
+
return Do((Δ) => {
|
|
2923
|
+
const queue = Δ(IO.acquireRelease(Queue.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
|
|
2924
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
|
2925
|
+
return queue;
|
|
2926
|
+
});
|
|
2927
|
+
};
|
|
3038
2928
|
}
|
|
3039
2929
|
|
|
3040
2930
|
/**
|
|
3041
|
-
* @tsplus
|
|
2931
|
+
* @tsplus pipeable fncts.io.Stream toQueueDropping
|
|
3042
2932
|
*/
|
|
3043
|
-
export function
|
|
3044
|
-
stream: Stream<R, E, A
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
)
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
return queue;
|
|
3052
|
-
});
|
|
2933
|
+
export function toQueueDropping(capacity = 2, __tsplusTrace?: string) {
|
|
2934
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Queue.Dequeue<Take<E, A>>> => {
|
|
2935
|
+
return Do((Δ) => {
|
|
2936
|
+
const queue = Δ(IO.acquireRelease(Queue.makeDropping<Take<E, A>>(capacity), (_) => _.shutdown));
|
|
2937
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
|
2938
|
+
return queue;
|
|
2939
|
+
});
|
|
2940
|
+
};
|
|
3053
2941
|
}
|
|
3054
2942
|
|
|
3055
2943
|
/**
|
|
3056
|
-
* @tsplus
|
|
2944
|
+
* @tsplus pipeable fncts.io.Stream toQueueOfElements
|
|
3057
2945
|
*/
|
|
3058
|
-
export function
|
|
3059
|
-
stream: Stream<R, E, A>,
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
)
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
return queue;
|
|
3067
|
-
});
|
|
2946
|
+
export function toQueueOfElements(capacity = 2, __tsplusTrace?: string) {
|
|
2947
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Queue.Dequeue<Exit<Maybe<E>, A>>> => {
|
|
2948
|
+
return Do((Δ) => {
|
|
2949
|
+
const queue = Δ(IO.acquireRelease(Queue.makeBounded<Exit<Maybe<E>, A>>(capacity), (_) => _.shutdown));
|
|
2950
|
+
Δ(stream.runIntoElementsScoped(queue).fork);
|
|
2951
|
+
return queue;
|
|
2952
|
+
});
|
|
2953
|
+
};
|
|
3068
2954
|
}
|
|
3069
2955
|
|
|
3070
2956
|
/**
|
|
3071
|
-
* @tsplus
|
|
2957
|
+
* @tsplus pipeable fncts.io.Stream toQueueSliding
|
|
3072
2958
|
*/
|
|
3073
|
-
export function
|
|
3074
|
-
stream: Stream<R, E, A
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
)
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
return queue;
|
|
3082
|
-
});
|
|
2959
|
+
export function toQueueSliding(capacity = 2, __tsplusTrace?: string) {
|
|
2960
|
+
return <R, E, A>(stream: Stream<R, E, A>): IO<R | Scope, never, Queue.Dequeue<Take<E, A>>> => {
|
|
2961
|
+
return Do((Δ) => {
|
|
2962
|
+
const queue = Δ(IO.acquireRelease(Queue.makeSliding<Take<E, A>>(capacity), (_) => _.shutdown));
|
|
2963
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
|
2964
|
+
return queue;
|
|
2965
|
+
});
|
|
2966
|
+
};
|
|
3083
2967
|
}
|
|
3084
2968
|
|
|
3085
2969
|
/**
|
|
@@ -3216,59 +3100,58 @@ export function zipWithIndex_<R, E, A>(
|
|
|
3216
3100
|
* that emitted elements that are not the last value in chunks will never be
|
|
3217
3101
|
* used for zipping.
|
|
3218
3102
|
*
|
|
3219
|
-
* @tsplus
|
|
3103
|
+
* @tsplus pipeable fncts.io.Stream zipWithLatest
|
|
3220
3104
|
*/
|
|
3221
|
-
export function
|
|
3222
|
-
fa: Stream<R, E, A
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
|
|
3105
|
+
export function zipWithLatest<A, R1, E1, B, C>(fb: Stream<R1, E1, B>, f: (a: A, b: B) => C, __tsplusTrace?: string) {
|
|
3106
|
+
return <R, E>(fa: Stream<R, E, A>): Stream<R | R1, E | E1, C> => {
|
|
3107
|
+
function pullNonEmpty<R, E, A>(pull: IO<R, Maybe<E>, Conc<A>>, __tsplusTrace?: string): IO<R, Maybe<E>, Conc<A>> {
|
|
3108
|
+
return pull.flatMap((chunk) => (chunk.isNonEmpty ? pullNonEmpty(pull) : IO.succeedNow(chunk)));
|
|
3109
|
+
}
|
|
3110
|
+
return Stream.fromPull(
|
|
3111
|
+
Do((Δ) => {
|
|
3112
|
+
const left = Δ(fa.toPull.map(pullNonEmpty));
|
|
3113
|
+
const right = Δ(fb.toPull.map(pullNonEmpty));
|
|
3114
|
+
return Δ(
|
|
3115
|
+
Stream.fromIOMaybe(
|
|
3116
|
+
left.raceWith(
|
|
3117
|
+
right,
|
|
3118
|
+
(leftDone: Exit<Maybe<E | E1>, Conc<A>>, rightFiber) =>
|
|
3119
|
+
IO.fromExitNow(leftDone).zipWith(rightFiber.join, (l, r) => tuple(l, r, true)),
|
|
3120
|
+
(rightDone, leftFiber) => IO.fromExitNow(rightDone).zipWith(leftFiber.join, (r, l) => tuple(l, r, false)),
|
|
3121
|
+
),
|
|
3122
|
+
).flatMap(([l, r, leftFirst]) =>
|
|
3123
|
+
Stream.fromIO(Ref.make(tuple(l.unsafeGet(l.length - 1), r.unsafeGet(r.length - 1)))).flatMap((latest) =>
|
|
3124
|
+
Stream.fromChunk(
|
|
3125
|
+
leftFirst
|
|
3126
|
+
? r.map((b) => f(l.unsafeGet(l.length - 1), b))
|
|
3127
|
+
: l.map((a) => f(a, r.unsafeGet(r.length - 1))),
|
|
3128
|
+
).concat(
|
|
3129
|
+
Stream.repeatIOMaybe(left)
|
|
3130
|
+
.mergeEither(Stream.repeatIOMaybe(right))
|
|
3131
|
+
.mapIO((ab) =>
|
|
3132
|
+
ab.match(
|
|
3133
|
+
(leftChunk) =>
|
|
3134
|
+
latest.modify(([_, rightLatest]) =>
|
|
3135
|
+
tuple(
|
|
3136
|
+
leftChunk.map((a) => f(a, rightLatest)),
|
|
3137
|
+
tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
|
|
3138
|
+
),
|
|
3256
3139
|
),
|
|
3257
|
-
)
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3140
|
+
(rightChunk) =>
|
|
3141
|
+
latest.modify(([leftLatest, _]) =>
|
|
3142
|
+
tuple(
|
|
3143
|
+
rightChunk.map((b) => f(leftLatest, b)),
|
|
3144
|
+
tuple(leftLatest, rightChunk.unsafeGet(rightChunk.length - 1)),
|
|
3145
|
+
),
|
|
3263
3146
|
),
|
|
3264
|
-
|
|
3265
|
-
)
|
|
3266
|
-
|
|
3267
|
-
|
|
3147
|
+
),
|
|
3148
|
+
)
|
|
3149
|
+
.flatMap(Stream.fromChunkNow),
|
|
3150
|
+
),
|
|
3268
3151
|
),
|
|
3269
|
-
),
|
|
3270
|
-
)
|
|
3271
|
-
)
|
|
3272
|
-
|
|
3273
|
-
|
|
3152
|
+
).toPull,
|
|
3153
|
+
);
|
|
3154
|
+
}),
|
|
3155
|
+
);
|
|
3156
|
+
};
|
|
3274
3157
|
}
|