@typed/fx 0.0.4 → 0.0.8
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/.eslintcache +1 -1
- package/cjs/Cause/Cause.d.ts +10 -0
- package/cjs/Cause/Cause.d.ts.map +1 -1
- package/cjs/Cause/Cause.js +37 -2
- package/cjs/Cause/Cause.js.map +1 -1
- package/cjs/Cause/Renderer.js +1 -1
- package/cjs/Cause/Renderer.js.map +1 -1
- package/cjs/Env/Env.d.ts +9 -1
- package/cjs/Env/Env.d.ts.map +1 -1
- package/cjs/Env/Env.js +32 -5
- package/cjs/Env/Env.js.map +1 -1
- package/cjs/Fiber/fromScope.d.ts +5 -0
- package/cjs/Fiber/fromScope.d.ts.map +1 -0
- package/cjs/Fiber/fromScope.js +17 -0
- package/cjs/Fiber/fromScope.js.map +1 -0
- package/cjs/FiberRef/builtins.d.ts +4 -1
- package/cjs/FiberRef/builtins.d.ts.map +1 -1
- package/cjs/FiberRef/builtins.js +40 -13
- package/cjs/FiberRef/builtins.js.map +1 -1
- package/cjs/FiberRuntime/FiberRuntime.d.ts.map +1 -1
- package/cjs/FiberRuntime/FiberRuntime.js +23 -14
- package/cjs/FiberRuntime/FiberRuntime.js.map +1 -1
- package/cjs/Fx/Fx.d.ts +4 -3
- package/cjs/Fx/Fx.d.ts.map +1 -1
- package/cjs/Fx/Fx.js +25 -24
- package/cjs/Fx/Fx.js.map +1 -1
- package/cjs/Fx/join.d.ts +1 -1
- package/cjs/Fx/join.d.ts.map +1 -1
- package/cjs/Fx/join.js +1 -1
- package/cjs/Fx/join.js.map +1 -1
- package/cjs/Schedule/ScheduleState.d.ts +3 -0
- package/cjs/Schedule/ScheduleState.d.ts.map +1 -1
- package/cjs/Schedule/ScheduleState.js +3 -0
- package/cjs/Schedule/ScheduleState.js.map +1 -1
- package/cjs/Scheduler/RootScheduler.d.ts.map +1 -1
- package/cjs/Scheduler/RootScheduler.js +4 -5
- package/cjs/Scheduler/RootScheduler.js.map +1 -1
- package/cjs/Scheduler/Scheduler.d.ts +2 -2
- package/cjs/Scheduler/Scheduler.d.ts.map +1 -1
- package/cjs/Scheduler/Scheduler.js.map +1 -1
- package/cjs/Scheduler/callbackScheduler.d.ts.map +1 -1
- package/cjs/Scheduler/callbackScheduler.js +1 -0
- package/cjs/Scheduler/callbackScheduler.js.map +1 -1
- package/cjs/Scheduler/runSchedule.d.ts +1 -1
- package/cjs/Scheduler/runSchedule.d.ts.map +1 -1
- package/cjs/Scheduler/runSchedule.js +3 -2
- package/cjs/Scheduler/runSchedule.js.map +1 -1
- package/cjs/Scope/LocalScope.d.ts.map +1 -1
- package/cjs/Scope/LocalScope.js +8 -8
- package/cjs/Scope/LocalScope.js.map +1 -1
- package/cjs/Semaphore/Semaphore.d.ts +9 -9
- package/cjs/Semaphore/Semaphore.d.ts.map +1 -1
- package/cjs/Semaphore/Semaphore.js +34 -15
- package/cjs/Semaphore/Semaphore.js.map +1 -1
- package/cjs/Sink/Sink.d.ts +1 -0
- package/cjs/Sink/Sink.d.ts.map +1 -1
- package/cjs/Sink/Sink.js +11 -1
- package/cjs/Sink/Sink.js.map +1 -1
- package/cjs/Stream/Stream.d.ts +5 -14
- package/cjs/Stream/Stream.d.ts.map +1 -1
- package/cjs/Stream/Stream.js.map +1 -1
- package/cjs/Stream/acquirePermit.d.ts +15 -0
- package/cjs/Stream/acquirePermit.d.ts.map +1 -0
- package/cjs/Stream/acquirePermit.js +43 -0
- package/cjs/Stream/acquirePermit.js.map +1 -0
- package/cjs/Stream/bimap.d.ts +33 -4
- package/cjs/Stream/bimap.d.ts.map +1 -1
- package/cjs/Stream/bimap.js +109 -12
- package/cjs/Stream/bimap.js.map +1 -1
- package/cjs/Stream/continueWith.d.ts +4 -3
- package/cjs/Stream/continueWith.d.ts.map +1 -1
- package/cjs/Stream/continueWith.js +9 -6
- package/cjs/Stream/continueWith.js.map +1 -1
- package/cjs/Stream/delay.d.ts +4 -0
- package/cjs/Stream/delay.d.ts.map +1 -0
- package/cjs/Stream/delay.js +30 -0
- package/cjs/Stream/delay.js.map +1 -0
- package/cjs/Stream/drain.d.ts +2 -2
- package/cjs/Stream/drain.d.ts.map +1 -1
- package/cjs/Stream/drain.js +5 -5
- package/cjs/Stream/drain.js.map +1 -1
- package/cjs/Stream/empty.d.ts.map +1 -1
- package/cjs/Stream/empty.js +1 -2
- package/cjs/Stream/empty.js.map +1 -1
- package/cjs/Stream/flatMap.d.ts +7 -5
- package/cjs/Stream/flatMap.d.ts.map +1 -1
- package/cjs/Stream/flatMap.js +33 -19
- package/cjs/Stream/flatMap.js.map +1 -1
- package/cjs/Stream/flatMapConcurrently.d.ts +6 -0
- package/cjs/Stream/flatMapConcurrently.d.ts.map +1 -0
- package/cjs/Stream/flatMapConcurrently.js +25 -0
- package/cjs/Stream/flatMapConcurrently.js.map +1 -0
- package/cjs/Stream/flatMapFx.d.ts +5 -1
- package/cjs/Stream/flatMapFx.d.ts.map +1 -1
- package/cjs/Stream/flatMapFx.js +18 -3
- package/cjs/Stream/flatMapFx.js.map +1 -1
- package/cjs/Stream/foldMap.d.ts +11 -0
- package/cjs/Stream/foldMap.d.ts.map +1 -0
- package/cjs/Stream/foldMap.js +67 -0
- package/cjs/Stream/foldMap.js.map +1 -0
- package/cjs/Stream/fromArray.d.ts +2 -0
- package/cjs/Stream/fromArray.d.ts.map +1 -0
- package/cjs/Stream/fromArray.js +12 -0
- package/cjs/Stream/fromArray.js.map +1 -0
- package/cjs/Stream/fromCallback.d.ts +4 -3
- package/cjs/Stream/fromCallback.d.ts.map +1 -1
- package/cjs/Stream/fromCallback.js +26 -26
- package/cjs/Stream/fromCallback.js.map +1 -1
- package/cjs/Stream/fromFx.d.ts +23 -8
- package/cjs/Stream/fromFx.d.ts.map +1 -1
- package/cjs/Stream/fromFx.js +36 -16
- package/cjs/Stream/fromFx.js.map +1 -1
- package/cjs/Stream/hkt.d.ts +24 -1
- package/cjs/Stream/hkt.d.ts.map +1 -1
- package/cjs/Stream/hkt.js +43 -5
- package/cjs/Stream/hkt.js.map +1 -1
- package/cjs/Stream/hold.d.ts +27 -0
- package/cjs/Stream/hold.d.ts.map +1 -0
- package/cjs/Stream/hold.js +94 -0
- package/cjs/Stream/hold.js.map +1 -0
- package/cjs/Stream/index.d.ts +14 -1
- package/cjs/Stream/index.d.ts.map +1 -1
- package/cjs/Stream/index.js +14 -1
- package/cjs/Stream/index.js.map +1 -1
- package/cjs/Stream/lazy.d.ts +3 -0
- package/cjs/Stream/lazy.d.ts.map +1 -0
- package/cjs/Stream/lazy.js +9 -0
- package/cjs/Stream/lazy.js.map +1 -0
- package/cjs/Stream/merge.d.ts +18 -0
- package/cjs/Stream/merge.d.ts.map +1 -0
- package/cjs/Stream/merge.js +84 -0
- package/cjs/Stream/merge.js.map +1 -0
- package/cjs/Stream/multicast.d.ts +27 -0
- package/cjs/Stream/multicast.d.ts.map +1 -0
- package/cjs/Stream/multicast.js +83 -0
- package/cjs/Stream/multicast.js.map +1 -0
- package/cjs/Stream/orElse.d.ts +17 -0
- package/cjs/Stream/orElse.d.ts.map +1 -0
- package/cjs/Stream/orElse.js +105 -0
- package/cjs/Stream/orElse.js.map +1 -0
- package/cjs/Stream/periodic.d.ts +1 -1
- package/cjs/Stream/periodic.d.ts.map +1 -1
- package/cjs/Stream/periodic.js +1 -1
- package/cjs/Stream/periodic.js.map +1 -1
- package/cjs/Stream/provide.d.ts +8 -0
- package/cjs/Stream/provide.d.ts.map +1 -0
- package/cjs/Stream/provide.js +42 -0
- package/cjs/Stream/provide.js.map +1 -0
- package/cjs/Stream/run.d.ts +2 -2
- package/cjs/Stream/run.d.ts.map +1 -1
- package/cjs/Stream/run.js +1 -1
- package/cjs/Stream/run.js.map +1 -1
- package/cjs/Stream/scan.d.ts +17 -0
- package/cjs/Stream/scan.d.ts.map +1 -0
- package/cjs/Stream/scan.js +32 -0
- package/cjs/Stream/scan.js.map +1 -0
- package/cjs/Stream/scheduled.d.ts +12 -3
- package/cjs/Stream/scheduled.d.ts.map +1 -1
- package/cjs/Stream/scheduled.js +23 -5
- package/cjs/Stream/scheduled.js.map +1 -1
- package/cjs/Stream/setFiberRefLocally.d.ts +15 -0
- package/cjs/Stream/setFiberRefLocally.d.ts.map +1 -0
- package/cjs/Stream/setFiberRefLocally.js +53 -0
- package/cjs/Stream/setFiberRefLocally.js.map +1 -0
- package/cjs/Stream/skipRepeats.d.ts +5 -0
- package/cjs/Stream/skipRepeats.d.ts.map +1 -0
- package/cjs/Stream/skipRepeats.js +36 -0
- package/cjs/Stream/skipRepeats.js.map +1 -0
- package/cjs/Stream/switchMap.d.ts +18 -0
- package/cjs/Stream/switchMap.d.ts.map +1 -0
- package/cjs/Stream/switchMap.js +124 -0
- package/cjs/Stream/switchMap.js.map +1 -0
- package/cjs/Stream/tap.d.ts +2 -1
- package/cjs/Stream/tap.d.ts.map +1 -1
- package/cjs/Stream/tap.js +4 -2
- package/cjs/Stream/tap.js.map +1 -1
- package/cjs/Supervisor/index.d.ts +2 -0
- package/cjs/Supervisor/index.d.ts.map +1 -1
- package/cjs/Supervisor/index.js +2 -0
- package/cjs/Supervisor/index.js.map +1 -1
- package/cjs/Supervisor/inheritFiberRefs.d.ts +2 -0
- package/cjs/Supervisor/inheritFiberRefs.d.ts.map +1 -0
- package/cjs/Supervisor/inheritFiberRefs.js +17 -0
- package/cjs/Supervisor/inheritFiberRefs.js.map +1 -0
- package/cjs/Timeline/index.js.map +1 -1
- package/esm/Cause/Cause.d.ts +10 -0
- package/esm/Cause/Cause.d.ts.map +1 -1
- package/esm/Cause/Cause.js +27 -0
- package/esm/Cause/Cause.js.map +1 -1
- package/esm/Cause/Renderer.js +1 -1
- package/esm/Cause/Renderer.js.map +1 -1
- package/esm/Env/Env.d.ts +9 -1
- package/esm/Env/Env.d.ts.map +1 -1
- package/esm/Env/Env.js +8 -5
- package/esm/Env/Env.js.map +1 -1
- package/esm/Fiber/fromScope.d.ts +5 -0
- package/esm/Fiber/fromScope.d.ts.map +1 -0
- package/esm/Fiber/fromScope.js +13 -0
- package/esm/Fiber/fromScope.js.map +1 -0
- package/esm/FiberRef/builtins.d.ts +4 -1
- package/esm/FiberRef/builtins.d.ts.map +1 -1
- package/esm/FiberRef/builtins.js +36 -12
- package/esm/FiberRef/builtins.js.map +1 -1
- package/esm/FiberRuntime/FiberRuntime.d.ts.map +1 -1
- package/esm/FiberRuntime/FiberRuntime.js +23 -14
- package/esm/FiberRuntime/FiberRuntime.js.map +1 -1
- package/esm/Fx/Fx.d.ts +4 -3
- package/esm/Fx/Fx.d.ts.map +1 -1
- package/esm/Fx/Fx.js +22 -22
- package/esm/Fx/Fx.js.map +1 -1
- package/esm/Fx/join.d.ts +1 -1
- package/esm/Fx/join.d.ts.map +1 -1
- package/esm/Fx/join.js +1 -1
- package/esm/Fx/join.js.map +1 -1
- package/esm/Schedule/ScheduleState.d.ts +3 -0
- package/esm/Schedule/ScheduleState.d.ts.map +1 -1
- package/esm/Schedule/ScheduleState.js +3 -0
- package/esm/Schedule/ScheduleState.js.map +1 -1
- package/esm/Scheduler/RootScheduler.d.ts.map +1 -1
- package/esm/Scheduler/RootScheduler.js +4 -5
- package/esm/Scheduler/RootScheduler.js.map +1 -1
- package/esm/Scheduler/Scheduler.d.ts +2 -2
- package/esm/Scheduler/Scheduler.d.ts.map +1 -1
- package/esm/Scheduler/Scheduler.js.map +1 -1
- package/esm/Scheduler/callbackScheduler.d.ts.map +1 -1
- package/esm/Scheduler/callbackScheduler.js +1 -0
- package/esm/Scheduler/callbackScheduler.js.map +1 -1
- package/esm/Scheduler/runSchedule.d.ts +1 -1
- package/esm/Scheduler/runSchedule.d.ts.map +1 -1
- package/esm/Scheduler/runSchedule.js +4 -3
- package/esm/Scheduler/runSchedule.js.map +1 -1
- package/esm/Scope/LocalScope.d.ts.map +1 -1
- package/esm/Scope/LocalScope.js +8 -8
- package/esm/Scope/LocalScope.js.map +1 -1
- package/esm/Semaphore/Semaphore.d.ts +9 -9
- package/esm/Semaphore/Semaphore.d.ts.map +1 -1
- package/esm/Semaphore/Semaphore.js +11 -15
- package/esm/Semaphore/Semaphore.js.map +1 -1
- package/esm/Sink/Sink.d.ts +1 -0
- package/esm/Sink/Sink.d.ts.map +1 -1
- package/esm/Sink/Sink.js +10 -1
- package/esm/Sink/Sink.js.map +1 -1
- package/esm/Stream/Stream.d.ts +5 -14
- package/esm/Stream/Stream.d.ts.map +1 -1
- package/esm/Stream/Stream.js.map +1 -1
- package/esm/Stream/acquirePermit.d.ts +15 -0
- package/esm/Stream/acquirePermit.d.ts.map +1 -0
- package/esm/Stream/acquirePermit.js +15 -0
- package/esm/Stream/acquirePermit.js.map +1 -0
- package/esm/Stream/bimap.d.ts +33 -4
- package/esm/Stream/bimap.d.ts.map +1 -1
- package/esm/Stream/bimap.js +102 -11
- package/esm/Stream/bimap.js.map +1 -1
- package/esm/Stream/continueWith.d.ts +4 -3
- package/esm/Stream/continueWith.d.ts.map +1 -1
- package/esm/Stream/continueWith.js +9 -6
- package/esm/Stream/continueWith.js.map +1 -1
- package/esm/Stream/delay.d.ts +4 -0
- package/esm/Stream/delay.d.ts.map +1 -0
- package/esm/Stream/delay.js +26 -0
- package/esm/Stream/delay.js.map +1 -0
- package/esm/Stream/drain.d.ts +2 -2
- package/esm/Stream/drain.d.ts.map +1 -1
- package/esm/Stream/drain.js +6 -6
- package/esm/Stream/drain.js.map +1 -1
- package/esm/Stream/empty.d.ts.map +1 -1
- package/esm/Stream/empty.js +1 -2
- package/esm/Stream/empty.js.map +1 -1
- package/esm/Stream/flatMap.d.ts +7 -5
- package/esm/Stream/flatMap.d.ts.map +1 -1
- package/esm/Stream/flatMap.js +32 -19
- package/esm/Stream/flatMap.js.map +1 -1
- package/esm/Stream/flatMapConcurrently.d.ts +6 -0
- package/esm/Stream/flatMapConcurrently.d.ts.map +1 -0
- package/esm/Stream/flatMapConcurrently.js +19 -0
- package/esm/Stream/flatMapConcurrently.js.map +1 -0
- package/esm/Stream/flatMapFx.d.ts +5 -1
- package/esm/Stream/flatMapFx.d.ts.map +1 -1
- package/esm/Stream/flatMapFx.js +16 -4
- package/esm/Stream/flatMapFx.js.map +1 -1
- package/esm/Stream/foldMap.d.ts +11 -0
- package/esm/Stream/foldMap.d.ts.map +1 -0
- package/esm/Stream/foldMap.js +38 -0
- package/esm/Stream/foldMap.js.map +1 -0
- package/esm/Stream/fromArray.d.ts +2 -0
- package/esm/Stream/fromArray.d.ts.map +1 -0
- package/esm/Stream/fromArray.js +8 -0
- package/esm/Stream/fromArray.js.map +1 -0
- package/esm/Stream/fromCallback.d.ts +4 -3
- package/esm/Stream/fromCallback.d.ts.map +1 -1
- package/esm/Stream/fromCallback.js +26 -26
- package/esm/Stream/fromCallback.js.map +1 -1
- package/esm/Stream/fromFx.d.ts +23 -8
- package/esm/Stream/fromFx.d.ts.map +1 -1
- package/esm/Stream/fromFx.js +24 -14
- package/esm/Stream/fromFx.js.map +1 -1
- package/esm/Stream/hkt.d.ts +24 -1
- package/esm/Stream/hkt.d.ts.map +1 -1
- package/esm/Stream/hkt.js +41 -4
- package/esm/Stream/hkt.js.map +1 -1
- package/esm/Stream/hold.d.ts +27 -0
- package/esm/Stream/hold.d.ts.map +1 -0
- package/esm/Stream/hold.js +66 -0
- package/esm/Stream/hold.js.map +1 -0
- package/esm/Stream/index.d.ts +14 -1
- package/esm/Stream/index.d.ts.map +1 -1
- package/esm/Stream/index.js +14 -1
- package/esm/Stream/index.js.map +1 -1
- package/esm/Stream/lazy.d.ts +3 -0
- package/esm/Stream/lazy.d.ts.map +1 -0
- package/esm/Stream/lazy.js +5 -0
- package/esm/Stream/lazy.js.map +1 -0
- package/esm/Stream/merge.d.ts +18 -0
- package/esm/Stream/merge.d.ts.map +1 -0
- package/esm/Stream/merge.js +55 -0
- package/esm/Stream/merge.js.map +1 -0
- package/esm/Stream/multicast.d.ts +27 -0
- package/esm/Stream/multicast.d.ts.map +1 -0
- package/esm/Stream/multicast.js +55 -0
- package/esm/Stream/multicast.js.map +1 -0
- package/esm/Stream/orElse.d.ts +17 -0
- package/esm/Stream/orElse.d.ts.map +1 -0
- package/esm/Stream/orElse.js +77 -0
- package/esm/Stream/orElse.js.map +1 -0
- package/esm/Stream/periodic.d.ts +1 -1
- package/esm/Stream/periodic.d.ts.map +1 -1
- package/esm/Stream/periodic.js +1 -1
- package/esm/Stream/periodic.js.map +1 -1
- package/esm/Stream/provide.d.ts +8 -0
- package/esm/Stream/provide.d.ts.map +1 -0
- package/esm/Stream/provide.js +13 -0
- package/esm/Stream/provide.js.map +1 -0
- package/esm/Stream/run.d.ts +2 -2
- package/esm/Stream/run.d.ts.map +1 -1
- package/esm/Stream/run.js +2 -2
- package/esm/Stream/run.js.map +1 -1
- package/esm/Stream/scan.d.ts +17 -0
- package/esm/Stream/scan.d.ts.map +1 -0
- package/esm/Stream/scan.js +27 -0
- package/esm/Stream/scan.js.map +1 -0
- package/esm/Stream/scheduled.d.ts +12 -3
- package/esm/Stream/scheduled.d.ts.map +1 -1
- package/esm/Stream/scheduled.js +16 -4
- package/esm/Stream/scheduled.js.map +1 -1
- package/esm/Stream/setFiberRefLocally.d.ts +15 -0
- package/esm/Stream/setFiberRefLocally.d.ts.map +1 -0
- package/esm/Stream/setFiberRefLocally.js +25 -0
- package/esm/Stream/setFiberRefLocally.js.map +1 -0
- package/esm/Stream/skipRepeats.d.ts +5 -0
- package/esm/Stream/skipRepeats.d.ts.map +1 -0
- package/esm/Stream/skipRepeats.js +31 -0
- package/esm/Stream/skipRepeats.js.map +1 -0
- package/esm/Stream/switchMap.d.ts +18 -0
- package/esm/Stream/switchMap.d.ts.map +1 -0
- package/esm/Stream/switchMap.js +95 -0
- package/esm/Stream/switchMap.js.map +1 -0
- package/esm/Stream/tap.d.ts +2 -1
- package/esm/Stream/tap.d.ts.map +1 -1
- package/esm/Stream/tap.js +3 -2
- package/esm/Stream/tap.js.map +1 -1
- package/esm/Supervisor/index.d.ts +2 -0
- package/esm/Supervisor/index.d.ts.map +1 -1
- package/esm/Supervisor/index.js +2 -0
- package/esm/Supervisor/index.js.map +1 -1
- package/esm/Supervisor/inheritFiberRefs.d.ts +2 -0
- package/esm/Supervisor/inheritFiberRefs.d.ts.map +1 -0
- package/esm/Supervisor/inheritFiberRefs.js +14 -0
- package/esm/Supervisor/inheritFiberRefs.js.map +1 -0
- package/esm/Timeline/index.js.map +1 -1
- package/package.json +173 -37
- package/perf/Stream-filter-map-reduce.test.ts +103 -0
- package/readme.md +1 -1
- package/src/Cause/Cause.ts +63 -0
- package/src/Cause/Renderer.ts +1 -1
- package/src/Env/Env.ts +15 -5
- package/src/Fiber/fromScope.ts +19 -0
- package/src/FiberRef/builtins.ts +63 -11
- package/src/FiberRuntime/FiberRuntime.ts +35 -28
- package/src/Fx/Fx.test.ts +2 -2
- package/src/Fx/Fx.ts +11 -10
- package/src/Fx/join.ts +4 -4
- package/src/Schedule/ScheduleState.ts +3 -0
- package/src/Scheduler/RootScheduler.ts +7 -9
- package/src/Scheduler/Scheduler.ts +5 -6
- package/src/Scheduler/callbackScheduler.ts +1 -0
- package/src/Scheduler/runSchedule.ts +5 -2
- package/src/Scope/LocalScope.ts +8 -6
- package/src/Semaphore/Semaphore.ts +12 -19
- package/src/Sink/Sink.ts +11 -1
- package/src/Stream/Stream.ts +9 -15
- package/src/Stream/acquirePermit.ts +32 -0
- package/src/Stream/bimap.ts +164 -12
- package/src/Stream/continueWith.ts +11 -7
- package/src/Stream/delay.ts +43 -0
- package/src/Stream/drain.ts +8 -7
- package/src/Stream/empty.ts +1 -2
- package/src/Stream/flatMap.test.ts +8 -21
- package/src/Stream/flatMap.ts +46 -24
- package/src/Stream/flatMapConcurrently.test.ts +77 -0
- package/src/Stream/flatMapConcurrently.ts +34 -0
- package/src/Stream/flatMapFx.ts +37 -4
- package/src/Stream/foldMap.ts +88 -0
- package/src/Stream/fromArray.ts +8 -0
- package/src/Stream/fromCallback.test.ts +3 -16
- package/src/Stream/fromCallback.ts +48 -29
- package/src/Stream/fromFx.test.ts +3 -24
- package/src/Stream/fromFx.ts +54 -28
- package/src/Stream/hkt.ts +59 -10
- package/src/Stream/hold.test.ts +52 -0
- package/src/Stream/hold.ts +117 -0
- package/src/Stream/index.ts +14 -1
- package/src/Stream/lazy.ts +5 -0
- package/src/Stream/logging.test.ts +8 -3
- package/src/Stream/merge.test.ts +31 -0
- package/src/Stream/merge.ts +76 -0
- package/src/Stream/multicast.test.ts +32 -0
- package/src/Stream/multicast.ts +114 -0
- package/src/Stream/orElse.ts +107 -0
- package/src/Stream/periodic.ts +2 -2
- package/src/Stream/provide.test.ts +78 -0
- package/src/Stream/provide.ts +34 -0
- package/src/Stream/run.ts +6 -3
- package/src/Stream/scan.test.ts +28 -0
- package/src/Stream/scan.ts +46 -0
- package/src/Stream/scheduled.test.ts +9 -1
- package/src/Stream/scheduled.ts +46 -12
- package/src/Stream/setFiberRefLocally.ts +38 -0
- package/src/Stream/skipRepeats.ts +41 -0
- package/src/Stream/switchMap.test.ts +43 -0
- package/src/Stream/switchMap.ts +145 -0
- package/src/Stream/tap.ts +6 -3
- package/src/Supervisor/index.ts +2 -0
- package/src/Supervisor/inheritFiberRefs.ts +17 -0
- package/src/Timeline/index.ts +1 -0
- package/cjs/Effect/Effect.d.ts +0 -199
- package/cjs/Effect/Effect.d.ts.map +0 -1
- package/cjs/Effect/Effect.js +0 -66
- package/cjs/Effect/Effect.js.map +0 -1
- package/cjs/Stream/map.d.ts +0 -14
- package/cjs/Stream/map.d.ts.map +0 -1
- package/cjs/Stream/map.js +0 -30
- package/cjs/Stream/map.js.map +0 -1
- package/cjs/test.d.ts +0 -1
- package/cjs/test.d.ts.map +0 -1
- package/cjs/test.js +0 -2
- package/cjs/test.js.map +0 -1
- package/esm/Effect/Effect.d.ts +0 -199
- package/esm/Effect/Effect.d.ts.map +0 -1
- package/esm/Effect/Effect.js +0 -50
- package/esm/Effect/Effect.js.map +0 -1
- package/esm/Stream/map.d.ts +0 -14
- package/esm/Stream/map.d.ts.map +0 -1
- package/esm/Stream/map.js +0 -25
- package/esm/Stream/map.js.map +0 -1
- package/esm/test.d.ts +0 -1
- package/esm/test.d.ts.map +0 -1
- package/esm/test.js +0 -2
- package/esm/test.js.map +0 -1
- package/src/Effect/Effect.ts +0 -109
- package/src/Stream/map.ts +0 -35
- package/src/test.ts +0 -0
|
@@ -4,7 +4,7 @@ import { NonNegativeInteger } from 'hkt-ts/number'
|
|
|
4
4
|
import { AtomicCounter, decrement, increment } from '@/Atomic/AtomicCounter.js'
|
|
5
5
|
import { MutableFutureQueue } from '@/Future/MutableFutureQueue.js'
|
|
6
6
|
import { wait } from '@/Future/wait.js'
|
|
7
|
-
import
|
|
7
|
+
import * as Fx from '@/Fx/Fx.js'
|
|
8
8
|
import { fiberScoped, managed, scoped } from '@/Fx/scoped.js'
|
|
9
9
|
|
|
10
10
|
export class Semaphore {
|
|
@@ -22,10 +22,10 @@ export class Semaphore {
|
|
|
22
22
|
return this.running.get()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
readonly prepare = fromLazy(() => {
|
|
25
|
+
readonly prepare = Fx.fromLazy(() => {
|
|
26
26
|
if (this.available > 0) {
|
|
27
27
|
return new Acquisition(
|
|
28
|
-
fromLazy(() => {
|
|
28
|
+
Fx.fromLazy(() => {
|
|
29
29
|
increment(this.running)
|
|
30
30
|
}),
|
|
31
31
|
this.release,
|
|
@@ -39,11 +39,7 @@ export class Semaphore {
|
|
|
39
39
|
const acquisition = new Acquisition(
|
|
40
40
|
pipe(
|
|
41
41
|
wait(future),
|
|
42
|
-
|
|
43
|
-
fromLazy(() => {
|
|
44
|
-
increment(that.running)
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
42
|
+
Fx.tapLazy(() => increment(that.running)),
|
|
47
43
|
),
|
|
48
44
|
this.release,
|
|
49
45
|
)
|
|
@@ -51,17 +47,14 @@ export class Semaphore {
|
|
|
51
47
|
return acquisition
|
|
52
48
|
})
|
|
53
49
|
|
|
54
|
-
protected release = fromLazy(() => {
|
|
50
|
+
protected release = Fx.fromLazy(() => {
|
|
55
51
|
decrement(this.running)
|
|
56
|
-
|
|
57
|
-
if (this.waiting.size() > 0) {
|
|
58
|
-
this.waiting.next(unit)
|
|
59
|
-
}
|
|
52
|
+
this.waiting.next(Fx.unit)
|
|
60
53
|
})
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
export class Acquisition {
|
|
64
|
-
constructor(readonly acquire: Of<void>, readonly release: Of<void>) {}
|
|
57
|
+
constructor(readonly acquire: Fx.Of<void>, readonly release: Fx.Of<void>) {}
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
/**
|
|
@@ -80,7 +73,7 @@ export class Lock extends Semaphore {
|
|
|
80
73
|
export function acquirePermit(semaphore: Semaphore) {
|
|
81
74
|
return pipe(
|
|
82
75
|
semaphore.prepare,
|
|
83
|
-
flatMap(({ acquire, release }) => managed(acquire, constant(release))),
|
|
76
|
+
Fx.flatMap(({ acquire, release }) => managed(acquire, constant(release))),
|
|
84
77
|
)
|
|
85
78
|
}
|
|
86
79
|
|
|
@@ -88,10 +81,10 @@ export function acquirePermit(semaphore: Semaphore) {
|
|
|
88
81
|
* Acquire a permit from a given semaphore, run an Fx, and then release the permit.
|
|
89
82
|
*/
|
|
90
83
|
export function acquire(semaphore: Semaphore) {
|
|
91
|
-
return <R, E, A>(fx: Fx<R, E, A>) =>
|
|
84
|
+
return <R, E, A>(fx: Fx.Fx<R, E, A>) =>
|
|
92
85
|
pipe(
|
|
93
86
|
acquirePermit(semaphore),
|
|
94
|
-
flatMap(() => fx),
|
|
87
|
+
Fx.flatMap(() => fx),
|
|
95
88
|
scoped,
|
|
96
89
|
)
|
|
97
90
|
}
|
|
@@ -100,10 +93,10 @@ export function acquire(semaphore: Semaphore) {
|
|
|
100
93
|
* Acquire a permit from a given semaphore, run an Fx, and then release the permit.
|
|
101
94
|
*/
|
|
102
95
|
export function acquireFiber(semaphore: Semaphore) {
|
|
103
|
-
return <R, E, A>(fx: Fx<R, E, A>) =>
|
|
96
|
+
return <R, E, A>(fx: Fx.Fx<R, E, A>) =>
|
|
104
97
|
pipe(
|
|
105
98
|
acquirePermit(semaphore),
|
|
106
|
-
flatMap(() => fx),
|
|
99
|
+
Fx.flatMap(() => fx),
|
|
107
100
|
fiberScoped,
|
|
108
101
|
)
|
|
109
102
|
}
|
package/src/Sink/Sink.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { flow, pipe } from 'hkt-ts'
|
|
|
2
2
|
import { Left, Right } from 'hkt-ts/Either'
|
|
3
3
|
|
|
4
4
|
import { Cause } from '@/Cause/Cause.js'
|
|
5
|
-
import { Fx, IO, access, flatMap, fromLazy, provide, unit } from '@/Fx/Fx.js'
|
|
5
|
+
import { Fx, IO, access, addCustomTrace, flatMap, fromLazy, provide, unit } from '@/Fx/Fx.js'
|
|
6
6
|
import { Closeable } from '@/Scope/Closeable.js'
|
|
7
7
|
|
|
8
8
|
export interface Sink<in E, in A, out E2 = never> {
|
|
@@ -77,3 +77,13 @@ export function makeDrain<
|
|
|
77
77
|
}),
|
|
78
78
|
)
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
export function addTrace<E, A, E2>(sink: Sink<E, A, E2>, trace?: string): Sink<E, A, E2> {
|
|
82
|
+
if (trace === undefined) return sink
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
event: flow(sink.event, addCustomTrace(trace)),
|
|
86
|
+
error: flow(sink.error, addCustomTrace(trace)),
|
|
87
|
+
end: pipe(sink.end, addCustomTrace(trace)),
|
|
88
|
+
}
|
|
89
|
+
}
|
package/src/Stream/Stream.ts
CHANGED
|
@@ -7,19 +7,13 @@ import { Sink } from '@/Sink/Sink.js'
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* TODOS:
|
|
10
|
-
* - Scan
|
|
11
10
|
* - Loop
|
|
12
11
|
* - zipItems
|
|
13
12
|
* - withItems
|
|
14
|
-
* - switchLatest
|
|
15
|
-
* - concatMap
|
|
16
|
-
* - mergeConcurrently
|
|
17
|
-
* - merge/mergeArray
|
|
18
13
|
* - combine/combineArray
|
|
19
14
|
* - zip/zipArray
|
|
20
15
|
* - sample
|
|
21
16
|
* - snapshot
|
|
22
|
-
* - skipRepeats
|
|
23
17
|
* - slice/take/skip
|
|
24
18
|
* - takeWhile/skipWhile
|
|
25
19
|
* - takeUntil/skipUntil
|
|
@@ -27,27 +21,27 @@ import { Sink } from '@/Sink/Sink.js'
|
|
|
27
21
|
* - since
|
|
28
22
|
* - during
|
|
29
23
|
* - until
|
|
30
|
-
* - delay
|
|
31
24
|
* - throttle
|
|
32
25
|
* - debounce
|
|
33
|
-
* - orElse
|
|
34
|
-
* - multicast
|
|
35
|
-
* - hold
|
|
36
|
-
* - reduce
|
|
37
|
-
* - run
|
|
38
26
|
* - Fusion/Commutation
|
|
39
27
|
* - Unique Identification for streams to add to tracing
|
|
40
28
|
* - How to build a dynamic stream graph?
|
|
41
29
|
*/
|
|
42
30
|
|
|
43
|
-
export interface Stream<R = never, E = never, A = unknown> {
|
|
44
|
-
|
|
31
|
+
export interface Stream<out R = never, out E = never, out A = unknown> {
|
|
32
|
+
fork<E2 = never>(
|
|
45
33
|
sink: Sink<E, A, E2>,
|
|
46
34
|
scheduler: Scheduler,
|
|
47
35
|
context: FiberContext<FiberId.Live>,
|
|
48
|
-
)
|
|
36
|
+
): Fx.RIO<R, Fiber<E2, any>>
|
|
49
37
|
}
|
|
50
38
|
|
|
39
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
40
|
+
export type ResourcesOf<T> = T extends Stream<infer R, infer _, infer __> ? R : never
|
|
41
|
+
export type ErrorsOf<T> = T extends Stream<infer _, infer E, infer __> ? E : never
|
|
42
|
+
export type OutputOf<T> = T extends Stream<infer _, infer __, infer A> ? A : never
|
|
43
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
44
|
+
|
|
51
45
|
export interface RIO<R, A> extends Stream<R, never, A> {}
|
|
52
46
|
export interface IO<E, A> extends Stream<never, E, A> {}
|
|
53
47
|
export interface Of<A> extends Stream<never, never, A> {}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { pipe } from 'hkt-ts/function'
|
|
2
|
+
|
|
3
|
+
import { Stream } from './Stream.js'
|
|
4
|
+
|
|
5
|
+
import { FiberContext } from '@/FiberContext/FiberContext.js'
|
|
6
|
+
import { Live } from '@/FiberId/FiberId.js'
|
|
7
|
+
import * as Fx from '@/Fx/Fx.js'
|
|
8
|
+
import { Scheduler } from '@/Scheduler/index.js'
|
|
9
|
+
import * as Semaphore from '@/Semaphore/index.js'
|
|
10
|
+
import { Sink } from '@/Sink/Sink.js'
|
|
11
|
+
|
|
12
|
+
export function acquirePermit(semaphore: Semaphore.Semaphore) {
|
|
13
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> =>
|
|
14
|
+
new AcquirePermitStream(stream, semaphore)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class AcquirePermitStream<R, E, A> implements Stream<R, E, A> {
|
|
18
|
+
constructor(readonly stream: Stream<R, E, A>, readonly semaphore: Semaphore.Semaphore) {}
|
|
19
|
+
|
|
20
|
+
fork = <E2>(sink: Sink<E, A, E2>, scheduler: Scheduler, context: FiberContext<Live>) =>
|
|
21
|
+
pipe(
|
|
22
|
+
this.semaphore.prepare,
|
|
23
|
+
Fx.flatMap(({ acquire, release }) =>
|
|
24
|
+
pipe(
|
|
25
|
+
acquire,
|
|
26
|
+
Fx.uninterruptable,
|
|
27
|
+
Fx.tapLazy(() => context.scope.ensuring(() => release)),
|
|
28
|
+
Fx.flatMap(() => this.stream.fork(sink, scheduler, context)),
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
}
|
package/src/Stream/bimap.ts
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Maybe } from 'hkt-ts'
|
|
2
|
+
import { flow, pipe } from 'hkt-ts/function'
|
|
2
3
|
|
|
3
4
|
import { Stream } from './Stream.js'
|
|
4
|
-
import { MapStream } from './map.js'
|
|
5
5
|
|
|
6
6
|
import * as Cause from '@/Cause/index.js'
|
|
7
7
|
import { FiberContext } from '@/FiberContext/FiberContext.js'
|
|
8
8
|
import { Live } from '@/FiberId/FiberId.js'
|
|
9
|
+
import { unit } from '@/Fx/Fx.js'
|
|
9
10
|
import { Scheduler } from '@/Scheduler/Scheduler.js'
|
|
10
|
-
import { Sink } from '@/Sink/Sink.js'
|
|
11
|
+
import { Sink, addTrace } from '@/Sink/Sink.js'
|
|
11
12
|
|
|
12
13
|
export function bimap<A, B, C, D>(
|
|
13
14
|
f: (a: A) => B,
|
|
14
15
|
g: (c: C) => D,
|
|
16
|
+
__trace?: string,
|
|
15
17
|
): <R>(stream: Stream<R, A, C>) => Stream<R, B, D> {
|
|
16
|
-
return (stream) => BimapStream.make(stream, f, g)
|
|
18
|
+
return (stream) => BimapStream.make(stream, f, g, __trace)
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export class BimapStream<R, A, B, C, D> implements Stream<R, B, D> {
|
|
20
|
-
constructor(
|
|
22
|
+
constructor(
|
|
23
|
+
readonly stream: Stream<R, A, C>,
|
|
24
|
+
readonly f: (a: A) => B,
|
|
25
|
+
readonly g: (c: C) => D,
|
|
26
|
+
readonly __trace?: string,
|
|
27
|
+
) {}
|
|
21
28
|
|
|
22
|
-
fork = <
|
|
23
|
-
return this.stream.fork<
|
|
29
|
+
fork = <E>(sink: Sink<B, D, E>, scheduler: Scheduler, context: FiberContext<Live>) => {
|
|
30
|
+
return this.stream.fork<E>(
|
|
24
31
|
new BimapSink(sink, scheduler, context, this.f, this.g),
|
|
25
32
|
scheduler,
|
|
26
33
|
context,
|
|
@@ -31,16 +38,17 @@ export class BimapStream<R, A, B, C, D> implements Stream<R, B, D> {
|
|
|
31
38
|
stream: Stream<R, A, C>,
|
|
32
39
|
f: (a: A) => B,
|
|
33
40
|
g: (c: C) => D,
|
|
41
|
+
__trace?: string,
|
|
34
42
|
): Stream<R, B, D> {
|
|
35
43
|
if (stream instanceof MapStream) {
|
|
36
|
-
return BimapStream.make(stream.stream, f, flow(stream.f, g))
|
|
44
|
+
return BimapStream.make(stream.stream, f, flow(stream.f, g), __trace)
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
if (stream instanceof BimapStream) {
|
|
40
|
-
return BimapStream.make(stream.stream, flow(stream.f, f), flow(stream.g, g))
|
|
48
|
+
return BimapStream.make(stream.stream, flow(stream.f, f), flow(stream.g, g), __trace)
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
return new BimapStream(stream, f, g)
|
|
51
|
+
return new BimapStream(stream, f, g, __trace)
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
|
|
@@ -53,7 +61,151 @@ class BimapSink<A, B, C, D, E> implements Sink<A, C, E> {
|
|
|
53
61
|
readonly g: (c: C) => D,
|
|
54
62
|
) {}
|
|
55
63
|
|
|
56
|
-
event = (
|
|
57
|
-
error = (
|
|
64
|
+
event = flow(this.g, this.sink.event)
|
|
65
|
+
error = flow(Cause.map(this.f), this.sink.error)
|
|
58
66
|
end = this.sink.end
|
|
59
67
|
}
|
|
68
|
+
|
|
69
|
+
export function map<A, B>(
|
|
70
|
+
f: (a: A) => B,
|
|
71
|
+
__trace?: string,
|
|
72
|
+
): <R, E>(stream: Stream<R, E, A>) => Stream<R, E, B> {
|
|
73
|
+
return (stream) => MapStream.make(stream, f, __trace)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class MapStream<R, E, A, B> implements Stream<R, E, B> {
|
|
77
|
+
constructor(
|
|
78
|
+
readonly stream: Stream<R, E, A>,
|
|
79
|
+
readonly f: (a: A) => B,
|
|
80
|
+
readonly __trace?: string,
|
|
81
|
+
) {}
|
|
82
|
+
|
|
83
|
+
fork<E2>(sink: Sink<E, B, E2>, scheduler: Scheduler, context: FiberContext<Live>) {
|
|
84
|
+
return this.stream.fork(
|
|
85
|
+
addTrace(
|
|
86
|
+
{
|
|
87
|
+
...sink,
|
|
88
|
+
event: flow(this.f, sink.event),
|
|
89
|
+
},
|
|
90
|
+
this.__trace,
|
|
91
|
+
),
|
|
92
|
+
scheduler,
|
|
93
|
+
context,
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static make<R, E, A, B>(
|
|
98
|
+
stream: Stream<R, E, A>,
|
|
99
|
+
f: (a: A) => B,
|
|
100
|
+
__trace?: string,
|
|
101
|
+
): Stream<R, E, B> {
|
|
102
|
+
if (stream instanceof MapStream) {
|
|
103
|
+
return MapStream.make(stream.stream, flow(stream.f, f), __trace)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (stream instanceof MapLeftStream) {
|
|
107
|
+
return BimapStream.make(stream.stream, stream.f, f, __trace)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (stream instanceof FilterMapStream) {
|
|
111
|
+
return FilterMapStream.make(stream.stream, flow(stream.f, Maybe.map(f)), __trace)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return new MapStream(stream, f, __trace)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function mapLeft<E1, E2>(
|
|
119
|
+
f: (error: E1) => E2,
|
|
120
|
+
__trace?: string,
|
|
121
|
+
): <R, A>(stream: Stream<R, E1, A>) => Stream<R, E2, A> {
|
|
122
|
+
return (stream) => MapLeftStream.make(stream, f, __trace)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class MapLeftStream<R, E1, A, E2> implements Stream<R, E2, A> {
|
|
126
|
+
constructor(
|
|
127
|
+
readonly stream: Stream<R, E1, A>,
|
|
128
|
+
readonly f: (error: E1) => E2,
|
|
129
|
+
readonly __trace?: string,
|
|
130
|
+
) {}
|
|
131
|
+
|
|
132
|
+
fork<E3>(sink: Sink<E2, A, E3>, scheduler: Scheduler, context: FiberContext<Live>) {
|
|
133
|
+
return this.stream.fork(
|
|
134
|
+
addTrace(
|
|
135
|
+
{
|
|
136
|
+
...sink,
|
|
137
|
+
error: flow(Cause.map(this.f), sink.error),
|
|
138
|
+
},
|
|
139
|
+
this.__trace,
|
|
140
|
+
),
|
|
141
|
+
scheduler,
|
|
142
|
+
context,
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static make<R, E1, A, E2>(
|
|
147
|
+
stream: Stream<R, E1, A>,
|
|
148
|
+
f: (e: E1) => E2,
|
|
149
|
+
__trace?: string,
|
|
150
|
+
): Stream<R, E2, A> {
|
|
151
|
+
if (stream instanceof MapLeftStream) {
|
|
152
|
+
return MapLeftStream.make(stream.stream, flow(stream.f, f), __trace)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (stream instanceof MapStream) {
|
|
156
|
+
return BimapStream.make(stream.stream, f, stream.f, __trace)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return new MapLeftStream(stream, f, __trace)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function filterMap<A, B>(
|
|
164
|
+
f: (a: A) => Maybe.Maybe<B>,
|
|
165
|
+
__trace?: string,
|
|
166
|
+
): <R, E>(stream: Stream<R, E, A>) => Stream<R, E, B> {
|
|
167
|
+
return (stream) => FilterMapStream.make(stream, f, __trace)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export class FilterMapStream<R, E, A, B> implements Stream<R, E, B> {
|
|
171
|
+
constructor(
|
|
172
|
+
readonly stream: Stream<R, E, A>,
|
|
173
|
+
readonly f: (a: A) => Maybe.Maybe<B>,
|
|
174
|
+
readonly __trace?: string,
|
|
175
|
+
) {}
|
|
176
|
+
|
|
177
|
+
fork<E2>(sink: Sink<E, B, E2>, scheduler: Scheduler, context: FiberContext<Live>) {
|
|
178
|
+
return this.stream.fork(
|
|
179
|
+
addTrace(
|
|
180
|
+
{
|
|
181
|
+
...sink,
|
|
182
|
+
event: (a) =>
|
|
183
|
+
pipe(
|
|
184
|
+
a,
|
|
185
|
+
this.f,
|
|
186
|
+
Maybe.match(() => unit, sink.event),
|
|
187
|
+
),
|
|
188
|
+
},
|
|
189
|
+
this.__trace,
|
|
190
|
+
),
|
|
191
|
+
scheduler,
|
|
192
|
+
context,
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static make<R, E, A, B>(
|
|
197
|
+
stream: Stream<R, E, A>,
|
|
198
|
+
f: (a: A) => Maybe.Maybe<B>,
|
|
199
|
+
__trace?: string,
|
|
200
|
+
): Stream<R, E, B> {
|
|
201
|
+
if (stream instanceof MapStream) {
|
|
202
|
+
return FilterMapStream.make(stream.stream, flow(stream.f, f), __trace)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (stream instanceof FilterMapStream) {
|
|
206
|
+
return FilterMapStream.make(stream.stream, flow(stream.f, Maybe.flatMap(f)), __trace)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return new FilterMapStream(stream, f, __trace)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -8,23 +8,27 @@ import { FiberContext } from '@/FiberContext/FiberContext.js'
|
|
|
8
8
|
import { FiberId } from '@/FiberId/FiberId.js'
|
|
9
9
|
import * as Fx from '@/Fx/index.js'
|
|
10
10
|
import { Scheduler } from '@/Scheduler/Scheduler.js'
|
|
11
|
-
import { Sink } from '@/Sink/Sink.js'
|
|
11
|
+
import { Sink, addTrace } from '@/Sink/Sink.js'
|
|
12
12
|
|
|
13
|
-
export function continueWith<R2, E2, B>(f: () => Stream<R2, E2, B
|
|
13
|
+
export function continueWith<R2, E2, B>(f: () => Stream<R2, E2, B>, __trace?: string) {
|
|
14
14
|
return <R, E, A>(stream: Stream<R, E, A>): Stream<R | R2, E | E2, A | B> =>
|
|
15
|
-
new ContinueWith(stream, f)
|
|
15
|
+
new ContinueWith(stream, f, __trace)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const startWith =
|
|
19
|
-
<B>(value: B) =>
|
|
19
|
+
<B>(value: B, __trace?: string) =>
|
|
20
20
|
<R, E, A>(stream: Stream<R, E, A>) =>
|
|
21
21
|
pipe(
|
|
22
22
|
now(value),
|
|
23
|
-
continueWith(() => stream),
|
|
23
|
+
continueWith(() => stream, __trace),
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
export class ContinueWith<R, E, A, R2, E2, B> implements Stream<R | R2, E | E2, A | B> {
|
|
27
|
-
constructor(
|
|
27
|
+
constructor(
|
|
28
|
+
readonly stream: Stream<R, E, A>,
|
|
29
|
+
readonly f: () => Stream<R2, E2, B>,
|
|
30
|
+
readonly __trace?: string,
|
|
31
|
+
) {}
|
|
28
32
|
|
|
29
33
|
fork = <E3>(
|
|
30
34
|
sink: Sink<E | E2, A | B, E3>,
|
|
@@ -33,7 +37,7 @@ export class ContinueWith<R, E, A, R2, E2, B> implements Stream<R | R2, E | E2,
|
|
|
33
37
|
) => {
|
|
34
38
|
return Fx.access((env: Env<R | R2>) =>
|
|
35
39
|
this.stream.fork(
|
|
36
|
-
new ContinueWithSink(sink, scheduler, context, env, this.f),
|
|
40
|
+
addTrace(new ContinueWithSink(sink, scheduler, context, env, this.f), this.__trace),
|
|
37
41
|
scheduler,
|
|
38
42
|
context,
|
|
39
43
|
),
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Stream } from './Stream.js'
|
|
2
|
+
|
|
3
|
+
import { Env } from '@/Env/Env.js'
|
|
4
|
+
import { FiberContext } from '@/FiberContext/FiberContext.js'
|
|
5
|
+
import { FiberId } from '@/FiberId/FiberId.js'
|
|
6
|
+
import { access, fromLazy } from '@/Fx/index.js'
|
|
7
|
+
import { delayed } from '@/Schedule/Schedule.js'
|
|
8
|
+
import { Scheduler } from '@/Scheduler/Scheduler.js'
|
|
9
|
+
import { Sink } from '@/Sink/Sink.js'
|
|
10
|
+
import { Delay } from '@/Time/index.js'
|
|
11
|
+
|
|
12
|
+
export function delay(delay: Delay) {
|
|
13
|
+
return <R, E, A>(stream: Stream<R, E, A>): Stream<R, E, A> =>
|
|
14
|
+
Stream((sink, scheduler, context) =>
|
|
15
|
+
access((env: Env<R>) =>
|
|
16
|
+
stream.fork(new DelaySink(sink, scheduler, context, env, delay), scheduler, context),
|
|
17
|
+
),
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class DelaySink<E, A, E2> implements Sink<E, A, E2> {
|
|
22
|
+
constructor(
|
|
23
|
+
readonly sink: Sink<E, A, E2>,
|
|
24
|
+
readonly scheduler: Scheduler,
|
|
25
|
+
readonly context: FiberContext<FiberId.Live>,
|
|
26
|
+
readonly env: Env<any>,
|
|
27
|
+
readonly delay: Delay,
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
event(value: A) {
|
|
31
|
+
return fromLazy(() =>
|
|
32
|
+
this.scheduler.schedule(
|
|
33
|
+
this.sink.event(value),
|
|
34
|
+
this.env,
|
|
35
|
+
delayed(this.delay),
|
|
36
|
+
this.context.fork(),
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
error = this.sink.error
|
|
42
|
+
end = this.sink.end
|
|
43
|
+
}
|
package/src/Stream/drain.ts
CHANGED
|
@@ -7,18 +7,18 @@ import { FiberContext } from '@/FiberContext/FiberContext.js'
|
|
|
7
7
|
import { FiberId } from '@/FiberId/FiberId.js'
|
|
8
8
|
import * as Fx from '@/Fx/index.js'
|
|
9
9
|
import { Scheduler } from '@/Scheduler/Scheduler.js'
|
|
10
|
-
import { Drain, Sink, makeDrain } from '@/Sink/Sink.js'
|
|
10
|
+
import { Drain, Sink, addTrace, makeDrain } from '@/Sink/Sink.js'
|
|
11
11
|
|
|
12
12
|
export function drain<R, E, A>(
|
|
13
13
|
stream: Stream<R, E, A>,
|
|
14
14
|
__trace?: string,
|
|
15
|
-
): Fx.Fx<R | Scheduler, never, Fiber<
|
|
15
|
+
): Fx.Fx<R | Scheduler, never, Fiber<never, any>> {
|
|
16
16
|
return pipe(
|
|
17
17
|
Fx.Do,
|
|
18
18
|
Fx.bind('fiberContext', () => Fx.getFiberContext),
|
|
19
19
|
Fx.let('context', ({ fiberContext }) => fiberContext.fork()),
|
|
20
20
|
Fx.let('sink', ({ context }) => new Drain<E, A>(context.scope)),
|
|
21
|
-
Fx.flatMap(({ sink, context }) => fork(stream, sink, context), __trace),
|
|
21
|
+
Fx.flatMap(({ sink, context }) => fork(stream, sink, context, __trace), __trace),
|
|
22
22
|
)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -26,8 +26,9 @@ export function fork<R, E, A, E2 = never>(
|
|
|
26
26
|
stream: Stream<R, E, A>,
|
|
27
27
|
sink: Sink<E, A, E2>,
|
|
28
28
|
context: FiberContext<FiberId.Live>,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
__trace?: string,
|
|
30
|
+
): Fx.Fx<R | Scheduler, never, Fiber<E2, A>> {
|
|
31
|
+
return Fx.asks(Scheduler)((scheduler) => stream.fork(addTrace(sink, __trace), scheduler, context))
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export function observe<A, R2, E2, B>(f: (a: A) => Fx.Fx<R2, E2, B>, __trace?: string) {
|
|
@@ -37,7 +38,7 @@ export function observe<A, R2, E2, B>(f: (a: A) => Fx.Fx<R2, E2, B>, __trace?: s
|
|
|
37
38
|
Fx.bind('fiberContext', () => Fx.getFiberContext),
|
|
38
39
|
Fx.let('context', ({ fiberContext }) => fiberContext.fork()),
|
|
39
40
|
Fx.bind('sink', ({ context }) => makeDrain<E, A, R2, E2>(context.scope, { event: f })),
|
|
40
|
-
Fx.flatMap(({ sink, context }) => fork(stream, sink, context), __trace),
|
|
41
|
+
Fx.flatMap(({ sink, context }) => fork(stream, sink, context, __trace), __trace),
|
|
41
42
|
)
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -50,7 +51,7 @@ export function collect<R, E, A>(
|
|
|
50
51
|
|
|
51
52
|
yield* pipe(
|
|
52
53
|
stream,
|
|
53
|
-
observe((a) => Fx.fromLazy(() => events.push(a))),
|
|
54
|
+
observe((a) => Fx.fromLazy(() => events.push(a)), __trace),
|
|
54
55
|
Fx.flatMap(Fx.join),
|
|
55
56
|
)
|
|
56
57
|
|
package/src/Stream/empty.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Stream } from './Stream.js'
|
|
2
2
|
|
|
3
3
|
import * as Fx from '@/Fx/Fx.js'
|
|
4
|
-
import { span } from '@/Fx/logging.js'
|
|
5
4
|
|
|
6
5
|
export const empty = Stream<never, never, never>((sink, scheduler, context) =>
|
|
7
|
-
Fx.asksEnv((env) => scheduler.asap(sink.end, env, context
|
|
6
|
+
Fx.asksEnv((env) => scheduler.asap(sink.end, env, context)),
|
|
8
7
|
)
|
|
@@ -2,13 +2,11 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import { pipe } from 'hkt-ts'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { collectAll } from './_internal.test.js'
|
|
6
6
|
import { flatMap } from './flatMap.js'
|
|
7
7
|
import { fromFx } from './fromFx.js'
|
|
8
8
|
|
|
9
9
|
import * as Fx from '@/Fx/index.js'
|
|
10
|
-
import { RootScheduler } from '@/Scheduler/RootScheduler.js'
|
|
11
|
-
import { Scheduler } from '@/Scheduler/Scheduler.js'
|
|
12
10
|
import { testSuite } from '@/_internal/suite.js'
|
|
13
11
|
|
|
14
12
|
testSuite(import.meta.url, () => {
|
|
@@ -19,25 +17,14 @@ testSuite(import.meta.url, () => {
|
|
|
19
17
|
flatMap((a) => fromFx(Fx.success(a + 1))),
|
|
20
18
|
)
|
|
21
19
|
|
|
22
|
-
it('
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Fx.flatMap(Fx.join),
|
|
27
|
-
Fx.provideService(Scheduler, RootScheduler()),
|
|
28
|
-
Fx.runMain,
|
|
29
|
-
))
|
|
30
|
-
|
|
31
|
-
it('should be collectable', async () => {
|
|
32
|
-
await pipe(
|
|
33
|
-
Fx.Fx(function* () {
|
|
34
|
-
const events: readonly number[] = yield* collect(stream)
|
|
20
|
+
it('is collectable', async () => {
|
|
21
|
+
const events = await collectAll(stream)
|
|
22
|
+
deepStrictEqual(events, [value + 1])
|
|
23
|
+
})
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Fx.runMain,
|
|
40
|
-
)
|
|
25
|
+
it('is collectable with multiple subscribers', async () => {
|
|
26
|
+
const events = await Promise.all([collectAll(stream), collectAll(stream)])
|
|
27
|
+
deepStrictEqual(events, [[value + 1], [value + 1]])
|
|
41
28
|
})
|
|
42
29
|
})
|
|
43
30
|
})
|