@fncts/io 0.0.35 → 0.0.37

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.
Files changed (76) hide show
  1. package/Fiber/constructors.d.ts +5 -0
  2. package/Push/api.d.ts +70 -41
  3. package/Push/definition.d.ts +11 -13
  4. package/Push/internal.d.ts +7 -11
  5. package/RefSubject/Atomic.d.ts +8 -11
  6. package/RefSubject/Synchronized/definition.d.ts +4 -6
  7. package/RefSubject/api.d.ts +0 -1
  8. package/RefSubject/definition.d.ts +6 -8
  9. package/STM/definition.d.ts +17 -0
  10. package/Sink/api.d.ts +6 -6
  11. package/Subject/Atomic.d.ts +4 -6
  12. package/Subject/definition.d.ts +2 -2
  13. package/_cjs/Fiber/constructors.cjs +10 -2
  14. package/_cjs/Fiber/constructors.cjs.map +1 -1
  15. package/_cjs/IO/definition.cjs.map +1 -1
  16. package/_cjs/Layer/api.cjs.map +1 -1
  17. package/_cjs/Push/api.cjs +206 -175
  18. package/_cjs/Push/api.cjs.map +1 -1
  19. package/_cjs/Push/definition.cjs +12 -13
  20. package/_cjs/Push/definition.cjs.map +1 -1
  21. package/_cjs/Push/internal.cjs +37 -29
  22. package/_cjs/Push/internal.cjs.map +1 -1
  23. package/_cjs/RefSubject/Atomic.cjs +15 -19
  24. package/_cjs/RefSubject/Atomic.cjs.map +1 -1
  25. package/_cjs/RefSubject/Synchronized/definition.cjs +9 -10
  26. package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
  27. package/_cjs/RefSubject/api.cjs +5 -6
  28. package/_cjs/RefSubject/api.cjs.map +1 -1
  29. package/_cjs/RefSubject/definition.cjs.map +1 -1
  30. package/_cjs/STM/api.cjs +2 -2
  31. package/_cjs/STM/api.cjs.map +1 -1
  32. package/_cjs/STM/definition.cjs.map +1 -1
  33. package/_cjs/Sink/api.cjs +13 -13
  34. package/_cjs/Sink/api.cjs.map +1 -1
  35. package/_cjs/Subject/Atomic.cjs +4 -5
  36. package/_cjs/Subject/Atomic.cjs.map +1 -1
  37. package/_mjs/Fiber/constructors.mjs +7 -1
  38. package/_mjs/Fiber/constructors.mjs.map +1 -1
  39. package/_mjs/IO/definition.mjs.map +1 -1
  40. package/_mjs/Layer/api.mjs.map +1 -1
  41. package/_mjs/Push/api.mjs +194 -173
  42. package/_mjs/Push/api.mjs.map +1 -1
  43. package/_mjs/Push/definition.mjs +9 -10
  44. package/_mjs/Push/definition.mjs.map +1 -1
  45. package/_mjs/Push/internal.mjs +33 -22
  46. package/_mjs/Push/internal.mjs.map +1 -1
  47. package/_mjs/RefSubject/Atomic.mjs +15 -19
  48. package/_mjs/RefSubject/Atomic.mjs.map +1 -1
  49. package/_mjs/RefSubject/Synchronized/definition.mjs +9 -10
  50. package/_mjs/RefSubject/Synchronized/definition.mjs.map +1 -1
  51. package/_mjs/RefSubject/api.mjs +6 -7
  52. package/_mjs/RefSubject/api.mjs.map +1 -1
  53. package/_mjs/RefSubject/definition.mjs.map +1 -1
  54. package/_mjs/STM/api.mjs +2 -2
  55. package/_mjs/STM/api.mjs.map +1 -1
  56. package/_mjs/STM/definition.mjs.map +1 -1
  57. package/_mjs/Sink/api.mjs +10 -10
  58. package/_mjs/Sink/api.mjs.map +1 -1
  59. package/_mjs/Subject/Atomic.mjs +4 -5
  60. package/_mjs/Subject/Atomic.mjs.map +1 -1
  61. package/_src/Fiber/constructors.ts +5 -0
  62. package/_src/IO/definition.ts +0 -1
  63. package/_src/Layer/api.ts +0 -1
  64. package/_src/Push/api.ts +270 -335
  65. package/_src/Push/definition.ts +13 -17
  66. package/_src/Push/internal.ts +63 -31
  67. package/_src/RefSubject/Atomic.ts +16 -22
  68. package/_src/RefSubject/Synchronized/definition.ts +6 -9
  69. package/_src/RefSubject/api.ts +9 -12
  70. package/_src/RefSubject/definition.ts +6 -8
  71. package/_src/STM/api.ts +0 -5
  72. package/_src/STM/definition.ts +6 -0
  73. package/_src/Sink/api.ts +9 -9
  74. package/_src/Subject/Atomic.ts +6 -8
  75. package/_src/Subject/definition.ts +2 -2
  76. 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/Push/definition";
13
- import * as tsplus_module_11 from "@fncts/base/data/Either/constructors";
14
- import * as tsplus_module_12 from "@fncts/io/IO/api/forkScoped";
15
- import * as tsplus_module_13 from "@fncts/io/CountdownLatch";
16
- import * as tsplus_module_14 from "@fncts/base/collection/Iterable/api";
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/io/IO/api/acquireRelease";
19
- import * as tsplus_module_17 from "@fncts/io/Fiber/api/interrupt";
20
- import * as tsplus_module_18 from "@fncts/io/Ref/Synchronized/api";
21
- import * as tsplus_module_19 from "@fncts/io/Ref/Synchronized/constructors";
22
- import * as tsplus_module_20 from "@fncts/io/Semaphore";
23
- import * as tsplus_module_21 from "@fncts/base/data/Maybe/destructors";
24
- import * as tsplus_module_22 from "@fncts/io/IO/api/concurrency";
25
- import * as tsplus_module_23 from "@fncts/base/data/function/api";
26
- import * as tsplus_module_24 from "@fncts/io/Schedule/api";
27
- import * as tsplus_module_25 from "@fncts/io/IO/api/schedule";
28
- import * as tsplus_module_26 from "@fncts/io/IO/api/environment";
29
- import * as tsplus_module_27 from "@fncts/base/data/Maybe/constructors";
30
- import * as tsplus_module_28 from "@fncts/base/data/Maybe/definition";
31
- import * as tsplus_module_29 from "@fncts/base/data/FiberId/constructors";
32
- import * as tsplus_module_30 from "@fncts/io/Fiber/api/interruptAs";
33
- import * as tsplus_module_31 from "@fncts/base/data/Cause/api";
34
- import * as tsplus_module_32 from "@fncts/io/IO/api/foreachConcurrent";
35
- import * as tsplus_module_33 from "@fncts/io/Fiber/api/interruptFork";
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 { Emitter, Push, PushTypeId, PushVariance } from "./definition.mjs";
57
- import { earlyExit, onEarlyExit } from "./internal.mjs";
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(future => tsplus_module_4.flatMap(scope => tsplus_module_4.flatMap(runtime => {
71
- const unsafeEmitter = {
72
- emit: value => runtime.unsafeRunOrFork(tsplus_module_5.forkIn(scope, fileName_1 + ":35:76")(emitter.emit(value)), fileName_1 + ":35:49"),
73
- failCause: cause => runtime.unsafeRunOrFork(tsplus_module_5.forkIn(scope, fileName_1 + ":36:102")(tsplus_module_6.fulfill(future, fileName_1 + ":36:87")(emitter.failCause(cause))), fileName_1 + ":36:54"),
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 + ":40:8")(tsplus_module_3.match(canceller => tsplus_module_2.onInterrupt(() => canceller, fileName_1 + ":42:50")(tsplus_module_1.wait(future, fileName_1 + ":42:32")), push => push.run(emitter))(eitherPush)), fileName_1 + ":39:27")(tsplus_module_4.succeed(() => make(unsafeEmitter), fileName_1 + ":39:30"));
77
- }, fileName_1 + ":33:24")(tsplus_module_7.runtime(fileName_1 + ":33:35")), fileName_1 + ":32:24")(tsplus_module_8.scope), fileName_1 + ":31:24")(tsplus_module_9.make(fileName_1 + ":31:36")));
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(emitter => {
84
- make(emitter);
85
- return tsplus_module_11.left(tsplus_module_4.unit, fileName_1 + ":56:23");
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 tsplus_module_10.makePush(emitter => (() => {
90
- const size = tsplus_module_14.size(streams);
91
- return tsplus_module_4.flatMap(ref => tsplus_module_4.flatMap(latch => {
92
- const emitIfReady = tsplus_module_4.flatMap(as => as.length === size ? emitter.emit(as) : tsplus_module_4.unit, fileName_1 + ":73:69")(tsplus_module_4.succeed(() => ref.filter(a => a != null), fileName_1 + ":73:31"));
93
- return tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, fileName_1 + ":89:8")(tsplus_module_4.zipRight(emitter.end, fileName_1 + ":89:22")(latch.await)), fileName_1 + ":76:8")(tsplus_module_4.foreachWithIndex(streams, (i, stream) => tsplus_module_12.forkScoped(stream.run(tsplus_module_10.makeEmitter(value => tsplus_module_4.zipRight(emitIfReady, fileName_1 + ":82:50")(tsplus_module_4.succeed(() => ref[i] = value, fileName_1 + ":82:30")), cause => emitter.failCause(cause), latch.countDown)), fileName_1 + ":86:14"), fileName_1 + ":77:28"));
94
- }, fileName_1 + ":72:30")(tsplus_module_13.make(size)), fileName_1 + ":71:30")(tsplus_module_4.succeed(() => Array(size), fileName_1 + ":71:33"));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(ref => tsplus_module_4.flatMap(latch => tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, fileName_1 + ":127:10")(tsplus_module_4.zipRight(emitter.end, fileName_1 + ":127:24")(latch.await)), fileName_1 + ":112:10")(tsplus_module_12.forkScoped(self.run(tsplus_module_10.makeEmitter(value => tsplus_module_18.updateIO(previous => tsplus_module_4.flatMap(() => tsplus_module_12.forkScoped(tsplus_module_16.acquireRelease(() => tsplus_module_15.delay(duration)(emitter.emit(value)), () => latch.countDown, fileName_1 + ":119:47"), fileName_1 + ":119:107"), fileName_1 + ":118:22")(tsplus_module_4.defer(() => previous ? tsplus_module_17.interrupt(previous) : latch.increment, fileName_1 + ":118:31")), fileName_1 + ":116:29")(ref), cause => emitter.failCause(cause), latch.countDown)), fileName_1 + ":125:12")), fileName_1 + ":111:24")(tsplus_module_13.make(1)), fileName_1 + ":110:24")(tsplus_module_19.makeSynchronized(() => null, fileName_1 + ":110:46")));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(push => push.run(emitter), fileName_1 + ":137:44")(tsplus_module_4.succeed(self, fileName_1 + ":137:30")));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(semaphore => tsplus_module_4.map(() => void 0, fileName_1 + ":148:10")(flatMapConcurrentUnbounded_1(a => transform_1(io => semaphore.withPermit(io))(f(a)))(self).run(emitter)), fileName_1 + ":147:28")(tsplus_module_20.makeSemaphore(concurrency, fileName_1 + ":147:38")));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(latch => tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, fileName_1 + ":172:10")(tsplus_module_4.zipRight(emitter.end, fileName_1 + ":172:24")(latch.await)), fileName_1 + ":162:10")(tsplus_module_12.forkScoped(self.run(tsplus_module_10.makeEmitter(value => tsplus_module_4.zipRight(tsplus_module_12.forkScoped(f(value).run(tsplus_module_10.makeEmitter(emitter.emit, emitter.failCause, latch.countDown)), fileName_1 + ":166:106"), fileName_1 + ":166:34")(latch.increment), emitter.failCause, latch.countDown)), fileName_1 + ":170:12")), fileName_1 + ":161:24")(tsplus_module_13.make(1)));
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 => tsplus_module_21.match(() => flatMapConcurrentUnbounded_1(f)(self), n => flatMapConcurrentBounded_1(f, n)(self))(concurrency), fileName_1 + ":184:25")(tsplus_module_22.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(tsplus_module_23.identity)(self);
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 tsplus_module_10.makePush(emitter => tsplus_module_4.zipRight(emitter.end, fileName_1 + ":219:10")(tsplus_module_4.matchCauseIO(cause => emitter.failCause(cause), value => emitter.emit(value), fileName_1 + ":216:32")(tsplus_module_4.defer(io, fileName_1 + ":216:15"))));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.defer(() => fromAsyncIterableLoop(iterable[Symbol.asyncIterator](), emitter, fileName_1 + ":227:58"), fileName_1 + ":227:36"));
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, emitter, __tsplusTrace) {
170
- return tsplus_module_4.matchCauseIO(cause => tsplus_module_4.zipRight(emitter.end, __tsplusTrace)(emitter.failCause(cause)), result => result.done ? emitter.end : tsplus_module_4.zipRight(fromAsyncIterableLoop(iterator, emitter, __tsplusTrace), __tsplusTrace)(emitter.emit(result.value)), __tsplusTrace)(tsplus_module_4.fromPromiseHalt(iterator.next, __tsplusTrace));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.defer(() => fromIterableLoop(iterable[Symbol.iterator](), emitter), fileName_1 + ":245:36"));
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, emitter) {
222
+ function fromIterableLoop(iterator, sink, cb) {
179
223
  return tsplus_module_4.defer(() => {
180
224
  const value = iterator.next();
181
- return value.done ? emitter.end : tsplus_module_4.zipRight(fromIterableLoop(iterator, emitter), fileName_1 + ":251:66")(emitter.emit(value.value));
182
- }, fileName_1 + ":249:18");
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(emitter) {
197
- return tsplus_module_4.flatMap(environment => tsplus_module_4.flatMap(future => tsplus_module_4.flatMap(() => tsplus_module_1.wait(future, fileName_1 + ":296:22"), fileName_1 + ":283:8")(tsplus_module_4.defer(() => {
198
- this.observers.push({
199
- emitter,
200
- environment,
201
- future
202
- });
203
- if (this.fiber) {
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
- }, fileName_1 + ":284:17")), fileName_1 + ":282:28")(tsplus_module_9.make(fileName_1 + ":282:40")), fileName_1 + ":281:28")(tsplus_module_26.environment(fileName_1 + ":281:43"));
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
- emit(value) {
211
- return tsplus_module_4.defer(() => tsplus_module_4.foreachDiscard(this.observers.slice(), observer => this.runEvent(value, observer), fileName_1 + ":301:38"), fileName_1 + ":301:20");
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
- failCause(cause) {
214
- return tsplus_module_4.zipRight(tsplus_module_4.defer(() => this.cleanup(), fileName_1 + ":307:15"), fileName_1 + ":306:110")(tsplus_module_4.defer(() => tsplus_module_4.foreachDiscard(this.observers.slice(), observer => this.runFailCause(cause, observer), fileName_1 + ":306:33"), fileName_1 + ":306:15"));
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
- get end() {
217
- return tsplus_module_4.zipRight(tsplus_module_4.defer(() => this.cleanup(), fileName_1 + ":314:15"), fileName_1 + ":313:97")(tsplus_module_4.defer(() => tsplus_module_4.foreachDiscard(this.observers.slice(), observer => this.runEnd(observer), fileName_1 + ":313:33"), fileName_1 + ":313:15"));
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
- runEvent(value, observer) {
220
- return tsplus_module_26.provideEnvironment(observer.environment, fileName_1 + ":322:26")(tsplus_module_4.tapErrorCause(cause => this.runFailCause(cause, observer), fileName_1 + ":321:21")(observer.emitter.emit(value)));
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
- runFailCause(cause, observer) {
223
- this.observers.splice(this.observers.indexOf(observer), 1);
224
- return tsplus_module_26.provideEnvironment(observer.environment, fileName_1 + ":327:89")(tsplus_module_6.fulfill(observer.future, fileName_1 + ":327:53")(observer.emitter.failCause(cause)));
225
- }
226
- runEnd(observer) {
227
- this.observers.splice(this.observers.indexOf(observer), 1);
228
- return tsplus_module_26.provideEnvironment(observer.environment, fileName_1 + ":332:76")(tsplus_module_6.fulfill(observer.future, fileName_1 + ":332:40")(observer.emitter.end));
229
- }
230
- cleanup() {
231
- if (this.fiber) {
232
- return tsplus_module_4.zipRight(tsplus_module_4.succeed(() => this.fiber = undefined, fileName_1 + ":337:39"), fileName_1 + ":337:36")(tsplus_module_17.interrupt(this.fiber));
233
- }
234
- return tsplus_module_4.unit;
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.value = new AtomicReference(tsplus_module_27.nothing(fileName_1 + ":351:47"));
249
- this.pendingEmitters = [];
250
- this.scheduledFiber = null;
293
+ this.current = new AtomicReference(tsplus_module_25.nothing(fileName_1 + ":383:49"));
251
294
  }
252
- run(emitter) {
253
- if (this.shouldScheduleFlush()) {
254
- return tsplus_module_4.flatMap(() => super.run(emitter), fileName_1 + ":361:49")(this.scheduleFlush(emitter));
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(emitter);
300
+ return super.run(sink);
261
301
  }
262
- emit(value) {
302
+ event(value) {
263
303
  return tsplus_module_4.defer(() => {
264
- this.addValue(value);
265
- return tsplus_module_4.flatMap(() => super.emit(value), fileName_1 + ":375:41")(this.flushPending());
266
- }, fileName_1 + ":373:20");
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 + ":441:43"))(self);
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 tsplus_module_10.makePush(emitter => self.run(tsplus_module_10.makeEmitter(value => emitter.emit(value), cause => emitter.failCause(tsplus_module_31.map(f)(cause)), emitter.end)));
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 tsplus_module_10.makePush(emitter => self.run(tsplus_module_10.makeEmitter(value => emitter.emit(value), cause => emitter.failCause(f(cause)), emitter.end)));
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 => tsplus_module_10.makePush(emitter => self.run(tsplus_module_10.makeEmitter(value => tsplus_module_4.matchCauseIO(cause => emitter.failCause(cause), b => emitter.emit(b), fileName_1 + ":488:34")(f(value)), cause => emitter.failCause(cause), emitter.end)));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(latch => tsplus_module_4.flatMap(() => tsplus_module_4.map(() => void 0, fileName_1 + ":531:8")(tsplus_module_4.zipRight(emitter.end, fileName_1 + ":531:22")(latch.await)), fileName_1 + ":519:8")(tsplus_module_32.foreachConcurrent(streams, stream => tsplus_module_12.forkScoped(stream.run(tsplus_module_10.makeEmitter(value => emitter.emit(value), cause => emitter.failCause(cause), latch.countDown)), fileName_1 + ":528:14"), fileName_1 + ":520:37")), fileName_1 + ":518:22")(tsplus_module_13.make(tsplus_module_14.size(streams))));
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
- export function observe(f, __tsplusTrace) {
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)(tsplus_module_33.interruptFork(fiber, __tsplusTrace)), __tsplusTrace)(tsplus_module_1.wait(future, __tsplusTrace)), __tsplusTrace)(tsplus_module_12.forkScoped(self.run(tsplus_module_10.makeEmitter(a => tsplus_module_4.catchAllCause(cause => tsplus_module_1.failCause(cause, __tsplusTrace)(future), __tsplusTrace)(f(a)), cause => tsplus_module_1.failCause(cause, __tsplusTrace)(future), tsplus_module_1.succeed_(undefined, __tsplusTrace)(future))), __tsplusTrace)), __tsplusTrace)(tsplus_module_9.make(__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 => tsplus_module_21.match(() => tsplus_module_4.succeedNow(tsplus_module_27.nothing(__tsplusTrace), __tsplusTrace), tsplus_module_4.failNow)(maybeError), __tsplusTrace)(tsplus_module_4.map(a => tsplus_module_27.just([a, undefined], __tsplusTrace), __tsplusTrace)(io)));
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.flatMap(future => tsplus_module_4.zipRight(tsplus_module_4.succeed(() => tsplus_module_34.fromArray(out), fileName_1 + ":586:11"), fileName_1 + ":585:23")(tsplus_module_4.zipRight(tsplus_module_1.wait(future, fileName_1 + ":585:15"), fileName_1 + ":584:12")(self.run(tsplus_module_10.makeEmitter(value => tsplus_module_4.succeed(() => out.push(value), fileName_1 + ":580:26"), cause => tsplus_module_1.failCause(cause, fileName_1 + ":581:40")(future), tsplus_module_1.succeed_(undefined, fileName_1 + ":582:27")(future))))), fileName_1 + ":576:42")(tsplus_module_9.make(fileName_1 + ":576:23"));
369
- }, fileName_1 + ":574:18");
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 tsplus_module_4.flatMap(future => tsplus_module_4.zipRight(tsplus_module_1.wait(future, fileName_1 + ":603:17"), fileName_1 + ":603:10")(self.run(tsplus_module_10.makeEmitter(() => tsplus_module_4.unit, cause => tsplus_module_1.failCause(cause, fileName_1 + ":600:38")(future), tsplus_module_1.succeed_(undefined, fileName_1 + ":601:25")(future)))), fileName_1 + ":595:40")(tsplus_module_9.make(fileName_1 + ":595:21"));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.zipRight(emitter.end, __tsplusTrace)(tsplus_module_4.matchCauseIO(cause => emitter.failCause(cause), value => emitter.emit(value), __tsplusTrace)(tsplus_module_35.scoped(tsplus_module_4.defer(io, __tsplusTrace), __tsplusTrace))));
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 + ":624:32"));
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.PushOps switchMap
408
+ * @tsplus pipeable fncts.io.Push tap
391
409
  */
392
- export function switchMap(f) {
410
+ export function tap(f) {
393
411
  return self => {
394
- return tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(current => tsplus_module_4.flatMap(latch => {
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 => tsplus_module_10.makePush(emitter => f(self.run(emitter)));
419
+ return self => tsplus_module_11.makePush(emitter => f(self.run(emitter)));
405
420
  }
406
421
  function unfoldLoop(s, f, emitter) {
407
- return tsplus_module_21.match(() => emitter.end, ([a, s]) => tsplus_module_4.zipRight(unfoldLoop(s, f, emitter), fileName_1 + ":673:34")(emitter.emit(a)))(f(s));
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 tsplus_module_10.makePush(emitter => unfoldLoop(s, f, emitter));
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.failCause(cause), fileName_1 + ":696:19")(tsplus_module_4.flatMap(result => tsplus_module_21.match(() => emitter.end, ([a, s]) => tsplus_module_4.zipRight(unfoldIOLoop(s, f, emitter), fileName_1 + ":693:38")(emitter.emit(a)))(result), fileName_1 + ":690:13")(f(s)));
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 tsplus_module_10.makePush(emitter => unfoldIOLoop(s, f, emitter));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(futureFiber => tsplus_module_4.flatMap(streamFiber => tsplus_module_4.map(() => void 0, fileName_1 + ":722:10")(tsplus_module_4.via(tsplus_module_37.joinAll([futureFiber, streamFiber], fileName_1 + ":722:24"), onEarlyExit(emitter.end))), fileName_1 + ":721:30")(tsplus_module_12.forkScoped(self.run(emitter), fileName_1 + ":721:48")), fileName_1 + ":713:30")(tsplus_module_12.forkScoped(tsplus_module_4.zipRight(earlyExit, fileName_1 + ":719:22")(tsplus_module_4.matchCauseIO(cause => emitter.failCause(cause), () => tsplus_module_4.unit, fileName_1 + ":715:26")(tsplus_module_1.wait(future, fileName_1 + ":714:17"))), fileName_1 + ":719:33")));
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 tsplus_module_10.makePush(emitter => tsplus_module_4.flatMap(signalFiber => tsplus_module_4.flatMap(streamFiber => tsplus_module_4.map(() => void 0, fileName_1 + ":745:10")(tsplus_module_4.via(tsplus_module_37.joinAll([signalFiber, streamFiber], fileName_1 + ":745:24"), onEarlyExit(emitter.end))), fileName_1 + ":744:30")(tsplus_module_12.forkScoped(self.run(emitter), fileName_1 + ":744:48")), fileName_1 + ":735:30")(tsplus_module_12.forkScoped(signal.run(tsplus_module_10.makeEmitter(() => earlyExit, cause => emitter.failCause(cause), earlyExit)), fileName_1 + ":742:12")));
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(() => tsplus_module_38.never);
476
+ export const never = /*#__PURE__*/fromIO_1(() => tsplus_module_33.never);
456
477
  //# sourceMappingURL=api.mjs.map