@fncts/io 0.0.48 → 0.0.49
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 +1 -1
- package/Channel/api.d.ts +80 -80
- package/Channel/core-api.d.ts +26 -26
- package/Console/definition.d.ts +1 -0
- package/CountdownLatch.d.ts +1 -0
- package/Fiber/FiberMessage.d.ts +6 -28
- package/Fiber/FiberRuntime.d.ts +108 -77
- package/Fiber/api/interruptAs.d.ts +2 -2
- package/Fiber/definition.d.ts +2 -0
- package/FiberScope/definition.d.ts +3 -0
- package/FiberSet.d.ts +2 -1
- package/Future/State.d.ts +59 -0
- package/Future/api.d.ts +8 -3
- package/Future/constructors.d.ts +1 -1
- package/Future/definition.d.ts +1 -17
- package/Future.d.ts +1 -0
- package/Hub/api.d.ts +15 -15
- package/IO/api/array.d.ts +22 -0
- package/IO/api/awaitAllChildren.d.ts +6 -0
- package/IO/api/cachedInvalidate.d.ts +15 -0
- package/IO/api/forkDaemon.d.ts +1 -1
- package/IO/api/onTermination.d.ts +1 -2
- package/IO/api/transplant.d.ts +11 -1
- package/IO/api.d.ts +247 -225
- package/IO/definition.d.ts +12 -25
- package/IO.d.ts +3 -1
- package/Random/definition.d.ts +1 -0
- package/Ref/Synchronized/api.d.ts +1 -1
- package/Semaphore/Reservation.d.ts +15 -0
- package/Semaphore/constructors.d.ts +13 -0
- package/Semaphore/definition.d.ts +29 -0
- package/Semaphore.d.ts +3 -40
- package/Stream/api.d.ts +164 -164
- package/_cjs/Cached/api.cjs +1 -2
- package/_cjs/Cached/api.cjs.map +1 -1
- package/_cjs/Cached/internal.cjs +1 -2
- package/_cjs/Cached/internal.cjs.map +1 -1
- package/_cjs/Channel/api/interruptWhen.cjs +1 -2
- package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +2 -3
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAll.cjs +1 -2
- package/_cjs/Channel/api/mergeAll.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +1 -2
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +2 -3
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeMap.cjs +1 -2
- package/_cjs/Channel/api/mergeMap.cjs.map +1 -1
- package/_cjs/Channel/api/mergeWith.cjs +1 -2
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
- package/_cjs/Channel/api/run.cjs +1 -2
- package/_cjs/Channel/api/run.cjs.map +1 -1
- package/_cjs/Channel/api/runCollect.cjs +1 -2
- package/_cjs/Channel/api/runCollect.cjs.map +1 -1
- package/_cjs/Channel/api/runDrain.cjs +1 -2
- package/_cjs/Channel/api/runDrain.cjs.map +1 -1
- package/_cjs/Channel/api/runScoped.cjs +3 -4
- package/_cjs/Channel/api/runScoped.cjs.map +1 -1
- package/_cjs/Channel/api/toPull.cjs +2 -3
- package/_cjs/Channel/api/toPull.cjs.map +1 -1
- package/_cjs/Channel/api/zipConcurrent.cjs +1 -2
- package/_cjs/Channel/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +206 -207
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/core-api.cjs +43 -42
- package/_cjs/Channel/core-api.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelExecutor.cjs +4 -5
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelState.cjs +1 -2
- package/_cjs/Channel/internal/ChannelState.cjs.map +1 -1
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +1 -2
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
- package/_cjs/Clock/api.cjs +1 -2
- package/_cjs/Clock/api.cjs.map +1 -1
- package/_cjs/Clock/definition.cjs +1 -2
- package/_cjs/Clock/definition.cjs.map +1 -1
- package/_cjs/Clock/live.cjs +1 -2
- package/_cjs/Clock/live.cjs.map +1 -1
- package/_cjs/Console/api.cjs +1 -2
- package/_cjs/Console/api.cjs.map +1 -1
- package/_cjs/Console/definition.cjs +2 -2
- package/_cjs/Console/definition.cjs.map +1 -1
- package/_cjs/Console/live.cjs +1 -2
- package/_cjs/Console/live.cjs.map +1 -1
- package/_cjs/CountdownLatch.cjs +3 -3
- package/_cjs/CountdownLatch.cjs.map +1 -1
- package/_cjs/Differ/api.cjs +1 -2
- package/_cjs/Differ/api.cjs.map +1 -1
- package/_cjs/Fiber/FiberMessage.cjs +3 -24
- package/_cjs/Fiber/FiberMessage.cjs.map +1 -1
- package/_cjs/Fiber/FiberRuntime.cjs +879 -636
- package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
- package/_cjs/Fiber/api/awaitAll.cjs +1 -2
- package/_cjs/Fiber/api/awaitAll.cjs.map +1 -1
- package/_cjs/Fiber/api/collectAll.cjs +2 -3
- package/_cjs/Fiber/api/collectAll.cjs.map +1 -1
- package/_cjs/Fiber/api/fromIO.cjs +1 -2
- package/_cjs/Fiber/api/fromIO.cjs.map +1 -1
- package/_cjs/Fiber/api/interrupt.cjs +2 -3
- package/_cjs/Fiber/api/interrupt.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptAll.cjs +2 -3
- package/_cjs/Fiber/api/interruptAll.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptAs.cjs +5 -10
- package/_cjs/Fiber/api/interruptAs.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptFork.cjs +2 -3
- package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
- package/_cjs/Fiber/api/join.cjs +1 -2
- package/_cjs/Fiber/api/join.cjs.map +1 -1
- package/_cjs/Fiber/api/joinAll.cjs +1 -2
- package/_cjs/Fiber/api/joinAll.cjs.map +1 -1
- package/_cjs/Fiber/api/mapFiber.cjs +1 -2
- package/_cjs/Fiber/api/mapFiber.cjs.map +1 -1
- package/_cjs/Fiber/api/mapIO.cjs +2 -3
- package/_cjs/Fiber/api/mapIO.cjs.map +1 -1
- package/_cjs/Fiber/api/zipWith.cjs +2 -3
- package/_cjs/Fiber/api/zipWith.cjs.map +1 -1
- package/_cjs/Fiber/constructors.cjs +2 -3
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/Fiber/definition.cjs +6 -4
- package/_cjs/Fiber/definition.cjs.map +1 -1
- package/_cjs/FiberRef/api/locallyScoped.cjs +1 -2
- package/_cjs/FiberRef/api/locallyScoped.cjs.map +1 -1
- package/_cjs/FiberRef/api/locallyScopedWith.cjs +1 -2
- package/_cjs/FiberRef/api/locallyScopedWith.cjs.map +1 -1
- package/_cjs/FiberRef/constructors.cjs +1 -2
- package/_cjs/FiberRef/constructors.cjs.map +1 -1
- package/_cjs/FiberRef/definition.cjs +1 -2
- package/_cjs/FiberRef/definition.cjs.map +1 -1
- package/_cjs/FiberRef/operations.cjs +1 -2
- package/_cjs/FiberRef/operations.cjs.map +1 -1
- package/_cjs/FiberRef/unsafe.cjs +1 -2
- package/_cjs/FiberRef/unsafe.cjs.map +1 -1
- package/_cjs/FiberRefs/Patch.cjs +1 -2
- package/_cjs/FiberRefs/Patch.cjs.map +1 -1
- package/_cjs/FiberRefs/api.cjs +1 -2
- package/_cjs/FiberRefs/api.cjs.map +1 -1
- package/_cjs/FiberRefs/definition.cjs +1 -2
- package/_cjs/FiberRefs/definition.cjs.map +1 -1
- package/_cjs/FiberScope/definition.cjs +29 -6
- package/_cjs/FiberScope/definition.cjs.map +1 -1
- package/_cjs/FiberSet.cjs +16 -15
- package/_cjs/FiberSet.cjs.map +1 -1
- package/_cjs/FiberStatus/definition.cjs +1 -2
- package/_cjs/FiberStatus/definition.cjs.map +1 -1
- package/_cjs/Future/State.cjs +108 -0
- package/_cjs/Future/State.cjs.map +1 -0
- package/_cjs/Future/api.cjs +71 -64
- package/_cjs/Future/api.cjs.map +1 -1
- package/_cjs/Future/constructors.cjs +3 -4
- package/_cjs/Future/constructors.cjs.map +1 -1
- package/_cjs/Future/definition.cjs +1 -15
- package/_cjs/Future/definition.cjs.map +1 -1
- package/_cjs/Future.cjs +11 -0
- package/_cjs/Future.cjs.map +1 -1
- package/_cjs/Hub/api.cjs +56 -57
- package/_cjs/Hub/api.cjs.map +1 -1
- package/_cjs/Hub/internal.cjs +1 -2
- package/_cjs/Hub/internal.cjs.map +1 -1
- package/_cjs/IO/api/acquireRelease.cjs +1 -2
- package/_cjs/IO/api/acquireRelease.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseExit.cjs +1 -2
- package/_cjs/IO/api/acquireReleaseExit.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs +1 -2
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +1 -2
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs.map +1 -1
- package/_cjs/IO/api/addFinalizer.cjs +1 -2
- package/_cjs/IO/api/addFinalizer.cjs.map +1 -1
- package/_cjs/IO/api/addFinalizerExit.cjs +1 -2
- package/_cjs/IO/api/addFinalizerExit.cjs.map +1 -1
- package/_cjs/IO/api/all.cjs +1 -2
- package/_cjs/IO/api/all.cjs.map +1 -1
- package/_cjs/IO/api/array.cjs +51 -0
- package/_cjs/IO/api/array.cjs.map +1 -0
- package/_cjs/IO/api/asyncIO.cjs +1 -2
- package/_cjs/IO/api/asyncIO.cjs.map +1 -1
- package/_cjs/IO/api/asyncInterrupt.cjs +1 -2
- package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
- package/_cjs/IO/api/awaitAllChildren.cjs +17 -0
- package/_cjs/IO/api/awaitAllChildren.cjs.map +1 -0
- package/_cjs/IO/api/blocking.cjs +1 -2
- package/_cjs/IO/api/blocking.cjs.map +1 -1
- package/_cjs/IO/api/bracket.cjs +1 -2
- package/_cjs/IO/api/bracket.cjs.map +1 -1
- package/_cjs/IO/api/bracketExit.cjs +1 -2
- package/_cjs/IO/api/bracketExit.cjs.map +1 -1
- package/_cjs/IO/api/cachedInvalidate.cjs +47 -0
- package/_cjs/IO/api/cachedInvalidate.cjs.map +1 -0
- package/_cjs/IO/api/clockWith.cjs +1 -2
- package/_cjs/IO/api/clockWith.cjs.map +1 -1
- package/_cjs/IO/api/concurrency.cjs +1 -2
- package/_cjs/IO/api/concurrency.cjs.map +1 -1
- package/_cjs/IO/api/concurrentFinalizers.cjs +1 -2
- package/_cjs/IO/api/concurrentFinalizers.cjs.map +1 -1
- package/_cjs/IO/api/consoleWith.cjs +1 -2
- package/_cjs/IO/api/consoleWith.cjs.map +1 -1
- package/_cjs/IO/api/daemonChildren.cjs +1 -2
- package/_cjs/IO/api/daemonChildren.cjs.map +1 -1
- package/_cjs/IO/api/delay.cjs +1 -2
- package/_cjs/IO/api/delay.cjs.map +1 -1
- package/_cjs/IO/api/descriptor.cjs +1 -2
- package/_cjs/IO/api/descriptor.cjs.map +1 -1
- package/_cjs/IO/api/diffFiberRefs.cjs +1 -2
- package/_cjs/IO/api/diffFiberRefs.cjs.map +1 -1
- package/_cjs/IO/api/disconnect.cjs +2 -3
- package/_cjs/IO/api/disconnect.cjs.map +1 -1
- package/_cjs/IO/api/ensuringChildren.cjs +1 -2
- package/_cjs/IO/api/ensuringChildren.cjs.map +1 -1
- package/_cjs/IO/api/environment.cjs +1 -2
- package/_cjs/IO/api/environment.cjs.map +1 -1
- package/_cjs/IO/api/foreachConcurrent.cjs +36 -30
- package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
- package/_cjs/IO/api/foreachExec.cjs +1 -2
- package/_cjs/IO/api/foreachExec.cjs.map +1 -1
- package/_cjs/IO/api/fork.cjs +2 -3
- package/_cjs/IO/api/fork.cjs.map +1 -1
- package/_cjs/IO/api/forkAll.cjs +1 -2
- package/_cjs/IO/api/forkAll.cjs.map +1 -1
- package/_cjs/IO/api/forkDaemon.cjs +5 -6
- package/_cjs/IO/api/forkDaemon.cjs.map +1 -1
- package/_cjs/IO/api/forkIn.cjs +1 -2
- package/_cjs/IO/api/forkIn.cjs.map +1 -1
- package/_cjs/IO/api/forkScoped.cjs +1 -2
- package/_cjs/IO/api/forkScoped.cjs.map +1 -1
- package/_cjs/IO/api/fulfill.cjs +1 -2
- package/_cjs/IO/api/fulfill.cjs.map +1 -1
- package/_cjs/IO/api/interrupt.cjs +4 -5
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/memoize.cjs +1 -2
- package/_cjs/IO/api/memoize.cjs.map +1 -1
- package/_cjs/IO/api/onTermination.cjs +2 -3
- package/_cjs/IO/api/onTermination.cjs.map +1 -1
- package/_cjs/IO/api/once.cjs +1 -2
- package/_cjs/IO/api/once.cjs.map +1 -1
- package/_cjs/IO/api/patchFiberRefs.cjs +1 -2
- package/_cjs/IO/api/patchFiberRefs.cjs.map +1 -1
- package/_cjs/IO/api/provideLayer.cjs +1 -2
- package/_cjs/IO/api/provideLayer.cjs.map +1 -1
- package/_cjs/IO/api/provideScope.cjs +1 -2
- package/_cjs/IO/api/provideScope.cjs.map +1 -1
- package/_cjs/IO/api/provideSomeLayer.cjs +1 -2
- package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -1
- package/_cjs/IO/api/provideSomeRuntime.cjs +1 -2
- package/_cjs/IO/api/provideSomeRuntime.cjs.map +1 -1
- package/_cjs/IO/api/race.cjs +2 -3
- package/_cjs/IO/api/race.cjs.map +1 -1
- package/_cjs/IO/api/raceFirst.cjs +1 -2
- package/_cjs/IO/api/raceFirst.cjs.map +1 -1
- package/_cjs/IO/api/raceWith.cjs +1 -2
- package/_cjs/IO/api/raceWith.cjs.map +1 -1
- package/_cjs/IO/api/randomWith.cjs +1 -2
- package/_cjs/IO/api/randomWith.cjs.map +1 -1
- package/_cjs/IO/api/repeat.cjs +1 -2
- package/_cjs/IO/api/repeat.cjs.map +1 -1
- package/_cjs/IO/api/retry.cjs +1 -2
- package/_cjs/IO/api/retry.cjs.map +1 -1
- package/_cjs/IO/api/schedule.cjs +1 -2
- package/_cjs/IO/api/schedule.cjs.map +1 -1
- package/_cjs/IO/api/scope.cjs +1 -2
- package/_cjs/IO/api/scope.cjs.map +1 -1
- package/_cjs/IO/api/scopeWith.cjs +1 -2
- package/_cjs/IO/api/scopeWith.cjs.map +1 -1
- package/_cjs/IO/api/scoped.cjs +1 -2
- package/_cjs/IO/api/scoped.cjs.map +1 -1
- package/_cjs/IO/api/sleep.cjs +1 -2
- package/_cjs/IO/api/sleep.cjs.map +1 -1
- package/_cjs/IO/api/stateful.cjs +1 -2
- package/_cjs/IO/api/stateful.cjs.map +1 -1
- package/_cjs/IO/api/supervised.cjs +1 -2
- package/_cjs/IO/api/supervised.cjs.map +1 -1
- package/_cjs/IO/api/timeout.cjs +9 -11
- package/_cjs/IO/api/timeout.cjs.map +1 -1
- package/_cjs/IO/api/transplant.cjs +22 -7
- package/_cjs/IO/api/transplant.cjs.map +1 -1
- package/_cjs/IO/api/whenFiberRef.cjs +1 -2
- package/_cjs/IO/api/whenFiberRef.cjs.map +1 -1
- package/_cjs/IO/api/whenRef.cjs +1 -2
- package/_cjs/IO/api/whenRef.cjs.map +1 -1
- package/_cjs/IO/api/withChildren.cjs +1 -2
- package/_cjs/IO/api/withChildren.cjs.map +1 -1
- package/_cjs/IO/api/withEarlyRelease.cjs +1 -2
- package/_cjs/IO/api/withEarlyRelease.cjs.map +1 -1
- package/_cjs/IO/api/withFinalizer.cjs +1 -2
- package/_cjs/IO/api/withFinalizer.cjs.map +1 -1
- package/_cjs/IO/api/withFinalizerExit.cjs +1 -2
- package/_cjs/IO/api/withFinalizerExit.cjs.map +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs +5 -6
- package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/IO/api.cjs +522 -473
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +2 -3
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +9 -10
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +33 -11
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/IOEnv/definition.cjs +1 -2
- package/_cjs/IOEnv/definition.cjs.map +1 -1
- package/_cjs/IOEnv/live.cjs +1 -2
- package/_cjs/IOEnv/live.cjs.map +1 -1
- package/_cjs/IOEnv/services.cjs +1 -2
- package/_cjs/IOEnv/services.cjs.map +1 -1
- package/_cjs/Layer/MemoMap.cjs +1 -2
- package/_cjs/Layer/MemoMap.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +1 -2
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Logger/api.cjs +1 -2
- package/_cjs/Logger/api.cjs.map +1 -1
- package/_cjs/Logger/constructors.cjs +1 -2
- package/_cjs/Logger/constructors.cjs.map +1 -1
- package/_cjs/MVar/api.cjs +1 -2
- package/_cjs/MVar/api.cjs.map +1 -1
- package/_cjs/Push/api.cjs +2 -3
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +1 -2
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/Queue/api/dimapIO.cjs +1 -2
- package/_cjs/Queue/api/dimapIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterInputIO.cjs +1 -2
- package/_cjs/Queue/api/filterInputIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterOutputIO.cjs +1 -2
- package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -1
- package/_cjs/Queue/api/poll.cjs +1 -2
- package/_cjs/Queue/api/poll.cjs.map +1 -1
- package/_cjs/Queue/api/takeBetween.cjs +1 -2
- package/_cjs/Queue/api/takeBetween.cjs.map +1 -1
- package/_cjs/Queue/api/takeN.cjs +1 -2
- package/_cjs/Queue/api/takeN.cjs.map +1 -1
- package/_cjs/Queue/api/zipWithIO.cjs +1 -2
- package/_cjs/Queue/api/zipWithIO.cjs.map +1 -1
- package/_cjs/Queue/constructors.cjs +1 -2
- package/_cjs/Queue/constructors.cjs.map +1 -1
- package/_cjs/Queue/internal.cjs +1 -2
- package/_cjs/Queue/internal.cjs.map +1 -1
- package/_cjs/Queue/strategy.cjs +1 -2
- package/_cjs/Queue/strategy.cjs.map +1 -1
- package/_cjs/Random/api.cjs +1 -2
- package/_cjs/Random/api.cjs.map +1 -1
- package/_cjs/Random/definition.cjs +2 -2
- package/_cjs/Random/definition.cjs.map +1 -1
- package/_cjs/Random/live.cjs +1 -2
- package/_cjs/Random/live.cjs.map +1 -1
- package/_cjs/Ref/Atomic.cjs +1 -2
- package/_cjs/Ref/Atomic.cjs.map +1 -1
- package/_cjs/Ref/Derived.cjs +1 -2
- package/_cjs/Ref/Derived.cjs.map +1 -1
- package/_cjs/Ref/DerivedAll.cjs +1 -2
- package/_cjs/Ref/DerivedAll.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/api.cjs +2 -3
- package/_cjs/Ref/Synchronized/api.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/constructors.cjs +2 -3
- package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +2 -3
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
- package/_cjs/Ref/api/collect.cjs +1 -2
- package/_cjs/Ref/api/collect.cjs.map +1 -1
- package/_cjs/Ref/api/dimap.cjs +1 -2
- package/_cjs/Ref/api/dimap.cjs.map +1 -1
- package/_cjs/Ref/api/filter.cjs +1 -2
- package/_cjs/Ref/api/filter.cjs.map +1 -1
- package/_cjs/Ref/api/modify.cjs +1 -2
- package/_cjs/Ref/api/modify.cjs.map +1 -1
- package/_cjs/Ref/api.cjs +1 -2
- package/_cjs/Ref/api.cjs.map +1 -1
- package/_cjs/Ref/constructors.cjs +1 -2
- package/_cjs/Ref/constructors.cjs.map +1 -1
- package/_cjs/RefSubject/Atomic.cjs +1 -2
- package/_cjs/RefSubject/Atomic.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/api.cjs +1 -2
- package/_cjs/RefSubject/Synchronized/api.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +1 -2
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
- package/_cjs/RefSubject/api.cjs +1 -2
- package/_cjs/RefSubject/api.cjs.map +1 -1
- package/_cjs/Reloadable/api.cjs +1 -2
- package/_cjs/Reloadable/api.cjs.map +1 -1
- package/_cjs/Reloadable/constructors.cjs +1 -2
- package/_cjs/Reloadable/constructors.cjs.map +1 -1
- package/_cjs/Reloadable/definition.cjs +1 -2
- package/_cjs/Reloadable/definition.cjs.map +1 -1
- package/_cjs/RuntimeFlags/Patch.cjs +1 -2
- package/_cjs/RuntimeFlags/Patch.cjs.map +1 -1
- package/_cjs/RuntimeFlags/RuntimeFlags.cjs +1 -2
- package/_cjs/RuntimeFlags/RuntimeFlags.cjs.map +1 -1
- package/_cjs/STM/api/atomically.cjs +1 -2
- package/_cjs/STM/api/atomically.cjs.map +1 -1
- package/_cjs/STM/api/core-api.cjs +1 -2
- package/_cjs/STM/api/core-api.cjs.map +1 -1
- package/_cjs/STM/api.cjs +1 -2
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs +2 -3
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/STM/driver.cjs +1 -2
- package/_cjs/STM/driver.cjs.map +1 -1
- package/_cjs/STM/internal/CommitState.cjs +1 -2
- package/_cjs/STM/internal/CommitState.cjs.map +1 -1
- package/_cjs/STM/internal/Journal.cjs +1 -2
- package/_cjs/STM/internal/Journal.cjs.map +1 -1
- package/_cjs/Schedule/Decision.cjs +1 -2
- package/_cjs/Schedule/Decision.cjs.map +1 -1
- package/_cjs/Schedule/api/driver.cjs +1 -2
- package/_cjs/Schedule/api/driver.cjs.map +1 -1
- package/_cjs/Schedule/api.cjs +1 -2
- package/_cjs/Schedule/api.cjs.map +1 -1
- package/_cjs/Scope/Finalizer/definition.cjs +1 -2
- package/_cjs/Scope/Finalizer/definition.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/api.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/api.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/constructors.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/constructors.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/definition.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -1
- package/_cjs/Scope/api.cjs +1 -2
- package/_cjs/Scope/api.cjs.map +1 -1
- package/_cjs/Scope/definition.cjs +1 -2
- package/_cjs/Scope/definition.cjs.map +1 -1
- package/_cjs/ScopedRef/api.cjs +2 -3
- package/_cjs/ScopedRef/api.cjs.map +1 -1
- package/_cjs/Semaphore/Reservation.cjs +24 -0
- package/_cjs/Semaphore/Reservation.cjs.map +1 -0
- package/_cjs/Semaphore/constructors.cjs +25 -0
- package/_cjs/Semaphore/constructors.cjs.map +1 -0
- package/_cjs/Semaphore/definition.cjs +149 -0
- package/_cjs/Semaphore/definition.cjs.map +1 -0
- package/_cjs/Semaphore.cjs +31 -138
- package/_cjs/Semaphore.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +1 -2
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/State/api.cjs +1 -2
- package/_cjs/State/api.cjs.map +1 -1
- package/_cjs/Stream/api/zipAllWith.cjs +1 -2
- package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWith.cjs +1 -2
- package/_cjs/Stream/api/zipWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWithChunks.cjs +1 -2
- package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +702 -703
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/Stream/internal/Handoff.cjs +1 -2
- package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
- package/_cjs/Stream/internal/Pull.cjs +1 -2
- package/_cjs/Stream/internal/Pull.cjs.map +1 -1
- package/_cjs/Stream/internal/Take.cjs +1 -2
- package/_cjs/Stream/internal/Take.cjs.map +1 -1
- package/_cjs/Stream/internal/util.cjs +1 -2
- package/_cjs/Stream/internal/util.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +1 -2
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_cjs/Subject/api.cjs +1 -2
- package/_cjs/Subject/api.cjs.map +1 -1
- package/_cjs/SubscriptionRef.cjs +2 -3
- package/_cjs/SubscriptionRef.cjs.map +1 -1
- package/_cjs/Supervisor/api.cjs +1 -2
- package/_cjs/Supervisor/api.cjs.map +1 -1
- package/_cjs/Supervisor/constructors.cjs +1 -2
- package/_cjs/Supervisor/constructors.cjs.map +1 -1
- package/_cjs/Supervisor/definition.cjs +1 -2
- package/_cjs/Supervisor/definition.cjs.map +1 -1
- package/_cjs/SupervisorPatch.cjs +1 -2
- package/_cjs/SupervisorPatch.cjs.map +1 -1
- package/_cjs/TExit/definition.cjs +1 -2
- package/_cjs/TExit/definition.cjs.map +1 -1
- package/_cjs/TFuture/api.cjs +1 -2
- package/_cjs/TFuture/api.cjs.map +1 -1
- package/_cjs/TFuture/constructors.cjs +1 -2
- package/_cjs/TFuture/constructors.cjs.map +1 -1
- package/_cjs/TFuture/definition.cjs +1 -2
- package/_cjs/TFuture/definition.cjs.map +1 -1
- package/_cjs/TReentrantLock/api.cjs +1 -2
- package/_cjs/TReentrantLock/api.cjs.map +1 -1
- package/_cjs/TReentrantLock/definition.cjs +1 -2
- package/_cjs/TReentrantLock/definition.cjs.map +1 -1
- package/_cjs/TRef/api.cjs +1 -2
- package/_cjs/TRef/api.cjs.map +1 -1
- package/_cjs/TRef/constructors.cjs +1 -2
- package/_cjs/TRef/constructors.cjs.map +1 -1
- package/_cjs/TRef/definition.cjs +1 -2
- package/_cjs/TRef/definition.cjs.map +1 -1
- package/_cjs/TSemaphore/api.cjs +1 -2
- package/_cjs/TSemaphore/api.cjs.map +1 -1
- package/_cjs/TSemaphore/constructors.cjs +1 -2
- package/_cjs/TSemaphore/constructors.cjs.map +1 -1
- package/_cjs/TSemaphore/definition.cjs +1 -2
- package/_cjs/TSemaphore/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/filterIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/findIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/findIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/mapIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
- package/_cjs/data/Exit/foreachIO.cjs +1 -2
- package/_cjs/data/Exit/foreachIO.cjs.map +1 -1
- package/_cjs/internal/HashedPair.cjs +1 -2
- package/_cjs/internal/HashedPair.cjs.map +1 -1
- package/_cjs/internal/Hub.cjs +1 -2
- package/_cjs/internal/Hub.cjs.map +1 -1
- package/_cjs/internal/MutableQueue.cjs +1 -2
- package/_cjs/internal/MutableQueue.cjs.map +1 -1
- package/_cjs/internal/Scheduler.cjs +1 -2
- package/_cjs/internal/Scheduler.cjs.map +1 -1
- package/_cjs/internal/StackTraceBuilder.cjs +1 -2
- package/_cjs/internal/StackTraceBuilder.cjs.map +1 -1
- package/_mjs/Cached/api.mjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +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 +1 -1
- package/_mjs/Channel/api/toPull.mjs.map +1 -1
- package/_mjs/Channel/api.mjs +205 -205
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/core-api.mjs +43 -42
- package/_mjs/Channel/core-api.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelExecutor.mjs +3 -3
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
- package/_mjs/Console/definition.mjs +1 -0
- package/_mjs/Console/definition.mjs.map +1 -1
- package/_mjs/CountdownLatch.mjs +2 -1
- package/_mjs/CountdownLatch.mjs.map +1 -1
- package/_mjs/Fiber/FiberMessage.mjs +2 -20
- package/_mjs/Fiber/FiberMessage.mjs.map +1 -1
- package/_mjs/Fiber/FiberRuntime.mjs +877 -633
- package/_mjs/Fiber/FiberRuntime.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/interrupt.mjs +1 -1
- package/_mjs/Fiber/api/interrupt.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptAll.mjs +1 -1
- package/_mjs/Fiber/api/interruptAll.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptAs.mjs +4 -7
- package/_mjs/Fiber/api/interruptAs.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/mapIO.mjs +1 -1
- package/_mjs/Fiber/api/mapIO.mjs.map +1 -1
- package/_mjs/Fiber/api/zipWith.mjs +1 -1
- package/_mjs/Fiber/api/zipWith.mjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +1 -1
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/Fiber/definition.mjs +5 -2
- package/_mjs/Fiber/definition.mjs.map +1 -1
- package/_mjs/FiberScope/definition.mjs +28 -4
- package/_mjs/FiberScope/definition.mjs.map +1 -1
- package/_mjs/FiberSet.mjs +14 -12
- package/_mjs/FiberSet.mjs.map +1 -1
- package/_mjs/Future/State.mjs +96 -0
- package/_mjs/Future/State.mjs.map +1 -0
- package/_mjs/Future/api.mjs +67 -61
- package/_mjs/Future/api.mjs.map +1 -1
- package/_mjs/Future/constructors.mjs +3 -3
- package/_mjs/Future/constructors.mjs.map +1 -1
- package/_mjs/Future/definition.mjs +0 -12
- package/_mjs/Future/definition.mjs.map +1 -1
- package/_mjs/Future.mjs +1 -0
- package/_mjs/Future.mjs.map +1 -1
- package/_mjs/Hub/api.mjs +55 -55
- package/_mjs/Hub/api.mjs.map +1 -1
- package/_mjs/IO/api/array.mjs +42 -0
- package/_mjs/IO/api/array.mjs.map +1 -0
- package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
- package/_mjs/IO/api/awaitAllChildren.mjs +10 -0
- package/_mjs/IO/api/awaitAllChildren.mjs.map +1 -0
- package/_mjs/IO/api/cachedInvalidate.mjs +39 -0
- package/_mjs/IO/api/cachedInvalidate.mjs.map +1 -0
- package/_mjs/IO/api/disconnect.mjs +1 -1
- package/_mjs/IO/api/disconnect.mjs.map +1 -1
- package/_mjs/IO/api/foreachConcurrent.mjs +35 -28
- package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
- package/_mjs/IO/api/fork.mjs +1 -1
- package/_mjs/IO/api/fork.mjs.map +1 -1
- package/_mjs/IO/api/forkDaemon.mjs +4 -4
- package/_mjs/IO/api/forkDaemon.mjs.map +1 -1
- package/_mjs/IO/api/interrupt.mjs +3 -3
- package/_mjs/IO/api/onTermination.mjs +1 -1
- package/_mjs/IO/api/onTermination.mjs.map +1 -1
- package/_mjs/IO/api/race.mjs +1 -1
- package/_mjs/IO/api/race.mjs.map +1 -1
- package/_mjs/IO/api/timeout.mjs +8 -9
- package/_mjs/IO/api/timeout.mjs.map +1 -1
- package/_mjs/IO/api/transplant.mjs +19 -5
- package/_mjs/IO/api/transplant.mjs.map +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs +4 -4
- package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
- package/_mjs/IO/api.mjs +515 -468
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +1 -1
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +8 -8
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +3 -1
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/IOEnv/definition.mjs.map +1 -1
- package/_mjs/Push/api.mjs +1 -1
- package/_mjs/Random/definition.mjs +1 -0
- package/_mjs/Random/definition.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/api.mjs +1 -1
- package/_mjs/Ref/Synchronized/api.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/constructors.mjs +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/STM/definition.mjs +1 -1
- package/_mjs/ScopedRef/api.mjs +1 -1
- package/_mjs/ScopedRef/api.mjs.map +1 -1
- package/_mjs/Semaphore/Reservation.mjs +16 -0
- package/_mjs/Semaphore/Reservation.mjs.map +1 -0
- package/_mjs/Semaphore/constructors.mjs +17 -0
- package/_mjs/Semaphore/constructors.mjs.map +1 -0
- package/_mjs/Semaphore/definition.mjs +141 -0
- package/_mjs/Semaphore/definition.mjs.map +1 -0
- package/_mjs/Semaphore.mjs +4 -133
- package/_mjs/Semaphore.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +701 -701
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/SubscriptionRef.mjs +1 -1
- package/_src/Cached/api.ts +3 -3
- package/_src/Channel/api/toPull.ts +1 -1
- package/_src/Channel/api.ts +273 -272
- package/_src/Channel/core-api.ts +57 -55
- package/_src/Channel/internal/ChannelExecutor.ts +3 -3
- package/_src/Console/definition.ts +1 -0
- package/_src/CountdownLatch.ts +2 -0
- package/_src/Fiber/FiberMessage.ts +3 -28
- package/_src/Fiber/FiberRuntime.ts +988 -616
- package/_src/Fiber/api/interruptAs.ts +4 -3
- package/_src/Fiber/constructors.ts +1 -1
- package/_src/Fiber/definition.ts +4 -0
- package/_src/FiberScope/definition.ts +40 -2
- package/_src/FiberSet.ts +6 -2
- package/_src/Future/State.ts +128 -0
- package/_src/Future/api.ts +62 -51
- package/_src/Future/constructors.ts +4 -2
- package/_src/Future/definition.ts +2 -17
- package/_src/Future.ts +4 -3
- package/_src/Hub/api.ts +61 -61
- package/_src/IO/api/addFinalizerExit.ts +4 -4
- package/_src/IO/api/array.ts +49 -0
- package/_src/IO/api/asyncInterrupt.ts +1 -1
- package/_src/IO/api/awaitAllChildren.ts +6 -0
- package/_src/IO/api/cachedInvalidate.ts +42 -0
- package/_src/IO/api/foreachConcurrent.ts +39 -23
- package/_src/IO/api/fork.ts +1 -1
- package/_src/IO/api/forkDaemon.ts +2 -2
- package/_src/IO/api/memoize.ts +3 -3
- package/_src/IO/api/onTermination.ts +2 -2
- package/_src/IO/api/transplant.ts +26 -3
- package/_src/IO/api/zipConcurrent.ts +2 -2
- package/_src/IO/api.ts +547 -525
- package/_src/IO/definition.ts +4 -28
- package/_src/IO/runtime.ts +0 -1
- package/_src/IO.ts +65 -63
- package/_src/IOEnv/definition.ts +1 -4
- package/_src/Random/definition.ts +1 -0
- package/_src/Ref/Synchronized/api.ts +2 -2
- package/_src/Ref/Synchronized/definition.ts +1 -1
- package/_src/Semaphore/Reservation.ts +15 -0
- package/_src/Semaphore/constructors.ts +14 -0
- package/_src/Semaphore/definition.ts +180 -0
- package/_src/Semaphore.ts +5 -159
- package/_src/Stream/api.ts +679 -679
- package/package.json +4 -4
- package/IO/api/sequenceT.d.ts +0 -26
- package/_cjs/IO/api/sequenceT.cjs +0 -18
- package/_cjs/IO/api/sequenceT.cjs.map +0 -1
- package/_mjs/IO/api/sequenceT.mjs +0 -10
- package/_mjs/IO/api/sequenceT.mjs.map +0 -1
- package/_src/IO/api/sequenceT.ts +0 -16
package/_mjs/Stream/api.mjs
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
const fileName_1 = "(@fncts/io) src/Stream/api.ts";
|
2
2
|
import * as tsplus_module_1 from "@fncts/io/IO/api";
|
3
|
-
import * as tsplus_module_2 from "@fncts/io/
|
4
|
-
import * as tsplus_module_3 from "@fncts/
|
5
|
-
import * as tsplus_module_4 from "@fncts/
|
6
|
-
import * as tsplus_module_5 from "@fncts/
|
7
|
-
import * as tsplus_module_6 from "@fncts/
|
8
|
-
import * as tsplus_module_7 from "@fncts/
|
9
|
-
import * as tsplus_module_8 from "@fncts/io/
|
10
|
-
import * as tsplus_module_9 from "@fncts/
|
11
|
-
import * as tsplus_module_10 from "@fncts/io/
|
12
|
-
import * as tsplus_module_11 from "@fncts/io/
|
13
|
-
import * as tsplus_module_12 from "@fncts/
|
14
|
-
import * as tsplus_module_13 from "@fncts/io/
|
15
|
-
import * as tsplus_module_14 from "@fncts/
|
16
|
-
import * as tsplus_module_15 from "@fncts/io/Ref/api/
|
17
|
-
import * as tsplus_module_16 from "@fncts/io/
|
18
|
-
import * as tsplus_module_17 from "@fncts/io/
|
19
|
-
import * as tsplus_module_18 from "@fncts/
|
20
|
-
import * as tsplus_module_19 from "@fncts/
|
21
|
-
import * as tsplus_module_20 from "@fncts/base/data/
|
22
|
-
import * as tsplus_module_21 from "@fncts/
|
23
|
-
import * as tsplus_module_22 from "@fncts/
|
24
|
-
import * as tsplus_module_23 from "@fncts/io/
|
25
|
-
import * as tsplus_module_24 from "@fncts/io/
|
26
|
-
import * as tsplus_module_25 from "@fncts/
|
27
|
-
import * as tsplus_module_26 from "@fncts/io/IO/api/
|
28
|
-
import * as tsplus_module_27 from "@fncts/
|
29
|
-
import * as tsplus_module_28 from "@fncts/io/
|
30
|
-
import * as tsplus_module_29 from "@fncts/io/
|
31
|
-
import * as tsplus_module_30 from "@fncts/io/Queue/
|
32
|
-
import * as tsplus_module_31 from "@fncts/io/IO/
|
33
|
-
import * as tsplus_module_32 from "@fncts/io/
|
3
|
+
import * as tsplus_module_2 from "@fncts/io/IO/api/acquireRelease";
|
4
|
+
import * as tsplus_module_3 from "@fncts/io/IO/api/acquireReleaseExit";
|
5
|
+
import * as tsplus_module_4 from "@fncts/io/Schedule/api";
|
6
|
+
import * as tsplus_module_5 from "@fncts/base/data/Maybe/constructors";
|
7
|
+
import * as tsplus_module_6 from "@fncts/base/data/Either/destructors";
|
8
|
+
import * as tsplus_module_7 from "@fncts/io/Stream/internal/Handoff";
|
9
|
+
import * as tsplus_module_8 from "@fncts/io/Ref/constructors";
|
10
|
+
import * as tsplus_module_9 from "@fncts/base/collection/immutable/Conc/api/empty";
|
11
|
+
import * as tsplus_module_10 from "@fncts/io/Schedule/api/driver";
|
12
|
+
import * as tsplus_module_11 from "@fncts/io/IO/api/all";
|
13
|
+
import * as tsplus_module_12 from "@fncts/io/Channel/api";
|
14
|
+
import * as tsplus_module_13 from "@fncts/io/Channel/core-api";
|
15
|
+
import * as tsplus_module_14 from "@fncts/base/collection/immutable/Conc/api";
|
16
|
+
import * as tsplus_module_15 from "@fncts/io/Ref/api/set";
|
17
|
+
import * as tsplus_module_16 from "@fncts/io/Ref/api/get";
|
18
|
+
import * as tsplus_module_17 from "@fncts/io/Ref/api/modify";
|
19
|
+
import * as tsplus_module_18 from "@fncts/io/Channel/api/runScoped";
|
20
|
+
import * as tsplus_module_19 from "@fncts/io/IO/api/forkScoped";
|
21
|
+
import * as tsplus_module_20 from "@fncts/base/data/Either/constructors";
|
22
|
+
import * as tsplus_module_21 from "@fncts/base/collection/immutable/Conc/constructors";
|
23
|
+
import * as tsplus_module_22 from "@fncts/base/data/Maybe/destructors";
|
24
|
+
import * as tsplus_module_23 from "@fncts/io/Stream/internal/SinkEndReason";
|
25
|
+
import * as tsplus_module_24 from "@fncts/io/Fiber/api/join";
|
26
|
+
import * as tsplus_module_25 from "@fncts/io/Fiber/api/interrupt";
|
27
|
+
import * as tsplus_module_26 from "@fncts/io/IO/api/forkDaemon";
|
28
|
+
import * as tsplus_module_27 from "@fncts/base/data/Cause/api";
|
29
|
+
import * as tsplus_module_28 from "@fncts/io/IO/api/raceWith";
|
30
|
+
import * as tsplus_module_29 from "@fncts/io/Stream/internal/Take";
|
31
|
+
import * as tsplus_module_30 from "@fncts/io/Queue/api/operations";
|
32
|
+
import * as tsplus_module_31 from "@fncts/io/IO/runtime";
|
33
|
+
import * as tsplus_module_32 from "@fncts/io/Queue/constructors";
|
34
34
|
import * as tsplus_module_33 from "@fncts/io/IO/api/fork";
|
35
35
|
import * as tsplus_module_34 from "@fncts/io/Hub/api";
|
36
36
|
import * as tsplus_module_35 from "@fncts/base/collection/immutable/Conc/api/replicate";
|
@@ -44,24 +44,24 @@ import * as tsplus_module_42 from "@fncts/io/Stream/internal/DebounceState";
|
|
44
44
|
import * as tsplus_module_43 from "@fncts/io/Clock/api";
|
45
45
|
import * as tsplus_module_44 from "@fncts/io/IO/api/transplant";
|
46
46
|
import * as tsplus_module_45 from "@fncts/base/collection/immutable/HashMap/api";
|
47
|
-
import * as tsplus_module_46 from "@fncts/io/Semaphore";
|
48
|
-
import * as tsplus_module_47 from "@fncts/
|
49
|
-
import * as tsplus_module_48 from "@fncts/
|
47
|
+
import * as tsplus_module_46 from "@fncts/io/Semaphore/constructors";
|
48
|
+
import * as tsplus_module_47 from "@fncts/base/data/Predicate/api";
|
49
|
+
import * as tsplus_module_48 from "@fncts/io/Sink/api";
|
50
50
|
import * as tsplus_module_49 from "@fncts/io/Fiber/api/poll";
|
51
51
|
import * as tsplus_module_50 from "@fncts/io/IO/api/environment";
|
52
52
|
import * as tsplus_module_51 from "@fncts/io/collection/immutable/Conc/findIO";
|
53
53
|
import * as tsplus_module_52 from "@fncts/base/data/Exit/definition";
|
54
|
-
import * as tsplus_module_53 from "@fncts/
|
55
|
-
import * as tsplus_module_54 from "@fncts/io/
|
56
|
-
import * as tsplus_module_55 from "@fncts/io/
|
57
|
-
import * as tsplus_module_56 from "@fncts/io/Channel/api/
|
58
|
-
import * as tsplus_module_57 from "@fncts/io/Channel/api/
|
59
|
-
import * as tsplus_module_58 from "@fncts/io/Channel/api/
|
54
|
+
import * as tsplus_module_53 from "@fncts/io/Stream/internal/Pull";
|
55
|
+
import * as tsplus_module_54 from "@fncts/io/Queue/api/takeBetween";
|
56
|
+
import * as tsplus_module_55 from "@fncts/io/Channel/api/interruptWhen";
|
57
|
+
import * as tsplus_module_56 from "@fncts/io/Channel/api/mapOutConcurrentIO";
|
58
|
+
import * as tsplus_module_57 from "@fncts/io/Channel/api/mergeMap";
|
59
|
+
import * as tsplus_module_58 from "@fncts/io/Channel/api/mergeWith";
|
60
60
|
import * as tsplus_module_59 from "@fncts/io/Channel/internal/MergeDecision";
|
61
|
-
import * as tsplus_module_60 from "@fncts/io/
|
62
|
-
import * as tsplus_module_61 from "@fncts/io/Layer/
|
63
|
-
import * as tsplus_module_62 from "@fncts/io/
|
64
|
-
import * as tsplus_module_63 from "@fncts/
|
61
|
+
import * as tsplus_module_60 from "@fncts/io/Layer/MemoMap";
|
62
|
+
import * as tsplus_module_61 from "@fncts/io/Layer/api";
|
63
|
+
import * as tsplus_module_62 from "@fncts/io/Channel/api/runDrain";
|
64
|
+
import * as tsplus_module_63 from "@fncts/base/collection/immutable/Conc/definition";
|
65
65
|
import * as tsplus_module_64 from "@fncts/base/data/Maybe/definition";
|
66
66
|
import * as tsplus_module_65 from "@fncts/base/data/exceptions";
|
67
67
|
import * as tsplus_module_66 from "@fncts/io/IO/api/interrupt";
|
@@ -70,14 +70,12 @@ import * as tsplus_module_68 from "@fncts/io/Scope/api";
|
|
70
70
|
import * as tsplus_module_69 from "@fncts/io/IO/api/provideScope";
|
71
71
|
export const aggregateAsyncWithin = aggregateAsyncWithin_1;
|
72
72
|
export const aggregateAsyncWithinEither = aggregateAsyncWithinEither_1;
|
73
|
-
export const zipRight = zipRight_1;
|
74
73
|
export const asyncInterrupt = asyncInterrupt_1;
|
75
74
|
export const asyncMaybe = asyncMaybe_1;
|
76
75
|
export const broadcastedQueues = broadcastedQueues_1;
|
77
76
|
export const broadcastedQueuesDynamic = broadcastedQueuesDynamic_1;
|
78
77
|
export const catchAll = catchAll_1;
|
79
78
|
export const catchAllCause = catchAllCause_1;
|
80
|
-
export const flatMap = flatMap_1;
|
81
79
|
export const chunks = chunks_1;
|
82
80
|
export const concat = concat_1;
|
83
81
|
export const crossWith = crossWith_1;
|
@@ -86,20 +84,21 @@ export const distributedWithDynamic = distributedWithDynamic_1;
|
|
86
84
|
export const drain = drain_1;
|
87
85
|
export const drop = drop_1;
|
88
86
|
export const dropWhile = dropWhile_1;
|
87
|
+
export const flatMap = flatMap_1;
|
88
|
+
export const zipRight = zipRight_1;
|
89
89
|
export const ensuring = ensuring_1;
|
90
90
|
export const environment = environment_1;
|
91
91
|
export const execute = execute_1;
|
92
|
-
export const failNow = failNow_1;
|
93
92
|
export const failCauseNow = failCauseNow_1;
|
93
|
+
export const failNow = failNow_1;
|
94
94
|
export const filterMap = filterMap_1;
|
95
95
|
export const flatten = flatten_1;
|
96
|
+
export const flattenChunks = flattenChunks_1;
|
96
97
|
export const flattenExitOption = flattenExitOption_1;
|
97
98
|
export const flattenTake = flattenTake_1;
|
98
|
-
export const flattenChunks = flattenChunks_1;
|
99
99
|
export const forever = forever_1;
|
100
|
-
export const fromChunkNow = fromChunkNow_1;
|
101
100
|
export const fromChunk = fromChunk_1;
|
102
|
-
export const
|
101
|
+
export const fromChunkNow = fromChunkNow_1;
|
103
102
|
export const fromIO = fromIO_1;
|
104
103
|
export const fromIOMaybe = fromIOMaybe_1;
|
105
104
|
export const fromPull = fromPull_1;
|
@@ -115,24 +114,25 @@ export const mapConcatChunk = mapConcatChunk_1;
|
|
115
114
|
export const mapError = mapError_1;
|
116
115
|
export const mapIO = mapIO_1;
|
117
116
|
export const merge = merge_1;
|
118
|
-
export const mergeMap = mergeMap_1;
|
119
117
|
export const mergeEither = mergeEither_1;
|
118
|
+
export const mergeMap = mergeMap_1;
|
120
119
|
export const mergeWith = mergeWith_1;
|
121
120
|
export const orElse = orElse_1;
|
122
121
|
export const pipeThrough = pipeThrough_1;
|
123
122
|
export const pipeThroughChannelOrFail = pipeThroughChannelOrFail_1;
|
124
123
|
export const provideEnvironment = provideEnvironment_1;
|
125
124
|
export const provideLayer = provideLayer_1;
|
126
|
-
export const repeatIOMaybe = repeatIOMaybe_1;
|
127
125
|
export const repeatIOChunkMaybe = repeatIOChunkMaybe_1;
|
126
|
+
export const repeatIOMaybe = repeatIOMaybe_1;
|
128
127
|
export const run = run_1;
|
129
128
|
export const runForeachScoped = runForeachScoped_1;
|
130
|
-
export const runIntoQueueScoped = runIntoQueueScoped_1;
|
131
|
-
export const runIntoQueueElementsScoped = runIntoQueueElementsScoped_1;
|
132
129
|
export const runIntoHubScoped = runIntoHubScoped_1;
|
130
|
+
export const runIntoQueueElementsScoped = runIntoQueueElementsScoped_1;
|
131
|
+
export const runIntoQueueScoped = runIntoQueueScoped_1;
|
133
132
|
export const runScoped = runScoped_1;
|
134
133
|
export const scanIO = scanIO_1;
|
135
134
|
export const scanReduceIO = scanReduceIO_1;
|
135
|
+
export const scoped = scoped_1;
|
136
136
|
export const succeedNow = succeedNow_1;
|
137
137
|
export const tap = tap_1;
|
138
138
|
export const tapError = tapError_1;
|
@@ -142,9 +142,9 @@ export const toPull = toPull_1;
|
|
142
142
|
export const toQueue = toQueue_1;
|
143
143
|
export const toQueueOfElements = toQueueOfElements_1;
|
144
144
|
export const toQueueUnbounded = toQueueUnbounded_1;
|
145
|
+
export const unfoldChunk = unfoldChunk_1;
|
145
146
|
export const unfoldChunkIO = unfoldChunkIO_1;
|
146
147
|
export const unfoldIO = unfoldIO_1;
|
147
|
-
export const unfoldChunk = unfoldChunk_1;
|
148
148
|
export const unwrap = unwrap_1;
|
149
149
|
export const unwrapScoped = unwrapScoped_1;
|
150
150
|
import { identity, tuple } from "@fncts/base/data/function";
|
@@ -159,6 +159,24 @@ import { ScheduleEnd, UpstreamEnd } from "./internal/SinkEndReason.mjs";
|
|
159
159
|
export function absolve(self, __tsplusTrace) {
|
160
160
|
return mapIO_1(either => tsplus_module_1.fromEither(() => either, __tsplusTrace), __tsplusTrace)(self);
|
161
161
|
}
|
162
|
+
/**
|
163
|
+
* Creates a stream from a single value that will get cleaned up after the
|
164
|
+
* stream is consumed
|
165
|
+
*
|
166
|
+
* @tsplus static fncts.io.StreamOps acquireRelease
|
167
|
+
*/
|
168
|
+
export function acquireRelease(acquire, release, __tsplusTrace) {
|
169
|
+
return scoped_1(() => tsplus_module_2.acquireRelease(() => acquire, release, __tsplusTrace), __tsplusTrace);
|
170
|
+
}
|
171
|
+
/**
|
172
|
+
* Creates a stream from a single value that will get cleaned up after the
|
173
|
+
* stream is consumed
|
174
|
+
*
|
175
|
+
* @tsplus static fncts.io.StreamOps acquireReleaseExit
|
176
|
+
*/
|
177
|
+
export function acquireReleaseExit(acquire, release, __tsplusTrace) {
|
178
|
+
return scoped_1(() => tsplus_module_3.acquireReleaseExit(() => acquire, release, __tsplusTrace), __tsplusTrace);
|
179
|
+
}
|
162
180
|
/**
|
163
181
|
* Aggregates elements of this stream using the provided sink for as long
|
164
182
|
* as the downstream operators on the stream are busy.
|
@@ -175,7 +193,7 @@ export function absolve(self, __tsplusTrace) {
|
|
175
193
|
*/
|
176
194
|
export function aggregateAsync(sink, __tsplusTrace) {
|
177
195
|
return stream => {
|
178
|
-
return aggregateAsyncWithin_1(sink,
|
196
|
+
return aggregateAsyncWithin_1(sink, tsplus_module_4.forever, __tsplusTrace)(stream);
|
179
197
|
};
|
180
198
|
}
|
181
199
|
/**
|
@@ -185,7 +203,7 @@ export function aggregateAsync(sink, __tsplusTrace) {
|
|
185
203
|
*/
|
186
204
|
function aggregateAsyncWithin_1(sink, schedule, __tsplusTrace) {
|
187
205
|
return stream => {
|
188
|
-
return filterMap_1(cb =>
|
206
|
+
return filterMap_1(cb => tsplus_module_6.match(() => tsplus_module_5.nothing(__tsplusTrace), tsplus_module_5.just)(cb), __tsplusTrace)(aggregateAsyncWithinEither_1(sink, schedule, __tsplusTrace)(stream));
|
189
207
|
};
|
190
208
|
}
|
191
209
|
/**
|
@@ -204,76 +222,52 @@ function aggregateAsyncWithin_1(sink, schedule, __tsplusTrace) {
|
|
204
222
|
*/
|
205
223
|
function aggregateAsyncWithinEither_1(sink, schedule, __tsplusTrace) {
|
206
224
|
return stream => {
|
207
|
-
const deps =
|
225
|
+
const deps = tsplus_module_11.all([tsplus_module_7.make(), tsplus_module_8.make(() => new ScheduleEnd(), __tsplusTrace), tsplus_module_8.make(() => tsplus_module_9.empty(), __tsplusTrace), tsplus_module_10.driver(schedule, __tsplusTrace), tsplus_module_8.make(() => false, __tsplusTrace)]);
|
208
226
|
return flatMap_1(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver, consumed]) => {
|
209
|
-
const handoffProducer =
|
210
|
-
const handoffConsumer =
|
211
|
-
if (
|
212
|
-
return tsplus_module_1.zipRight(tsplus_module_1.succeedNow(
|
227
|
+
const handoffProducer = tsplus_module_12.readWithCause(_in => tsplus_module_13.zipRight(handoffProducer)(tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_7.emit(_in))(handoff))), cause => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_7.halt(cause))(handoff)), _ => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_7.end(new UpstreamEnd()))(handoff)));
|
228
|
+
const handoffConsumer = tsplus_module_12.unwrap(() => tsplus_module_1.flatMap(leftovers => {
|
229
|
+
if (tsplus_module_14.isNonEmpty(leftovers)) {
|
230
|
+
return tsplus_module_1.zipRight(tsplus_module_1.succeedNow(tsplus_module_13.zipRight(handoffConsumer)(tsplus_module_12.writeNow(leftovers)), __tsplusTrace), __tsplusTrace)(tsplus_module_15.set(true, __tsplusTrace)(consumed));
|
213
231
|
} else {
|
214
|
-
return tsplus_module_1.map(signal =>
|
232
|
+
return tsplus_module_1.map(signal => tsplus_module_7.matchSignal({
|
215
233
|
Emit: ({
|
216
234
|
els
|
217
|
-
}) =>
|
235
|
+
}) => tsplus_module_13.zipRight(handoffConsumer)(tsplus_module_13.zipRight(tsplus_module_12.writeNow(els))(tsplus_module_12.fromIO(() => tsplus_module_15.set(true, __tsplusTrace)(consumed)))),
|
218
236
|
Halt: ({
|
219
237
|
error
|
220
|
-
}) =>
|
238
|
+
}) => tsplus_module_13.failCause(() => error),
|
221
239
|
End: ({
|
222
240
|
reason
|
223
241
|
}) => {
|
224
242
|
if (reason._tag === "ScheduleEnd" /* SinkEndReasonTag.ScheduleEnd */) {
|
225
|
-
return
|
243
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(p => p ? tsplus_module_12.fromIO(() => tsplus_module_15.set(new ScheduleEnd(), __tsplusTrace)(sinkEndReason)) : tsplus_module_13.zipRight(handoffConsumer)(tsplus_module_12.fromIO(() => tsplus_module_15.set(new ScheduleEnd(), __tsplusTrace)(sinkEndReason))), __tsplusTrace)(tsplus_module_16.get(consumed, __tsplusTrace)));
|
226
244
|
} else {
|
227
|
-
return
|
245
|
+
return tsplus_module_12.fromIO(() => tsplus_module_15.set(reason, __tsplusTrace)(sinkEndReason));
|
228
246
|
}
|
229
247
|
}
|
230
|
-
})(signal), __tsplusTrace)(
|
248
|
+
})(signal), __tsplusTrace)(tsplus_module_7.take(handoff));
|
231
249
|
}
|
232
|
-
}, __tsplusTrace)(
|
250
|
+
}, __tsplusTrace)(tsplus_module_17.getAndSet(tsplus_module_9.empty(), __tsplusTrace)(sinkLeftovers)));
|
233
251
|
function timeout(lastB, __tsplusTrace) {
|
234
252
|
return scheduleDriver.next(lastB, __tsplusTrace);
|
235
253
|
}
|
236
254
|
const scheduledAggregator = (sinkFiber, scheduleFiber) => {
|
237
|
-
const forkSink = tsplus_module_1.zipRight(
|
255
|
+
const forkSink = tsplus_module_1.zipRight(tsplus_module_19.forkScoped(tsplus_module_18.runScoped(tsplus_module_12.doneCollect(tsplus_module_12.pipeToOrFail(sink.channel)(handoffConsumer))), __tsplusTrace), __tsplusTrace)(tsplus_module_15.set(false, __tsplusTrace)(consumed));
|
238
256
|
function handleSide(leftovers, b, c, __tsplusTrace) {
|
239
|
-
return
|
240
|
-
ScheduleEnd: () =>
|
241
|
-
const toWrite =
|
242
|
-
return consumed_ ?
|
243
|
-
}, __tsplusTrace)(
|
244
|
-
UpstreamEnd: () =>
|
245
|
-
})(reason), __tsplusTrace)(
|
257
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.zipRight(tsplus_module_1.map(reason => tsplus_module_23.matchSinkEndReason({
|
258
|
+
ScheduleEnd: () => tsplus_module_12.unwrapScoped(() => tsplus_module_1.flatMap(consumed_ => tsplus_module_1.flatMap(sinkFiber => tsplus_module_1.map(scheduleFiber => {
|
259
|
+
const toWrite = tsplus_module_22.match(() => tsplus_module_21.make(tsplus_module_20.right(b, __tsplusTrace)), c => tsplus_module_21.make(tsplus_module_20.right(b, __tsplusTrace), tsplus_module_20.left(c, __tsplusTrace)))(c);
|
260
|
+
return consumed_ ? tsplus_module_13.zipRight(scheduledAggregator(sinkFiber, scheduleFiber))(tsplus_module_12.write(() => toWrite)) : scheduledAggregator(sinkFiber, scheduleFiber);
|
261
|
+
}, __tsplusTrace)(tsplus_module_19.forkScoped(timeout(tsplus_module_5.just(b, __tsplusTrace), __tsplusTrace), __tsplusTrace)), __tsplusTrace)(forkSink), __tsplusTrace)(tsplus_module_16.get(consumed, __tsplusTrace))),
|
262
|
+
UpstreamEnd: () => tsplus_module_12.unwrap(() => tsplus_module_1.map(p => p ? tsplus_module_12.write(() => tsplus_module_21.make(tsplus_module_20.right(b, __tsplusTrace))) : tsplus_module_12.unit, __tsplusTrace)(tsplus_module_16.get(consumed, __tsplusTrace)))
|
263
|
+
})(reason), __tsplusTrace)(tsplus_module_16.get(sinkEndReason, __tsplusTrace)), __tsplusTrace)(tsplus_module_15.set(tsplus_module_14.flatten(leftovers), __tsplusTrace)(sinkLeftovers)));
|
246
264
|
}
|
247
|
-
return
|
265
|
+
return tsplus_module_12.unwrap(() => tsplus_module_28.raceWith(() => tsplus_module_24.join(scheduleFiber, __tsplusTrace), (sinkExit, scheduleFiber) => tsplus_module_1.zipRight(tsplus_module_1.map(([leftovers, b]) => handleSide(leftovers, b, tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace), __tsplusTrace)(tsplus_module_1.fromExit(() => sinkExit, __tsplusTrace)), __tsplusTrace)(tsplus_module_25.interrupt(scheduleFiber)), (scheduleExit, sinkFiber) => tsplus_module_1.matchCauseIO(cause => tsplus_module_6.match(() => tsplus_module_1.zipRight(tsplus_module_1.map(([leftovers, b]) => handleSide(leftovers, b, tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace), __tsplusTrace)(tsplus_module_24.join(sinkFiber, __tsplusTrace)), __tsplusTrace)(tsplus_module_26.forkDaemon(tsplus_module_7.offer(tsplus_module_7.end(new ScheduleEnd()))(handoff), __tsplusTrace)), cause => tsplus_module_1.zipRight(tsplus_module_1.map(([leftovers, b]) => handleSide(leftovers, b, tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace), __tsplusTrace)(tsplus_module_24.join(sinkFiber, __tsplusTrace)), __tsplusTrace)(tsplus_module_26.forkDaemon(tsplus_module_7.offer(tsplus_module_7.halt(cause))(handoff), __tsplusTrace)))(tsplus_module_27.failureOrCause(cause)), c => tsplus_module_1.zipRight(tsplus_module_1.map(([leftovers, b]) => handleSide(leftovers, b, tsplus_module_5.just(c, __tsplusTrace), __tsplusTrace), __tsplusTrace)(tsplus_module_24.join(sinkFiber, __tsplusTrace)), __tsplusTrace)(tsplus_module_26.forkDaemon(tsplus_module_7.offer(tsplus_module_7.end(new ScheduleEnd()))(handoff), __tsplusTrace)), __tsplusTrace)(tsplus_module_1.fromExit(() => scheduleExit, __tsplusTrace)), __tsplusTrace)(tsplus_module_24.join(sinkFiber, __tsplusTrace)));
|
248
266
|
};
|
249
|
-
return unwrapScoped_1(tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(sinkFiber => tsplus_module_1.map(scheduleFiber => new Stream(scheduledAggregator(sinkFiber, scheduleFiber)), __tsplusTrace)(
|
267
|
+
return unwrapScoped_1(tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(sinkFiber => tsplus_module_1.map(scheduleFiber => new Stream(scheduledAggregator(sinkFiber, scheduleFiber)), __tsplusTrace)(tsplus_module_19.forkScoped(timeout(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace), __tsplusTrace)), __tsplusTrace)(tsplus_module_19.forkScoped(tsplus_module_18.runScoped(tsplus_module_12.doneCollect(tsplus_module_12.pipeToOrFail(sink.channel)(handoffConsumer))), __tsplusTrace)), __tsplusTrace)(tsplus_module_19.forkScoped(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(handoffProducer)(stream.channel)), __tsplusTrace)), __tsplusTrace);
|
250
268
|
}, __tsplusTrace)(fromIO_1(deps, __tsplusTrace));
|
251
269
|
};
|
252
270
|
}
|
253
|
-
/**
|
254
|
-
* Composes this stream with the specified stream to create a cartesian product of elements,
|
255
|
-
* but keeps only elements from this stream.
|
256
|
-
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
257
|
-
*
|
258
|
-
* @tsplus pipeable fncts.io.Stream zipLeft
|
259
|
-
*/
|
260
|
-
export function zipLeft(that, __tsplusTrace) {
|
261
|
-
return stream => {
|
262
|
-
return crossWith_1(that, (a, _) => a, __tsplusTrace)(stream);
|
263
|
-
};
|
264
|
-
}
|
265
|
-
/**
|
266
|
-
* Composes this stream with the specified stream to create a cartesian product of elements,
|
267
|
-
* but keeps only elements from the other stream.
|
268
|
-
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
269
|
-
*
|
270
|
-
* @tsplus pipeable fncts.io.Stream zipRight
|
271
|
-
*/
|
272
|
-
function zipRight_1(that, __tsplusTrace) {
|
273
|
-
return stream => {
|
274
|
-
return crossWith_1(that, (_, b) => b, __tsplusTrace)(stream);
|
275
|
-
};
|
276
|
-
}
|
277
271
|
/**
|
278
272
|
* Maps the success values of this stream to the specified constant value.
|
279
273
|
*
|
@@ -284,57 +278,57 @@ export function as(b, __tsplusTrace) {
|
|
284
278
|
return map_1(() => b(), __tsplusTrace)(stream);
|
285
279
|
};
|
286
280
|
}
|
281
|
+
/**
|
282
|
+
* @tsplus static fncts.io.StreamOps async
|
283
|
+
*/
|
284
|
+
export function async(register, outputBuffer = 16, __tsplusTrace) {
|
285
|
+
return asyncMaybe_1(cb => {
|
286
|
+
register(cb);
|
287
|
+
return tsplus_module_5.nothing(__tsplusTrace);
|
288
|
+
}, outputBuffer, __tsplusTrace);
|
289
|
+
}
|
287
290
|
/**
|
288
291
|
* @tsplus static fncts.io.StreamOps asyncInterrupt
|
289
292
|
*/
|
290
293
|
function asyncInterrupt_1(register, outputBuffer = 16, __tsplusTrace) {
|
291
|
-
return unwrapScoped_1(tsplus_module_1.flatMap(output => tsplus_module_1.flatMap(runtime => tsplus_module_1.map(eitherStream =>
|
292
|
-
const loop =
|
294
|
+
return unwrapScoped_1(tsplus_module_1.flatMap(output => tsplus_module_1.flatMap(runtime => tsplus_module_1.map(eitherStream => tsplus_module_6.match(canceler => {
|
295
|
+
const loop = tsplus_module_12.unwrap(() => tsplus_module_1.match(maybeError => tsplus_module_22.match(() => tsplus_module_13.endNow(undefined), tsplus_module_12.failNow)(maybeError), as => tsplus_module_13.zipRight(loop)(tsplus_module_12.writeNow(as)), __tsplusTrace)(tsplus_module_1.flatMap(take => tsplus_module_29.done(take), __tsplusTrace)(tsplus_module_30.take(output, __tsplusTrace))));
|
293
296
|
return ensuring_1(canceler, __tsplusTrace)(new Stream(loop));
|
294
|
-
}, stream => unwrap_1(tsplus_module_1.as(() => stream, __tsplusTrace)(
|
295
|
-
const effect = tsplus_module_1.flatMap(a =>
|
297
|
+
}, stream => unwrap_1(tsplus_module_1.as(() => stream, __tsplusTrace)(tsplus_module_30.shutdown(output, __tsplusTrace)), __tsplusTrace))(eitherStream), __tsplusTrace)(tsplus_module_1.succeed(() => register((k, cb) => {
|
298
|
+
const effect = tsplus_module_1.flatMap(a => tsplus_module_30.offer(a, __tsplusTrace)(output), __tsplusTrace)(tsplus_module_29.fromPull(k));
|
296
299
|
const fiber = runtime.makeFiber(effect, __tsplusTrace);
|
297
300
|
if (cb) {
|
298
301
|
fiber.addObserver(cb);
|
299
302
|
}
|
300
303
|
fiber.start(effect);
|
301
|
-
}), __tsplusTrace)), __tsplusTrace)(
|
302
|
-
}
|
303
|
-
/**
|
304
|
-
* Creates a stream from an asynchronous callback that can be called multiple times.
|
305
|
-
* The registration of the callback can possibly return the stream synchronously.
|
306
|
-
* The optionality of the error type `E` can be used to signal the end of the stream,
|
307
|
-
* by setting it to `None`.
|
308
|
-
*
|
309
|
-
* @tsplus static fncts.io.StreamOps asyncMaybe
|
310
|
-
*/
|
311
|
-
function asyncMaybe_1(register, outputBuffer = 16, __tsplusTrace) {
|
312
|
-
return asyncInterrupt_1(k => tsplus_module_20.match(() => tsplus_module_18.left(tsplus_module_1.unit, __tsplusTrace), tsplus_module_18.right)(register(k)), outputBuffer, __tsplusTrace);
|
313
|
-
}
|
314
|
-
/**
|
315
|
-
* @tsplus static fncts.io.StreamOps async
|
316
|
-
*/
|
317
|
-
export function async(register, outputBuffer = 16, __tsplusTrace) {
|
318
|
-
return asyncMaybe_1(cb => {
|
319
|
-
register(cb);
|
320
|
-
return tsplus_module_3.nothing(__tsplusTrace);
|
321
|
-
}, outputBuffer, __tsplusTrace);
|
304
|
+
}), __tsplusTrace)), __tsplusTrace)(tsplus_module_31.runtime(__tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeBounded(outputBuffer, __tsplusTrace), queue => tsplus_module_30.shutdown(queue, __tsplusTrace), __tsplusTrace)), __tsplusTrace);
|
322
305
|
}
|
323
306
|
/**
|
324
307
|
* @tsplus static fncts.io.StreamOps asyncIO
|
325
308
|
*/
|
326
309
|
export function asyncIO(register, outputBuffer = 16, __tsplusTrace) {
|
327
|
-
return new Stream(
|
328
|
-
const loop =
|
310
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.flatMap(output => tsplus_module_1.flatMap(runtime => tsplus_module_1.map(() => {
|
311
|
+
const loop = tsplus_module_12.unwrap(() => tsplus_module_1.matchCauseIO(cause => tsplus_module_1.as(() => tsplus_module_6.match(maybeError => tsplus_module_22.match(() => tsplus_module_13.endNow(undefined), tsplus_module_12.failNow)(maybeError), tsplus_module_13.failCauseNow)(tsplus_module_27.failureOrCause(cause)), __tsplusTrace)(tsplus_module_30.shutdown(output, __tsplusTrace)), as => tsplus_module_1.succeed(() => tsplus_module_13.zipRight(loop)(tsplus_module_12.writeNow(as)), __tsplusTrace), __tsplusTrace)(tsplus_module_1.flatMap(take => tsplus_module_29.done(take), __tsplusTrace)(tsplus_module_30.take(output, __tsplusTrace))));
|
329
312
|
return loop;
|
330
313
|
}, __tsplusTrace)(register((k, cb) => {
|
331
|
-
const io = tsplus_module_1.flatMap(a =>
|
314
|
+
const io = tsplus_module_1.flatMap(a => tsplus_module_30.offer(a, __tsplusTrace)(output), __tsplusTrace)(tsplus_module_29.fromPull(k));
|
332
315
|
const fiber = runtime.makeFiber(io, __tsplusTrace);
|
333
316
|
if (cb) {
|
334
317
|
fiber.addObserver(cb);
|
335
318
|
}
|
336
319
|
fiber.start(io);
|
337
|
-
})), __tsplusTrace)(
|
320
|
+
})), __tsplusTrace)(tsplus_module_31.runtime(__tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeBounded(outputBuffer, __tsplusTrace), _ => tsplus_module_30.shutdown(_, __tsplusTrace), __tsplusTrace))));
|
321
|
+
}
|
322
|
+
/**
|
323
|
+
* Creates a stream from an asynchronous callback that can be called multiple times.
|
324
|
+
* The registration of the callback can possibly return the stream synchronously.
|
325
|
+
* The optionality of the error type `E` can be used to signal the end of the stream,
|
326
|
+
* by setting it to `None`.
|
327
|
+
*
|
328
|
+
* @tsplus static fncts.io.StreamOps asyncMaybe
|
329
|
+
*/
|
330
|
+
function asyncMaybe_1(register, outputBuffer = 16, __tsplusTrace) {
|
331
|
+
return asyncInterrupt_1(k => tsplus_module_22.match(() => tsplus_module_20.left(tsplus_module_1.unit, __tsplusTrace), tsplus_module_20.right)(register(k)), outputBuffer, __tsplusTrace);
|
338
332
|
}
|
339
333
|
/**
|
340
334
|
* Returns a stream whose failure and success channels have been mapped by
|
@@ -345,24 +339,6 @@ export function asyncIO(register, outputBuffer = 16, __tsplusTrace) {
|
|
345
339
|
export function bimap(f, g, __tsplusTrace) {
|
346
340
|
return stream => map_1(g, __tsplusTrace)(mapError_1(f, __tsplusTrace)(stream));
|
347
341
|
}
|
348
|
-
/**
|
349
|
-
* Creates a stream from a single value that will get cleaned up after the
|
350
|
-
* stream is consumed
|
351
|
-
*
|
352
|
-
* @tsplus static fncts.io.StreamOps acquireRelease
|
353
|
-
*/
|
354
|
-
export function acquireRelease(acquire, release, __tsplusTrace) {
|
355
|
-
return scoped_1(() => tsplus_module_31.acquireRelease(() => acquire, release, __tsplusTrace), __tsplusTrace);
|
356
|
-
}
|
357
|
-
/**
|
358
|
-
* Creates a stream from a single value that will get cleaned up after the
|
359
|
-
* stream is consumed
|
360
|
-
*
|
361
|
-
* @tsplus static fncts.io.StreamOps acquireReleaseExit
|
362
|
-
*/
|
363
|
-
export function acquireReleaseExit(acquire, release, __tsplusTrace) {
|
364
|
-
return scoped_1(() => tsplus_module_32.acquireReleaseExit(() => acquire, release, __tsplusTrace), __tsplusTrace);
|
365
|
-
}
|
366
342
|
/**
|
367
343
|
* Fan out the stream, producing a list of streams that have the same elements as this stream.
|
368
344
|
* The driver stream will only ever advance of the `maximumLag` chunks before the
|
@@ -372,7 +348,7 @@ export function acquireReleaseExit(acquire, release, __tsplusTrace) {
|
|
372
348
|
*/
|
373
349
|
export function broadcast(n, maximumLag, __tsplusTrace) {
|
374
350
|
return stream => {
|
375
|
-
return tsplus_module_1.map(c =>
|
351
|
+
return tsplus_module_1.map(c => tsplus_module_14.map(hub => flattenTake_1(fromQueueWithShutdown_1(hub), __tsplusTrace))(c), __tsplusTrace)(broadcastedQueues_1(n, maximumLag, __tsplusTrace)(stream));
|
376
352
|
};
|
377
353
|
}
|
378
354
|
/**
|
@@ -422,8 +398,8 @@ function broadcastedQueuesDynamic_1(maximumLag, __tsplusTrace) {
|
|
422
398
|
export function buffer(capacity, __tsplusTrace) {
|
423
399
|
return stream => {
|
424
400
|
const queue = toQueueOfElements_1(capacity, __tsplusTrace)(stream);
|
425
|
-
return new Stream(
|
426
|
-
const process =
|
401
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(queue => {
|
402
|
+
const process = tsplus_module_13.flatMap(exit => tsplus_module_36.match(cause => tsplus_module_22.match(() => tsplus_module_13.endNow(undefined), tsplus_module_13.failCauseNow)(tsplus_module_27.flipCauseOption(cause)), value => tsplus_module_13.zipRight(process)(tsplus_module_12.writeNow(tsplus_module_21.single(value))))(exit))(tsplus_module_12.fromIO(() => tsplus_module_30.take(queue, __tsplusTrace)));
|
427
403
|
return process;
|
428
404
|
}, __tsplusTrace)(queue)));
|
429
405
|
};
|
@@ -434,12 +410,20 @@ export function buffer(capacity, __tsplusTrace) {
|
|
434
410
|
export function bufferChunks(capacity, __tsplusTrace) {
|
435
411
|
return stream => {
|
436
412
|
const queue = toQueue_1(capacity, __tsplusTrace)(stream);
|
437
|
-
return new Stream(
|
438
|
-
const process =
|
413
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(queue => {
|
414
|
+
const process = tsplus_module_13.flatMap(take => tsplus_module_29.match(tsplus_module_13.endNow(undefined), tsplus_module_13.failCauseNow, value => tsplus_module_13.zipRight(process)(tsplus_module_12.writeNow(value)))(take))(tsplus_module_12.fromIO(() => tsplus_module_30.take(queue, __tsplusTrace)));
|
439
415
|
return process;
|
440
416
|
}, __tsplusTrace)(queue)));
|
441
417
|
};
|
442
418
|
}
|
419
|
+
function bufferSignalConsumer(queue, __tsplusTrace) {
|
420
|
+
const process = tsplus_module_13.flatMap(([take, promise]) => tsplus_module_13.zipRight(tsplus_module_29.match(tsplus_module_13.endNow(undefined), tsplus_module_13.failCauseNow, value => tsplus_module_13.zipRight(process)(tsplus_module_12.writeNow(value)))(take))(tsplus_module_12.fromIO(() => tsplus_module_37.succeed_(undefined, __tsplusTrace)(promise))))(tsplus_module_12.fromIO(() => tsplus_module_30.take(queue, __tsplusTrace)));
|
421
|
+
return process;
|
422
|
+
}
|
423
|
+
function bufferSignalProducer(queue, ref, __tsplusTrace) {
|
424
|
+
const terminate = take => tsplus_module_12.fromIO(() => tsplus_module_1.flatMap(latch => tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(p => tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => void 0, __tsplusTrace)(tsplus_module_37.wait(p, __tsplusTrace)), __tsplusTrace)(tsplus_module_15.set(p, __tsplusTrace)(ref)), __tsplusTrace)(tsplus_module_30.offer(tuple(take, p), __tsplusTrace)(queue)), __tsplusTrace)(tsplus_module_38.make(__tsplusTrace)), __tsplusTrace)(tsplus_module_37.wait(latch, __tsplusTrace)), __tsplusTrace)(tsplus_module_16.get(ref, __tsplusTrace)));
|
425
|
+
return tsplus_module_12.readWith(inp => tsplus_module_13.zipRight(bufferSignalProducer(queue, ref, __tsplusTrace))(tsplus_module_12.fromIO(() => tsplus_module_1.flatMap(p => tsplus_module_1.flatMap(added => tsplus_module_1.map(() => void 0, __tsplusTrace)(tsplus_module_1.when(() => added, __tsplusTrace)(tsplus_module_15.set(p, __tsplusTrace)(ref))), __tsplusTrace)(tsplus_module_30.offer(tuple(tsplus_module_29.chunk(inp), p), __tsplusTrace)(queue)), __tsplusTrace)(tsplus_module_38.make(__tsplusTrace)))), e => terminate(tsplus_module_29.fail(e)), () => terminate(tsplus_module_29.end));
|
426
|
+
}
|
443
427
|
/**
|
444
428
|
* Allows a faster producer to progress independently of a slower consumer by buffering
|
445
429
|
* elements into an unbounded queue.
|
@@ -448,19 +432,11 @@ export function bufferChunks(capacity, __tsplusTrace) {
|
|
448
432
|
*/
|
449
433
|
export function bufferUnbounded(stream, __tsplusTrace) {
|
450
434
|
const queue = toQueueUnbounded_1(stream, __tsplusTrace);
|
451
|
-
return new Stream(
|
452
|
-
const process =
|
435
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(queue => {
|
436
|
+
const process = tsplus_module_13.flatMap(take => tsplus_module_29.match(tsplus_module_13.endNow(undefined), tsplus_module_13.failCauseNow, value => tsplus_module_13.zipRight(process)(tsplus_module_12.writeNow(value)))(take))(tsplus_module_12.fromIO(() => tsplus_module_30.take(queue, __tsplusTrace)));
|
453
437
|
return process;
|
454
438
|
}, __tsplusTrace)(queue)));
|
455
439
|
}
|
456
|
-
function bufferSignalProducer(queue, ref, __tsplusTrace) {
|
457
|
-
const terminate = take => tsplus_module_10.fromIO(() => tsplus_module_1.flatMap(latch => tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(p => tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => void 0, __tsplusTrace)(tsplus_module_37.wait(p, __tsplusTrace)), __tsplusTrace)(tsplus_module_13.set(p, __tsplusTrace)(ref)), __tsplusTrace)(tsplus_module_28.offer(tuple(take, p), __tsplusTrace)(queue)), __tsplusTrace)(tsplus_module_38.make(__tsplusTrace)), __tsplusTrace)(tsplus_module_37.wait(latch, __tsplusTrace)), __tsplusTrace)(tsplus_module_14.get(ref, __tsplusTrace)));
|
458
|
-
return tsplus_module_10.readWith(inp => tsplus_module_11.zipRight(bufferSignalProducer(queue, ref, __tsplusTrace))(tsplus_module_10.fromIO(() => tsplus_module_1.flatMap(p => tsplus_module_1.flatMap(added => tsplus_module_1.map(() => void 0, __tsplusTrace)(tsplus_module_1.when(() => added, __tsplusTrace)(tsplus_module_13.set(p, __tsplusTrace)(ref))), __tsplusTrace)(tsplus_module_28.offer(tuple(tsplus_module_27.chunk(inp), p), __tsplusTrace)(queue)), __tsplusTrace)(tsplus_module_38.make(__tsplusTrace)))), e => terminate(tsplus_module_27.fail(e)), () => terminate(tsplus_module_27.end));
|
459
|
-
}
|
460
|
-
function bufferSignalConsumer(queue, __tsplusTrace) {
|
461
|
-
const process = tsplus_module_11.flatMap(([take, promise]) => tsplus_module_11.zipRight(tsplus_module_27.match(tsplus_module_11.endNow(undefined), tsplus_module_11.failCauseNow, value => tsplus_module_11.zipRight(process)(tsplus_module_10.writeNow(value)))(take))(tsplus_module_10.fromIO(() => tsplus_module_37.succeed_(undefined, __tsplusTrace)(promise))))(tsplus_module_10.fromIO(() => tsplus_module_28.take(queue, __tsplusTrace)));
|
462
|
-
return process;
|
463
|
-
}
|
464
440
|
/**
|
465
441
|
* Switches over to the stream produced by the provided function in case this one
|
466
442
|
* fails with a typed error.
|
@@ -469,7 +445,7 @@ function bufferSignalConsumer(queue, __tsplusTrace) {
|
|
469
445
|
*/
|
470
446
|
function catchAll_1(f, __tsplusTrace) {
|
471
447
|
return stream => {
|
472
|
-
return catchAllCause_1(cause =>
|
448
|
+
return catchAllCause_1(cause => tsplus_module_6.match(f, failCauseNow_1)(tsplus_module_27.failureOrCause(cause)), __tsplusTrace)(stream);
|
473
449
|
};
|
474
450
|
}
|
475
451
|
/**
|
@@ -481,7 +457,7 @@ function catchAll_1(f, __tsplusTrace) {
|
|
481
457
|
*/
|
482
458
|
function catchAllCause_1(f, __tsplusTrace) {
|
483
459
|
return stream => {
|
484
|
-
const channel =
|
460
|
+
const channel = tsplus_module_12.catchAllCause(cause => f(cause).channel)(stream.channel);
|
485
461
|
return new Stream(channel);
|
486
462
|
};
|
487
463
|
}
|
@@ -509,23 +485,30 @@ export function catchJustCause(pf, __tsplusTrace) {
|
|
509
485
|
};
|
510
486
|
}
|
511
487
|
/**
|
512
|
-
* Returns a stream
|
513
|
-
*
|
488
|
+
* Returns a new stream that only emits elements that are not equal to the
|
489
|
+
* previous element emitted, using the specified function to determine
|
490
|
+
* whether two elements are equal.
|
514
491
|
*
|
515
|
-
* @tsplus pipeable fncts.io.Stream
|
492
|
+
* @tsplus pipeable fncts.io.Stream changesWith
|
516
493
|
*/
|
517
|
-
function
|
494
|
+
export function changesWith(f, __tsplusTrace) {
|
518
495
|
return stream => {
|
519
|
-
return new Stream(
|
496
|
+
return new Stream(tsplus_module_12.pipeTo(changesWithWriter(f, tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace))(stream.channel));
|
520
497
|
};
|
521
498
|
}
|
499
|
+
function changesWithWriter(f, last, __tsplusTrace) {
|
500
|
+
return tsplus_module_12.readWithCause(chunk => {
|
501
|
+
const [newLast, newChunk] = tsplus_module_14.foldLeft([last, tsplus_module_9.empty()], ([maybeLast, os], o1) => tsplus_module_22.match(() => [tsplus_module_5.just(o1, __tsplusTrace), tsplus_module_14.append(o1)(os)], o => f(o, o1) ? [tsplus_module_5.just(o1, __tsplusTrace), os] : [tsplus_module_5.just(o1, __tsplusTrace), tsplus_module_14.append(o1)(os)])(maybeLast))(chunk);
|
502
|
+
return tsplus_module_13.zipRight(changesWithWriter(f, newLast, __tsplusTrace))(tsplus_module_12.writeNow(newChunk));
|
503
|
+
}, tsplus_module_13.failCauseNow, () => tsplus_module_12.unit);
|
504
|
+
}
|
522
505
|
/**
|
523
506
|
* Exposes the underlying chunks of the stream as a stream of chunks of elements
|
524
507
|
*
|
525
508
|
* @tsplus getter fncts.io.Stream chunks
|
526
509
|
*/
|
527
510
|
function chunks_1(stream, __tsplusTrace) {
|
528
|
-
return mapChunks_1(
|
511
|
+
return mapChunks_1(tsplus_module_21.single, __tsplusTrace)(stream);
|
529
512
|
}
|
530
513
|
/**
|
531
514
|
* Performs the specified stream transformation with the chunk structure of
|
@@ -538,24 +521,6 @@ export function chunksWith(f, __tsplusTrace) {
|
|
538
521
|
return flattenChunks_1(f(chunks_1(self, __tsplusTrace)), __tsplusTrace);
|
539
522
|
};
|
540
523
|
}
|
541
|
-
function changesWithWriter(f, last, __tsplusTrace) {
|
542
|
-
return tsplus_module_10.readWithCause(chunk => {
|
543
|
-
const [newLast, newChunk] = tsplus_module_12.foldLeft([last, tsplus_module_7.empty()], ([maybeLast, os], o1) => tsplus_module_20.match(() => [tsplus_module_3.just(o1, __tsplusTrace), tsplus_module_12.append(o1)(os)], o => f(o, o1) ? [tsplus_module_3.just(o1, __tsplusTrace), os] : [tsplus_module_3.just(o1, __tsplusTrace), tsplus_module_12.append(o1)(os)])(maybeLast))(chunk);
|
544
|
-
return tsplus_module_11.zipRight(changesWithWriter(f, newLast, __tsplusTrace))(tsplus_module_10.writeNow(newChunk));
|
545
|
-
}, tsplus_module_11.failCauseNow, () => tsplus_module_10.unit);
|
546
|
-
}
|
547
|
-
/**
|
548
|
-
* Returns a new stream that only emits elements that are not equal to the
|
549
|
-
* previous element emitted, using the specified function to determine
|
550
|
-
* whether two elements are equal.
|
551
|
-
*
|
552
|
-
* @tsplus pipeable fncts.io.Stream changesWith
|
553
|
-
*/
|
554
|
-
export function changesWith(f, __tsplusTrace) {
|
555
|
-
return stream => {
|
556
|
-
return new Stream(tsplus_module_10.pipeTo(changesWithWriter(f, tsplus_module_3.nothing(__tsplusTrace), __tsplusTrace))(stream.channel));
|
557
|
-
};
|
558
|
-
}
|
559
524
|
/**
|
560
525
|
* Transforms all elements of the stream for as long as the specified partial function is defined.
|
561
526
|
*
|
@@ -563,34 +528,31 @@ export function changesWith(f, __tsplusTrace) {
|
|
563
528
|
*/
|
564
529
|
export function collectWhile(pf, __tsplusTrace) {
|
565
530
|
return stream => {
|
566
|
-
const loop =
|
567
|
-
const mapped =
|
531
|
+
const loop = tsplus_module_12.readWith(inp => {
|
532
|
+
const mapped = tsplus_module_14.collectWhile(pf)(inp);
|
568
533
|
if (mapped.length === inp.length) {
|
569
|
-
return
|
534
|
+
return tsplus_module_13.zipRight(loop)(tsplus_module_12.writeNow(mapped));
|
570
535
|
} else {
|
571
|
-
return
|
536
|
+
return tsplus_module_12.writeNow(mapped);
|
572
537
|
}
|
573
|
-
},
|
574
|
-
return new Stream(
|
538
|
+
}, tsplus_module_12.failNow, tsplus_module_13.succeedNow);
|
539
|
+
return new Stream(tsplus_module_12.pipeTo(loop)(stream.channel));
|
575
540
|
};
|
576
541
|
}
|
577
542
|
/**
|
578
543
|
* Effectfully transforms all elements of the stream for as long as the specified partial function is defined.
|
579
544
|
*/
|
580
545
|
export function collectWhileIO(stream, pf, __tsplusTrace) {
|
581
|
-
return new Stream(
|
546
|
+
return new Stream(tsplus_module_12.pipeTo(collectWhileIOLoop(tsplus_module_40.empty()[Symbol.iterator](), pf, __tsplusTrace))(stream.channel));
|
582
547
|
}
|
583
548
|
function collectWhileIOLoop(iterator, pf, __tsplusTrace) {
|
584
549
|
const next = iterator.next();
|
585
550
|
if (next.done) {
|
586
|
-
return
|
551
|
+
return tsplus_module_12.readWithCause(elem => collectWhileIOLoop(elem[Symbol.iterator](), pf, __tsplusTrace), tsplus_module_13.failCauseNow, tsplus_module_13.succeedNow);
|
587
552
|
} else {
|
588
|
-
return
|
553
|
+
return tsplus_module_12.unwrap(() => tsplus_module_22.match(() => tsplus_module_1.succeedNow(tsplus_module_12.unit, __tsplusTrace), b => tsplus_module_1.map(b => tsplus_module_13.zipRight(collectWhileIOLoop(iterator, pf, __tsplusTrace))(tsplus_module_12.writeNow(tsplus_module_21.single(b))), __tsplusTrace)(b))(pf(next.value)));
|
589
554
|
}
|
590
555
|
}
|
591
|
-
function combineProducer(handoff, latch, __tsplusTrace) {
|
592
|
-
return tsplus_module_11.zipRight(tsplus_module_10.readWithCause(value => tsplus_module_11.zipRight(combineProducer(handoff, latch, __tsplusTrace))(tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_41.succeed(value, __tsplusTrace))(handoff))), cause => tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_41.failCause(tsplus_module_25.map(tsplus_module_3.just)(cause), __tsplusTrace))(handoff)), () => tsplus_module_11.zipRight(combineProducer(handoff, latch, __tsplusTrace))(tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_41.fail(tsplus_module_3.nothing(__tsplusTrace), __tsplusTrace))(handoff)))))(tsplus_module_10.fromIO(() => tsplus_module_5.take(latch)));
|
593
|
-
}
|
594
556
|
/**
|
595
557
|
* Combines the elements from this stream and the specified stream by repeatedly applying the
|
596
558
|
* function `f` to extract an element using both sides and conceptually "offer"
|
@@ -603,16 +565,13 @@ function combineProducer(handoff, latch, __tsplusTrace) {
|
|
603
565
|
*/
|
604
566
|
export function combine(that, s, f, __tsplusTrace) {
|
605
567
|
return stream => {
|
606
|
-
return new Stream(
|
607
|
-
const pullLeft = tsplus_module_1.flatMap(tsplus_module_1.fromExitNow, __tsplusTrace)(tsplus_module_1.zipRight(
|
608
|
-
const pullRight = tsplus_module_1.flatMap(tsplus_module_1.fromExitNow, __tsplusTrace)(tsplus_module_1.zipRight(
|
568
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(([left, right, latchL, latchR]) => {
|
569
|
+
const pullLeft = tsplus_module_1.flatMap(tsplus_module_1.fromExitNow, __tsplusTrace)(tsplus_module_1.zipRight(tsplus_module_7.take(left), __tsplusTrace)(tsplus_module_7.offer(undefined)(latchL)));
|
570
|
+
const pullRight = tsplus_module_1.flatMap(tsplus_module_1.fromExitNow, __tsplusTrace)(tsplus_module_1.zipRight(tsplus_module_7.take(right), __tsplusTrace)(tsplus_module_7.offer(undefined)(latchR)));
|
609
571
|
return unfoldIO_1(s, s => tsplus_module_1.flatMap(exit => tsplus_module_1.optional(tsplus_module_1.fromExitNow(exit, __tsplusTrace), __tsplusTrace), __tsplusTrace)(f(s, pullLeft, pullRight)), __tsplusTrace).channel;
|
610
|
-
}, __tsplusTrace)(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => tsplus_module_1.flatMap(latchL => tsplus_module_1.flatMap(latchR => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => tuple(left, right, latchL, latchR), __tsplusTrace)(tsplus_module_33.fork(
|
572
|
+
}, __tsplusTrace)(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => tsplus_module_1.flatMap(latchL => tsplus_module_1.flatMap(latchR => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => tuple(left, right, latchL, latchR), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(combineProducer(right, latchR, __tsplusTrace))(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(that.channel))), __tsplusTrace)), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(combineProducer(left, latchL, __tsplusTrace))(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(stream.channel))), __tsplusTrace)), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()))));
|
611
573
|
};
|
612
574
|
}
|
613
|
-
function combineChunksProducer(handoff, latch, __tsplusTrace) {
|
614
|
-
return tsplus_module_11.zipRight(tsplus_module_10.readWithCause(chunk => tsplus_module_11.zipRight(combineChunksProducer(handoff, latch, __tsplusTrace))(tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_27.chunk(chunk))(handoff))), cause => tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_27.failCause(cause))(handoff)), () => tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_27.end)(handoff))))(tsplus_module_10.fromIO(() => tsplus_module_5.take(latch)));
|
615
|
-
}
|
616
575
|
/**
|
617
576
|
* Combines the chunks from this stream and the specified stream by repeatedly applying the
|
618
577
|
* function `f` to extract a chunk using both sides and conceptually "offer"
|
@@ -623,13 +582,19 @@ function combineChunksProducer(handoff, latch, __tsplusTrace) {
|
|
623
582
|
*/
|
624
583
|
export function combineChunks(that, s, f, __tsplusTrace) {
|
625
584
|
return stream => {
|
626
|
-
return new Stream(
|
627
|
-
const pullLeft = tsplus_module_1.flatMap(take =>
|
628
|
-
const pullRight = tsplus_module_1.flatMap(take =>
|
585
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(([left, right, latchL, latchR]) => {
|
586
|
+
const pullLeft = tsplus_module_1.flatMap(take => tsplus_module_29.done(take), __tsplusTrace)(tsplus_module_1.zipRight(tsplus_module_7.take(left), __tsplusTrace)(tsplus_module_7.offer(undefined)(latchL)));
|
587
|
+
const pullRight = tsplus_module_1.flatMap(take => tsplus_module_29.done(take), __tsplusTrace)(tsplus_module_1.zipRight(tsplus_module_7.take(right), __tsplusTrace)(tsplus_module_7.offer(undefined)(latchR)));
|
629
588
|
return unfoldChunkIO_1(s, s => tsplus_module_1.flatMap(exit => tsplus_module_1.optional(tsplus_module_1.fromExit(() => exit, __tsplusTrace), __tsplusTrace), __tsplusTrace)(f(s, pullLeft, pullRight)), __tsplusTrace).channel;
|
630
|
-
}, __tsplusTrace)(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => tsplus_module_1.flatMap(latchL => tsplus_module_1.flatMap(latchR => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => tuple(left, right, latchL, latchR), __tsplusTrace)(tsplus_module_33.fork(
|
589
|
+
}, __tsplusTrace)(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => tsplus_module_1.flatMap(latchL => tsplus_module_1.flatMap(latchR => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => tuple(left, right, latchL, latchR), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(combineChunksProducer(right, latchR, __tsplusTrace))(that.channel)), __tsplusTrace)), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(combineChunksProducer(left, latchL, __tsplusTrace))(stream.channel)), __tsplusTrace)), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()))));
|
631
590
|
};
|
632
591
|
}
|
592
|
+
function combineChunksProducer(handoff, latch, __tsplusTrace) {
|
593
|
+
return tsplus_module_13.zipRight(tsplus_module_12.readWithCause(chunk => tsplus_module_13.zipRight(combineChunksProducer(handoff, latch, __tsplusTrace))(tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_29.chunk(chunk))(handoff))), cause => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_29.failCause(cause))(handoff)), () => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_29.end)(handoff))))(tsplus_module_12.fromIO(() => tsplus_module_7.take(latch)));
|
594
|
+
}
|
595
|
+
function combineProducer(handoff, latch, __tsplusTrace) {
|
596
|
+
return tsplus_module_13.zipRight(tsplus_module_12.readWithCause(value => tsplus_module_13.zipRight(combineProducer(handoff, latch, __tsplusTrace))(tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_41.succeed(value, __tsplusTrace))(handoff))), cause => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_41.failCause(tsplus_module_27.map(tsplus_module_5.just)(cause), __tsplusTrace))(handoff)), () => tsplus_module_13.zipRight(combineProducer(handoff, latch, __tsplusTrace))(tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_41.fail(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace))(handoff)))))(tsplus_module_12.fromIO(() => tsplus_module_7.take(latch)));
|
597
|
+
}
|
633
598
|
/**
|
634
599
|
* Concatenates the specified stream with this stream, resulting in a stream
|
635
600
|
* that emits the elements from this stream and then the elements from the specified stream.
|
@@ -638,7 +603,18 @@ export function combineChunks(that, s, f, __tsplusTrace) {
|
|
638
603
|
*/
|
639
604
|
function concat_1(that, __tsplusTrace) {
|
640
605
|
return stream => {
|
641
|
-
return new Stream(
|
606
|
+
return new Stream(tsplus_module_13.zipRight(that.channel)(stream.channel));
|
607
|
+
};
|
608
|
+
}
|
609
|
+
/**
|
610
|
+
* Provides some of the environment required to run this effect,
|
611
|
+
* leaving the remainder `R0`.
|
612
|
+
*
|
613
|
+
* @tsplus pipeable fncts.io.Stream contramapEnvironment
|
614
|
+
*/
|
615
|
+
export function contramapEnvironment(f, __tsplusTrace) {
|
616
|
+
return ra => {
|
617
|
+
return flatMap_1(r0 => provideEnvironment_1(f(r0), __tsplusTrace)(ra), __tsplusTrace)(environment_1(__tsplusTrace));
|
642
618
|
};
|
643
619
|
}
|
644
620
|
/**
|
@@ -649,7 +625,7 @@ function concat_1(that, __tsplusTrace) {
|
|
649
625
|
*/
|
650
626
|
export function cross(that, __tsplusTrace) {
|
651
627
|
return stream => {
|
652
|
-
return new Stream(
|
628
|
+
return new Stream(tsplus_module_12.concatMap(as => tsplus_module_12.mapOut(bs => tsplus_module_14.flatMap(a => tsplus_module_14.map(b => tuple(a, b))(bs))(as))(that.channel))(stream.channel));
|
653
629
|
};
|
654
630
|
}
|
655
631
|
/**
|
@@ -664,17 +640,6 @@ function crossWith_1(fb, f, __tsplusTrace) {
|
|
664
640
|
return flatMap_1(a => map_1(b => f(a, b), __tsplusTrace)(fb), __tsplusTrace)(fa);
|
665
641
|
};
|
666
642
|
}
|
667
|
-
/**
|
668
|
-
* Provides some of the environment required to run this effect,
|
669
|
-
* leaving the remainder `R0`.
|
670
|
-
*
|
671
|
-
* @tsplus pipeable fncts.io.Stream contramapEnvironment
|
672
|
-
*/
|
673
|
-
export function contramapEnvironment(f, __tsplusTrace) {
|
674
|
-
return ra => {
|
675
|
-
return flatMap_1(r0 => provideEnvironment_1(f(r0), __tsplusTrace)(ra), __tsplusTrace)(environment_1(__tsplusTrace));
|
676
|
-
};
|
677
|
-
}
|
678
643
|
/**
|
679
644
|
* @tsplus pipeable fncts.io.Stream debounce
|
680
645
|
*/
|
@@ -682,57 +647,48 @@ export function debounce(duration, __tsplusTrace) {
|
|
682
647
|
return stream => {
|
683
648
|
return unwrap_1(tsplus_module_44.transplant(grafter => tsplus_module_1.map(handoff => {
|
684
649
|
function enqueue(last, __tsplusTrace) {
|
685
|
-
return tsplus_module_1.map(f => consumer(tsplus_module_42.previous(f), __tsplusTrace), __tsplusTrace)(grafter(tsplus_module_33.fork(tsplus_module_1.as(() => last, __tsplusTrace)(tsplus_module_43.sleep(duration, __tsplusTrace)), __tsplusTrace)));
|
650
|
+
return tsplus_module_1.map(f => consumer(tsplus_module_42.previous(f), __tsplusTrace), __tsplusTrace)(grafter.graft(tsplus_module_33.fork(tsplus_module_1.as(() => last, __tsplusTrace)(tsplus_module_43.sleep(duration, __tsplusTrace)), __tsplusTrace), __tsplusTrace));
|
686
651
|
}
|
687
|
-
const producer =
|
652
|
+
const producer = tsplus_module_12.readWithCause(inp => tsplus_module_22.match(() => producer, last => tsplus_module_13.zipRight(producer)(tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_7.emit(tsplus_module_21.single(last)))(handoff))))(tsplus_module_14.last(inp)), cause => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_7.halt(cause))(handoff)), () => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_7.end(new UpstreamEnd()))(handoff)));
|
688
653
|
function consumer(state, __tsplusTrace) {
|
689
|
-
return
|
690
|
-
NotStarted: () => tsplus_module_1.map(signal =>
|
654
|
+
return tsplus_module_12.unwrap(() => tsplus_module_42.match({
|
655
|
+
NotStarted: () => tsplus_module_1.map(signal => tsplus_module_7.matchSignal({
|
691
656
|
Emit: ({
|
692
657
|
els
|
693
|
-
}) =>
|
658
|
+
}) => tsplus_module_12.unwrap(() => enqueue(els, __tsplusTrace)),
|
694
659
|
Halt: ({
|
695
660
|
error
|
696
|
-
}) =>
|
697
|
-
End: () =>
|
698
|
-
})(signal), __tsplusTrace)(
|
661
|
+
}) => tsplus_module_13.failCauseNow(error),
|
662
|
+
End: () => tsplus_module_12.unit
|
663
|
+
})(signal), __tsplusTrace)(tsplus_module_7.take(handoff)),
|
699
664
|
Current: ({
|
700
665
|
fiber
|
701
|
-
}) => tsplus_module_1.map(signal =>
|
666
|
+
}) => tsplus_module_1.map(signal => tsplus_module_7.matchSignal({
|
702
667
|
Emit: ({
|
703
668
|
els
|
704
|
-
}) =>
|
669
|
+
}) => tsplus_module_12.unwrap(() => enqueue(els, __tsplusTrace)),
|
705
670
|
Halt: ({
|
706
671
|
error
|
707
|
-
}) =>
|
708
|
-
End: () =>
|
709
|
-
})(signal), __tsplusTrace)(
|
672
|
+
}) => tsplus_module_13.failCauseNow(error),
|
673
|
+
End: () => tsplus_module_12.unit
|
674
|
+
})(signal), __tsplusTrace)(tsplus_module_24.join(fiber, __tsplusTrace)),
|
710
675
|
Previous: ({
|
711
676
|
fiber
|
712
|
-
}) =>
|
677
|
+
}) => tsplus_module_28.raceWith(() => tsplus_module_7.take(handoff), (ex, current) => tsplus_module_36.match(cause => tsplus_module_1.as(() => tsplus_module_13.failCauseNow(cause), __tsplusTrace)(tsplus_module_25.interrupt(current)), chunk => tsplus_module_1.succeedNow(tsplus_module_13.zipRight(consumer(tsplus_module_42.current(current), __tsplusTrace))(tsplus_module_12.writeNow(chunk)), __tsplusTrace))(ex), (ex, previous) => tsplus_module_36.match(cause => tsplus_module_1.as(() => tsplus_module_13.failCauseNow(cause), __tsplusTrace)(tsplus_module_25.interrupt(previous)), signal => tsplus_module_7.matchSignal({
|
713
678
|
Emit: ({
|
714
679
|
els
|
715
|
-
}) => tsplus_module_1.zipRight(enqueue(els, __tsplusTrace), __tsplusTrace)(
|
680
|
+
}) => tsplus_module_1.zipRight(enqueue(els, __tsplusTrace), __tsplusTrace)(tsplus_module_25.interrupt(previous)),
|
716
681
|
Halt: ({
|
717
682
|
error
|
718
|
-
}) => tsplus_module_1.as(() =>
|
719
|
-
End: () => tsplus_module_1.map(chunk =>
|
720
|
-
})(signal))(ex), __tsplusTrace)(
|
683
|
+
}) => tsplus_module_1.as(() => tsplus_module_13.failCauseNow(error), __tsplusTrace)(tsplus_module_25.interrupt(previous)),
|
684
|
+
End: () => tsplus_module_1.map(chunk => tsplus_module_13.zipRight(tsplus_module_12.unit)(tsplus_module_12.writeNow(chunk)), __tsplusTrace)(tsplus_module_24.join(previous, __tsplusTrace))
|
685
|
+
})(signal))(ex), __tsplusTrace)(tsplus_module_24.join(fiber, __tsplusTrace))
|
721
686
|
})(state));
|
722
687
|
}
|
723
|
-
return zipRight_1(new Stream(consumer(tsplus_module_42.notStarted, __tsplusTrace)), __tsplusTrace)(scoped_1(() => tsplus_module_33.fork(
|
724
|
-
}, __tsplusTrace)(
|
688
|
+
return zipRight_1(new Stream(consumer(tsplus_module_42.notStarted, __tsplusTrace)), __tsplusTrace)(scoped_1(() => tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(producer)(stream.channel)), __tsplusTrace), __tsplusTrace));
|
689
|
+
}, __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace), __tsplusTrace);
|
725
690
|
};
|
726
691
|
}
|
727
|
-
/**
|
728
|
-
* @tsplus static fncts.io.StreamOps defer
|
729
|
-
*/
|
730
|
-
function defer_1(self) {
|
731
|
-
return new Stream(tsplus_module_10.defer(() => self().channel));
|
732
|
-
}
|
733
|
-
function defaultIfEmptyWriter(fb, __tsplusTrace) {
|
734
|
-
return tsplus_module_10.readWith(i => tsplus_module_12.isEmpty(i) ? defaultIfEmptyWriter(fb, __tsplusTrace) : tsplus_module_11.zipRight(tsplus_module_10.id())(tsplus_module_10.writeNow(i)), tsplus_module_10.failNow, () => fb.channel);
|
735
|
-
}
|
736
692
|
/**
|
737
693
|
* Switches to the provided stream in case this one is empty.
|
738
694
|
*
|
@@ -740,9 +696,18 @@ function defaultIfEmptyWriter(fb, __tsplusTrace) {
|
|
740
696
|
*/
|
741
697
|
export function defaultIfEmpty(fb, __tsplusTrace) {
|
742
698
|
return fa => {
|
743
|
-
return new Stream(
|
699
|
+
return new Stream(tsplus_module_12.pipeTo(defaultIfEmptyWriter(fb, __tsplusTrace))(fa.channel));
|
744
700
|
};
|
745
701
|
}
|
702
|
+
function defaultIfEmptyWriter(fb, __tsplusTrace) {
|
703
|
+
return tsplus_module_12.readWith(i => tsplus_module_14.isEmpty(i) ? defaultIfEmptyWriter(fb, __tsplusTrace) : tsplus_module_13.zipRight(tsplus_module_12.id())(tsplus_module_12.writeNow(i)), tsplus_module_12.failNow, () => fb.channel);
|
704
|
+
}
|
705
|
+
/**
|
706
|
+
* @tsplus static fncts.io.StreamOps defer
|
707
|
+
*/
|
708
|
+
function defer_1(self) {
|
709
|
+
return new Stream(tsplus_module_12.defer(() => self().channel));
|
710
|
+
}
|
746
711
|
/**
|
747
712
|
* More powerful version of `broadcast`. Allows to provide a function that determines what
|
748
713
|
* queues should receive which elements. The decide function will receive the indices of the queues
|
@@ -753,9 +718,9 @@ export function defaultIfEmpty(fb, __tsplusTrace) {
|
|
753
718
|
export function distributedWith(n, maximumLag, decide, __tsplusTrace) {
|
754
719
|
return self => {
|
755
720
|
return tsplus_module_1.flatMap(p => tsplus_module_1.flatMap(next => tsplus_module_1.flatMap(entries => {
|
756
|
-
const [mappings, queues] =
|
721
|
+
const [mappings, queues] = tsplus_module_14.foldRight([tsplus_module_45.empty(), tsplus_module_9.empty()], ([mapping, queue], [mappings, queues]) => [tsplus_module_45.set(mapping[0], mapping[1])(mappings), tsplus_module_14.append(queue)(queues)])(entries);
|
757
722
|
return tsplus_module_1.as(() => queues, __tsplusTrace)(tsplus_module_37.succeed_(a => tsplus_module_1.map(f => key => f(tsplus_module_39.toUndefined(tsplus_module_45.get(key)(mappings))), __tsplusTrace)(decide(a)), __tsplusTrace)(p));
|
758
|
-
}, __tsplusTrace)(tsplus_module_1.sequenceIterable(
|
723
|
+
}, __tsplusTrace)(tsplus_module_1.sequenceIterable(tsplus_module_14.map(id => tsplus_module_1.map(([key, queue]) => [[key, id], queue], __tsplusTrace)(next))(tsplus_module_21.range(0, n)), __tsplusTrace)), __tsplusTrace)(distributedWithDynamic_1(maximumLag, a => tsplus_module_1.flatMap(f => f(a), __tsplusTrace)(tsplus_module_37.wait(p, __tsplusTrace)), () => tsplus_module_1.unit, __tsplusTrace)(self)), __tsplusTrace)(tsplus_module_38.make(__tsplusTrace));
|
759
724
|
};
|
760
725
|
}
|
761
726
|
/**
|
@@ -770,20 +735,20 @@ export function distributedWith(n, maximumLag, decide, __tsplusTrace) {
|
|
770
735
|
*/
|
771
736
|
function distributedWithDynamic_1(maximumLag, decide, done = () => tsplus_module_1.unit, __tsplusTrace) {
|
772
737
|
return self => {
|
773
|
-
const offer = queuesRef => a => tsplus_module_1.flatMap(shouldProcess => tsplus_module_1.flatMap(queues => tsplus_module_1.flatMap(ids =>
|
738
|
+
const offer = queuesRef => a => tsplus_module_1.flatMap(shouldProcess => tsplus_module_1.flatMap(queues => tsplus_module_1.flatMap(ids => tsplus_module_14.isNonEmpty(ids) ? tsplus_module_17.update(map => tsplus_module_45.removeMany(ids)(map), __tsplusTrace)(queuesRef) : tsplus_module_1.unit, __tsplusTrace)(tsplus_module_1.foldLeft(queues, tsplus_module_9.empty(), (b, [id, queue]) => {
|
774
739
|
if (shouldProcess(id)) {
|
775
|
-
return tsplus_module_1.matchCauseIO(c =>
|
740
|
+
return tsplus_module_1.matchCauseIO(c => tsplus_module_27.interrupted(c) ? tsplus_module_1.succeedNow(tsplus_module_14.append(id)(b), __tsplusTrace) : tsplus_module_1.failCauseNow(c, __tsplusTrace), () => tsplus_module_1.succeedNow(b, __tsplusTrace), __tsplusTrace)(tsplus_module_30.offer(tsplus_module_41.succeed(a, __tsplusTrace), __tsplusTrace)(queue));
|
776
741
|
} else {
|
777
742
|
return tsplus_module_1.succeedNow(b, __tsplusTrace);
|
778
743
|
}
|
779
|
-
}, __tsplusTrace)), __tsplusTrace)(
|
744
|
+
}, __tsplusTrace)), __tsplusTrace)(tsplus_module_16.get(queuesRef, __tsplusTrace)), __tsplusTrace)(decide(a));
|
780
745
|
return tsplus_module_1.flatMap(queuesRef => tsplus_module_1.map(add => add, __tsplusTrace)(tsplus_module_1.flatMap(queuesLock => tsplus_module_1.flatMap(newQueue => {
|
781
|
-
const finalize = endTake => queuesLock.withPermit(tsplus_module_1.asUnit(tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(queues => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => void 0, __tsplusTrace)(done(endTake)), __tsplusTrace)(tsplus_module_1.foreach(queues, queue => tsplus_module_1.catchJustCause(c =>
|
746
|
+
const finalize = endTake => queuesLock.withPermit(tsplus_module_1.asUnit(tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(queues => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => void 0, __tsplusTrace)(done(endTake)), __tsplusTrace)(tsplus_module_1.foreach(queues, queue => tsplus_module_1.catchJustCause(c => tsplus_module_27.interrupted(c) ? tsplus_module_5.just(tsplus_module_1.unit, __tsplusTrace) : tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace)(tsplus_module_30.offer(endTake, __tsplusTrace)(queue)), __tsplusTrace)), __tsplusTrace)(tsplus_module_1.map(map => tsplus_module_45.values(map), __tsplusTrace)(tsplus_module_16.get(queuesRef, __tsplusTrace))), __tsplusTrace)(tsplus_module_15.set(tsplus_module_1.flatMap(queue => tsplus_module_1.flatMap(() => {
|
782
747
|
const id = Symbol();
|
783
|
-
return tsplus_module_1.map(() => tuple(id, queue), __tsplusTrace)(
|
784
|
-
}, __tsplusTrace)(
|
785
|
-
return tsplus_module_1.map(() => queuesLock.withPermit(tsplus_module_1.flatten(
|
786
|
-
}, __tsplusTrace)(
|
748
|
+
return tsplus_module_1.map(() => tuple(id, queue), __tsplusTrace)(tsplus_module_17.update(map => tsplus_module_45.set(id, queue)(map), __tsplusTrace)(queuesRef));
|
749
|
+
}, __tsplusTrace)(tsplus_module_30.offer(endTake, __tsplusTrace)(queue)), __tsplusTrace)(tsplus_module_32.makeBounded(1, __tsplusTrace)), __tsplusTrace)(newQueue)), __tsplusTrace));
|
750
|
+
return tsplus_module_1.map(() => queuesLock.withPermit(tsplus_module_1.flatten(tsplus_module_16.get(newQueue, __tsplusTrace), __tsplusTrace)), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_1.matchCauseIO(cause => finalize(tsplus_module_41.failCause(tsplus_module_27.map(tsplus_module_5.just)(cause), __tsplusTrace)), () => finalize(tsplus_module_41.fail(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace)), __tsplusTrace)(runForeachScoped_1(offer(queuesRef), __tsplusTrace)(self)), __tsplusTrace));
|
751
|
+
}, __tsplusTrace)(tsplus_module_8.make(() => tsplus_module_1.flatMap(queue => tsplus_module_1.flatMap(id => tsplus_module_1.map(() => tuple(id, queue), __tsplusTrace)(tsplus_module_17.update(map => tsplus_module_45.set(id, queue)(map), __tsplusTrace)(queuesRef)), __tsplusTrace)(tsplus_module_1.succeed(() => Symbol(), __tsplusTrace)), __tsplusTrace)(tsplus_module_32.makeBounded(maximumLag, __tsplusTrace)), __tsplusTrace)), __tsplusTrace)(tsplus_module_46.makeSemaphore(1, __tsplusTrace))), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_8.make(() => tsplus_module_45.empty(), __tsplusTrace), ref => tsplus_module_1.flatMap(qs => tsplus_module_1.foreach(tsplus_module_45.values(qs), q => tsplus_module_30.shutdown(q, __tsplusTrace), __tsplusTrace), __tsplusTrace)(tsplus_module_16.get(ref, __tsplusTrace)), __tsplusTrace));
|
787
752
|
};
|
788
753
|
}
|
789
754
|
/**
|
@@ -793,15 +758,7 @@ function distributedWithDynamic_1(maximumLag, decide, done = () => tsplus_module
|
|
793
758
|
* @tsplus getter fncts.io.Stream drain
|
794
759
|
*/
|
795
760
|
function drain_1(fa, __tsplusTrace) {
|
796
|
-
return new Stream(
|
797
|
-
}
|
798
|
-
function dropLoop(r, __tsplusTrace) {
|
799
|
-
return tsplus_module_10.readWith(inp => {
|
800
|
-
const dropped = tsplus_module_12.drop(r)(inp);
|
801
|
-
const leftover = Math.max(0, r - inp.length);
|
802
|
-
const more = tsplus_module_12.isEmpty(inp) || leftover > 0;
|
803
|
-
return more ? dropLoop(leftover, __tsplusTrace) : tsplus_module_11.zipRight(tsplus_module_10.id())(tsplus_module_10.write(() => dropped));
|
804
|
-
}, tsplus_module_10.failNow, () => tsplus_module_10.unit);
|
761
|
+
return new Stream(tsplus_module_12.drain(fa.channel));
|
805
762
|
}
|
806
763
|
/**
|
807
764
|
* Drops the specified number of elements from this stream.
|
@@ -810,29 +767,37 @@ function dropLoop(r, __tsplusTrace) {
|
|
810
767
|
*/
|
811
768
|
function drop_1(n, __tsplusTrace) {
|
812
769
|
return stream => {
|
813
|
-
return new Stream(
|
770
|
+
return new Stream(tsplus_module_12.pipeTo(dropLoop(n, __tsplusTrace))(stream.channel));
|
814
771
|
};
|
815
772
|
}
|
773
|
+
function dropLoop(r, __tsplusTrace) {
|
774
|
+
return tsplus_module_12.readWith(inp => {
|
775
|
+
const dropped = tsplus_module_14.drop(r)(inp);
|
776
|
+
const leftover = Math.max(0, r - inp.length);
|
777
|
+
const more = tsplus_module_14.isEmpty(inp) || leftover > 0;
|
778
|
+
return more ? dropLoop(leftover, __tsplusTrace) : tsplus_module_13.zipRight(tsplus_module_12.id())(tsplus_module_12.write(() => dropped));
|
779
|
+
}, tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
780
|
+
}
|
816
781
|
/**
|
817
|
-
* Drops all elements of the stream
|
818
|
-
*
|
782
|
+
* Drops all elements of the stream until the specified predicate evaluates
|
783
|
+
* to `true`.
|
819
784
|
*
|
820
|
-
* @tsplus pipeable fncts.io.Stream
|
785
|
+
* @tsplus pipeable fncts.io.Stream dropUntil
|
821
786
|
*/
|
822
|
-
function
|
787
|
+
export function dropUntil(p, __tsplusTrace) {
|
823
788
|
return stream => {
|
824
|
-
return
|
789
|
+
return drop_1(1, __tsplusTrace)(dropWhile_1(tsplus_module_47.invert(p), __tsplusTrace)(stream));
|
825
790
|
};
|
826
791
|
}
|
827
792
|
/**
|
828
|
-
* Drops all elements of the stream
|
829
|
-
* to `true`.
|
793
|
+
* Drops all elements of the stream for as long as the specified predicate
|
794
|
+
* evaluates to `true`.
|
830
795
|
*
|
831
|
-
* @tsplus pipeable fncts.io.Stream
|
796
|
+
* @tsplus pipeable fncts.io.Stream dropWhile
|
832
797
|
*/
|
833
|
-
|
798
|
+
function dropWhile_1(p, __tsplusTrace) {
|
834
799
|
return stream => {
|
835
|
-
return
|
800
|
+
return pipeThrough_1(tsplus_module_48.makeDropWhile(p, __tsplusTrace), __tsplusTrace)(stream);
|
836
801
|
};
|
837
802
|
}
|
838
803
|
/**
|
@@ -845,16 +810,48 @@ export function dropUntil(p, __tsplusTrace) {
|
|
845
810
|
* @tsplus getter fncts.io.Stream either
|
846
811
|
*/
|
847
812
|
export function either(stream, __tsplusTrace) {
|
848
|
-
return catchAll_1(e => succeedNow_1(
|
813
|
+
return catchAll_1(e => succeedNow_1(tsplus_module_20.left(e, __tsplusTrace), __tsplusTrace), __tsplusTrace)(map_1(tsplus_module_20.right, __tsplusTrace)(stream));
|
814
|
+
}
|
815
|
+
/**
|
816
|
+
* Returns a stream made of the concatenation in strict order of all the streams
|
817
|
+
* produced by passing each element of this stream to `f`
|
818
|
+
*
|
819
|
+
* @tsplus pipeable fncts.io.Stream flatMap
|
820
|
+
*/
|
821
|
+
function flatMap_1(f, __tsplusTrace) {
|
822
|
+
return stream => {
|
823
|
+
return new Stream(tsplus_module_12.concatMap(as => tsplus_module_14.foldLeft(tsplus_module_12.unit, (s, a) => tsplus_module_13.flatMap(() => a)(s))(tsplus_module_14.map(a => f(a).channel)(as)))(stream.channel));
|
824
|
+
};
|
825
|
+
}
|
826
|
+
/**
|
827
|
+
* Composes this stream with the specified stream to create a cartesian product of elements,
|
828
|
+
* but keeps only elements from this stream.
|
829
|
+
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
830
|
+
*
|
831
|
+
* @tsplus pipeable fncts.io.Stream zipLeft
|
832
|
+
*/
|
833
|
+
export function zipLeft(that, __tsplusTrace) {
|
834
|
+
return stream => {
|
835
|
+
return crossWith_1(that, (a, _) => a, __tsplusTrace)(stream);
|
836
|
+
};
|
837
|
+
}
|
838
|
+
/**
|
839
|
+
* Composes this stream with the specified stream to create a cartesian product of elements,
|
840
|
+
* but keeps only elements from the other stream.
|
841
|
+
* The `that` stream would be run multiple times, for every element in the `this` stream.
|
842
|
+
*
|
843
|
+
* @tsplus pipeable fncts.io.Stream zipRight
|
844
|
+
*/
|
845
|
+
function zipRight_1(that, __tsplusTrace) {
|
846
|
+
return stream => {
|
847
|
+
return crossWith_1(that, (_, b) => b, __tsplusTrace)(stream);
|
848
|
+
};
|
849
849
|
}
|
850
850
|
/**
|
851
851
|
* @tsplus static fncts.io.StreamOps empty
|
852
852
|
*/
|
853
|
-
const empty_1 = /*#__PURE__*/fromChunkNow_1(/*#__PURE__*/
|
853
|
+
const empty_1 = /*#__PURE__*/fromChunkNow_1(/*#__PURE__*/tsplus_module_9.empty(), fileName_1 + ":1234:70");
|
854
854
|
export const empty = empty_1;
|
855
|
-
function endWhenWriter(fiber, __tsplusTrace) {
|
856
|
-
return tsplus_module_10.unwrap(() => tsplus_module_1.map(maybeExit => tsplus_module_20.match(() => tsplus_module_10.readWith(inp => tsplus_module_11.zipRight(endWhenWriter(fiber, __tsplusTrace))(tsplus_module_10.writeNow(inp)), tsplus_module_10.failNow, () => tsplus_module_10.unit), exit => tsplus_module_36.match(tsplus_module_11.failCauseNow, () => tsplus_module_10.unit)(exit))(maybeExit), __tsplusTrace)(tsplus_module_49.poll(fiber, __tsplusTrace)));
|
857
|
-
}
|
858
855
|
/**
|
859
856
|
* Halts the evaluation of this stream when the provided IO completes. The given IO
|
860
857
|
* will be forked as part of the returned stream, and its success will be discarded.
|
@@ -868,15 +865,18 @@ function endWhenWriter(fiber, __tsplusTrace) {
|
|
868
865
|
*/
|
869
866
|
export function endWhen(io, __tsplusTrace) {
|
870
867
|
return stream => {
|
871
|
-
return new Stream(
|
868
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(fiber => tsplus_module_12.pipeTo(endWhenWriter(fiber, __tsplusTrace))(stream.channel), __tsplusTrace)(tsplus_module_19.forkScoped(io, __tsplusTrace))));
|
872
869
|
};
|
873
870
|
}
|
871
|
+
function endWhenWriter(fiber, __tsplusTrace) {
|
872
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(maybeExit => tsplus_module_22.match(() => tsplus_module_12.readWith(inp => tsplus_module_13.zipRight(endWhenWriter(fiber, __tsplusTrace))(tsplus_module_12.writeNow(inp)), tsplus_module_12.failNow, () => tsplus_module_12.unit), exit => tsplus_module_36.match(tsplus_module_13.failCauseNow, () => tsplus_module_12.unit)(exit))(maybeExit), __tsplusTrace)(tsplus_module_49.poll(fiber, __tsplusTrace)));
|
873
|
+
}
|
874
874
|
/**
|
875
875
|
* @tsplus pipeable fncts.io.Stream ensuring
|
876
876
|
*/
|
877
877
|
function ensuring_1(finalizer, __tsplusTrace) {
|
878
878
|
return self => {
|
879
|
-
return new Stream(
|
879
|
+
return new Stream(tsplus_module_12.ensuring(finalizer)(self.channel));
|
880
880
|
};
|
881
881
|
}
|
882
882
|
/**
|
@@ -920,18 +920,18 @@ function execute_1(io, __tsplusTrace) {
|
|
920
920
|
/**
|
921
921
|
* Halt a stream with the specified error
|
922
922
|
*
|
923
|
-
* @tsplus static fncts.io.StreamOps
|
923
|
+
* @tsplus static fncts.io.StreamOps fail
|
924
924
|
*/
|
925
|
-
function
|
926
|
-
return new Stream(
|
925
|
+
export function fail(error, __tsplusTrace) {
|
926
|
+
return new Stream(tsplus_module_12.fail(error));
|
927
927
|
}
|
928
928
|
/**
|
929
|
-
*
|
929
|
+
* The stream that always halts with `cause`.
|
930
930
|
*
|
931
|
-
* @tsplus static fncts.io.StreamOps
|
931
|
+
* @tsplus static fncts.io.StreamOps failCause
|
932
932
|
*/
|
933
|
-
export function
|
934
|
-
return
|
933
|
+
export function failCause(cause, __tsplusTrace) {
|
934
|
+
return fromIO_1(tsplus_module_1.failCause(cause, __tsplusTrace), __tsplusTrace);
|
935
935
|
}
|
936
936
|
/**
|
937
937
|
* The stream that always halts with `cause`.
|
@@ -942,16 +942,16 @@ function failCauseNow_1(cause, __tsplusTrace) {
|
|
942
942
|
return fromIO_1(tsplus_module_1.failCauseNow(cause, __tsplusTrace), __tsplusTrace);
|
943
943
|
}
|
944
944
|
/**
|
945
|
-
*
|
945
|
+
* Halt a stream with the specified error
|
946
946
|
*
|
947
|
-
* @tsplus static fncts.io.StreamOps
|
947
|
+
* @tsplus static fncts.io.StreamOps failNow
|
948
948
|
*/
|
949
|
-
|
950
|
-
return
|
949
|
+
function failNow_1(error, __tsplusTrace) {
|
950
|
+
return new Stream(tsplus_module_12.failNow(error));
|
951
951
|
}
|
952
952
|
export function filter(predicate, __tsplusTrace) {
|
953
953
|
return fa => {
|
954
|
-
return mapChunks_1(chunk =>
|
954
|
+
return mapChunks_1(chunk => tsplus_module_14.filter(predicate)(chunk), __tsplusTrace)(fa);
|
955
955
|
};
|
956
956
|
}
|
957
957
|
/**
|
@@ -959,15 +959,15 @@ export function filter(predicate, __tsplusTrace) {
|
|
959
959
|
*/
|
960
960
|
export function filterIO(f, __tsplusTrace) {
|
961
961
|
return fa => {
|
962
|
-
return new Stream(
|
962
|
+
return new Stream(tsplus_module_12.pipeTo(filterIOLoop(tsplus_module_40.empty()[Symbol.iterator](), f, __tsplusTrace))(fa.channel));
|
963
963
|
};
|
964
964
|
}
|
965
965
|
function filterIOLoop(iterator, f, __tsplusTrace) {
|
966
966
|
const next = iterator.next();
|
967
967
|
if (next.done) {
|
968
|
-
return
|
968
|
+
return tsplus_module_12.readWithCause(elem => filterIOLoop(elem[Symbol.iterator](), f, __tsplusTrace), tsplus_module_13.failCauseNow, tsplus_module_13.succeedNow);
|
969
969
|
} else {
|
970
|
-
return
|
970
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(b => b ? tsplus_module_13.zipRight(filterIOLoop(iterator, f, __tsplusTrace))(tsplus_module_12.writeNow(tsplus_module_21.single(next.value))) : filterIOLoop(iterator, f, __tsplusTrace), __tsplusTrace)(f(next.value)));
|
971
971
|
}
|
972
972
|
}
|
973
973
|
/**
|
@@ -975,7 +975,7 @@ function filterIOLoop(iterator, f, __tsplusTrace) {
|
|
975
975
|
*/
|
976
976
|
function filterMap_1(f, __tsplusTrace) {
|
977
977
|
return fa => {
|
978
|
-
return mapChunks_1(chunk =>
|
978
|
+
return mapChunks_1(chunk => tsplus_module_14.filterMap(f)(chunk), __tsplusTrace)(fa);
|
979
979
|
};
|
980
980
|
}
|
981
981
|
/**
|
@@ -983,15 +983,15 @@ function filterMap_1(f, __tsplusTrace) {
|
|
983
983
|
*/
|
984
984
|
export function filterMapIO(f, __tsplusTrace) {
|
985
985
|
return fa => {
|
986
|
-
return new Stream(
|
986
|
+
return new Stream(tsplus_module_12.pipeTo(filterMapIOLoop(tsplus_module_40.empty()[Symbol.iterator](), f, __tsplusTrace))(fa.channel));
|
987
987
|
};
|
988
988
|
}
|
989
989
|
function filterMapIOLoop(iterator, f, __tsplusTrace) {
|
990
990
|
const next = iterator.next();
|
991
991
|
if (next.done) {
|
992
|
-
return
|
992
|
+
return tsplus_module_12.readWithCause(elem => filterMapIOLoop(elem[Symbol.iterator](), f, __tsplusTrace), tsplus_module_13.failCauseNow, tsplus_module_13.succeedNow);
|
993
993
|
} else {
|
994
|
-
return
|
994
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(b => tsplus_module_22.match(() => filterMapIOLoop(iterator, f, __tsplusTrace), b => tsplus_module_13.zipRight(filterMapIOLoop(iterator, f, __tsplusTrace))(tsplus_module_12.writeNow(tsplus_module_21.single(b))))(b), __tsplusTrace)(f(next.value)));
|
995
995
|
}
|
996
996
|
}
|
997
997
|
/**
|
@@ -1001,8 +1001,8 @@ function filterMapIOLoop(iterator, f, __tsplusTrace) {
|
|
1001
1001
|
*/
|
1002
1002
|
export function find(p, __tsplusTrace) {
|
1003
1003
|
return stream => {
|
1004
|
-
const loop =
|
1005
|
-
return new Stream(
|
1004
|
+
const loop = tsplus_module_12.readWith(inp => tsplus_module_22.match(() => loop, a => tsplus_module_12.writeNow(tsplus_module_21.single(a)))(tsplus_module_14.find(p)(inp)), tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
1005
|
+
return new Stream(tsplus_module_12.pipeTo(loop)(stream.channel));
|
1006
1006
|
};
|
1007
1007
|
}
|
1008
1008
|
/**
|
@@ -1012,8 +1012,8 @@ export function find(p, __tsplusTrace) {
|
|
1012
1012
|
*/
|
1013
1013
|
export function findIO(f, __tsplusTrace) {
|
1014
1014
|
return stream => {
|
1015
|
-
const loop =
|
1016
|
-
return new Stream(
|
1015
|
+
const loop = tsplus_module_12.readWith(inp => tsplus_module_12.unwrap(() => tsplus_module_1.map(maybeA => tsplus_module_22.match(() => loop, a => tsplus_module_12.writeNow(tsplus_module_21.single(a)))(maybeA), __tsplusTrace)(tsplus_module_51.findIO(f, __tsplusTrace)(inp))), tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
1016
|
+
return new Stream(tsplus_module_12.pipeTo(loop)(stream.channel));
|
1017
1017
|
};
|
1018
1018
|
}
|
1019
1019
|
/**
|
@@ -1025,6 +1025,15 @@ export function findIO(f, __tsplusTrace) {
|
|
1025
1025
|
function flatten_1(self, __tsplusTrace) {
|
1026
1026
|
return flatMap_1(identity, __tsplusTrace)(self);
|
1027
1027
|
}
|
1028
|
+
/**
|
1029
|
+
* Submerges the chunks carried by this stream into the stream's structure, while
|
1030
|
+
* still preserving them.
|
1031
|
+
*
|
1032
|
+
* @tsplus getter fncts.io.Stream flattenChunks
|
1033
|
+
*/
|
1034
|
+
function flattenChunks_1(stream, __tsplusTrace) {
|
1035
|
+
return new Stream(tsplus_module_12.mapOut(c => tsplus_module_14.flatten(c))(stream.channel));
|
1036
|
+
}
|
1028
1037
|
/**
|
1029
1038
|
* Unwraps `Exit` values that also signify end-of-stream by failing with `None`.
|
1030
1039
|
*
|
@@ -1034,12 +1043,12 @@ function flatten_1(self, __tsplusTrace) {
|
|
1034
1043
|
*/
|
1035
1044
|
function flattenExitOption_1(stream, __tsplusTrace) {
|
1036
1045
|
const processChunk = (chunk, cont) => {
|
1037
|
-
const [toEmit, rest] =
|
1038
|
-
const next =
|
1039
|
-
return
|
1046
|
+
const [toEmit, rest] = tsplus_module_14.splitWhere(_ => !tsplus_module_52.isSuccess(_))(chunk);
|
1047
|
+
const next = tsplus_module_22.match(() => cont, exit => tsplus_module_36.match(cause => tsplus_module_22.match(() => tsplus_module_13.endNow(undefined), tsplus_module_13.failCauseNow)(tsplus_module_27.flipCauseOption(cause)), () => tsplus_module_13.endNow(undefined))(exit))(tsplus_module_14.head(rest));
|
1048
|
+
return tsplus_module_13.zipRight(next)(tsplus_module_12.writeNow(tsplus_module_14.filterMap(exit => tsplus_module_36.match(() => tsplus_module_5.nothing(__tsplusTrace), tsplus_module_5.just)(exit))(toEmit)));
|
1040
1049
|
};
|
1041
|
-
const process =
|
1042
|
-
return new Stream(
|
1050
|
+
const process = tsplus_module_12.readWithCause(chunk => processChunk(chunk, process), tsplus_module_13.failCauseNow, _ => tsplus_module_13.endNow(undefined));
|
1051
|
+
return new Stream(tsplus_module_12.pipeTo(process)(stream.channel));
|
1043
1052
|
}
|
1044
1053
|
/**
|
1045
1054
|
* Unwraps `Exit` values and flatten chunks that also signify end-of-stream by failing with `None`.
|
@@ -1049,30 +1058,24 @@ function flattenExitOption_1(stream, __tsplusTrace) {
|
|
1049
1058
|
function flattenTake_1(stream, __tsplusTrace) {
|
1050
1059
|
return flattenChunks_1(flattenExitOption_1(map_1(take => take.exit, __tsplusTrace)(stream), __tsplusTrace), __tsplusTrace);
|
1051
1060
|
}
|
1052
|
-
/**
|
1053
|
-
* Submerges the chunks carried by this stream into the stream's structure, while
|
1054
|
-
* still preserving them.
|
1055
|
-
*
|
1056
|
-
* @tsplus getter fncts.io.Stream flattenChunks
|
1057
|
-
*/
|
1058
|
-
function flattenChunks_1(stream, __tsplusTrace) {
|
1059
|
-
return new Stream(tsplus_module_10.mapOut(c => tsplus_module_12.flatten(c))(stream.channel));
|
1060
|
-
}
|
1061
1061
|
/**
|
1062
1062
|
* Repeats this stream forever.
|
1063
1063
|
*
|
1064
1064
|
* @tsplus getter fncts.io.Stream forever
|
1065
1065
|
*/
|
1066
1066
|
function forever_1(stream, __tsplusTrace) {
|
1067
|
-
return new Stream(
|
1067
|
+
return new Stream(tsplus_module_12.repeated(stream.channel));
|
1068
1068
|
}
|
1069
1069
|
/**
|
1070
|
-
*
|
1071
|
-
*
|
1072
|
-
* @tsplus static fncts.io.StreamOps fromChunkNow
|
1070
|
+
* @tsplus static fncts.io.StreamOps fromAsyncIterable
|
1073
1071
|
*/
|
1074
|
-
function
|
1075
|
-
return new Stream(
|
1072
|
+
export function fromAsyncIterable(iterable, __tsplusTrace) {
|
1073
|
+
return new Stream(fromAsyncIterableLoop(iterable[Symbol.asyncIterator](), __tsplusTrace));
|
1074
|
+
}
|
1075
|
+
function fromAsyncIterableLoop(iterator, __tsplusTrace) {
|
1076
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.async(k => {
|
1077
|
+
iterator.next().then(result => result.done ? k(tsplus_module_1.succeedNow(tsplus_module_13.end(() => undefined), __tsplusTrace)) : k(tsplus_module_1.succeedNow(tsplus_module_13.zipRight(fromAsyncIterableLoop(iterator, __tsplusTrace))(tsplus_module_12.writeNow(tsplus_module_21.single(result.value))), __tsplusTrace)));
|
1078
|
+
}));
|
1076
1079
|
}
|
1077
1080
|
/**
|
1078
1081
|
* Creates a stream from a `Chunk` of values
|
@@ -1080,77 +1083,27 @@ function fromChunkNow_1(c, __tsplusTrace) {
|
|
1080
1083
|
* @tsplus static fncts.io.StreamOps fromChunk
|
1081
1084
|
*/
|
1082
1085
|
function fromChunk_1(c, __tsplusTrace) {
|
1083
|
-
return new Stream(
|
1086
|
+
return new Stream(tsplus_module_12.unwrap(() => tsplus_module_1.succeedNow(tsplus_module_12.write(c), __tsplusTrace)));
|
1084
1087
|
}
|
1085
1088
|
/**
|
1086
|
-
*
|
1089
|
+
* Creates a stream from a `Chunk` of values
|
1090
|
+
*
|
1091
|
+
* @tsplus static fncts.io.StreamOps fromChunkNow
|
1087
1092
|
*/
|
1088
|
-
|
1089
|
-
return
|
1090
|
-
done,
|
1091
|
-
value
|
1092
|
-
}) => done ? tsplus_module_1.failNow(tsplus_module_3.nothing(fileName_1 + ":1606:38"), fileName_1 + ":1606:30") : tsplus_module_1.succeedNow(value, fileName_1 + ":1606:57"), fileName_1 + ":1605:88")(tsplus_module_1.fromPromiseCatch(() => reader.read(), reason => tsplus_module_3.just(onError(reason), fileName_1 + ":1605:62"), fileName_1 + ":1605:30")), fileName_1 + ":1604:29"), fileName_1 + ":1603:11")(tsplus_module_31.acquireRelease(() => tsplus_module_1.succeed(() => evaluate().getReader(), fileName_1 + ":1601:7"), reader => tsplus_module_1.fromPromiseHalt(() => reader.cancel(), fileName_1 + ":1602:53"), fileName_1 + ":1602:22")), fileName_1 + ":1600:29");
|
1093
|
+
function fromChunkNow_1(c, __tsplusTrace) {
|
1094
|
+
return new Stream(tsplus_module_12.defer(() => tsplus_module_14.isEmpty(c) ? tsplus_module_12.unit : tsplus_module_12.writeNow(c)));
|
1093
1095
|
}
|
1094
1096
|
/**
|
1095
|
-
*
|
1096
|
-
*
|
1097
|
-
* @tsplus static fncts.io.StreamOps scoped
|
1097
|
+
* @tsplus static fncts.io.StreamOps fromHub
|
1098
1098
|
*/
|
1099
|
-
function
|
1100
|
-
return
|
1099
|
+
export function fromHub(hub, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1100
|
+
return flatMap_1(queue => fromQueueWithShutdown_1(queue, maxChunkSize, __tsplusTrace), __tsplusTrace)(scoped_1(() => tsplus_module_34.subscribe(hub(), __tsplusTrace), __tsplusTrace));
|
1101
1101
|
}
|
1102
1102
|
/**
|
1103
|
-
*
|
1104
|
-
*
|
1105
|
-
* @tsplus pipeable fncts.io.Stream sliding
|
1103
|
+
* @tsplus static fncts.io.StreamOps fromHubScoped
|
1106
1104
|
*/
|
1107
|
-
export function
|
1108
|
-
return
|
1109
|
-
return defer_1(() => {
|
1110
|
-
function slidingChunk(chunk, input) {
|
1111
|
-
const updatedChunk = tsplus_module_12.concat(input)(chunk);
|
1112
|
-
const length = updatedChunk.length;
|
1113
|
-
if (length >= chunkSize) {
|
1114
|
-
const array = new Array((length - chunkSize) / stepSize + 1);
|
1115
|
-
let arrayIndex = 0;
|
1116
|
-
let chunkIndex = 0;
|
1117
|
-
while (chunkIndex + chunkSize <= length) {
|
1118
|
-
array[arrayIndex] = tsplus_module_12.slice(chunkIndex, chunkIndex + chunkSize)(updatedChunk);
|
1119
|
-
arrayIndex += 1;
|
1120
|
-
chunkIndex += stepSize;
|
1121
|
-
}
|
1122
|
-
return [tsplus_module_12.drop(chunkIndex)(updatedChunk), tsplus_module_53.fromArray(array)];
|
1123
|
-
} else {
|
1124
|
-
return [updatedChunk, tsplus_module_7.empty()];
|
1125
|
-
}
|
1126
|
-
}
|
1127
|
-
function sliding(chunk, written) {
|
1128
|
-
return tsplus_module_10.readWithCause(input => {
|
1129
|
-
const [updatedChunk, out] = slidingChunk(chunk, input);
|
1130
|
-
if (tsplus_module_12.isEmpty(out)) {
|
1131
|
-
return sliding(updatedChunk, written);
|
1132
|
-
} else {
|
1133
|
-
return tsplus_module_11.zipRight(sliding(updatedChunk, true))(tsplus_module_10.writeNow(out));
|
1134
|
-
}
|
1135
|
-
}, err => {
|
1136
|
-
const index = written && chunkSize > stepSize ? chunkSize - stepSize : 0;
|
1137
|
-
if (index >= chunk.length) {
|
1138
|
-
return tsplus_module_11.failCauseNow(err);
|
1139
|
-
} else {
|
1140
|
-
return tsplus_module_11.zipRight(tsplus_module_11.failCauseNow(err))(tsplus_module_10.writeNow(tsplus_module_19.single(chunk)));
|
1141
|
-
}
|
1142
|
-
}, done => {
|
1143
|
-
const index = written && chunkSize > stepSize ? chunkSize - stepSize : 0;
|
1144
|
-
if (index >= chunk.length) {
|
1145
|
-
return tsplus_module_11.succeedNow(done);
|
1146
|
-
} else {
|
1147
|
-
return tsplus_module_11.zipRight(tsplus_module_11.succeedNow(done))(tsplus_module_10.writeNow(tsplus_module_19.single(chunk)));
|
1148
|
-
}
|
1149
|
-
});
|
1150
|
-
}
|
1151
|
-
return new Stream(tsplus_module_10.pipeTo(sliding(tsplus_module_7.empty(), false))(self.channel));
|
1152
|
-
});
|
1153
|
-
};
|
1105
|
+
export function fromHubScoped(hub, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1106
|
+
return tsplus_module_1.defer(() => tsplus_module_1.map(queue => fromQueueWithShutdown_1(queue, maxChunkSize, __tsplusTrace), __tsplusTrace)(tsplus_module_34.subscribe(hub(), __tsplusTrace)), __tsplusTrace);
|
1154
1107
|
}
|
1155
1108
|
/**
|
1156
1109
|
* Creates a stream from an effect producing a value of type `A`
|
@@ -1158,7 +1111,7 @@ export function sliding(chunkSize, stepSize, __tsplusTrace) {
|
|
1158
1111
|
* @tsplus static fncts.io.StreamOps fromIO
|
1159
1112
|
*/
|
1160
1113
|
function fromIO_1(fa, __tsplusTrace) {
|
1161
|
-
return fromIOMaybe_1(tsplus_module_1.mapError(
|
1114
|
+
return fromIOMaybe_1(tsplus_module_1.mapError(tsplus_module_5.just, __tsplusTrace)(fa), __tsplusTrace);
|
1162
1115
|
}
|
1163
1116
|
/**
|
1164
1117
|
* Creates a stream from an effect producing a value of type `A` or an empty Stream
|
@@ -1166,31 +1119,20 @@ function fromIO_1(fa, __tsplusTrace) {
|
|
1166
1119
|
* @tsplus static fncts.io.StreamOps fromIOMaybe
|
1167
1120
|
*/
|
1168
1121
|
function fromIOMaybe_1(fa, __tsplusTrace) {
|
1169
|
-
return new Stream(
|
1170
|
-
}
|
1171
|
-
function fromAsyncIterableLoop(iterator, __tsplusTrace) {
|
1172
|
-
return tsplus_module_10.unwrap(() => tsplus_module_1.async(k => {
|
1173
|
-
iterator.next().then(result => result.done ? k(tsplus_module_1.succeedNow(tsplus_module_11.end(() => undefined), __tsplusTrace)) : k(tsplus_module_1.succeedNow(tsplus_module_11.zipRight(fromAsyncIterableLoop(iterator, __tsplusTrace))(tsplus_module_10.writeNow(tsplus_module_19.single(result.value))), __tsplusTrace)));
|
1174
|
-
}));
|
1175
|
-
}
|
1176
|
-
/**
|
1177
|
-
* @tsplus static fncts.io.StreamOps fromAsyncIterable
|
1178
|
-
*/
|
1179
|
-
export function fromAsyncIterable(iterable, __tsplusTrace) {
|
1180
|
-
return new Stream(fromAsyncIterableLoop(iterable[Symbol.asyncIterator](), __tsplusTrace));
|
1122
|
+
return new Stream(tsplus_module_12.unwrap(() => tsplus_module_1.match(maybeError => tsplus_module_22.match(() => tsplus_module_12.unit, tsplus_module_12.failNow)(maybeError), a => tsplus_module_12.writeNow(tsplus_module_21.single(a)), __tsplusTrace)(fa)));
|
1181
1123
|
}
|
1182
1124
|
/**
|
1183
1125
|
* @tsplus static fncts.io.StreamOps fromIterable
|
1184
1126
|
*/
|
1185
1127
|
export function fromIterable(iterable, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1186
1128
|
return unwrap_1(tsplus_module_1.succeed(() => {
|
1187
|
-
const loop = iterator =>
|
1129
|
+
const loop = iterator => tsplus_module_12.unwrap(() => tsplus_module_1.succeed(() => {
|
1188
1130
|
let result = iterator.next();
|
1189
1131
|
if (result.done) {
|
1190
|
-
return
|
1132
|
+
return tsplus_module_12.unit;
|
1191
1133
|
}
|
1192
1134
|
if (maxChunkSize === 1) {
|
1193
|
-
return
|
1135
|
+
return tsplus_module_13.zipRight(loop(iterator))(tsplus_module_12.writeNow(tsplus_module_21.single(result.value)));
|
1194
1136
|
} else {
|
1195
1137
|
const out = Array(maxChunkSize);
|
1196
1138
|
out[0] = result.value;
|
@@ -1199,7 +1141,7 @@ export function fromIterable(iterable, maxChunkSize = DEFAULT_CHUNK_SIZE, __tspl
|
|
1199
1141
|
out[count] = result.value;
|
1200
1142
|
count++;
|
1201
1143
|
}
|
1202
|
-
return
|
1144
|
+
return tsplus_module_13.zipRight(loop(iterator))(tsplus_module_12.writeNow(tsplus_module_21.from(out)));
|
1203
1145
|
}
|
1204
1146
|
}, __tsplusTrace));
|
1205
1147
|
return new Stream(loop(iterable[Symbol.iterator]()));
|
@@ -1212,7 +1154,7 @@ export function fromIterableSingle(iterable, __tsplusTrace) {
|
|
1212
1154
|
return flatMap_1(iterator => repeatIOMaybe_1(tsplus_module_1.defer(() => {
|
1213
1155
|
const value = iterator.next();
|
1214
1156
|
if (value.done) {
|
1215
|
-
return tsplus_module_1.failNow(
|
1157
|
+
return tsplus_module_1.failNow(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace);
|
1216
1158
|
} else {
|
1217
1159
|
return tsplus_module_1.succeedNow(value.value, __tsplusTrace);
|
1218
1160
|
}
|
@@ -1231,49 +1173,43 @@ function fromPull_1(scopedPull, __tsplusTrace) {
|
|
1231
1173
|
*/
|
1232
1174
|
function fromQueue_1(queue, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1233
1175
|
return repeatIOChunkMaybe_1(tsplus_module_1.catchAllCause(c => tsplus_module_1.flatMap(down => {
|
1234
|
-
if (down &&
|
1235
|
-
return
|
1176
|
+
if (down && tsplus_module_27.interrupted(c)) {
|
1177
|
+
return tsplus_module_53.end;
|
1236
1178
|
} else {
|
1237
|
-
return
|
1179
|
+
return tsplus_module_53.failCause(c);
|
1238
1180
|
}
|
1239
|
-
}, __tsplusTrace)(
|
1181
|
+
}, __tsplusTrace)(tsplus_module_30.isShutdown(queue, __tsplusTrace)), __tsplusTrace)(tsplus_module_1.map(tsplus_module_21.from, __tsplusTrace)(tsplus_module_54.takeBetween(1, maxChunkSize, __tsplusTrace)(queue))), __tsplusTrace);
|
1240
1182
|
}
|
1241
1183
|
/**
|
1242
1184
|
* @tsplus static fncts.io.StreamOps fromQueueWithShutdown
|
1243
1185
|
*/
|
1244
1186
|
function fromQueueWithShutdown_1(queue, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1245
|
-
return ensuring_1(
|
1187
|
+
return ensuring_1(tsplus_module_30.shutdown(queue, __tsplusTrace), __tsplusTrace)(fromQueue_1(queue, maxChunkSize, __tsplusTrace));
|
1246
1188
|
}
|
1247
1189
|
/**
|
1248
|
-
* @tsplus static fncts.io.StreamOps
|
1249
|
-
*/
|
1250
|
-
export function fromHub(hub, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1251
|
-
return flatMap_1(queue => fromQueueWithShutdown_1(queue, maxChunkSize, __tsplusTrace), __tsplusTrace)(scoped_1(() => tsplus_module_34.subscribe(hub(), __tsplusTrace), __tsplusTrace));
|
1252
|
-
}
|
1253
|
-
/**
|
1254
|
-
* @tsplus static fncts.io.StreamOps fromHubScoped
|
1190
|
+
* @tsplus static fncts.io.StreamOps fromReadableStream
|
1255
1191
|
*/
|
1256
|
-
export function
|
1257
|
-
return
|
1192
|
+
export function fromReadableStream(evaluate, onError) {
|
1193
|
+
return unwrapScoped_1(tsplus_module_1.map(reader => repeatIOMaybe_1(tsplus_module_1.flatMap(({
|
1194
|
+
done,
|
1195
|
+
value
|
1196
|
+
}) => done ? tsplus_module_1.failNow(tsplus_module_5.nothing(fileName_1 + ":1784:38"), fileName_1 + ":1784:30") : tsplus_module_1.succeedNow(value, fileName_1 + ":1784:57"), fileName_1 + ":1783:88")(tsplus_module_1.fromPromiseCatch(() => reader.read(), reason => tsplus_module_5.just(onError(reason), fileName_1 + ":1783:62"), fileName_1 + ":1783:30")), fileName_1 + ":1782:29"), fileName_1 + ":1781:11")(tsplus_module_2.acquireRelease(() => tsplus_module_1.succeed(() => evaluate().getReader(), fileName_1 + ":1779:7"), reader => tsplus_module_1.fromPromiseHalt(() => reader.cancel(), fileName_1 + ":1780:53"), fileName_1 + ":1780:22")), fileName_1 + ":1778:29");
|
1258
1197
|
}
|
1259
1198
|
/**
|
1260
1199
|
* Halt a stream with the specified exception
|
1261
1200
|
*
|
1262
|
-
* @tsplus static fncts.io.StreamOps
|
1201
|
+
* @tsplus static fncts.io.StreamOps halt
|
1263
1202
|
*/
|
1264
|
-
|
1265
|
-
return new Stream(
|
1203
|
+
function halt_1(u, __tsplusTrace) {
|
1204
|
+
return new Stream(tsplus_module_12.halt(u));
|
1266
1205
|
}
|
1267
1206
|
/**
|
1268
1207
|
* Halt a stream with the specified exception
|
1269
1208
|
*
|
1270
|
-
* @tsplus static fncts.io.StreamOps
|
1209
|
+
* @tsplus static fncts.io.StreamOps haltNow
|
1271
1210
|
*/
|
1272
|
-
function
|
1273
|
-
return new Stream(
|
1274
|
-
}
|
1275
|
-
function haltWhenWriter(fiber, __tsplusTrace) {
|
1276
|
-
return tsplus_module_10.unwrap(() => tsplus_module_1.map(maybeExit => tsplus_module_20.match(() => tsplus_module_10.readWith(i => tsplus_module_11.zipRight(haltWhenWriter(fiber, __tsplusTrace))(tsplus_module_10.writeNow(i)), tsplus_module_10.failNow, () => tsplus_module_10.unit), exit => tsplus_module_36.match(tsplus_module_11.failCauseNow, () => tsplus_module_10.unit)(exit))(maybeExit), __tsplusTrace)(tsplus_module_49.poll(fiber, __tsplusTrace)));
|
1211
|
+
export function haltNow(u, __tsplusTrace) {
|
1212
|
+
return new Stream(tsplus_module_12.halt(() => u));
|
1277
1213
|
}
|
1278
1214
|
/**
|
1279
1215
|
* Halts the evaluation of this stream when the provided IO completes. The
|
@@ -1289,12 +1225,9 @@ function haltWhenWriter(fiber, __tsplusTrace) {
|
|
1289
1225
|
*/
|
1290
1226
|
export function haltWhen(io, __tsplusTrace) {
|
1291
1227
|
return fa => {
|
1292
|
-
return new Stream(
|
1228
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(fiber => tsplus_module_12.pipeTo(haltWhenWriter(fiber, __tsplusTrace))(fa.channel), __tsplusTrace)(tsplus_module_19.forkScoped(io, __tsplusTrace))));
|
1293
1229
|
};
|
1294
1230
|
}
|
1295
|
-
function haltWhenFutureWriter(future, __tsplusTrace) {
|
1296
|
-
return tsplus_module_10.unwrap(() => tsplus_module_1.map(maybeIO => tsplus_module_20.match(() => tsplus_module_10.readWith(i => tsplus_module_11.zipRight(haltWhenFutureWriter(future, __tsplusTrace))(tsplus_module_10.writeNow(i)), tsplus_module_10.failNow, () => tsplus_module_10.unit), io => tsplus_module_10.unwrap(() => tsplus_module_1.match(tsplus_module_10.failNow, () => tsplus_module_10.unit, __tsplusTrace)(io)))(maybeIO), __tsplusTrace)(tsplus_module_37.poll(future, __tsplusTrace)));
|
1297
|
-
}
|
1298
1231
|
/**
|
1299
1232
|
* Halts the evaluation of this stream when the provided promise resolves.
|
1300
1233
|
*
|
@@ -1304,20 +1237,23 @@ function haltWhenFutureWriter(future, __tsplusTrace) {
|
|
1304
1237
|
*/
|
1305
1238
|
export function haltWhenFuture(future, __tsplusTrace) {
|
1306
1239
|
return fa => {
|
1307
|
-
return new Stream(
|
1240
|
+
return new Stream(tsplus_module_12.pipeTo(haltWhenFutureWriter(future, __tsplusTrace))(fa.channel));
|
1308
1241
|
};
|
1309
1242
|
}
|
1243
|
+
function haltWhenFutureWriter(future, __tsplusTrace) {
|
1244
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(maybeIO => tsplus_module_22.match(() => tsplus_module_12.readWith(i => tsplus_module_13.zipRight(haltWhenFutureWriter(future, __tsplusTrace))(tsplus_module_12.writeNow(i)), tsplus_module_12.failNow, () => tsplus_module_12.unit), io => tsplus_module_12.unwrap(() => tsplus_module_1.match(tsplus_module_12.failNow, () => tsplus_module_12.unit, __tsplusTrace)(io)))(maybeIO), __tsplusTrace)(tsplus_module_37.poll(future, __tsplusTrace)));
|
1245
|
+
}
|
1246
|
+
function haltWhenWriter(fiber, __tsplusTrace) {
|
1247
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(maybeExit => tsplus_module_22.match(() => tsplus_module_12.readWith(i => tsplus_module_13.zipRight(haltWhenWriter(fiber, __tsplusTrace))(tsplus_module_12.writeNow(i)), tsplus_module_12.failNow, () => tsplus_module_12.unit), exit => tsplus_module_36.match(tsplus_module_13.failCauseNow, () => tsplus_module_12.unit)(exit))(maybeExit), __tsplusTrace)(tsplus_module_49.poll(fiber, __tsplusTrace)));
|
1248
|
+
}
|
1310
1249
|
/**
|
1311
1250
|
* @tsplus pipeable fncts.io.Stream interleave
|
1312
1251
|
*/
|
1313
1252
|
export function interleave(sb, __tsplusTrace) {
|
1314
1253
|
return sa => {
|
1315
|
-
return interleaveWith_1(sb, forever_1(fromChunk_1(() =>
|
1254
|
+
return interleaveWith_1(sb, forever_1(fromChunk_1(() => tsplus_module_21.make(true, false), __tsplusTrace), __tsplusTrace), __tsplusTrace)(sa);
|
1316
1255
|
};
|
1317
1256
|
}
|
1318
|
-
function interleaveWithProducer(handoff, __tsplusTrace) {
|
1319
|
-
return tsplus_module_10.readWithCause(value => tsplus_module_11.zipRight(interleaveWithProducer(handoff, __tsplusTrace))(tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_27.single(value))(handoff))), cause => tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_27.failCause(cause))(handoff)), () => tsplus_module_10.fromIO(() => tsplus_module_5.offer(tsplus_module_27.end)(handoff)));
|
1320
|
-
}
|
1321
1257
|
/**
|
1322
1258
|
* Combines this stream and the specified stream deterministically using the
|
1323
1259
|
* stream of boolean values `b` to control which stream to pull from next.
|
@@ -1330,41 +1266,22 @@ function interleaveWithProducer(handoff, __tsplusTrace) {
|
|
1330
1266
|
*/
|
1331
1267
|
function interleaveWith_1(sb, b, __tsplusTrace) {
|
1332
1268
|
return sa => {
|
1333
|
-
return new Stream(
|
1334
|
-
const process = (leftDone, rightDone) =>
|
1269
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(([left, right]) => {
|
1270
|
+
const process = (leftDone, rightDone) => tsplus_module_12.readWithCause(b => {
|
1335
1271
|
if (b && !leftDone) {
|
1336
|
-
return
|
1272
|
+
return tsplus_module_13.flatMap(take => tsplus_module_29.match(rightDone ? tsplus_module_12.unit : process(true, rightDone), tsplus_module_13.failCauseNow, chunk => tsplus_module_13.zipRight(process(leftDone, rightDone))(tsplus_module_12.writeNow(chunk)))(take))(tsplus_module_12.fromIO(() => tsplus_module_7.take(left)));
|
1337
1273
|
}
|
1338
1274
|
if (!b && !rightDone) {
|
1339
|
-
return
|
1275
|
+
return tsplus_module_13.flatMap(take => tsplus_module_29.match(leftDone ? tsplus_module_12.unit : process(leftDone, true), tsplus_module_13.failCauseNow, chunk => tsplus_module_13.zipRight(process(leftDone, rightDone))(tsplus_module_12.writeNow(chunk)))(take))(tsplus_module_12.fromIO(() => tsplus_module_7.take(right)));
|
1340
1276
|
}
|
1341
1277
|
return process(leftDone, rightDone);
|
1342
|
-
},
|
1343
|
-
return
|
1344
|
-
}, __tsplusTrace)(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => tuple(left, right), __tsplusTrace)(tsplus_module_33.fork(
|
1278
|
+
}, tsplus_module_13.failCauseNow, () => tsplus_module_12.unit);
|
1279
|
+
return tsplus_module_12.pipeTo(process(false, false))(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(b.channel));
|
1280
|
+
}, __tsplusTrace)(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => tsplus_module_1.flatMap(() => tsplus_module_1.map(() => tuple(left, right), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(interleaveWithProducer(right, __tsplusTrace))(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(sb.channel))), __tsplusTrace)), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_18.runScoped(tsplus_module_12.pipeTo(interleaveWithProducer(left, __tsplusTrace))(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(sa.channel))), __tsplusTrace)), __tsplusTrace)(tsplus_module_7.make()), __tsplusTrace)(tsplus_module_7.make()))));
|
1345
1281
|
};
|
1346
1282
|
}
|
1347
|
-
function
|
1348
|
-
return
|
1349
|
-
const builder = tsplus_module_12.builder();
|
1350
|
-
let flagResult = isFirst;
|
1351
|
-
tsplus_module_12.forEach(a => {
|
1352
|
-
if (flagResult) {
|
1353
|
-
flagResult = false;
|
1354
|
-
builder.append(a);
|
1355
|
-
} else {
|
1356
|
-
builder.append(middle);
|
1357
|
-
builder.append(a);
|
1358
|
-
}
|
1359
|
-
})(inp);
|
1360
|
-
return tsplus_module_11.zipRight(intersperseWriter(middle, flagResult, __tsplusTrace))(tsplus_module_10.writeNow(builder.result()));
|
1361
|
-
}, tsplus_module_10.failNow, () => tsplus_module_10.unit);
|
1362
|
-
}
|
1363
|
-
/**
|
1364
|
-
* Intersperse stream with provided element
|
1365
|
-
*/
|
1366
|
-
export function intersperse(stream, middle, __tsplusTrace) {
|
1367
|
-
return new Stream(tsplus_module_10.pipeTo(intersperseWriter(middle, true, __tsplusTrace))(stream.channel));
|
1283
|
+
function interleaveWithProducer(handoff, __tsplusTrace) {
|
1284
|
+
return tsplus_module_12.readWithCause(value => tsplus_module_13.zipRight(interleaveWithProducer(handoff, __tsplusTrace))(tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_29.single(value))(handoff))), cause => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_29.failCause(cause))(handoff)), () => tsplus_module_12.fromIO(() => tsplus_module_7.offer(tsplus_module_29.end)(handoff)));
|
1368
1285
|
}
|
1369
1286
|
/**
|
1370
1287
|
* Interrupts the evaluation of this stream when the provided IO completes. The given
|
@@ -1378,7 +1295,7 @@ export function intersperse(stream, middle, __tsplusTrace) {
|
|
1378
1295
|
*/
|
1379
1296
|
export function interruptWhen(io, __tsplusTrace) {
|
1380
1297
|
return stream => {
|
1381
|
-
return new Stream(
|
1298
|
+
return new Stream(tsplus_module_55.interruptWhen(io)(stream.channel));
|
1382
1299
|
};
|
1383
1300
|
}
|
1384
1301
|
/**
|
@@ -1386,9 +1303,31 @@ export function interruptWhen(io, __tsplusTrace) {
|
|
1386
1303
|
*/
|
1387
1304
|
export function interruptWhenFuture(future, __tsplusTrace) {
|
1388
1305
|
return fa => {
|
1389
|
-
return new Stream(
|
1306
|
+
return new Stream(tsplus_module_55.interruptWhenFuture(future)(fa.channel));
|
1390
1307
|
};
|
1391
1308
|
}
|
1309
|
+
/**
|
1310
|
+
* Intersperse stream with provided element
|
1311
|
+
*/
|
1312
|
+
export function intersperse(stream, middle, __tsplusTrace) {
|
1313
|
+
return new Stream(tsplus_module_12.pipeTo(intersperseWriter(middle, true, __tsplusTrace))(stream.channel));
|
1314
|
+
}
|
1315
|
+
function intersperseWriter(middle, isFirst, __tsplusTrace) {
|
1316
|
+
return tsplus_module_12.readWith(inp => {
|
1317
|
+
const builder = tsplus_module_14.builder();
|
1318
|
+
let flagResult = isFirst;
|
1319
|
+
tsplus_module_14.forEach(a => {
|
1320
|
+
if (flagResult) {
|
1321
|
+
flagResult = false;
|
1322
|
+
builder.append(a);
|
1323
|
+
} else {
|
1324
|
+
builder.append(middle);
|
1325
|
+
builder.append(a);
|
1326
|
+
}
|
1327
|
+
})(inp);
|
1328
|
+
return tsplus_module_13.zipRight(intersperseWriter(middle, flagResult, __tsplusTrace))(tsplus_module_12.writeNow(builder.result()));
|
1329
|
+
}, tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
1330
|
+
}
|
1392
1331
|
/**
|
1393
1332
|
* Transforms the elements of this stream using the supplied function.
|
1394
1333
|
*
|
@@ -1396,15 +1335,9 @@ export function interruptWhenFuture(future, __tsplusTrace) {
|
|
1396
1335
|
*/
|
1397
1336
|
function map_1(f, __tsplusTrace) {
|
1398
1337
|
return stream => {
|
1399
|
-
return new Stream(
|
1338
|
+
return new Stream(tsplus_module_12.mapOut(as => tsplus_module_14.map(f)(as))(stream.channel));
|
1400
1339
|
};
|
1401
1340
|
}
|
1402
|
-
function mapAccumAccumulator(currS, f, __tsplusTrace) {
|
1403
|
-
return tsplus_module_10.readWith(inp => {
|
1404
|
-
const [nextS, bs] = tsplus_module_12.mapAccum(currS, f)(inp);
|
1405
|
-
return tsplus_module_11.zipRight(mapAccumAccumulator(nextS, f, __tsplusTrace))(tsplus_module_10.writeNow(bs));
|
1406
|
-
}, tsplus_module_10.failNow, () => tsplus_module_10.unit);
|
1407
|
-
}
|
1408
1341
|
/**
|
1409
1342
|
* Statefully maps over the elements of this stream to produce new elements.
|
1410
1343
|
*
|
@@ -1412,20 +1345,14 @@ function mapAccumAccumulator(currS, f, __tsplusTrace) {
|
|
1412
1345
|
*/
|
1413
1346
|
function mapAccum_1(s, f, __tsplusTrace) {
|
1414
1347
|
return stream => {
|
1415
|
-
return new Stream(
|
1348
|
+
return new Stream(tsplus_module_12.pipeTo(mapAccumAccumulator(s, f, __tsplusTrace))(stream.channel));
|
1416
1349
|
};
|
1417
1350
|
}
|
1418
|
-
function
|
1419
|
-
return
|
1420
|
-
const
|
1421
|
-
|
1422
|
-
|
1423
|
-
}, __tsplusTrace);
|
1424
|
-
return tsplus_module_1.match(e => {
|
1425
|
-
const partialResult = outputChunk.result();
|
1426
|
-
return tsplus_module_12.isNonEmpty(partialResult) ? tsplus_module_11.zipRight(tsplus_module_10.failNow(e))(tsplus_module_10.writeNow(partialResult)) : tsplus_module_10.failNow(e);
|
1427
|
-
}, s => tsplus_module_11.zipRight(mapAccumIOAccumulator(s, f, __tsplusTrace))(tsplus_module_10.writeNow(outputChunk.result())), __tsplusTrace)(tsplus_module_1.foldLeft(inp, s, (s1, a) => tsplus_module_1.flatMap(([b, s2]) => tsplus_module_1.as(() => s2, __tsplusTrace)(emit(b)), __tsplusTrace)(f(s1, a)), __tsplusTrace));
|
1428
|
-
}, __tsplusTrace)), tsplus_module_10.failNow, () => tsplus_module_10.unit);
|
1351
|
+
function mapAccumAccumulator(currS, f, __tsplusTrace) {
|
1352
|
+
return tsplus_module_12.readWith(inp => {
|
1353
|
+
const [nextS, bs] = tsplus_module_14.mapAccum(currS, f)(inp);
|
1354
|
+
return tsplus_module_13.zipRight(mapAccumAccumulator(nextS, f, __tsplusTrace))(tsplus_module_12.writeNow(bs));
|
1355
|
+
}, tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
1429
1356
|
}
|
1430
1357
|
/**
|
1431
1358
|
* Statefully and effectfully maps over the elements of this stream to produce
|
@@ -1435,9 +1362,21 @@ function mapAccumIOAccumulator(s, f, __tsplusTrace) {
|
|
1435
1362
|
*/
|
1436
1363
|
function mapAccumIO_1(s, f, __tsplusTrace) {
|
1437
1364
|
return stream => {
|
1438
|
-
return new Stream(
|
1365
|
+
return new Stream(tsplus_module_12.pipeTo(mapAccumIOAccumulator(s, f, __tsplusTrace))(stream.channel));
|
1439
1366
|
};
|
1440
1367
|
}
|
1368
|
+
function mapAccumIOAccumulator(s, f, __tsplusTrace) {
|
1369
|
+
return tsplus_module_12.readWith(inp => tsplus_module_12.unwrap(() => tsplus_module_1.defer(() => {
|
1370
|
+
const outputChunk = tsplus_module_14.builder();
|
1371
|
+
const emit = b => tsplus_module_1.succeed(() => {
|
1372
|
+
outputChunk.append(b);
|
1373
|
+
}, __tsplusTrace);
|
1374
|
+
return tsplus_module_1.match(e => {
|
1375
|
+
const partialResult = outputChunk.result();
|
1376
|
+
return tsplus_module_14.isNonEmpty(partialResult) ? tsplus_module_13.zipRight(tsplus_module_12.failNow(e))(tsplus_module_12.writeNow(partialResult)) : tsplus_module_12.failNow(e);
|
1377
|
+
}, s => tsplus_module_13.zipRight(mapAccumIOAccumulator(s, f, __tsplusTrace))(tsplus_module_12.writeNow(outputChunk.result())), __tsplusTrace)(tsplus_module_1.foldLeft(inp, s, (s1, a) => tsplus_module_1.flatMap(([b, s2]) => tsplus_module_1.as(() => s2, __tsplusTrace)(emit(b)), __tsplusTrace)(f(s1, a)), __tsplusTrace));
|
1378
|
+
}, __tsplusTrace)), tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
1379
|
+
}
|
1441
1380
|
/**
|
1442
1381
|
* Transforms the chunks emitted by this stream.
|
1443
1382
|
*
|
@@ -1445,7 +1384,7 @@ function mapAccumIO_1(s, f, __tsplusTrace) {
|
|
1445
1384
|
*/
|
1446
1385
|
function mapChunks_1(f, __tsplusTrace) {
|
1447
1386
|
return stream => {
|
1448
|
-
return new Stream(
|
1387
|
+
return new Stream(tsplus_module_12.mapOut(f)(stream.channel));
|
1449
1388
|
};
|
1450
1389
|
}
|
1451
1390
|
/**
|
@@ -1455,7 +1394,7 @@ function mapChunks_1(f, __tsplusTrace) {
|
|
1455
1394
|
*/
|
1456
1395
|
export function mapChunksIO(f, __tsplusTrace) {
|
1457
1396
|
return stream => {
|
1458
|
-
return new Stream(
|
1397
|
+
return new Stream(tsplus_module_12.mapOutIO(f)(stream.channel));
|
1459
1398
|
};
|
1460
1399
|
}
|
1461
1400
|
/**
|
@@ -1466,7 +1405,7 @@ export function mapChunksIO(f, __tsplusTrace) {
|
|
1466
1405
|
*/
|
1467
1406
|
export function mapConcat(f, __tsplusTrace) {
|
1468
1407
|
return stream => {
|
1469
|
-
return mapConcatChunk_1(a =>
|
1408
|
+
return mapConcatChunk_1(a => tsplus_module_21.from(f(a)), __tsplusTrace)(stream);
|
1470
1409
|
};
|
1471
1410
|
}
|
1472
1411
|
/**
|
@@ -1477,7 +1416,7 @@ export function mapConcat(f, __tsplusTrace) {
|
|
1477
1416
|
*/
|
1478
1417
|
function mapConcatChunk_1(f, __tsplusTrace) {
|
1479
1418
|
return stream => {
|
1480
|
-
return mapChunks_1(c =>
|
1419
|
+
return mapChunks_1(c => tsplus_module_14.flatMap(f)(c), __tsplusTrace)(stream);
|
1481
1420
|
};
|
1482
1421
|
}
|
1483
1422
|
/**
|
@@ -1499,7 +1438,7 @@ export function mapConcatChunkIO(f, __tsplusTrace) {
|
|
1499
1438
|
*/
|
1500
1439
|
export function mapConcatIO(f, __tsplusTrace) {
|
1501
1440
|
return stream => {
|
1502
|
-
return mapConcatChunk_1(identity, __tsplusTrace)(mapIO_1(a => tsplus_module_1.map(
|
1441
|
+
return mapConcatChunk_1(identity, __tsplusTrace)(mapIO_1(a => tsplus_module_1.map(tsplus_module_21.from, __tsplusTrace)(f(a)), __tsplusTrace)(stream));
|
1503
1442
|
};
|
1504
1443
|
}
|
1505
1444
|
/**
|
@@ -1509,7 +1448,7 @@ export function mapConcatIO(f, __tsplusTrace) {
|
|
1509
1448
|
*/
|
1510
1449
|
function mapError_1(f, __tsplusTrace) {
|
1511
1450
|
return stream => {
|
1512
|
-
return new Stream(
|
1451
|
+
return new Stream(tsplus_module_12.mapError(f)(stream.channel));
|
1513
1452
|
};
|
1514
1453
|
}
|
1515
1454
|
/**
|
@@ -1519,7 +1458,7 @@ function mapError_1(f, __tsplusTrace) {
|
|
1519
1458
|
*/
|
1520
1459
|
export function mapErrorCause(f, __tsplusTrace) {
|
1521
1460
|
return fa => {
|
1522
|
-
return new Stream(
|
1461
|
+
return new Stream(tsplus_module_12.mapErrorCause(f)(fa.channel));
|
1523
1462
|
};
|
1524
1463
|
}
|
1525
1464
|
/**
|
@@ -1529,17 +1468,9 @@ export function mapErrorCause(f, __tsplusTrace) {
|
|
1529
1468
|
*/
|
1530
1469
|
function mapIO_1(f, __tsplusTrace) {
|
1531
1470
|
return stream => {
|
1532
|
-
return new Stream(
|
1471
|
+
return new Stream(tsplus_module_12.pipeTo(mapIOLoop(tsplus_module_40.empty()[Symbol.iterator](), f, __tsplusTrace))(stream.channel));
|
1533
1472
|
};
|
1534
1473
|
}
|
1535
|
-
function mapIOLoop(iterator, f, __tsplusTrace) {
|
1536
|
-
const next = iterator.next();
|
1537
|
-
if (next.done) {
|
1538
|
-
return tsplus_module_10.readWithCause(elem => mapIOLoop(elem[Symbol.iterator](), f, __tsplusTrace), tsplus_module_11.failCauseNow, tsplus_module_11.succeedNow);
|
1539
|
-
} else {
|
1540
|
-
return tsplus_module_10.unwrap(() => tsplus_module_1.map(b => tsplus_module_11.zipRight(mapIOLoop(iterator, f, __tsplusTrace))(tsplus_module_10.writeNow(tsplus_module_19.single(b))), __tsplusTrace)(f(next.value)));
|
1541
|
-
}
|
1542
|
-
}
|
1543
1474
|
/**
|
1544
1475
|
* Maps over elements of the stream with the specified effectful function,
|
1545
1476
|
* executing up to `n` invocations of `f` concurrently. Transformed elements
|
@@ -1551,7 +1482,7 @@ function mapIOLoop(iterator, f, __tsplusTrace) {
|
|
1551
1482
|
*/
|
1552
1483
|
export function mapIOConcurrently(n, f, __tsplusTrace) {
|
1553
1484
|
return stream => {
|
1554
|
-
return new Stream(
|
1485
|
+
return new Stream(tsplus_module_12.mapOut(tsplus_module_21.single)(tsplus_module_56.mapOutConcurrentIO(n, f)(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(stream.channel))));
|
1555
1486
|
};
|
1556
1487
|
}
|
1557
1488
|
/**
|
@@ -1559,9 +1490,17 @@ export function mapIOConcurrently(n, f, __tsplusTrace) {
|
|
1559
1490
|
*/
|
1560
1491
|
export function mapIOConcurrentlyUnordered(n, f) {
|
1561
1492
|
return self => {
|
1562
|
-
return pipeThroughChannelOrFail_1(
|
1493
|
+
return pipeThroughChannelOrFail_1(tsplus_module_57.mergeMap(inp => fromIO_1(f(inp), fileName_1 + ":2225:41").channel, n, 16)(tsplus_module_12.concatMap(chunk => tsplus_module_12.writeChunk(chunk))(tsplus_module_12.id())))(self);
|
1563
1494
|
};
|
1564
1495
|
}
|
1496
|
+
function mapIOLoop(iterator, f, __tsplusTrace) {
|
1497
|
+
const next = iterator.next();
|
1498
|
+
if (next.done) {
|
1499
|
+
return tsplus_module_12.readWithCause(elem => mapIOLoop(elem[Symbol.iterator](), f, __tsplusTrace), tsplus_module_13.failCauseNow, tsplus_module_13.succeedNow);
|
1500
|
+
} else {
|
1501
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(b => tsplus_module_13.zipRight(mapIOLoop(iterator, f, __tsplusTrace))(tsplus_module_12.writeNow(tsplus_module_21.single(b))), __tsplusTrace)(f(next.value)));
|
1502
|
+
}
|
1503
|
+
}
|
1565
1504
|
/**
|
1566
1505
|
* Merges this stream and the specified stream together.
|
1567
1506
|
*
|
@@ -1575,6 +1514,14 @@ function merge_1(that, strategy = "Both", __tsplusTrace) {
|
|
1575
1514
|
return mergeWith_1(that, identity, identity, strategy, __tsplusTrace)(self);
|
1576
1515
|
};
|
1577
1516
|
}
|
1517
|
+
/**
|
1518
|
+
* @tsplus pipeable fncts.io.Stream mergeEither
|
1519
|
+
*/
|
1520
|
+
function mergeEither_1(fb, __tsplusTrace) {
|
1521
|
+
return fa => {
|
1522
|
+
return mergeWith_1(fb, tsplus_module_20.left, tsplus_module_20.right)(fa);
|
1523
|
+
};
|
1524
|
+
}
|
1578
1525
|
/**
|
1579
1526
|
* Merges this stream and the specified stream together. New produced stream
|
1580
1527
|
* will terminate when either stream terminates.
|
@@ -1619,17 +1566,6 @@ export function mergeLeft(that, __tsplusTrace) {
|
|
1619
1566
|
return merge_1(drain_1(that, __tsplusTrace))(self);
|
1620
1567
|
};
|
1621
1568
|
}
|
1622
|
-
/**
|
1623
|
-
* Merges this stream and the specified stream together, discarding the values
|
1624
|
-
* from the left stream.
|
1625
|
-
*
|
1626
|
-
* @tsplus pipeable fncts.io.Stream mergeRight
|
1627
|
-
*/
|
1628
|
-
export function mergeRight(that, __tsplusTrace) {
|
1629
|
-
return self => {
|
1630
|
-
return merge_1(that)(drain_1(self, __tsplusTrace));
|
1631
|
-
};
|
1632
|
-
}
|
1633
1569
|
/**
|
1634
1570
|
* Maps each element of this stream to another stream and returns the
|
1635
1571
|
* non-deterministic merge of those streams, executing up to `n` inner streams
|
@@ -1640,7 +1576,7 @@ export function mergeRight(that, __tsplusTrace) {
|
|
1640
1576
|
*/
|
1641
1577
|
function mergeMap_1(f, n, bufferSize = 16, __tsplusTrace) {
|
1642
1578
|
return ma => {
|
1643
|
-
return new Stream(
|
1579
|
+
return new Stream(tsplus_module_57.mergeMap(a => f(a).channel, n, bufferSize)(tsplus_module_12.concatMap(tsplus_module_12.writeChunk)(ma.channel)));
|
1644
1580
|
};
|
1645
1581
|
}
|
1646
1582
|
/**
|
@@ -1656,24 +1592,27 @@ export function mergeMapIO(f, n, bufferSize = 16, __tsplusTrace) {
|
|
1656
1592
|
};
|
1657
1593
|
}
|
1658
1594
|
/**
|
1659
|
-
*
|
1595
|
+
* Merges this stream and the specified stream together, discarding the values
|
1596
|
+
* from the left stream.
|
1597
|
+
*
|
1598
|
+
* @tsplus pipeable fncts.io.Stream mergeRight
|
1660
1599
|
*/
|
1661
|
-
function
|
1662
|
-
return
|
1663
|
-
return
|
1600
|
+
export function mergeRight(that, __tsplusTrace) {
|
1601
|
+
return self => {
|
1602
|
+
return merge_1(that)(drain_1(self, __tsplusTrace));
|
1664
1603
|
};
|
1665
1604
|
}
|
1666
|
-
function mergeWithHandler(terminate, __tsplusTrace) {
|
1667
|
-
return exit => terminate || !tsplus_module_52.isSuccess(exit) ? tsplus_module_59.done(tsplus_module_1.fromExitNow(exit, __tsplusTrace)) : tsplus_module_59.wait(tsplus_module_1.fromExitNow);
|
1668
|
-
}
|
1669
1605
|
/**
|
1670
1606
|
* @tsplus pipeable fncts.io.Stream mergeWith
|
1671
1607
|
*/
|
1672
1608
|
function mergeWith_1(sb, l, r, strategy = "Both", __tsplusTrace) {
|
1673
1609
|
return sa => {
|
1674
|
-
return new Stream(
|
1610
|
+
return new Stream(tsplus_module_58.mergeWith(map_1(r, __tsplusTrace)(sb).channel, mergeWithHandler(strategy === "Either" || strategy === "Left", __tsplusTrace), mergeWithHandler(strategy === "Either" || strategy === "Right", __tsplusTrace))(map_1(l, __tsplusTrace)(sa).channel));
|
1675
1611
|
};
|
1676
1612
|
}
|
1613
|
+
function mergeWithHandler(terminate, __tsplusTrace) {
|
1614
|
+
return exit => terminate || !tsplus_module_52.isSuccess(exit) ? tsplus_module_59.done(tsplus_module_1.fromExitNow(exit, __tsplusTrace)) : tsplus_module_59.wait(tsplus_module_1.fromExitNow);
|
1615
|
+
}
|
1677
1616
|
/**
|
1678
1617
|
* Runs the specified effect if this stream fails, providing the error to the effect if it exists.
|
1679
1618
|
*
|
@@ -1695,7 +1634,7 @@ export function onError(cleanup, __tsplusTrace) {
|
|
1695
1634
|
*/
|
1696
1635
|
function orElse_1(that, __tsplusTrace) {
|
1697
1636
|
return stream => {
|
1698
|
-
return new Stream(
|
1637
|
+
return new Stream(tsplus_module_12.orElse(that().channel)(stream.channel));
|
1699
1638
|
};
|
1700
1639
|
}
|
1701
1640
|
/**
|
@@ -1707,7 +1646,7 @@ function orElse_1(that, __tsplusTrace) {
|
|
1707
1646
|
*/
|
1708
1647
|
export function orElseEither(that, __tsplusTrace) {
|
1709
1648
|
return stream => {
|
1710
|
-
return orElse_1(() => map_1(
|
1649
|
+
return orElse_1(() => map_1(tsplus_module_20.right, __tsplusTrace)(that()), __tsplusTrace)(map_1(tsplus_module_20.left, __tsplusTrace)(stream));
|
1711
1650
|
};
|
1712
1651
|
}
|
1713
1652
|
/**
|
@@ -1728,7 +1667,7 @@ export function orElseFail(e, __tsplusTrace) {
|
|
1728
1667
|
* See also Stream#catchAll.
|
1729
1668
|
*/
|
1730
1669
|
export function orElseOptional(stream, that, __tsplusTrace) {
|
1731
|
-
return catchAll_1(maybeError =>
|
1670
|
+
return catchAll_1(maybeError => tsplus_module_22.match(() => that(), e => failNow_1(tsplus_module_5.just(e, __tsplusTrace), __tsplusTrace))(maybeError), __tsplusTrace)(stream);
|
1732
1671
|
}
|
1733
1672
|
/**
|
1734
1673
|
* Succeeds with the specified value if this one fails with a typed error.
|
@@ -1745,7 +1684,7 @@ export function orElseSucceed(a, __tsplusTrace) {
|
|
1745
1684
|
*/
|
1746
1685
|
function pipeThrough_1(sa, __tsplusTrace) {
|
1747
1686
|
return ma => {
|
1748
|
-
return new Stream(
|
1687
|
+
return new Stream(tsplus_module_12.pipeToOrFail(sa.channel)(ma.channel));
|
1749
1688
|
};
|
1750
1689
|
}
|
1751
1690
|
/**
|
@@ -1753,7 +1692,7 @@ function pipeThrough_1(sa, __tsplusTrace) {
|
|
1753
1692
|
*/
|
1754
1693
|
function pipeThroughChannelOrFail_1(channel) {
|
1755
1694
|
return self => {
|
1756
|
-
return new Stream(
|
1695
|
+
return new Stream(tsplus_module_12.pipeToOrFail(channel)(self.channel));
|
1757
1696
|
};
|
1758
1697
|
}
|
1759
1698
|
/**
|
@@ -1764,7 +1703,7 @@ function pipeThroughChannelOrFail_1(channel) {
|
|
1764
1703
|
*/
|
1765
1704
|
function provideEnvironment_1(r, __tsplusTrace) {
|
1766
1705
|
return ra => {
|
1767
|
-
return new Stream(
|
1706
|
+
return new Stream(tsplus_module_12.provideEnvironment(() => r)(ra.channel));
|
1768
1707
|
};
|
1769
1708
|
}
|
1770
1709
|
/**
|
@@ -1772,7 +1711,7 @@ function provideEnvironment_1(r, __tsplusTrace) {
|
|
1772
1711
|
*/
|
1773
1712
|
function provideLayer_1(layer, __tsplusTrace) {
|
1774
1713
|
return self => {
|
1775
|
-
return new Stream(
|
1714
|
+
return new Stream(tsplus_module_12.unwrapScoped(() => tsplus_module_1.map(r => tsplus_module_12.provideEnvironment(() => r)(self.channel), __tsplusTrace)(tsplus_module_60.build(layer, __tsplusTrace))));
|
1776
1715
|
};
|
1777
1716
|
}
|
1778
1717
|
/**
|
@@ -1781,7 +1720,19 @@ function provideLayer_1(layer, __tsplusTrace) {
|
|
1781
1720
|
export function provideSomeLayer(layer, __tsplusTrace) {
|
1782
1721
|
return self => {
|
1783
1722
|
// @ts-expect-error
|
1784
|
-
return provideLayer_1(
|
1723
|
+
return provideLayer_1(tsplus_module_61.and(layer, __tsplusTrace)(tsplus_module_61.environment(__tsplusTrace)), __tsplusTrace)(self);
|
1724
|
+
};
|
1725
|
+
}
|
1726
|
+
/**
|
1727
|
+
* Re-chunks the elements of the stream into chunks of
|
1728
|
+
* `n` elements each.
|
1729
|
+
* The last chunk might contain less than `n` elements
|
1730
|
+
*
|
1731
|
+
* @tsplus pipeable fncts.io.Stream rechunk
|
1732
|
+
*/
|
1733
|
+
export function rechunk(n, __tsplusTrace) {
|
1734
|
+
return stream => {
|
1735
|
+
return new Stream(tsplus_module_12.pipeTo(rechunkProcess(new Rechunker(n), n, __tsplusTrace))(stream.channel));
|
1785
1736
|
};
|
1786
1737
|
}
|
1787
1738
|
class Rechunker {
|
@@ -1797,15 +1748,15 @@ class Rechunker {
|
|
1797
1748
|
const result = this.builder;
|
1798
1749
|
this.builder = [];
|
1799
1750
|
this.pos = 0;
|
1800
|
-
return
|
1751
|
+
return tsplus_module_21.from(result);
|
1801
1752
|
}
|
1802
1753
|
return null;
|
1803
1754
|
}
|
1804
1755
|
emitOfNotEmpty() {
|
1805
1756
|
if (this.pos !== 0) {
|
1806
|
-
return
|
1757
|
+
return tsplus_module_12.writeNow(tsplus_module_21.from(this.builder));
|
1807
1758
|
} else {
|
1808
|
-
return
|
1759
|
+
return tsplus_module_12.unit;
|
1809
1760
|
}
|
1810
1761
|
}
|
1811
1762
|
get isEmpty() {
|
@@ -1813,16 +1764,16 @@ class Rechunker {
|
|
1813
1764
|
}
|
1814
1765
|
}
|
1815
1766
|
function rechunkProcess(rechunker, target, __tsplusTrace) {
|
1816
|
-
return
|
1767
|
+
return tsplus_module_12.readWithCause(chunk => {
|
1817
1768
|
if (chunk.length === target && rechunker.isEmpty) {
|
1818
|
-
return
|
1769
|
+
return tsplus_module_13.zipRight(rechunkProcess(rechunker, target, __tsplusTrace))(tsplus_module_12.writeNow(chunk));
|
1819
1770
|
} else if (chunk.length > 0) {
|
1820
1771
|
const chunks = [];
|
1821
1772
|
let result = null;
|
1822
1773
|
let i = 0;
|
1823
1774
|
while (i < chunk.length) {
|
1824
1775
|
while (i < chunk.length && result === null) {
|
1825
|
-
result = rechunker.write(
|
1776
|
+
result = rechunker.write(tsplus_module_14.unsafeGet(i)(chunk));
|
1826
1777
|
i += 1;
|
1827
1778
|
}
|
1828
1779
|
if (result !== null) {
|
@@ -1830,39 +1781,35 @@ function rechunkProcess(rechunker, target, __tsplusTrace) {
|
|
1830
1781
|
result = null;
|
1831
1782
|
}
|
1832
1783
|
}
|
1833
|
-
return
|
1784
|
+
return tsplus_module_13.zipRight(rechunkProcess(rechunker, target, __tsplusTrace))(tsplus_module_12.writeAll(chunks));
|
1834
1785
|
} else {
|
1835
1786
|
return rechunkProcess(rechunker, target, __tsplusTrace);
|
1836
1787
|
}
|
1837
|
-
}, cause =>
|
1788
|
+
}, cause => tsplus_module_13.zipRight(tsplus_module_13.failCauseNow(cause))(rechunker.emitOfNotEmpty()), () => rechunker.emitOfNotEmpty());
|
1838
1789
|
}
|
1839
1790
|
/**
|
1840
|
-
*
|
1841
|
-
* `n` elements each.
|
1842
|
-
* The last chunk might contain less than `n` elements
|
1791
|
+
* Creates a stream from an effect producing a value of type `A` which repeats forever.
|
1843
1792
|
*
|
1844
|
-
* @tsplus
|
1793
|
+
* @tsplus static fncts.io.StreamOps repeatIO
|
1845
1794
|
*/
|
1846
|
-
export function
|
1847
|
-
return
|
1848
|
-
return new Stream(tsplus_module_10.pipeTo(rechunkProcess(new Rechunker(n), n, __tsplusTrace))(stream.channel));
|
1849
|
-
};
|
1795
|
+
export function repeatIO(fa, __tsplusTrace) {
|
1796
|
+
return repeatIOMaybe_1(tsplus_module_1.mapError(tsplus_module_5.just, __tsplusTrace)(fa), __tsplusTrace);
|
1850
1797
|
}
|
1851
1798
|
/**
|
1852
|
-
*
|
1799
|
+
* Creates a stream from an effect producing chunks of `A` values which repeats forever.
|
1853
1800
|
*
|
1854
|
-
* @tsplus static fncts.io.StreamOps
|
1801
|
+
* @tsplus static fncts.io.StreamOps repeatIOChunk
|
1855
1802
|
*/
|
1856
|
-
export function
|
1857
|
-
return
|
1803
|
+
export function repeatIOChunk(fa, __tsplusTrace) {
|
1804
|
+
return repeatIOChunkMaybe_1(tsplus_module_1.mapError(tsplus_module_5.just, __tsplusTrace)(fa), __tsplusTrace);
|
1858
1805
|
}
|
1859
1806
|
/**
|
1860
|
-
* Creates a stream from an effect producing
|
1807
|
+
* Creates a stream from an effect producing chunks of `A` values until it fails with None.
|
1861
1808
|
*
|
1862
|
-
* @tsplus static fncts.io.StreamOps
|
1809
|
+
* @tsplus static fncts.io.StreamOps repeatIOChunkMaybe
|
1863
1810
|
*/
|
1864
|
-
|
1865
|
-
return
|
1811
|
+
function repeatIOChunkMaybe_1(fa, __tsplusTrace) {
|
1812
|
+
return unfoldChunkIO_1(undefined, _ => tsplus_module_1.catchAll(maybeError => tsplus_module_22.match(() => tsplus_module_1.succeedNow(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace), tsplus_module_1.failNow)(maybeError), __tsplusTrace)(tsplus_module_1.map(chunk => tsplus_module_5.just(tuple(chunk, undefined), __tsplusTrace), __tsplusTrace)(fa)), __tsplusTrace);
|
1866
1813
|
}
|
1867
1814
|
/**
|
1868
1815
|
* Creates a stream from an effect producing values of type `A` until it fails with None.
|
@@ -1870,23 +1817,15 @@ export function repeatIO(fa, __tsplusTrace) {
|
|
1870
1817
|
* @tsplus static fncts.io.StreamOps repeatIOMaybe
|
1871
1818
|
*/
|
1872
1819
|
function repeatIOMaybe_1(fa, __tsplusTrace) {
|
1873
|
-
return repeatIOChunkMaybe_1(tsplus_module_1.map(
|
1874
|
-
}
|
1875
|
-
/**
|
1876
|
-
* Creates a stream from an effect producing chunks of `A` values which repeats forever.
|
1877
|
-
*
|
1878
|
-
* @tsplus static fncts.io.StreamOps repeatIOChunk
|
1879
|
-
*/
|
1880
|
-
export function repeatIOChunk(fa, __tsplusTrace) {
|
1881
|
-
return repeatIOChunkMaybe_1(tsplus_module_1.mapError(tsplus_module_3.just, __tsplusTrace)(fa), __tsplusTrace);
|
1820
|
+
return repeatIOChunkMaybe_1(tsplus_module_1.map(tsplus_module_21.single, __tsplusTrace)(fa), __tsplusTrace);
|
1882
1821
|
}
|
1883
1822
|
/**
|
1884
|
-
*
|
1823
|
+
* Repeats the provided value infinitely.
|
1885
1824
|
*
|
1886
|
-
* @tsplus static fncts.io.StreamOps
|
1825
|
+
* @tsplus static fncts.io.StreamOps repeatValue
|
1887
1826
|
*/
|
1888
|
-
function
|
1889
|
-
return
|
1827
|
+
export function repeatValue(a, __tsplusTrace) {
|
1828
|
+
return new Stream(tsplus_module_12.repeated(tsplus_module_12.writeNow(tsplus_module_21.single(a))));
|
1890
1829
|
}
|
1891
1830
|
/**
|
1892
1831
|
* Runs the sink on the stream to produce either the sink's result or an error.
|
@@ -1895,7 +1834,7 @@ function repeatIOChunkMaybe_1(fa, __tsplusTrace) {
|
|
1895
1834
|
*/
|
1896
1835
|
function run_1(sink, __tsplusTrace) {
|
1897
1836
|
return stream => {
|
1898
|
-
return
|
1837
|
+
return tsplus_module_62.runDrain(tsplus_module_12.pipeToOrFail(sink.channel)(stream.channel));
|
1899
1838
|
};
|
1900
1839
|
}
|
1901
1840
|
/**
|
@@ -1904,7 +1843,7 @@ function run_1(sink, __tsplusTrace) {
|
|
1904
1843
|
* @tsplus getter fncts.io.Stream runCollect
|
1905
1844
|
*/
|
1906
1845
|
export function runCollect(stream, __tsplusTrace) {
|
1907
|
-
return run_1(
|
1846
|
+
return run_1(tsplus_module_48.makeCollectAll(__tsplusTrace), __tsplusTrace)(stream);
|
1908
1847
|
}
|
1909
1848
|
/**
|
1910
1849
|
* Runs the stream and collects ignore its elements.
|
@@ -1912,14 +1851,14 @@ export function runCollect(stream, __tsplusTrace) {
|
|
1912
1851
|
* @tsplus getter fncts.io.Stream runDrain
|
1913
1852
|
*/
|
1914
1853
|
export function runDrain(stream, __tsplusTrace) {
|
1915
|
-
return run_1(
|
1854
|
+
return run_1(tsplus_module_48.drain, __tsplusTrace)(stream);
|
1916
1855
|
}
|
1917
1856
|
/**
|
1918
1857
|
* @tsplus pipeable fncts.io.Stream runForeachScoped
|
1919
1858
|
*/
|
1920
1859
|
function runForeachScoped_1(f, __tsplusTrace) {
|
1921
1860
|
return self => {
|
1922
|
-
return runScoped_1(
|
1861
|
+
return runScoped_1(tsplus_module_48.makeForeach(f, __tsplusTrace), __tsplusTrace)(self);
|
1923
1862
|
};
|
1924
1863
|
}
|
1925
1864
|
/**
|
@@ -1930,20 +1869,19 @@ function runForeachScoped_1(f, __tsplusTrace) {
|
|
1930
1869
|
*/
|
1931
1870
|
export function runIntoElementsScoped_(queue, __tsplusTrace) {
|
1932
1871
|
return stream => {
|
1933
|
-
const writer =
|
1934
|
-
return tsplus_module_1.asUnit(
|
1872
|
+
const writer = tsplus_module_12.readWith(inp => tsplus_module_13.zipRight(writer)(tsplus_module_14.foldLeft(tsplus_module_12.unit, (channel, a) => tsplus_module_13.zipRight(tsplus_module_12.writeNow(tsplus_module_41.succeed(a, __tsplusTrace)))(channel))(inp)), err => tsplus_module_12.writeNow(tsplus_module_41.fail(tsplus_module_5.just(err, __tsplusTrace), __tsplusTrace)), () => tsplus_module_12.writeNow(tsplus_module_41.fail(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace)));
|
1873
|
+
return tsplus_module_1.asUnit(tsplus_module_18.runScoped(tsplus_module_12.drain(tsplus_module_12.mapOutIO(exit => tsplus_module_30.offer(exit, __tsplusTrace)(queue))(tsplus_module_12.pipeTo(writer)(stream.channel)))), __tsplusTrace);
|
1935
1874
|
};
|
1936
1875
|
}
|
1937
1876
|
/**
|
1938
|
-
* Like `Stream#
|
1877
|
+
* Like `Stream#runIntoHub`, but provides the result as a `Managed` to allow for scope
|
1939
1878
|
* composition.
|
1940
1879
|
*
|
1941
|
-
* @tsplus pipeable fncts.io.Stream
|
1880
|
+
* @tsplus pipeable fncts.io.Stream runIntoHubScoped
|
1942
1881
|
*/
|
1943
|
-
function
|
1882
|
+
function runIntoHubScoped_1(hub, __tsplusTrace) {
|
1944
1883
|
return stream => {
|
1945
|
-
|
1946
|
-
return tsplus_module_1.asUnit(tsplus_module_16.runScoped(tsplus_module_10.drain(tsplus_module_10.mapOutIO(take => tsplus_module_28.offer(take, __tsplusTrace)(queue))(tsplus_module_10.pipeTo(writer)(stream.channel)))), __tsplusTrace);
|
1884
|
+
return runIntoQueueScoped_1(hub, __tsplusTrace)(stream);
|
1947
1885
|
};
|
1948
1886
|
}
|
1949
1887
|
/**
|
@@ -1956,20 +1894,21 @@ function runIntoQueueElementsScoped_1(queue) {
|
|
1956
1894
|
return self => {
|
1957
1895
|
return tsplus_module_1.defer(() => {
|
1958
1896
|
const queue0 = queue();
|
1959
|
-
const writer =
|
1960
|
-
return tsplus_module_1.asUnit(
|
1961
|
-
}, fileName_1 + ":
|
1897
|
+
const writer = tsplus_module_12.readWithCause(inp => tsplus_module_13.zipRight(writer)(tsplus_module_12.fromIO(() => tsplus_module_30.offerAll(tsplus_module_14.map(a => tsplus_module_41.succeed(a, fileName_1 + ":2746:85"))(inp), fileName_1 + ":2746:57")(queue0))), cause => tsplus_module_12.fromIO(() => tsplus_module_30.offer(tsplus_module_41.failCause(tsplus_module_27.map(e => tsplus_module_5.just(e, fileName_1 + ":2747:84"))(cause), fileName_1 + ":2747:62"), fileName_1 + ":2747:47")(queue0)), () => tsplus_module_12.fromIO(() => tsplus_module_30.offer(tsplus_module_41.fail(tsplus_module_5.nothing(fileName_1 + ":2748:60"), fileName_1 + ":2748:52"), fileName_1 + ":2748:42")(queue0)));
|
1898
|
+
return tsplus_module_1.asUnit(tsplus_module_18.runScoped(tsplus_module_12.drain(tsplus_module_12.pipeTo(writer)(self.channel))), fileName_1 + ":2751:55");
|
1899
|
+
}, fileName_1 + ":2743:20");
|
1962
1900
|
};
|
1963
1901
|
}
|
1964
1902
|
/**
|
1965
|
-
* Like `Stream#
|
1903
|
+
* Like `Stream#into`, but provides the result as a `Managed` to allow for scope
|
1966
1904
|
* composition.
|
1967
1905
|
*
|
1968
|
-
* @tsplus pipeable fncts.io.Stream
|
1906
|
+
* @tsplus pipeable fncts.io.Stream runIntoQueueScoped
|
1969
1907
|
*/
|
1970
|
-
function
|
1908
|
+
function runIntoQueueScoped_1(queue, __tsplusTrace) {
|
1971
1909
|
return stream => {
|
1972
|
-
|
1910
|
+
const writer = tsplus_module_12.readWithCause(inp => tsplus_module_13.zipRight(writer)(tsplus_module_12.writeNow(tsplus_module_29.chunk(inp))), cause => tsplus_module_12.writeNow(tsplus_module_29.failCause(cause)), _ => tsplus_module_12.writeNow(tsplus_module_29.end));
|
1911
|
+
return tsplus_module_1.asUnit(tsplus_module_18.runScoped(tsplus_module_12.drain(tsplus_module_12.mapOutIO(take => tsplus_module_30.offer(take, __tsplusTrace)(queue))(tsplus_module_12.pipeTo(writer)(stream.channel)))), __tsplusTrace);
|
1973
1912
|
};
|
1974
1913
|
}
|
1975
1914
|
/**
|
@@ -1979,7 +1918,7 @@ function runIntoHubScoped_1(hub, __tsplusTrace) {
|
|
1979
1918
|
*/
|
1980
1919
|
function runScoped_1(sink, __tsplusTrace) {
|
1981
1920
|
return stream => {
|
1982
|
-
return
|
1921
|
+
return tsplus_module_18.runScoped(tsplus_module_12.drain(tsplus_module_12.pipeToOrFail(sink.channel)(stream.channel)));
|
1983
1922
|
};
|
1984
1923
|
}
|
1985
1924
|
/**
|
@@ -2023,7 +1962,68 @@ export function scanReduce(f, __tsplusTrace) {
|
|
2023
1962
|
*/
|
2024
1963
|
function scanReduceIO_1(f, __tsplusTrace) {
|
2025
1964
|
return fa => {
|
2026
|
-
return mapAccumIO_1(
|
1965
|
+
return mapAccumIO_1(tsplus_module_5.nothing(__tsplusTrace), (s, a) => tsplus_module_22.match(() => tsplus_module_1.succeedNow([a, tsplus_module_5.just(a, __tsplusTrace)], __tsplusTrace), b => tsplus_module_1.map(b => [b, tsplus_module_5.just(b, __tsplusTrace)], __tsplusTrace)(f(b, a)))(s), __tsplusTrace)(fa);
|
1966
|
+
};
|
1967
|
+
}
|
1968
|
+
/**
|
1969
|
+
* Creates a single-valued stream from a managed resource
|
1970
|
+
*
|
1971
|
+
* @tsplus static fncts.io.StreamOps scoped
|
1972
|
+
*/
|
1973
|
+
function scoped_1(stream, __tsplusTrace) {
|
1974
|
+
return new Stream(tsplus_module_12.scoped(() => tsplus_module_1.map(tsplus_module_21.single, __tsplusTrace)(stream())));
|
1975
|
+
}
|
1976
|
+
/**
|
1977
|
+
* Emits a sliding window of n elements.
|
1978
|
+
*
|
1979
|
+
* @tsplus pipeable fncts.io.Stream sliding
|
1980
|
+
*/
|
1981
|
+
export function sliding(chunkSize, stepSize, __tsplusTrace) {
|
1982
|
+
return self => {
|
1983
|
+
return defer_1(() => {
|
1984
|
+
function slidingChunk(chunk, input) {
|
1985
|
+
const updatedChunk = tsplus_module_14.concat(input)(chunk);
|
1986
|
+
const length = updatedChunk.length;
|
1987
|
+
if (length >= chunkSize) {
|
1988
|
+
const array = new Array((length - chunkSize) / stepSize + 1);
|
1989
|
+
let arrayIndex = 0;
|
1990
|
+
let chunkIndex = 0;
|
1991
|
+
while (chunkIndex + chunkSize <= length) {
|
1992
|
+
array[arrayIndex] = tsplus_module_14.slice(chunkIndex, chunkIndex + chunkSize)(updatedChunk);
|
1993
|
+
arrayIndex += 1;
|
1994
|
+
chunkIndex += stepSize;
|
1995
|
+
}
|
1996
|
+
return [tsplus_module_14.drop(chunkIndex)(updatedChunk), tsplus_module_63.fromArray(array)];
|
1997
|
+
} else {
|
1998
|
+
return [updatedChunk, tsplus_module_9.empty()];
|
1999
|
+
}
|
2000
|
+
}
|
2001
|
+
function sliding(chunk, written) {
|
2002
|
+
return tsplus_module_12.readWithCause(input => {
|
2003
|
+
const [updatedChunk, out] = slidingChunk(chunk, input);
|
2004
|
+
if (tsplus_module_14.isEmpty(out)) {
|
2005
|
+
return sliding(updatedChunk, written);
|
2006
|
+
} else {
|
2007
|
+
return tsplus_module_13.zipRight(sliding(updatedChunk, true))(tsplus_module_12.writeNow(out));
|
2008
|
+
}
|
2009
|
+
}, err => {
|
2010
|
+
const index = written && chunkSize > stepSize ? chunkSize - stepSize : 0;
|
2011
|
+
if (index >= chunk.length) {
|
2012
|
+
return tsplus_module_13.failCauseNow(err);
|
2013
|
+
} else {
|
2014
|
+
return tsplus_module_13.zipRight(tsplus_module_13.failCauseNow(err))(tsplus_module_12.writeNow(tsplus_module_21.single(chunk)));
|
2015
|
+
}
|
2016
|
+
}, done => {
|
2017
|
+
const index = written && chunkSize > stepSize ? chunkSize - stepSize : 0;
|
2018
|
+
if (index >= chunk.length) {
|
2019
|
+
return tsplus_module_13.succeedNow(done);
|
2020
|
+
} else {
|
2021
|
+
return tsplus_module_13.zipRight(tsplus_module_13.succeedNow(done))(tsplus_module_12.writeNow(tsplus_module_21.single(chunk)));
|
2022
|
+
}
|
2023
|
+
});
|
2024
|
+
}
|
2025
|
+
return new Stream(tsplus_module_12.pipeTo(sliding(tsplus_module_9.empty(), false))(self.channel));
|
2026
|
+
});
|
2027
2027
|
};
|
2028
2028
|
}
|
2029
2029
|
/**
|
@@ -2032,53 +2032,42 @@ function scanReduceIO_1(f, __tsplusTrace) {
|
|
2032
2032
|
export function split(predicate, __tsplusTrace) {
|
2033
2033
|
return self => {
|
2034
2034
|
function split(leftovers, input) {
|
2035
|
-
const [chunk, remaining] =
|
2036
|
-
if (
|
2037
|
-
return loop(
|
2035
|
+
const [chunk, remaining] = tsplus_module_14.splitWhere(predicate)(tsplus_module_14.concat(input)(leftovers));
|
2036
|
+
if (tsplus_module_14.isEmpty(chunk) || tsplus_module_14.isEmpty(remaining)) {
|
2037
|
+
return loop(tsplus_module_14.concat(tsplus_module_14.drop(1)(remaining))(chunk));
|
2038
2038
|
} else {
|
2039
|
-
return
|
2039
|
+
return tsplus_module_13.zipRight(split(tsplus_module_9.empty(), tsplus_module_14.drop(1)(remaining)))(tsplus_module_12.writeNow(tsplus_module_21.single(chunk)));
|
2040
2040
|
}
|
2041
2041
|
}
|
2042
2042
|
function loop(leftovers) {
|
2043
|
-
return
|
2044
|
-
if (
|
2045
|
-
return
|
2046
|
-
} else if (tsplus_module_64.isNothing(
|
2047
|
-
return
|
2043
|
+
return tsplus_module_12.readWith(input => split(leftovers, input), tsplus_module_12.failNow, _ => {
|
2044
|
+
if (tsplus_module_14.isEmpty(leftovers)) {
|
2045
|
+
return tsplus_module_12.unit;
|
2046
|
+
} else if (tsplus_module_64.isNothing(tsplus_module_14.find(predicate)(leftovers))) {
|
2047
|
+
return tsplus_module_13.zipRight(tsplus_module_12.unit)(tsplus_module_12.writeNow(tsplus_module_21.single(leftovers)));
|
2048
2048
|
} else {
|
2049
|
-
return
|
2049
|
+
return tsplus_module_13.zipRight(tsplus_module_12.unit)(split(tsplus_module_9.empty(), leftovers));
|
2050
2050
|
}
|
2051
2051
|
});
|
2052
2052
|
}
|
2053
|
-
return new Stream(
|
2053
|
+
return new Stream(tsplus_module_12.pipeTo(loop(tsplus_module_9.empty()))(self.channel));
|
2054
2054
|
};
|
2055
2055
|
}
|
2056
2056
|
/**
|
2057
2057
|
* Creates a single-valued pure stream
|
2058
2058
|
*
|
2059
|
-
* @tsplus static fncts.io.StreamOps
|
2059
|
+
* @tsplus static fncts.io.StreamOps succeed
|
2060
2060
|
*/
|
2061
|
-
function
|
2062
|
-
return
|
2061
|
+
export function succeed(a, __tsplusTrace) {
|
2062
|
+
return fromChunk_1(() => tsplus_module_21.single(a()), __tsplusTrace);
|
2063
2063
|
}
|
2064
2064
|
/**
|
2065
2065
|
* Creates a single-valued pure stream
|
2066
2066
|
*
|
2067
|
-
* @tsplus static fncts.io.StreamOps
|
2067
|
+
* @tsplus static fncts.io.StreamOps succeedNow
|
2068
2068
|
*/
|
2069
|
-
|
2070
|
-
return
|
2071
|
-
}
|
2072
|
-
function takeLoop(n, __tsplusTrace) {
|
2073
|
-
return tsplus_module_10.readWithCause(inp => {
|
2074
|
-
const taken = tsplus_module_12.take(n)(inp);
|
2075
|
-
const left = Math.max(n - taken.length, 0);
|
2076
|
-
if (left > 0) {
|
2077
|
-
return tsplus_module_11.zipRight(takeLoop(left, __tsplusTrace))(tsplus_module_10.writeNow(taken));
|
2078
|
-
} else {
|
2079
|
-
return tsplus_module_10.writeNow(taken);
|
2080
|
-
}
|
2081
|
-
}, tsplus_module_11.failCauseNow, tsplus_module_11.endNow);
|
2069
|
+
function succeedNow_1(o, __tsplusTrace) {
|
2070
|
+
return fromChunkNow_1(tsplus_module_21.single(o), __tsplusTrace);
|
2082
2071
|
}
|
2083
2072
|
/**
|
2084
2073
|
* Takes the specified number of elements from this stream.
|
@@ -2093,7 +2082,29 @@ export function take(n, __tsplusTrace) {
|
|
2093
2082
|
if (!Number.isInteger(n)) {
|
2094
2083
|
return halt_1(() => new tsplus_module_65.IllegalArgumentError(`${n} should be an integer`, "Stream.take"), __tsplusTrace);
|
2095
2084
|
}
|
2096
|
-
return new Stream(
|
2085
|
+
return new Stream(tsplus_module_12.pipeTo(takeLoop(n, __tsplusTrace))(stream.channel));
|
2086
|
+
};
|
2087
|
+
}
|
2088
|
+
function takeLoop(n, __tsplusTrace) {
|
2089
|
+
return tsplus_module_12.readWithCause(inp => {
|
2090
|
+
const taken = tsplus_module_14.take(n)(inp);
|
2091
|
+
const left = Math.max(n - taken.length, 0);
|
2092
|
+
if (left > 0) {
|
2093
|
+
return tsplus_module_13.zipRight(takeLoop(left, __tsplusTrace))(tsplus_module_12.writeNow(taken));
|
2094
|
+
} else {
|
2095
|
+
return tsplus_module_12.writeNow(taken);
|
2096
|
+
}
|
2097
|
+
}, tsplus_module_13.failCauseNow, tsplus_module_13.endNow);
|
2098
|
+
}
|
2099
|
+
/**
|
2100
|
+
* Takes all elements of the stream until the specified predicate evaluates
|
2101
|
+
* to `true`.
|
2102
|
+
*
|
2103
|
+
* @tsplus pipeable fncts.io.Stream takeUntil
|
2104
|
+
*/
|
2105
|
+
export function takeUntil(p, __tsplusTrace) {
|
2106
|
+
return fa => {
|
2107
|
+
return new Stream(tsplus_module_12.pipeTo(takeUntilLoop(p, __tsplusTrace))(fa.channel));
|
2097
2108
|
};
|
2098
2109
|
}
|
2099
2110
|
/**
|
@@ -2101,38 +2112,27 @@ export function take(n, __tsplusTrace) {
|
|
2101
2112
|
*/
|
2102
2113
|
export function takeUntilIO(f, __tsplusTrace) {
|
2103
2114
|
return ma => {
|
2104
|
-
return new Stream(
|
2115
|
+
return new Stream(tsplus_module_12.pipeTo(takeUntilIOLoop(tsplus_module_40.empty()[Symbol.iterator](), f, __tsplusTrace))(ma.channel));
|
2105
2116
|
};
|
2106
2117
|
}
|
2107
2118
|
function takeUntilIOLoop(iterator, f, __tsplusTrace) {
|
2108
2119
|
const next = iterator.next();
|
2109
2120
|
if (next.done) {
|
2110
|
-
return
|
2121
|
+
return tsplus_module_12.readWithCause(elem => takeUntilIOLoop(elem[Symbol.iterator](), f, __tsplusTrace), tsplus_module_13.failCauseNow, tsplus_module_13.succeedNow);
|
2111
2122
|
} else {
|
2112
|
-
return
|
2123
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(b => b ? tsplus_module_12.writeNow(tsplus_module_21.single(next.value)) : tsplus_module_13.zipRight(takeUntilIOLoop(iterator, f, __tsplusTrace))(tsplus_module_12.writeNow(tsplus_module_21.single(next.value))), __tsplusTrace)(f(next.value)));
|
2113
2124
|
}
|
2114
2125
|
}
|
2115
2126
|
function takeUntilLoop(p, __tsplusTrace) {
|
2116
|
-
return
|
2117
|
-
const taken =
|
2118
|
-
const last =
|
2119
|
-
if (
|
2120
|
-
return
|
2127
|
+
return tsplus_module_12.readWith(chunk => {
|
2128
|
+
const taken = tsplus_module_14.takeWhile(tsplus_module_47.invert(p))(chunk);
|
2129
|
+
const last = tsplus_module_14.take(1)(tsplus_module_14.drop(taken.length)(chunk));
|
2130
|
+
if (tsplus_module_14.isEmpty(last)) {
|
2131
|
+
return tsplus_module_13.zipRight(takeUntilLoop(p, __tsplusTrace))(tsplus_module_12.writeNow(taken));
|
2121
2132
|
} else {
|
2122
|
-
return
|
2133
|
+
return tsplus_module_12.writeNow(tsplus_module_14.concat(last)(taken));
|
2123
2134
|
}
|
2124
|
-
},
|
2125
|
-
}
|
2126
|
-
/**
|
2127
|
-
* Takes all elements of the stream until the specified predicate evaluates
|
2128
|
-
* to `true`.
|
2129
|
-
*
|
2130
|
-
* @tsplus pipeable fncts.io.Stream takeUntil
|
2131
|
-
*/
|
2132
|
-
export function takeUntil(p, __tsplusTrace) {
|
2133
|
-
return fa => {
|
2134
|
-
return new Stream(tsplus_module_10.pipeTo(takeUntilLoop(p, __tsplusTrace))(fa.channel));
|
2135
|
-
};
|
2135
|
+
}, tsplus_module_12.failNow, tsplus_module_13.succeedNow);
|
2136
2136
|
}
|
2137
2137
|
/**
|
2138
2138
|
* @tsplus pipeable fncts.io.Stream tap
|
@@ -2171,7 +2171,7 @@ function tapError_1(f, __tsplusTrace) {
|
|
2171
2171
|
*/
|
2172
2172
|
export function tapErrorCause(f, __tsplusTrace) {
|
2173
2173
|
return self => {
|
2174
|
-
return catchAllCause_1(e => fromIO_1(tsplus_module_1.zipRight(tsplus_module_1.refailCause(e, __tsplusTrace), __tsplusTrace)(f(e)), __tsplusTrace), __tsplusTrace)(self);
|
2174
|
+
return catchAllCause_1(e => fromIO_1(tsplus_module_1.zipRight(tsplus_module_1.refailCause(() => e, __tsplusTrace), __tsplusTrace)(f(e)), __tsplusTrace), __tsplusTrace)(self);
|
2175
2175
|
};
|
2176
2176
|
}
|
2177
2177
|
/**
|
@@ -2184,9 +2184,9 @@ export function tapSink(sink, __tsplusTrace) {
|
|
2184
2184
|
return self => {
|
2185
2185
|
return flatMap_1(([queue, future]) => {
|
2186
2186
|
const right = flattenTake_1(fromQueue_1(queue, 1, __tsplusTrace), __tsplusTrace);
|
2187
|
-
const loop =
|
2188
|
-
return merge_1(execute_1(tsplus_module_66.ensuring(tsplus_module_37.succeed_(undefined, __tsplusTrace)(future), __tsplusTrace)(run_1(sink, __tsplusTrace)(right)), __tsplusTrace), "Both", __tsplusTrace)(new Stream(
|
2189
|
-
}, __tsplusTrace)(fromIO_1(tsplus_module_1.zip(tsplus_module_38.make(__tsplusTrace), __tsplusTrace)(
|
2187
|
+
const loop = tsplus_module_12.readWithCause(chunk => tsplus_module_13.zipRight(loop)(tsplus_module_13.zipRight(tsplus_module_12.writeNow(chunk))(tsplus_module_12.fromIO(() => tsplus_module_30.offer(tsplus_module_29.chunk(chunk), __tsplusTrace)(queue)))), cause => tsplus_module_12.fromIO(() => tsplus_module_30.offer(tsplus_module_29.failCause(cause), __tsplusTrace)(queue)), () => tsplus_module_12.fromIO(() => tsplus_module_30.offer(tsplus_module_29.end, __tsplusTrace)(queue)));
|
2188
|
+
return merge_1(execute_1(tsplus_module_66.ensuring(tsplus_module_37.succeed_(undefined, __tsplusTrace)(future), __tsplusTrace)(run_1(sink, __tsplusTrace)(right)), __tsplusTrace), "Both", __tsplusTrace)(new Stream(tsplus_module_12.ensuring(tsplus_module_1.zipRight(tsplus_module_37.wait(future, __tsplusTrace), __tsplusTrace)(tsplus_module_26.forkDaemon(tsplus_module_30.offer(tsplus_module_29.end, __tsplusTrace)(queue), __tsplusTrace)))(tsplus_module_12.pipeTo(loop)(self.channel))));
|
2189
|
+
}, __tsplusTrace)(fromIO_1(tsplus_module_1.zip(tsplus_module_38.make(__tsplusTrace), __tsplusTrace)(tsplus_module_32.makeBounded(1, __tsplusTrace)), __tsplusTrace));
|
2190
2190
|
};
|
2191
2191
|
}
|
2192
2192
|
/**
|
@@ -2202,18 +2202,6 @@ export function throttleEnforce(costFn, units, duration, burst = 0, __tsplusTrac
|
|
2202
2202
|
return throttleEnforceIO_1(chunk => tsplus_module_1.succeedNow(costFn(chunk), __tsplusTrace), units, duration, burst, __tsplusTrace)(sa);
|
2203
2203
|
};
|
2204
2204
|
}
|
2205
|
-
function throttleEnforceIOLoop(costFn, units, duration, burst, tokens, timestamp, __tsplusTrace) {
|
2206
|
-
return tsplus_module_10.readWith(inp => tsplus_module_10.unwrap(() => tsplus_module_1.zipWith(tsplus_module_43.currentTime, (weight, current) => {
|
2207
|
-
const elapsed = current - timestamp;
|
2208
|
-
const cycles = elapsed / duration;
|
2209
|
-
const available = (() => {
|
2210
|
-
const sum = tokens + cycles * units;
|
2211
|
-
const max = units + burst < 0 ? Number.MAX_SAFE_INTEGER : units + burst;
|
2212
|
-
return sum < 0 ? max : Math.min(sum, max);
|
2213
|
-
})();
|
2214
|
-
return weight <= available ? tsplus_module_11.zipRight(throttleEnforceIOLoop(costFn, units, duration, burst, available - weight, current, __tsplusTrace))(tsplus_module_10.writeNow(inp)) : throttleEnforceIOLoop(costFn, units, duration, burst, available - weight, current, __tsplusTrace);
|
2215
|
-
}, __tsplusTrace)(costFn(inp))), tsplus_module_10.failNow, () => tsplus_module_10.unit);
|
2216
|
-
}
|
2217
2205
|
/**
|
2218
2206
|
* Throttles the chunks of this stream according to the given bandwidth parameters using the token bucket
|
2219
2207
|
* algorithm. Allows for burst in the processing of elements by allowing the token bucket to accumulate
|
@@ -2224,9 +2212,21 @@ function throttleEnforceIOLoop(costFn, units, duration, burst, tokens, timestamp
|
|
2224
2212
|
*/
|
2225
2213
|
function throttleEnforceIO_1(costFn, units, duration, burst = 0, __tsplusTrace) {
|
2226
2214
|
return sa => {
|
2227
|
-
return new Stream(
|
2215
|
+
return new Stream(tsplus_module_13.flatMap(current => tsplus_module_12.pipeTo(throttleEnforceIOLoop(costFn, units, duration, burst, units, current, __tsplusTrace))(sa.channel))(tsplus_module_12.fromIO(() => tsplus_module_43.currentTime)));
|
2228
2216
|
};
|
2229
2217
|
}
|
2218
|
+
function throttleEnforceIOLoop(costFn, units, duration, burst, tokens, timestamp, __tsplusTrace) {
|
2219
|
+
return tsplus_module_12.readWith(inp => tsplus_module_12.unwrap(() => tsplus_module_1.zipWith(tsplus_module_43.currentTime, (weight, current) => {
|
2220
|
+
const elapsed = current - timestamp;
|
2221
|
+
const cycles = elapsed / duration;
|
2222
|
+
const available = (() => {
|
2223
|
+
const sum = tokens + cycles * units;
|
2224
|
+
const max = units + burst < 0 ? Number.MAX_SAFE_INTEGER : units + burst;
|
2225
|
+
return sum < 0 ? max : Math.min(sum, max);
|
2226
|
+
})();
|
2227
|
+
return weight <= available ? tsplus_module_13.zipRight(throttleEnforceIOLoop(costFn, units, duration, burst, available - weight, current, __tsplusTrace))(tsplus_module_12.writeNow(inp)) : throttleEnforceIOLoop(costFn, units, duration, burst, available - weight, current, __tsplusTrace);
|
2228
|
+
}, __tsplusTrace)(costFn(inp))), tsplus_module_12.failNow, () => tsplus_module_12.unit);
|
2229
|
+
}
|
2230
2230
|
/**
|
2231
2231
|
* Converts the stream to a managed hub of chunks. After the managed hub is used,
|
2232
2232
|
* the hub will never again produce values and should be discarded.
|
@@ -2235,7 +2235,7 @@ function throttleEnforceIO_1(costFn, units, duration, burst = 0, __tsplusTrace)
|
|
2235
2235
|
*/
|
2236
2236
|
function toHub_1(capacity, __tsplusTrace) {
|
2237
2237
|
return stream => {
|
2238
|
-
return tsplus_module_1.flatMap(hub => tsplus_module_1.map(() => hub, __tsplusTrace)(tsplus_module_33.fork(runIntoHubScoped_1(hub, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(
|
2238
|
+
return tsplus_module_1.flatMap(hub => tsplus_module_1.map(() => hub, __tsplusTrace)(tsplus_module_33.fork(runIntoHubScoped_1(hub, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_34.makeBounded(capacity, __tsplusTrace), _ => tsplus_module_34.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2239
2239
|
};
|
2240
2240
|
}
|
2241
2241
|
/**
|
@@ -2244,7 +2244,7 @@ function toHub_1(capacity, __tsplusTrace) {
|
|
2244
2244
|
* @tsplus getter fncts.io.Stream toPull
|
2245
2245
|
*/
|
2246
2246
|
function toPull_1(stream, __tsplusTrace) {
|
2247
|
-
return tsplus_module_1.map(io => tsplus_module_1.flatMap(r =>
|
2247
|
+
return tsplus_module_1.map(io => tsplus_module_1.flatMap(r => tsplus_module_6.match(() => tsplus_module_1.failNow(tsplus_module_5.nothing(__tsplusTrace), __tsplusTrace), tsplus_module_1.succeedNow)(r), __tsplusTrace)(tsplus_module_1.mapError(tsplus_module_5.just, __tsplusTrace)(io)), __tsplusTrace)(tsplus_module_67.toPull(stream.channel));
|
2248
2248
|
}
|
2249
2249
|
/**
|
2250
2250
|
* Converts the stream to a managed queue of chunks. After the managed queue is used,
|
@@ -2254,7 +2254,7 @@ function toPull_1(stream, __tsplusTrace) {
|
|
2254
2254
|
*/
|
2255
2255
|
function toQueue_1(capacity = 2, __tsplusTrace) {
|
2256
2256
|
return stream => {
|
2257
|
-
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(
|
2257
|
+
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeBounded(capacity, __tsplusTrace), _ => tsplus_module_30.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2258
2258
|
};
|
2259
2259
|
}
|
2260
2260
|
/**
|
@@ -2262,7 +2262,7 @@ function toQueue_1(capacity = 2, __tsplusTrace) {
|
|
2262
2262
|
*/
|
2263
2263
|
export function toQueueDropping(capacity = 2, __tsplusTrace) {
|
2264
2264
|
return stream => {
|
2265
|
-
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(
|
2265
|
+
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeDropping(capacity, __tsplusTrace), _ => tsplus_module_30.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2266
2266
|
};
|
2267
2267
|
}
|
2268
2268
|
/**
|
@@ -2270,7 +2270,7 @@ export function toQueueDropping(capacity = 2, __tsplusTrace) {
|
|
2270
2270
|
*/
|
2271
2271
|
function toQueueOfElements_1(capacity = 2, __tsplusTrace) {
|
2272
2272
|
return stream => {
|
2273
|
-
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(
|
2273
|
+
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_19.forkScoped(runIntoQueueElementsScoped_1(() => queue)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeBounded(capacity, __tsplusTrace), _ => tsplus_module_30.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2274
2274
|
};
|
2275
2275
|
}
|
2276
2276
|
/**
|
@@ -2278,7 +2278,7 @@ function toQueueOfElements_1(capacity = 2, __tsplusTrace) {
|
|
2278
2278
|
*/
|
2279
2279
|
export function toQueueSliding(capacity = 2, __tsplusTrace) {
|
2280
2280
|
return stream => {
|
2281
|
-
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(
|
2281
|
+
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeSliding(capacity, __tsplusTrace), _ => tsplus_module_30.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2282
2282
|
};
|
2283
2283
|
}
|
2284
2284
|
/**
|
@@ -2288,7 +2288,7 @@ export function toQueueSliding(capacity = 2, __tsplusTrace) {
|
|
2288
2288
|
* @tsplus getter fncts.io.Stream toQueueUnbounded
|
2289
2289
|
*/
|
2290
2290
|
function toQueueUnbounded_1(stream, __tsplusTrace) {
|
2291
|
-
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(
|
2291
|
+
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_33.fork(runIntoQueueScoped_1(queue, __tsplusTrace)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_2.acquireRelease(() => tsplus_module_32.makeUnbounded(__tsplusTrace), _ => tsplus_module_30.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2292
2292
|
}
|
2293
2293
|
/**
|
2294
2294
|
* @tsplus getter fncts.io.Stream toReadableStream
|
@@ -2298,21 +2298,30 @@ export function toReadableStream(self, __tsplusTrace) {
|
|
2298
2298
|
let scope;
|
2299
2299
|
return new ReadableStream({
|
2300
2300
|
start(controller) {
|
2301
|
-
scope = tsplus_module_36.getOrThrow(
|
2302
|
-
pull = tsplus_module_1.asUnit(tsplus_module_1.catchAll(error =>
|
2301
|
+
scope = tsplus_module_36.getOrThrow(tsplus_module_31.unsafeRun(tsplus_module_68.make));
|
2302
|
+
pull = tsplus_module_1.asUnit(tsplus_module_1.catchAll(error => tsplus_module_22.match(() => tsplus_module_1.succeed(() => controller.close(), __tsplusTrace), error => tsplus_module_1.succeed(() => controller.error(error), __tsplusTrace))(error), __tsplusTrace)(tsplus_module_1.tapErrorCause(() => scope.close(() => tsplus_module_41.unit), __tsplusTrace)(tsplus_module_1.tap(chunk => tsplus_module_1.succeed(() => tsplus_module_14.forEach(a => {
|
2303
2303
|
controller.enqueue(a);
|
2304
|
-
})(chunk), __tsplusTrace), __tsplusTrace)(tsplus_module_36.getOrThrow(
|
2304
|
+
})(chunk), __tsplusTrace), __tsplusTrace)(tsplus_module_36.getOrThrow(tsplus_module_31.unsafeRun(tsplus_module_69.provideScope(scope)(toPull_1(self, __tsplusTrace))))))), __tsplusTrace);
|
2305
2305
|
},
|
2306
2306
|
pull() {
|
2307
|
-
return
|
2307
|
+
return tsplus_module_31.unsafeRunPromise(pull, __tsplusTrace);
|
2308
2308
|
},
|
2309
2309
|
cancel() {
|
2310
|
-
return
|
2310
|
+
return tsplus_module_31.unsafeRunPromise(scope.close(() => tsplus_module_41.unit), __tsplusTrace);
|
2311
2311
|
}
|
2312
2312
|
});
|
2313
2313
|
}
|
2314
|
-
|
2315
|
-
|
2314
|
+
/**
|
2315
|
+
* @tsplus static fncts.io.StreamOps unfold
|
2316
|
+
*/
|
2317
|
+
export function unfold(s, f, __tsplusTrace) {
|
2318
|
+
return unfoldChunk_1(s, s => tsplus_module_39.map(([a, s]) => tuple(tsplus_module_21.single(a), s))(f(s)), __tsplusTrace);
|
2319
|
+
}
|
2320
|
+
/**
|
2321
|
+
* @tsplus static fncts.io.StreamOps unfoldChunk
|
2322
|
+
*/
|
2323
|
+
function unfoldChunk_1(s, f, __tsplusTrace) {
|
2324
|
+
return new Stream(tsplus_module_12.defer(() => unfoldChunkLoop(s, f, __tsplusTrace)));
|
2316
2325
|
}
|
2317
2326
|
/**
|
2318
2327
|
* Creates a stream by effectfully peeling off the "layers" of a value of type `S`
|
@@ -2322,28 +2331,19 @@ function unfoldChunkIOLoop(s, f, __tsplusTrace) {
|
|
2322
2331
|
function unfoldChunkIO_1(s, f, __tsplusTrace) {
|
2323
2332
|
return new Stream(unfoldChunkIOLoop(s, f, __tsplusTrace));
|
2324
2333
|
}
|
2334
|
+
function unfoldChunkIOLoop(s, f, __tsplusTrace) {
|
2335
|
+
return tsplus_module_12.unwrap(() => tsplus_module_1.map(m => tsplus_module_22.match(() => tsplus_module_12.unit, ([as, s]) => tsplus_module_13.flatMap(() => unfoldChunkIOLoop(s, f, __tsplusTrace))(tsplus_module_12.writeNow(as)))(m), __tsplusTrace)(f(s)));
|
2336
|
+
}
|
2337
|
+
function unfoldChunkLoop(s, f, __tsplusTrace) {
|
2338
|
+
return tsplus_module_22.match(() => tsplus_module_12.unit, ([as, s]) => tsplus_module_13.flatMap(() => unfoldChunkLoop(s, f, __tsplusTrace))(tsplus_module_12.writeNow(as)))(f(s));
|
2339
|
+
}
|
2325
2340
|
/**
|
2326
2341
|
* Creates a stream by effectfully peeling off the "layers" of a value of type `S`
|
2327
2342
|
*
|
2328
2343
|
* @tsplus static fncts.io.StreamOps unfoldIO
|
2329
2344
|
*/
|
2330
2345
|
function unfoldIO_1(s, f, __tsplusTrace) {
|
2331
|
-
return unfoldChunkIO_1(s, _ => tsplus_module_1.map(m => tsplus_module_39.map(([a, s]) => tuple(
|
2332
|
-
}
|
2333
|
-
function unfoldChunkLoop(s, f, __tsplusTrace) {
|
2334
|
-
return tsplus_module_20.match(() => tsplus_module_10.unit, ([as, s]) => tsplus_module_11.flatMap(() => unfoldChunkLoop(s, f, __tsplusTrace))(tsplus_module_10.writeNow(as)))(f(s));
|
2335
|
-
}
|
2336
|
-
/**
|
2337
|
-
* @tsplus static fncts.io.StreamOps unfoldChunk
|
2338
|
-
*/
|
2339
|
-
function unfoldChunk_1(s, f, __tsplusTrace) {
|
2340
|
-
return new Stream(tsplus_module_10.defer(() => unfoldChunkLoop(s, f, __tsplusTrace)));
|
2341
|
-
}
|
2342
|
-
/**
|
2343
|
-
* @tsplus static fncts.io.StreamOps unfold
|
2344
|
-
*/
|
2345
|
-
export function unfold(s, f, __tsplusTrace) {
|
2346
|
-
return unfoldChunk_1(s, s => tsplus_module_39.map(([a, s]) => tuple(tsplus_module_19.single(a), s))(f(s)), __tsplusTrace);
|
2346
|
+
return unfoldChunkIO_1(s, _ => tsplus_module_1.map(m => tsplus_module_39.map(([a, s]) => tuple(tsplus_module_21.single(a), s))(m), __tsplusTrace)(f(_)), __tsplusTrace);
|
2347
2347
|
}
|
2348
2348
|
/**
|
2349
2349
|
* Creates a stream produced from an IO
|
@@ -2381,9 +2381,9 @@ export function zipWithIndex_(self, __tsplusTrace) {
|
|
2381
2381
|
export function zipWithLatest(fb, f, __tsplusTrace) {
|
2382
2382
|
return fa => {
|
2383
2383
|
function pullNonEmpty(pull, __tsplusTrace) {
|
2384
|
-
return tsplus_module_1.flatMap(chunk =>
|
2384
|
+
return tsplus_module_1.flatMap(chunk => tsplus_module_14.isNonEmpty(chunk) ? pullNonEmpty(pull, __tsplusTrace) : tsplus_module_1.succeedNow(chunk, __tsplusTrace), __tsplusTrace)(pull);
|
2385
2385
|
}
|
2386
|
-
return fromPull_1(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => toPull_1(flatMap_1(([l, r, leftFirst]) => flatMap_1(latest => concat_1(flatMap_1(fromChunkNow_1, __tsplusTrace)(mapIO_1(ab =>
|
2386
|
+
return fromPull_1(tsplus_module_1.flatMap(left => tsplus_module_1.flatMap(right => toPull_1(flatMap_1(([l, r, leftFirst]) => flatMap_1(latest => concat_1(flatMap_1(fromChunkNow_1, __tsplusTrace)(mapIO_1(ab => tsplus_module_6.match(leftChunk => tsplus_module_17.modify(([_, rightLatest]) => tuple(tsplus_module_14.map(a => f(a, rightLatest))(leftChunk), tuple(tsplus_module_14.unsafeGet(leftChunk.length - 1)(leftChunk), rightLatest)), __tsplusTrace)(latest), rightChunk => tsplus_module_17.modify(([leftLatest, _]) => tuple(tsplus_module_14.map(b => f(leftLatest, b))(rightChunk), tuple(leftLatest, tsplus_module_14.unsafeGet(rightChunk.length - 1)(rightChunk))), __tsplusTrace)(latest))(ab), __tsplusTrace)(mergeEither_1(repeatIOMaybe_1(right, __tsplusTrace), __tsplusTrace)(repeatIOMaybe_1(left, __tsplusTrace)))), __tsplusTrace)(fromChunk_1(() => leftFirst ? tsplus_module_14.map(b => f(tsplus_module_14.unsafeGet(l.length - 1)(l), b))(r) : tsplus_module_14.map(a => f(a, tsplus_module_14.unsafeGet(r.length - 1)(r)))(l), __tsplusTrace)), __tsplusTrace)(fromIO_1(tsplus_module_8.make(() => tuple(tsplus_module_14.unsafeGet(l.length - 1)(l), tsplus_module_14.unsafeGet(r.length - 1)(r)), __tsplusTrace), __tsplusTrace)), __tsplusTrace)(fromIOMaybe_1(tsplus_module_28.raceWith(() => right, (leftDone, rightFiber) => tsplus_module_1.zipWith(tsplus_module_24.join(rightFiber, __tsplusTrace), (l, r) => tuple(l, r, true), __tsplusTrace)(tsplus_module_1.fromExitNow(leftDone, __tsplusTrace)), (rightDone, leftFiber) => tsplus_module_1.zipWith(tsplus_module_24.join(leftFiber, __tsplusTrace), (r, l) => tuple(l, r, false), __tsplusTrace)(tsplus_module_1.fromExitNow(rightDone, __tsplusTrace)), __tsplusTrace)(left), __tsplusTrace)), __tsplusTrace), __tsplusTrace)(tsplus_module_1.map(pullNonEmpty, __tsplusTrace)(toPull_1(fb, __tsplusTrace))), __tsplusTrace)(tsplus_module_1.map(pullNonEmpty, __tsplusTrace)(toPull_1(fa, __tsplusTrace))), __tsplusTrace);
|
2387
2387
|
};
|
2388
2388
|
}
|
2389
2389
|
//# sourceMappingURL=api.mjs.map
|