@fncts/io 0.0.30 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- package/Channel/api/runScoped.d.ts +1 -0
- package/Channel/api.d.ts +1 -0
- package/Channel/internal/ChannelExecutor.d.ts +2 -2
- package/Fiber/FiberMessage.d.ts +5 -5
- package/IO/api/blocking.d.ts +7 -0
- package/IO/api/provideSomeLayer.d.ts +1 -2
- package/IO/api/zipConcurrent.d.ts +2 -1
- package/IO/runtime.d.ts +4 -2
- package/IO.d.ts +1 -0
- package/Ref/Synchronized/definition.d.ts +3 -3
- package/Semaphore.d.ts +30 -0
- package/Stream/api.d.ts +24 -4
- package/SubscriptionRef.d.ts +3 -3
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +14 -16
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +30 -32
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/runScoped.cjs +19 -3
- package/_cjs/Channel/api/runScoped.cjs.map +1 -1
- package/_cjs/Channel/api/toPull.cjs +1 -1
- package/_cjs/Channel/api/toPull.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +3 -2
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelExecutor.cjs +61 -52
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
- package/_cjs/Fiber/FiberMessage.cjs +12 -11
- package/_cjs/Fiber/FiberMessage.cjs.map +1 -1
- package/_cjs/Fiber/FiberRuntime.cjs +28 -27
- package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
- package/_cjs/FiberScope/definition.cjs +2 -2
- package/_cjs/FiberScope/definition.cjs.map +1 -1
- package/_cjs/Hub/api.cjs.map +1 -1
- package/_cjs/{RuntimeConfig.cjs → IO/api/blocking.cjs} +13 -5
- package/_cjs/IO/api/blocking.cjs.map +1 -0
- package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -1
- package/_cjs/IO/api/raceWith.cjs +9 -12
- package/_cjs/IO/api/raceWith.cjs.map +1 -1
- package/_cjs/IO/api/stateful.cjs +3 -3
- package/_cjs/IO/api/stateful.cjs.map +1 -1
- package/_cjs/IO/api/withChildren.cjs +5 -4
- package/_cjs/IO/api/withChildren.cjs.map +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs +23 -23
- package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +8 -8
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +11 -0
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/Queue/api/filterInputIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/constructors.cjs +4 -5
- package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +1 -2
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
- package/_cjs/Semaphore.cjs +90 -0
- package/_cjs/Semaphore.cjs.map +1 -0
- package/_cjs/Stream/api.cjs +101 -61
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/SubscriptionRef.cjs +2 -3
- package/_cjs/SubscriptionRef.cjs.map +1 -1
- package/_cjs/internal/BackgroundScheduler.cjs +199 -0
- package/_cjs/internal/BackgroundScheduler.cjs.map +1 -0
- package/_mjs/Cached/definition.mjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +14 -16
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs.map +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +30 -32
- package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
- package/_mjs/Channel/api/runScoped.mjs +19 -3
- 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 +3 -2
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelExecutor.mjs +61 -52
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
- package/_mjs/Fiber/FiberMessage.mjs +5 -5
- package/_mjs/Fiber/FiberMessage.mjs.map +1 -1
- package/_mjs/Fiber/FiberRuntime.mjs +28 -27
- package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
- package/_mjs/FiberScope/definition.mjs +2 -2
- package/_mjs/FiberScope/definition.mjs.map +1 -1
- package/_mjs/Hub/api.mjs.map +1 -1
- package/_mjs/IO/api/blocking.mjs +12 -0
- package/_mjs/IO/api/blocking.mjs.map +1 -0
- package/_mjs/IO/api/provideSomeLayer.mjs.map +1 -1
- package/_mjs/IO/api/raceWith.mjs +9 -12
- package/_mjs/IO/api/raceWith.mjs.map +1 -1
- package/_mjs/IO/api/stateful.mjs +3 -3
- package/_mjs/IO/api/stateful.mjs.map +1 -1
- package/_mjs/IO/api/withChildren.mjs +5 -4
- package/_mjs/IO/api/withChildren.mjs.map +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs +23 -23
- package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +6 -6
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +1 -0
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/Queue/api/filterInputIO.mjs.map +1 -1
- package/_mjs/Queue/api/filterOutputIO.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/constructors.mjs +4 -5
- package/_mjs/Ref/Synchronized/constructors.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs +1 -2
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/Semaphore.mjs +78 -0
- package/_mjs/Semaphore.mjs.map +1 -0
- package/_mjs/Stream/api.mjs +93 -57
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/SubscriptionRef.mjs +2 -3
- package/_mjs/SubscriptionRef.mjs.map +1 -1
- package/_mjs/internal/BackgroundScheduler.mjs +191 -0
- package/_mjs/internal/BackgroundScheduler.mjs.map +1 -0
- package/_src/Cached/definition.ts +1 -1
- package/_src/Channel/api/mapOutConcurrentIO.ts +1 -1
- package/_src/Channel/api/mergeAllWith.ts +1 -1
- package/_src/Channel/api/runScoped.ts +30 -5
- package/_src/Channel/api/toPull.ts +1 -1
- package/_src/Channel/api.ts +1 -0
- package/_src/Channel/internal/ChannelExecutor.ts +24 -20
- package/_src/Fiber/FiberMessage.ts +5 -5
- package/_src/Fiber/FiberRuntime.ts +1 -1
- package/_src/FiberRefs/api.ts +1 -1
- package/_src/Hub/api.ts +1 -1
- package/_src/IO/api/blocking.ts +9 -0
- package/_src/IO/api/provideSomeLayer.ts +1 -3
- package/_src/IO/api/raceWith.ts +1 -3
- package/_src/IO/api/stateful.ts +1 -1
- package/_src/IO/api/zipConcurrent.ts +26 -30
- package/_src/IO/runtime.ts +4 -4
- package/_src/IO.ts +1 -0
- package/_src/Queue/api/filterInputIO.ts +1 -1
- package/_src/Queue/api/filterOutputIO.ts +1 -1
- package/_src/Ref/Synchronized/constructors.ts +2 -2
- package/_src/Ref/Synchronized/definition.ts +1 -1
- package/_src/Semaphore.ts +81 -0
- package/_src/State/definition.ts +1 -1
- package/_src/Stream/api.ts +58 -7
- package/_src/Subject/Atomic.ts +1 -1
- package/_src/SubscriptionRef.ts +2 -2
- package/_src/global.ts +4 -4
- package/_src/index.ts +2 -2
- package/_src/internal/BackgroundScheduler.ts +276 -0
- package/global.d.ts +4 -4
- package/index.d.ts +2 -2
- package/internal/BackgroundScheduler.d.ts +47 -0
- package/package.json +3 -3
- package/RuntimeConfig.d.ts +0 -11
- package/_cjs/RuntimeConfig.cjs.map +0 -1
- package/_mjs/RuntimeConfig.mjs +0 -3
- package/_mjs/RuntimeConfig.mjs.map +0 -1
- package/_src/RuntimeConfig.ts +0 -6
package/_mjs/Stream/api.mjs
CHANGED
@@ -44,27 +44,25 @@ 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/
|
48
|
-
import * as tsplus_module_47 from "@fncts/io/
|
49
|
-
import * as tsplus_module_48 from "@fncts/
|
50
|
-
import * as tsplus_module_49 from "@fncts/io/
|
51
|
-
import * as tsplus_module_50 from "@fncts/
|
52
|
-
import * as tsplus_module_51 from "@fncts/io/
|
53
|
-
import * as tsplus_module_52 from "@fncts/
|
54
|
-
import * as tsplus_module_53 from "@fncts/io/
|
55
|
-
import * as tsplus_module_54 from "@fncts/
|
56
|
-
import * as tsplus_module_55 from "@fncts/io/
|
57
|
-
import * as tsplus_module_56 from "@fncts/io/
|
58
|
-
import * as tsplus_module_57 from "@fncts/io/Channel/api/
|
59
|
-
import * as tsplus_module_58 from "@fncts/io/Channel/
|
60
|
-
import * as tsplus_module_59 from "@fncts/io/Channel/api/
|
61
|
-
import * as tsplus_module_60 from "@fncts/io/
|
62
|
-
import * as tsplus_module_61 from "@fncts/io/
|
63
|
-
import * as tsplus_module_62 from "@fncts/io/
|
64
|
-
import * as tsplus_module_63 from "@fncts/
|
65
|
-
import * as tsplus_module_64 from "@fncts/io/Channel/api/
|
66
|
-
import * as tsplus_module_65 from "@fncts/base/data/exceptions";
|
67
|
-
import * as tsplus_module_66 from "@fncts/io/Channel/api/toPull";
|
47
|
+
import * as tsplus_module_46 from "@fncts/io/Semaphore";
|
48
|
+
import * as tsplus_module_47 from "@fncts/io/Sink/api";
|
49
|
+
import * as tsplus_module_48 from "@fncts/base/data/Predicate/api";
|
50
|
+
import * as tsplus_module_49 from "@fncts/io/Fiber/api/poll";
|
51
|
+
import * as tsplus_module_50 from "@fncts/io/IO/api/environment";
|
52
|
+
import * as tsplus_module_51 from "@fncts/io/collection/immutable/Conc/findIO";
|
53
|
+
import * as tsplus_module_52 from "@fncts/base/data/Exit/definition";
|
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/internal/MergeDecision";
|
60
|
+
import * as tsplus_module_59 from "@fncts/io/Channel/api/mergeWith";
|
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/data/exceptions";
|
65
|
+
import * as tsplus_module_64 from "@fncts/io/Channel/api/toPull";
|
68
66
|
export const aggregateAsyncWithin = aggregateAsyncWithin_1;
|
69
67
|
export const aggregateAsyncWithinEither = aggregateAsyncWithinEither_1;
|
70
68
|
export const zipRight = zipRight_1;
|
@@ -113,14 +111,15 @@ export const mergeEither = mergeEither_1;
|
|
113
111
|
export const mergeWith = mergeWith_1;
|
114
112
|
export const orElse = orElse_1;
|
115
113
|
export const pipeThrough = pipeThrough_1;
|
114
|
+
export const pipeThroughChannelOrFail = pipeThroughChannelOrFail_1;
|
116
115
|
export const provideEnvironment = provideEnvironment_1;
|
117
116
|
export const provideLayer = provideLayer_1;
|
118
117
|
export const repeatIOMaybe = repeatIOMaybe_1;
|
119
118
|
export const repeatIOChunkMaybe = repeatIOChunkMaybe_1;
|
120
119
|
export const run = run_1;
|
121
120
|
export const runForeachScoped = runForeachScoped_1;
|
122
|
-
export const runIntoElementsScoped_ = runIntoElementsScoped_1;
|
123
121
|
export const runIntoQueueScoped = runIntoQueueScoped_1;
|
122
|
+
export const runIntoQueueElementsScoped = runIntoQueueElementsScoped_1;
|
124
123
|
export const runIntoHubScoped = runIntoHubScoped_1;
|
125
124
|
export const runScoped = runScoped_1;
|
126
125
|
export const scanIO = scanIO_1;
|
@@ -590,7 +589,7 @@ export function combine(that, s, f, __tsplusTrace) {
|
|
590
589
|
};
|
591
590
|
}
|
592
591
|
function combineChunksProducer(handoff, latch, __tsplusTrace) {
|
593
|
-
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)), () =>
|
592
|
+
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)));
|
594
593
|
}
|
595
594
|
/**
|
596
595
|
* Combines the chunks from this stream and the specified stream by repeatedly applying the
|
@@ -703,6 +702,12 @@ export function debounce(duration, __tsplusTrace) {
|
|
703
702
|
}, __tsplusTrace)(tsplus_module_5.make()), __tsplusTrace), __tsplusTrace);
|
704
703
|
};
|
705
704
|
}
|
705
|
+
/**
|
706
|
+
* @tsplus static fncts.io.StreamOps defer
|
707
|
+
*/
|
708
|
+
export function defer(self) {
|
709
|
+
return new Stream(tsplus_module_10.defer(() => self().channel));
|
710
|
+
}
|
706
711
|
function defaultIfEmptyWriter(fb, __tsplusTrace) {
|
707
712
|
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);
|
708
713
|
}
|
@@ -751,12 +756,12 @@ function distributedWithDynamic_1(maximumLag, decide, done = () => tsplus_module
|
|
751
756
|
}
|
752
757
|
}, __tsplusTrace)), __tsplusTrace)(tsplus_module_14.get(queuesRef, __tsplusTrace)), __tsplusTrace)(decide(a));
|
753
758
|
return tsplus_module_1.flatMap(queuesRef => tsplus_module_1.map(add => add, __tsplusTrace)(tsplus_module_1.flatMap(queuesLock => tsplus_module_1.flatMap(newQueue => {
|
754
|
-
const finalize = endTake =>
|
759
|
+
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_25.interrupted(c) ? tsplus_module_3.just(tsplus_module_1.unit) : tsplus_module_3.nothing(), __tsplusTrace)(tsplus_module_28.offer(endTake, __tsplusTrace)(queue)), __tsplusTrace)), __tsplusTrace)(tsplus_module_1.map(map => tsplus_module_45.values(map), __tsplusTrace)(tsplus_module_14.get(queuesRef, __tsplusTrace))), __tsplusTrace)(tsplus_module_13.set(tsplus_module_1.flatMap(queue => tsplus_module_1.flatMap(() => {
|
755
760
|
const id = Symbol();
|
756
761
|
return tsplus_module_1.map(() => tuple(id, queue), __tsplusTrace)(tsplus_module_15.update(map => tsplus_module_45.set(id, queue)(map), __tsplusTrace)(queuesRef));
|
757
762
|
}, __tsplusTrace)(tsplus_module_28.offer(endTake, __tsplusTrace)(queue)), __tsplusTrace)(tsplus_module_30.makeBounded(1, __tsplusTrace)), __tsplusTrace)(newQueue)), __tsplusTrace));
|
758
|
-
return tsplus_module_1.map(() =>
|
759
|
-
}, __tsplusTrace)(tsplus_module_6.make(() => tsplus_module_1.flatMap(queue => tsplus_module_1.flatMap(id => tsplus_module_1.map(() => tuple(id, queue), __tsplusTrace)(tsplus_module_15.update(map => tsplus_module_45.set(id, queue)(map), __tsplusTrace)(queuesRef)), __tsplusTrace)(tsplus_module_1.succeed(() => Symbol(), __tsplusTrace)), __tsplusTrace)(tsplus_module_30.makeBounded(maximumLag, __tsplusTrace)), __tsplusTrace)), __tsplusTrace)(
|
763
|
+
return tsplus_module_1.map(() => queuesLock.withPermit(tsplus_module_1.flatten(tsplus_module_14.get(newQueue, __tsplusTrace), __tsplusTrace)), __tsplusTrace)(tsplus_module_33.fork(tsplus_module_1.matchCauseIO(cause => finalize(tsplus_module_41.failCause(tsplus_module_25.map(tsplus_module_3.just)(cause))), () => finalize(tsplus_module_41.fail(tsplus_module_3.nothing())), __tsplusTrace)(runForeachScoped_1(offer(queuesRef), __tsplusTrace)(self)), __tsplusTrace));
|
764
|
+
}, __tsplusTrace)(tsplus_module_6.make(() => tsplus_module_1.flatMap(queue => tsplus_module_1.flatMap(id => tsplus_module_1.map(() => tuple(id, queue), __tsplusTrace)(tsplus_module_15.update(map => tsplus_module_45.set(id, queue)(map), __tsplusTrace)(queuesRef)), __tsplusTrace)(tsplus_module_1.succeed(() => Symbol(), __tsplusTrace)), __tsplusTrace)(tsplus_module_30.makeBounded(maximumLag, __tsplusTrace)), __tsplusTrace)), __tsplusTrace)(tsplus_module_46.makeSemaphore(1, __tsplusTrace))), __tsplusTrace)(tsplus_module_31.acquireRelease(() => tsplus_module_6.make(() => tsplus_module_45.empty(), __tsplusTrace), ref => tsplus_module_1.flatMap(qs => tsplus_module_1.foreach(tsplus_module_45.values(qs), q => tsplus_module_28.shutdown(q, __tsplusTrace), __tsplusTrace), __tsplusTrace)(tsplus_module_14.get(ref, __tsplusTrace)), __tsplusTrace));
|
760
765
|
};
|
761
766
|
}
|
762
767
|
/**
|
@@ -794,7 +799,7 @@ function drop_1(n, __tsplusTrace) {
|
|
794
799
|
*/
|
795
800
|
function dropWhile_1(p, __tsplusTrace) {
|
796
801
|
return stream => {
|
797
|
-
return pipeThrough_1(
|
802
|
+
return pipeThrough_1(tsplus_module_47.makeDropWhile(p, __tsplusTrace), __tsplusTrace)(stream);
|
798
803
|
};
|
799
804
|
}
|
800
805
|
/**
|
@@ -805,7 +810,7 @@ function dropWhile_1(p, __tsplusTrace) {
|
|
805
810
|
*/
|
806
811
|
export function dropUntil(p, __tsplusTrace) {
|
807
812
|
return stream => {
|
808
|
-
return drop_1(1, __tsplusTrace)(dropWhile_1(
|
813
|
+
return drop_1(1, __tsplusTrace)(dropWhile_1(tsplus_module_48.invert(p), __tsplusTrace)(stream));
|
809
814
|
};
|
810
815
|
}
|
811
816
|
/**
|
@@ -823,10 +828,10 @@ export function either(stream, __tsplusTrace) {
|
|
823
828
|
/**
|
824
829
|
* @tsplus static fncts.io.StreamOps empty
|
825
830
|
*/
|
826
|
-
const empty_1 = /*#__PURE__*/fromChunkNow_1( /*#__PURE__*/tsplus_module_7.empty(), fileName_1 + ":
|
831
|
+
const empty_1 = /*#__PURE__*/fromChunkNow_1( /*#__PURE__*/tsplus_module_7.empty(), fileName_1 + ":1228:70");
|
827
832
|
export const empty = empty_1;
|
828
833
|
function endWhenWriter(fiber, __tsplusTrace) {
|
829
|
-
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)(
|
834
|
+
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)));
|
830
835
|
}
|
831
836
|
/**
|
832
837
|
* Halts the evaluation of this stream when the provided IO completes. The given IO
|
@@ -856,7 +861,7 @@ function ensuring_1(finalizer, __tsplusTrace) {
|
|
856
861
|
* @tsplus static fncts.io.StreamOps environment
|
857
862
|
*/
|
858
863
|
function environment_1(__tsplusTrace) {
|
859
|
-
return fromIO_1(
|
864
|
+
return fromIO_1(tsplus_module_50.environment(__tsplusTrace), __tsplusTrace);
|
860
865
|
}
|
861
866
|
/**
|
862
867
|
* Accesses the environment of the stream.
|
@@ -977,7 +982,7 @@ export function find(p, __tsplusTrace) {
|
|
977
982
|
*/
|
978
983
|
export function findIO(f, __tsplusTrace) {
|
979
984
|
return stream => {
|
980
|
-
const loop = tsplus_module_10.readWith(inp => tsplus_module_10.unwrap(() => tsplus_module_1.map(maybeA => tsplus_module_20.match(() => loop, a => tsplus_module_10.writeNow(tsplus_module_19.single(a)))(maybeA), __tsplusTrace)(
|
985
|
+
const loop = tsplus_module_10.readWith(inp => tsplus_module_10.unwrap(() => tsplus_module_1.map(maybeA => tsplus_module_20.match(() => loop, a => tsplus_module_10.writeNow(tsplus_module_19.single(a)))(maybeA), __tsplusTrace)(tsplus_module_51.findIO(f, __tsplusTrace)(inp))), tsplus_module_10.failNow, () => tsplus_module_10.unit);
|
981
986
|
return new Stream(tsplus_module_10.pipeTo(loop)(stream.channel));
|
982
987
|
};
|
983
988
|
}
|
@@ -999,7 +1004,7 @@ function flatten_1(self, __tsplusTrace) {
|
|
999
1004
|
*/
|
1000
1005
|
function flattenExitOption_1(stream, __tsplusTrace) {
|
1001
1006
|
const processChunk = (chunk, cont) => {
|
1002
|
-
const [toEmit, rest] = tsplus_module_12.splitWhere(_ => !
|
1007
|
+
const [toEmit, rest] = tsplus_module_12.splitWhere(_ => !tsplus_module_52.isSuccess(_))(chunk);
|
1003
1008
|
const next = tsplus_module_20.match(() => cont, exit => tsplus_module_36.match(cause => tsplus_module_20.match(() => tsplus_module_11.endNow(undefined), tsplus_module_11.failCauseNow)(tsplus_module_25.flipCauseOption(cause)), () => tsplus_module_11.endNow(undefined))(exit))(tsplus_module_12.head(rest));
|
1004
1009
|
return tsplus_module_11.zipRight(next)(tsplus_module_10.writeNow(tsplus_module_12.filterMap(exit => tsplus_module_36.match(() => tsplus_module_3.nothing(), tsplus_module_3.just)(exit))(toEmit)));
|
1005
1010
|
};
|
@@ -1135,11 +1140,11 @@ function fromPull_1(scopedPull, __tsplusTrace) {
|
|
1135
1140
|
function fromQueue_1(queue, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
|
1136
1141
|
return repeatIOChunkMaybe_1(tsplus_module_1.catchAllCause(c => tsplus_module_1.flatMap(down => {
|
1137
1142
|
if (down && tsplus_module_25.interrupted(c)) {
|
1138
|
-
return
|
1143
|
+
return tsplus_module_53.end;
|
1139
1144
|
} else {
|
1140
|
-
return
|
1145
|
+
return tsplus_module_53.failCause(c);
|
1141
1146
|
}
|
1142
|
-
}, __tsplusTrace)(tsplus_module_28.isShutdown(queue, __tsplusTrace)), __tsplusTrace)(tsplus_module_1.map(tsplus_module_19.from, __tsplusTrace)(
|
1147
|
+
}, __tsplusTrace)(tsplus_module_28.isShutdown(queue, __tsplusTrace)), __tsplusTrace)(tsplus_module_1.map(tsplus_module_19.from, __tsplusTrace)(tsplus_module_54.takeBetween(1, maxChunkSize, __tsplusTrace)(queue))), __tsplusTrace);
|
1143
1148
|
}
|
1144
1149
|
/**
|
1145
1150
|
* @tsplus static fncts.io.StreamOps fromQueueWithShutdown
|
@@ -1176,7 +1181,7 @@ function halt_1(u, __tsplusTrace) {
|
|
1176
1181
|
return new Stream(tsplus_module_10.halt(u));
|
1177
1182
|
}
|
1178
1183
|
function haltWhenWriter(fiber, __tsplusTrace) {
|
1179
|
-
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)(
|
1184
|
+
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)));
|
1180
1185
|
}
|
1181
1186
|
/**
|
1182
1187
|
* Halts the evaluation of this stream when the provided IO completes. The
|
@@ -1281,7 +1286,7 @@ export function intersperse(stream, middle, __tsplusTrace) {
|
|
1281
1286
|
*/
|
1282
1287
|
export function interruptWhen(io, __tsplusTrace) {
|
1283
1288
|
return stream => {
|
1284
|
-
return new Stream(
|
1289
|
+
return new Stream(tsplus_module_55.interruptWhen(io)(stream.channel));
|
1285
1290
|
};
|
1286
1291
|
}
|
1287
1292
|
/**
|
@@ -1289,7 +1294,7 @@ export function interruptWhen(io, __tsplusTrace) {
|
|
1289
1294
|
*/
|
1290
1295
|
export function interruptWhenFuture(future, __tsplusTrace) {
|
1291
1296
|
return fa => {
|
1292
|
-
return new Stream(
|
1297
|
+
return new Stream(tsplus_module_55.interruptWhenFuture(future)(fa.channel));
|
1293
1298
|
};
|
1294
1299
|
}
|
1295
1300
|
/**
|
@@ -1450,11 +1455,19 @@ function mapIOLoop(iterator, f, __tsplusTrace) {
|
|
1450
1455
|
*
|
1451
1456
|
* @note This combinator destroys the chunking structure. It's recommended to use chunkN afterwards.
|
1452
1457
|
*
|
1453
|
-
* @tsplus pipeable fncts.io.Stream
|
1458
|
+
* @tsplus pipeable fncts.io.Stream mapIOConcurrently
|
1454
1459
|
*/
|
1455
|
-
export function
|
1460
|
+
export function mapIOConcurrently(n, f, __tsplusTrace) {
|
1456
1461
|
return stream => {
|
1457
|
-
return new Stream(tsplus_module_10.mapOut(tsplus_module_19.single)(
|
1462
|
+
return new Stream(tsplus_module_10.mapOut(tsplus_module_19.single)(tsplus_module_56.mapOutConcurrentIO(n, f)(tsplus_module_10.concatMap(tsplus_module_10.writeChunk)(stream.channel))));
|
1463
|
+
};
|
1464
|
+
}
|
1465
|
+
/**
|
1466
|
+
* @tsplus pipeable fncts.io.Stream mapIOConcurrentlyUnordered
|
1467
|
+
*/
|
1468
|
+
export function mapIOConcurrentlyUnordered(n, f) {
|
1469
|
+
return self => {
|
1470
|
+
return pipeThroughChannelOrFail_1(tsplus_module_57.mergeMap(inp => fromIO_1(f(inp), fileName_1 + ":2216:41").channel, n, 16)(tsplus_module_10.concatMap(chunk => tsplus_module_10.writeChunk(chunk))(tsplus_module_10.id())))(self);
|
1458
1471
|
};
|
1459
1472
|
}
|
1460
1473
|
/**
|
@@ -1467,7 +1480,7 @@ export function mapIOC(n, f, __tsplusTrace) {
|
|
1467
1480
|
*/
|
1468
1481
|
function mergeMap_1(f, n, bufferSize = 16, __tsplusTrace) {
|
1469
1482
|
return ma => {
|
1470
|
-
return new Stream(
|
1483
|
+
return new Stream(tsplus_module_57.mergeMap(a => f(a).channel, n, bufferSize)(tsplus_module_10.concatMap(tsplus_module_10.writeChunk)(ma.channel)));
|
1471
1484
|
};
|
1472
1485
|
}
|
1473
1486
|
/**
|
@@ -1490,15 +1503,15 @@ function mergeEither_1(fb, __tsplusTrace) {
|
|
1490
1503
|
return mergeWith_1(fb, tsplus_module_18.left, tsplus_module_18.right)(fa);
|
1491
1504
|
};
|
1492
1505
|
}
|
1493
|
-
|
1494
|
-
return exit => terminate || !
|
1506
|
+
function mergeWithHandler(terminate, __tsplusTrace) {
|
1507
|
+
return exit => terminate || !tsplus_module_52.isSuccess(exit) ? tsplus_module_58.done(tsplus_module_1.fromExitNow(exit, __tsplusTrace)) : tsplus_module_58.wait(tsplus_module_1.fromExitNow);
|
1495
1508
|
}
|
1496
1509
|
/**
|
1497
1510
|
* @tsplus pipeable fncts.io.Stream mergeWith
|
1498
1511
|
*/
|
1499
1512
|
function mergeWith_1(sb, l, r, strategy = "Both", __tsplusTrace) {
|
1500
1513
|
return sa => {
|
1501
|
-
return new Stream(
|
1514
|
+
return new Stream(tsplus_module_59.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));
|
1502
1515
|
};
|
1503
1516
|
}
|
1504
1517
|
/**
|
@@ -1575,6 +1588,14 @@ function pipeThrough_1(sa, __tsplusTrace) {
|
|
1575
1588
|
return new Stream(tsplus_module_10.pipeToOrFail(sa.channel)(ma.channel));
|
1576
1589
|
};
|
1577
1590
|
}
|
1591
|
+
/**
|
1592
|
+
* @tsplus pipeable fncts.io.Stream pipeThroughChannelOrFail
|
1593
|
+
*/
|
1594
|
+
function pipeThroughChannelOrFail_1(channel) {
|
1595
|
+
return self => {
|
1596
|
+
return new Stream(tsplus_module_10.pipeToOrFail(channel)(self.channel));
|
1597
|
+
};
|
1598
|
+
}
|
1578
1599
|
/**
|
1579
1600
|
* Provides the stream with its required environment, which eliminates
|
1580
1601
|
* its dependency on `R`.
|
@@ -1591,7 +1612,7 @@ function provideEnvironment_1(r, __tsplusTrace) {
|
|
1591
1612
|
*/
|
1592
1613
|
function provideLayer_1(layer, __tsplusTrace) {
|
1593
1614
|
return self => {
|
1594
|
-
return new Stream(tsplus_module_10.unwrapScoped(() => tsplus_module_1.map(r => tsplus_module_10.provideEnvironment(() => r)(self.channel), __tsplusTrace)(
|
1615
|
+
return new Stream(tsplus_module_10.unwrapScoped(() => tsplus_module_1.map(r => tsplus_module_10.provideEnvironment(() => r)(self.channel), __tsplusTrace)(tsplus_module_60.build(layer, __tsplusTrace))));
|
1595
1616
|
};
|
1596
1617
|
}
|
1597
1618
|
/**
|
@@ -1600,7 +1621,7 @@ function provideLayer_1(layer, __tsplusTrace) {
|
|
1600
1621
|
export function provideSomeLayer(layer, __tsplusTrace) {
|
1601
1622
|
return self => {
|
1602
1623
|
// @ts-expect-error
|
1603
|
-
return provideLayer_1(
|
1624
|
+
return provideLayer_1(tsplus_module_61.and(layer, __tsplusTrace)(tsplus_module_61.environment(__tsplusTrace)), __tsplusTrace)(self);
|
1604
1625
|
};
|
1605
1626
|
}
|
1606
1627
|
class Rechunker {
|
@@ -1714,7 +1735,7 @@ function repeatIOChunkMaybe_1(fa, __tsplusTrace) {
|
|
1714
1735
|
*/
|
1715
1736
|
function run_1(sink, __tsplusTrace) {
|
1716
1737
|
return stream => {
|
1717
|
-
return
|
1738
|
+
return tsplus_module_62.runDrain(tsplus_module_10.pipeToOrFail(sink.channel)(stream.channel));
|
1718
1739
|
};
|
1719
1740
|
}
|
1720
1741
|
/**
|
@@ -1723,7 +1744,7 @@ function run_1(sink, __tsplusTrace) {
|
|
1723
1744
|
* @tsplus getter fncts.io.Stream runCollect
|
1724
1745
|
*/
|
1725
1746
|
export function runCollect(stream, __tsplusTrace) {
|
1726
|
-
return run_1(
|
1747
|
+
return run_1(tsplus_module_47.makeCollectAll(__tsplusTrace), __tsplusTrace)(stream);
|
1727
1748
|
}
|
1728
1749
|
/**
|
1729
1750
|
* Runs the stream and collects ignore its elements.
|
@@ -1731,14 +1752,14 @@ export function runCollect(stream, __tsplusTrace) {
|
|
1731
1752
|
* @tsplus getter fncts.io.Stream runDrain
|
1732
1753
|
*/
|
1733
1754
|
export function runDrain(stream, __tsplusTrace) {
|
1734
|
-
return run_1(
|
1755
|
+
return run_1(tsplus_module_47.drain, __tsplusTrace)(stream);
|
1735
1756
|
}
|
1736
1757
|
/**
|
1737
1758
|
* @tsplus pipeable fncts.io.Stream runForeachScoped
|
1738
1759
|
*/
|
1739
1760
|
function runForeachScoped_1(f, __tsplusTrace) {
|
1740
1761
|
return self => {
|
1741
|
-
return runScoped_1(
|
1762
|
+
return runScoped_1(tsplus_module_47.makeForeach(f, __tsplusTrace), __tsplusTrace)(self);
|
1742
1763
|
};
|
1743
1764
|
}
|
1744
1765
|
/**
|
@@ -1747,7 +1768,7 @@ function runForeachScoped_1(f, __tsplusTrace) {
|
|
1747
1768
|
*
|
1748
1769
|
* @tsplus pipeable fncts.io.Stream runIntoElementsScoped
|
1749
1770
|
*/
|
1750
|
-
function
|
1771
|
+
export function runIntoElementsScoped_(queue, __tsplusTrace) {
|
1751
1772
|
return stream => {
|
1752
1773
|
const writer = tsplus_module_10.readWith(inp => tsplus_module_11.zipRight(writer)(tsplus_module_12.foldLeft(tsplus_module_10.unit, (channel, a) => tsplus_module_11.zipRight(tsplus_module_10.writeNow(tsplus_module_41.succeed(a)))(channel))(inp)), err => tsplus_module_10.writeNow(tsplus_module_41.fail(tsplus_module_3.just(err))), () => tsplus_module_10.writeNow(tsplus_module_41.fail(tsplus_module_3.nothing())));
|
1753
1774
|
return tsplus_module_1.asUnit(tsplus_module_16.runScoped(tsplus_module_10.drain(tsplus_module_10.mapOutIO(exit => tsplus_module_28.offer(exit, __tsplusTrace)(queue))(tsplus_module_10.pipeTo(writer)(stream.channel)))), __tsplusTrace);
|
@@ -1765,6 +1786,21 @@ function runIntoQueueScoped_1(queue, __tsplusTrace) {
|
|
1765
1786
|
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);
|
1766
1787
|
};
|
1767
1788
|
}
|
1789
|
+
/**
|
1790
|
+
* Like runIntoQueue, but provides the result as a scoped IO
|
1791
|
+
* to allow for scope composition.
|
1792
|
+
*
|
1793
|
+
* @tsplus pipeable fncts.io.Stream runIntoQueueElementsScoped
|
1794
|
+
*/
|
1795
|
+
function runIntoQueueElementsScoped_1(queue) {
|
1796
|
+
return self => {
|
1797
|
+
return tsplus_module_1.defer(() => {
|
1798
|
+
const queue0 = queue();
|
1799
|
+
const writer = tsplus_module_10.readWithCause(inp => tsplus_module_11.zipRight(writer)(tsplus_module_10.fromIO(() => tsplus_module_28.offerAll(tsplus_module_12.map(a => tsplus_module_41.succeed(a))(inp), fileName_1 + ":2647:57")(queue0))), cause => tsplus_module_10.fromIO(() => tsplus_module_28.offer(tsplus_module_41.failCause(tsplus_module_25.map(e => tsplus_module_3.just(e))(cause)), fileName_1 + ":2648:47")(queue0)), () => tsplus_module_10.fromIO(() => tsplus_module_28.offer(tsplus_module_41.fail(tsplus_module_3.nothing()), fileName_1 + ":2649:42")(queue0)));
|
1800
|
+
return tsplus_module_1.asUnit(tsplus_module_16.runScoped(tsplus_module_10.drain(tsplus_module_10.pipeTo(writer)(self.channel))), fileName_1 + ":2652:55");
|
1801
|
+
}, fileName_1 + ":2644:20");
|
1802
|
+
};
|
1803
|
+
}
|
1768
1804
|
/**
|
1769
1805
|
* Like `Stream#runIntoHub`, but provides the result as a `Managed` to allow for scope
|
1770
1806
|
* composition.
|
@@ -1868,7 +1904,7 @@ export function take(n, __tsplusTrace) {
|
|
1868
1904
|
return empty_1;
|
1869
1905
|
}
|
1870
1906
|
if (!Number.isInteger(n)) {
|
1871
|
-
return halt_1(() => new
|
1907
|
+
return halt_1(() => new tsplus_module_63.IllegalArgumentError(`${n} should be an integer`, "Stream.take"), __tsplusTrace);
|
1872
1908
|
}
|
1873
1909
|
return new Stream(tsplus_module_10.pipeTo(takeLoop(n, __tsplusTrace))(stream.channel));
|
1874
1910
|
};
|
@@ -1891,7 +1927,7 @@ function takeUntilIOLoop(iterator, f, __tsplusTrace) {
|
|
1891
1927
|
}
|
1892
1928
|
function takeUntilLoop(p, __tsplusTrace) {
|
1893
1929
|
return tsplus_module_10.readWith(chunk => {
|
1894
|
-
const taken = tsplus_module_12.takeWhile(
|
1930
|
+
const taken = tsplus_module_12.takeWhile(tsplus_module_48.invert(p))(chunk);
|
1895
1931
|
const last = tsplus_module_12.take(1)(tsplus_module_12.drop(taken.length)(chunk));
|
1896
1932
|
if (tsplus_module_12.isEmpty(last)) {
|
1897
1933
|
return tsplus_module_11.zipRight(takeUntilLoop(p, __tsplusTrace))(tsplus_module_10.writeNow(taken));
|
@@ -1974,7 +2010,7 @@ function toHub_1(capacity, __tsplusTrace) {
|
|
1974
2010
|
* @tsplus getter fncts.io.Stream toPull
|
1975
2011
|
*/
|
1976
2012
|
function toPull_1(stream, __tsplusTrace) {
|
1977
|
-
return tsplus_module_1.map(io => tsplus_module_1.flatMap(r => tsplus_module_4.match(() => tsplus_module_1.failNow(tsplus_module_3.nothing(), __tsplusTrace), tsplus_module_1.succeedNow)(r), __tsplusTrace)(tsplus_module_1.mapError(tsplus_module_3.just, __tsplusTrace)(io)), __tsplusTrace)(
|
2013
|
+
return tsplus_module_1.map(io => tsplus_module_1.flatMap(r => tsplus_module_4.match(() => tsplus_module_1.failNow(tsplus_module_3.nothing(), __tsplusTrace), tsplus_module_1.succeedNow)(r), __tsplusTrace)(tsplus_module_1.mapError(tsplus_module_3.just, __tsplusTrace)(io)), __tsplusTrace)(tsplus_module_64.toPull(stream.channel));
|
1978
2014
|
}
|
1979
2015
|
/**
|
1980
2016
|
* Converts the stream to a managed queue of chunks. After the managed queue is used,
|
@@ -2000,7 +2036,7 @@ export function toQueueDropping(capacity = 2, __tsplusTrace) {
|
|
2000
2036
|
*/
|
2001
2037
|
function toQueueOfElements_1(capacity = 2, __tsplusTrace) {
|
2002
2038
|
return stream => {
|
2003
|
-
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(
|
2039
|
+
return tsplus_module_1.flatMap(queue => tsplus_module_1.map(() => queue, __tsplusTrace)(tsplus_module_17.forkScoped(runIntoQueueElementsScoped_1(() => queue)(stream), __tsplusTrace)), __tsplusTrace)(tsplus_module_31.acquireRelease(() => tsplus_module_30.makeBounded(capacity, __tsplusTrace), _ => tsplus_module_28.shutdown(_, __tsplusTrace), __tsplusTrace));
|
2004
2040
|
};
|
2005
2041
|
}
|
2006
2042
|
/**
|