@fncts/io 0.0.35 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- package/Fiber/constructors.d.ts +5 -0
- package/Push/api.d.ts +70 -41
- package/Push/definition.d.ts +11 -13
- package/Push/internal.d.ts +7 -11
- package/RefSubject/Atomic.d.ts +8 -11
- package/RefSubject/Synchronized/definition.d.ts +4 -6
- package/RefSubject/api.d.ts +0 -1
- package/RefSubject/definition.d.ts +6 -8
- package/STM/definition.d.ts +17 -0
- package/Sink/api.d.ts +6 -6
- package/Subject/Atomic.d.ts +4 -6
- package/Subject/definition.d.ts +2 -2
- package/_cjs/Fiber/constructors.cjs +10 -2
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Push/api.cjs +206 -175
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/definition.cjs +12 -13
- package/_cjs/Push/definition.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +37 -29
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/RefSubject/Atomic.cjs +15 -19
- package/_cjs/RefSubject/Atomic.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +9 -10
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
- package/_cjs/RefSubject/api.cjs +5 -6
- package/_cjs/RefSubject/api.cjs.map +1 -1
- package/_cjs/RefSubject/definition.cjs.map +1 -1
- package/_cjs/STM/api.cjs +2 -2
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +13 -13
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +4 -5
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +7 -1
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Push/api.mjs +194 -173
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Push/definition.mjs +9 -10
- package/_mjs/Push/definition.mjs.map +1 -1
- package/_mjs/Push/internal.mjs +33 -22
- package/_mjs/Push/internal.mjs.map +1 -1
- package/_mjs/RefSubject/Atomic.mjs +15 -19
- package/_mjs/RefSubject/Atomic.mjs.map +1 -1
- package/_mjs/RefSubject/Synchronized/definition.mjs +9 -10
- package/_mjs/RefSubject/Synchronized/definition.mjs.map +1 -1
- package/_mjs/RefSubject/api.mjs +6 -7
- package/_mjs/RefSubject/api.mjs.map +1 -1
- package/_mjs/RefSubject/definition.mjs.map +1 -1
- package/_mjs/STM/api.mjs +2 -2
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/STM/definition.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +10 -10
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +4 -5
- package/_mjs/Subject/Atomic.mjs.map +1 -1
- package/_src/Fiber/constructors.ts +5 -0
- package/_src/IO/definition.ts +0 -1
- package/_src/Layer/api.ts +0 -1
- package/_src/Push/api.ts +270 -335
- package/_src/Push/definition.ts +13 -17
- package/_src/Push/internal.ts +63 -31
- package/_src/RefSubject/Atomic.ts +16 -22
- package/_src/RefSubject/Synchronized/definition.ts +6 -9
- package/_src/RefSubject/api.ts +9 -12
- package/_src/RefSubject/definition.ts +6 -8
- package/_src/STM/api.ts +0 -5
- package/_src/STM/definition.ts +6 -0
- package/_src/Sink/api.ts +9 -9
- package/_src/Subject/Atomic.ts +6 -8
- package/_src/Subject/definition.ts +2 -2
- package/package.json +2 -2
package/_mjs/Push/api.mjs
CHANGED
@@ -9,37 +9,33 @@ import * as tsplus_module_6 from "@fncts/io/IO/api/fulfill";
|
|
9
9
|
import * as tsplus_module_7 from "@fncts/io/IO/runtime";
|
10
10
|
import * as tsplus_module_8 from "@fncts/io/IO/api/scope";
|
11
11
|
import * as tsplus_module_9 from "@fncts/io/Future/constructors";
|
12
|
-
import * as tsplus_module_10 from "@fncts/io/
|
13
|
-
import * as tsplus_module_11 from "@fncts/
|
14
|
-
import * as tsplus_module_12 from "@fncts/
|
15
|
-
import * as tsplus_module_13 from "@fncts/
|
16
|
-
import * as tsplus_module_14 from "@fncts/
|
12
|
+
import * as tsplus_module_10 from "@fncts/io/IO/api/scoped";
|
13
|
+
import * as tsplus_module_11 from "@fncts/io/Push/definition";
|
14
|
+
import * as tsplus_module_12 from "@fncts/base/data/Either/constructors";
|
15
|
+
import * as tsplus_module_13 from "@fncts/base/collection/Iterable/api";
|
16
|
+
import * as tsplus_module_14 from "@fncts/io/IO/api/foreachConcurrent";
|
17
17
|
import * as tsplus_module_15 from "@fncts/io/IO/api/delay";
|
18
|
-
import * as tsplus_module_16 from "@fncts/
|
19
|
-
import * as tsplus_module_17 from "@fncts/io/
|
20
|
-
import * as tsplus_module_18 from "@fncts/io/
|
21
|
-
import * as tsplus_module_19 from "@fncts/
|
22
|
-
import * as tsplus_module_20 from "@fncts/io/
|
23
|
-
import * as tsplus_module_21 from "@fncts/
|
24
|
-
import * as tsplus_module_22 from "@fncts/io/
|
25
|
-
import * as tsplus_module_23 from "@fncts/
|
26
|
-
import * as tsplus_module_24 from "@fncts/io/
|
27
|
-
import * as tsplus_module_25 from "@fncts/
|
28
|
-
import * as tsplus_module_26 from "@fncts/
|
29
|
-
import * as tsplus_module_27 from "@fncts/base/data/
|
30
|
-
import * as tsplus_module_28 from "@fncts/
|
31
|
-
import * as tsplus_module_29 from "@fncts/
|
32
|
-
import * as tsplus_module_30 from "@fncts/
|
33
|
-
import * as tsplus_module_31 from "@fncts/
|
34
|
-
import * as tsplus_module_32 from "@fncts/io/IO/api/
|
35
|
-
import * as tsplus_module_33 from "@fncts/io/
|
36
|
-
import * as tsplus_module_34 from "@fncts/base/collection/immutable/Conc/definition";
|
37
|
-
import * as tsplus_module_35 from "@fncts/io/IO/api/scoped";
|
38
|
-
import * as tsplus_module_36 from "@fncts/io/Ref/api/set";
|
39
|
-
import * as tsplus_module_37 from "@fncts/io/Fiber/api/joinAll";
|
40
|
-
import * as tsplus_module_38 from "@fncts/io/IO/api/asyncInterrupt";
|
18
|
+
import * as tsplus_module_16 from "@fncts/base/data/Maybe/destructors";
|
19
|
+
import * as tsplus_module_17 from "@fncts/io/Semaphore";
|
20
|
+
import * as tsplus_module_18 from "@fncts/io/IO/api/concurrency";
|
21
|
+
import * as tsplus_module_19 from "@fncts/base/data/function/api";
|
22
|
+
import * as tsplus_module_20 from "@fncts/io/IO/api/asyncIO";
|
23
|
+
import * as tsplus_module_21 from "@fncts/io/IO/api/forkDaemon";
|
24
|
+
import * as tsplus_module_22 from "@fncts/io/Fiber/api/await";
|
25
|
+
import * as tsplus_module_23 from "@fncts/io/IO/api/environment";
|
26
|
+
import * as tsplus_module_24 from "@fncts/io/Fiber/api/interrupt";
|
27
|
+
import * as tsplus_module_25 from "@fncts/base/data/Maybe/constructors";
|
28
|
+
import * as tsplus_module_26 from "@fncts/base/data/Maybe/definition";
|
29
|
+
import * as tsplus_module_27 from "@fncts/base/data/Cause/api";
|
30
|
+
import * as tsplus_module_28 from "@fncts/io/Fiber/api/interruptFork";
|
31
|
+
import * as tsplus_module_29 from "@fncts/io/IO/api/forkScoped";
|
32
|
+
import * as tsplus_module_30 from "@fncts/base/collection/immutable/Conc/definition";
|
33
|
+
import * as tsplus_module_31 from "@fncts/io/Fiber/api/joinAll";
|
34
|
+
import * as tsplus_module_32 from "@fncts/io/IO/api/fork";
|
35
|
+
import * as tsplus_module_33 from "@fncts/io/IO/api/asyncInterrupt";
|
41
36
|
export const asyncInterrupt = asyncInterrupt_1;
|
42
37
|
export const combineLatest = combineLatest_1;
|
38
|
+
export const exhaustMap = exhaustMap_1;
|
43
39
|
export const flatMapConcurrentBounded = flatMapConcurrentBounded_1;
|
44
40
|
export const flatMapConcurrentUnbounded = flatMapConcurrentUnbounded_1;
|
45
41
|
export const flatMap = flatMap_1;
|
@@ -48,13 +44,17 @@ export const fromIO = fromIO_1;
|
|
48
44
|
export const map = map_1;
|
49
45
|
export const mapIO = mapIO_1;
|
50
46
|
export const mergeAll = mergeAll_1;
|
47
|
+
export const observe = observe_1;
|
51
48
|
export const scoped = scoped_1;
|
49
|
+
export const switchMap = switchMap_1;
|
50
|
+
export const switchMapIO = switchMapIO_1;
|
52
51
|
export const transform = transform_1;
|
53
52
|
export const unfoldIO = unfoldIO_1;
|
54
53
|
export const unwrap = unwrap_1;
|
55
54
|
import { AtomicReference } from "@fncts/base/internal/AtomicReference";
|
56
|
-
import {
|
57
|
-
import {
|
55
|
+
import { IO } from "@fncts/io/IO";
|
56
|
+
import { withExhaust, withSwitch, withUnboundedConcurrency } from "@fncts/io/Push/internal";
|
57
|
+
import { Push, PushTypeId, PushVariance, Sink } from "./definition.mjs";
|
58
58
|
/**
|
59
59
|
* @tsplus pipeable fncts.io.Push as
|
60
60
|
*/
|
@@ -67,31 +67,30 @@ export function as(b) {
|
|
67
67
|
* @tsplus static fncts.io.PushOps asyncInterrupt
|
68
68
|
*/
|
69
69
|
function asyncInterrupt_1(make) {
|
70
|
-
return
|
71
|
-
const
|
72
|
-
|
73
|
-
|
74
|
-
end: () => runtime.unsafeRunOrFork(tsplus_module_4.zipRight(tsplus_module_1.succeed_(undefined, fileName_1 + ":37:72")(future), fileName_1 + ":37:57")(emitter.end), fileName_1 + ":37:43")
|
70
|
+
return tsplus_module_11.makePush(sink => tsplus_module_10.scoped(tsplus_module_4.flatMap(future => tsplus_module_4.flatMap(scope => tsplus_module_4.flatMap(runtime => {
|
71
|
+
const unsafeSink = {
|
72
|
+
event: value => runtime.unsafeRunOrFork(tsplus_module_5.forkIn(scope, fileName_1 + ":34:77")(sink.event(value)), fileName_1 + ":34:52"),
|
73
|
+
error: cause => runtime.unsafeRunOrFork(tsplus_module_5.forkIn(scope, fileName_1 + ":35:93")(tsplus_module_6.fulfill(future, fileName_1 + ":35:78")(sink.error(cause))), fileName_1 + ":35:52")
|
75
74
|
};
|
76
|
-
return tsplus_module_4.flatMap(eitherPush => tsplus_module_4.map(() => void 0, fileName_1 + ":
|
77
|
-
}, fileName_1 + ":
|
75
|
+
return tsplus_module_4.flatMap(eitherPush => tsplus_module_4.map(() => void 0, fileName_1 + ":38:10")(tsplus_module_3.match(canceller => tsplus_module_2.onInterrupt(() => canceller, fileName_1 + ":40:52")(tsplus_module_1.wait(future, fileName_1 + ":40:34")), push => push.run(sink))(eitherPush)), fileName_1 + ":37:29")(tsplus_module_4.succeed(() => make(unsafeSink), fileName_1 + ":37:32"));
|
76
|
+
}, fileName_1 + ":32:26")(tsplus_module_7.runtime(fileName_1 + ":32:37")), fileName_1 + ":31:26")(tsplus_module_8.scope), fileName_1 + ":30:26")(tsplus_module_9.make(fileName_1 + ":30:38")), fileName_1 + ":44:9"));
|
78
77
|
}
|
79
78
|
/**
|
80
79
|
* @tsplus static fncts.io.PushOps async
|
81
80
|
*/
|
82
81
|
export function async(make) {
|
83
|
-
return asyncInterrupt_1(
|
84
|
-
make(
|
85
|
-
return
|
82
|
+
return asyncInterrupt_1(sink => {
|
83
|
+
make(sink);
|
84
|
+
return tsplus_module_12.left(tsplus_module_4.unit, fileName_1 + ":54:23");
|
86
85
|
});
|
87
86
|
}
|
88
87
|
function combineLatest_1(streams) {
|
89
|
-
return
|
90
|
-
const size =
|
91
|
-
return tsplus_module_4.flatMap(ref =>
|
92
|
-
const emitIfReady = tsplus_module_4.flatMap(as => as.length === size ? emitter.
|
93
|
-
return tsplus_module_4.
|
94
|
-
}, fileName_1 + ":
|
88
|
+
return tsplus_module_11.makePush(emitter => (() => {
|
89
|
+
const size = tsplus_module_13.size(streams);
|
90
|
+
return tsplus_module_4.flatMap(ref => {
|
91
|
+
const emitIfReady = tsplus_module_4.flatMap(as => as.length === size ? emitter.event(as) : tsplus_module_4.unit, fileName_1 + ":70:69")(tsplus_module_4.succeed(() => ref.filter(a => a != null), fileName_1 + ":70:31"));
|
92
|
+
return tsplus_module_4.map(() => void 0, fileName_1 + ":73:8")(tsplus_module_14.foreachConcurrent(tsplus_module_13.zipWithIndex(streams), ([i, stream]) => stream.run(tsplus_module_11.makeSink(value => tsplus_module_4.zipRight(emitIfReady, fileName_1 + ":77:48")(tsplus_module_4.succeed(() => ref[i] = value, fileName_1 + ":77:28")), cause => emitter.error(cause))), fileName_1 + ":74:29"));
|
93
|
+
}, fileName_1 + ":69:30")(tsplus_module_4.succeed(() => Array(size), fileName_1 + ":69:33"));
|
95
94
|
})());
|
96
95
|
}
|
97
96
|
/**
|
@@ -107,21 +106,66 @@ export function combineLatestWith(that, f) {
|
|
107
106
|
*/
|
108
107
|
export function debounce(duration) {
|
109
108
|
return self => {
|
110
|
-
return
|
109
|
+
return switchMapIO_1(a => tsplus_module_15.delay(duration)(tsplus_module_4.succeedNow(a, fileName_1 + ":101:49")))(self);
|
111
110
|
};
|
112
111
|
}
|
113
112
|
/**
|
114
113
|
* @tsplus static fncts.io.PushOps defer
|
115
114
|
*/
|
116
115
|
export function defer(self) {
|
117
|
-
return
|
116
|
+
return tsplus_module_11.makePush(emitter => tsplus_module_4.flatMap(push => push.run(emitter), fileName_1 + ":109:44")(tsplus_module_4.succeed(self, fileName_1 + ":109:30")));
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* @tsplus pipeable fncts.io.Push exhaustMap
|
120
|
+
*/
|
121
|
+
function exhaustMap_1(f) {
|
122
|
+
return self => {
|
123
|
+
return tsplus_module_11.makePush(sink => withExhaust(fork => self.run(tsplus_module_11.makeSink(a => fork(f(a).run(sink)), sink.error))));
|
124
|
+
};
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* @tsplus pipeable fncts.io.Push exhaustMapIO
|
128
|
+
*/
|
129
|
+
export function exhaustMapIO(f) {
|
130
|
+
return self => {
|
131
|
+
return exhaustMap_1(a => fromIO_1(() => f(a)))(self);
|
132
|
+
};
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
* @tsplus pipeable fncts.io.Push filterIO
|
136
|
+
*/
|
137
|
+
export function filterIO(predicate) {
|
138
|
+
return self => {
|
139
|
+
return tsplus_module_11.makePush(sink => self.run(tsplus_module_11.makeSink(a => tsplus_module_4.catchAllCause(sink.error, fileName_1 + ":141:29")(tsplus_module_4.flatMap(b => b ? sink.event(a) : tsplus_module_4.unit, fileName_1 + ":140:23")(predicate(a))), sink.error)));
|
140
|
+
};
|
141
|
+
}
|
142
|
+
/**
|
143
|
+
* @tsplus pipeable fncts.io.Push filterMapIO
|
144
|
+
*/
|
145
|
+
export function filterMapIO(f) {
|
146
|
+
return self => {
|
147
|
+
return tsplus_module_11.makePush(sink => self.run(tsplus_module_11.makeSink(a => tsplus_module_4.catchAllCause(sink.error, fileName_1 + ":160:29")(tsplus_module_4.flatMap(mb => tsplus_module_16.match(() => tsplus_module_4.unit, sink.event)(mb), fileName_1 + ":159:23")(f(a))), sink.error)));
|
148
|
+
};
|
149
|
+
}
|
150
|
+
export function filter(predicate) {
|
151
|
+
return self => {
|
152
|
+
return tsplus_module_11.makePush(sink => self.run(tsplus_module_11.makeSink(a => predicate(a) ? sink.event(a) : tsplus_module_4.unit, sink.error)));
|
153
|
+
};
|
154
|
+
}
|
155
|
+
/**
|
156
|
+
* @tsplus pipeable fncts.io.Push filterMap
|
157
|
+
*/
|
158
|
+
export function filterMap(f) {
|
159
|
+
return self => {
|
160
|
+
return tsplus_module_11.makePush(sink => self.run(tsplus_module_11.makeSink(a => tsplus_module_16.match(() => tsplus_module_4.unit, sink.event)(f(a)), sink.error)));
|
161
|
+
};
|
118
162
|
}
|
119
163
|
/**
|
120
164
|
* @tsplus pipeable fncts.io.Push flatMapConcurrentBounded
|
121
165
|
*/
|
122
166
|
function flatMapConcurrentBounded_1(f, concurrency) {
|
123
167
|
return self => {
|
124
|
-
return
|
168
|
+
return tsplus_module_11.makePush(emitter => tsplus_module_4.flatMap(semaphore => tsplus_module_4.map(() => void 0, fileName_1 + ":196:10")(flatMapConcurrentUnbounded_1(a => transform_1(io => semaphore.withPermit(io))(f(a)))(self).run(emitter)), fileName_1 + ":195:28")(tsplus_module_17.makeSemaphore(concurrency, fileName_1 + ":195:38")));
|
125
169
|
};
|
126
170
|
}
|
127
171
|
/**
|
@@ -129,7 +173,7 @@ function flatMapConcurrentBounded_1(f, concurrency) {
|
|
129
173
|
*/
|
130
174
|
function flatMapConcurrentUnbounded_1(f) {
|
131
175
|
return self => {
|
132
|
-
return
|
176
|
+
return tsplus_module_11.makePush(sink => withUnboundedConcurrency(fork => self.run(tsplus_module_11.makeSink(a => fork(f(a).run(sink)), sink.error))));
|
133
177
|
};
|
134
178
|
}
|
135
179
|
/**
|
@@ -137,7 +181,7 @@ function flatMapConcurrentUnbounded_1(f) {
|
|
137
181
|
*/
|
138
182
|
export function flatMapConcurrent(f) {
|
139
183
|
return self => {
|
140
|
-
return unwrap_1(tsplus_module_4.map(concurrency =>
|
184
|
+
return unwrap_1(tsplus_module_4.map(concurrency => tsplus_module_16.match(() => flatMapConcurrentUnbounded_1(f)(self), n => flatMapConcurrentBounded_1(f, n)(self))(concurrency), fileName_1 + ":217:25")(tsplus_module_18.concurrency));
|
141
185
|
};
|
142
186
|
}
|
143
187
|
/**
|
@@ -152,34 +196,34 @@ function flatMap_1(f) {
|
|
152
196
|
* @tsplus getter fncts.io.Push flatten
|
153
197
|
*/
|
154
198
|
function flatten_1(self) {
|
155
|
-
return flatMap_1(
|
199
|
+
return flatMap_1(tsplus_module_19.identity)(self);
|
156
200
|
}
|
157
201
|
/**
|
158
202
|
* @tsplus static fncts.io.PushOps fromIO
|
159
203
|
*/
|
160
204
|
function fromIO_1(io) {
|
161
|
-
return
|
205
|
+
return tsplus_module_11.makePush(emitter => tsplus_module_4.matchCauseIO(cause => emitter.error(cause), value => emitter.event(value), fileName_1 + ":248:30")(tsplus_module_4.defer(io, fileName_1 + ":248:13")));
|
162
206
|
}
|
163
207
|
/**
|
164
208
|
* @tsplus static fncts.io.PushOps fromAsyncIterable
|
165
209
|
*/
|
166
210
|
export function fromAsyncIterable(iterable) {
|
167
|
-
return
|
211
|
+
return tsplus_module_11.makePush(sink => tsplus_module_20.asyncIO(cb => tsplus_module_4.defer(() => fromAsyncIterableLoop(iterable[Symbol.asyncIterator](), sink, cb, fileName_1 + ":260:70"), fileName_1 + ":260:48"), fileName_1 + ":260:15"));
|
168
212
|
}
|
169
|
-
function fromAsyncIterableLoop(iterator,
|
170
|
-
return tsplus_module_4.matchCauseIO(cause =>
|
213
|
+
function fromAsyncIterableLoop(iterator, sink, cb, __tsplusTrace) {
|
214
|
+
return tsplus_module_4.matchCauseIO(cause => sink.error(cause), result => result.done ? tsplus_module_4.succeed(() => cb(tsplus_module_4.unit), __tsplusTrace) : tsplus_module_4.zipRight(fromAsyncIterableLoop(iterator, sink, cb, __tsplusTrace), __tsplusTrace)(sink.event(result.value)), __tsplusTrace)(tsplus_module_4.fromPromiseHalt(iterator.next, __tsplusTrace));
|
171
215
|
}
|
172
216
|
/**
|
173
217
|
* @tsplus static fncts.io.PushOps fromIterable
|
174
218
|
*/
|
175
219
|
export function fromIterable(iterable) {
|
176
|
-
return
|
220
|
+
return tsplus_module_11.makePush(sink => tsplus_module_20.asyncIO(cb => tsplus_module_4.defer(() => fromIterableLoop(iterable[Symbol.iterator](), sink, cb), fileName_1 + ":281:48"), fileName_1 + ":281:15"));
|
177
221
|
}
|
178
|
-
function fromIterableLoop(iterator,
|
222
|
+
function fromIterableLoop(iterator, sink, cb) {
|
179
223
|
return tsplus_module_4.defer(() => {
|
180
224
|
const value = iterator.next();
|
181
|
-
return value.done ?
|
182
|
-
}, fileName_1 + ":
|
225
|
+
return value.done ? tsplus_module_4.succeed(() => cb(tsplus_module_4.unit), fileName_1 + ":292:27") : tsplus_module_4.zipRight(fromIterableLoop(iterator, sink, cb), fileName_1 + ":292:68")(sink.event(value.value));
|
226
|
+
}, fileName_1 + ":290:18");
|
183
227
|
}
|
184
228
|
/**
|
185
229
|
* @tsplus getter fncts.io.Push multicast
|
@@ -193,45 +237,46 @@ export class Multicast {
|
|
193
237
|
this[_a] = PushTypeId;
|
194
238
|
this.observers = [];
|
195
239
|
}
|
196
|
-
run(
|
197
|
-
return tsplus_module_4.flatMap(environment => tsplus_module_4.
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
})
|
203
|
-
|
204
|
-
return tsplus_module_4.unit;
|
205
|
-
} else {
|
206
|
-
return tsplus_module_4.tap(fiber => tsplus_module_4.succeed(() => this.fiber = fiber, fileName_1 + ":292:44"), fileName_1 + ":292:30")(tsplus_module_12.forkScoped(tsplus_module_25.schedule(() => tsplus_module_24.asap, fileName_1 + ":291:24")(this.push.run(this)), fileName_1 + ":291:39"));
|
240
|
+
run(sink) {
|
241
|
+
return tsplus_module_4.flatMap(environment => tsplus_module_4.map(() => void 0, fileName_1 + ":322:8")(tsplus_module_4.defer(() => {
|
242
|
+
let io = tsplus_module_4.unit;
|
243
|
+
if (this.observers.push({
|
244
|
+
sink: sink,
|
245
|
+
environment
|
246
|
+
}) === 1) {
|
247
|
+
io = tsplus_module_4.flatMap(fiber => tsplus_module_4.succeed(() => this.fiber = fiber, fileName_1 + ":326:70"), fileName_1 + ":326:56")(tsplus_module_21.forkDaemon(this.push.run(this), fileName_1 + ":326:37"));
|
207
248
|
}
|
208
|
-
|
249
|
+
return tsplus_module_4.zipRight(tsplus_module_2.ensuring(this.removeSink(sink), fileName_1 + ":328:49")(tsplus_module_22.wait(this.fiber, fileName_1 + ":328:34")), fileName_1 + ":328:22")(io);
|
250
|
+
}, fileName_1 + ":323:17")), fileName_1 + ":321:28")(tsplus_module_23.environment(fileName_1 + ":321:43"));
|
209
251
|
}
|
210
|
-
|
211
|
-
return tsplus_module_4.defer(() => tsplus_module_4.foreachDiscard(this.observers.slice(), observer => this.
|
252
|
+
event(value) {
|
253
|
+
return tsplus_module_4.defer(() => tsplus_module_4.foreachDiscard(this.observers.slice(), observer => this.runValue(value, observer), fileName_1 + ":335:38"), fileName_1 + ":335:20");
|
212
254
|
}
|
213
|
-
|
214
|
-
return tsplus_module_4.
|
255
|
+
error(cause) {
|
256
|
+
return tsplus_module_4.defer(() => tsplus_module_4.foreachDiscard(this.observers.slice(), observer => this.runError(cause, observer), fileName_1 + ":339:38"), fileName_1 + ":339:20");
|
215
257
|
}
|
216
|
-
|
217
|
-
return tsplus_module_4.
|
258
|
+
runValue(value, observer) {
|
259
|
+
return tsplus_module_4.catchAllCause(() => this.removeSink(observer.sink), fileName_1 + ":346:21")(tsplus_module_23.provideEnvironment(observer.environment, fileName_1 + ":345:26")(observer.sink.event(value)));
|
218
260
|
}
|
219
|
-
|
220
|
-
return
|
261
|
+
runError(cause, observer) {
|
262
|
+
return tsplus_module_4.catchAllCause(() => this.removeSink(observer.sink), fileName_1 + ":353:21")(tsplus_module_23.provideEnvironment(observer.environment, fileName_1 + ":352:26")(observer.sink.error(cause)));
|
221
263
|
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
264
|
+
removeSink(sink) {
|
265
|
+
return tsplus_module_4.defer(() => {
|
266
|
+
if (this.observers.length === 0) {
|
267
|
+
return tsplus_module_4.unit;
|
268
|
+
}
|
269
|
+
const index = this.observers.findIndex(observer => observer.sink === sink);
|
270
|
+
if (index > -1) {
|
271
|
+
this.observers.splice(index, 1);
|
272
|
+
if (this.observers.length === 0) {
|
273
|
+
const interrupt = tsplus_module_24.interrupt(this.fiber);
|
274
|
+
this.fiber = undefined;
|
275
|
+
return interrupt;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
return tsplus_module_4.unit;
|
279
|
+
}, fileName_1 + ":357:20");
|
235
280
|
}
|
236
281
|
}
|
237
282
|
_a = PushTypeId;
|
@@ -245,63 +290,20 @@ export class Hold extends Multicast {
|
|
245
290
|
constructor(push) {
|
246
291
|
super(push);
|
247
292
|
this.push = push;
|
248
|
-
this.
|
249
|
-
this.pendingEmitters = [];
|
250
|
-
this.scheduledFiber = null;
|
293
|
+
this.current = new AtomicReference(tsplus_module_25.nothing(fileName_1 + ":383:49"));
|
251
294
|
}
|
252
|
-
run(
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
const value = this.value.get;
|
257
|
-
if (tsplus_module_28.isJust(value) && this.observers.length === 0) {
|
258
|
-
return tsplus_module_4.flatMap(() => super.run(emitter), fileName_1 + ":366:47")(emitter.emit(value.value));
|
295
|
+
run(sink) {
|
296
|
+
const current = this.current.get;
|
297
|
+
if (tsplus_module_26.isJust(current)) {
|
298
|
+
return tsplus_module_4.zipRight(super.run(sink), fileName_1 + ":393:41")(sink.event(current.value));
|
259
299
|
}
|
260
|
-
return super.run(
|
300
|
+
return super.run(sink);
|
261
301
|
}
|
262
|
-
|
302
|
+
event(value) {
|
263
303
|
return tsplus_module_4.defer(() => {
|
264
|
-
this.
|
265
|
-
return
|
266
|
-
}, fileName_1 + ":
|
267
|
-
}
|
268
|
-
failCause(cause) {
|
269
|
-
return tsplus_module_4.defer(() => tsplus_module_4.flatMap(() => super.failCause(cause), fileName_1 + ":380:48")(this.flushPending()), fileName_1 + ":380:20");
|
270
|
-
}
|
271
|
-
get end() {
|
272
|
-
return tsplus_module_4.defer(() => tsplus_module_4.flatMap(() => super.end, fileName_1 + ":384:48")(this.flushPending()), fileName_1 + ":384:20");
|
273
|
-
}
|
274
|
-
shouldScheduleFlush() {
|
275
|
-
return tsplus_module_28.isJust(this.value.get) && this.observers.length > 0;
|
276
|
-
}
|
277
|
-
scheduleFlush(observer) {
|
278
|
-
this.pendingEmitters.push([observer, tsplus_module_21.match(() => [], a => [a])(this.value.get)]);
|
279
|
-
const interrupt = this.scheduledFiber ? tsplus_module_30.interruptAsFork(this.scheduledFiber, tsplus_module_29.none) : tsplus_module_4.unit;
|
280
|
-
this.scheduledFiber = null;
|
281
|
-
return tsplus_module_4.tap(fiber => tsplus_module_4.succeed(() => this.scheduledFiber = fiber, fileName_1 + ":404:9"), fileName_1 + ":403:87")(tsplus_module_12.forkScoped(tsplus_module_4.zipRight(tsplus_module_4.flatMap(() => this.flushPending(), fileName_1 + ":403:44")(interrupt), fileName_1 + ":403:26")(tsplus_module_4.yieldNow), fileName_1 + ":403:72"));
|
282
|
-
}
|
283
|
-
flushPending() {
|
284
|
-
if (this.pendingEmitters.length === 0) {
|
285
|
-
return tsplus_module_4.unit;
|
286
|
-
}
|
287
|
-
const emitters = this.pendingEmitters;
|
288
|
-
this.pendingEmitters = [];
|
289
|
-
return tsplus_module_4.foreachDiscard(emitters, pendingEmitter => {
|
290
|
-
return tsplus_module_4.defer(() => {
|
291
|
-
const [emitter, values] = pendingEmitter;
|
292
|
-
const observer = this.observers.find(observer => observer.emitter === emitter);
|
293
|
-
if (!observer) {
|
294
|
-
return tsplus_module_4.unit;
|
295
|
-
}
|
296
|
-
return tsplus_module_4.foreachDiscard(values, value => this.runEvent(value, observer), fileName_1 + ":423:33");
|
297
|
-
}, fileName_1 + ":417:22");
|
298
|
-
}, fileName_1 + ":416:29");
|
299
|
-
}
|
300
|
-
addValue(value) {
|
301
|
-
this.value.set(tsplus_module_27.just(value, fileName_1 + ":429:24"));
|
302
|
-
this.pendingEmitters.forEach(([, values]) => {
|
303
|
-
values.push(value);
|
304
|
-
});
|
304
|
+
this.current.set(tsplus_module_25.just(value, fileName_1 + ":401:28"));
|
305
|
+
return super.event(value);
|
306
|
+
}, fileName_1 + ":400:20");
|
305
307
|
}
|
306
308
|
}
|
307
309
|
/**
|
@@ -309,7 +311,7 @@ export class Hold extends Multicast {
|
|
309
311
|
*/
|
310
312
|
function map_1(f) {
|
311
313
|
return self => {
|
312
|
-
return mapIO_1(a => tsplus_module_4.succeedNow(f(a), fileName_1 + ":
|
314
|
+
return mapIO_1(a => tsplus_module_4.succeedNow(f(a), fileName_1 + ":412:43"))(self);
|
313
315
|
};
|
314
316
|
}
|
315
317
|
/**
|
@@ -317,7 +319,7 @@ function map_1(f) {
|
|
317
319
|
*/
|
318
320
|
export function mapError(f) {
|
319
321
|
return self => {
|
320
|
-
return
|
322
|
+
return tsplus_module_11.makePush(emitter => self.run(tsplus_module_11.makeSink(value => emitter.event(value), cause => emitter.error(tsplus_module_27.map(f)(cause)))));
|
321
323
|
};
|
322
324
|
}
|
323
325
|
/**
|
@@ -325,14 +327,14 @@ export function mapError(f) {
|
|
325
327
|
*/
|
326
328
|
export function mapErrorCause(f) {
|
327
329
|
return self => {
|
328
|
-
return
|
330
|
+
return tsplus_module_11.makePush(emitter => self.run(tsplus_module_11.makeSink(value => emitter.event(value), cause => emitter.error(f(cause)))));
|
329
331
|
};
|
330
332
|
}
|
331
333
|
/**
|
332
334
|
* @tsplus pipeable fncts.io.Push mapIO
|
333
335
|
*/
|
334
336
|
function mapIO_1(f) {
|
335
|
-
return self =>
|
337
|
+
return self => tsplus_module_11.makePush(emitter => self.run(tsplus_module_11.makeSink(value => tsplus_module_4.matchCauseIO(cause => emitter.error(cause), b => emitter.event(b), fileName_1 + ":457:34")(f(value)), cause => emitter.error(cause))));
|
336
338
|
}
|
337
339
|
/**
|
338
340
|
* @tsplus pipeable fncts.io.Push merge
|
@@ -343,21 +345,21 @@ export function merge(that) {
|
|
343
345
|
};
|
344
346
|
}
|
345
347
|
function mergeAll_1(streams) {
|
346
|
-
return
|
348
|
+
return tsplus_module_11.makePush(sink => tsplus_module_14.foreachConcurrentDiscard(streams, stream => stream.run(tsplus_module_11.makeSink(sink.event, cause => tsplus_module_27.isInterruptedOnly(cause) ? tsplus_module_4.unit : sink.error(cause))), fileName_1 + ":485:32"));
|
347
349
|
}
|
348
350
|
/**
|
349
351
|
* @tsplus pipeable fncts.io.Push observe
|
350
352
|
*/
|
351
|
-
|
353
|
+
function observe_1(f, __tsplusTrace) {
|
352
354
|
return self => {
|
353
|
-
return tsplus_module_4.flatMap(future => tsplus_module_4.flatMap(fiber => tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, __tsplusTrace)(
|
355
|
+
return tsplus_module_4.flatMap(future => tsplus_module_4.flatMap(fiber => tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, __tsplusTrace)(tsplus_module_28.interruptFork(fiber, __tsplusTrace)), __tsplusTrace)(tsplus_module_1.wait(future, __tsplusTrace)), __tsplusTrace)(tsplus_module_29.forkScoped(tsplus_module_4.flatMap(() => tsplus_module_1.succeed_(undefined, __tsplusTrace)(future), __tsplusTrace)(self.run(tsplus_module_11.makeSink(a => tsplus_module_4.catchAllCause(cause => tsplus_module_1.failCause(cause, __tsplusTrace)(future), __tsplusTrace)(f(a)), cause => tsplus_module_1.failCause(cause, __tsplusTrace)(future)))), __tsplusTrace)), __tsplusTrace)(tsplus_module_9.make(__tsplusTrace));
|
354
356
|
};
|
355
357
|
}
|
356
358
|
/**
|
357
359
|
* @tsplus static fncts.io.PushOps repeatIOMaybe
|
358
360
|
*/
|
359
361
|
export function repeatIOMaybe(io, __tsplusTrace) {
|
360
|
-
return unfoldIO_1(undefined, () => tsplus_module_4.catchAll(maybeError =>
|
362
|
+
return unfoldIO_1(undefined, () => tsplus_module_4.catchAll(maybeError => tsplus_module_16.match(() => tsplus_module_4.succeedNow(tsplus_module_25.nothing(__tsplusTrace), __tsplusTrace), tsplus_module_4.failNow)(maybeError), __tsplusTrace)(tsplus_module_4.map(a => tsplus_module_25.just([a, undefined], __tsplusTrace), __tsplusTrace)(io)));
|
361
363
|
}
|
362
364
|
/**
|
363
365
|
* @tsplus getter fncts.io.Push runCollect
|
@@ -365,68 +367,84 @@ export function repeatIOMaybe(io, __tsplusTrace) {
|
|
365
367
|
export function runCollect(self) {
|
366
368
|
return tsplus_module_4.defer(() => {
|
367
369
|
const out = [];
|
368
|
-
return tsplus_module_4.
|
369
|
-
}, fileName_1 + ":
|
370
|
+
return tsplus_module_4.as(() => tsplus_module_30.fromArray(out), fileName_1 + ":532:51")(observe_1(a => tsplus_module_4.succeed(() => out.push(a), fileName_1 + ":532:34"), fileName_1 + ":532:24")(self));
|
371
|
+
}, fileName_1 + ":530:18");
|
370
372
|
}
|
371
373
|
/**
|
372
374
|
* @tsplus getter fncts.io.Push runDrain
|
373
375
|
*/
|
374
376
|
export function runDrain(self) {
|
375
|
-
return
|
377
|
+
return observe_1(() => tsplus_module_4.unit, fileName_1 + ":540:22")(self);
|
376
378
|
}
|
377
379
|
/**
|
378
380
|
* @tsplus static fncts.io.PushOps scoped
|
379
381
|
*/
|
380
382
|
function scoped_1(io, __tsplusTrace) {
|
381
|
-
return
|
383
|
+
return tsplus_module_11.makePush(emitter => tsplus_module_4.matchCauseIO(cause => emitter.error(cause), value => emitter.event(value), __tsplusTrace)(tsplus_module_10.scoped(tsplus_module_4.defer(io, __tsplusTrace), __tsplusTrace)));
|
382
384
|
}
|
383
385
|
/**
|
384
386
|
* @tsplus static fncts.io.PushOps succeed
|
385
387
|
*/
|
386
388
|
export function succeed(value) {
|
387
|
-
return fromIO_1(() => tsplus_module_4.succeed(value, fileName_1 + ":
|
389
|
+
return fromIO_1(() => tsplus_module_4.succeed(value, fileName_1 + ":559:32"));
|
390
|
+
}
|
391
|
+
/**
|
392
|
+
* @tsplus pipeable fncts.io.Push switchMap
|
393
|
+
*/
|
394
|
+
function switchMap_1(f) {
|
395
|
+
return self => {
|
396
|
+
return tsplus_module_11.makePush(sink => withSwitch(fork => self.run(tsplus_module_11.makeSink(a => fork(f(a).run(sink)), sink.error))));
|
397
|
+
};
|
398
|
+
}
|
399
|
+
/**
|
400
|
+
* @tsplus pipeable fncts.io.Push switchMapIO
|
401
|
+
*/
|
402
|
+
function switchMapIO_1(f) {
|
403
|
+
return self => {
|
404
|
+
return switchMap_1(a => fromIO_1(() => f(a)))(self);
|
405
|
+
};
|
388
406
|
}
|
389
407
|
/**
|
390
|
-
* @tsplus pipeable fncts.io.
|
408
|
+
* @tsplus pipeable fncts.io.Push tap
|
391
409
|
*/
|
392
|
-
export function
|
410
|
+
export function tap(f) {
|
393
411
|
return self => {
|
394
|
-
return
|
395
|
-
const innerEmitter = tsplus_module_10.makeEmitter(value => emitter.emit(value), cause => tsplus_module_4.zipRight(emitter.failCause(cause), fileName_1 + ":638:41")(tsplus_module_36.set(null, fileName_1 + ":638:33")(current)), latch.countDown);
|
396
|
-
return tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, fileName_1 + ":653:10")(tsplus_module_4.zipRight(emitter.end, fileName_1 + ":653:24")(latch.await)), fileName_1 + ":641:10")(self.run(tsplus_module_10.makeEmitter(value => tsplus_module_18.updateIO(fiber => tsplus_module_4.zipRight(tsplus_module_12.forkScoped(f(value).run(innerEmitter), fileName_1 + ":646:98"), fileName_1 + ":646:71")(fiber ? tsplus_module_17.interrupt(fiber) : latch.increment), fileName_1 + ":645:33")(current), cause => emitter.failCause(cause), latch.countDown)));
|
397
|
-
}, fileName_1 + ":635:31")(tsplus_module_13.make(1)), fileName_1 + ":634:31")(tsplus_module_19.makeSynchronized(() => null, fileName_1 + ":634:53")));
|
412
|
+
return tsplus_module_11.makePush(sink => self.run(tsplus_module_11.makeSink(a => tsplus_module_4.matchCauseIO(sink.error, () => sink.event(a), fileName_1 + ":585:65")(f(a)), sink.error)));
|
398
413
|
};
|
399
414
|
}
|
400
415
|
/**
|
401
416
|
* @tsplus pipeable fncts.io.Push transform
|
402
417
|
*/
|
403
418
|
function transform_1(f) {
|
404
|
-
return self =>
|
419
|
+
return self => tsplus_module_11.makePush(emitter => f(self.run(emitter)));
|
405
420
|
}
|
406
421
|
function unfoldLoop(s, f, emitter) {
|
407
|
-
return
|
422
|
+
return tsplus_module_16.match(() => tsplus_module_4.unit, ([a, s]) => tsplus_module_4.zipRight(unfoldLoop(s, f, emitter), fileName_1 + ":603:35")(emitter.event(a)))(f(s));
|
408
423
|
}
|
409
424
|
/**
|
410
425
|
* @tsplus static fncts.io.PushOps unfold
|
411
426
|
*/
|
412
427
|
export function unfold(s, f) {
|
413
|
-
return
|
428
|
+
return tsplus_module_11.makePush(emitter => unfoldLoop(s, f, emitter));
|
414
429
|
}
|
415
430
|
function unfoldIOLoop(s, f, emitter) {
|
416
|
-
return tsplus_module_4.catchAllCause(cause => emitter.
|
431
|
+
return tsplus_module_4.catchAllCause(cause => emitter.error(cause), fileName_1 + ":626:19")(tsplus_module_4.flatMap(result => tsplus_module_16.match(() => tsplus_module_4.unit, ([a, s]) => tsplus_module_4.zipRight(unfoldIOLoop(s, f, emitter), fileName_1 + ":623:39")(emitter.event(a)))(result), fileName_1 + ":620:13")(f(s)));
|
417
432
|
}
|
418
433
|
/**
|
419
434
|
* @tsplus static fncts.io.PushOps unfoldIO
|
420
435
|
*/
|
421
436
|
function unfoldIO_1(s, f) {
|
422
|
-
return
|
437
|
+
return tsplus_module_11.makePush(emitter => unfoldIOLoop(s, f, emitter));
|
423
438
|
}
|
424
439
|
/**
|
425
440
|
* @tsplus pipeable fncts.io.Push untilFuture
|
426
441
|
*/
|
427
442
|
export function untilFuture(future) {
|
428
443
|
return self => {
|
429
|
-
return
|
444
|
+
return tsplus_module_11.makePush(sink => tsplus_module_20.asyncIO(cb => {
|
445
|
+
const exit = tsplus_module_4.succeed(() => cb(tsplus_module_4.unit), fileName_1 + ":643:24");
|
446
|
+
return tsplus_module_4.flatMap(streamFiber => tsplus_module_4.flatMap(futureFiber => tsplus_module_4.map(() => void 0, fileName_1 + ":654:12")(tsplus_module_31.joinAll([streamFiber, futureFiber], fileName_1 + ":654:26")), fileName_1 + ":646:32")(tsplus_module_32.fork(tsplus_module_4.zipRight(exit, fileName_1 + ":652:24")(tsplus_module_4.matchCauseIO(cause => sink.error(cause), () => tsplus_module_4.unit, fileName_1 + ":648:28")(tsplus_module_1.wait(future, fileName_1 + ":647:19"))), fileName_1 + ":652:30")), fileName_1 + ":645:32")(tsplus_module_32.fork(self.run(sink), fileName_1 + ":645:47"));
|
447
|
+
}, fileName_1 + ":642:17"));
|
430
448
|
};
|
431
449
|
}
|
432
450
|
/**
|
@@ -434,7 +452,10 @@ export function untilFuture(future) {
|
|
434
452
|
*/
|
435
453
|
export function untilPush(signal) {
|
436
454
|
return self => {
|
437
|
-
return
|
455
|
+
return tsplus_module_11.makePush(sink => tsplus_module_20.asyncIO(cb => {
|
456
|
+
const exit = tsplus_module_4.succeed(() => cb(tsplus_module_4.unit), fileName_1 + ":668:24");
|
457
|
+
return tsplus_module_4.flatMap(signalFiber => tsplus_module_4.flatMap(streamFiber => tsplus_module_4.map(() => void 0, fileName_1 + ":679:12")(tsplus_module_31.joinAll([signalFiber, streamFiber], fileName_1 + ":679:26")), fileName_1 + ":678:32")(tsplus_module_32.fork(self.run(sink), fileName_1 + ":678:47")), fileName_1 + ":670:32")(tsplus_module_32.fork(signal.run(tsplus_module_11.makeSink(() => exit, cause => sink.error(cause))), fileName_1 + ":676:14"));
|
458
|
+
}, fileName_1 + ":667:17"));
|
438
459
|
};
|
439
460
|
}
|
440
461
|
/**
|
@@ -452,5 +473,5 @@ export function unwrapScoped(self, __tsplusTrace) {
|
|
452
473
|
/**
|
453
474
|
* @tsplus static fncts.io.PushOps never
|
454
475
|
*/
|
455
|
-
export const never = /*#__PURE__*/fromIO_1(() =>
|
476
|
+
export const never = /*#__PURE__*/fromIO_1(() => tsplus_module_33.never);
|
456
477
|
//# sourceMappingURL=api.mjs.map
|