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