@fncts/io 0.0.1
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 +27 -0
- package/Cached/definition.d.ts +18 -0
- package/Cached/internal.d.ts +10 -0
- package/Cached.d.ts +3 -0
- package/CancellerState.d.ts +42 -0
- package/Channel/ChildExecutorDecision/api.d.ts +6 -0
- package/Channel/ChildExecutorDecision/definition.d.ts +35 -0
- package/Channel/ChildExecutorDecision.d.ts +2 -0
- package/Channel/UpstreamPullRequest/api.d.ts +16 -0
- package/Channel/UpstreamPullRequest/definition.d.ts +20 -0
- package/Channel/UpstreamPullRequest.d.ts +2 -0
- package/Channel/UpstreamPullStrategy/definition.d.ts +26 -0
- package/Channel/UpstreamPullStrategy.d.ts +1 -0
- package/Channel/api/interruptWhen.d.ts +23 -0
- package/Channel/api/mapOutIOC.d.ts +8 -0
- package/Channel/api/mergeAll.d.ts +7 -0
- package/Channel/api/mergeAllUnboundedWith.d.ts +6 -0
- package/Channel/api/mergeAllWith.d.ts +11 -0
- package/Channel/api/mergeMap.d.ts +7 -0
- package/Channel/api/mergeWith.d.ts +14 -0
- package/Channel/api/run.d.ts +8 -0
- package/Channel/api/runCollect.d.ts +8 -0
- package/Channel/api/runDrain.d.ts +8 -0
- package/Channel/api/runScoped.d.ts +10 -0
- package/Channel/api/toPull.d.ts +11 -0
- package/Channel/api/zipC.d.ts +16 -0
- package/Channel/api.d.ts +420 -0
- package/Channel/core-api.d.ts +78 -0
- package/Channel/definition.d.ts +164 -0
- package/Channel/internal/AsyncInputConsumer.d.ts +8 -0
- package/Channel/internal/AsyncInputProducer.d.ts +8 -0
- package/Channel/internal/ChannelExecutor.d.ts +51 -0
- package/Channel/internal/ChannelState.d.ts +44 -0
- package/Channel/internal/MergeDecision.d.ts +51 -0
- package/Channel/internal/MergeState.d.ts +50 -0
- package/Channel/internal/SingleProducerAsyncInput.d.ts +71 -0
- package/Channel.d.ts +3 -0
- package/Clock/api.d.ts +11 -0
- package/Clock/definition.d.ts +14 -0
- package/Clock/live.d.ts +7 -0
- package/Clock.d.ts +3 -0
- package/Console/api.d.ts +11 -0
- package/Console/definition.d.ts +15 -0
- package/Console/live.d.ts +11 -0
- package/Console.d.ts +3 -0
- package/Fiber/FiberContext.d.ts +145 -0
- package/Fiber/api/await.d.ts +8 -0
- package/Fiber/api/awaitAll.d.ts +10 -0
- package/Fiber/api/children.d.ts +8 -0
- package/Fiber/api/collectAll.d.ts +11 -0
- package/Fiber/api/evalOn.d.ts +7 -0
- package/Fiber/api/evalOnIO.d.ts +9 -0
- package/Fiber/api/fromIO.d.ts +8 -0
- package/Fiber/api/id.d.ts +7 -0
- package/Fiber/api/inheritRefs.d.ts +7 -0
- package/Fiber/api/interrupt.d.ts +11 -0
- package/Fiber/api/interruptAll.d.ts +15 -0
- package/Fiber/api/interruptAs.d.ts +9 -0
- package/Fiber/api/interruptFork.d.ts +10 -0
- package/Fiber/api/join.d.ts +12 -0
- package/Fiber/api/joinAll.d.ts +11 -0
- package/Fiber/api/location.d.ts +7 -0
- package/Fiber/api/mapFiber.d.ts +9 -0
- package/Fiber/api/mapIO.d.ts +14 -0
- package/Fiber/api/poll.d.ts +9 -0
- package/Fiber/api/zipWith.d.ts +9 -0
- package/Fiber/constructors.d.ts +29 -0
- package/Fiber/definition.d.ts +102 -0
- package/Fiber.d.ts +23 -0
- package/FiberDescriptor.d.ts +18 -0
- package/FiberRef/api/locallyScoped.d.ts +9 -0
- package/FiberRef/api/locallyScopedWith.d.ts +9 -0
- package/FiberRef/api.d.ts +89 -0
- package/FiberRef/constructors.d.ts +63 -0
- package/FiberRef/definition.d.ts +41 -0
- package/FiberRef.d.ts +5 -0
- package/FiberRefs/api.d.ts +15 -0
- package/FiberRefs/definition.d.ts +14 -0
- package/FiberRefs/join.d.ts +8 -0
- package/FiberRefs.d.ts +3 -0
- package/FiberScope/constructors.d.ts +16 -0
- package/FiberScope/definition.d.ts +24 -0
- package/FiberScope.d.ts +2 -0
- package/FiberState/api.d.ts +7 -0
- package/FiberState/constructors.d.ts +22 -0
- package/FiberState/definition.d.ts +38 -0
- package/FiberState.d.ts +3 -0
- package/FiberStatus/constructors.d.ts +22 -0
- package/FiberStatus/definition.d.ts +59 -0
- package/FiberStatus.d.ts +2 -0
- package/Future/api.d.ts +113 -0
- package/Future/constructors.d.ts +21 -0
- package/Future/definition.d.ts +27 -0
- package/Future.d.ts +3 -0
- package/Hub/api.d.ts +191 -0
- package/Hub/definition.d.ts +89 -0
- package/Hub/internal.d.ts +97 -0
- package/Hub.d.ts +2 -0
- package/IO/api/acquireRelease.d.ts +10 -0
- package/IO/api/acquireReleaseExit.d.ts +11 -0
- package/IO/api/acquireReleaseInterruptible.d.ts +9 -0
- package/IO/api/acquireReleaseInterruptibleExit.d.ts +10 -0
- package/IO/api/addFinalizer.d.ts +9 -0
- package/IO/api/addFinalizerExit.d.ts +9 -0
- package/IO/api/bracket.d.ts +26 -0
- package/IO/api/bracketExit.d.ts +14 -0
- package/IO/api/clockWith.d.ts +12 -0
- package/IO/api/concurrency.d.ts +35 -0
- package/IO/api/concurrentFinalizers.d.ts +8 -0
- package/IO/api/consoleWith.d.ts +12 -0
- package/IO/api/core-scope.d.ts +77 -0
- package/IO/api/environment.d.ts +74 -0
- package/IO/api/foreachC.d.ts +29 -0
- package/IO/api/foreachExec.d.ts +12 -0
- package/IO/api/forkAll.d.ts +10 -0
- package/IO/api/forkIn.d.ts +9 -0
- package/IO/api/forkScoped.d.ts +8 -0
- package/IO/api/fulfill.d.ts +10 -0
- package/IO/api/interrupt.d.ts +108 -0
- package/IO/api/memoize.d.ts +6 -0
- package/IO/api/onExit.d.ts +7 -0
- package/IO/api/once.d.ts +6 -0
- package/IO/api/provideLayer.d.ts +7 -0
- package/IO/api/provideSomeLayer.d.ts +13 -0
- package/IO/api/race.d.ts +13 -0
- package/IO/api/raceFirst.d.ts +16 -0
- package/IO/api/randomWith.d.ts +12 -0
- package/IO/api/repeat.d.ts +20 -0
- package/IO/api/retry.d.ts +19 -0
- package/IO/api/schedule.d.ts +13 -0
- package/IO/api/scope.d.ts +8 -0
- package/IO/api/scopeWith.d.ts +8 -0
- package/IO/api/scoped.d.ts +14 -0
- package/IO/api/sequenceT.d.ts +10 -0
- package/IO/api/sleep.d.ts +6 -0
- package/IO/api/stateful.d.ts +10 -0
- package/IO/api/withChildren.d.ts +7 -0
- package/IO/api/withFinalizer.d.ts +8 -0
- package/IO/api/withFinalizerExit.d.ts +9 -0
- package/IO/api/withRuntimeConfig.d.ts +10 -0
- package/IO/api/zipC.d.ts +6 -0
- package/IO/api/zipWithC.d.ts +9 -0
- package/IO/api.d.ts +1130 -0
- package/IO/definition.d.ts +338 -0
- package/IO/runtime.d.ts +43 -0
- package/IO.d.ts +47 -0
- package/IOEnv/definition.d.ts +16 -0
- package/IOEnv/live.d.ts +6 -0
- package/IOEnv/services.d.ts +8 -0
- package/IOEnv.d.ts +3 -0
- package/IOSpec.d.ts +3 -0
- package/InterruptStatus/constructors.d.ts +16 -0
- package/InterruptStatus/definition.d.ts +12 -0
- package/InterruptStatus.d.ts +2 -0
- package/Layer/MemoMap.d.ts +43 -0
- package/Layer/api.d.ts +209 -0
- package/Layer/definition.d.ts +75 -0
- package/Layer.d.ts +3 -0
- package/LogLevel.d.ts +74 -0
- package/LogSpan.d.ts +14 -0
- package/Logger/api.d.ts +14 -0
- package/Logger/constructors.d.ts +10 -0
- package/Logger/definition.d.ts +18 -0
- package/Logger.d.ts +3 -0
- package/Queue/api/dimapIO.d.ts +41 -0
- package/Queue/api/filterInputIO.d.ts +32 -0
- package/Queue/api/filterOutputIO.d.ts +31 -0
- package/Queue/api/operations.d.ts +82 -0
- package/Queue/api/poll.d.ts +9 -0
- package/Queue/api/takeBetween.d.ts +11 -0
- package/Queue/api/zipWithIO.d.ts +44 -0
- package/Queue/api.d.ts +7 -0
- package/Queue/constructors.d.ts +22 -0
- package/Queue/definition.d.ts +129 -0
- package/Queue/internal.d.ts +12 -0
- package/Queue/strategy.d.ts +33 -0
- package/Queue.d.ts +5 -0
- package/Random/api.d.ts +42 -0
- package/Random/definition.d.ts +21 -0
- package/Random/live.d.ts +20 -0
- package/Random.d.ts +3 -0
- package/Ref/Atomic/Atomic.d.ts +18 -0
- package/Ref/Atomic/api.d.ts +53 -0
- package/Ref/Atomic.d.ts +2 -0
- package/Ref/Derived.d.ts +14 -0
- package/Ref/DerivedAll.d.ts +14 -0
- package/Ref/Synchronized/api.d.ts +100 -0
- package/Ref/Synchronized/constructors.d.ts +7 -0
- package/Ref/Synchronized/definition.d.ts +41 -0
- package/Ref/api/collect.d.ts +11 -0
- package/Ref/api/dimap.d.ts +56 -0
- package/Ref/api/filter.d.ts +20 -0
- package/Ref/api/get.d.ts +9 -0
- package/Ref/api/match.d.ts +13 -0
- package/Ref/api/matchAll.d.ts +11 -0
- package/Ref/api/modify.d.ts +79 -0
- package/Ref/api/set.d.ts +10 -0
- package/Ref/api.d.ts +23 -0
- package/Ref/constructors.d.ts +13 -0
- package/Ref/definition.d.ts +74 -0
- package/Ref.d.ts +9 -0
- package/RuntimeConfig.d.ts +34 -0
- package/STM/api/core-api.d.ts +35 -0
- package/STM/api/core-constructors.d.ts +45 -0
- package/STM/api.d.ts +379 -0
- package/STM/definition.d.ts +105 -0
- package/STM/driver.d.ts +15 -0
- package/STM/internal/CommitState.d.ts +47 -0
- package/STM/internal/Entry.d.ts +37 -0
- package/STM/internal/Journal.d.ts +101 -0
- package/STM/internal/TryCommit.d.ts +21 -0
- package/STM/internal/Versioned.d.ts +7 -0
- package/STM.d.ts +5 -0
- package/Schedule/Decision.d.ts +38 -0
- package/Schedule/Driver.d.ts +19 -0
- package/Schedule/Interval.d.ts +71 -0
- package/Schedule/api/driver.d.ts +7 -0
- package/Schedule/api.d.ts +359 -0
- package/Schedule/definition.d.ts +51 -0
- package/Schedule.d.ts +5 -0
- package/Scope/Finalizer/definition.d.ts +26 -0
- package/Scope/Finalizer.d.ts +1 -0
- package/Scope/ReleaseMap/api/releaseAll.d.ts +9 -0
- package/Scope/ReleaseMap/api.d.ts +30 -0
- package/Scope/ReleaseMap/constructors.d.ts +12 -0
- package/Scope/ReleaseMap/definition.d.ts +38 -0
- package/Scope/ReleaseMap.d.ts +3 -0
- package/Scope/api.d.ts +61 -0
- package/Scope/definition.d.ts +32 -0
- package/Scope.d.ts +2 -0
- package/ScopedRef/api.d.ts +9 -0
- package/ScopedRef/definition.d.ts +14 -0
- package/ScopedRef.d.ts +2 -0
- package/Sink/api.d.ts +35 -0
- package/Sink/definition.d.ts +15 -0
- package/Sink.d.ts +2 -0
- package/State/api.d.ts +25 -0
- package/State/definition.d.ts +14 -0
- package/State/internal.d.ts +10 -0
- package/State.d.ts +2 -0
- package/Stream/api/zipAllWith.d.ts +10 -0
- package/Stream/api/zipWith.d.ts +6 -0
- package/Stream/api/zipWithChunks.d.ts +11 -0
- package/Stream/api.d.ts +1087 -0
- package/Stream/definition.d.ts +38 -0
- package/Stream/internal/DebounceState.d.ts +61 -0
- package/Stream/internal/Handoff.d.ts +111 -0
- package/Stream/internal/Pull.d.ts +48 -0
- package/Stream/internal/SinkEndReason.d.ts +39 -0
- package/Stream/internal/Take.d.ts +128 -0
- package/Stream/internal/util.d.ts +3 -0
- package/Stream.d.ts +2 -0
- package/Supervisor/api.d.ts +10 -0
- package/Supervisor/constructors.d.ts +34 -0
- package/Supervisor/definition.d.ts +35 -0
- package/Supervisor.d.ts +3 -0
- package/TExit/constructors.d.ts +32 -0
- package/TExit/definition.d.ts +90 -0
- package/TExit.d.ts +2 -0
- package/TFuture/api.d.ts +29 -0
- package/TFuture/constructors.d.ts +16 -0
- package/TFuture/definition.d.ts +22 -0
- package/TFuture.d.ts +3 -0
- package/TRef/api.d.ts +85 -0
- package/TRef/constructors.d.ts +32 -0
- package/TRef/definition.d.ts +87 -0
- package/TRef.d.ts +3 -0
- package/TSemaphore/api.d.ts +38 -0
- package/TSemaphore/constructors.d.ts +13 -0
- package/TSemaphore/definition.d.ts +20 -0
- package/TSemaphore.d.ts +3 -0
- package/TxnId.d.ts +12 -0
- package/_cjs/Cached/api.cjs +85 -0
- package/_cjs/Cached/api.cjs.map +1 -0
- package/_cjs/Cached/definition.cjs +33 -0
- package/_cjs/Cached/definition.cjs.map +1 -0
- package/_cjs/Cached/internal.cjs +18 -0
- package/_cjs/Cached/internal.cjs.map +1 -0
- package/_cjs/Cached.cjs +45 -0
- package/_cjs/Cached.cjs.map +1 -0
- package/_cjs/CancellerState.cjs +64 -0
- package/_cjs/CancellerState.cjs.map +1 -0
- package/_cjs/Channel/ChildExecutorDecision/api.cjs +29 -0
- package/_cjs/Channel/ChildExecutorDecision/api.cjs.map +1 -0
- package/_cjs/Channel/ChildExecutorDecision/definition.cjs +39 -0
- package/_cjs/Channel/ChildExecutorDecision/definition.cjs.map +1 -0
- package/_cjs/Channel/ChildExecutorDecision.cjs +32 -0
- package/_cjs/Channel/ChildExecutorDecision.cjs.map +1 -0
- package/_cjs/Channel/UpstreamPullRequest/api.cjs +44 -0
- package/_cjs/Channel/UpstreamPullRequest/api.cjs.map +1 -0
- package/_cjs/Channel/UpstreamPullRequest/definition.cjs +29 -0
- package/_cjs/Channel/UpstreamPullRequest/definition.cjs.map +1 -0
- package/_cjs/Channel/UpstreamPullRequest.cjs +32 -0
- package/_cjs/Channel/UpstreamPullRequest.cjs.map +1 -0
- package/_cjs/Channel/UpstreamPullStrategy/definition.cjs +33 -0
- package/_cjs/Channel/UpstreamPullStrategy/definition.cjs.map +1 -0
- package/_cjs/Channel/UpstreamPullStrategy.cjs +19 -0
- package/_cjs/Channel/UpstreamPullStrategy.cjs.map +1 -0
- package/_cjs/Channel/api/interruptWhen.cjs +54 -0
- package/_cjs/Channel/api/interruptWhen.cjs.map +1 -0
- package/_cjs/Channel/api/mapOutIOC.cjs +63 -0
- package/_cjs/Channel/api/mapOutIOC.cjs.map +1 -0
- package/_cjs/Channel/api/mergeAll.cjs +20 -0
- package/_cjs/Channel/api/mergeAll.cjs.map +1 -0
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +20 -0
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs.map +1 -0
- package/_cjs/Channel/api/mergeAllWith.cjs +97 -0
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -0
- package/_cjs/Channel/api/mergeMap.cjs +22 -0
- package/_cjs/Channel/api/mergeMap.cjs.map +1 -0
- package/_cjs/Channel/api/mergeWith.cjs +98 -0
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -0
- package/_cjs/Channel/api/run.cjs +24 -0
- package/_cjs/Channel/api/run.cjs.map +1 -0
- package/_cjs/Channel/api/runCollect.cjs +22 -0
- package/_cjs/Channel/api/runCollect.cjs.map +1 -0
- package/_cjs/Channel/api/runDrain.cjs +24 -0
- package/_cjs/Channel/api/runDrain.cjs.map +1 -0
- package/_cjs/Channel/api/runScoped.cjs +70 -0
- package/_cjs/Channel/api/runScoped.cjs.map +1 -0
- package/_cjs/Channel/api/toPull.cjs +63 -0
- package/_cjs/Channel/api/toPull.cjs.map +1 -0
- package/_cjs/Channel/api/zipC.cjs +51 -0
- package/_cjs/Channel/api/zipC.cjs.map +1 -0
- package/_cjs/Channel/api.cjs +875 -0
- package/_cjs/Channel/api.cjs.map +1 -0
- package/_cjs/Channel/core-api.cjs +149 -0
- package/_cjs/Channel/core-api.cjs.map +1 -0
- package/_cjs/Channel/definition.cjs +262 -0
- package/_cjs/Channel/definition.cjs.map +1 -0
- package/_cjs/Channel/internal/AsyncInputConsumer.cjs +6 -0
- package/_cjs/Channel/internal/AsyncInputConsumer.cjs.map +1 -0
- package/_cjs/Channel/internal/AsyncInputProducer.cjs +6 -0
- package/_cjs/Channel/internal/AsyncInputProducer.cjs.map +1 -0
- package/_cjs/Channel/internal/ChannelExecutor.cjs +954 -0
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -0
- package/_cjs/Channel/internal/ChannelState.cjs +100 -0
- package/_cjs/Channel/internal/ChannelState.cjs.map +1 -0
- package/_cjs/Channel/internal/MergeDecision.cjs +85 -0
- package/_cjs/Channel/internal/MergeDecision.cjs.map +1 -0
- package/_cjs/Channel/internal/MergeState.cjs +73 -0
- package/_cjs/Channel/internal/MergeState.cjs.map +1 -0
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +276 -0
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -0
- package/_cjs/Channel.cjs +45 -0
- package/_cjs/Channel.cjs.map +1 -0
- package/_cjs/Clock/api.cjs +30 -0
- package/_cjs/Clock/api.cjs.map +1 -0
- package/_cjs/Clock/definition.cjs +27 -0
- package/_cjs/Clock/definition.cjs.map +1 -0
- package/_cjs/Clock/live.cjs +45 -0
- package/_cjs/Clock/live.cjs.map +1 -0
- package/_cjs/Clock.cjs +45 -0
- package/_cjs/Clock.cjs.map +1 -0
- package/_cjs/Console/api.cjs +29 -0
- package/_cjs/Console/api.cjs.map +1 -0
- package/_cjs/Console/definition.cjs +27 -0
- package/_cjs/Console/definition.cjs.map +1 -0
- package/_cjs/Console/live.cjs +40 -0
- package/_cjs/Console/live.cjs.map +1 -0
- package/_cjs/Console.cjs +45 -0
- package/_cjs/Console.cjs.map +1 -0
- package/_cjs/Fiber/FiberContext.cjs +1219 -0
- package/_cjs/Fiber/FiberContext.cjs.map +1 -0
- package/_cjs/Fiber/api/await.cjs +15 -0
- package/_cjs/Fiber/api/await.cjs.map +1 -0
- package/_cjs/Fiber/api/awaitAll.cjs +28 -0
- package/_cjs/Fiber/api/awaitAll.cjs.map +1 -0
- package/_cjs/Fiber/api/children.cjs +15 -0
- package/_cjs/Fiber/api/children.cjs.map +1 -0
- package/_cjs/Fiber/api/collectAll.cjs +61 -0
- package/_cjs/Fiber/api/collectAll.cjs.map +1 -0
- package/_cjs/Fiber/api/evalOn.cjs +28 -0
- package/_cjs/Fiber/api/evalOn.cjs.map +1 -0
- package/_cjs/Fiber/api/evalOnIO.cjs +33 -0
- package/_cjs/Fiber/api/evalOnIO.cjs.map +1 -0
- package/_cjs/Fiber/api/fromIO.cjs +26 -0
- package/_cjs/Fiber/api/fromIO.cjs.map +1 -0
- package/_cjs/Fiber/api/id.cjs +15 -0
- package/_cjs/Fiber/api/id.cjs.map +1 -0
- package/_cjs/Fiber/api/inheritRefs.cjs +15 -0
- package/_cjs/Fiber/api/inheritRefs.cjs.map +1 -0
- package/_cjs/Fiber/api/interrupt.cjs +27 -0
- package/_cjs/Fiber/api/interrupt.cjs.map +1 -0
- package/_cjs/Fiber/api/interruptAll.cjs +42 -0
- package/_cjs/Fiber/api/interruptAll.cjs.map +1 -0
- package/_cjs/Fiber/api/interruptAs.cjs +15 -0
- package/_cjs/Fiber/api/interruptAs.cjs.map +1 -0
- package/_cjs/Fiber/api/interruptFork.cjs +28 -0
- package/_cjs/Fiber/api/interruptFork.cjs.map +1 -0
- package/_cjs/Fiber/api/join.cjs +29 -0
- package/_cjs/Fiber/api/join.cjs.map +1 -0
- package/_cjs/Fiber/api/joinAll.cjs +30 -0
- package/_cjs/Fiber/api/joinAll.cjs.map +1 -0
- package/_cjs/Fiber/api/location.cjs +21 -0
- package/_cjs/Fiber/api/location.cjs.map +1 -0
- package/_cjs/Fiber/api/mapFiber.cjs +31 -0
- package/_cjs/Fiber/api/mapFiber.cjs.map +1 -0
- package/_cjs/Fiber/api/mapIO.cjs +57 -0
- package/_cjs/Fiber/api/mapIO.cjs.map +1 -0
- package/_cjs/Fiber/api/poll.cjs +15 -0
- package/_cjs/Fiber/api/poll.cjs.map +1 -0
- package/_cjs/Fiber/api/zipWith.cjs +50 -0
- package/_cjs/Fiber/api/zipWith.cjs.map +1 -0
- package/_cjs/Fiber/constructors.cjs +70 -0
- package/_cjs/Fiber/constructors.cjs.map +1 -0
- package/_cjs/Fiber/definition.cjs +48 -0
- package/_cjs/Fiber/definition.cjs.map +1 -0
- package/_cjs/Fiber.cjs +305 -0
- package/_cjs/Fiber.cjs.map +1 -0
- package/_cjs/FiberDescriptor.cjs +26 -0
- package/_cjs/FiberDescriptor.cjs.map +1 -0
- package/_cjs/FiberRef/api/locallyScoped.cjs +26 -0
- package/_cjs/FiberRef/api/locallyScoped.cjs.map +1 -0
- package/_cjs/FiberRef/api/locallyScopedWith.cjs +24 -0
- package/_cjs/FiberRef/api/locallyScopedWith.cjs.map +1 -0
- package/_cjs/FiberRef/api.cjs +182 -0
- package/_cjs/FiberRef/api.cjs.map +1 -0
- package/_cjs/FiberRef/constructors.cjs +116 -0
- package/_cjs/FiberRef/constructors.cjs.map +1 -0
- package/_cjs/FiberRef/definition.cjs +76 -0
- package/_cjs/FiberRef/definition.cjs.map +1 -0
- package/_cjs/FiberRef.cjs +71 -0
- package/_cjs/FiberRef.cjs.map +1 -0
- package/_cjs/FiberRefs/api.cjs +31 -0
- package/_cjs/FiberRefs/api.cjs.map +1 -0
- package/_cjs/FiberRefs/definition.cjs +24 -0
- package/_cjs/FiberRefs/definition.cjs.map +1 -0
- package/_cjs/FiberRefs/join.cjs +110 -0
- package/_cjs/FiberRefs/join.cjs.map +1 -0
- package/_cjs/FiberRefs.cjs +45 -0
- package/_cjs/FiberRefs.cjs.map +1 -0
- package/_cjs/FiberScope/constructors.cjs +28 -0
- package/_cjs/FiberScope/constructors.cjs.map +1 -0
- package/_cjs/FiberScope/definition.cjs +60 -0
- package/_cjs/FiberScope/definition.cjs.map +1 -0
- package/_cjs/FiberScope.cjs +32 -0
- package/_cjs/FiberScope.cjs.map +1 -0
- package/_cjs/FiberState/api.cjs +26 -0
- package/_cjs/FiberState/api.cjs.map +1 -0
- package/_cjs/FiberState/constructors.cjs +44 -0
- package/_cjs/FiberState/constructors.cjs.map +1 -0
- package/_cjs/FiberState/definition.cjs +46 -0
- package/_cjs/FiberState/definition.cjs.map +1 -0
- package/_cjs/FiberState.cjs +45 -0
- package/_cjs/FiberState.cjs.map +1 -0
- package/_cjs/FiberStatus/constructors.cjs +42 -0
- package/_cjs/FiberStatus/constructors.cjs.map +1 -0
- package/_cjs/FiberStatus/definition.cjs +107 -0
- package/_cjs/FiberStatus/definition.cjs.map +1 -0
- package/_cjs/FiberStatus.cjs +32 -0
- package/_cjs/FiberStatus.cjs.map +1 -0
- package/_cjs/Future/api.cjs +292 -0
- package/_cjs/Future/api.cjs.map +1 -0
- package/_cjs/Future/constructors.cjs +55 -0
- package/_cjs/Future/constructors.cjs.map +1 -0
- package/_cjs/Future/definition.cjs +45 -0
- package/_cjs/Future/definition.cjs.map +1 -0
- package/_cjs/Future.cjs +45 -0
- package/_cjs/Future.cjs.map +1 -0
- package/_cjs/Hub/api.cjs +456 -0
- package/_cjs/Hub/api.cjs.map +1 -0
- package/_cjs/Hub/definition.cjs +28 -0
- package/_cjs/Hub/definition.cjs.map +1 -0
- package/_cjs/Hub/internal.cjs +449 -0
- package/_cjs/Hub/internal.cjs.map +1 -0
- package/_cjs/Hub.cjs +32 -0
- package/_cjs/Hub.cjs.map +1 -0
- package/_cjs/IO/api/acquireRelease.cjs +23 -0
- package/_cjs/IO/api/acquireRelease.cjs.map +1 -0
- package/_cjs/IO/api/acquireReleaseExit.cjs +25 -0
- package/_cjs/IO/api/acquireReleaseExit.cjs.map +1 -0
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs +20 -0
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs.map +1 -0
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +22 -0
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs.map +1 -0
- package/_cjs/IO/api/addFinalizer.cjs +20 -0
- package/_cjs/IO/api/addFinalizer.cjs.map +1 -0
- package/_cjs/IO/api/addFinalizerExit.cjs +32 -0
- package/_cjs/IO/api/addFinalizerExit.cjs.map +1 -0
- package/_cjs/IO/api/bracket.cjs +40 -0
- package/_cjs/IO/api/bracket.cjs.map +1 -0
- package/_cjs/IO/api/bracketExit.cjs +37 -0
- package/_cjs/IO/api/bracketExit.cjs.map +1 -0
- package/_cjs/IO/api/clockWith.cjs +40 -0
- package/_cjs/IO/api/clockWith.cjs.map +1 -0
- package/_cjs/IO/api/concurrency.cjs +72 -0
- package/_cjs/IO/api/concurrency.cjs.map +1 -0
- package/_cjs/IO/api/concurrentFinalizers.cjs +28 -0
- package/_cjs/IO/api/concurrentFinalizers.cjs.map +1 -0
- package/_cjs/IO/api/consoleWith.cjs +40 -0
- package/_cjs/IO/api/consoleWith.cjs.map +1 -0
- package/_cjs/IO/api/core-scope.cjs +168 -0
- package/_cjs/IO/api/core-scope.cjs.map +1 -0
- package/_cjs/IO/api/environment.cjs +153 -0
- package/_cjs/IO/api/environment.cjs.map +1 -0
- package/_cjs/IO/api/foreachC.cjs +152 -0
- package/_cjs/IO/api/foreachC.cjs.map +1 -0
- package/_cjs/IO/api/foreachExec.cjs +33 -0
- package/_cjs/IO/api/foreachExec.cjs.map +1 -0
- package/_cjs/IO/api/forkAll.cjs +25 -0
- package/_cjs/IO/api/forkAll.cjs.map +1 -0
- package/_cjs/IO/api/forkIn.cjs +33 -0
- package/_cjs/IO/api/forkIn.cjs.map +1 -0
- package/_cjs/IO/api/forkScoped.cjs +30 -0
- package/_cjs/IO/api/forkScoped.cjs.map +1 -0
- package/_cjs/IO/api/fulfill.cjs +32 -0
- package/_cjs/IO/api/fulfill.cjs.map +1 -0
- package/_cjs/IO/api/interrupt.cjs +204 -0
- package/_cjs/IO/api/interrupt.cjs.map +1 -0
- package/_cjs/IO/api/memoize.cjs +30 -0
- package/_cjs/IO/api/memoize.cjs.map +1 -0
- package/_cjs/IO/api/onExit.cjs +22 -0
- package/_cjs/IO/api/onExit.cjs.map +1 -0
- package/_cjs/IO/api/once.cjs +24 -0
- package/_cjs/IO/api/once.cjs.map +1 -0
- package/_cjs/IO/api/provideLayer.cjs +30 -0
- package/_cjs/IO/api/provideLayer.cjs.map +1 -0
- package/_cjs/IO/api/provideSomeLayer.cjs +37 -0
- package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -0
- package/_cjs/IO/api/race.cjs +47 -0
- package/_cjs/IO/api/race.cjs.map +1 -0
- package/_cjs/IO/api/raceFirst.cjs +35 -0
- package/_cjs/IO/api/raceFirst.cjs.map +1 -0
- package/_cjs/IO/api/randomWith.cjs +40 -0
- package/_cjs/IO/api/randomWith.cjs.map +1 -0
- package/_cjs/IO/api/repeat.cjs +59 -0
- package/_cjs/IO/api/repeat.cjs.map +1 -0
- package/_cjs/IO/api/retry.cjs +56 -0
- package/_cjs/IO/api/retry.cjs.map +1 -0
- package/_cjs/IO/api/schedule.cjs +43 -0
- package/_cjs/IO/api/schedule.cjs.map +1 -0
- package/_cjs/IO/api/scope.cjs +23 -0
- package/_cjs/IO/api/scope.cjs.map +1 -0
- package/_cjs/IO/api/scopeWith.cjs +24 -0
- package/_cjs/IO/api/scopeWith.cjs.map +1 -0
- package/_cjs/IO/api/scoped.cjs +36 -0
- package/_cjs/IO/api/scoped.cjs.map +1 -0
- package/_cjs/IO/api/sequenceT.cjs +24 -0
- package/_cjs/IO/api/sequenceT.cjs.map +1 -0
- package/_cjs/IO/api/sleep.cjs +20 -0
- package/_cjs/IO/api/sleep.cjs.map +1 -0
- package/_cjs/IO/api/stateful.cjs +24 -0
- package/_cjs/IO/api/stateful.cjs.map +1 -0
- package/_cjs/IO/api/withChildren.cjs +24 -0
- package/_cjs/IO/api/withChildren.cjs.map +1 -0
- package/_cjs/IO/api/withFinalizer.cjs +20 -0
- package/_cjs/IO/api/withFinalizer.cjs.map +1 -0
- package/_cjs/IO/api/withFinalizerExit.cjs +22 -0
- package/_cjs/IO/api/withFinalizerExit.cjs.map +1 -0
- package/_cjs/IO/api/withRuntimeConfig.cjs +27 -0
- package/_cjs/IO/api/withRuntimeConfig.cjs.map +1 -0
- package/_cjs/IO/api/zipC.cjs +22 -0
- package/_cjs/IO/api/zipC.cjs.map +1 -0
- package/_cjs/IO/api/zipWithC.cjs +40 -0
- package/_cjs/IO/api/zipWithC.cjs.map +1 -0
- package/_cjs/IO/api.cjs +2142 -0
- package/_cjs/IO/api.cjs.map +1 -0
- package/_cjs/IO/definition.cjs +558 -0
- package/_cjs/IO/definition.cjs.map +1 -0
- package/_cjs/IO/runtime.cjs +144 -0
- package/_cjs/IO/runtime.cjs.map +1 -0
- package/_cjs/IO.cjs +617 -0
- package/_cjs/IO.cjs.map +1 -0
- package/_cjs/IOEnv/definition.cjs +34 -0
- package/_cjs/IOEnv/definition.cjs.map +1 -0
- package/_cjs/IOEnv/live.cjs +31 -0
- package/_cjs/IOEnv/live.cjs.map +1 -0
- package/_cjs/IOEnv/services.cjs +21 -0
- package/_cjs/IOEnv/services.cjs.map +1 -0
- package/_cjs/IOEnv.cjs +45 -0
- package/_cjs/IOEnv.cjs.map +1 -0
- package/_cjs/InterruptStatus/constructors.cjs +36 -0
- package/_cjs/InterruptStatus/constructors.cjs.map +1 -0
- package/_cjs/InterruptStatus/definition.cjs +30 -0
- package/_cjs/InterruptStatus/definition.cjs.map +1 -0
- package/_cjs/InterruptStatus.cjs +32 -0
- package/_cjs/InterruptStatus.cjs.map +1 -0
- package/_cjs/Layer/MemoMap.cjs +215 -0
- package/_cjs/Layer/MemoMap.cjs.map +1 -0
- package/_cjs/Layer/api.cjs +426 -0
- package/_cjs/Layer/api.cjs.map +1 -0
- package/_cjs/Layer/definition.cjs +137 -0
- package/_cjs/Layer/definition.cjs.map +1 -0
- package/_cjs/Layer.cjs +45 -0
- package/_cjs/Layer.cjs.map +1 -0
- package/_cjs/LogLevel.cjs +111 -0
- package/_cjs/LogLevel.cjs.map +1 -0
- package/_cjs/LogSpan.cjs +43 -0
- package/_cjs/LogSpan.cjs.map +1 -0
- package/_cjs/Logger/api.cjs +37 -0
- package/_cjs/Logger/api.cjs.map +1 -0
- package/_cjs/Logger/constructors.cjs +80 -0
- package/_cjs/Logger/constructors.cjs.map +1 -0
- package/_cjs/Logger/definition.cjs +20 -0
- package/_cjs/Logger/definition.cjs.map +1 -0
- package/_cjs/Logger.cjs +45 -0
- package/_cjs/Logger.cjs.map +1 -0
- package/_cjs/Queue/api/dimapIO.cjs +120 -0
- package/_cjs/Queue/api/dimapIO.cjs.map +1 -0
- package/_cjs/Queue/api/filterInputIO.cjs +84 -0
- package/_cjs/Queue/api/filterInputIO.cjs.map +1 -0
- package/_cjs/Queue/api/filterOutputIO.cjs +89 -0
- package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -0
- package/_cjs/Queue/api/operations.cjs +147 -0
- package/_cjs/Queue/api/operations.cjs.map +1 -0
- package/_cjs/Queue/api/poll.cjs +29 -0
- package/_cjs/Queue/api/poll.cjs.map +1 -0
- package/_cjs/Queue/api/takeBetween.cjs +59 -0
- package/_cjs/Queue/api/takeBetween.cjs.map +1 -0
- package/_cjs/Queue/api/zipWithIO.cjs +99 -0
- package/_cjs/Queue/api/zipWithIO.cjs.map +1 -0
- package/_cjs/Queue/api.cjs +97 -0
- package/_cjs/Queue/api.cjs.map +1 -0
- package/_cjs/Queue/constructors.cjs +55 -0
- package/_cjs/Queue/constructors.cjs.map +1 -0
- package/_cjs/Queue/definition.cjs +29 -0
- package/_cjs/Queue/definition.cjs.map +1 -0
- package/_cjs/Queue/internal.cjs +255 -0
- package/_cjs/Queue/internal.cjs.map +1 -0
- package/_cjs/Queue/strategy.cjs +172 -0
- package/_cjs/Queue/strategy.cjs.map +1 -0
- package/_cjs/Queue.cjs +71 -0
- package/_cjs/Queue.cjs.map +1 -0
- package/_cjs/Random/api.cjs +76 -0
- package/_cjs/Random/api.cjs.map +1 -0
- package/_cjs/Random/definition.cjs +28 -0
- package/_cjs/Random/definition.cjs.map +1 -0
- package/_cjs/Random/live.cjs +57 -0
- package/_cjs/Random/live.cjs.map +1 -0
- package/_cjs/Random.cjs +45 -0
- package/_cjs/Random.cjs.map +1 -0
- package/_cjs/Ref/Atomic/Atomic.cjs +64 -0
- package/_cjs/Ref/Atomic/Atomic.cjs.map +1 -0
- package/_cjs/Ref/Atomic/api.cjs +154 -0
- package/_cjs/Ref/Atomic/api.cjs.map +1 -0
- package/_cjs/Ref/Atomic.cjs +32 -0
- package/_cjs/Ref/Atomic.cjs.map +1 -0
- package/_cjs/Ref/Derived.cjs +55 -0
- package/_cjs/Ref/Derived.cjs.map +1 -0
- package/_cjs/Ref/DerivedAll.cjs +55 -0
- package/_cjs/Ref/DerivedAll.cjs.map +1 -0
- package/_cjs/Ref/Synchronized/api.cjs +197 -0
- package/_cjs/Ref/Synchronized/api.cjs.map +1 -0
- package/_cjs/Ref/Synchronized/constructors.cjs +38 -0
- package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -0
- package/_cjs/Ref/Synchronized/definition.cjs +88 -0
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -0
- package/_cjs/Ref/api/collect.cjs +31 -0
- package/_cjs/Ref/api/collect.cjs.map +1 -0
- package/_cjs/Ref/api/dimap.cjs +110 -0
- package/_cjs/Ref/api/dimap.cjs.map +1 -0
- package/_cjs/Ref/api/filter.cjs +45 -0
- package/_cjs/Ref/api/filter.cjs.map +1 -0
- package/_cjs/Ref/api/get.cjs +20 -0
- package/_cjs/Ref/api/get.cjs.map +1 -0
- package/_cjs/Ref/api/match.cjs +26 -0
- package/_cjs/Ref/api/match.cjs.map +1 -0
- package/_cjs/Ref/api/matchAll.cjs +24 -0
- package/_cjs/Ref/api/matchAll.cjs.map +1 -0
- package/_cjs/Ref/api/modify.cjs +240 -0
- package/_cjs/Ref/api/modify.cjs.map +1 -0
- package/_cjs/Ref/api/set.cjs +21 -0
- package/_cjs/Ref/api/set.cjs.map +1 -0
- package/_cjs/Ref/api.cjs +158 -0
- package/_cjs/Ref/api.cjs.map +1 -0
- package/_cjs/Ref/constructors.cjs +35 -0
- package/_cjs/Ref/constructors.cjs.map +1 -0
- package/_cjs/Ref/definition.cjs +23 -0
- package/_cjs/Ref/definition.cjs.map +1 -0
- package/_cjs/Ref.cjs +123 -0
- package/_cjs/Ref.cjs.map +1 -0
- package/_cjs/RuntimeConfig.cjs +55 -0
- package/_cjs/RuntimeConfig.cjs.map +1 -0
- package/_cjs/STM/api/core-api.cjs +83 -0
- package/_cjs/STM/api/core-api.cjs.map +1 -0
- package/_cjs/STM/api/core-constructors.cjs +90 -0
- package/_cjs/STM/api/core-constructors.cjs.map +1 -0
- package/_cjs/STM/api.cjs +758 -0
- package/_cjs/STM/api.cjs.map +1 -0
- package/_cjs/STM/definition.cjs +213 -0
- package/_cjs/STM/definition.cjs.map +1 -0
- package/_cjs/STM/driver.cjs +184 -0
- package/_cjs/STM/driver.cjs.map +1 -0
- package/_cjs/STM/internal/CommitState.cjs +89 -0
- package/_cjs/STM/internal/CommitState.cjs.map +1 -0
- package/_cjs/STM/internal/Entry.cjs +89 -0
- package/_cjs/STM/internal/Entry.cjs.map +1 -0
- package/_cjs/STM/internal/Journal.cjs +414 -0
- package/_cjs/STM/internal/Journal.cjs.map +1 -0
- package/_cjs/STM/internal/TryCommit.cjs +35 -0
- package/_cjs/STM/internal/TryCommit.cjs.map +1 -0
- package/_cjs/STM/internal/Versioned.cjs +19 -0
- package/_cjs/STM/internal/Versioned.cjs.map +1 -0
- package/_cjs/STM.cjs +71 -0
- package/_cjs/STM.cjs.map +1 -0
- package/_cjs/Schedule/Decision.cjs +67 -0
- package/_cjs/Schedule/Decision.cjs.map +1 -0
- package/_cjs/Schedule/Driver.cjs +32 -0
- package/_cjs/Schedule/Driver.cjs.map +1 -0
- package/_cjs/Schedule/Interval.cjs +154 -0
- package/_cjs/Schedule/Interval.cjs.map +1 -0
- package/_cjs/Schedule/api/driver.cjs +50 -0
- package/_cjs/Schedule/api/driver.cjs.map +1 -0
- package/_cjs/Schedule/api.cjs +790 -0
- package/_cjs/Schedule/api.cjs.map +1 -0
- package/_cjs/Schedule/definition.cjs +41 -0
- package/_cjs/Schedule/definition.cjs.map +1 -0
- package/_cjs/Schedule.cjs +71 -0
- package/_cjs/Schedule.cjs.map +1 -0
- package/_cjs/Scope/Finalizer/definition.cjs +24 -0
- package/_cjs/Scope/Finalizer/definition.cjs.map +1 -0
- package/_cjs/Scope/Finalizer.cjs +19 -0
- package/_cjs/Scope/Finalizer.cjs.map +1 -0
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +46 -0
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs.map +1 -0
- package/_cjs/Scope/ReleaseMap/api.cjs +110 -0
- package/_cjs/Scope/ReleaseMap/api.cjs.map +1 -0
- package/_cjs/Scope/ReleaseMap/constructors.cjs +39 -0
- package/_cjs/Scope/ReleaseMap/constructors.cjs.map +1 -0
- package/_cjs/Scope/ReleaseMap/definition.cjs +39 -0
- package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -0
- package/_cjs/Scope/ReleaseMap.cjs +45 -0
- package/_cjs/Scope/ReleaseMap.cjs.map +1 -0
- package/_cjs/Scope/api.cjs +178 -0
- package/_cjs/Scope/api.cjs.map +1 -0
- package/_cjs/Scope/definition.cjs +45 -0
- package/_cjs/Scope/definition.cjs.map +1 -0
- package/_cjs/Scope.cjs +32 -0
- package/_cjs/Scope.cjs.map +1 -0
- package/_cjs/ScopedRef/api.cjs +73 -0
- package/_cjs/ScopedRef/api.cjs.map +1 -0
- package/_cjs/ScopedRef/definition.cjs +23 -0
- package/_cjs/ScopedRef/definition.cjs.map +1 -0
- package/_cjs/ScopedRef.cjs +32 -0
- package/_cjs/ScopedRef.cjs.map +1 -0
- package/_cjs/Sink/api.cjs +102 -0
- package/_cjs/Sink/api.cjs.map +1 -0
- package/_cjs/Sink/definition.cjs +25 -0
- package/_cjs/Sink/definition.cjs.map +1 -0
- package/_cjs/Sink.cjs +32 -0
- package/_cjs/Sink.cjs.map +1 -0
- package/_cjs/State/api.cjs +76 -0
- package/_cjs/State/api.cjs.map +1 -0
- package/_cjs/State/definition.cjs +30 -0
- package/_cjs/State/definition.cjs.map +1 -0
- package/_cjs/State/internal.cjs +18 -0
- package/_cjs/State/internal.cjs.map +1 -0
- package/_cjs/State.cjs +32 -0
- package/_cjs/State.cjs.map +1 -0
- package/_cjs/Stream/api/zipAllWith.cjs +127 -0
- package/_cjs/Stream/api/zipAllWith.cjs.map +1 -0
- package/_cjs/Stream/api/zipWith.cjs +22 -0
- package/_cjs/Stream/api/zipWith.cjs.map +1 -0
- package/_cjs/Stream/api/zipWithChunks.cjs +100 -0
- package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -0
- package/_cjs/Stream/api.cjs +2517 -0
- package/_cjs/Stream/api.cjs.map +1 -0
- package/_cjs/Stream/definition.cjs +55 -0
- package/_cjs/Stream/definition.cjs.map +1 -0
- package/_cjs/Stream/internal/DebounceState.cjs +99 -0
- package/_cjs/Stream/internal/DebounceState.cjs.map +1 -0
- package/_cjs/Stream/internal/Handoff.cjs +222 -0
- package/_cjs/Stream/internal/Handoff.cjs.map +1 -0
- package/_cjs/Stream/internal/Pull.cjs +89 -0
- package/_cjs/Stream/internal/Pull.cjs.map +1 -0
- package/_cjs/Stream/internal/SinkEndReason.cjs +87 -0
- package/_cjs/Stream/internal/SinkEndReason.cjs.map +1 -0
- package/_cjs/Stream/internal/Take.cjs +249 -0
- package/_cjs/Stream/internal/Take.cjs.map +1 -0
- package/_cjs/Stream/internal/util.cjs +34 -0
- package/_cjs/Stream/internal/util.cjs.map +1 -0
- package/_cjs/Stream.cjs +32 -0
- package/_cjs/Stream.cjs.map +1 -0
- package/_cjs/Supervisor/api.cjs +56 -0
- package/_cjs/Supervisor/api.cjs.map +1 -0
- package/_cjs/Supervisor/constructors.cjs +92 -0
- package/_cjs/Supervisor/constructors.cjs.map +1 -0
- package/_cjs/Supervisor/definition.cjs +89 -0
- package/_cjs/Supervisor/definition.cjs.map +1 -0
- package/_cjs/Supervisor.cjs +45 -0
- package/_cjs/Supervisor.cjs.map +1 -0
- package/_cjs/TExit/constructors.cjs +59 -0
- package/_cjs/TExit/constructors.cjs.map +1 -0
- package/_cjs/TExit/definition.cjs +214 -0
- package/_cjs/TExit/definition.cjs.map +1 -0
- package/_cjs/TExit.cjs +32 -0
- package/_cjs/TExit.cjs.map +1 -0
- package/_cjs/TFuture/api.cjs +76 -0
- package/_cjs/TFuture/api.cjs.map +1 -0
- package/_cjs/TFuture/constructors.cjs +42 -0
- package/_cjs/TFuture/constructors.cjs.map +1 -0
- package/_cjs/TFuture/definition.cjs +16 -0
- package/_cjs/TFuture/definition.cjs.map +1 -0
- package/_cjs/TFuture.cjs +45 -0
- package/_cjs/TFuture.cjs.map +1 -0
- package/_cjs/TRef/api.cjs +372 -0
- package/_cjs/TRef/api.cjs.map +1 -0
- package/_cjs/TRef/constructors.cjs +98 -0
- package/_cjs/TRef/constructors.cjs.map +1 -0
- package/_cjs/TRef/definition.cjs +101 -0
- package/_cjs/TRef/definition.cjs.map +1 -0
- package/_cjs/TRef.cjs +45 -0
- package/_cjs/TRef.cjs.map +1 -0
- package/_cjs/TSemaphore/api.cjs +104 -0
- package/_cjs/TSemaphore/api.cjs.map +1 -0
- package/_cjs/TSemaphore/constructors.cjs +34 -0
- package/_cjs/TSemaphore/constructors.cjs.map +1 -0
- package/_cjs/TSemaphore/definition.cjs +16 -0
- package/_cjs/TSemaphore/definition.cjs.map +1 -0
- package/_cjs/TSemaphore.cjs +45 -0
- package/_cjs/TSemaphore.cjs.map +1 -0
- package/_cjs/TxnId.cjs +21 -0
- package/_cjs/TxnId.cjs.map +1 -0
- package/_cjs/collection/immutable/Conc/findIO.cjs +54 -0
- package/_cjs/collection/immutable/Conc/findIO.cjs.map +1 -0
- package/_cjs/collection/immutable/Conc/mapIO.cjs +29 -0
- package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -0
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +53 -0
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -0
- package/_cjs/collection/immutable/Conc.cjs +45 -0
- package/_cjs/collection/immutable/Conc.cjs.map +1 -0
- package/_cjs/data/Exit/foreachIO.cjs +29 -0
- package/_cjs/data/Exit/foreachIO.cjs.map +1 -0
- package/_cjs/internal/HashedPair.cjs +37 -0
- package/_cjs/internal/HashedPair.cjs.map +1 -0
- package/_cjs/internal/Hub.cjs +758 -0
- package/_cjs/internal/Hub.cjs.map +1 -0
- package/_cjs/internal/MutableQueue.cjs +315 -0
- package/_cjs/internal/MutableQueue.cjs.map +1 -0
- package/_cjs/internal/Scheduler.cjs +33 -0
- package/_cjs/internal/Scheduler.cjs.map +1 -0
- package/_cjs/internal/StackTraceBuilder.cjs +36 -0
- package/_cjs/internal/StackTraceBuilder.cjs.map +1 -0
- package/_mjs/Cached/api.mjs +57 -0
- package/_mjs/Cached/api.mjs.map +1 -0
- package/_mjs/Cached/definition.mjs +22 -0
- package/_mjs/Cached/definition.mjs.map +1 -0
- package/_mjs/Cached/internal.mjs +8 -0
- package/_mjs/Cached/internal.mjs.map +1 -0
- package/_mjs/Cached.mjs +5 -0
- package/_mjs/Cached.mjs.map +1 -0
- package/_mjs/CancellerState.mjs +44 -0
- package/_mjs/CancellerState.mjs.map +1 -0
- package/_mjs/Channel/ChildExecutorDecision/api.mjs +22 -0
- package/_mjs/Channel/ChildExecutorDecision/api.mjs.map +1 -0
- package/_mjs/Channel/ChildExecutorDecision/definition.mjs +25 -0
- package/_mjs/Channel/ChildExecutorDecision/definition.mjs.map +1 -0
- package/_mjs/Channel/ChildExecutorDecision.mjs +4 -0
- package/_mjs/Channel/ChildExecutorDecision.mjs.map +1 -0
- package/_mjs/Channel/UpstreamPullRequest/api.mjs +34 -0
- package/_mjs/Channel/UpstreamPullRequest/api.mjs.map +1 -0
- package/_mjs/Channel/UpstreamPullRequest/definition.mjs +16 -0
- package/_mjs/Channel/UpstreamPullRequest/definition.mjs.map +1 -0
- package/_mjs/Channel/UpstreamPullRequest.mjs +4 -0
- package/_mjs/Channel/UpstreamPullRequest.mjs.map +1 -0
- package/_mjs/Channel/UpstreamPullStrategy/definition.mjs +21 -0
- package/_mjs/Channel/UpstreamPullStrategy/definition.mjs.map +1 -0
- package/_mjs/Channel/UpstreamPullStrategy.mjs +3 -0
- package/_mjs/Channel/UpstreamPullStrategy.mjs.map +1 -0
- package/_mjs/Channel/api/interruptWhen.mjs +35 -0
- package/_mjs/Channel/api/interruptWhen.mjs.map +1 -0
- package/_mjs/Channel/api/mapOutIOC.mjs +32 -0
- package/_mjs/Channel/api/mapOutIOC.mjs.map +1 -0
- package/_mjs/Channel/api/mergeAll.mjs +9 -0
- package/_mjs/Channel/api/mergeAll.mjs.map +1 -0
- package/_mjs/Channel/api/mergeAllUnboundedWith.mjs +9 -0
- package/_mjs/Channel/api/mergeAllUnboundedWith.mjs.map +1 -0
- package/_mjs/Channel/api/mergeAllWith.mjs +58 -0
- package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -0
- package/_mjs/Channel/api/mergeMap.mjs +10 -0
- package/_mjs/Channel/api/mergeMap.mjs.map +1 -0
- package/_mjs/Channel/api/mergeWith.mjs +74 -0
- package/_mjs/Channel/api/mergeWith.mjs.map +1 -0
- package/_mjs/Channel/api/run.mjs +12 -0
- package/_mjs/Channel/api/run.mjs.map +1 -0
- package/_mjs/Channel/api/runCollect.mjs +10 -0
- package/_mjs/Channel/api/runCollect.mjs.map +1 -0
- package/_mjs/Channel/api/runDrain.mjs +12 -0
- package/_mjs/Channel/api/runDrain.mjs.map +1 -0
- package/_mjs/Channel/api/runScoped.mjs +55 -0
- package/_mjs/Channel/api/runScoped.mjs.map +1 -0
- package/_mjs/Channel/api/toPull.mjs +46 -0
- package/_mjs/Channel/api/toPull.mjs.map +1 -0
- package/_mjs/Channel/api/zipC.mjs +30 -0
- package/_mjs/Channel/api/zipC.mjs.map +1 -0
- package/_mjs/Channel/api.mjs +727 -0
- package/_mjs/Channel/api.mjs.map +1 -0
- package/_mjs/Channel/core-api.mjs +123 -0
- package/_mjs/Channel/core-api.mjs.map +1 -0
- package/_mjs/Channel/definition.mjs +195 -0
- package/_mjs/Channel/definition.mjs.map +1 -0
- package/_mjs/Channel/internal/AsyncInputConsumer.mjs +2 -0
- package/_mjs/Channel/internal/AsyncInputConsumer.mjs.map +1 -0
- package/_mjs/Channel/internal/AsyncInputProducer.mjs +2 -0
- package/_mjs/Channel/internal/AsyncInputProducer.mjs.map +1 -0
- package/_mjs/Channel/internal/ChannelExecutor.mjs +913 -0
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -0
- package/_mjs/Channel/internal/ChannelState.mjs +67 -0
- package/_mjs/Channel/internal/ChannelState.mjs.map +1 -0
- package/_mjs/Channel/internal/MergeDecision.mjs +61 -0
- package/_mjs/Channel/internal/MergeDecision.mjs.map +1 -0
- package/_mjs/Channel/internal/MergeState.mjs +51 -0
- package/_mjs/Channel/internal/MergeState.mjs.map +1 -0
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +234 -0
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -0
- package/_mjs/Channel.mjs +5 -0
- package/_mjs/Channel.mjs.map +1 -0
- package/_mjs/Clock/api.mjs +15 -0
- package/_mjs/Clock/api.mjs.map +1 -0
- package/_mjs/Clock/definition.mjs +13 -0
- package/_mjs/Clock/definition.mjs.map +1 -0
- package/_mjs/Clock/live.mjs +30 -0
- package/_mjs/Clock/live.mjs.map +1 -0
- package/_mjs/Clock.mjs +5 -0
- package/_mjs/Clock.mjs.map +1 -0
- package/_mjs/Console/api.mjs +16 -0
- package/_mjs/Console/api.mjs.map +1 -0
- package/_mjs/Console/definition.mjs +13 -0
- package/_mjs/Console/definition.mjs.map +1 -0
- package/_mjs/Console/live.mjs +23 -0
- package/_mjs/Console/live.mjs.map +1 -0
- package/_mjs/Console.mjs +5 -0
- package/_mjs/Console.mjs.map +1 -0
- package/_mjs/Fiber/FiberContext.mjs +1141 -0
- package/_mjs/Fiber/FiberContext.mjs.map +1 -0
- package/_mjs/Fiber/api/await.mjs +8 -0
- package/_mjs/Fiber/api/await.mjs.map +1 -0
- package/_mjs/Fiber/api/awaitAll.mjs +14 -0
- package/_mjs/Fiber/api/awaitAll.mjs.map +1 -0
- package/_mjs/Fiber/api/children.mjs +8 -0
- package/_mjs/Fiber/api/children.mjs.map +1 -0
- package/_mjs/Fiber/api/collectAll.mjs +31 -0
- package/_mjs/Fiber/api/collectAll.mjs.map +1 -0
- package/_mjs/Fiber/api/evalOn.mjs +17 -0
- package/_mjs/Fiber/api/evalOn.mjs.map +1 -0
- package/_mjs/Fiber/api/evalOnIO.mjs +17 -0
- package/_mjs/Fiber/api/evalOnIO.mjs.map +1 -0
- package/_mjs/Fiber/api/fromIO.mjs +13 -0
- package/_mjs/Fiber/api/fromIO.mjs.map +1 -0
- package/_mjs/Fiber/api/id.mjs +8 -0
- package/_mjs/Fiber/api/id.mjs.map +1 -0
- package/_mjs/Fiber/api/inheritRefs.mjs +8 -0
- package/_mjs/Fiber/api/inheritRefs.mjs.map +1 -0
- package/_mjs/Fiber/api/interrupt.mjs +15 -0
- package/_mjs/Fiber/api/interrupt.mjs.map +1 -0
- package/_mjs/Fiber/api/interruptAll.mjs +25 -0
- package/_mjs/Fiber/api/interruptAll.mjs.map +1 -0
- package/_mjs/Fiber/api/interruptAs.mjs +8 -0
- package/_mjs/Fiber/api/interruptAs.mjs.map +1 -0
- package/_mjs/Fiber/api/interruptFork.mjs +15 -0
- package/_mjs/Fiber/api/interruptFork.mjs.map +1 -0
- package/_mjs/Fiber/api/join.mjs +17 -0
- package/_mjs/Fiber/api/join.mjs.map +1 -0
- package/_mjs/Fiber/api/joinAll.mjs +16 -0
- package/_mjs/Fiber/api/joinAll.mjs.map +1 -0
- package/_mjs/Fiber/api/location.mjs +10 -0
- package/_mjs/Fiber/api/location.mjs.map +1 -0
- package/_mjs/Fiber/api/mapFiber.mjs +16 -0
- package/_mjs/Fiber/api/mapFiber.mjs.map +1 -0
- package/_mjs/Fiber/api/mapIO.mjs +33 -0
- package/_mjs/Fiber/api/mapIO.mjs.map +1 -0
- package/_mjs/Fiber/api/poll.mjs +8 -0
- package/_mjs/Fiber/api/poll.mjs.map +1 -0
- package/_mjs/Fiber/api/zipWith.mjs +26 -0
- package/_mjs/Fiber/api/zipWith.mjs.map +1 -0
- package/_mjs/Fiber/constructors.mjs +45 -0
- package/_mjs/Fiber/constructors.mjs.map +1 -0
- package/_mjs/Fiber/definition.mjs +27 -0
- package/_mjs/Fiber/definition.mjs.map +1 -0
- package/_mjs/Fiber.mjs +27 -0
- package/_mjs/Fiber.mjs.map +1 -0
- package/_mjs/FiberDescriptor.mjs +17 -0
- package/_mjs/FiberDescriptor.mjs.map +1 -0
- package/_mjs/FiberRef/api/locallyScoped.mjs +12 -0
- package/_mjs/FiberRef/api/locallyScoped.mjs.map +1 -0
- package/_mjs/FiberRef/api/locallyScopedWith.mjs +11 -0
- package/_mjs/FiberRef/api/locallyScopedWith.mjs.map +1 -0
- package/_mjs/FiberRef/api.mjs +139 -0
- package/_mjs/FiberRef/api.mjs.map +1 -0
- package/_mjs/FiberRef/constructors.mjs +82 -0
- package/_mjs/FiberRef/constructors.mjs.map +1 -0
- package/_mjs/FiberRef/definition.mjs +50 -0
- package/_mjs/FiberRef/definition.mjs.map +1 -0
- package/_mjs/FiberRef.mjs +9 -0
- package/_mjs/FiberRef.mjs.map +1 -0
- package/_mjs/FiberRefs/api.mjs +17 -0
- package/_mjs/FiberRefs/api.mjs.map +1 -0
- package/_mjs/FiberRefs/definition.mjs +14 -0
- package/_mjs/FiberRefs/definition.mjs.map +1 -0
- package/_mjs/FiberRefs/join.mjs +90 -0
- package/_mjs/FiberRefs/join.mjs.map +1 -0
- package/_mjs/FiberRefs.mjs +5 -0
- package/_mjs/FiberRefs.mjs.map +1 -0
- package/_mjs/FiberScope/constructors.mjs +18 -0
- package/_mjs/FiberScope/constructors.mjs.map +1 -0
- package/_mjs/FiberScope/definition.mjs +41 -0
- package/_mjs/FiberScope/definition.mjs.map +1 -0
- package/_mjs/FiberScope.mjs +4 -0
- package/_mjs/FiberScope.mjs.map +1 -0
- package/_mjs/FiberState/api.mjs +15 -0
- package/_mjs/FiberState/api.mjs.map +1 -0
- package/_mjs/FiberState/constructors.mjs +26 -0
- package/_mjs/FiberState/constructors.mjs.map +1 -0
- package/_mjs/FiberState/definition.mjs +26 -0
- package/_mjs/FiberState/definition.mjs.map +1 -0
- package/_mjs/FiberState.mjs +5 -0
- package/_mjs/FiberState.mjs.map +1 -0
- package/_mjs/FiberStatus/constructors.mjs +28 -0
- package/_mjs/FiberStatus/constructors.mjs.map +1 -0
- package/_mjs/FiberStatus/definition.mjs +88 -0
- package/_mjs/FiberStatus/definition.mjs.map +1 -0
- package/_mjs/FiberStatus.mjs +4 -0
- package/_mjs/FiberStatus.mjs.map +1 -0
- package/_mjs/Future/api.mjs +249 -0
- package/_mjs/Future/api.mjs.map +1 -0
- package/_mjs/Future/constructors.mjs +36 -0
- package/_mjs/Future/constructors.mjs.map +1 -0
- package/_mjs/Future/definition.mjs +30 -0
- package/_mjs/Future/definition.mjs.map +1 -0
- package/_mjs/Future.mjs +5 -0
- package/_mjs/Future.mjs.map +1 -0
- package/_mjs/Hub/api.mjs +384 -0
- package/_mjs/Hub/api.mjs.map +1 -0
- package/_mjs/Hub/definition.mjs +15 -0
- package/_mjs/Hub/definition.mjs.map +1 -0
- package/_mjs/Hub/internal.mjs +400 -0
- package/_mjs/Hub/internal.mjs.map +1 -0
- package/_mjs/Hub.mjs +4 -0
- package/_mjs/Hub.mjs.map +1 -0
- package/_mjs/IO/api/acquireRelease.mjs +11 -0
- package/_mjs/IO/api/acquireRelease.mjs.map +1 -0
- package/_mjs/IO/api/acquireReleaseExit.mjs +12 -0
- package/_mjs/IO/api/acquireReleaseExit.mjs.map +1 -0
- package/_mjs/IO/api/acquireReleaseInterruptible.mjs +9 -0
- package/_mjs/IO/api/acquireReleaseInterruptible.mjs.map +1 -0
- package/_mjs/IO/api/acquireReleaseInterruptibleExit.mjs +10 -0
- package/_mjs/IO/api/acquireReleaseInterruptibleExit.mjs.map +1 -0
- package/_mjs/IO/api/addFinalizer.mjs +9 -0
- package/_mjs/IO/api/addFinalizer.mjs.map +1 -0
- package/_mjs/IO/api/addFinalizerExit.mjs +17 -0
- package/_mjs/IO/api/addFinalizerExit.mjs.map +1 -0
- package/_mjs/IO/api/bracket.mjs +29 -0
- package/_mjs/IO/api/bracket.mjs.map +1 -0
- package/_mjs/IO/api/bracketExit.mjs +22 -0
- package/_mjs/IO/api/bracketExit.mjs.map +1 -0
- package/_mjs/IO/api/clockWith.mjs +21 -0
- package/_mjs/IO/api/clockWith.mjs.map +1 -0
- package/_mjs/IO/api/concurrency.mjs +49 -0
- package/_mjs/IO/api/concurrency.mjs.map +1 -0
- package/_mjs/IO/api/concurrentFinalizers.mjs +13 -0
- package/_mjs/IO/api/concurrentFinalizers.mjs.map +1 -0
- package/_mjs/IO/api/consoleWith.mjs +21 -0
- package/_mjs/IO/api/consoleWith.mjs.map +1 -0
- package/_mjs/IO/api/core-scope.mjs +130 -0
- package/_mjs/IO/api/core-scope.mjs.map +1 -0
- package/_mjs/IO/api/environment.mjs +116 -0
- package/_mjs/IO/api/environment.mjs.map +1 -0
- package/_mjs/IO/api/foreachC.mjs +119 -0
- package/_mjs/IO/api/foreachC.mjs.map +1 -0
- package/_mjs/IO/api/foreachExec.mjs +18 -0
- package/_mjs/IO/api/foreachExec.mjs.map +1 -0
- package/_mjs/IO/api/forkAll.mjs +13 -0
- package/_mjs/IO/api/forkAll.mjs.map +1 -0
- package/_mjs/IO/api/forkIn.mjs +18 -0
- package/_mjs/IO/api/forkIn.mjs.map +1 -0
- package/_mjs/IO/api/forkScoped.mjs +15 -0
- package/_mjs/IO/api/forkScoped.mjs.map +1 -0
- package/_mjs/IO/api/fulfill.mjs +18 -0
- package/_mjs/IO/api/fulfill.mjs.map +1 -0
- package/_mjs/IO/api/interrupt.mjs +171 -0
- package/_mjs/IO/api/interrupt.mjs.map +1 -0
- package/_mjs/IO/api/memoize.mjs +16 -0
- package/_mjs/IO/api/memoize.mjs.map +1 -0
- package/_mjs/IO/api/onExit.mjs +10 -0
- package/_mjs/IO/api/onExit.mjs.map +1 -0
- package/_mjs/IO/api/once.mjs +11 -0
- package/_mjs/IO/api/once.mjs.map +1 -0
- package/_mjs/IO/api/provideLayer.mjs +14 -0
- package/_mjs/IO/api/provideLayer.mjs.map +1 -0
- package/_mjs/IO/api/provideSomeLayer.mjs +21 -0
- package/_mjs/IO/api/provideSomeLayer.mjs.map +1 -0
- package/_mjs/IO/api/race.mjs +29 -0
- package/_mjs/IO/api/race.mjs.map +1 -0
- package/_mjs/IO/api/raceFirst.mjs +22 -0
- package/_mjs/IO/api/raceFirst.mjs.map +1 -0
- package/_mjs/IO/api/randomWith.mjs +21 -0
- package/_mjs/IO/api/randomWith.mjs.map +1 -0
- package/_mjs/IO/api/repeat.mjs +38 -0
- package/_mjs/IO/api/repeat.mjs.map +1 -0
- package/_mjs/IO/api/retry.mjs +36 -0
- package/_mjs/IO/api/retry.mjs.map +1 -0
- package/_mjs/IO/api/schedule.mjs +27 -0
- package/_mjs/IO/api/schedule.mjs.map +1 -0
- package/_mjs/IO/api/scope.mjs +9 -0
- package/_mjs/IO/api/scope.mjs.map +1 -0
- package/_mjs/IO/api/scopeWith.mjs +11 -0
- package/_mjs/IO/api/scopeWith.mjs.map +1 -0
- package/_mjs/IO/api/scoped.mjs +20 -0
- package/_mjs/IO/api/scoped.mjs.map +1 -0
- package/_mjs/IO/api/sequenceT.mjs +11 -0
- package/_mjs/IO/api/sequenceT.mjs.map +1 -0
- package/_mjs/IO/api/sleep.mjs +9 -0
- package/_mjs/IO/api/sleep.mjs.map +1 -0
- package/_mjs/IO/api/stateful.mjs +11 -0
- package/_mjs/IO/api/stateful.mjs.map +1 -0
- package/_mjs/IO/api/withChildren.mjs +11 -0
- package/_mjs/IO/api/withChildren.mjs.map +1 -0
- package/_mjs/IO/api/withFinalizer.mjs +9 -0
- package/_mjs/IO/api/withFinalizer.mjs.map +1 -0
- package/_mjs/IO/api/withFinalizerExit.mjs +10 -0
- package/_mjs/IO/api/withFinalizerExit.mjs.map +1 -0
- package/_mjs/IO/api/withRuntimeConfig.mjs +14 -0
- package/_mjs/IO/api/withRuntimeConfig.mjs.map +1 -0
- package/_mjs/IO/api/zipC.mjs +10 -0
- package/_mjs/IO/api/zipC.mjs.map +1 -0
- package/_mjs/IO/api/zipWithC.mjs +23 -0
- package/_mjs/IO/api/zipWithC.mjs.map +1 -0
- package/_mjs/IO/api.mjs +1804 -0
- package/_mjs/IO/api.mjs.map +1 -0
- package/_mjs/IO/definition.mjs +444 -0
- package/_mjs/IO/definition.mjs.map +1 -0
- package/_mjs/IO/runtime.mjs +97 -0
- package/_mjs/IO/runtime.mjs.map +1 -0
- package/_mjs/IO.mjs +51 -0
- package/_mjs/IO.mjs.map +1 -0
- package/_mjs/IOEnv/definition.mjs +14 -0
- package/_mjs/IOEnv/definition.mjs.map +1 -0
- package/_mjs/IOEnv/live.mjs +13 -0
- package/_mjs/IOEnv/live.mjs.map +1 -0
- package/_mjs/IOEnv/services.mjs +8 -0
- package/_mjs/IOEnv/services.mjs.map +1 -0
- package/_mjs/IOEnv.mjs +5 -0
- package/_mjs/IOEnv.mjs.map +1 -0
- package/_mjs/InterruptStatus/constructors.mjs +21 -0
- package/_mjs/InterruptStatus/constructors.mjs.map +1 -0
- package/_mjs/InterruptStatus/definition.mjs +21 -0
- package/_mjs/InterruptStatus/definition.mjs.map +1 -0
- package/_mjs/InterruptStatus.mjs +4 -0
- package/_mjs/InterruptStatus.mjs.map +1 -0
- package/_mjs/Layer/MemoMap.mjs +171 -0
- package/_mjs/Layer/MemoMap.mjs.map +1 -0
- package/_mjs/Layer/api.mjs +338 -0
- package/_mjs/Layer/api.mjs.map +1 -0
- package/_mjs/Layer/definition.mjs +104 -0
- package/_mjs/Layer/definition.mjs.map +1 -0
- package/_mjs/Layer.mjs +5 -0
- package/_mjs/Layer.mjs.map +1 -0
- package/_mjs/LogLevel.mjs +85 -0
- package/_mjs/LogLevel.mjs.map +1 -0
- package/_mjs/LogSpan.mjs +32 -0
- package/_mjs/LogSpan.mjs.map +1 -0
- package/_mjs/Logger/api.mjs +23 -0
- package/_mjs/Logger/api.mjs.map +1 -0
- package/_mjs/Logger/constructors.mjs +63 -0
- package/_mjs/Logger/constructors.mjs.map +1 -0
- package/_mjs/Logger/definition.mjs +11 -0
- package/_mjs/Logger/definition.mjs.map +1 -0
- package/_mjs/Logger.mjs +5 -0
- package/_mjs/Logger.mjs.map +1 -0
- package/_mjs/Queue/api/dimapIO.mjs +97 -0
- package/_mjs/Queue/api/dimapIO.mjs.map +1 -0
- package/_mjs/Queue/api/filterInputIO.mjs +63 -0
- package/_mjs/Queue/api/filterInputIO.mjs.map +1 -0
- package/_mjs/Queue/api/filterOutputIO.mjs +68 -0
- package/_mjs/Queue/api/filterOutputIO.mjs.map +1 -0
- package/_mjs/Queue/api/operations.mjs +122 -0
- package/_mjs/Queue/api/operations.mjs.map +1 -0
- package/_mjs/Queue/api/poll.mjs +15 -0
- package/_mjs/Queue/api/poll.mjs.map +1 -0
- package/_mjs/Queue/api/takeBetween.mjs +44 -0
- package/_mjs/Queue/api/takeBetween.mjs.map +1 -0
- package/_mjs/Queue/api/zipWithIO.mjs +75 -0
- package/_mjs/Queue/api/zipWithIO.mjs.map +1 -0
- package/_mjs/Queue/api.mjs +9 -0
- package/_mjs/Queue/api.mjs.map +1 -0
- package/_mjs/Queue/constructors.mjs +34 -0
- package/_mjs/Queue/constructors.mjs.map +1 -0
- package/_mjs/Queue/definition.mjs +17 -0
- package/_mjs/Queue/definition.mjs.map +1 -0
- package/_mjs/Queue/internal.mjs +224 -0
- package/_mjs/Queue/internal.mjs.map +1 -0
- package/_mjs/Queue/strategy.mjs +147 -0
- package/_mjs/Queue/strategy.mjs.map +1 -0
- package/_mjs/Queue.mjs +7 -0
- package/_mjs/Queue.mjs.map +1 -0
- package/_mjs/Random/api.mjs +52 -0
- package/_mjs/Random/api.mjs.map +1 -0
- package/_mjs/Random/definition.mjs +13 -0
- package/_mjs/Random/definition.mjs.map +1 -0
- package/_mjs/Random/live.mjs +40 -0
- package/_mjs/Random/live.mjs.map +1 -0
- package/_mjs/Random.mjs +5 -0
- package/_mjs/Random.mjs.map +1 -0
- package/_mjs/Ref/Atomic/Atomic.mjs +47 -0
- package/_mjs/Ref/Atomic/Atomic.mjs.map +1 -0
- package/_mjs/Ref/Atomic/api.mjs +124 -0
- package/_mjs/Ref/Atomic/api.mjs.map +1 -0
- package/_mjs/Ref/Atomic.mjs +4 -0
- package/_mjs/Ref/Atomic.mjs.map +1 -0
- package/_mjs/Ref/Derived.mjs +35 -0
- package/_mjs/Ref/Derived.mjs.map +1 -0
- package/_mjs/Ref/DerivedAll.mjs +35 -0
- package/_mjs/Ref/DerivedAll.mjs.map +1 -0
- package/_mjs/Ref/Synchronized/api.mjs +155 -0
- package/_mjs/Ref/Synchronized/api.mjs.map +1 -0
- package/_mjs/Ref/Synchronized/constructors.mjs +20 -0
- package/_mjs/Ref/Synchronized/constructors.mjs.map +1 -0
- package/_mjs/Ref/Synchronized/definition.mjs +66 -0
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -0
- package/_mjs/Ref/api/collect.mjs +17 -0
- package/_mjs/Ref/api/collect.mjs.map +1 -0
- package/_mjs/Ref/api/dimap.mjs +84 -0
- package/_mjs/Ref/api/dimap.mjs.map +1 -0
- package/_mjs/Ref/api/filter.mjs +29 -0
- package/_mjs/Ref/api/filter.mjs.map +1 -0
- package/_mjs/Ref/api/get.mjs +13 -0
- package/_mjs/Ref/api/get.mjs.map +1 -0
- package/_mjs/Ref/api/match.mjs +18 -0
- package/_mjs/Ref/api/match.mjs.map +1 -0
- package/_mjs/Ref/api/matchAll.mjs +16 -0
- package/_mjs/Ref/api/matchAll.mjs.map +1 -0
- package/_mjs/Ref/api/modify.mjs +205 -0
- package/_mjs/Ref/api/modify.mjs.map +1 -0
- package/_mjs/Ref/api/set.mjs +14 -0
- package/_mjs/Ref/api/set.mjs.map +1 -0
- package/_mjs/Ref/api.mjs +34 -0
- package/_mjs/Ref/api.mjs.map +1 -0
- package/_mjs/Ref/constructors.mjs +19 -0
- package/_mjs/Ref/constructors.mjs.map +1 -0
- package/_mjs/Ref/definition.mjs +10 -0
- package/_mjs/Ref/definition.mjs.map +1 -0
- package/_mjs/Ref.mjs +13 -0
- package/_mjs/Ref.mjs.map +1 -0
- package/_mjs/RuntimeConfig.mjs +34 -0
- package/_mjs/RuntimeConfig.mjs.map +1 -0
- package/_mjs/STM/api/core-api.mjs +61 -0
- package/_mjs/STM/api/core-api.mjs.map +1 -0
- package/_mjs/STM/api/core-constructors.mjs +68 -0
- package/_mjs/STM/api/core-constructors.mjs.map +1 -0
- package/_mjs/STM/api.mjs +633 -0
- package/_mjs/STM/api.mjs.map +1 -0
- package/_mjs/STM/definition.mjs +148 -0
- package/_mjs/STM/definition.mjs.map +1 -0
- package/_mjs/STM/driver.mjs +166 -0
- package/_mjs/STM/driver.mjs.map +1 -0
- package/_mjs/STM/internal/CommitState.mjs +68 -0
- package/_mjs/STM/internal/CommitState.mjs.map +1 -0
- package/_mjs/STM/internal/Entry.mjs +70 -0
- package/_mjs/STM/internal/Entry.mjs.map +1 -0
- package/_mjs/STM/internal/Journal.mjs +377 -0
- package/_mjs/STM/internal/Journal.mjs.map +1 -0
- package/_mjs/STM/internal/TryCommit.mjs +22 -0
- package/_mjs/STM/internal/TryCommit.mjs.map +1 -0
- package/_mjs/STM/internal/Versioned.mjs +9 -0
- package/_mjs/STM/internal/Versioned.mjs.map +1 -0
- package/_mjs/STM.mjs +9 -0
- package/_mjs/STM.mjs.map +1 -0
- package/_mjs/Schedule/Decision.mjs +48 -0
- package/_mjs/Schedule/Decision.mjs.map +1 -0
- package/_mjs/Schedule/Driver.mjs +21 -0
- package/_mjs/Schedule/Driver.mjs.map +1 -0
- package/_mjs/Schedule/Interval.mjs +114 -0
- package/_mjs/Schedule/Interval.mjs.map +1 -0
- package/_mjs/Schedule/api/driver.mjs +30 -0
- package/_mjs/Schedule/api/driver.mjs.map +1 -0
- package/_mjs/Schedule/api.mjs +642 -0
- package/_mjs/Schedule/api.mjs.map +1 -0
- package/_mjs/Schedule/definition.mjs +32 -0
- package/_mjs/Schedule/definition.mjs.map +1 -0
- package/_mjs/Schedule.mjs +7 -0
- package/_mjs/Schedule.mjs.map +1 -0
- package/_mjs/Scope/Finalizer/definition.mjs +9 -0
- package/_mjs/Scope/Finalizer/definition.mjs.map +1 -0
- package/_mjs/Scope/Finalizer.mjs +3 -0
- package/_mjs/Scope/Finalizer.mjs.map +1 -0
- package/_mjs/Scope/ReleaseMap/api/releaseAll.mjs +26 -0
- package/_mjs/Scope/ReleaseMap/api/releaseAll.mjs.map +1 -0
- package/_mjs/Scope/ReleaseMap/api.mjs +84 -0
- package/_mjs/Scope/ReleaseMap/api.mjs.map +1 -0
- package/_mjs/Scope/ReleaseMap/constructors.mjs +21 -0
- package/_mjs/Scope/ReleaseMap/constructors.mjs.map +1 -0
- package/_mjs/Scope/ReleaseMap/definition.mjs +21 -0
- package/_mjs/Scope/ReleaseMap/definition.mjs.map +1 -0
- package/_mjs/Scope/ReleaseMap.mjs +5 -0
- package/_mjs/Scope/ReleaseMap.mjs.map +1 -0
- package/_mjs/Scope/api.mjs +140 -0
- package/_mjs/Scope/api.mjs.map +1 -0
- package/_mjs/Scope/definition.mjs +25 -0
- package/_mjs/Scope/definition.mjs.map +1 -0
- package/_mjs/Scope.mjs +4 -0
- package/_mjs/Scope.mjs.map +1 -0
- package/_mjs/ScopedRef/api.mjs +50 -0
- package/_mjs/ScopedRef/api.mjs.map +1 -0
- package/_mjs/ScopedRef/definition.mjs +13 -0
- package/_mjs/ScopedRef/definition.mjs.map +1 -0
- package/_mjs/ScopedRef.mjs +4 -0
- package/_mjs/ScopedRef.mjs.map +1 -0
- package/_mjs/Sink/api.mjs +76 -0
- package/_mjs/Sink/api.mjs.map +1 -0
- package/_mjs/Sink/definition.mjs +16 -0
- package/_mjs/Sink/definition.mjs.map +1 -0
- package/_mjs/Sink.mjs +4 -0
- package/_mjs/Sink.mjs.map +1 -0
- package/_mjs/State/api.mjs +53 -0
- package/_mjs/State/api.mjs.map +1 -0
- package/_mjs/State/definition.mjs +19 -0
- package/_mjs/State/definition.mjs.map +1 -0
- package/_mjs/State/internal.mjs +8 -0
- package/_mjs/State/internal.mjs.map +1 -0
- package/_mjs/State.mjs +4 -0
- package/_mjs/State.mjs.map +1 -0
- package/_mjs/Stream/api/zipAllWith.mjs +106 -0
- package/_mjs/Stream/api/zipAllWith.mjs.map +1 -0
- package/_mjs/Stream/api/zipWith.mjs +10 -0
- package/_mjs/Stream/api/zipWith.mjs.map +1 -0
- package/_mjs/Stream/api/zipWithChunks.mjs +83 -0
- package/_mjs/Stream/api/zipWithChunks.mjs.map +1 -0
- package/_mjs/Stream/api.mjs +2178 -0
- package/_mjs/Stream/api.mjs.map +1 -0
- package/_mjs/Stream/definition.mjs +41 -0
- package/_mjs/Stream/definition.mjs.map +1 -0
- package/_mjs/Stream/internal/DebounceState.mjs +72 -0
- package/_mjs/Stream/internal/DebounceState.mjs.map +1 -0
- package/_mjs/Stream/internal/Handoff.mjs +162 -0
- package/_mjs/Stream/internal/Handoff.mjs.map +1 -0
- package/_mjs/Stream/internal/Pull.mjs +56 -0
- package/_mjs/Stream/internal/Pull.mjs.map +1 -0
- package/_mjs/Stream/internal/SinkEndReason.mjs +66 -0
- package/_mjs/Stream/internal/SinkEndReason.mjs.map +1 -0
- package/_mjs/Stream/internal/Take.mjs +191 -0
- package/_mjs/Stream/internal/Take.mjs.map +1 -0
- package/_mjs/Stream/internal/util.mjs +19 -0
- package/_mjs/Stream/internal/util.mjs.map +1 -0
- package/_mjs/Stream.mjs +4 -0
- package/_mjs/Stream.mjs.map +1 -0
- package/_mjs/Supervisor/api.mjs +44 -0
- package/_mjs/Supervisor/api.mjs.map +1 -0
- package/_mjs/Supervisor/constructors.mjs +69 -0
- package/_mjs/Supervisor/constructors.mjs.map +1 -0
- package/_mjs/Supervisor/definition.mjs +74 -0
- package/_mjs/Supervisor/definition.mjs.map +1 -0
- package/_mjs/Supervisor.mjs +5 -0
- package/_mjs/Supervisor.mjs.map +1 -0
- package/_mjs/TExit/constructors.mjs +40 -0
- package/_mjs/TExit/constructors.mjs.map +1 -0
- package/_mjs/TExit/definition.mjs +173 -0
- package/_mjs/TExit/definition.mjs.map +1 -0
- package/_mjs/TExit.mjs +4 -0
- package/_mjs/TExit.mjs.map +1 -0
- package/_mjs/TFuture/api.mjs +47 -0
- package/_mjs/TFuture/api.mjs.map +1 -0
- package/_mjs/TFuture/constructors.mjs +23 -0
- package/_mjs/TFuture/constructors.mjs.map +1 -0
- package/_mjs/TFuture/definition.mjs +3 -0
- package/_mjs/TFuture/definition.mjs.map +1 -0
- package/_mjs/TFuture.mjs +5 -0
- package/_mjs/TFuture.mjs.map +1 -0
- package/_mjs/TRef/api.mjs +327 -0
- package/_mjs/TRef/api.mjs.map +1 -0
- package/_mjs/TRef/constructors.mjs +72 -0
- package/_mjs/TRef/constructors.mjs.map +1 -0
- package/_mjs/TRef/definition.mjs +71 -0
- package/_mjs/TRef/definition.mjs.map +1 -0
- package/_mjs/TRef.mjs +5 -0
- package/_mjs/TRef.mjs.map +1 -0
- package/_mjs/TSemaphore/api.mjs +74 -0
- package/_mjs/TSemaphore/api.mjs.map +1 -0
- package/_mjs/TSemaphore/constructors.mjs +19 -0
- package/_mjs/TSemaphore/constructors.mjs.map +1 -0
- package/_mjs/TSemaphore/definition.mjs +3 -0
- package/_mjs/TSemaphore/definition.mjs.map +1 -0
- package/_mjs/TSemaphore.mjs +5 -0
- package/_mjs/TSemaphore.mjs.map +1 -0
- package/_mjs/TxnId.mjs +11 -0
- package/_mjs/TxnId.mjs.map +1 -0
- package/_mjs/collection/immutable/Conc/findIO.mjs +40 -0
- package/_mjs/collection/immutable/Conc/findIO.mjs.map +1 -0
- package/_mjs/collection/immutable/Conc/mapIO.mjs +16 -0
- package/_mjs/collection/immutable/Conc/mapIO.mjs.map +1 -0
- package/_mjs/collection/immutable/Conc/takeWhileIO.mjs +39 -0
- package/_mjs/collection/immutable/Conc/takeWhileIO.mjs.map +1 -0
- package/_mjs/collection/immutable/Conc.mjs +5 -0
- package/_mjs/collection/immutable/Conc.mjs.map +1 -0
- package/_mjs/data/Exit/foreachIO.mjs +15 -0
- package/_mjs/data/Exit/foreachIO.mjs.map +1 -0
- package/_mjs/internal/HashedPair.mjs +20 -0
- package/_mjs/internal/HashedPair.mjs.map +1 -0
- package/_mjs/internal/Hub.mjs +723 -0
- package/_mjs/internal/Hub.mjs.map +1 -0
- package/_mjs/internal/MutableQueue.mjs +276 -0
- package/_mjs/internal/MutableQueue.mjs.map +1 -0
- package/_mjs/internal/Scheduler.mjs +18 -0
- package/_mjs/internal/Scheduler.mjs.map +1 -0
- package/_mjs/internal/StackTraceBuilder.mjs +21 -0
- package/_mjs/internal/StackTraceBuilder.mjs.map +1 -0
- package/_src/Cached/api.ts +54 -0
- package/_src/Cached/definition.ts +23 -0
- package/_src/Cached/internal.ts +10 -0
- package/_src/Cached.ts +5 -0
- package/_src/CancellerState.ts +47 -0
- package/_src/Channel/ChildExecutorDecision/api.ts +23 -0
- package/_src/Channel/ChildExecutorDecision/definition.ts +48 -0
- package/_src/Channel/ChildExecutorDecision.ts +4 -0
- package/_src/Channel/UpstreamPullRequest/api.ts +36 -0
- package/_src/Channel/UpstreamPullRequest/definition.ts +21 -0
- package/_src/Channel/UpstreamPullRequest.ts +4 -0
- package/_src/Channel/UpstreamPullStrategy/definition.ts +38 -0
- package/_src/Channel/UpstreamPullStrategy.ts +3 -0
- package/_src/Channel/api/interruptWhen.ts +37 -0
- package/_src/Channel/api/mapOutIOC.ts +63 -0
- package/_src/Channel/api/mergeAll.ts +21 -0
- package/_src/Channel/api/mergeAllUnboundedWith.ts +30 -0
- package/_src/Channel/api/mergeAllWith.ts +141 -0
- package/_src/Channel/api/mergeMap.ts +27 -0
- package/_src/Channel/api/mergeWith.ts +200 -0
- package/_src/Channel/api/run.ts +10 -0
- package/_src/Channel/api/runCollect.ts +8 -0
- package/_src/Channel/api/runDrain.ts +10 -0
- package/_src/Channel/api/runScoped.ts +45 -0
- package/_src/Channel/api/toPull.ts +38 -0
- package/_src/Channel/api/zipC.ts +104 -0
- package/_src/Channel/api.ts +1258 -0
- package/_src/Channel/core-api.ts +230 -0
- package/_src/Channel/definition.ts +322 -0
- package/_src/Channel/internal/AsyncInputConsumer.ts +6 -0
- package/_src/Channel/internal/AsyncInputProducer.ts +6 -0
- package/_src/Channel/internal/ChannelExecutor.ts +1078 -0
- package/_src/Channel/internal/ChannelState.ts +61 -0
- package/_src/Channel/internal/MergeDecision.ts +65 -0
- package/_src/Channel/internal/MergeState.ts +63 -0
- package/_src/Channel/internal/SingleProducerAsyncInput.ts +186 -0
- package/_src/Channel.ts +5 -0
- package/_src/Clock/api.ts +11 -0
- package/_src/Clock/definition.ts +13 -0
- package/_src/Clock/live.ts +21 -0
- package/_src/Clock.ts +5 -0
- package/_src/Console/api.ts +13 -0
- package/_src/Console/definition.ts +14 -0
- package/_src/Console/live.ts +18 -0
- package/_src/Console.ts +5 -0
- package/_src/Fiber/FiberContext.ts +1101 -0
- package/_src/Fiber/api/await.ts +7 -0
- package/_src/Fiber/api/awaitAll.ts +8 -0
- package/_src/Fiber/api/children.ts +7 -0
- package/_src/Fiber/api/collectAll.ts +32 -0
- package/_src/Fiber/api/evalOn.ts +12 -0
- package/_src/Fiber/api/evalOnIO.ts +18 -0
- package/_src/Fiber/api/fromIO.ts +8 -0
- package/_src/Fiber/api/id.ts +7 -0
- package/_src/Fiber/api/inheritRefs.ts +7 -0
- package/_src/Fiber/api/interrupt.ts +11 -0
- package/_src/Fiber/api/interruptAll.ts +17 -0
- package/_src/Fiber/api/interruptAs.ts +7 -0
- package/_src/Fiber/api/interruptFork.ts +10 -0
- package/_src/Fiber/api/join.ts +13 -0
- package/_src/Fiber/api/joinAll.ts +12 -0
- package/_src/Fiber/api/location.ts +7 -0
- package/_src/Fiber/api/mapFiber.ts +9 -0
- package/_src/Fiber/api/mapIO.ts +31 -0
- package/_src/Fiber/api/poll.ts +7 -0
- package/_src/Fiber/api/zipWith.ts +25 -0
- package/_src/Fiber/constructors.ts +43 -0
- package/_src/Fiber/definition.ts +128 -0
- package/_src/Fiber.ts +28 -0
- package/_src/FiberDescriptor.ts +19 -0
- package/_src/FiberRef/api/locallyScoped.ts +9 -0
- package/_src/FiberRef/api/locallyScopedWith.ts +6 -0
- package/_src/FiberRef/api.ts +135 -0
- package/_src/FiberRef/constructors.ts +98 -0
- package/_src/FiberRef/definition.ts +64 -0
- package/_src/FiberRef.ts +10 -0
- package/_src/FiberRefs/api.ts +15 -0
- package/_src/FiberRefs/definition.ts +11 -0
- package/_src/FiberRefs/join.ts +67 -0
- package/_src/FiberRefs.ts +5 -0
- package/_src/FiberScope/constructors.ts +19 -0
- package/_src/FiberScope/definition.ts +38 -0
- package/_src/FiberScope.ts +4 -0
- package/_src/FiberState/api.ts +12 -0
- package/_src/FiberState/constructors.ts +33 -0
- package/_src/FiberState/definition.ts +44 -0
- package/_src/FiberState.ts +5 -0
- package/_src/FiberStatus/constructors.ts +35 -0
- package/_src/FiberStatus/definition.ts +87 -0
- package/_src/FiberStatus.ts +4 -0
- package/_src/Future/api.ts +204 -0
- package/_src/Future/constructors.ts +28 -0
- package/_src/Future/definition.ts +24 -0
- package/_src/Future.ts +5 -0
- package/_src/Hub/api.ts +434 -0
- package/_src/Hub/definition.ts +102 -0
- package/_src/Hub/internal.ts +493 -0
- package/_src/Hub.ts +4 -0
- package/_src/IO/api/acquireRelease.ts +10 -0
- package/_src/IO/api/acquireReleaseExit.ts +11 -0
- package/_src/IO/api/acquireReleaseInterruptible.ts +10 -0
- package/_src/IO/api/acquireReleaseInterruptibleExit.ts +10 -0
- package/_src/IO/api/addFinalizer.ts +9 -0
- package/_src/IO/api/addFinalizerExit.ts +12 -0
- package/_src/IO/api/bracket.ts +30 -0
- package/_src/IO/api/bracketExit.ts +32 -0
- package/_src/IO/api/clockWith.ts +11 -0
- package/_src/IO/api/concurrency.ts +42 -0
- package/_src/IO/api/concurrentFinalizers.ts +11 -0
- package/_src/IO/api/consoleWith.ts +13 -0
- package/_src/IO/api/core-scope.ts +138 -0
- package/_src/IO/api/environment.ts +126 -0
- package/_src/IO/api/foreachC.ts +178 -0
- package/_src/IO/api/foreachExec.ts +19 -0
- package/_src/IO/api/forkAll.ts +9 -0
- package/_src/IO/api/forkIn.ts +15 -0
- package/_src/IO/api/forkScoped.ts +11 -0
- package/_src/IO/api/fulfill.ts +10 -0
- package/_src/IO/api/interrupt.ts +169 -0
- package/_src/IO/api/memoize.ts +10 -0
- package/_src/IO/api/onExit.ts +12 -0
- package/_src/IO/api/once.ts +6 -0
- package/_src/IO/api/provideLayer.ts +12 -0
- package/_src/IO/api/provideSomeLayer.ts +23 -0
- package/_src/IO/api/race.ts +32 -0
- package/_src/IO/api/raceFirst.ts +17 -0
- package/_src/IO/api/randomWith.ts +11 -0
- package/_src/IO/api/repeat.ts +49 -0
- package/_src/IO/api/retry.ts +42 -0
- package/_src/IO/api/schedule.ts +31 -0
- package/_src/IO/api/scope.ts +4 -0
- package/_src/IO/api/scopeWith.ts +6 -0
- package/_src/IO/api/scoped.ts +13 -0
- package/_src/IO/api/sequenceT.ts +12 -0
- package/_src/IO/api/sleep.ts +6 -0
- package/_src/IO/api/stateful.ts +15 -0
- package/_src/IO/api/withChildren.ts +13 -0
- package/_src/IO/api/withFinalizer.ts +9 -0
- package/_src/IO/api/withFinalizerExit.ts +9 -0
- package/_src/IO/api/withRuntimeConfig.ts +16 -0
- package/_src/IO/api/zipC.ts +8 -0
- package/_src/IO/api/zipWithC.ts +41 -0
- package/_src/IO/api.ts +2126 -0
- package/_src/IO/definition.ts +429 -0
- package/_src/IO/runtime.ts +99 -0
- package/_src/IO.ts +52 -0
- package/_src/IOEnv/definition.ts +20 -0
- package/_src/IOEnv/live.ts +8 -0
- package/_src/IOEnv/services.ts +10 -0
- package/_src/IOEnv.ts +5 -0
- package/_src/InterruptStatus/constructors.ts +16 -0
- package/_src/InterruptStatus/definition.ts +17 -0
- package/_src/InterruptStatus.ts +4 -0
- package/_src/Layer/MemoMap.ts +170 -0
- package/_src/Layer/api.ts +378 -0
- package/_src/Layer/definition.ts +111 -0
- package/_src/Layer.ts +5 -0
- package/_src/LogLevel.ts +79 -0
- package/_src/LogSpan.ts +27 -0
- package/_src/Logger/api.ts +24 -0
- package/_src/Logger/constructors.ts +59 -0
- package/_src/Logger/definition.ts +22 -0
- package/_src/Logger.ts +5 -0
- package/_src/Queue/api/dimapIO.ts +120 -0
- package/_src/Queue/api/filterInputIO.ts +73 -0
- package/_src/Queue/api/filterOutputIO.ts +74 -0
- package/_src/Queue/api/operations.ts +121 -0
- package/_src/Queue/api/poll.ts +11 -0
- package/_src/Queue/api/takeBetween.ts +40 -0
- package/_src/Queue/api/zipWithIO.ts +96 -0
- package/_src/Queue/api.ts +9 -0
- package/_src/Queue/constructors.ts +33 -0
- package/_src/Queue/definition.ts +134 -0
- package/_src/Queue/internal.ts +240 -0
- package/_src/Queue/strategy.ts +177 -0
- package/_src/Queue.ts +7 -0
- package/_src/Random/api.ts +51 -0
- package/_src/Random/definition.ts +21 -0
- package/_src/Random/live.ts +36 -0
- package/_src/Random.ts +5 -0
- package/_src/Ref/Atomic/Atomic.ts +56 -0
- package/_src/Ref/Atomic/api.ts +120 -0
- package/_src/Ref/Atomic.ts +4 -0
- package/_src/Ref/Derived.ts +71 -0
- package/_src/Ref/DerivedAll.ts +75 -0
- package/_src/Ref/Synchronized/api.ts +234 -0
- package/_src/Ref/Synchronized/constructors.ts +12 -0
- package/_src/Ref/Synchronized/definition.ts +126 -0
- package/_src/Ref/api/collect.ts +18 -0
- package/_src/Ref/api/dimap.ts +108 -0
- package/_src/Ref/api/filter.ts +33 -0
- package/_src/Ref/api/get.ts +14 -0
- package/_src/Ref/api/match.ts +24 -0
- package/_src/Ref/api/matchAll.ts +23 -0
- package/_src/Ref/api/modify.ts +225 -0
- package/_src/Ref/api/set.ts +15 -0
- package/_src/Ref/api.ts +39 -0
- package/_src/Ref/constructors.ts +15 -0
- package/_src/Ref/definition.ts +104 -0
- package/_src/Ref.ts +14 -0
- package/_src/RuntimeConfig.ts +37 -0
- package/_src/STM/api/core-api.ts +60 -0
- package/_src/STM/api/core-constructors.ts +65 -0
- package/_src/STM/api.ts +685 -0
- package/_src/STM/definition.ts +155 -0
- package/_src/STM/driver.ts +131 -0
- package/_src/STM/internal/CommitState.ts +75 -0
- package/_src/STM/internal/Entry.ts +76 -0
- package/_src/STM/internal/Journal.ts +341 -0
- package/_src/STM/internal/TryCommit.ts +23 -0
- package/_src/STM/internal/Versioned.ts +7 -0
- package/_src/STM.ts +10 -0
- package/_src/Schedule/Decision.ts +51 -0
- package/_src/Schedule/Driver.ts +24 -0
- package/_src/Schedule/Interval.ts +103 -0
- package/_src/Schedule/api/driver.ts +38 -0
- package/_src/Schedule/api.ts +887 -0
- package/_src/Schedule/definition.ts +60 -0
- package/_src/Schedule.ts +7 -0
- package/_src/Scope/Finalizer/definition.ts +26 -0
- package/_src/Scope/Finalizer.ts +3 -0
- package/_src/Scope/ReleaseMap/api/releaseAll.ts +28 -0
- package/_src/Scope/ReleaseMap/api.ts +86 -0
- package/_src/Scope/ReleaseMap/constructors.ts +17 -0
- package/_src/Scope/ReleaseMap/definition.ts +37 -0
- package/_src/Scope/ReleaseMap.ts +5 -0
- package/_src/Scope/api.ts +117 -0
- package/_src/Scope/definition.ts +31 -0
- package/_src/Scope.ts +4 -0
- package/_src/ScopedRef/api.ts +50 -0
- package/_src/ScopedRef/definition.ts +13 -0
- package/_src/ScopedRef.ts +4 -0
- package/_src/Sink/api.ts +88 -0
- package/_src/Sink/definition.ts +12 -0
- package/_src/Sink.ts +4 -0
- package/_src/State/api.ts +49 -0
- package/_src/State/definition.ts +19 -0
- package/_src/State/internal.ts +10 -0
- package/_src/State.ts +4 -0
- package/_src/Stream/api/zipAllWith.ts +135 -0
- package/_src/Stream/api/zipWith.ts +12 -0
- package/_src/Stream/api/zipWithChunks.ts +89 -0
- package/_src/Stream/api.ts +2931 -0
- package/_src/Stream/definition.ts +42 -0
- package/_src/Stream/internal/DebounceState.ts +79 -0
- package/_src/Stream/internal/Handoff.ts +174 -0
- package/_src/Stream/internal/Pull.ts +58 -0
- package/_src/Stream/internal/SinkEndReason.ts +59 -0
- package/_src/Stream/internal/Take.ts +192 -0
- package/_src/Stream/internal/util.ts +19 -0
- package/_src/Stream.ts +4 -0
- package/_src/Supervisor/api.ts +36 -0
- package/_src/Supervisor/constructors.ts +65 -0
- package/_src/Supervisor/definition.ts +70 -0
- package/_src/Supervisor.ts +5 -0
- package/_src/TExit/constructors.ts +39 -0
- package/_src/TExit/definition.ts +147 -0
- package/_src/TExit.ts +4 -0
- package/_src/TFuture/api.ts +42 -0
- package/_src/TFuture/constructors.ts +14 -0
- package/_src/TFuture/definition.ts +23 -0
- package/_src/TFuture.ts +5 -0
- package/_src/TRef/api.ts +312 -0
- package/_src/TRef/constructors.ts +69 -0
- package/_src/TRef/definition.ts +230 -0
- package/_src/TRef.ts +5 -0
- package/_src/TSemaphore/api.ts +68 -0
- package/_src/TSemaphore/constructors.ts +14 -0
- package/_src/TSemaphore/definition.ts +21 -0
- package/_src/TSemaphore.ts +5 -0
- package/_src/TxnId.ts +19 -0
- package/_src/collection/immutable/Conc/findIO.ts +37 -0
- package/_src/collection/immutable/Conc/mapIO.ts +13 -0
- package/_src/collection/immutable/Conc/takeWhileIO.ts +32 -0
- package/_src/collection/immutable/Conc.ts +5 -0
- package/_src/data/Exit/foreachIO.ts +15 -0
- package/_src/internal/HashedPair.ts +15 -0
- package/_src/internal/Hub.ts +754 -0
- package/_src/internal/MutableQueue.ts +295 -0
- package/_src/internal/Scheduler.ts +15 -0
- package/_src/internal/StackTraceBuilder.ts +16 -0
- package/collection/immutable/Conc/findIO.d.ts +8 -0
- package/collection/immutable/Conc/mapIO.d.ts +7 -0
- package/collection/immutable/Conc/takeWhileIO.d.ts +7 -0
- package/collection/immutable/Conc.d.ts +3 -0
- package/data/Exit/foreachIO.d.ts +9 -0
- package/internal/HashedPair.d.ts +9 -0
- package/internal/Hub.d.ts +121 -0
- package/internal/MutableQueue.d.ts +125 -0
- package/internal/Scheduler.d.ts +1 -0
- package/internal/StackTraceBuilder.d.ts +8 -0
- package/package.json +17 -0
@@ -0,0 +1,2931 @@
|
|
1
|
+
import type { PHub } from "../Hub.js";
|
2
|
+
import type { Canceler } from "../IO.js";
|
3
|
+
import type { PQueue } from "../Queue.js";
|
4
|
+
import type { SinkEndReason } from "./internal/SinkEndReason.js";
|
5
|
+
import type { Erase } from "@fncts/typelevel/Intersection.js";
|
6
|
+
|
7
|
+
import { constVoid, identity, tuple } from "@fncts/base/data/function";
|
8
|
+
|
9
|
+
import { MergeDecision } from "../Channel/internal/MergeDecision.js";
|
10
|
+
import { Queue } from "../Queue.js";
|
11
|
+
import { DEFAULT_CHUNK_SIZE, Stream } from "./definition.js";
|
12
|
+
import { DebounceState } from "./internal/DebounceState.js";
|
13
|
+
import { Handoff, HandoffSignal } from "./internal/Handoff.js";
|
14
|
+
import { Pull } from "./internal/Pull.js";
|
15
|
+
import { ScheduleEnd, ScheduleTimeout, SinkEnd, UpstreamEnd } from "./internal/SinkEndReason.js";
|
16
|
+
import { Take } from "./internal/Take.js";
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Submerges the error case of an `Either` into the `Stream`.
|
20
|
+
*
|
21
|
+
* @tsplus getter fncts.io.Stream absolve
|
22
|
+
*/
|
23
|
+
export function absolve<R, E, E2, A>(self: Stream<R, E, Either<E2, A>>): Stream<R, E | E2, A> {
|
24
|
+
return self.mapIO((either) => IO.fromEither(either));
|
25
|
+
}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Aggregates elements of this stream using the provided sink for as long
|
29
|
+
* as the downstream operators on the stream are busy.
|
30
|
+
*
|
31
|
+
* This operator divides the stream into two asynchronous "islands". Operators upstream
|
32
|
+
* of this operator run on one fiber, while downstream operators run on another. Whenever
|
33
|
+
* the downstream fiber is busy processing elements, the upstream fiber will feed elements
|
34
|
+
* into the sink until it signals completion.
|
35
|
+
*
|
36
|
+
* Any sink can be used here, but see `Sink.foldWeightedM` and `Sink.foldUntilM` for
|
37
|
+
* sinks that cover the common usecases.
|
38
|
+
*
|
39
|
+
* @tsplus fluent fncts.io.Stream aggregateAsync
|
40
|
+
*/
|
41
|
+
export function aggregateAsync_<R, E, A extends A1, R1, E1, A1, B>(
|
42
|
+
stream: Stream<R, E, A>,
|
43
|
+
sink: Sink<R1, E1, A1, A1, B>,
|
44
|
+
): Stream<R & R1, E | E1, B> {
|
45
|
+
return stream.aggregateAsyncWithin(sink, Schedule.forever);
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Like `aggregateAsyncWithinEither`, but only returns the `Right` results.
|
50
|
+
*
|
51
|
+
* @tsplus fluent fncts.io.Stream aggregateAsyncWithin
|
52
|
+
*/
|
53
|
+
export function aggregateAsyncWithin_<R, E, A extends A1, R1, E1, A1, B, R2, C>(
|
54
|
+
stream: Stream<R, E, A>,
|
55
|
+
sink: Sink<R1, E1, A1, A1, B>,
|
56
|
+
schedule: Schedule<R2, Maybe<B>, C>,
|
57
|
+
): Stream<R & R1 & R2, E | E1, B> {
|
58
|
+
return stream.aggregateAsyncWithinEither(sink, schedule).filterMap((cb) => cb.match(() => Nothing(), Maybe.just));
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Aggregates elements using the provided sink until it completes, or until the
|
63
|
+
* delay signalled by the schedule has passed.
|
64
|
+
*
|
65
|
+
* This operator divides the stream into two asynchronous islands. Operators upstream
|
66
|
+
* of this operator run on one fiber, while downstream operators run on another. Elements
|
67
|
+
* will be aggregated by the sink until the downstream fiber pulls the aggregated value,
|
68
|
+
* or until the schedule's delay has passed.
|
69
|
+
*
|
70
|
+
* Aggregated elements will be fed into the schedule to determine the delays between
|
71
|
+
* pulls.
|
72
|
+
*
|
73
|
+
* @tsplus fluent fncts.io.Stream aggregateAsyncWithinEither
|
74
|
+
*/
|
75
|
+
export function aggregateAsyncWithinEither_<R, E, A extends A1, R1, E1, A1, B, R2, C>(
|
76
|
+
stream: Stream<R, E, A>,
|
77
|
+
sink: Sink<R1, E1, A1, A1, B>,
|
78
|
+
schedule: Schedule<R2, Maybe<B>, C>,
|
79
|
+
): Stream<R & R1 & R2, E | E1, Either<C, B>> {
|
80
|
+
type LocalHandoffSignal = HandoffSignal<C, E | E1, A1>;
|
81
|
+
type LocalSinkEndReason = SinkEndReason<C>;
|
82
|
+
|
83
|
+
const deps = IO.sequenceT(
|
84
|
+
Handoff<LocalHandoffSignal>(),
|
85
|
+
Ref.make<LocalSinkEndReason>(new SinkEnd()),
|
86
|
+
Ref.make(Conc.empty<A1>()),
|
87
|
+
schedule.driver,
|
88
|
+
);
|
89
|
+
|
90
|
+
return Stream.fromIO(deps).flatMap(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver]) => {
|
91
|
+
const handoffProducer: Channel<unknown, E | E1, Conc<A1>, unknown, never, never, any> = Channel.readWithCause(
|
92
|
+
(_in: Conc<A1>) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(_in))).apSecond(handoffProducer),
|
93
|
+
(cause: Cause<E | E1>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
|
94
|
+
(_: any) => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
|
95
|
+
);
|
96
|
+
|
97
|
+
const handoffConsumer: Channel<unknown, unknown, unknown, unknown, E | E1, Conc<A1>, void> = Channel.unwrap(
|
98
|
+
sinkLeftovers.getAndSet(Conc.empty<A>()).flatMap((leftovers) => {
|
99
|
+
if (leftovers.isEmpty) {
|
100
|
+
return IO.succeedNow(Channel.writeNow(leftovers).apSecond(handoffConsumer));
|
101
|
+
} else {
|
102
|
+
return handoff.take.map((signal) =>
|
103
|
+
signal.match({
|
104
|
+
Emit: ({ els }) => Channel.writeNow(els).apSecond(handoffConsumer),
|
105
|
+
Halt: ({ error }) => Channel.failCause(error),
|
106
|
+
End: ({ reason }) => Channel.fromIO(sinkEndReason.set(reason)),
|
107
|
+
}),
|
108
|
+
);
|
109
|
+
}
|
110
|
+
}),
|
111
|
+
);
|
112
|
+
|
113
|
+
const scheduledAggregator = (
|
114
|
+
lastB: Maybe<B>,
|
115
|
+
): Channel<R1 & R2, unknown, unknown, unknown, E | E1, Conc<Either<C, B>>, any> => {
|
116
|
+
const timeout = scheduleDriver.next(lastB).matchCauseIO(
|
117
|
+
(_) =>
|
118
|
+
_.failureOrCause.match(
|
119
|
+
() => handoff.offer(HandoffSignal.End(new ScheduleTimeout())),
|
120
|
+
(cause) => handoff.offer(HandoffSignal.Halt(cause)),
|
121
|
+
),
|
122
|
+
(c) => handoff.offer(HandoffSignal.End(new ScheduleEnd(c))),
|
123
|
+
);
|
124
|
+
|
125
|
+
return Channel.unwrapScoped(
|
126
|
+
timeout.forkScoped.map((fiber) => {
|
127
|
+
return handoffConsumer.pipeToOrFail(sink.channel).doneCollect.flatMap(([leftovers, b]) => {
|
128
|
+
return Channel.fromIO(fiber.interrupt.apSecond(sinkLeftovers.set(leftovers.flatten))).apSecond(
|
129
|
+
Channel.unwrap(
|
130
|
+
sinkEndReason.modify((reason) =>
|
131
|
+
reason.match({
|
132
|
+
ScheduleEnd: ({ c }) =>
|
133
|
+
tuple(Channel.writeNow(Conc.from([Either.right(b), Either.left(c)])).as(Just(b)), new SinkEnd()),
|
134
|
+
ScheduleTimeout: () =>
|
135
|
+
tuple(Channel.writeNow(Conc.single(Either.right(b))).as(Just(b)), new SinkEnd()),
|
136
|
+
SinkEnd: () => tuple(Channel.writeNow(Conc.single(Either.right(b))).as(Just(b)), new SinkEnd()),
|
137
|
+
UpstreamEnd: () =>
|
138
|
+
tuple(Channel.writeNow(Conc.single(Either.right(b))).as(Nothing()), new UpstreamEnd()),
|
139
|
+
}),
|
140
|
+
),
|
141
|
+
),
|
142
|
+
);
|
143
|
+
});
|
144
|
+
}),
|
145
|
+
).flatMap((_) =>
|
146
|
+
_.match(
|
147
|
+
() => Channel.unit,
|
148
|
+
() => scheduledAggregator(_),
|
149
|
+
),
|
150
|
+
);
|
151
|
+
};
|
152
|
+
|
153
|
+
return Stream.scoped(stream.channel.pipeTo(handoffProducer).runScoped.forkDaemon).apSecond(
|
154
|
+
new Stream(scheduledAggregator(Nothing())),
|
155
|
+
);
|
156
|
+
});
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Composes this stream with the specified stream to create a cartesian product of elements,
|
161
|
+
* but keeps only elements from this stream.
|
162
|
+
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
163
|
+
*
|
164
|
+
* @tsplus fluent fncts.io.Stream apFirst
|
165
|
+
*/
|
166
|
+
export function apFirst_<R, R1, E, E1, A, A1>(
|
167
|
+
stream: Stream<R, E, A>,
|
168
|
+
that: Stream<R1, E1, A1>,
|
169
|
+
): Stream<R & R1, E | E1, A> {
|
170
|
+
return stream.crossWith(that, (a, _) => a);
|
171
|
+
}
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Composes this stream with the specified stream to create a cartesian product of elements,
|
175
|
+
* but keeps only elements from the other stream.
|
176
|
+
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
177
|
+
*
|
178
|
+
* @tsplus fluent fncts.io.Stream apSecond
|
179
|
+
*/
|
180
|
+
export function apSecond_<R, R1, E, E1, A, A1>(
|
181
|
+
stream: Stream<R, E, A>,
|
182
|
+
that: Stream<R1, E1, A1>,
|
183
|
+
): Stream<R & R1, E | E1, A1> {
|
184
|
+
return stream.crossWith(that, (_, b) => b);
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Maps the success values of this stream to the specified constant value.
|
189
|
+
*
|
190
|
+
* @tsplus fluent fncts.io.Stream as
|
191
|
+
*/
|
192
|
+
export function as_<R, E, A, B>(stream: Stream<R, E, A>, b: Lazy<B>): Stream<R, E, B> {
|
193
|
+
return stream.map(() => b());
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* @tsplus static fncts.io.StreamOps asyncInterrupt
|
198
|
+
*/
|
199
|
+
export function asyncInterrupt<R, E, A>(
|
200
|
+
register: (
|
201
|
+
resolve: (next: IO<R, Maybe<E>, Conc<A>>, offerCb?: (e: Exit<never, boolean>) => void) => void,
|
202
|
+
) => Either<Canceler<R>, Stream<R, E, A>>,
|
203
|
+
outputBuffer = 16,
|
204
|
+
): Stream<R, E, A> {
|
205
|
+
return Stream.unwrapScoped(
|
206
|
+
Do((Δ) => {
|
207
|
+
const output = Δ(IO.acquireRelease(Queue.makeBounded<Take<E, A>>(outputBuffer), (queue) => queue.shutdown));
|
208
|
+
const runtime = Δ(IO.runtime<R>());
|
209
|
+
const eitherStream = Δ(
|
210
|
+
IO.succeed(() =>
|
211
|
+
register((k, cb) => {
|
212
|
+
const effect = Take.fromPull(k).flatMap((a) => output.offer(a));
|
213
|
+
return runtime.unsafeRunAsyncWith(effect, cb || constVoid);
|
214
|
+
}),
|
215
|
+
),
|
216
|
+
);
|
217
|
+
return eitherStream.match(
|
218
|
+
(canceler) => {
|
219
|
+
const loop: Channel<unknown, unknown, unknown, unknown, E, Conc<A>, void> = Channel.unwrap(
|
220
|
+
output.take
|
221
|
+
.flatMap((take) => take.done)
|
222
|
+
.match(
|
223
|
+
(maybeError) => maybeError.match(() => Channel.endNow(undefined), Channel.failNow),
|
224
|
+
(as) => Channel.writeNow(as) > loop,
|
225
|
+
),
|
226
|
+
);
|
227
|
+
return new Stream(loop).ensuring(canceler);
|
228
|
+
},
|
229
|
+
(stream) => Stream.unwrap(output.shutdown.as(stream)),
|
230
|
+
);
|
231
|
+
}),
|
232
|
+
);
|
233
|
+
}
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Creates a stream from an asynchronous callback that can be called multiple times.
|
237
|
+
* The registration of the callback can possibly return the stream synchronously.
|
238
|
+
* The optionality of the error type `E` can be used to signal the end of the stream,
|
239
|
+
* by setting it to `None`.
|
240
|
+
*
|
241
|
+
* @tsplus static fncts.io.StreamOps asyncMaybe
|
242
|
+
*/
|
243
|
+
export function asyncMaybe<R, E, A>(
|
244
|
+
register: (
|
245
|
+
resolve: (next: IO<R, Maybe<E>, Conc<A>>, offerCb?: (e: Exit<never, boolean>) => void) => void,
|
246
|
+
) => Maybe<Stream<R, E, A>>,
|
247
|
+
outputBuffer = 16,
|
248
|
+
): Stream<R, E, A> {
|
249
|
+
return Stream.asyncInterrupt((k) => register(k).match(() => Either.left(IO.unit), Either.right), outputBuffer);
|
250
|
+
}
|
251
|
+
|
252
|
+
/**
|
253
|
+
* @tsplus static fncts.io.StreamOps async
|
254
|
+
*/
|
255
|
+
export function async<R, E, A>(
|
256
|
+
register: (resolve: (next: IO<R, Maybe<E>, Conc<A>>, offerCb?: (e: Exit<never, boolean>) => void) => void) => void,
|
257
|
+
outputBuffer = 16,
|
258
|
+
): Stream<R, E, A> {
|
259
|
+
return Stream.asyncMaybe((cb) => {
|
260
|
+
register(cb);
|
261
|
+
return Nothing();
|
262
|
+
}, outputBuffer);
|
263
|
+
}
|
264
|
+
|
265
|
+
/**
|
266
|
+
* @tsplus static fncts.io.StreamOps asyncIO
|
267
|
+
*/
|
268
|
+
export function asyncIO<R, E, A, R1 = R, E1 = E>(
|
269
|
+
register: (
|
270
|
+
resolve: (next: IO<R, Maybe<E>, Conc<A>>, offerCb?: (e: Exit<never, boolean>) => void) => void,
|
271
|
+
) => IO<R1, E1, unknown>,
|
272
|
+
outputBuffer = 16,
|
273
|
+
): Stream<R & R1, E | E1, A> {
|
274
|
+
return new Stream(
|
275
|
+
Channel.unwrapScoped(
|
276
|
+
Do((Δ) => {
|
277
|
+
const output = Δ(IO.acquireRelease(Queue.makeBounded<Take<E, A>>(outputBuffer), (_) => _.shutdown));
|
278
|
+
const runtime = Δ(IO.runtime<R>());
|
279
|
+
Δ(
|
280
|
+
register((k, cb) =>
|
281
|
+
runtime.unsafeRunAsyncWith(
|
282
|
+
Take.fromPull(k).flatMap((a) => output.offer(a)),
|
283
|
+
cb || constVoid,
|
284
|
+
),
|
285
|
+
),
|
286
|
+
);
|
287
|
+
const loop: Channel<unknown, unknown, unknown, unknown, E, Conc<A>, void> = Channel.unwrap(
|
288
|
+
output.take
|
289
|
+
.flatMap((take) => take.done)
|
290
|
+
.matchCauseIO(
|
291
|
+
(cause) =>
|
292
|
+
output.shutdown.as(
|
293
|
+
cause.failureOrCause.match(
|
294
|
+
(maybeError) => maybeError.match(() => Channel.endNow(undefined), Channel.failNow),
|
295
|
+
Channel.failCauseNow,
|
296
|
+
),
|
297
|
+
),
|
298
|
+
(as) => IO.succeed(Channel.writeNow(as) > loop),
|
299
|
+
),
|
300
|
+
);
|
301
|
+
return loop;
|
302
|
+
}),
|
303
|
+
),
|
304
|
+
);
|
305
|
+
}
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Returns a stream whose failure and success channels have been mapped by
|
309
|
+
* the specified pair of functions, `f` and `g`.
|
310
|
+
*/
|
311
|
+
export function bimap_<R, E, E1, A, A1>(stream: Stream<R, E, A>, f: (e: E) => E1, g: (a: A) => A1): Stream<R, E1, A1> {
|
312
|
+
return stream.mapError(f).map(g);
|
313
|
+
}
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Creates a stream from a single value that will get cleaned up after the
|
317
|
+
* stream is consumed
|
318
|
+
*
|
319
|
+
* @tsplus static fncts.io.StreamOps acquireRelease
|
320
|
+
*/
|
321
|
+
export function acquireRelease_<R, E, A, R1>(
|
322
|
+
acquire: IO<R, E, A>,
|
323
|
+
release: (a: A) => IO<R1, never, unknown>,
|
324
|
+
): Stream<R & R1, E, A> {
|
325
|
+
return Stream.scoped(IO.acquireRelease(acquire, release));
|
326
|
+
}
|
327
|
+
|
328
|
+
/**
|
329
|
+
* Creates a stream from a single value that will get cleaned up after the
|
330
|
+
* stream is consumed
|
331
|
+
*
|
332
|
+
* @tsplus static fncts.io.StreamOps acquireReleaseExit
|
333
|
+
*/
|
334
|
+
export function acquireReleaseExit_<R, E, A, R1>(
|
335
|
+
acquire: IO<R, E, A>,
|
336
|
+
release: (a: A, exit: Exit<any, any>) => IO<R1, never, unknown>,
|
337
|
+
): Stream<R & R1, E, A> {
|
338
|
+
return Stream.scoped(IO.acquireReleaseExit(acquire, release));
|
339
|
+
}
|
340
|
+
|
341
|
+
/**
|
342
|
+
* Fan out the stream, producing a list of streams that have the same elements as this stream.
|
343
|
+
* The driver stream will only ever advance of the `maximumLag` chunks before the
|
344
|
+
* slowest downstream stream.
|
345
|
+
*
|
346
|
+
* @tsplus fluent fncts.io.Stream broadcast
|
347
|
+
*/
|
348
|
+
export function broadcast_<R, E, A>(
|
349
|
+
stream: Stream<R, E, A>,
|
350
|
+
n: number,
|
351
|
+
maximumLag: number,
|
352
|
+
): IO<R & Has<Scope>, never, Conc<Stream<unknown, E, A>>> {
|
353
|
+
return stream
|
354
|
+
.broadcastedQueues(n, maximumLag)
|
355
|
+
.map((c) => c.map((hub) => Stream.fromQueueWithShutdown(hub).flattenTake));
|
356
|
+
}
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Fan out the stream, producing a dynamic number of streams that have the same elements as this stream.
|
360
|
+
* The driver stream will only ever advance of the `maximumLag` chunks before the
|
361
|
+
* slowest downstream stream.
|
362
|
+
*
|
363
|
+
* @tsplus fluent fncts.io.Stream broadcastDynamic
|
364
|
+
*/
|
365
|
+
export function broadcastDynamic_<R, E, A>(
|
366
|
+
stream: Stream<R, E, A>,
|
367
|
+
maximumLag: number,
|
368
|
+
): IO<R & Has<Scope>, never, Stream<unknown, E, A>> {
|
369
|
+
return stream
|
370
|
+
.broadcastedQueuesDynamic(maximumLag)
|
371
|
+
.map((scoped) => Stream.scoped(scoped).flatMap(Stream.fromQueue).flattenTake);
|
372
|
+
}
|
373
|
+
|
374
|
+
/**
|
375
|
+
* Converts the stream to a managed list of queues. Every value will be replicated to every queue with the
|
376
|
+
* slowest queue being allowed to buffer `maximumLag` chunks before the driver is backpressured.
|
377
|
+
*
|
378
|
+
* Queues can unsubscribe from upstream by shutting down.
|
379
|
+
*
|
380
|
+
* @tsplus fluent fncts.io.Stream broadcastedQueues
|
381
|
+
*/
|
382
|
+
export function broadcastedQueues_<R, E, A>(
|
383
|
+
stream: Stream<R, E, A>,
|
384
|
+
n: number,
|
385
|
+
maximumLag: number,
|
386
|
+
): IO<R & Has<Scope>, never, Conc<Hub.Dequeue<unknown, never, Take<E, A>>>> {
|
387
|
+
return Do((Δ) => {
|
388
|
+
const hub = Δ(Hub.makeBounded<Take<E, A>>(maximumLag));
|
389
|
+
const queues = Δ(IO.sequenceIterable(Conc.replicate(n, hub.subscribe)));
|
390
|
+
Δ(stream.runIntoHubScoped(hub).fork);
|
391
|
+
return queues;
|
392
|
+
});
|
393
|
+
}
|
394
|
+
|
395
|
+
/**
|
396
|
+
* Converts the stream to a managed dynamic amount of queues. Every chunk will be replicated to every queue with the
|
397
|
+
* slowest queue being allowed to buffer `maximumLag` chunks before the driver is backpressured.
|
398
|
+
*
|
399
|
+
* Queues can unsubscribe from upstream by shutting down.
|
400
|
+
*
|
401
|
+
* @tsplus fluent fncts.io.Stream broadcastedQueuesDynamic
|
402
|
+
*/
|
403
|
+
export function broadcastedQueuesDynamic_<R, E, A>(
|
404
|
+
stream: Stream<R, E, A>,
|
405
|
+
maximumLag: number,
|
406
|
+
): IO<R & Has<Scope>, never, IO<Has<Scope>, never, Hub.Dequeue<unknown, never, Take<E, A>>>> {
|
407
|
+
return stream.toHub(maximumLag).map((hub) => hub.subscribe);
|
408
|
+
}
|
409
|
+
|
410
|
+
/**
|
411
|
+
* Allows a faster producer to progress independently of a slower consumer by buffering
|
412
|
+
* up to `capacity` elements in a queue.
|
413
|
+
*
|
414
|
+
* @tsplus fluent fncts.io.Stream buffer
|
415
|
+
*/
|
416
|
+
export function buffer_<R, E, A>(stream: Stream<R, E, A>, capacity: number): Stream<R, E, A> {
|
417
|
+
const queue = toQueueOfElements_(stream, capacity);
|
418
|
+
return new Stream(
|
419
|
+
Channel.unwrapScoped(
|
420
|
+
queue.map((queue) => {
|
421
|
+
const process: Channel<unknown, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
|
422
|
+
queue.take,
|
423
|
+
).flatMap((exit: Exit<Maybe<E>, A>) =>
|
424
|
+
exit.match(
|
425
|
+
(cause) => cause.flipCauseMaybe.match(() => Channel.endNow(undefined), Channel.failCauseNow),
|
426
|
+
(value) => Channel.writeNow(Conc.single(value)).apSecond(process),
|
427
|
+
),
|
428
|
+
);
|
429
|
+
return process;
|
430
|
+
}),
|
431
|
+
),
|
432
|
+
);
|
433
|
+
}
|
434
|
+
|
435
|
+
/**
|
436
|
+
* @tsplus fluent fncts.io.Stream bufferChunks
|
437
|
+
*/
|
438
|
+
export function bufferChunks_<R, E, A>(stream: Stream<R, E, A>, capacity: number): Stream<R, E, A> {
|
439
|
+
const queue = stream.toQueue(capacity);
|
440
|
+
return new Stream(
|
441
|
+
Channel.unwrapScoped(
|
442
|
+
queue.map((queue) => {
|
443
|
+
const process: Channel<unknown, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
|
444
|
+
queue.take,
|
445
|
+
).flatMap((take: Take<E, A>) =>
|
446
|
+
take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
|
447
|
+
Channel.writeNow(value).apSecond(process),
|
448
|
+
),
|
449
|
+
);
|
450
|
+
return process;
|
451
|
+
}),
|
452
|
+
),
|
453
|
+
);
|
454
|
+
}
|
455
|
+
|
456
|
+
/**
|
457
|
+
* Allows a faster producer to progress independently of a slower consumer by buffering
|
458
|
+
* elements into an unbounded queue.
|
459
|
+
*
|
460
|
+
* @tsplus getter fncts.io.Stream bufferUnbounded
|
461
|
+
*/
|
462
|
+
export function bufferUnbounded<R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> {
|
463
|
+
const queue = stream.toQueueUnbounded;
|
464
|
+
|
465
|
+
return new Stream(
|
466
|
+
Channel.unwrapScoped(
|
467
|
+
queue.map((queue) => {
|
468
|
+
const process: Channel<unknown, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(
|
469
|
+
queue.take,
|
470
|
+
).flatMap((take) =>
|
471
|
+
take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
|
472
|
+
Channel.writeNow(value).apSecond(process),
|
473
|
+
),
|
474
|
+
);
|
475
|
+
|
476
|
+
return process;
|
477
|
+
}),
|
478
|
+
),
|
479
|
+
);
|
480
|
+
}
|
481
|
+
|
482
|
+
function bufferSignalProducer<R, E, A>(
|
483
|
+
queue: Queue<readonly [Take<E, A>, Future<never, void>]>,
|
484
|
+
ref: Ref<Future<never, void>>,
|
485
|
+
): Channel<R, E, Conc<A>, unknown, never, never, unknown> {
|
486
|
+
const terminate = (take: Take<E, A>): Channel<R, E, Conc<A>, unknown, never, never, unknown> =>
|
487
|
+
Channel.fromIO(
|
488
|
+
Do((Δ) => {
|
489
|
+
const latch = Δ(ref.get);
|
490
|
+
Δ(latch.await);
|
491
|
+
const p = Δ(Future.make<never, void>());
|
492
|
+
Δ(queue.offer(tuple(take, p)));
|
493
|
+
Δ(ref.set(p));
|
494
|
+
Δ(p.await);
|
495
|
+
}),
|
496
|
+
);
|
497
|
+
return Channel.readWith(
|
498
|
+
(inp) =>
|
499
|
+
Channel.fromIO(
|
500
|
+
Do((Δ) => {
|
501
|
+
const p = Δ(Future.make<never, void>());
|
502
|
+
const added = Δ(queue.offer(tuple(Take.chunk(inp), p)));
|
503
|
+
Δ(ref.set(p).when(added));
|
504
|
+
}),
|
505
|
+
) > bufferSignalProducer(queue, ref),
|
506
|
+
(e) => terminate(Take.fail(e)),
|
507
|
+
() => terminate(Take.end),
|
508
|
+
);
|
509
|
+
}
|
510
|
+
|
511
|
+
function bufferSignalConsumer<R, E, A>(
|
512
|
+
queue: Queue<readonly [Take<E, A>, Future<never, void>]>,
|
513
|
+
): Channel<R, unknown, unknown, unknown, E, Conc<A>, void> {
|
514
|
+
const process: Channel<unknown, unknown, unknown, unknown, E, Conc<A>, void> = Channel.fromIO(queue.take).flatMap(
|
515
|
+
([take, promise]) =>
|
516
|
+
Channel.fromIO(promise.succeed(undefined)).apSecond(
|
517
|
+
take.match(Channel.endNow(undefined), Channel.failCauseNow, (value) =>
|
518
|
+
Channel.writeNow(value).apSecond(process),
|
519
|
+
),
|
520
|
+
),
|
521
|
+
);
|
522
|
+
return process;
|
523
|
+
}
|
524
|
+
|
525
|
+
/**
|
526
|
+
* Switches over to the stream produced by the provided function in case this one
|
527
|
+
* fails with a typed error.
|
528
|
+
*
|
529
|
+
* @tsplus fluent fncts.io.Stream catchAll
|
530
|
+
*/
|
531
|
+
export function catchAll_<R, R1, E, E1, A, A1>(
|
532
|
+
stream: Stream<R, E, A>,
|
533
|
+
f: (e: E) => Stream<R1, E1, A1>,
|
534
|
+
): Stream<R & R1, E1, A | A1> {
|
535
|
+
return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
|
536
|
+
}
|
537
|
+
|
538
|
+
/**
|
539
|
+
* Switches over to the stream produced by the provided function in case this one
|
540
|
+
* fails. Allows recovery from all causes of failure, including interruption if the
|
541
|
+
* stream is uninterruptible.
|
542
|
+
*
|
543
|
+
* @tsplus fluent fncts.io.Stream catchAllCause
|
544
|
+
*/
|
545
|
+
export function catchAllCause_<R, R1, E, E1, A, A1>(
|
546
|
+
stream: Stream<R, E, A>,
|
547
|
+
f: (cause: Cause<E>) => Stream<R1, E1, A1>,
|
548
|
+
): Stream<R & R1, E1, A | A1> {
|
549
|
+
const channel: Channel<R & R1, unknown, unknown, unknown, E1, Conc<A | A1>, unknown> = stream.channel.catchAllCause(
|
550
|
+
(cause) => f(cause).channel,
|
551
|
+
);
|
552
|
+
return new Stream(channel);
|
553
|
+
}
|
554
|
+
|
555
|
+
/**
|
556
|
+
* Switches over to the stream produced by the provided function in case this one
|
557
|
+
* fails with some typed error.
|
558
|
+
*
|
559
|
+
* @tsplus fluent fncts.io.Stream catchJust
|
560
|
+
*/
|
561
|
+
export function catchJust_<R, R1, E, E1, A, A1>(
|
562
|
+
stream: Stream<R, E, A>,
|
563
|
+
pf: (e: E) => Maybe<Stream<R1, E1, A1>>,
|
564
|
+
): Stream<R & R1, E | E1, A | A1> {
|
565
|
+
return stream.catchAll((e) => pf(e).getOrElse(Stream.failNow(e)));
|
566
|
+
}
|
567
|
+
|
568
|
+
/**
|
569
|
+
* Switches over to the stream produced by the provided function in case this one
|
570
|
+
* fails with some errors. Allows recovery from all causes of failure, including interruption if the
|
571
|
+
* stream is uninterruptible.
|
572
|
+
*
|
573
|
+
* @tsplus fluent fncts.io.Stream catchJustCause
|
574
|
+
*/
|
575
|
+
export function catchJustCause_<R, R1, E, E1, A, A1>(
|
576
|
+
stream: Stream<R, E, A>,
|
577
|
+
pf: (e: Cause<E>) => Maybe<Stream<R1, E1, A1>>,
|
578
|
+
): Stream<R & R1, E | E1, A | A1> {
|
579
|
+
return stream.catchAllCause((cause) => pf(cause).getOrElse(Stream.failCauseNow(cause)));
|
580
|
+
}
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Returns a stream made of the concatenation in strict order of all the streams
|
584
|
+
* produced by passing each element of this stream to `f`
|
585
|
+
*
|
586
|
+
* @tsplus fluent fncts.io.Stream flatMap
|
587
|
+
*/
|
588
|
+
export function flatMap_<R, E, A, R1, E1, B>(
|
589
|
+
stream: Stream<R, E, A>,
|
590
|
+
f: (a: A) => Stream<R1, E1, B>,
|
591
|
+
): Stream<R & R1, E | E1, B> {
|
592
|
+
return new Stream(
|
593
|
+
stream.channel.concatMap((as) =>
|
594
|
+
as
|
595
|
+
.map((a) => f(a).channel)
|
596
|
+
.foldLeft(Channel.unit as Channel<R1, unknown, unknown, unknown, E1, Conc<B>, unknown>, (s, a) =>
|
597
|
+
s.flatMap(() => a),
|
598
|
+
),
|
599
|
+
),
|
600
|
+
);
|
601
|
+
}
|
602
|
+
|
603
|
+
/**
|
604
|
+
* Exposes the underlying chunks of the stream as a stream of chunks of elements
|
605
|
+
*
|
606
|
+
* @tsplus getter fncts.io.Stream chunks
|
607
|
+
*/
|
608
|
+
export function chunks<R, E, A>(stream: Stream<R, E, A>): Stream<R, E, Conc<A>> {
|
609
|
+
return stream.mapChunks(Conc.single);
|
610
|
+
}
|
611
|
+
|
612
|
+
function changesWithWriter<R, E, A>(
|
613
|
+
f: (x: A, y: A) => boolean,
|
614
|
+
last: Maybe<A>,
|
615
|
+
): Channel<R, E, Conc<A>, unknown, E, Conc<A>, void> {
|
616
|
+
return Channel.readWithCause(
|
617
|
+
(chunk: Conc<A>) => {
|
618
|
+
const [newLast, newChunk] = chunk.foldLeft([last, Conc.empty<A>()], ([maybeLast, os], o1) =>
|
619
|
+
maybeLast.match(
|
620
|
+
() => [Just(o1), os.append(o1)],
|
621
|
+
(o) => (f(o, o1) ? [Just(o1), os] : [Just(o1), os.append(o1)]),
|
622
|
+
),
|
623
|
+
);
|
624
|
+
return Channel.writeNow(newChunk).apSecond(changesWithWriter(f, newLast));
|
625
|
+
},
|
626
|
+
Channel.failCauseNow,
|
627
|
+
() => Channel.unit,
|
628
|
+
);
|
629
|
+
}
|
630
|
+
|
631
|
+
/**
|
632
|
+
* Returns a new stream that only emits elements that are not equal to the
|
633
|
+
* previous element emitted, using the specified function to determine
|
634
|
+
* whether two elements are equal.
|
635
|
+
*
|
636
|
+
* @tsplus fluent fncts.io.Stream changesWith
|
637
|
+
*/
|
638
|
+
export function changesWith_<R, E, A>(stream: Stream<R, E, A>, f: (x: A, y: A) => boolean): Stream<R, E, A> {
|
639
|
+
return new Stream(stream.channel.pipeTo(changesWithWriter<R, E, A>(f, Nothing())));
|
640
|
+
}
|
641
|
+
|
642
|
+
/**
|
643
|
+
* Transforms all elements of the stream for as long as the specified partial function is defined.
|
644
|
+
*
|
645
|
+
* @tsplus fluent fncts.io.Stream collectWhile
|
646
|
+
*/
|
647
|
+
export function collectWhile_<R, E, A, A1>(stream: Stream<R, E, A>, pf: (a: A) => Maybe<A1>): Stream<R, E, A1> {
|
648
|
+
const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A1>, any> = Channel.readWith(
|
649
|
+
(inp) => {
|
650
|
+
const mapped = inp.collectWhile(pf);
|
651
|
+
|
652
|
+
if (mapped.length === inp.length) {
|
653
|
+
return Channel.writeNow(mapped).apSecond(loop);
|
654
|
+
} else {
|
655
|
+
return Channel.writeNow(mapped);
|
656
|
+
}
|
657
|
+
},
|
658
|
+
Channel.failNow,
|
659
|
+
Channel.succeedNow,
|
660
|
+
);
|
661
|
+
|
662
|
+
return new Stream(stream.channel.pipeTo(loop));
|
663
|
+
}
|
664
|
+
|
665
|
+
/**
|
666
|
+
* Effectfully transforms all elements of the stream for as long as the specified partial function is defined.
|
667
|
+
*/
|
668
|
+
export function collectWhileIO_<R, E, A, R1, E1, B>(
|
669
|
+
stream: Stream<R, E, A>,
|
670
|
+
pf: (a: A) => Maybe<IO<R1, E1, B>>,
|
671
|
+
): Stream<R & R1, E | E1, B> {
|
672
|
+
return stream.loopOnPartialChunks((chunk, emit) => {
|
673
|
+
const pfJust = (a: A) =>
|
674
|
+
pf(a).match(
|
675
|
+
() => IO.succeedNow(false),
|
676
|
+
(effect) => effect.flatMap(emit).as(true),
|
677
|
+
);
|
678
|
+
|
679
|
+
const loop = (chunk: Conc<A>): IO<R1, E1, boolean> => {
|
680
|
+
if (chunk.isEmpty) {
|
681
|
+
return IO.succeedNow(true);
|
682
|
+
} else {
|
683
|
+
return pfJust(chunk.unsafeHead).flatMap((cont) => (cont ? loop(chunk.unsafeTail) : IO.succeedNow(false)));
|
684
|
+
}
|
685
|
+
};
|
686
|
+
|
687
|
+
return loop(chunk);
|
688
|
+
});
|
689
|
+
}
|
690
|
+
|
691
|
+
function combineProducer<Err, Elem>(
|
692
|
+
handoff: Handoff<Exit<Maybe<Err>, Elem>>,
|
693
|
+
latch: Handoff<void>,
|
694
|
+
): Channel<unknown, Err, Elem, unknown, never, never, any> {
|
695
|
+
return Channel.fromIO(latch.take).apSecond(
|
696
|
+
Channel.readWithCause(
|
697
|
+
(value) => Channel.fromIO(handoff.offer(Exit.succeed(value))).apSecond(combineProducer(handoff, latch)),
|
698
|
+
(cause) => Channel.fromIO(handoff.offer(Exit.failCause(cause.map(Maybe.just)))),
|
699
|
+
() => Channel.fromIO(handoff.offer(Exit.fail(Nothing()))).apSecond(combineProducer(handoff, latch)),
|
700
|
+
),
|
701
|
+
);
|
702
|
+
}
|
703
|
+
|
704
|
+
/**
|
705
|
+
* Combines the elements from this stream and the specified stream by repeatedly applying the
|
706
|
+
* function `f` to extract an element using both sides and conceptually "offer"
|
707
|
+
* it to the destination stream. `f` can maintain some internal state to control
|
708
|
+
* the combining process, with the initial state being specified by `s`.
|
709
|
+
*
|
710
|
+
* Where possible, prefer `Stream#combineChunks` for a more efficient implementation.
|
711
|
+
*
|
712
|
+
* @tsplus fluent fncts.io.Stream combine
|
713
|
+
*/
|
714
|
+
export function combine_<R, E, A, R1, E1, A1, S, R2, A2>(
|
715
|
+
stream: Stream<R, E, A>,
|
716
|
+
that: Stream<R1, E1, A1>,
|
717
|
+
s: S,
|
718
|
+
f: (
|
719
|
+
s: S,
|
720
|
+
eff1: IO<R, Maybe<E>, A>,
|
721
|
+
eff2: IO<R1, Maybe<E1>, A1>,
|
722
|
+
) => IO<R2, never, Exit<Maybe<E | E1>, readonly [A2, S]>>,
|
723
|
+
): Stream<R & R1 & R2, E | E1, A2> {
|
724
|
+
return new Stream(
|
725
|
+
Channel.unwrapScoped(
|
726
|
+
Do((Δ) => {
|
727
|
+
const left = Δ(Handoff<Exit<Maybe<E>, A>>());
|
728
|
+
const right = Δ(Handoff<Exit<Maybe<E1>, A1>>());
|
729
|
+
const latchL = Δ(Handoff<void>());
|
730
|
+
const latchR = Δ(Handoff<void>());
|
731
|
+
Δ(stream.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(left, latchL)).runScoped.fork);
|
732
|
+
Δ(that.channel.concatMap(Channel.writeChunk).pipeTo(combineProducer(right, latchR)).runScoped.fork);
|
733
|
+
return tuple(left, right, latchL, latchR);
|
734
|
+
}).map(([left, right, latchL, latchR]) => {
|
735
|
+
const pullLeft = latchL.offer(undefined).apSecond(left.take).flatMap(IO.fromExitNow);
|
736
|
+
const pullRight = latchR.offer(undefined).apSecond(right.take).flatMap(IO.fromExitNow);
|
737
|
+
return Stream.unfoldIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExitNow(exit).optional))
|
738
|
+
.channel;
|
739
|
+
}),
|
740
|
+
),
|
741
|
+
);
|
742
|
+
}
|
743
|
+
|
744
|
+
function combineChunksProducer<Err, Elem>(
|
745
|
+
handoff: Handoff<Take<Err, Elem>>,
|
746
|
+
latch: Handoff<void>,
|
747
|
+
): Channel<unknown, Err, Conc<Elem>, unknown, never, never, any> {
|
748
|
+
return Channel.fromIO(latch.take).apSecond(
|
749
|
+
Channel.readWithCause(
|
750
|
+
(chunk) => Channel.fromIO(handoff.offer(Take.chunk(chunk))).apSecond(combineChunksProducer(handoff, latch)),
|
751
|
+
(cause) => Channel.fromIO(handoff.offer(Take.failCause(cause))),
|
752
|
+
() => Channel.fromIO(handoff.offer(Take.end)).apSecond(combineChunksProducer(handoff, latch)),
|
753
|
+
),
|
754
|
+
);
|
755
|
+
}
|
756
|
+
|
757
|
+
/**
|
758
|
+
* Combines the chunks from this stream and the specified stream by repeatedly applying the
|
759
|
+
* function `f` to extract a chunk using both sides and conceptually "offer"
|
760
|
+
* it to the destination stream. `f` can maintain some internal state to control
|
761
|
+
* the combining process, with the initial state being specified by `s`.
|
762
|
+
*
|
763
|
+
* @tsplus fluent fncts.io.Stream combineChunks
|
764
|
+
*/
|
765
|
+
export function combineChunks_<R, E, A, R1, E1, A1, S, R2, A2>(
|
766
|
+
stream: Stream<R, E, A>,
|
767
|
+
that: Stream<R1, E1, A1>,
|
768
|
+
s: S,
|
769
|
+
f: (
|
770
|
+
s: S,
|
771
|
+
l: IO<R, Maybe<E>, Conc<A>>,
|
772
|
+
r: IO<R1, Maybe<E1>, Conc<A1>>,
|
773
|
+
) => IO<R2, never, Exit<Maybe<E | E1>, readonly [Conc<A2>, S]>>,
|
774
|
+
): Stream<R1 & R & R2, E | E1, A2> {
|
775
|
+
return new Stream(
|
776
|
+
Channel.unwrapScoped(
|
777
|
+
Do((Δ) => {
|
778
|
+
const left = Δ(Handoff<Take<E, A>>());
|
779
|
+
const right = Δ(Handoff<Take<E1, A1>>());
|
780
|
+
const latchL = Δ(Handoff<void>());
|
781
|
+
const latchR = Δ(Handoff<void>());
|
782
|
+
Δ(stream.channel.pipeTo(combineChunksProducer(left, latchL)).runScoped.fork);
|
783
|
+
Δ(that.channel.pipeTo(combineChunksProducer(right, latchR)).runScoped.fork);
|
784
|
+
return tuple(left, right, latchL, latchR);
|
785
|
+
}).map(([left, right, latchL, latchR]) => {
|
786
|
+
const pullLeft = latchL
|
787
|
+
.offer(undefined)
|
788
|
+
.apSecond(left.take)
|
789
|
+
.flatMap((take) => take.done);
|
790
|
+
const pullRight = latchR
|
791
|
+
.offer(undefined)
|
792
|
+
.apSecond(right.take)
|
793
|
+
.flatMap((take) => take.done);
|
794
|
+
return Stream.unfoldChunkIO(s, (s) => f(s, pullLeft, pullRight).flatMap((exit) => IO.fromExit(exit).optional))
|
795
|
+
.channel;
|
796
|
+
}),
|
797
|
+
),
|
798
|
+
);
|
799
|
+
}
|
800
|
+
|
801
|
+
/**
|
802
|
+
* Concatenates the specified stream with this stream, resulting in a stream
|
803
|
+
* that emits the elements from this stream and then the elements from the specified stream.
|
804
|
+
*
|
805
|
+
* @tsplus fluent fncts.io.Stream concat
|
806
|
+
*/
|
807
|
+
export function concat_<R, R1, E, E1, A, A1>(
|
808
|
+
stream: Stream<R, E, A>,
|
809
|
+
that: Stream<R1, E1, A1>,
|
810
|
+
): Stream<R & R1, E | E1, A | A1> {
|
811
|
+
return new Stream<R & R1, E | E1, A | A1>(stream.channel.apSecond(that.channel));
|
812
|
+
}
|
813
|
+
|
814
|
+
/**
|
815
|
+
* Composes this stream with the specified stream to create a cartesian product of elements.
|
816
|
+
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
817
|
+
*
|
818
|
+
* @tsplus fluent fncts.io.Stream cross
|
819
|
+
*/
|
820
|
+
export function cross_<R, E, A, R1, E1, B>(
|
821
|
+
stream: Stream<R, E, A>,
|
822
|
+
that: Stream<R1, E1, B>,
|
823
|
+
): Stream<R & R1, E | E1, readonly [A, B]> {
|
824
|
+
return new Stream(
|
825
|
+
stream.channel.concatMap((as) => that.channel.mapOut((bs) => as.flatMap((a) => bs.map((b) => tuple(a, b))))),
|
826
|
+
);
|
827
|
+
}
|
828
|
+
|
829
|
+
/**
|
830
|
+
* Composes this stream with the specified stream to create a cartesian product of elements
|
831
|
+
* with a specified function.
|
832
|
+
* The `fb` stream would be run multiple times, for every element in the `fa` stream.
|
833
|
+
*
|
834
|
+
* @tsplus fluent fncts.io.Stream crossWith
|
835
|
+
*/
|
836
|
+
export function crossWith_<R, E, A, R1, E1, B, C>(
|
837
|
+
fa: Stream<R, E, A>,
|
838
|
+
fb: Stream<R1, E1, B>,
|
839
|
+
f: (a: A, b: B) => C,
|
840
|
+
): Stream<R & R1, E | E1, C> {
|
841
|
+
return fa.flatMap((a) => fb.map((b) => f(a, b)));
|
842
|
+
}
|
843
|
+
|
844
|
+
/**
|
845
|
+
* Provides some of the environment required to run this effect,
|
846
|
+
* leaving the remainder `R0`.
|
847
|
+
*
|
848
|
+
* @tsplus fluent fncts.io.Stream contramapEnvironment
|
849
|
+
*/
|
850
|
+
export function contramapEnvironment_<R, E, A, R0>(
|
851
|
+
ra: Stream<R, E, A>,
|
852
|
+
f: (r0: Environment<R0>) => Environment<R>,
|
853
|
+
): Stream<R0, E, A> {
|
854
|
+
return Stream.environment<R0>().flatMap((r0) => ra.provideEnvironment(f(r0)));
|
855
|
+
}
|
856
|
+
|
857
|
+
/**
|
858
|
+
* @tsplus fluent fncts.io.Stream debounce
|
859
|
+
*/
|
860
|
+
export function debounce_<R, E, A>(stream: Stream<R, E, A>, duration: number): Stream<R, E, A> {
|
861
|
+
return Stream.unwrap(
|
862
|
+
IO.transplant((grafter) =>
|
863
|
+
Do((Δ) => {
|
864
|
+
const handoff = Δ(Handoff<HandoffSignal<void, E, A>>());
|
865
|
+
function enqueue(last: Conc<A>) {
|
866
|
+
return grafter(Clock.sleep(duration).as(last).fork).map((f) => consumer(DebounceState.Previous(f)));
|
867
|
+
}
|
868
|
+
const producer: Channel<R, E, Conc<A>, unknown, E, never, unknown> = Channel.readWithCause(
|
869
|
+
(inp: Conc<A>) =>
|
870
|
+
inp.last.match(
|
871
|
+
() => producer,
|
872
|
+
(last) => Channel.fromIO(handoff.offer(HandoffSignal.Emit(Conc.single(last)))).apSecond(producer),
|
873
|
+
),
|
874
|
+
(cause: Cause<E>) => Channel.fromIO(handoff.offer(HandoffSignal.Halt(cause))),
|
875
|
+
() => Channel.fromIO(handoff.offer(HandoffSignal.End(new UpstreamEnd()))),
|
876
|
+
);
|
877
|
+
function consumer(state: DebounceState<E, A>): Channel<R, unknown, unknown, unknown, E, Conc<A>, unknown> {
|
878
|
+
return Channel.unwrap(
|
879
|
+
state.match({
|
880
|
+
NotStarted: () =>
|
881
|
+
handoff.take.map((signal) =>
|
882
|
+
signal.match({
|
883
|
+
Emit: ({ els }) => Channel.unwrap(enqueue(els)),
|
884
|
+
Halt: ({ error }) => Channel.failCauseNow(error),
|
885
|
+
End: () => Channel.unit,
|
886
|
+
}),
|
887
|
+
),
|
888
|
+
Current: ({ fiber }) =>
|
889
|
+
fiber.join.map((signal) =>
|
890
|
+
signal.match({
|
891
|
+
Emit: ({ els }) => Channel.unwrap(enqueue(els)),
|
892
|
+
Halt: ({ error }) => Channel.failCauseNow(error),
|
893
|
+
End: () => Channel.unit,
|
894
|
+
}),
|
895
|
+
),
|
896
|
+
Previous: ({ fiber }) =>
|
897
|
+
fiber.join.raceWith(
|
898
|
+
handoff.take,
|
899
|
+
(ex, current) =>
|
900
|
+
ex.match(
|
901
|
+
(cause) => current.interrupt.as(Channel.failCauseNow(cause)),
|
902
|
+
(chunk) =>
|
903
|
+
IO.succeedNow(Channel.writeNow(chunk).apSecond(consumer(DebounceState.Current(current)))),
|
904
|
+
),
|
905
|
+
(ex, previous) =>
|
906
|
+
ex.match(
|
907
|
+
(cause) => previous.interrupt.as(Channel.failCauseNow(cause)),
|
908
|
+
(signal) =>
|
909
|
+
signal.match({
|
910
|
+
Emit: ({ els }) => previous.interrupt.apSecond(enqueue(els)),
|
911
|
+
Halt: ({ error }) => previous.interrupt.as(Channel.failCauseNow(error)),
|
912
|
+
End: () => previous.join.map((chunk) => Channel.writeNow(chunk).apSecond(Channel.unit)),
|
913
|
+
}),
|
914
|
+
),
|
915
|
+
),
|
916
|
+
}),
|
917
|
+
);
|
918
|
+
}
|
919
|
+
|
920
|
+
return Stream.scoped(stream.channel.pipeTo(producer).runScoped.fork).apSecond(
|
921
|
+
new Stream(consumer(DebounceState.NotStarted)),
|
922
|
+
);
|
923
|
+
}),
|
924
|
+
),
|
925
|
+
);
|
926
|
+
}
|
927
|
+
|
928
|
+
function defaultIfEmptyWriter<R, E, A, R1, E1, B>(
|
929
|
+
fb: Stream<R1, E1, B>,
|
930
|
+
): Channel<R & R1, E, Conc<A>, unknown, E | E1, Conc<A | B>, unknown> {
|
931
|
+
return Channel.readWith(
|
932
|
+
(i: Conc<A>) =>
|
933
|
+
i.isEmpty ? defaultIfEmptyWriter(fb) : Channel.writeNow(i).apSecond(Channel.id<E, Conc<A>, unknown>()),
|
934
|
+
Channel.failNow,
|
935
|
+
() => fb.channel,
|
936
|
+
);
|
937
|
+
}
|
938
|
+
|
939
|
+
/**
|
940
|
+
* Switches to the provided stream in case this one is empty.
|
941
|
+
*
|
942
|
+
* @tsplus fluent fncts.io.Stream defaultIfEmpty
|
943
|
+
*/
|
944
|
+
export function defaultIfEmpty_<R, E, A, R1, E1, B>(
|
945
|
+
fa: Stream<R, E, A>,
|
946
|
+
fb: Stream<R1, E1, B>,
|
947
|
+
): Stream<R & R1, E | E1, A | B> {
|
948
|
+
return new Stream(fa.channel.pipeTo(defaultIfEmptyWriter(fb)));
|
949
|
+
}
|
950
|
+
|
951
|
+
/**
|
952
|
+
* More powerful version of `broadcast`. Allows to provide a function that determines what
|
953
|
+
* queues should receive which elements. The decide function will receive the indices of the queues
|
954
|
+
* in the resulting list.
|
955
|
+
*
|
956
|
+
* @tsplus fluent fncts.io.Stream distributedWith
|
957
|
+
*/
|
958
|
+
export function distributedWith_<R, E, A>(
|
959
|
+
self: Stream<R, E, A>,
|
960
|
+
n: number,
|
961
|
+
maximumLag: number,
|
962
|
+
decide: (_: A) => UIO<(_: number) => boolean>,
|
963
|
+
): IO<R & Has<Scope>, never, Conc<Queue.Dequeue<Exit<Maybe<E>, A>>>> {
|
964
|
+
return Future.make<never, (a: A) => UIO<(_: symbol) => boolean>>().flatMap((p) =>
|
965
|
+
self
|
966
|
+
.distributedWithDynamic(
|
967
|
+
maximumLag,
|
968
|
+
(a) => p.await.flatMap((f) => f(a)),
|
969
|
+
() => IO.unit,
|
970
|
+
)
|
971
|
+
.flatMap((next) =>
|
972
|
+
IO.sequenceIterable(
|
973
|
+
Conc.range(0, n).map((id) => next.map(([key, queue]) => [[key, id], queue] as const)),
|
974
|
+
).flatMap((entries) => {
|
975
|
+
const [mappings, queues] = entries.foldRight(
|
976
|
+
[HashMap.makeDefault<symbol, number>(), Conc.empty<Queue.Dequeue<Exit<Maybe<E>, A>>>()] as const,
|
977
|
+
([mapping, queue], [mappings, queues]) => [mappings.set(mapping[0], mapping[1]), queues.append(queue)],
|
978
|
+
);
|
979
|
+
return p.succeed((a) => decide(a).map((f) => (key: symbol) => f(mappings.get(key).value!))).as(queues);
|
980
|
+
}),
|
981
|
+
),
|
982
|
+
);
|
983
|
+
}
|
984
|
+
|
985
|
+
/**
|
986
|
+
* More powerful version of `ZStream#distributedWith`. This returns a function that will produce
|
987
|
+
* new queues and corresponding indices.
|
988
|
+
* You can also provide a function that will be executed after the final events are enqueued in all queues.
|
989
|
+
* Shutdown of the queues is handled by the driver.
|
990
|
+
* Downstream users can also shutdown queues manually. In this case the driver will
|
991
|
+
* continue but no longer backpressure on them.
|
992
|
+
*
|
993
|
+
* @tsplus fluent fncts.io.Stream distributedWithDynamic
|
994
|
+
*/
|
995
|
+
export function distributedWithDynamic_<R, E, A>(
|
996
|
+
self: Stream<R, E, A>,
|
997
|
+
maximumLag: number,
|
998
|
+
decide: (a: A) => UIO<(_: symbol) => boolean>,
|
999
|
+
done: (exit: Exit<Maybe<E>, never>) => UIO<any> = () => IO.unit,
|
1000
|
+
): IO<R & Has<Scope>, never, UIO<readonly [symbol, Queue.Dequeue<Exit<Maybe<E>, A>>]>> {
|
1001
|
+
const offer = (queuesRef: Ref<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>) => (a: A) =>
|
1002
|
+
Do((Δ) => {
|
1003
|
+
const shouldProcess = Δ(decide(a));
|
1004
|
+
const queues = Δ(queuesRef.get);
|
1005
|
+
return Δ(
|
1006
|
+
IO.foldLeft(queues, Conc.empty<symbol>(), (b, [id, queue]) => {
|
1007
|
+
if (shouldProcess(id)) {
|
1008
|
+
return queue.offer(Exit.succeed(a)).matchCauseIO(
|
1009
|
+
(c) => (c.interrupted ? IO.succeedNow(b.append(id)) : IO.failCauseNow(c)),
|
1010
|
+
() => IO.succeedNow(b),
|
1011
|
+
);
|
1012
|
+
} else {
|
1013
|
+
return IO.succeedNow(b);
|
1014
|
+
}
|
1015
|
+
}).flatMap((ids) => (ids.isNonEmpty ? queuesRef.update((map) => map.removeMany(ids)) : IO.unit)),
|
1016
|
+
);
|
1017
|
+
});
|
1018
|
+
|
1019
|
+
return Do((Δ) => {
|
1020
|
+
const queuesRef = Δ(
|
1021
|
+
IO.acquireRelease(Ref.make<HashMap<symbol, Queue<Exit<Maybe<E>, A>>>>(HashMap.makeDefault()), (ref) =>
|
1022
|
+
ref.get.flatMap((qs) => IO.foreach(qs.values, (q) => q.shutdown)),
|
1023
|
+
),
|
1024
|
+
);
|
1025
|
+
|
1026
|
+
const add = Δ(
|
1027
|
+
Do((Δ) => {
|
1028
|
+
const queuesLock = Δ(TSemaphore.make(1).commit);
|
1029
|
+
const newQueue = Δ(
|
1030
|
+
Ref.make<UIO<readonly [symbol, Queue<Exit<Maybe<E>, A>>]>>(
|
1031
|
+
Do((Δ) => {
|
1032
|
+
const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(maximumLag));
|
1033
|
+
const id = Δ(IO.succeed(Symbol()));
|
1034
|
+
Δ(queuesRef.update((map) => map.set(id, queue)));
|
1035
|
+
return tuple(id, queue);
|
1036
|
+
}),
|
1037
|
+
),
|
1038
|
+
);
|
1039
|
+
const finalize = (endTake: Exit<Maybe<E>, never>): UIO<void> =>
|
1040
|
+
queuesLock.withPermit(
|
1041
|
+
newQueue
|
1042
|
+
.set(
|
1043
|
+
Do((Δ) => {
|
1044
|
+
const queue = Δ(Queue.makeBounded<Exit<Maybe<E>, A>>(1));
|
1045
|
+
Δ(queue.offer(endTake));
|
1046
|
+
const id = Symbol();
|
1047
|
+
Δ(queuesRef.update((map) => map.set(id, queue)));
|
1048
|
+
return tuple(id, queue);
|
1049
|
+
}),
|
1050
|
+
)
|
1051
|
+
.flatMap(() =>
|
1052
|
+
Do((Δ) => {
|
1053
|
+
const queues = Δ(queuesRef.get.map((map) => map.values));
|
1054
|
+
Δ(
|
1055
|
+
IO.foreach(queues, (queue) =>
|
1056
|
+
queue
|
1057
|
+
.offer(endTake)
|
1058
|
+
.catchJustCause((c) => (c.interrupted ? Just(IO.unit) : Nothing<UIO<void>>())),
|
1059
|
+
),
|
1060
|
+
);
|
1061
|
+
Δ(done(endTake));
|
1062
|
+
}),
|
1063
|
+
).asUnit,
|
1064
|
+
);
|
1065
|
+
|
1066
|
+
Δ(
|
1067
|
+
self.runForeachScoped(offer(queuesRef)).matchCauseIO(
|
1068
|
+
(cause) => finalize(Exit.failCause(cause.map(Maybe.just))),
|
1069
|
+
() => finalize(Exit.fail(Nothing())),
|
1070
|
+
).fork,
|
1071
|
+
);
|
1072
|
+
|
1073
|
+
return queuesLock.withPermit(newQueue.get.flatten);
|
1074
|
+
}),
|
1075
|
+
);
|
1076
|
+
|
1077
|
+
return add;
|
1078
|
+
});
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
/**
|
1082
|
+
* Converts this stream to a stream that executes its effects but emits no
|
1083
|
+
* elements. Useful for sequencing effects using streams.
|
1084
|
+
*
|
1085
|
+
* @tsplus getter fncts.io.Stream drain
|
1086
|
+
*/
|
1087
|
+
export function drain<R, E, A>(fa: Stream<R, E, A>): Stream<R, E, void> {
|
1088
|
+
return new Stream(fa.channel.drain);
|
1089
|
+
}
|
1090
|
+
|
1091
|
+
function dropLoop<R, E, A>(r: number): Channel<R, E, Conc<A>, unknown, E, Conc<A>, unknown> {
|
1092
|
+
return Channel.readWith(
|
1093
|
+
(inp: Conc<A>) => {
|
1094
|
+
const dropped = inp.drop(r);
|
1095
|
+
const leftover = Math.max(0, r - inp.length);
|
1096
|
+
const more = inp.isEmpty || leftover > 0;
|
1097
|
+
return more ? dropLoop(leftover) : Channel.write(dropped).apSecond(Channel.id());
|
1098
|
+
},
|
1099
|
+
Channel.failNow,
|
1100
|
+
() => Channel.unit,
|
1101
|
+
);
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
/**
|
1105
|
+
* Drops the specified number of elements from this stream.
|
1106
|
+
*
|
1107
|
+
* @tsplus fluent fncts.io.Stream drop
|
1108
|
+
*/
|
1109
|
+
export function drop_<R, E, A>(stream: Stream<R, E, A>, n: number): Stream<R, E, A> {
|
1110
|
+
return new Stream(stream.channel.pipeTo(dropLoop(n)));
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
/**
|
1114
|
+
* Drops all elements of the stream for as long as the specified predicate
|
1115
|
+
* evaluates to `true`.
|
1116
|
+
*
|
1117
|
+
* @tsplus fluent fncts.io.Stream dropWhile
|
1118
|
+
*/
|
1119
|
+
export function dropWhile_<R, E, A>(stream: Stream<R, E, A>, p: Predicate<A>): Stream<R, E, A> {
|
1120
|
+
return stream.pipeThrough(Sink.dropWhile(p));
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
/**
|
1124
|
+
* Drops all elements of the stream until the specified predicate evaluates
|
1125
|
+
* to `true`.
|
1126
|
+
*
|
1127
|
+
* @tsplus fluent fncts.io.Stream dropUntil
|
1128
|
+
*/
|
1129
|
+
export function dropUntil_<R, E, A>(stream: Stream<R, E, A>, p: Predicate<A>): Stream<R, E, A> {
|
1130
|
+
return stream.dropWhile(p.invert).drop(1);
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
/**
|
1134
|
+
* Returns a stream whose failures and successes have been lifted into an
|
1135
|
+
* `Either`. The resulting stream cannot fail, because the failures have
|
1136
|
+
* been exposed as part of the `Either` success case.
|
1137
|
+
*
|
1138
|
+
* @note the stream will end as soon as the first error occurs.
|
1139
|
+
*
|
1140
|
+
* @tsplus getter fncts.io.Stream either
|
1141
|
+
*/
|
1142
|
+
export function either<R, E, A>(stream: Stream<R, E, A>): Stream<R, never, Either<E, A>> {
|
1143
|
+
return stream.map(Either.right).catchAll((e) => Stream.succeedNow(Either.left(e)));
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
/**
|
1147
|
+
* @tsplus static fncts.io.StreamOps empty
|
1148
|
+
*/
|
1149
|
+
export const empty: Stream<unknown, never, never> = Stream.fromChunkNow(Conc.empty<never>());
|
1150
|
+
|
1151
|
+
function endWhenWriter<E, A, E1>(
|
1152
|
+
fiber: Fiber<E1, any>,
|
1153
|
+
): Channel<unknown, E | E1, Conc<A>, unknown, E | E1, Conc<A>, void> {
|
1154
|
+
return Channel.unwrap(
|
1155
|
+
fiber.poll.map((maybeExit) =>
|
1156
|
+
maybeExit.match(
|
1157
|
+
() =>
|
1158
|
+
Channel.readWith(
|
1159
|
+
(inp: Conc<A>) => Channel.writeNow(inp).apSecond(endWhenWriter(fiber)),
|
1160
|
+
Channel.failNow,
|
1161
|
+
() => Channel.unit,
|
1162
|
+
),
|
1163
|
+
(exit) => exit.match(Channel.failCauseNow, () => Channel.unit),
|
1164
|
+
),
|
1165
|
+
),
|
1166
|
+
);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
/**
|
1170
|
+
* Halts the evaluation of this stream when the provided IO completes. The given IO
|
1171
|
+
* will be forked as part of the returned stream, and its success will be discarded.
|
1172
|
+
*
|
1173
|
+
* An element in the process of being pulled will not be interrupted when the IO
|
1174
|
+
* completes. See `interruptWhen` for this behavior.
|
1175
|
+
*
|
1176
|
+
* If the IO completes with a failure, the stream will emit that failure.
|
1177
|
+
*
|
1178
|
+
* @tsplus fluent fncts.io.Stream endWhen
|
1179
|
+
*/
|
1180
|
+
export function endWhen_<R, E, A, R1, E1>(stream: Stream<R, E, A>, io: IO<R1, E1, any>): Stream<R & R1, E | E1, A> {
|
1181
|
+
return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => stream.channel.pipeTo(endWhenWriter(fiber)))));
|
1182
|
+
}
|
1183
|
+
|
1184
|
+
/**
|
1185
|
+
* @tsplus fluent fncts.io.Stream ensuring
|
1186
|
+
*/
|
1187
|
+
export function ensuring_<R, E, A, R1>(self: Stream<R, E, A>, finalizer: IO<R1, never, any>): Stream<R & R1, E, A> {
|
1188
|
+
return new Stream(self.channel.ensuring(finalizer));
|
1189
|
+
}
|
1190
|
+
|
1191
|
+
/**
|
1192
|
+
* @tsplus static fncts.io.StreamOps environment
|
1193
|
+
*/
|
1194
|
+
export function environment<R>(): Stream<R, never, Environment<R>> {
|
1195
|
+
return Stream.fromIO(IO.environment<R>());
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
/**
|
1199
|
+
* Accesses the environment of the stream.
|
1200
|
+
*
|
1201
|
+
* @tsplus static fncts.io.StreamOps environmentWith
|
1202
|
+
*/
|
1203
|
+
export function environmentWith<R, A>(f: (r: Environment<R>) => A): Stream<R, never, A> {
|
1204
|
+
return Stream.environment<R>().map(f);
|
1205
|
+
}
|
1206
|
+
|
1207
|
+
/**
|
1208
|
+
* Accesses the environment of the stream in the context of an effect.
|
1209
|
+
*
|
1210
|
+
* @tsplus static fncts.io.StreamOps environmentWithIO
|
1211
|
+
*/
|
1212
|
+
export function environmentWithIO<R0, R, E, A>(f: (r0: Environment<R0>) => IO<R, E, A>): Stream<R0 & R, E, A> {
|
1213
|
+
return Stream.environment<R0>().mapIO(f);
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
/**
|
1217
|
+
* Accesses the environment of the stream in the context of a stream.
|
1218
|
+
*
|
1219
|
+
* @tsplus static fncts.io.StreamOps environmentWithStream
|
1220
|
+
*/
|
1221
|
+
export function environmentWithStream<R0, R, E, A>(f: (r0: Environment<R0>) => Stream<R, E, A>): Stream<R0 & R, E, A> {
|
1222
|
+
return Stream.environment<R0>().flatMap(f);
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
/**
|
1226
|
+
* Halt a stream with the specified error
|
1227
|
+
*
|
1228
|
+
* @tsplus static fncts.io.StreamOps failNow
|
1229
|
+
*/
|
1230
|
+
export function failNow<E>(error: E): Stream<unknown, E, never> {
|
1231
|
+
return new Stream(Channel.failNow(error));
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
/**
|
1235
|
+
* Halt a stream with the specified error
|
1236
|
+
*
|
1237
|
+
* @tsplus static fncts.io.StreamOps fail
|
1238
|
+
*/
|
1239
|
+
export function fail<E>(error: Lazy<E>): Stream<unknown, E, never> {
|
1240
|
+
return new Stream(Channel.fail(error));
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
/**
|
1244
|
+
* The stream that always halts with `cause`.
|
1245
|
+
*
|
1246
|
+
* @tsplus static fncts.io.StreamOps failCauseNow
|
1247
|
+
*/
|
1248
|
+
export function failCauseNow<E>(cause: Cause<E>): Stream<unknown, E, never> {
|
1249
|
+
return Stream.fromIO(IO.failCauseNow(cause));
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
/**
|
1253
|
+
* The stream that always halts with `cause`.
|
1254
|
+
*
|
1255
|
+
* @tsplus static fncts.io.StreamOps failCause
|
1256
|
+
*/
|
1257
|
+
export function failCause<E>(cause: Lazy<Cause<E>>): Stream<unknown, E, never> {
|
1258
|
+
return Stream.fromIO(IO.failCause(cause));
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
/**
|
1262
|
+
* @tsplus fluent fncts.io.Stream filter
|
1263
|
+
*/
|
1264
|
+
export function filter_<R, E, A, B extends A>(fa: Stream<R, E, A>, refinement: Refinement<A, B>): Stream<R, E, B>;
|
1265
|
+
export function filter_<R, E, A>(fa: Stream<R, E, A>, predicate: Predicate<A>): Stream<R, E, A>;
|
1266
|
+
export function filter_<R, E, A>(fa: Stream<R, E, A>, predicate: Predicate<A>): Stream<R, E, A> {
|
1267
|
+
return fa.mapChunks((chunk) => chunk.filter(predicate));
|
1268
|
+
}
|
1269
|
+
|
1270
|
+
/**
|
1271
|
+
* @tsplus fluent fncts.io.Stream filterIO
|
1272
|
+
*/
|
1273
|
+
export function filterIO_<R, E, A, R1, E1>(
|
1274
|
+
fa: Stream<R, E, A>,
|
1275
|
+
f: (a: A) => IO<R1, E1, boolean>,
|
1276
|
+
): Stream<R & R1, E | E1, A> {
|
1277
|
+
return fa.loopOnPartialChunksElements((a, emit) => f(a).flatMap((r) => (r ? emit(a) : IO.unit)));
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
/**
|
1281
|
+
* @tsplus fluent fncts.io.Stream filterMap
|
1282
|
+
*/
|
1283
|
+
export function filterMap_<R, E, A, B>(fa: Stream<R, E, A>, f: (a: A) => Maybe<B>): Stream<R, E, B> {
|
1284
|
+
return fa.mapChunks((chunk) => chunk.filterMap(f));
|
1285
|
+
}
|
1286
|
+
|
1287
|
+
/**
|
1288
|
+
* @tsplus fluent fncts.io.Stream filterMapIO
|
1289
|
+
*/
|
1290
|
+
export function filterMapIO_<R, E, A, R1, E1, B>(
|
1291
|
+
fa: Stream<R, E, A>,
|
1292
|
+
f: (a: A) => IO<R1, E1, Maybe<B>>,
|
1293
|
+
): Stream<R & R1, E | E1, B> {
|
1294
|
+
return fa.loopOnPartialChunksElements((a, emit) => f(a).flatMap((maybeB) => maybeB.match(() => IO.unit, emit)));
|
1295
|
+
}
|
1296
|
+
|
1297
|
+
/**
|
1298
|
+
* Finds the first element emitted by this stream that satisfies the provided predicate.
|
1299
|
+
*
|
1300
|
+
* @tsplus fluent fncts.io.Stream find
|
1301
|
+
*/
|
1302
|
+
export function find_<R, E, A>(stream: Stream<R, E, A>, p: Predicate<A>): Stream<R, E, A> {
|
1303
|
+
const loop: Channel<R, E, Conc<A>, unknown, E, Conc<A>, unknown> = Channel.readWith(
|
1304
|
+
(inp: Conc<A>) =>
|
1305
|
+
inp.find(p).match(
|
1306
|
+
() => loop,
|
1307
|
+
(a) => Channel.writeNow(Conc.single(a)),
|
1308
|
+
),
|
1309
|
+
Channel.failNow,
|
1310
|
+
() => Channel.unit,
|
1311
|
+
);
|
1312
|
+
return new Stream(stream.channel.pipeTo(loop));
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
/**
|
1316
|
+
* Finds the first element emitted by this stream that satisfies the provided effectful predicate.
|
1317
|
+
*
|
1318
|
+
* @tsplus fluent fncts.io.Stream findIO
|
1319
|
+
*/
|
1320
|
+
export function findIO_<R, E, A, R1, E1>(
|
1321
|
+
stream: Stream<R, E, A>,
|
1322
|
+
f: (a: A) => IO<R1, E1, boolean>,
|
1323
|
+
): Stream<R & R1, E | E1, A> {
|
1324
|
+
const loop: Channel<R & R1, E, Conc<A>, unknown, E | E1, Conc<A>, unknown> = Channel.readWith(
|
1325
|
+
(inp: Conc<A>) =>
|
1326
|
+
Channel.unwrap(
|
1327
|
+
inp.findIO(f).map((maybeA) =>
|
1328
|
+
maybeA.match(
|
1329
|
+
() => loop,
|
1330
|
+
(a) => Channel.writeNow(Conc.single(a)),
|
1331
|
+
),
|
1332
|
+
),
|
1333
|
+
),
|
1334
|
+
Channel.failNow,
|
1335
|
+
() => Channel.unit,
|
1336
|
+
);
|
1337
|
+
return new Stream(stream.channel.pipeTo(loop));
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
/**
|
1341
|
+
* Flattens this stream-of-streams into a stream made of the concatenation in
|
1342
|
+
* strict order of all the streams.
|
1343
|
+
*
|
1344
|
+
* @tsplus getter fncts.io.Stream flatten
|
1345
|
+
*/
|
1346
|
+
export function flatten<R, E, R1, E1, A>(self: Stream<R, E, Stream<R1, E1, A>>): Stream<R & R1, E | E1, A> {
|
1347
|
+
return self.flatMap(identity);
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
/**
|
1351
|
+
* Unwraps `Exit` values that also signify end-of-stream by failing with `None`.
|
1352
|
+
*
|
1353
|
+
* For `Exit<E, A>` values that do not signal end-of-stream, prefer:
|
1354
|
+
*
|
1355
|
+
* @tsplus getter fncts.io.Stream flattenExitOption
|
1356
|
+
*/
|
1357
|
+
export function flattenExitOption<R, E, E1, A>(stream: Stream<R, E, Exit<Maybe<E1>, A>>): Stream<R, E | E1, A> {
|
1358
|
+
const processChunk = (
|
1359
|
+
chunk: Conc<Exit<Maybe<E1>, A>>,
|
1360
|
+
cont: Channel<R, E, Conc<Exit<Maybe<E1>, A>>, unknown, E | E1, Conc<A>, any>,
|
1361
|
+
): Channel<R, E, Conc<Exit<Maybe<E1>, A>>, unknown, E | E1, Conc<A>, any> => {
|
1362
|
+
const [toEmit, rest] = chunk.splitWhere((_) => !_.isSuccess());
|
1363
|
+
const next = rest.head.match(
|
1364
|
+
() => cont,
|
1365
|
+
(exit) =>
|
1366
|
+
exit.match(
|
1367
|
+
(cause) => cause.flipCauseMaybe.match(() => Channel.endNow<void>(undefined), Channel.failCauseNow),
|
1368
|
+
() => Channel.endNow<void>(undefined),
|
1369
|
+
),
|
1370
|
+
);
|
1371
|
+
|
1372
|
+
return Channel.writeNow(toEmit.filterMap((exit) => exit.match(() => Nothing(), Maybe.just))).apSecond(next);
|
1373
|
+
};
|
1374
|
+
|
1375
|
+
const process: Channel<R, E, Conc<Exit<Maybe<E1>, A>>, unknown, E | E1, Conc<A>, any> = Channel.readWithCause(
|
1376
|
+
(chunk) => processChunk(chunk, process),
|
1377
|
+
Channel.failCauseNow,
|
1378
|
+
(_) => Channel.endNow(undefined),
|
1379
|
+
);
|
1380
|
+
|
1381
|
+
return new Stream(stream.channel.pipeTo(process));
|
1382
|
+
}
|
1383
|
+
|
1384
|
+
/**
|
1385
|
+
* Unwraps `Exit` values and flatten chunks that also signify end-of-stream by failing with `None`.
|
1386
|
+
*
|
1387
|
+
* @tsplus getter fncts.io.Stream flattenTake
|
1388
|
+
*/
|
1389
|
+
export function flattenTake<R, E, E1, A>(stream: Stream<R, E, Take<E1, A>>): Stream<R, E | E1, A> {
|
1390
|
+
return stream.map((take) => take.exit).flattenExitOption.flattenChunks;
|
1391
|
+
}
|
1392
|
+
|
1393
|
+
/**
|
1394
|
+
* Submerges the chunks carried by this stream into the stream's structure, while
|
1395
|
+
* still preserving them.
|
1396
|
+
*
|
1397
|
+
* @tsplus getter fncts.io.Stream flattenChunks
|
1398
|
+
*/
|
1399
|
+
export function flattenChunks<R, E, A>(stream: Stream<R, E, Conc<A>>): Stream<R, E, A> {
|
1400
|
+
return new Stream(stream.channel.mapOut((c) => c.flatten));
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
/**
|
1404
|
+
* Repeats this stream forever.
|
1405
|
+
*
|
1406
|
+
* @tsplus getter fncts.io.Stream forever
|
1407
|
+
*/
|
1408
|
+
export function forever<R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> {
|
1409
|
+
return new Stream(stream.channel.repeated);
|
1410
|
+
}
|
1411
|
+
|
1412
|
+
/**
|
1413
|
+
* Creates a stream from a `Chunk` of values
|
1414
|
+
*
|
1415
|
+
* @tsplus static fncts.io.StreamOps fromChunkNow
|
1416
|
+
*/
|
1417
|
+
export function fromChunkNow<O>(c: Conc<O>): Stream<unknown, never, O> {
|
1418
|
+
return new Stream(Channel.defer(() => (c.isEmpty ? Channel.unit : Channel.writeNow(c))));
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
/**
|
1422
|
+
* Creates a stream from a `Chunk` of values
|
1423
|
+
*
|
1424
|
+
* @tsplus static fncts.io.StreamOps fromChunk
|
1425
|
+
*/
|
1426
|
+
export function fromChunk<O>(c: Lazy<Conc<O>>): Stream<unknown, never, O> {
|
1427
|
+
return new Stream(Channel.unwrap(IO.succeedNow(Channel.write(c))));
|
1428
|
+
}
|
1429
|
+
|
1430
|
+
/**
|
1431
|
+
* Creates a single-valued stream from a managed resource
|
1432
|
+
*
|
1433
|
+
* @tsplus static fncts.io.StreamOps scoped
|
1434
|
+
*/
|
1435
|
+
export function scoped<R, E, A>(stream: IO<R & Has<Scope>, E, A>): Stream<R, E, A> {
|
1436
|
+
return new Stream(Channel.scoped(stream.map(Conc.single)));
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
/**
|
1440
|
+
* Creates a stream from an effect producing a value of type `A`
|
1441
|
+
*
|
1442
|
+
* @tsplus static fncts.io.StreamOps fromIO
|
1443
|
+
*/
|
1444
|
+
export function fromIO<R, E, A>(fa: IO<R, E, A>): Stream<R, E, A> {
|
1445
|
+
return Stream.fromIOMaybe(fa.mapError(Maybe.just));
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
/**
|
1449
|
+
* Creates a stream from an effect producing a value of type `A` or an empty Stream
|
1450
|
+
*
|
1451
|
+
* @tsplus static fncts.io.StreamOps fromIOMaybe
|
1452
|
+
*/
|
1453
|
+
export function fromIOMaybe<R, E, A>(fa: IO<R, Maybe<E>, A>): Stream<R, E, A> {
|
1454
|
+
return new Stream(
|
1455
|
+
Channel.unwrap(
|
1456
|
+
fa.match(
|
1457
|
+
(maybeError) => maybeError.match(() => Channel.unit, Channel.failNow),
|
1458
|
+
(a) => Channel.writeNow(Conc.single(a)),
|
1459
|
+
),
|
1460
|
+
),
|
1461
|
+
);
|
1462
|
+
}
|
1463
|
+
|
1464
|
+
function fromAsyncIterableLoop<A>(
|
1465
|
+
iterator: AsyncIterator<A>,
|
1466
|
+
): Channel<unknown, unknown, unknown, unknown, never, Conc<A>, unknown> {
|
1467
|
+
return Channel.unwrap(
|
1468
|
+
IO.async<unknown, never, Channel<unknown, unknown, unknown, unknown, never, Conc<A>, unknown>>((k) => {
|
1469
|
+
iterator
|
1470
|
+
.next()
|
1471
|
+
.then((result) =>
|
1472
|
+
result.done
|
1473
|
+
? k(IO.succeedNow(Channel.end(undefined)))
|
1474
|
+
: k(IO.succeedNow(Channel.writeNow(Conc.single(result.value)).apSecond(fromAsyncIterableLoop(iterator)))),
|
1475
|
+
);
|
1476
|
+
}),
|
1477
|
+
);
|
1478
|
+
}
|
1479
|
+
|
1480
|
+
/**
|
1481
|
+
* @tsplus static fncts.io.StreamOps fromAsyncIterable
|
1482
|
+
*/
|
1483
|
+
export function fromAsyncIterable<A>(iterable: AsyncIterable<A>): Stream<unknown, never, A> {
|
1484
|
+
return new Stream(fromAsyncIterableLoop(iterable[Symbol.asyncIterator]()));
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
/**
|
1488
|
+
* @tsplus static fncts.io.StreamOps fromIterable
|
1489
|
+
*/
|
1490
|
+
export function fromIterable<A>(iterable: Iterable<A>, maxChunkSize = DEFAULT_CHUNK_SIZE): Stream<unknown, never, A> {
|
1491
|
+
return Stream.unwrap(
|
1492
|
+
IO.succeed(() => {
|
1493
|
+
const loop = (iterator: Iterator<A>): Channel<unknown, unknown, unknown, unknown, never, Conc<A>, unknown> =>
|
1494
|
+
Channel.unwrap(
|
1495
|
+
IO.succeed(() => {
|
1496
|
+
let result = iterator.next();
|
1497
|
+
if (result.done) {
|
1498
|
+
return Channel.unit;
|
1499
|
+
}
|
1500
|
+
if (maxChunkSize === 1) {
|
1501
|
+
return Channel.writeNow(Conc.single(result.value)).apSecond(loop(iterator));
|
1502
|
+
} else {
|
1503
|
+
const out = Array<A>(maxChunkSize);
|
1504
|
+
out[0] = result.value;
|
1505
|
+
let count = 1;
|
1506
|
+
while (count < maxChunkSize && !(result = iterator.next()).done) {
|
1507
|
+
out[count] = result.value;
|
1508
|
+
count++;
|
1509
|
+
}
|
1510
|
+
return Channel.writeNow(Conc.from(out)).apSecond(loop(iterator));
|
1511
|
+
}
|
1512
|
+
}),
|
1513
|
+
);
|
1514
|
+
return new Stream<unknown, never, A>(loop(iterable[Symbol.iterator]()));
|
1515
|
+
}),
|
1516
|
+
);
|
1517
|
+
}
|
1518
|
+
|
1519
|
+
/**
|
1520
|
+
* @tsplus static fncts.io.StreamOps fromIterableSingle
|
1521
|
+
*/
|
1522
|
+
export function fromIterableSingle<A>(iterable: Iterable<A>): Stream<unknown, never, A> {
|
1523
|
+
return Stream.fromIO(IO.succeed(iterable[Symbol.iterator]())).flatMap((iterator) =>
|
1524
|
+
Stream.repeatIOMaybe(
|
1525
|
+
IO.defer(() => {
|
1526
|
+
const value = iterator.next();
|
1527
|
+
if (value.done) {
|
1528
|
+
return IO.failNow(Nothing());
|
1529
|
+
} else {
|
1530
|
+
return IO.succeedNow(value.value);
|
1531
|
+
}
|
1532
|
+
}),
|
1533
|
+
),
|
1534
|
+
);
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
/**
|
1538
|
+
* @tsplus static fncts.io.StreamOps fromPull
|
1539
|
+
*/
|
1540
|
+
export function fromPull<R, E, A>(scopedPull: IO<R & Has<Scope>, never, IO<R, Maybe<E>, Conc<A>>>): Stream<R, E, A> {
|
1541
|
+
return Stream.unwrapScoped(scopedPull.map((pull) => Stream.repeatIOChunkMaybe(pull)));
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
/**
|
1545
|
+
* Creates a stream from a `Queue` of values
|
1546
|
+
*
|
1547
|
+
* @tsplus static fncts.io.StreamOps fromQueue
|
1548
|
+
*/
|
1549
|
+
export function fromQueue_<R, E, O>(
|
1550
|
+
queue: PQueue<never, R, unknown, E, never, O>,
|
1551
|
+
maxChunkSize: number = DEFAULT_CHUNK_SIZE,
|
1552
|
+
): Stream<R, E, O> {
|
1553
|
+
return repeatIOChunkMaybe(
|
1554
|
+
queue
|
1555
|
+
.takeBetween(1, maxChunkSize)
|
1556
|
+
.map(Conc.from)
|
1557
|
+
.catchAllCause((c) =>
|
1558
|
+
queue.isShutdown.flatMap((down) => {
|
1559
|
+
if (down && c.interrupted) {
|
1560
|
+
return Pull.end;
|
1561
|
+
} else {
|
1562
|
+
return Pull.failCause(c);
|
1563
|
+
}
|
1564
|
+
}),
|
1565
|
+
),
|
1566
|
+
);
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
/**
|
1570
|
+
* @tsplus static fncts.io.StreamOps fromQueueWithShutdown
|
1571
|
+
*/
|
1572
|
+
export function fromQueueWithShutdown<R, E, A>(
|
1573
|
+
queue: PQueue<never, R, unknown, E, never, A>,
|
1574
|
+
maxChunkSize: number = DEFAULT_CHUNK_SIZE,
|
1575
|
+
): Stream<R, E, A> {
|
1576
|
+
return Stream.fromQueue(queue, maxChunkSize).ensuring(queue.shutdown);
|
1577
|
+
}
|
1578
|
+
|
1579
|
+
/**
|
1580
|
+
* Halt a stream with the specified exception
|
1581
|
+
*
|
1582
|
+
* @tsplus static fncts.io.StreamOps haltNow
|
1583
|
+
*/
|
1584
|
+
export function haltNow(u: unknown): Stream<unknown, never, never> {
|
1585
|
+
return new Stream(Channel.halt(u));
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
/**
|
1589
|
+
* Halt a stream with the specified exception
|
1590
|
+
*
|
1591
|
+
* @tsplus static fncts.io.StreamOps halt
|
1592
|
+
*/
|
1593
|
+
export function halt(u: Lazy<unknown>): Stream<unknown, never, never> {
|
1594
|
+
return new Stream(Channel.halt(u));
|
1595
|
+
}
|
1596
|
+
|
1597
|
+
function haltWhenWriter<R, E, A, R1, E1>(
|
1598
|
+
fiber: Fiber<E1, any>,
|
1599
|
+
): Channel<R & R1, E | E1, Conc<A>, unknown, E | E1, Conc<A>, void> {
|
1600
|
+
return Channel.unwrap(
|
1601
|
+
fiber.poll.map((maybeExit) =>
|
1602
|
+
maybeExit.match(
|
1603
|
+
() =>
|
1604
|
+
Channel.readWith(
|
1605
|
+
(i: Conc<A>) => Channel.writeNow(i).apSecond(haltWhenWriter<R, E, A, R1, E1>(fiber)),
|
1606
|
+
Channel.failNow,
|
1607
|
+
() => Channel.unit,
|
1608
|
+
),
|
1609
|
+
(exit) => exit.match(Channel.failCauseNow, () => Channel.unit),
|
1610
|
+
),
|
1611
|
+
),
|
1612
|
+
);
|
1613
|
+
}
|
1614
|
+
|
1615
|
+
/**
|
1616
|
+
* Halts the evaluation of this stream when the provided IO completes. The
|
1617
|
+
* given IO will be forked as part of the returned stream, and its success
|
1618
|
+
* will be discarded.
|
1619
|
+
*
|
1620
|
+
* An element in the process of being pulled will not be interrupted when the
|
1621
|
+
* IO completes. See `interruptWhen` for this behavior.
|
1622
|
+
*
|
1623
|
+
* If the IO completes with a failure, the stream will emit that failure.
|
1624
|
+
*
|
1625
|
+
* @tsplus fluent fncts.io.Stream haltWhen
|
1626
|
+
*/
|
1627
|
+
export function haltWhen_<R, E, A, R1, E1>(fa: Stream<R, E, A>, io: IO<R1, E1, any>): Stream<R & R1, E | E1, A> {
|
1628
|
+
return new Stream(Channel.unwrapScoped(io.forkScoped.map((fiber) => fa.channel.pipeTo(haltWhenWriter(fiber)))));
|
1629
|
+
}
|
1630
|
+
|
1631
|
+
function haltWhenFutureWriter<R, E, A, E1>(
|
1632
|
+
future: Future<E1, unknown>,
|
1633
|
+
): Channel<R, E | E1, Conc<A>, unknown, E | E1, Conc<A>, void> {
|
1634
|
+
return Channel.unwrap(
|
1635
|
+
future.poll.map((maybeIO) =>
|
1636
|
+
maybeIO.match(
|
1637
|
+
() =>
|
1638
|
+
Channel.readWith(
|
1639
|
+
(i: Conc<A>) => Channel.writeNow(i).apSecond(haltWhenFutureWriter<R, E, A, E1>(future)),
|
1640
|
+
Channel.failNow,
|
1641
|
+
() => Channel.unit,
|
1642
|
+
),
|
1643
|
+
(io) => Channel.unwrap(io.match(Channel.failNow, () => Channel.unit)),
|
1644
|
+
),
|
1645
|
+
),
|
1646
|
+
);
|
1647
|
+
}
|
1648
|
+
|
1649
|
+
/**
|
1650
|
+
* Halts the evaluation of this stream when the provided promise resolves.
|
1651
|
+
*
|
1652
|
+
* If the promise completes with a failure, the stream will emit that failure.
|
1653
|
+
*
|
1654
|
+
* @tsplus fluent fncts.io.Stream haltWhen
|
1655
|
+
*/
|
1656
|
+
export function haltWhenFuture_<R, E, A, E1>(fa: Stream<R, E, A>, future: Future<E1, any>): Stream<R, E | E1, A> {
|
1657
|
+
return new Stream(fa.channel.pipeTo(haltWhenFutureWriter(future)));
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
/**
|
1661
|
+
* @tsplus fluent fncts.io.Stream interleave
|
1662
|
+
*/
|
1663
|
+
export function interleave_<R, E, A, R1, E1, B>(
|
1664
|
+
sa: Stream<R, E, A>,
|
1665
|
+
sb: Stream<R1, E1, B>,
|
1666
|
+
): Stream<R & R1, E | E1, A | B> {
|
1667
|
+
return sa.interleaveWith(sb, Stream.fromChunk(Conc(true, false)).forever);
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
function interleaveWithProducer<R, E, A>(handoff: Handoff<Take<E, A>>): Channel<R, E, A, unknown, never, never, void> {
|
1671
|
+
return Channel.readWithCause(
|
1672
|
+
(value: A) => Channel.fromIO(handoff.offer(Take.single(value))).apSecond(interleaveWithProducer(handoff)),
|
1673
|
+
(cause) => Channel.fromIO(handoff.offer(Take.failCause(cause))),
|
1674
|
+
() => Channel.fromIO(handoff.offer(Take.end)),
|
1675
|
+
);
|
1676
|
+
}
|
1677
|
+
|
1678
|
+
/**
|
1679
|
+
* Combines this stream and the specified stream deterministically using the
|
1680
|
+
* stream of boolean values `b` to control which stream to pull from next.
|
1681
|
+
* `true` indicates to pull from this stream and `false` indicates to pull
|
1682
|
+
* from the specified stream. Only consumes as many elements as requested by
|
1683
|
+
* `b`. If either this stream or the specified stream are exhausted further
|
1684
|
+
* requests for values from that stream will be ignored.
|
1685
|
+
*
|
1686
|
+
* @tsplus fluent fncts.io.Stream interleaveWith
|
1687
|
+
*/
|
1688
|
+
export function interleaveWith_<R, E, A, R1, E1, B, R2, E2>(
|
1689
|
+
sa: Stream<R, E, A>,
|
1690
|
+
sb: Stream<R1, E1, B>,
|
1691
|
+
b: Stream<R2, E2, boolean>,
|
1692
|
+
): Stream<R & R1 & R2, E | E1 | E2, A | B> {
|
1693
|
+
return new Stream(
|
1694
|
+
Channel.unwrapScoped(
|
1695
|
+
Do((Δ) => {
|
1696
|
+
const left = Δ(Handoff<Take<E, A>>());
|
1697
|
+
const right = Δ(Handoff<Take<E1, B>>());
|
1698
|
+
Δ(sa.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(left)).runScoped.fork);
|
1699
|
+
Δ(sb.channel.concatMap(Channel.writeChunk).pipeTo(interleaveWithProducer(right)).runScoped.fork);
|
1700
|
+
return tuple(left, right);
|
1701
|
+
}).map(([left, right]) => {
|
1702
|
+
const process = (
|
1703
|
+
leftDone: boolean,
|
1704
|
+
rightDone: boolean,
|
1705
|
+
): Channel<R & R1 & R2, E | E1 | E2, boolean, unknown, E | E1 | E2, Conc<A | B>, void> =>
|
1706
|
+
Channel.readWithCause(
|
1707
|
+
(b: boolean) => {
|
1708
|
+
if (b && !leftDone) {
|
1709
|
+
return Channel.fromIO(left.take).flatMap((take) =>
|
1710
|
+
take.match(rightDone ? Channel.unit : process(true, rightDone), Channel.failCauseNow, (chunk) =>
|
1711
|
+
Channel.writeNow(chunk).apSecond(process(leftDone, rightDone)),
|
1712
|
+
),
|
1713
|
+
);
|
1714
|
+
}
|
1715
|
+
if (!b && !rightDone) {
|
1716
|
+
return Channel.fromIO(right.take).flatMap((take) =>
|
1717
|
+
take.match(leftDone ? Channel.unit : process(leftDone, true), Channel.failCauseNow, (chunk) =>
|
1718
|
+
Channel.writeNow(chunk).apSecond(process(leftDone, rightDone)),
|
1719
|
+
),
|
1720
|
+
);
|
1721
|
+
}
|
1722
|
+
return process(leftDone, rightDone);
|
1723
|
+
},
|
1724
|
+
Channel.failCauseNow,
|
1725
|
+
() => Channel.unit,
|
1726
|
+
);
|
1727
|
+
return b.channel.concatMap(Channel.writeChunk).pipeTo(process(false, false));
|
1728
|
+
}),
|
1729
|
+
),
|
1730
|
+
);
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
function intersperseWriter<R, E, A, A1>(
|
1734
|
+
middle: A1,
|
1735
|
+
isFirst: boolean,
|
1736
|
+
): Channel<R, E, Conc<A>, unknown, E, Conc<A | A1>, void> {
|
1737
|
+
return Channel.readWith(
|
1738
|
+
(inp: Conc<A>) => {
|
1739
|
+
const builder = Conc.builder<A | A1>();
|
1740
|
+
let flagResult = isFirst;
|
1741
|
+
inp.forEach((a) => {
|
1742
|
+
if (flagResult) {
|
1743
|
+
flagResult = false;
|
1744
|
+
builder.append(a);
|
1745
|
+
} else {
|
1746
|
+
builder.append(middle);
|
1747
|
+
builder.append(a);
|
1748
|
+
}
|
1749
|
+
});
|
1750
|
+
return Channel.writeNow(builder.result()).apSecond(intersperseWriter(middle, flagResult));
|
1751
|
+
},
|
1752
|
+
Channel.failNow,
|
1753
|
+
() => Channel.unit,
|
1754
|
+
);
|
1755
|
+
}
|
1756
|
+
|
1757
|
+
/**
|
1758
|
+
* Intersperse stream with provided element
|
1759
|
+
*/
|
1760
|
+
export function intersperse_<R, E, A, A1>(stream: Stream<R, E, A>, middle: A1): Stream<R, E, A | A1> {
|
1761
|
+
return new Stream(stream.channel.pipeTo(intersperseWriter(middle, true)));
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
/**
|
1765
|
+
* Interrupts the evaluation of this stream when the provided IO completes. The given
|
1766
|
+
* IO will be forked as part of this stream, and its success will be discarded. This
|
1767
|
+
* combinator will also interrupt any in-progress element being pulled from upstream.
|
1768
|
+
*
|
1769
|
+
* If the IO completes with a failure before the stream completes, the returned stream
|
1770
|
+
* will emit that failure.
|
1771
|
+
*
|
1772
|
+
* @tsplus fluent fncts.io.Stream interruptWhen
|
1773
|
+
*/
|
1774
|
+
export function interruptWhen_<R, E, A, R1, E1>(
|
1775
|
+
stream: Stream<R, E, A>,
|
1776
|
+
io: IO<R1, E1, any>,
|
1777
|
+
): Stream<R & R1, E | E1, A> {
|
1778
|
+
return new Stream(stream.channel.interruptWhen(io));
|
1779
|
+
}
|
1780
|
+
|
1781
|
+
/**
|
1782
|
+
* @tsplus fluent fncts.io.Stream interruptWhen
|
1783
|
+
*/
|
1784
|
+
export function interruptWhenFuture_<R, E, A, E1>(
|
1785
|
+
fa: Stream<R, E, A>,
|
1786
|
+
future: Future<E1, unknown>,
|
1787
|
+
): Stream<R, E | E1, A> {
|
1788
|
+
return new Stream(fa.channel.interruptWhen(future));
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
/**
|
1792
|
+
* Loops over the stream chunks concatenating the result of f
|
1793
|
+
*
|
1794
|
+
* @tsplus fluent fncts.io.Stream loopOnChunks
|
1795
|
+
*/
|
1796
|
+
export function loopOnChunks_<R, E, A, R1, E1, A1>(
|
1797
|
+
stream: Stream<R, E, A>,
|
1798
|
+
f: (a: Conc<A>) => Channel<R1, E | E1, Conc<A>, unknown, E | E1, Conc<A1>, boolean>,
|
1799
|
+
): Stream<R & R1, E | E1, A1> {
|
1800
|
+
const loop: Channel<R1, E | E1, Conc<A>, unknown, E | E1, Conc<A1>, boolean> = Channel.readWithCause(
|
1801
|
+
(chunk) => f(chunk).flatMap((cont) => (cont ? loop : Channel.endNow(false))),
|
1802
|
+
Channel.failCauseNow,
|
1803
|
+
(_) => Channel.succeedNow(false),
|
1804
|
+
);
|
1805
|
+
return new Stream(stream.channel.pipeTo(loop));
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
/**
|
1809
|
+
* Loops on chunks emitting partially
|
1810
|
+
*
|
1811
|
+
* @tsplus fluent fncts.io.Stream loopOnPartialChunks
|
1812
|
+
*/
|
1813
|
+
export function loopOnPartialChunks_<R, E, A, R1, E1, A1>(
|
1814
|
+
stream: Stream<R, E, A>,
|
1815
|
+
f: (a: Conc<A>, emit: (a: A1) => UIO<void>) => IO<R1, E1, boolean>,
|
1816
|
+
): Stream<R & R1, E | E1, A1> {
|
1817
|
+
return stream.loopOnChunks((chunk) =>
|
1818
|
+
Channel.unwrap(
|
1819
|
+
IO.defer(() => {
|
1820
|
+
let outputChunk = Conc.empty<A1>();
|
1821
|
+
return f(chunk, (a) =>
|
1822
|
+
IO.succeed(() => {
|
1823
|
+
outputChunk = outputChunk.append(a);
|
1824
|
+
}),
|
1825
|
+
)
|
1826
|
+
.map((cont) => Channel.write(outputChunk).apSecond(Channel.endNow(cont)))
|
1827
|
+
.catchAll((failure) =>
|
1828
|
+
IO.succeed(() => {
|
1829
|
+
if (outputChunk.isEmpty) {
|
1830
|
+
return Channel.failNow(failure);
|
1831
|
+
} else {
|
1832
|
+
return Channel.writeNow(outputChunk).apSecond(Channel.failNow(failure));
|
1833
|
+
}
|
1834
|
+
}),
|
1835
|
+
);
|
1836
|
+
}),
|
1837
|
+
),
|
1838
|
+
);
|
1839
|
+
}
|
1840
|
+
|
1841
|
+
/**
|
1842
|
+
* Loops on chunks elements emitting partially
|
1843
|
+
*
|
1844
|
+
* @tsplus fluent fncts.io.Stream loopOnPartialChunksElements
|
1845
|
+
*/
|
1846
|
+
export function loopOnPartialChunksElements_<R, E, A, R1, E1, A1>(
|
1847
|
+
stream: Stream<R, E, A>,
|
1848
|
+
f: (a: A, emit: (a: A1) => UIO<void>) => IO<R1, E1, void>,
|
1849
|
+
): Stream<R & R1, E | E1, A1> {
|
1850
|
+
return stream.loopOnPartialChunks((as, emit) => as.mapIO((a) => f(a, emit)).as(true));
|
1851
|
+
}
|
1852
|
+
|
1853
|
+
/**
|
1854
|
+
* Transforms the elements of this stream using the supplied function.
|
1855
|
+
*
|
1856
|
+
* @tsplus fluent fncts.io.Stream map
|
1857
|
+
*/
|
1858
|
+
export function map_<R, E, A, B>(stream: Stream<R, E, A>, f: (o: A) => B): Stream<R, E, B> {
|
1859
|
+
return new Stream(stream.channel.mapOut((as) => as.map(f)));
|
1860
|
+
}
|
1861
|
+
|
1862
|
+
function mapAccumAccumulator<S, E = never, A = never, B = never>(
|
1863
|
+
currS: S,
|
1864
|
+
f: (s: S, a: A) => readonly [B, S],
|
1865
|
+
): Channel<unknown, E, Conc<A>, unknown, E, Conc<B>, void> {
|
1866
|
+
return Channel.readWith(
|
1867
|
+
(inp: Conc<A>) => {
|
1868
|
+
const [bs, nextS] = inp.mapAccum(currS, f);
|
1869
|
+
return Channel.writeNow(bs).apSecond(mapAccumAccumulator(nextS, f));
|
1870
|
+
},
|
1871
|
+
Channel.failNow,
|
1872
|
+
() => Channel.unit,
|
1873
|
+
);
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
/**
|
1877
|
+
* Statefully maps over the elements of this stream to produce new elements.
|
1878
|
+
*
|
1879
|
+
* @tsplus fluent fncts.io.Stream mapAccum
|
1880
|
+
*/
|
1881
|
+
export function mapAccum_<R, E, A, S, B>(
|
1882
|
+
stream: Stream<R, E, A>,
|
1883
|
+
s: S,
|
1884
|
+
f: (s: S, a: A) => readonly [B, S],
|
1885
|
+
): Stream<R, E, B> {
|
1886
|
+
return new Stream(stream.channel.pipeTo(mapAccumAccumulator(s, f)));
|
1887
|
+
}
|
1888
|
+
|
1889
|
+
function mapAccumIOAccumulator<R, E, A, R1, E1, S, B>(
|
1890
|
+
s: S,
|
1891
|
+
f: (s: S, a: A) => IO<R1, E1, readonly [B, S]>,
|
1892
|
+
): Channel<R & R1, E, Conc<A>, unknown, E | E1, Conc<B>, void> {
|
1893
|
+
return Channel.readWith(
|
1894
|
+
(inp: Conc<A>) =>
|
1895
|
+
Channel.unwrap(
|
1896
|
+
IO.defer(() => {
|
1897
|
+
const outputChunk = Conc.builder<B>();
|
1898
|
+
const emit = (b: B) =>
|
1899
|
+
IO.succeed(() => {
|
1900
|
+
outputChunk.append(b);
|
1901
|
+
});
|
1902
|
+
return IO.foldLeft(inp, s, (s1, a) => f(s1, a).flatMap(([b, s2]) => emit(b).as(s2))).match(
|
1903
|
+
(e) => {
|
1904
|
+
const partialResult = outputChunk.result();
|
1905
|
+
return partialResult.isNonEmpty
|
1906
|
+
? Channel.writeNow(partialResult).apSecond(Channel.failNow(e))
|
1907
|
+
: Channel.failNow(e);
|
1908
|
+
},
|
1909
|
+
(s) => Channel.writeNow(outputChunk.result()).apSecond(mapAccumIOAccumulator(s, f)),
|
1910
|
+
);
|
1911
|
+
}),
|
1912
|
+
),
|
1913
|
+
Channel.failNow,
|
1914
|
+
() => Channel.unit,
|
1915
|
+
);
|
1916
|
+
}
|
1917
|
+
|
1918
|
+
/**
|
1919
|
+
* Statefully and effectfully maps over the elements of this stream to produce
|
1920
|
+
* new elements.
|
1921
|
+
*
|
1922
|
+
* @tsplus fluent fncts.io.Stream mapAccumIO
|
1923
|
+
*/
|
1924
|
+
export function mapAccumIO_<R, E, A, R1, E1, S, B>(
|
1925
|
+
stream: Stream<R, E, A>,
|
1926
|
+
s: S,
|
1927
|
+
f: (s: S, a: A) => IO<R1, E1, readonly [B, S]>,
|
1928
|
+
): Stream<R & R1, E | E1, B> {
|
1929
|
+
return new Stream(stream.channel.pipeTo(mapAccumIOAccumulator(s, f)));
|
1930
|
+
}
|
1931
|
+
|
1932
|
+
/**
|
1933
|
+
* Transforms the chunks emitted by this stream.
|
1934
|
+
*
|
1935
|
+
* @tsplus fluent fncts.io.Stream mapChunks
|
1936
|
+
*/
|
1937
|
+
export function mapChunks_<R, E, A, A1>(stream: Stream<R, E, A>, f: (chunk: Conc<A>) => Conc<A1>): Stream<R, E, A1> {
|
1938
|
+
return new Stream(stream.channel.mapOut(f));
|
1939
|
+
}
|
1940
|
+
|
1941
|
+
/**
|
1942
|
+
* Effectfully transforms the chunks emitted by this stream.
|
1943
|
+
*
|
1944
|
+
* @tsplus fluent fncts.io.Stream mapChunksIO
|
1945
|
+
*/
|
1946
|
+
export function mapChunksIO_<R, E, A, R1, E1, B>(
|
1947
|
+
stream: Stream<R, E, A>,
|
1948
|
+
f: (chunk: Conc<A>) => IO<R1, E1, Conc<B>>,
|
1949
|
+
): Stream<R & R1, E | E1, B> {
|
1950
|
+
return new Stream(stream.channel.mapOutIO(f));
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
/**
|
1954
|
+
* Maps each element to an iterable, and flattens the iterables into the
|
1955
|
+
* output of this stream.
|
1956
|
+
*
|
1957
|
+
* @tsplus fluent fncts.io.Stream mapConcat
|
1958
|
+
*/
|
1959
|
+
export function mapConcat_<R, E, A, B>(stream: Stream<R, E, A>, f: (a: A) => Iterable<B>): Stream<R, E, B> {
|
1960
|
+
return stream.mapConcatChunk((a) => Conc.from(f(a)));
|
1961
|
+
}
|
1962
|
+
|
1963
|
+
/**
|
1964
|
+
* Maps each element to a chunk, and flattens the chunks into the output of
|
1965
|
+
* this stream.
|
1966
|
+
*
|
1967
|
+
* @tsplus fluent fncts.io.Stream mapConcatChunk
|
1968
|
+
*/
|
1969
|
+
export function mapConcatChunk_<R, E, A, B>(stream: Stream<R, E, A>, f: (a: A) => Conc<B>): Stream<R, E, B> {
|
1970
|
+
return stream.mapChunks((c) => c.flatMap(f));
|
1971
|
+
}
|
1972
|
+
|
1973
|
+
/**
|
1974
|
+
* Effectfully maps each element to a chunk, and flattens the chunks into
|
1975
|
+
* the output of this stream.
|
1976
|
+
*
|
1977
|
+
* @tsplus fluent fncts.io.Stream mapConcatChunkIO
|
1978
|
+
*/
|
1979
|
+
export function mapConcatChunkIO_<R, E, A, R1, E1, B>(
|
1980
|
+
stream: Stream<R, E, A>,
|
1981
|
+
f: (a: A) => IO<R1, E1, Conc<B>>,
|
1982
|
+
): Stream<R & R1, E | E1, B> {
|
1983
|
+
return stream.mapIO(f).mapConcatChunk(identity);
|
1984
|
+
}
|
1985
|
+
|
1986
|
+
/**
|
1987
|
+
* Effectfully maps each element to an iterable, and flattens the iterables into
|
1988
|
+
* the output of this stream.
|
1989
|
+
*
|
1990
|
+
* @tsplus fluent fncts.io.Stream mapConcatIO
|
1991
|
+
*/
|
1992
|
+
export function mapConcatIO_<R, E, A, R1, E1, B>(
|
1993
|
+
stream: Stream<R, E, A>,
|
1994
|
+
f: (a: A) => IO<R1, E1, Iterable<B>>,
|
1995
|
+
): Stream<R & R1, E | E1, B> {
|
1996
|
+
return stream.mapIO((a) => f(a).map(Conc.from)).mapConcatChunk(identity);
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
/**
|
2000
|
+
* Transforms the errors emitted by this stream using `f`.
|
2001
|
+
*
|
2002
|
+
* @tsplus fluent fncts.io.Stream mapError
|
2003
|
+
*/
|
2004
|
+
export function mapError_<R, E, E1, A>(stream: Stream<R, E, A>, f: (e: E) => E1): Stream<R, E1, A> {
|
2005
|
+
return new Stream(stream.channel.mapError(f));
|
2006
|
+
}
|
2007
|
+
|
2008
|
+
/**
|
2009
|
+
* Transforms the full causes of failures emitted by this stream.
|
2010
|
+
*
|
2011
|
+
* @tsplus fluent fncts.io.Stream mapErrorCause
|
2012
|
+
*/
|
2013
|
+
export function mapErrorCause_<R, E, A, E1>(fa: Stream<R, E, A>, f: (e: Cause<E>) => Cause<E1>): Stream<R, E1, A> {
|
2014
|
+
return new Stream(fa.channel.mapErrorCause(f));
|
2015
|
+
}
|
2016
|
+
|
2017
|
+
/**
|
2018
|
+
* Maps over elements of the stream with the specified effectful function.
|
2019
|
+
*
|
2020
|
+
* @tsplus fluent fncts.io.Stream mapIO
|
2021
|
+
*/
|
2022
|
+
export function mapIO_<R, E, A, R1, E1, B>(
|
2023
|
+
stream: Stream<R, E, A>,
|
2024
|
+
f: (a: A) => IO<R1, E1, B>,
|
2025
|
+
): Stream<R & R1, E | E1, B> {
|
2026
|
+
return stream.loopOnPartialChunksElements((a, emit) => f(a).flatMap(emit));
|
2027
|
+
}
|
2028
|
+
|
2029
|
+
/**
|
2030
|
+
* Maps over elements of the stream with the specified effectful function,
|
2031
|
+
* executing up to `n` invocations of `f` concurrently. Transformed elements
|
2032
|
+
* will be emitted in the original order.
|
2033
|
+
*
|
2034
|
+
* @note This combinator destroys the chunking structure. It's recommended to use chunkN afterwards.
|
2035
|
+
*
|
2036
|
+
* @tsplus fluent fncts.io.Stream mapIOC
|
2037
|
+
*/
|
2038
|
+
export function mapIOC_<R, E, A, R1, E1, B>(
|
2039
|
+
stream: Stream<R, E, A>,
|
2040
|
+
n: number,
|
2041
|
+
f: (a: A) => IO<R1, E1, B>,
|
2042
|
+
): Stream<R & R1, E | E1, B> {
|
2043
|
+
return new Stream(stream.channel.concatMap(Channel.writeChunk).mapOutIOC(n, f).mapOut(Conc.single));
|
2044
|
+
}
|
2045
|
+
|
2046
|
+
/**
|
2047
|
+
* Maps each element of this stream to another stream and returns the
|
2048
|
+
* non-deterministic merge of those streams, executing up to `n` inner streams
|
2049
|
+
* concurrently. Up to `bufferSize` elements of the produced streams may be
|
2050
|
+
* buffered in memory by this operator.
|
2051
|
+
*
|
2052
|
+
* @tsplus fluent fncts.io.Stream mergeMap
|
2053
|
+
*/
|
2054
|
+
export function mergeMap_<R, E, A, R1, E1, B>(
|
2055
|
+
ma: Stream<R, E, A>,
|
2056
|
+
f: (a: A) => Stream<R1, E1, B>,
|
2057
|
+
n: number,
|
2058
|
+
bufferSize = 16,
|
2059
|
+
): Stream<R & R1, E | E1, B> {
|
2060
|
+
return new Stream(ma.channel.concatMap(Channel.writeChunk).mergeMap((a) => f(a).channel, n, bufferSize));
|
2061
|
+
}
|
2062
|
+
|
2063
|
+
/**
|
2064
|
+
* Maps over elements of the stream with the specified effectful function,
|
2065
|
+
* executing up to `n` invocations of `f` concurrently. The element order
|
2066
|
+
* is not enforced by this combinator, and elements may be reordered.
|
2067
|
+
*
|
2068
|
+
* @tsplus fluent fncts.io.Stream mergeMapIO
|
2069
|
+
*/
|
2070
|
+
export function mergeMapIO_<R, E, A, R1, E1, B>(
|
2071
|
+
stream: Stream<R, E, A>,
|
2072
|
+
f: (a: A) => IO<R1, E1, B>,
|
2073
|
+
n: number,
|
2074
|
+
bufferSize = 16,
|
2075
|
+
): Stream<R & R1, E | E1, B> {
|
2076
|
+
return stream.mergeMap((a) => Stream.fromIO(f(a)), n, bufferSize);
|
2077
|
+
}
|
2078
|
+
|
2079
|
+
/**
|
2080
|
+
* @tsplus fluent fncts.io.Stream mergeEither
|
2081
|
+
*/
|
2082
|
+
export function mergeEither_<R, E, A, R1, E1, B>(
|
2083
|
+
fa: Stream<R, E, A>,
|
2084
|
+
fb: Stream<R1, E1, B>,
|
2085
|
+
): Stream<R & R1, E | E1, Either<A, B>> {
|
2086
|
+
return fa.mergeWith(fb, Either.left, Either.right);
|
2087
|
+
}
|
2088
|
+
|
2089
|
+
export function mergeWithHandler<R, E>(
|
2090
|
+
terminate: boolean,
|
2091
|
+
): (exit: Exit<E, unknown>) => MergeDecision<R, E, unknown, E, unknown> {
|
2092
|
+
return (exit) =>
|
2093
|
+
terminate || !exit.isSuccess() ? MergeDecision.Done(IO.fromExitNow(exit)) : MergeDecision.Await(IO.fromExitNow);
|
2094
|
+
}
|
2095
|
+
|
2096
|
+
export type TerminationStrategy = "Left" | "Right" | "Both" | "Either";
|
2097
|
+
|
2098
|
+
/**
|
2099
|
+
* @tsplus fluent fncts.io.Stream mergeWith
|
2100
|
+
*/
|
2101
|
+
export function mergeWith_<R, E, A, R1, E1, A1, B, C>(
|
2102
|
+
sa: Stream<R, E, A>,
|
2103
|
+
sb: Stream<R1, E1, A1>,
|
2104
|
+
l: (a: A) => B,
|
2105
|
+
r: (b: A1) => C,
|
2106
|
+
strategy: TerminationStrategy = "Both",
|
2107
|
+
): Stream<R & R1, E | E1, B | C> {
|
2108
|
+
return new Stream<R & R1, E | E1, B | C>(
|
2109
|
+
sa
|
2110
|
+
.map(l)
|
2111
|
+
.channel.mergeWith(
|
2112
|
+
map_(sb, r).channel,
|
2113
|
+
mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Left"),
|
2114
|
+
mergeWithHandler<R & R1, E | E1>(strategy === "Either" || strategy === "Right"),
|
2115
|
+
),
|
2116
|
+
);
|
2117
|
+
}
|
2118
|
+
|
2119
|
+
/**
|
2120
|
+
* Runs the specified effect if this stream fails, providing the error to the effect if it exists.
|
2121
|
+
*
|
2122
|
+
* Note: Unlike `IO.onError`, there is no guarantee that the provided effect will not be interrupted.
|
2123
|
+
*
|
2124
|
+
* @tsplus fluent fncts.io.Stream onError
|
2125
|
+
*/
|
2126
|
+
export function onError_<R, E, A, R1>(
|
2127
|
+
stream: Stream<R, E, A>,
|
2128
|
+
cleanup: (e: Cause<E>) => IO<R1, never, any>,
|
2129
|
+
): Stream<R & R1, E, A> {
|
2130
|
+
return stream.catchAllCause((cause) => fromIO(cleanup(cause).apSecond(IO.failCauseNow(cause))));
|
2131
|
+
}
|
2132
|
+
|
2133
|
+
/**
|
2134
|
+
* Switches to the provided stream in case this one fails with a typed error.
|
2135
|
+
*
|
2136
|
+
* See also Stream#catchAll
|
2137
|
+
*
|
2138
|
+
* @tsplus fluent fncts.io.Stream orElse
|
2139
|
+
*/
|
2140
|
+
export function orElse_<R, E, A, R1, E1, A1>(
|
2141
|
+
stream: Stream<R, E, A>,
|
2142
|
+
that: Lazy<Stream<R1, E1, A1>>,
|
2143
|
+
): Stream<R & R1, E1, A | A1> {
|
2144
|
+
return new Stream<R & R1, E1, A | A1>(stream.channel.orElse(that().channel));
|
2145
|
+
}
|
2146
|
+
|
2147
|
+
/**
|
2148
|
+
* Switches to the provided stream in case this one fails with a typed error.
|
2149
|
+
*
|
2150
|
+
* See also ZStream#catchAll
|
2151
|
+
*
|
2152
|
+
* @tsplus fluent fncts.io.Stream orElseEither
|
2153
|
+
*/
|
2154
|
+
export function orElseEither_<R, E, A, R1, E1, A1>(
|
2155
|
+
stream: Stream<R, E, A>,
|
2156
|
+
that: Lazy<Stream<R1, E1, A1>>,
|
2157
|
+
): Stream<R & R1, E1, Either<A, A1>> {
|
2158
|
+
return stream.map(Either.left).orElse(that().map(Either.right));
|
2159
|
+
}
|
2160
|
+
|
2161
|
+
/**
|
2162
|
+
* Fails with given error in case this one fails with a typed error.
|
2163
|
+
*
|
2164
|
+
* See also Stream#catchAll
|
2165
|
+
*
|
2166
|
+
* @tsplus fluent fncts.io.Stream orElseFail
|
2167
|
+
*/
|
2168
|
+
export function orElseFail_<R, E, A, E1>(stream: Stream<R, E, A>, e: Lazy<E1>): Stream<R, E1, A> {
|
2169
|
+
return stream.orElse(Stream.failNow(e()));
|
2170
|
+
}
|
2171
|
+
|
2172
|
+
/**
|
2173
|
+
* Switches to the provided stream in case this one fails with the `None` value.
|
2174
|
+
*
|
2175
|
+
* See also Stream#catchAll.
|
2176
|
+
*/
|
2177
|
+
export function orElseOptional_<R, E, A, R1, E1, A1>(
|
2178
|
+
stream: Stream<R, Maybe<E>, A>,
|
2179
|
+
that: Lazy<Stream<R1, Maybe<E1>, A1>>,
|
2180
|
+
): Stream<R & R1, Maybe<E | E1>, A | A1> {
|
2181
|
+
return stream.catchAll((maybeError) =>
|
2182
|
+
maybeError.match(
|
2183
|
+
() => that(),
|
2184
|
+
(e) => Stream.failNow(Just(e)),
|
2185
|
+
),
|
2186
|
+
);
|
2187
|
+
}
|
2188
|
+
|
2189
|
+
/**
|
2190
|
+
* Succeeds with the specified value if this one fails with a typed error.
|
2191
|
+
*
|
2192
|
+
* @tsplus fluent fncts.io.Stream orElseSucceed
|
2193
|
+
*/
|
2194
|
+
export function orElseSucceed_<R, E, A, A1>(stream: Stream<R, E, A>, a: Lazy<A1>): Stream<R, never, A | A1> {
|
2195
|
+
return stream.orElse(Stream.succeedNow(a()));
|
2196
|
+
}
|
2197
|
+
|
2198
|
+
/**
|
2199
|
+
* @tsplus fluent fncts.io.Stream pipeThrough
|
2200
|
+
*/
|
2201
|
+
export function pipeThrough_<R, E, A, R1, E1, L, Z>(
|
2202
|
+
ma: Stream<R, E, A>,
|
2203
|
+
sa: Sink<R1, E1, A, L, Z>,
|
2204
|
+
): Stream<R & R1, E | E1, L> {
|
2205
|
+
return new Stream(ma.channel.pipeToOrFail(sa.channel));
|
2206
|
+
}
|
2207
|
+
|
2208
|
+
/**
|
2209
|
+
* Provides the stream with its required environment, which eliminates
|
2210
|
+
* its dependency on `R`.
|
2211
|
+
*
|
2212
|
+
* @tsplus fluent fncts.io.Stream provideEnvironment
|
2213
|
+
*/
|
2214
|
+
export function provideEnvironment_<R, E, A>(ra: Stream<R, E, A>, r: Environment<R>): Stream<unknown, E, A> {
|
2215
|
+
return new Stream(ra.channel.provideEnvironment(r));
|
2216
|
+
}
|
2217
|
+
|
2218
|
+
/**
|
2219
|
+
* @tsplus fluent fncts.io.Stream provideLayer
|
2220
|
+
*/
|
2221
|
+
export function provideLayer_<RIn, E, ROut, E1, A>(
|
2222
|
+
self: Stream<ROut, E, A>,
|
2223
|
+
layer: Layer<RIn, E1, ROut>,
|
2224
|
+
__tsplusTrace?: string,
|
2225
|
+
): Stream<RIn, E | E1, A> {
|
2226
|
+
return new Stream(Channel.unwrapScoped(layer.build.map((r) => self.channel.provideEnvironment(r))));
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
/**
|
2230
|
+
* @tsplus fluent fncts.io.Stream provideSomeLayer
|
2231
|
+
*/
|
2232
|
+
export function provideSomeLayer_<R, E, A, RIn, E1, ROut>(
|
2233
|
+
self: Stream<R, E, A>,
|
2234
|
+
layer: Layer<RIn, E1, ROut>,
|
2235
|
+
__tsplusTrace?: string,
|
2236
|
+
): Stream<RIn & Erase<R, ROut>, E | E1, A> {
|
2237
|
+
// @ts-expect-error
|
2238
|
+
return self.provideLayer(Layer.environment<RIn>().and(layer));
|
2239
|
+
}
|
2240
|
+
|
2241
|
+
class Rechunker<A> {
|
2242
|
+
private builder: Array<A> = [];
|
2243
|
+
private pos = 0;
|
2244
|
+
|
2245
|
+
constructor(readonly n: number) {}
|
2246
|
+
|
2247
|
+
write(elem: A) {
|
2248
|
+
this.builder.push(elem);
|
2249
|
+
this.pos += 1;
|
2250
|
+
|
2251
|
+
if (this.pos === this.n) {
|
2252
|
+
const result = this.builder;
|
2253
|
+
this.builder = [];
|
2254
|
+
this.pos = 0;
|
2255
|
+
|
2256
|
+
return Conc.from(result);
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
return null;
|
2260
|
+
}
|
2261
|
+
|
2262
|
+
emitOfNotEmpty(): Channel<unknown, unknown, unknown, unknown, never, Conc<A>, void> {
|
2263
|
+
if (this.pos !== 0) {
|
2264
|
+
return Channel.writeNow(Conc.from(this.builder));
|
2265
|
+
} else {
|
2266
|
+
return Channel.unit;
|
2267
|
+
}
|
2268
|
+
}
|
2269
|
+
|
2270
|
+
get isEmpty(): boolean {
|
2271
|
+
return this.pos === 0;
|
2272
|
+
}
|
2273
|
+
/* eslint-enable */
|
2274
|
+
}
|
2275
|
+
|
2276
|
+
function rechunkProcess<E, In>(
|
2277
|
+
rechunker: Rechunker<In>,
|
2278
|
+
target: number,
|
2279
|
+
): Channel<unknown, E, Conc<In>, unknown, E, Conc<In>, unknown> {
|
2280
|
+
return Channel.readWithCause(
|
2281
|
+
(chunk: Conc<In>) => {
|
2282
|
+
if (chunk.length === target && rechunker.isEmpty) {
|
2283
|
+
return Channel.writeNow(chunk).apSecond(rechunkProcess<E, In>(rechunker, target));
|
2284
|
+
} else if (chunk.length > 0) {
|
2285
|
+
const chunks: Array<Conc<In>> = [];
|
2286
|
+
let result: Conc<In> | null = null;
|
2287
|
+
let i = 0;
|
2288
|
+
while (i < chunk.length) {
|
2289
|
+
while (i < chunk.length && result === null) {
|
2290
|
+
result = rechunker.write(chunk.unsafeGet(i));
|
2291
|
+
i += 1;
|
2292
|
+
}
|
2293
|
+
if (result !== null) {
|
2294
|
+
chunks.push(result);
|
2295
|
+
result = null;
|
2296
|
+
}
|
2297
|
+
}
|
2298
|
+
|
2299
|
+
return Channel.writeAll(chunks).apSecond(rechunkProcess<E, In>(rechunker, target));
|
2300
|
+
} else {
|
2301
|
+
return rechunkProcess<E, In>(rechunker, target);
|
2302
|
+
}
|
2303
|
+
},
|
2304
|
+
(cause) => rechunker.emitOfNotEmpty().apSecond(Channel.failCauseNow(cause)),
|
2305
|
+
() => rechunker.emitOfNotEmpty(),
|
2306
|
+
);
|
2307
|
+
}
|
2308
|
+
|
2309
|
+
/**
|
2310
|
+
* Re-chunks the elements of the stream into chunks of
|
2311
|
+
* `n` elements each.
|
2312
|
+
* The last chunk might contain less than `n` elements
|
2313
|
+
*
|
2314
|
+
* @tsplus fluent fncts.io.Stream rechunk
|
2315
|
+
*/
|
2316
|
+
export function rechunk_<R, E, A>(stream: Stream<R, E, A>, n: number): Stream<R, E, A> {
|
2317
|
+
return new Stream(stream.channel.pipeTo(rechunkProcess(new Rechunker(n), n)));
|
2318
|
+
}
|
2319
|
+
|
2320
|
+
/**
|
2321
|
+
* Repeats the provided value infinitely.
|
2322
|
+
*
|
2323
|
+
* @tsplus static fncts.io.StreamOps repeatValue
|
2324
|
+
*/
|
2325
|
+
export function repeatValue<A>(a: A): Stream<unknown, never, A> {
|
2326
|
+
return new Stream(Channel.writeNow(Conc.single(a)).repeated);
|
2327
|
+
}
|
2328
|
+
|
2329
|
+
/**
|
2330
|
+
* Creates a stream from an effect producing a value of type `A` which repeats forever.
|
2331
|
+
*
|
2332
|
+
* @tsplus static fncts.io.StreamOps repeatIO
|
2333
|
+
*/
|
2334
|
+
export function repeatIO<R, E, A>(fa: IO<R, E, A>): Stream<R, E, A> {
|
2335
|
+
return Stream.repeatIOMaybe(fa.mapError(Maybe.just));
|
2336
|
+
}
|
2337
|
+
|
2338
|
+
/**
|
2339
|
+
* Creates a stream from an effect producing values of type `A` until it fails with None.
|
2340
|
+
*
|
2341
|
+
* @tsplus static fncts.io.StreamOps repeatIOMaybe
|
2342
|
+
*/
|
2343
|
+
export function repeatIOMaybe<R, E, A>(fa: IO<R, Maybe<E>, A>): Stream<R, E, A> {
|
2344
|
+
return repeatIOChunkMaybe(fa.map(Conc.single));
|
2345
|
+
}
|
2346
|
+
|
2347
|
+
/**
|
2348
|
+
* Creates a stream from an effect producing chunks of `A` values which repeats forever.
|
2349
|
+
*
|
2350
|
+
* @tsplus static fncts.io.StreamOps repeatIOChunk
|
2351
|
+
*/
|
2352
|
+
export function repeatIOChunk<R, E, A>(fa: IO<R, E, Conc<A>>): Stream<R, E, A> {
|
2353
|
+
return repeatIOChunkMaybe(fa.mapError(Maybe.just));
|
2354
|
+
}
|
2355
|
+
|
2356
|
+
/**
|
2357
|
+
* Creates a stream from an effect producing chunks of `A` values until it fails with None.
|
2358
|
+
*
|
2359
|
+
* @tsplus static fncts.io.StreamOps repeatIOChunkMaybe
|
2360
|
+
*/
|
2361
|
+
export function repeatIOChunkMaybe<R, E, A>(fa: IO<R, Maybe<E>, Conc<A>>): Stream<R, E, A> {
|
2362
|
+
return Stream.unfoldChunkIO(undefined, (_) =>
|
2363
|
+
fa
|
2364
|
+
.map((chunk) => Maybe.just(tuple(chunk, undefined)))
|
2365
|
+
.catchAll((maybeError) => maybeError.match(() => IO.succeedNow(Nothing()), IO.failNow)),
|
2366
|
+
);
|
2367
|
+
}
|
2368
|
+
|
2369
|
+
/**
|
2370
|
+
* Runs the sink on the stream to produce either the sink's result or an error.
|
2371
|
+
*
|
2372
|
+
* @tsplus fluent fncts.io.Stream run
|
2373
|
+
*/
|
2374
|
+
export function run_<R, E, A, R2, E2, Z>(
|
2375
|
+
stream: Stream<R, E, A>,
|
2376
|
+
sink: Sink<R2, E2, A, unknown, Z>,
|
2377
|
+
): IO<R & R2, E | E2, Z> {
|
2378
|
+
return stream.channel.pipeToOrFail(sink.channel).runDrain;
|
2379
|
+
}
|
2380
|
+
|
2381
|
+
/**
|
2382
|
+
* Runs the stream and collects all of its elements to a chunk.
|
2383
|
+
*
|
2384
|
+
* @tsplus getter fncts.io.Stream runCollect
|
2385
|
+
*/
|
2386
|
+
export function runCollect<R, E, A>(stream: Stream<R, E, A>): IO<R, E, Conc<A>> {
|
2387
|
+
return stream.run(Sink.collectAll());
|
2388
|
+
}
|
2389
|
+
|
2390
|
+
/**
|
2391
|
+
* Runs the stream and collects ignore its elements.
|
2392
|
+
*
|
2393
|
+
* @tsplus getter fncts.io.Stream runDrain
|
2394
|
+
*/
|
2395
|
+
export function runDrain<R, E, A>(stream: Stream<R, E, A>): IO<R, E, void> {
|
2396
|
+
return stream.run(Sink.drain);
|
2397
|
+
}
|
2398
|
+
|
2399
|
+
/**
|
2400
|
+
* @tsplus fluent fncts.io.Stream runForeachScoped
|
2401
|
+
*/
|
2402
|
+
export function runForeachScoped_<R, E, A, R2, E2>(
|
2403
|
+
self: Stream<R, E, A>,
|
2404
|
+
f: (a: A) => IO<R2, E2, any>,
|
2405
|
+
): IO<R & R2 & Has<Scope>, E | E2, void> {
|
2406
|
+
return self.runScoped(Sink.foreach(f));
|
2407
|
+
}
|
2408
|
+
|
2409
|
+
/**
|
2410
|
+
* Like `into`, but provides the result as a `Managed` to allow for scope
|
2411
|
+
* composition.
|
2412
|
+
*
|
2413
|
+
* @tsplus fluent fncts.io.Stream runIntoElementsScoped
|
2414
|
+
*/
|
2415
|
+
export function runIntoElementsScoped_<R, E, A, R1, E1>(
|
2416
|
+
stream: Stream<R, E, A>,
|
2417
|
+
queue: PQueue<R1, unknown, never, never, Exit<Maybe<E | E1>, A>, unknown>,
|
2418
|
+
): IO<R & R1 & Has<Scope>, E | E1, void> {
|
2419
|
+
const writer: Channel<R & R1, E, Conc<A>, unknown, never, Exit<Maybe<E | E1>, A>, unknown> = Channel.readWith(
|
2420
|
+
(inp: Conc<A>) =>
|
2421
|
+
inp
|
2422
|
+
.foldLeft(
|
2423
|
+
Channel.unit as Channel<R1, unknown, unknown, unknown, never, Exit<Maybe<E | E1>, A>, unknown>,
|
2424
|
+
(channel, a) => channel.apSecond(Channel.writeNow(Exit.succeed(a))),
|
2425
|
+
)
|
2426
|
+
.apSecond(writer),
|
2427
|
+
(err) => Channel.writeNow(Exit.fail(Just(err))),
|
2428
|
+
() => Channel.writeNow(Exit.fail(Nothing())),
|
2429
|
+
);
|
2430
|
+
return stream.channel.pipeTo(writer).mapOutIO((exit) => queue.offer(exit)).drain.runScoped.asUnit;
|
2431
|
+
}
|
2432
|
+
|
2433
|
+
/**
|
2434
|
+
* Like `Stream#into`, but provides the result as a `Managed` to allow for scope
|
2435
|
+
* composition.
|
2436
|
+
*
|
2437
|
+
* @tsplus fluent fncts.io.Stream runIntoQueueScoped
|
2438
|
+
*/
|
2439
|
+
export function runIntoQueueScoped_<R, R1, E extends E1, E1, A>(
|
2440
|
+
stream: Stream<R, E, A>,
|
2441
|
+
queue: PQueue<R1, never, never, unknown, Take<E1, A>, any>,
|
2442
|
+
): IO<R & R1 & Has<Scope>, E | E1, void> {
|
2443
|
+
const writer: Channel<R, E, Conc<A>, unknown, E, Take<E | E1, A>, any> = Channel.readWithCause(
|
2444
|
+
(inp) => Channel.writeNow(Take.chunk(inp)).apSecond(writer),
|
2445
|
+
(cause) => Channel.writeNow(Take.failCause(cause)),
|
2446
|
+
(_) => Channel.writeNow(Take.end),
|
2447
|
+
);
|
2448
|
+
|
2449
|
+
return stream.channel.pipeTo(writer).mapOutIO((take) => queue.offer(take)).drain.runScoped.asUnit;
|
2450
|
+
}
|
2451
|
+
|
2452
|
+
/**
|
2453
|
+
* Like `Stream#runIntoHub`, but provides the result as a `Managed` to allow for scope
|
2454
|
+
* composition.
|
2455
|
+
*
|
2456
|
+
* @tsplus fluent fncts.io.Stream runIntoHubScoped
|
2457
|
+
*/
|
2458
|
+
export function runIntoHubScoped_<R, R1, E extends E1, E1, A>(
|
2459
|
+
stream: Stream<R, E, A>,
|
2460
|
+
hub: PHub<R1, never, never, unknown, Take<E1, A>, any>,
|
2461
|
+
): IO<R & R1 & Has<Scope>, E | E1, void> {
|
2462
|
+
return stream.runIntoQueueScoped(hub.toQueue);
|
2463
|
+
}
|
2464
|
+
|
2465
|
+
/**
|
2466
|
+
* Runs the sink on the stream to produce either the sink's result or an error.
|
2467
|
+
*
|
2468
|
+
* @tsplus fluent fncts.io.Stream runScoped
|
2469
|
+
*/
|
2470
|
+
export function runScoped_<R, E, A, R2, E2, Z>(
|
2471
|
+
stream: Stream<R, E, A>,
|
2472
|
+
sink: Sink<R2, E2, A, unknown, Z>,
|
2473
|
+
): IO<R & R2 & Has<Scope>, E | E2, Z> {
|
2474
|
+
return stream.channel.pipeToOrFail(sink.channel).drain.runScoped;
|
2475
|
+
}
|
2476
|
+
|
2477
|
+
/**
|
2478
|
+
* Statefully maps over the elements of this stream to produce all intermediate results
|
2479
|
+
* of type `B` given an initial B.
|
2480
|
+
*
|
2481
|
+
* @tsplus fluent fncts.io.Stream scan
|
2482
|
+
*/
|
2483
|
+
export function scan_<R, E, A, B>(sa: Stream<R, E, A>, b: B, f: (b: B, a: A) => B): Stream<R, E, B> {
|
2484
|
+
return sa.scanIO(b, (b, a) => IO.succeedNow(f(b, a)));
|
2485
|
+
}
|
2486
|
+
|
2487
|
+
/**
|
2488
|
+
* Statefully and effectfully maps over the elements of this stream to produce all
|
2489
|
+
* intermediate results of type `B` given an initial B.
|
2490
|
+
*
|
2491
|
+
* @tsplus fluent fncts.io.Stream scanIO
|
2492
|
+
*/
|
2493
|
+
export function scanIO_<R, E, A, R1, E1, B>(
|
2494
|
+
sa: Stream<R, E, A>,
|
2495
|
+
b: B,
|
2496
|
+
f: (b: B, a: A) => IO<R1, E1, B>,
|
2497
|
+
): Stream<R & R1, E | E1, B> {
|
2498
|
+
return Stream.succeedNow(b).concat(sa.mapAccumIO(b, (b, a) => f(b, a).map((b) => [b, b])));
|
2499
|
+
}
|
2500
|
+
|
2501
|
+
/**
|
2502
|
+
* Statefully maps over the elements of this stream to produce all
|
2503
|
+
* intermediate results.
|
2504
|
+
*
|
2505
|
+
* @tsplus fluent fncts.io.Stream scanReduce
|
2506
|
+
*/
|
2507
|
+
export function scanReduce_<R, E, A extends B, B>(fa: Stream<R, E, A>, f: (b: B, a: A) => B): Stream<R, E, B> {
|
2508
|
+
return fa.scanReduceIO((b, a) => IO.succeedNow(f(b, a)));
|
2509
|
+
}
|
2510
|
+
|
2511
|
+
/**
|
2512
|
+
* Statefully and effectfully maps over the elements of this stream to produce
|
2513
|
+
* all intermediate results.
|
2514
|
+
*
|
2515
|
+
* @tsplus fluent fncts.io.Stream scanReduceIO
|
2516
|
+
*/
|
2517
|
+
export function scanReduceIO_<R, E, A extends B, R1, E1, B>(
|
2518
|
+
fa: Stream<R, E, A>,
|
2519
|
+
f: (b: B, a: A) => IO<R1, E1, B>,
|
2520
|
+
): Stream<R & R1, E | E1, B> {
|
2521
|
+
return fa.mapAccumIO(Nothing<B>(), (s, a) =>
|
2522
|
+
s.match(
|
2523
|
+
() => IO.succeedNow([a, Just(a)]),
|
2524
|
+
(b) => f(b, a).map((b) => [b, Just(b)]),
|
2525
|
+
),
|
2526
|
+
);
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
/**
|
2530
|
+
* Creates a single-valued pure stream
|
2531
|
+
*
|
2532
|
+
* @tsplus static fncts.io.StreamOps succeedNow
|
2533
|
+
*/
|
2534
|
+
export function succeedNow<O>(o: O): Stream<unknown, never, O> {
|
2535
|
+
return fromChunkNow(Conc.single(o));
|
2536
|
+
}
|
2537
|
+
|
2538
|
+
/**
|
2539
|
+
* Creates a single-valued pure stream
|
2540
|
+
*
|
2541
|
+
* @tsplus static fncts.io.StreamOps succeed
|
2542
|
+
*/
|
2543
|
+
export function succeed<A>(a: Lazy<A>): Stream<unknown, never, A> {
|
2544
|
+
return fromChunk(Conc.single(a()));
|
2545
|
+
}
|
2546
|
+
|
2547
|
+
function takeLoop<E, A>(n: number): Channel<unknown, E, Conc<A>, unknown, E, Conc<A>, unknown> {
|
2548
|
+
return Channel.readWithCause(
|
2549
|
+
(inp) => {
|
2550
|
+
const taken = inp.take(n);
|
2551
|
+
const left = Math.max(n - taken.length, 0);
|
2552
|
+
if (left > 0) {
|
2553
|
+
return Channel.writeNow(taken).apSecond(takeLoop(left));
|
2554
|
+
} else {
|
2555
|
+
return Channel.writeNow(taken);
|
2556
|
+
}
|
2557
|
+
},
|
2558
|
+
Channel.failCauseNow,
|
2559
|
+
Channel.endNow,
|
2560
|
+
);
|
2561
|
+
}
|
2562
|
+
|
2563
|
+
/**
|
2564
|
+
* Takes the specified number of elements from this stream.
|
2565
|
+
*
|
2566
|
+
* @tsplus fluent fncts.io.Stream take
|
2567
|
+
*/
|
2568
|
+
export function take_<R, E, A>(stream: Stream<R, E, A>, n: number): Stream<R, E, A> {
|
2569
|
+
if (n <= 0) {
|
2570
|
+
return empty;
|
2571
|
+
}
|
2572
|
+
if (!Number.isInteger(n)) {
|
2573
|
+
return halt(new IllegalArgumentError(`${n} should be an integer`, "Stream.take"));
|
2574
|
+
}
|
2575
|
+
return new Stream(stream.channel.pipeTo(takeLoop(n)));
|
2576
|
+
}
|
2577
|
+
|
2578
|
+
/**
|
2579
|
+
* @tsplus fluent fncts.io.Stream takeUntilIO
|
2580
|
+
*/
|
2581
|
+
export function takeUntilIO_<R, E, A, R1, E1>(
|
2582
|
+
ma: Stream<R, E, A>,
|
2583
|
+
f: (a: A) => IO<R1, E1, boolean>,
|
2584
|
+
): Stream<R & R1, E | E1, A> {
|
2585
|
+
return ma.loopOnPartialChunks((chunk, emit) =>
|
2586
|
+
chunk
|
2587
|
+
.takeWhileIO((v) => emit(v).apSecond(f(v).map((b) => !b)))
|
2588
|
+
.map((taken) => taken.drop(taken.length).take(1).isEmpty),
|
2589
|
+
);
|
2590
|
+
}
|
2591
|
+
|
2592
|
+
function takeUntilLoop<R, E, A>(p: Predicate<A>): Channel<R, E, Conc<A>, unknown, E, Conc<A>, unknown> {
|
2593
|
+
return Channel.readWith(
|
2594
|
+
(chunk: Conc<A>) => {
|
2595
|
+
const taken = chunk.takeWhile(p.invert);
|
2596
|
+
const last = chunk.drop(taken.length).take(1);
|
2597
|
+
if (last.isEmpty) {
|
2598
|
+
return Channel.writeNow(taken).apSecond(takeUntilLoop<R, E, A>(p));
|
2599
|
+
} else {
|
2600
|
+
return Channel.writeNow(taken.concat(last));
|
2601
|
+
}
|
2602
|
+
},
|
2603
|
+
Channel.failNow,
|
2604
|
+
Channel.succeedNow,
|
2605
|
+
);
|
2606
|
+
}
|
2607
|
+
|
2608
|
+
/**
|
2609
|
+
* Takes all elements of the stream until the specified predicate evaluates
|
2610
|
+
* to `true`.
|
2611
|
+
*
|
2612
|
+
* @tsplus fluent fncts.io.Stream takeUntil
|
2613
|
+
*/
|
2614
|
+
export function takeUntil_<R, E, A>(fa: Stream<R, E, A>, p: Predicate<A>): Stream<R, E, A> {
|
2615
|
+
return new Stream(fa.channel.pipeTo(takeUntilLoop(p)));
|
2616
|
+
}
|
2617
|
+
|
2618
|
+
/**
|
2619
|
+
* @tsplus fluent fncts.io.Stream tap
|
2620
|
+
*/
|
2621
|
+
export function tap_<R, E, A, R1, E1>(ma: Stream<R, E, A>, f: (a: A) => IO<R1, E1, any>): Stream<R & R1, E | E1, A> {
|
2622
|
+
return ma.mapIO((a) => f(a).as(a));
|
2623
|
+
}
|
2624
|
+
|
2625
|
+
/**
|
2626
|
+
* Throttles the chunks of this stream according to the given bandwidth parameters using the token bucket
|
2627
|
+
* algorithm. Allows for burst in the processing of elements by allowing the token bucket to accumulate
|
2628
|
+
* tokens up to a `units + burst` threshold. Chunks that do not meet the bandwidth constraints are dropped.
|
2629
|
+
* The weight of each chunk is determined by the `costFn` function.
|
2630
|
+
*
|
2631
|
+
* @tsplus fluent fncts.io.Stream throttleEnforce
|
2632
|
+
*/
|
2633
|
+
export function throttleEnforce_<R, E, A>(
|
2634
|
+
sa: Stream<R, E, A>,
|
2635
|
+
costFn: (chunk: Conc<A>) => number,
|
2636
|
+
units: number,
|
2637
|
+
duration: number,
|
2638
|
+
burst = 0,
|
2639
|
+
): Stream<R, E, A> {
|
2640
|
+
return sa.throttleEnforceIO((chunk) => IO.succeedNow(costFn(chunk)), units, duration, burst);
|
2641
|
+
}
|
2642
|
+
|
2643
|
+
function throttleEnforceIOLoop<E, A, R1, E1>(
|
2644
|
+
costFn: (chunk: Conc<A>) => IO<R1, E1, number>,
|
2645
|
+
units: number,
|
2646
|
+
duration: number,
|
2647
|
+
burst: number,
|
2648
|
+
tokens: number,
|
2649
|
+
timestamp: number,
|
2650
|
+
): Channel<R1, E | E1, Conc<A>, unknown, E | E1, Conc<A>, void> {
|
2651
|
+
return Channel.readWith(
|
2652
|
+
(inp: Conc<A>) =>
|
2653
|
+
Channel.unwrap(
|
2654
|
+
costFn(inp).zipWith(Clock.currentTime, (weight, current) => {
|
2655
|
+
const elapsed = current - timestamp;
|
2656
|
+
const cycles = elapsed / duration;
|
2657
|
+
const available = (() => {
|
2658
|
+
const sum = tokens + cycles * units;
|
2659
|
+
const max = units + burst < 0 ? Number.MAX_SAFE_INTEGER : units + burst;
|
2660
|
+
|
2661
|
+
return sum < 0 ? max : Math.min(sum, max);
|
2662
|
+
})();
|
2663
|
+
|
2664
|
+
return weight <= available
|
2665
|
+
? Channel.writeNow(inp).apSecond(
|
2666
|
+
throttleEnforceIOLoop(costFn, units, duration, burst, available - weight, current),
|
2667
|
+
)
|
2668
|
+
: throttleEnforceIOLoop(costFn, units, duration, burst, available - weight, current);
|
2669
|
+
}),
|
2670
|
+
),
|
2671
|
+
Channel.failNow,
|
2672
|
+
() => Channel.unit,
|
2673
|
+
);
|
2674
|
+
}
|
2675
|
+
|
2676
|
+
/**
|
2677
|
+
* Throttles the chunks of this stream according to the given bandwidth parameters using the token bucket
|
2678
|
+
* algorithm. Allows for burst in the processing of elements by allowing the token bucket to accumulate
|
2679
|
+
* tokens up to a `units + burst` threshold. Chunks that do not meet the bandwidth constraints are dropped.
|
2680
|
+
* The weight of each chunk is determined by the `costFn` effectful function.
|
2681
|
+
*
|
2682
|
+
* @tsplus fluent fncts.io.Stream throttleEnforceIO
|
2683
|
+
*/
|
2684
|
+
export function throttleEnforceIO_<R, E, A, R1, E1>(
|
2685
|
+
sa: Stream<R, E, A>,
|
2686
|
+
costFn: (chunk: Conc<A>) => IO<R1, E1, number>,
|
2687
|
+
units: number,
|
2688
|
+
duration: number,
|
2689
|
+
burst = 0,
|
2690
|
+
): Stream<R & R1, E | E1, A> {
|
2691
|
+
return new Stream(
|
2692
|
+
Channel.fromIO(Clock.currentTime).flatMap((current) =>
|
2693
|
+
sa.channel.pipeTo(throttleEnforceIOLoop(costFn, units, duration, burst, units, current)),
|
2694
|
+
),
|
2695
|
+
);
|
2696
|
+
}
|
2697
|
+
|
2698
|
+
/**
|
2699
|
+
* Converts the stream to a managed hub of chunks. After the managed hub is used,
|
2700
|
+
* the hub will never again produce values and should be discarded.
|
2701
|
+
*
|
2702
|
+
* @tsplus fluent fncts.io.Stream toHub
|
2703
|
+
*/
|
2704
|
+
export function toHub_<R, E, A>(stream: Stream<R, E, A>, capacity: number): IO<R & Has<Scope>, never, Hub<Take<E, A>>> {
|
2705
|
+
return Do((Δ) => {
|
2706
|
+
const hub = Δ(IO.acquireRelease(Hub.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
|
2707
|
+
Δ(stream.runIntoHubScoped(hub).fork);
|
2708
|
+
return hub;
|
2709
|
+
});
|
2710
|
+
}
|
2711
|
+
|
2712
|
+
/**
|
2713
|
+
* Interpret the stream as a managed pull
|
2714
|
+
*
|
2715
|
+
* @tsplus getter fncts.io.Stream toPull
|
2716
|
+
*/
|
2717
|
+
export function toPull<R, E, A>(stream: Stream<R, E, A>): IO<R & Has<Scope>, never, IO<R, Maybe<E>, Conc<A>>> {
|
2718
|
+
return stream.channel.toPull.map((io) =>
|
2719
|
+
io.mapError(Maybe.just).flatMap((r) => r.match(() => IO.failNow(Nothing()), IO.succeedNow)),
|
2720
|
+
);
|
2721
|
+
}
|
2722
|
+
|
2723
|
+
/**
|
2724
|
+
* Converts the stream to a managed queue of chunks. After the managed queue is used,
|
2725
|
+
* the queue will never again produce values and should be discarded.
|
2726
|
+
*
|
2727
|
+
* @tsplus fluent fncts.io.Stream toQueue
|
2728
|
+
*/
|
2729
|
+
export function toQueue_<R, E, A>(stream: Stream<R, E, A>, capacity = 2): IO<R & Has<Scope>, never, Queue<Take<E, A>>> {
|
2730
|
+
return Do((Δ) => {
|
2731
|
+
const queue = Δ(IO.acquireRelease(Queue.makeBounded<Take<E, A>>(capacity), (_) => _.shutdown));
|
2732
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
2733
|
+
return queue;
|
2734
|
+
});
|
2735
|
+
}
|
2736
|
+
|
2737
|
+
/**
|
2738
|
+
* @tsplus fluent fncts.io.Stream toQueueDropping
|
2739
|
+
*/
|
2740
|
+
export function toQueueDropping_<R, E, A>(
|
2741
|
+
stream: Stream<R, E, A>,
|
2742
|
+
capacity = 2,
|
2743
|
+
): IO<R & Has<Scope>, never, Queue.Dequeue<Take<E, A>>> {
|
2744
|
+
return Do((Δ) => {
|
2745
|
+
const queue = Δ(IO.acquireRelease(Queue.makeDropping<Take<E, A>>(capacity), (_) => _.shutdown));
|
2746
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
2747
|
+
return queue;
|
2748
|
+
});
|
2749
|
+
}
|
2750
|
+
|
2751
|
+
/**
|
2752
|
+
* @tsplus fluent fncts.io.Stream toQueueOfElements
|
2753
|
+
*/
|
2754
|
+
export function toQueueOfElements_<R, E, A>(
|
2755
|
+
stream: Stream<R, E, A>,
|
2756
|
+
capacity = 2,
|
2757
|
+
): IO<R & Has<Scope>, never, Queue.Dequeue<Exit<Maybe<E>, A>>> {
|
2758
|
+
return Do((Δ) => {
|
2759
|
+
const queue = Δ(IO.acquireRelease(Queue.makeBounded<Exit<Maybe<E>, A>>(capacity), (_) => _.shutdown));
|
2760
|
+
Δ(stream.runIntoElementsScoped(queue).fork);
|
2761
|
+
return queue;
|
2762
|
+
});
|
2763
|
+
}
|
2764
|
+
|
2765
|
+
/**
|
2766
|
+
* @tsplus fluent fncts.io.Stream toQueueSliding
|
2767
|
+
*/
|
2768
|
+
export function toQueueSliding_<R, E, A>(
|
2769
|
+
stream: Stream<R, E, A>,
|
2770
|
+
capacity = 2,
|
2771
|
+
): IO<R & Has<Scope>, never, Queue.Dequeue<Take<E, A>>> {
|
2772
|
+
return Do((Δ) => {
|
2773
|
+
const queue = Δ(IO.acquireRelease(Queue.makeSliding<Take<E, A>>(capacity), (_) => _.shutdown));
|
2774
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
2775
|
+
return queue;
|
2776
|
+
});
|
2777
|
+
}
|
2778
|
+
|
2779
|
+
/**
|
2780
|
+
* Converts the stream into an unbounded managed queue. After the managed queue
|
2781
|
+
* is used, the queue will never again produce values and should be discarded.
|
2782
|
+
*
|
2783
|
+
* @tsplus getter fncts.io.Stream toQueueUnbounded
|
2784
|
+
*/
|
2785
|
+
export function toQueueUnbounded<R, E, A>(stream: Stream<R, E, A>): IO<R & Has<Scope>, never, Queue<Take<E, A>>> {
|
2786
|
+
return Do((Δ) => {
|
2787
|
+
const queue = Δ(IO.acquireRelease(Queue.makeUnbounded<Take<E, A>>(), (_) => _.shutdown));
|
2788
|
+
Δ(stream.runIntoQueueScoped(queue).fork);
|
2789
|
+
return queue;
|
2790
|
+
});
|
2791
|
+
}
|
2792
|
+
|
2793
|
+
function unfoldChunkIOLoop<S, R, E, A>(
|
2794
|
+
s: S,
|
2795
|
+
f: (s: S) => IO<R, E, Maybe<readonly [Conc<A>, S]>>,
|
2796
|
+
): Channel<R, unknown, unknown, unknown, E, Conc<A>, unknown> {
|
2797
|
+
return Channel.unwrap(
|
2798
|
+
f(s).map((m) =>
|
2799
|
+
m.match(
|
2800
|
+
() => Channel.unit,
|
2801
|
+
([as, s]) => Channel.writeNow(as).flatMap(() => unfoldChunkIOLoop(s, f)),
|
2802
|
+
),
|
2803
|
+
),
|
2804
|
+
);
|
2805
|
+
}
|
2806
|
+
|
2807
|
+
/**
|
2808
|
+
* Creates a stream by effectfully peeling off the "layers" of a value of type `S`
|
2809
|
+
*
|
2810
|
+
* @tsplus static fncts.io.StreamOps unfoldChunkIO
|
2811
|
+
*/
|
2812
|
+
export function unfoldChunkIO<R, E, A, S>(s: S, f: (s: S) => IO<R, E, Maybe<readonly [Conc<A>, S]>>): Stream<R, E, A> {
|
2813
|
+
return new Stream(unfoldChunkIOLoop(s, f));
|
2814
|
+
}
|
2815
|
+
|
2816
|
+
/**
|
2817
|
+
* Creates a stream by effectfully peeling off the "layers" of a value of type `S`
|
2818
|
+
*
|
2819
|
+
* @tsplus static fncts.io.StreamOps unfoldIO
|
2820
|
+
*/
|
2821
|
+
export function unfoldIO<S, R, E, A>(s: S, f: (s: S) => IO<R, E, Maybe<readonly [A, S]>>): Stream<R, E, A> {
|
2822
|
+
return unfoldChunkIO(s, (_) => f(_).map((m) => m.map(([a, s]) => tuple(Conc.single(a), s))));
|
2823
|
+
}
|
2824
|
+
|
2825
|
+
function unfoldChunkLoop<S, A>(
|
2826
|
+
s: S,
|
2827
|
+
f: (s: S) => Maybe<readonly [Conc<A>, S]>,
|
2828
|
+
): Channel<unknown, unknown, unknown, unknown, never, Conc<A>, unknown> {
|
2829
|
+
return f(s).match(
|
2830
|
+
() => Channel.unit,
|
2831
|
+
([as, s]) => Channel.writeNow(as).flatMap(() => unfoldChunkLoop(s, f)),
|
2832
|
+
);
|
2833
|
+
}
|
2834
|
+
|
2835
|
+
/**
|
2836
|
+
* @tsplus static fncts.io.StreamOps unfoldChunk
|
2837
|
+
*/
|
2838
|
+
export function unfoldChunk<S, A>(s: S, f: (s: S) => Maybe<readonly [Conc<A>, S]>): Stream<unknown, never, A> {
|
2839
|
+
return new Stream(Channel.defer(unfoldChunkLoop(s, f)));
|
2840
|
+
}
|
2841
|
+
|
2842
|
+
/**
|
2843
|
+
* @tsplus static fncts.io.StreamOps unfold
|
2844
|
+
*/
|
2845
|
+
export function unfold<S, A>(s: S, f: (s: S) => Maybe<readonly [A, S]>): Stream<unknown, never, A> {
|
2846
|
+
return Stream.unfoldChunk(s, (s) => f(s).map(([a, s]) => tuple(Conc.single(a), s)));
|
2847
|
+
}
|
2848
|
+
|
2849
|
+
/**
|
2850
|
+
* Creates a stream produced from an IO
|
2851
|
+
*
|
2852
|
+
* @tsplus static fncts.io.StreamOps unwrap
|
2853
|
+
*/
|
2854
|
+
export function unwrap<R, E, R1, E1, A>(stream: IO<R, E, Stream<R1, E1, A>>): Stream<R & R1, E | E1, A> {
|
2855
|
+
return Stream.fromIO(stream).flatten;
|
2856
|
+
}
|
2857
|
+
|
2858
|
+
/**
|
2859
|
+
* Creates a stream produced from a managed
|
2860
|
+
*
|
2861
|
+
* @tsplus static fncts.io.StreamOps unwrapScoped
|
2862
|
+
*/
|
2863
|
+
export function unwrapScoped<R0, E0, R, E, A>(
|
2864
|
+
stream: IO<R0 & Has<Scope>, E0, Stream<R, E, A>>,
|
2865
|
+
): Stream<R0 & R, E0 | E, A> {
|
2866
|
+
return Stream.scoped(stream).flatten;
|
2867
|
+
}
|
2868
|
+
|
2869
|
+
/**
|
2870
|
+
* Zips the two streams so that when a value is emitted by either of the two
|
2871
|
+
* streams, it is combined with the latest value from the other stream to
|
2872
|
+
* produce a result.
|
2873
|
+
*
|
2874
|
+
* Note: tracking the latest value is done on a per-chunk basis. That means
|
2875
|
+
* that emitted elements that are not the last value in chunks will never be
|
2876
|
+
* used for zipping.
|
2877
|
+
*
|
2878
|
+
* @tsplus fluent fncts.io.Stream zipWithLatest
|
2879
|
+
*/
|
2880
|
+
export function zipWithLatest_<R, E, A, R1, E1, B, C>(
|
2881
|
+
fa: Stream<R, E, A>,
|
2882
|
+
fb: Stream<R1, E1, B>,
|
2883
|
+
f: (a: A, b: B) => C,
|
2884
|
+
): Stream<R & R1, E | E1, C> {
|
2885
|
+
function pullNonEmpty<R, E, A>(pull: IO<R, Maybe<E>, Conc<A>>): IO<R, Maybe<E>, Conc<A>> {
|
2886
|
+
return pull.flatMap((chunk) => (chunk.isNonEmpty ? pullNonEmpty(pull) : IO.succeedNow(chunk)));
|
2887
|
+
}
|
2888
|
+
return Stream.fromPull(
|
2889
|
+
Do((Δ) => {
|
2890
|
+
const left = Δ(fa.toPull.map(pullNonEmpty));
|
2891
|
+
const right = Δ(fb.toPull.map(pullNonEmpty));
|
2892
|
+
return Δ(
|
2893
|
+
Stream.fromIOMaybe(
|
2894
|
+
left.raceWith(
|
2895
|
+
right,
|
2896
|
+
(leftDone, rightFiber) => IO.fromExitNow(leftDone).zipWith(rightFiber.join, (l, r) => tuple(l, r, true)),
|
2897
|
+
(rightDone, leftFiber) => IO.fromExitNow(rightDone).zipWith(leftFiber.join, (r, l) => tuple(l, r, false)),
|
2898
|
+
),
|
2899
|
+
).flatMap(([l, r, leftFirst]) =>
|
2900
|
+
Stream.fromIO(Ref.make(tuple(l.unsafeGet(l.length - 1), r.unsafeGet(r.length - 1)))).flatMap((latest) =>
|
2901
|
+
Stream.fromChunk(
|
2902
|
+
leftFirst ? r.map((b) => f(l.unsafeGet(l.length - 1), b)) : l.map((a) => f(a, r.unsafeGet(r.length - 1))),
|
2903
|
+
).concat(
|
2904
|
+
Stream.repeatIOMaybe(left)
|
2905
|
+
.mergeEither(Stream.repeatIOMaybe(right))
|
2906
|
+
.mapIO((ab) =>
|
2907
|
+
ab.match(
|
2908
|
+
(leftChunk) =>
|
2909
|
+
latest.modify(([_, rightLatest]) =>
|
2910
|
+
tuple(
|
2911
|
+
leftChunk.map((a) => f(a, rightLatest)),
|
2912
|
+
tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
|
2913
|
+
),
|
2914
|
+
),
|
2915
|
+
(rightChunk) =>
|
2916
|
+
latest.modify(([leftLatest, _]) =>
|
2917
|
+
tuple(
|
2918
|
+
rightChunk.map((b) => f(leftLatest, b)),
|
2919
|
+
tuple(leftLatest, rightChunk.unsafeGet(rightChunk.length - 1)),
|
2920
|
+
),
|
2921
|
+
),
|
2922
|
+
),
|
2923
|
+
)
|
2924
|
+
.flatMap(Stream.fromChunkNow),
|
2925
|
+
),
|
2926
|
+
),
|
2927
|
+
).toPull,
|
2928
|
+
);
|
2929
|
+
}),
|
2930
|
+
);
|
2931
|
+
}
|