@fncts/io 0.0.9 → 0.0.10

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 (81) hide show
  1. package/Channel/api.d.ts +27 -4
  2. package/Channel/internal/MergeDecision.d.ts +14 -0
  3. package/STM/api.d.ts +7 -0
  4. package/Sink/api.d.ts +455 -7
  5. package/TReentrantLock/api.d.ts +97 -0
  6. package/TReentrantLock/definition.d.ts +65 -0
  7. package/TReentrantLock.d.ts +2 -0
  8. package/_cjs/Cached/api.cjs +1 -1
  9. package/_cjs/Cached/api.cjs.map +1 -1
  10. package/_cjs/Channel/api/mapOutIOC.cjs +1 -1
  11. package/_cjs/Channel/api/mapOutIOC.cjs.map +1 -1
  12. package/_cjs/Channel/api/mergeAllWith.cjs +2 -2
  13. package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
  14. package/_cjs/Channel/api/mergeWith.cjs +1 -1
  15. package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
  16. package/_cjs/Channel/api.cjs +87 -32
  17. package/_cjs/Channel/api.cjs.map +1 -1
  18. package/_cjs/Channel/internal/MergeDecision.cjs +11 -2
  19. package/_cjs/Channel/internal/MergeDecision.cjs.map +1 -1
  20. package/_cjs/IO/api/foreachC.cjs +2 -2
  21. package/_cjs/IO/api/foreachC.cjs.map +1 -1
  22. package/_cjs/STM/api.cjs +15 -6
  23. package/_cjs/STM/api.cjs.map +1 -1
  24. package/_cjs/Sink/api.cjs +1180 -40
  25. package/_cjs/Sink/api.cjs.map +1 -1
  26. package/_cjs/Stream/api.cjs +28 -28
  27. package/_cjs/Stream/api.cjs.map +1 -1
  28. package/_cjs/TReentrantLock/api.cjs +297 -0
  29. package/_cjs/TReentrantLock/api.cjs.map +1 -0
  30. package/_cjs/TReentrantLock/definition.cjs +125 -0
  31. package/_cjs/TReentrantLock/definition.cjs.map +1 -0
  32. package/_cjs/TReentrantLock.cjs +32 -0
  33. package/_cjs/TReentrantLock.cjs.map +1 -0
  34. package/_cjs/collection/immutable/Conc/filterIO.cjs +35 -0
  35. package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -0
  36. package/_cjs/collection/immutable/Conc.cjs +13 -0
  37. package/_cjs/collection/immutable/Conc.cjs.map +1 -1
  38. package/_mjs/Cached/api.mjs +1 -1
  39. package/_mjs/Cached/api.mjs.map +1 -1
  40. package/_mjs/Channel/api/mapOutIOC.mjs +1 -1
  41. package/_mjs/Channel/api/mapOutIOC.mjs.map +1 -1
  42. package/_mjs/Channel/api/mergeAllWith.mjs +2 -2
  43. package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
  44. package/_mjs/Channel/api/mergeWith.mjs +1 -1
  45. package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
  46. package/_mjs/Channel/api.mjs +75 -30
  47. package/_mjs/Channel/api.mjs.map +1 -1
  48. package/_mjs/Channel/internal/MergeDecision.mjs +7 -0
  49. package/_mjs/Channel/internal/MergeDecision.mjs.map +1 -1
  50. package/_mjs/IO/api/foreachC.mjs +2 -2
  51. package/_mjs/IO/api/foreachC.mjs.map +1 -1
  52. package/_mjs/STM/api.mjs +13 -6
  53. package/_mjs/STM/api.mjs.map +1 -1
  54. package/_mjs/Sink/api.mjs +996 -31
  55. package/_mjs/Sink/api.mjs.map +1 -1
  56. package/_mjs/Stream/api.mjs +28 -28
  57. package/_mjs/Stream/api.mjs.map +1 -1
  58. package/_mjs/TReentrantLock/api.mjs +243 -0
  59. package/_mjs/TReentrantLock/api.mjs.map +1 -0
  60. package/_mjs/TReentrantLock/definition.mjs +102 -0
  61. package/_mjs/TReentrantLock/definition.mjs.map +1 -0
  62. package/_mjs/TReentrantLock.mjs +4 -0
  63. package/_mjs/TReentrantLock.mjs.map +1 -0
  64. package/_mjs/collection/immutable/Conc/filterIO.mjs +22 -0
  65. package/_mjs/collection/immutable/Conc/filterIO.mjs.map +1 -0
  66. package/_mjs/collection/immutable/Conc.mjs +1 -0
  67. package/_mjs/collection/immutable/Conc.mjs.map +1 -1
  68. package/_src/Channel/api.ts +98 -11
  69. package/_src/Channel/internal/MergeDecision.ts +15 -0
  70. package/_src/IO/api.ts +1 -1
  71. package/_src/STM/api.ts +9 -0
  72. package/_src/Sink/api.ts +1350 -19
  73. package/_src/TFuture/definition.ts +1 -1
  74. package/_src/TReentrantLock/api.ts +193 -0
  75. package/_src/TReentrantLock/definition.ts +86 -0
  76. package/_src/TReentrantLock.ts +4 -0
  77. package/_src/collection/immutable/Conc/filterIO.ts +16 -0
  78. package/_src/collection/immutable/Conc.ts +1 -0
  79. package/collection/immutable/Conc/filterIO.d.ts +7 -0
  80. package/collection/immutable/Conc.d.ts +1 -0
  81. package/package.json +3 -3
package/_cjs/Sink/api.cjs CHANGED
@@ -3,53 +3,381 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.apFirst = apFirst;
7
+ exports.apFirstC = apFirstC;
8
+ exports.apSecond = apSecond;
9
+ exports.apSecondC = apSecondC;
10
+ exports.as = as;
6
11
  exports.collectAll = collectAll;
12
+ exports.collectAllWhileWith = void 0;
13
+ exports.collectLeftover = collectLeftover;
14
+ exports.defer = exports.contramapIO = exports.contramapChunksIO = exports.contramapChunks = exports.contramap = void 0;
15
+ exports.dimap = dimap;
16
+ exports.dimapChunks = dimapChunks;
17
+ exports.dimapChunksIO = dimapChunksIO;
18
+ exports.dimapIO = dimapIO;
7
19
  exports.drain = void 0;
8
20
  exports.dropWhile = dropWhile;
9
- exports.foreach = foreach;
10
- exports.foreachWhile = void 0;
21
+ exports.environment = environment;
22
+ exports.environmentWith = environmentWith;
23
+ exports.environmentWithIO = environmentWithIO;
24
+ exports.environmentWithSink = environmentWithSink;
25
+ exports.fail = fail;
26
+ exports.failNow = exports.failCauseNow = exports.failCause = void 0;
27
+ exports.filterInput = filterInput;
28
+ exports.filterInputIO = filterInputIO;
29
+ exports.findIO = findIO;
30
+ exports.flatMap = void 0;
31
+ exports.fromChannel = fromChannel;
32
+ exports.fromHub = fromHub;
33
+ exports.fromHubWithShutdown = fromHubWithShutdown;
34
+ exports.fromIO = void 0;
35
+ exports.fromPush = fromPush;
36
+ exports.fromQueueWithShutdown = exports.fromQueue = void 0;
37
+ exports.halt = halt;
38
+ exports.haltNow = haltNow;
39
+ exports.head = head;
40
+ exports.ignoreLeftover = void 0;
41
+ exports.last = last;
42
+ exports.leftover = leftover;
43
+ exports.log = log;
44
+ exports.makeCollectAll = makeCollectAll;
45
+ exports.makeCollectAllN = makeCollectAllN;
46
+ exports.makeFoldLeft = exports.makeFoldIO = exports.makeFoldChunksIO = exports.makeFoldChunks = exports.makeFold = void 0;
47
+ exports.makeFoldLeftChunks = makeFoldLeftChunks;
48
+ exports.makeFoldLeftChunksIO = makeFoldLeftChunksIO;
49
+ exports.makeFoldLeftIO = makeFoldLeftIO;
50
+ exports.makeFoldUntil = void 0;
51
+ exports.makeFoldUntilIO = makeFoldUntilIO;
52
+ exports.makeFoldWeighted = makeFoldWeighted;
53
+ exports.makeFoldWeightedDecomposeIO = exports.makeFoldWeightedDecompose = void 0;
54
+ exports.makeFoldWeightedIO = makeFoldWeightedIO;
55
+ exports.makeForeach = makeForeach;
56
+ exports.makeForeachChunk = void 0;
57
+ exports.makeForeachChunkWhile = makeForeachChunkWhile;
58
+ exports.makeForeachWhile = void 0;
59
+ exports.mapError_ = mapError_;
60
+ exports.matchSink_ = exports.map_ = exports.mapIO_ = void 0;
61
+ exports.orElse = orElse;
62
+ exports.provideEnvironment = provideEnvironment;
63
+ exports.race = race;
64
+ exports.raceWith = exports.raceBoth = void 0;
65
+ exports.service = service;
66
+ exports.serviceWith = void 0;
67
+ exports.serviceWithIO = serviceWithIO;
68
+ exports.serviceWithSink = serviceWithSink;
69
+ exports.splitWhere = splitWhere;
70
+ exports.succeed = succeed;
71
+ exports.succeedNow = succeedNow;
72
+ exports.summarized = void 0;
73
+ exports.timed = timed;
74
+ exports.unwrapScoped = exports.unwrap = void 0;
75
+ exports.zip = zip;
76
+ exports.zipC = zipC;
77
+ exports.zipWithC = exports.zipWith = void 0;
11
78
 
12
- var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api"));
79
+ var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api/empty"));
13
80
 
14
- var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/core-api"));
81
+ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api"));
15
82
 
16
- var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/api"));
83
+ var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Sink/definition"));
17
84
 
18
- var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Sink/definition"));
85
+ var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/api"));
19
86
 
20
- var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api/empty"));
87
+ var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/core-api"));
21
88
 
22
- var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api"));
89
+ var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Ref/api/set"));
90
+
91
+ var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Ref/api/get"));
92
+
93
+ var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Ref/constructors"));
94
+
95
+ var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api"));
96
+
97
+ var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/collection/immutable/Conc/mapIO"));
98
+
99
+ var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/environment"));
100
+
101
+ var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/function/api"));
102
+
103
+ var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/collection/immutable/Conc/filterIO"));
104
+
105
+ var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
106
+
107
+ var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Either/destructors"));
108
+
109
+ var tsplus_module_16 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Queue/api/operations"));
110
+
111
+ var tsplus_module_17 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/acquireRelease"));
112
+
113
+ var tsplus_module_18 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Cause/api"));
114
+
115
+ var tsplus_module_19 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/definition"));
116
+
117
+ var tsplus_module_20 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/destructors"));
118
+
119
+ var tsplus_module_21 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc"));
120
+
121
+ var tsplus_module_22 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/constructors"));
122
+
123
+ var tsplus_module_23 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Either/api"));
124
+
125
+ var tsplus_module_24 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Either/constructors"));
126
+
127
+ var tsplus_module_25 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/internal/MergeDecision"));
128
+
129
+ var tsplus_module_26 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/api/mergeWith"));
130
+
131
+ var tsplus_module_27 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Hub/api"));
132
+
133
+ var tsplus_module_28 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/Iterable/api"));
134
+
135
+ var tsplus_module_29 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Clock/api"));
136
+
137
+ var tsplus_module_30 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Duration/api"));
138
+
139
+ var tsplus_module_31 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Exit/api"));
140
+
141
+ var _AtomicReference = /*#__PURE__*/require("@fncts/base/internal/AtomicReference");
23
142
 
24
143
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
144
 
26
145
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
146
 
28
- const foreachWhile = foreachWhile_1;
29
- exports.foreachWhile = foreachWhile;
147
+ const fileName_1 = "(@fncts/io) src/Sink/api.ts";
148
+ const collectAllWhileWith = collectAllWhileWith_1;
149
+ exports.collectAllWhileWith = collectAllWhileWith;
150
+ const contramap = contramap_1;
151
+ exports.contramap = contramap;
152
+ const contramapChunks = contramapChunks_1;
153
+ exports.contramapChunks = contramapChunks;
154
+ const contramapChunksIO = contramapChunksIO_1;
155
+ exports.contramapChunksIO = contramapChunksIO;
156
+ const contramapIO = contramapIO_1;
157
+ exports.contramapIO = contramapIO;
158
+ const defer = defer_1;
159
+ exports.defer = defer;
160
+ const failCause = failCause_1;
161
+ exports.failCause = failCause;
162
+ const failCauseNow = failCauseNow_1;
163
+ exports.failCauseNow = failCauseNow;
164
+ const failNow = failNow_1;
165
+ exports.failNow = failNow;
166
+ const flatMap = flatMap_1;
167
+ exports.flatMap = flatMap;
168
+ const fromQueue = fromQueue_1;
169
+ exports.fromQueue = fromQueue;
170
+ const fromQueueWithShutdown = fromQueueWithShutdown_1;
171
+ exports.fromQueueWithShutdown = fromQueueWithShutdown;
172
+ const fromIO = fromIO_1;
173
+ exports.fromIO = fromIO;
174
+ const ignoreLeftover = ignoreLeftover_1;
175
+ exports.ignoreLeftover = ignoreLeftover;
176
+ const makeForeachChunk = makeForeachChunk_1;
177
+ exports.makeForeachChunk = makeForeachChunk;
178
+ const makeForeachWhile = makeForeachWhile_1;
179
+ exports.makeForeachWhile = makeForeachWhile;
180
+ const makeFold = makeFold_1;
181
+ exports.makeFold = makeFold;
182
+ const makeFoldUntil = makeFoldUntil_1;
183
+ exports.makeFoldUntil = makeFoldUntil;
184
+ const makeFoldChunks = makeFoldChunks_1;
185
+ exports.makeFoldChunks = makeFoldChunks;
186
+ const makeFoldChunksIO = makeFoldChunksIO_1;
187
+ exports.makeFoldChunksIO = makeFoldChunksIO;
188
+ const makeFoldLeft = makeFoldLeft_1;
189
+ exports.makeFoldLeft = makeFoldLeft;
190
+ const makeFoldIO = makeFoldIO_1;
191
+ exports.makeFoldIO = makeFoldIO;
192
+ const makeFoldWeightedDecompose = makeFoldWeightedDecompose_1;
193
+ exports.makeFoldWeightedDecompose = makeFoldWeightedDecompose;
194
+ const makeFoldWeightedDecomposeIO = makeFoldWeightedDecomposeIO_1;
195
+ exports.makeFoldWeightedDecomposeIO = makeFoldWeightedDecomposeIO;
196
+ const map_ = map_1;
197
+ exports.map_ = map_;
198
+ const mapIO_ = mapIO_1;
199
+ exports.mapIO_ = mapIO_;
200
+ const matchSink_ = matchSink_1;
201
+ exports.matchSink_ = matchSink_;
202
+ const raceBoth = raceBoth_1;
203
+ exports.raceBoth = raceBoth;
204
+ const raceWith = raceWith_1;
205
+ exports.raceWith = raceWith;
206
+ const serviceWith = serviceWith_1;
207
+ exports.serviceWith = serviceWith;
208
+ const summarized = summarized_1;
209
+ exports.summarized = summarized;
210
+ const unwrap = unwrap_1;
211
+ exports.unwrap = unwrap;
212
+ const unwrapScoped = unwrapScoped_1;
213
+ exports.unwrapScoped = unwrapScoped;
214
+ const zipWith = zipWith_1;
215
+ exports.zipWith = zipWith;
216
+ const zipWithC = zipWithC_1;
217
+ exports.zipWithC = zipWithC;
30
218
 
31
- function collectLoop(state) {
32
- return tsplus_module_3.readWithCause(inp => collectLoop(tsplus_module_1.concat_(state, inp)), tsplus_module_2.failCauseNow, () => tsplus_module_2.endNow(state));
219
+ /**
220
+ * @tsplus fluent fncts.io.Sink apFirst
221
+ */
222
+ function apFirst(self, that) {
223
+ return zipWith_1(() => self, that, (z, _) => z);
33
224
  }
34
225
  /**
35
- * A sink that collects all of its inputs into a chunk.
36
- *
37
- * @tsplus static fncts.io.SinkOps collectAll
226
+ * @tsplus fluent fncts.io.Sink apFirstC
227
+ */
228
+
229
+
230
+ function apFirstC(self, that) {
231
+ return zipWithC_1(() => self, that, (z, _) => z);
232
+ }
233
+ /**
234
+ * @tsplus fluent fncts.io.Sink apSecond
235
+ */
236
+
237
+
238
+ function apSecond(self, that) {
239
+ return zipWith_1(() => self, that, (_, z1) => z1);
240
+ }
241
+ /**
242
+ * @tsplus fluent fncts.io.Sink apSecondC
243
+ */
244
+
245
+
246
+ function apSecondC(self, that) {
247
+ return zipWithC_1(() => self, that, (_, z1) => z1);
248
+ }
249
+ /**
250
+ * @tsplus fluent fncts.io.Sink as
251
+ */
252
+
253
+
254
+ function as(self, z) {
255
+ return map_1(self, () => z(), fileName_1 + ":49:18");
256
+ }
257
+ /**
258
+ * @tsplus fluent fncts.io.Sink collectAll
259
+ */
260
+
261
+
262
+ function collectAll(self, __tsplusTrace) {
263
+ return collectAllWhileWith_1(self, () => tsplus_module_1.empty(), () => true, (s, z) => tsplus_module_2.append_(s, z), __tsplusTrace);
264
+ }
265
+ /**
266
+ * @tsplus fluent fncts.io.Sink collectAllWhileWith
267
+ */
268
+
269
+
270
+ function collectAllWhileWith_1(self, z, p, f, __tsplusTrace) {
271
+ return new tsplus_module_3.Sink(tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => tsplus_module_9.zip_(tsplus_module_8.make(() => tsplus_module_1.empty()), tsplus_module_8.make(() => false))), ([leftoversRef, upstreamDoneRef]) => {
272
+ const upstreamMarker = tsplus_module_4.readWith(inp => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(inp), upstreamMarker), tsplus_module_4.failNow, x => tsplus_module_4.as_(tsplus_module_4.fromIO(() => tsplus_module_6.set_(upstreamDoneRef, true)), () => x));
273
+
274
+ function loop(currentResult) {
275
+ return tsplus_module_4.matchChannel_(tsplus_module_4.collectElements(self.channel), tsplus_module_4.failNow, ([leftovers, doneValue]) => {
276
+ if (p(doneValue)) {
277
+ return tsplus_module_5.apSecond_(tsplus_module_4.fromIO(() => tsplus_module_6.set_(leftoversRef, tsplus_module_2.flatten(leftovers))), tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => tsplus_module_7.get(upstreamDoneRef)), upstreamDone => {
278
+ const accumulatedResult = f(currentResult, doneValue);
279
+ if (upstreamDone) return tsplus_module_4.as_(tsplus_module_4.writeNow(tsplus_module_2.flatten(leftovers)), () => accumulatedResult);else return loop(accumulatedResult);
280
+ }));
281
+ } else {
282
+ return tsplus_module_4.as_(tsplus_module_4.writeNow(tsplus_module_2.flatten(leftovers)), () => currentResult);
283
+ }
284
+ });
285
+ }
286
+
287
+ return tsplus_module_4.pipeTo_(tsplus_module_4.pipeTo_(upstreamMarker, tsplus_module_4.bufferChunk(leftoversRef)), loop(z()));
288
+ }));
289
+ }
290
+ /**
291
+ * @tsplus getter fncts.io.Sink collectLeftover
292
+ */
293
+
294
+
295
+ function collectLeftover(self, __tsplusTrace) {
296
+ return new tsplus_module_3.Sink(tsplus_module_5.map_(tsplus_module_4.collectElements(self.channel), ([chunks, z]) => [z, tsplus_module_2.flatten(chunks)]));
297
+ }
298
+ /**
299
+ * @tsplus fluent fncts.io.Sink contramap
300
+ */
301
+
302
+
303
+ function contramap_1(self, f) {
304
+ return contramapChunks_1(self, chunk => tsplus_module_2.map_(chunk, f));
305
+ }
306
+ /**
307
+ * @tsplus fluent fncts.io.Sink contramapChunks
308
+ */
309
+
310
+
311
+ function contramapChunks_1(self, f) {
312
+ const loop = tsplus_module_4.readWith(chunk => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(f(chunk)), loop), tsplus_module_4.failNow, tsplus_module_5.succeedNow);
313
+ return new tsplus_module_3.Sink(tsplus_module_4.pipeTo_(loop, self.channel));
314
+ }
315
+ /**
316
+ * @tsplus fluent fncts.io.Sink contramapChunksIO
317
+ */
318
+
319
+
320
+ function contramapChunksIO_1(self, f) {
321
+ const loop = tsplus_module_4.readWith(chunk => tsplus_module_5.apSecond_(tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => f(chunk)), tsplus_module_4.writeNow), loop), tsplus_module_4.failNow, tsplus_module_5.succeedNow);
322
+ return new tsplus_module_3.Sink(tsplus_module_4.pipeToOrFail_(loop, self.channel));
323
+ }
324
+ /**
325
+ * @tsplus fluent fncts.io.Sink contramapIO
326
+ */
327
+
328
+
329
+ function contramapIO_1(self, f) {
330
+ return contramapChunksIO_1(self, chunk => tsplus_module_10.mapIO_(chunk, f));
331
+ }
332
+ /**
333
+ * @tsplus fluent fncts.io.Sink dimap
334
+ */
335
+
336
+
337
+ function dimap(self, f, g) {
338
+ return map_1(contramap_1(self, f), g, fileName_1 + ":171:31");
339
+ }
340
+ /**
341
+ * @tsplus fluent fncts.io.Sink dimapChunks
342
+ */
343
+
344
+
345
+ function dimapChunks(self, f, g) {
346
+ return map_1(contramapChunks_1(self, f), g, fileName_1 + ":182:37");
347
+ }
348
+ /**
349
+ * @tsplus fluent fncts.io.Sink dimapChunksIO
350
+ */
351
+
352
+
353
+ function dimapChunksIO(self, f, g) {
354
+ return mapIO_1(contramapChunksIO_1(self, f), g, fileName_1 + ":193:41");
355
+ }
356
+ /**
357
+ * @tsplus fluent fncts.io.Sink dimapIO
358
+ */
359
+
360
+
361
+ function dimapIO(self, f, g) {
362
+ return mapIO_1(contramapIO_1(self, f), g, fileName_1 + ":204:35");
363
+ }
364
+ /**
365
+ * @tsplus static fncts.io.SinkOps defer
38
366
  */
39
367
 
40
368
 
41
- function collectAll() {
42
- return new tsplus_module_4.Sink(collectLoop(tsplus_module_5.empty()));
369
+ function defer_1(sink) {
370
+ return new tsplus_module_3.Sink(tsplus_module_4.defer(() => sink().channel));
43
371
  }
44
372
 
45
- const drainLoop = /*#__PURE__*/tsplus_module_3.readWithCause(() => drainLoop, tsplus_module_2.failCauseNow, () => tsplus_module_3.unit);
373
+ const drainLoop = /*#__PURE__*/tsplus_module_4.readWithCause(() => drainLoop, tsplus_module_5.failCauseNow, () => tsplus_module_4.unit);
46
374
  /**
47
375
  * A sink that ignores all of its inputs.
48
376
  *
49
377
  * @tsplus static fncts.io.SinkOps drain
50
378
  */
51
379
 
52
- const drain = /*#__PURE__*/new tsplus_module_4.Sink(drainLoop);
380
+ const drain = /*#__PURE__*/new tsplus_module_3.Sink(drainLoop);
53
381
  /**
54
382
  * @tsplus static fncts.io.SinkOps dropWhile
55
383
  */
@@ -57,46 +385,858 @@ const drain = /*#__PURE__*/new tsplus_module_4.Sink(drainLoop);
57
385
  exports.drain = drain;
58
386
 
59
387
  function dropWhile(predicate) {
60
- const loop = tsplus_module_3.readWith(inp => {
61
- const leftover = tsplus_module_1.dropWhile_(inp, predicate);
62
- const more = tsplus_module_1.isEmpty(leftover);
388
+ const loop = tsplus_module_4.readWith(inp => {
389
+ const leftover = tsplus_module_2.dropWhile_(inp, predicate);
390
+ const more = tsplus_module_2.isEmpty(leftover);
63
391
 
64
392
  if (more) {
65
393
  return loop;
66
394
  } else {
67
- return tsplus_module_2.apSecond_(tsplus_module_3.writeNow(leftover), tsplus_module_3.id());
395
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftover), tsplus_module_4.id());
68
396
  }
69
- }, tsplus_module_3.failNow, () => tsplus_module_3.unit);
70
- return new tsplus_module_4.Sink(loop);
397
+ }, tsplus_module_4.failNow, () => tsplus_module_4.unit);
398
+ return new tsplus_module_3.Sink(loop);
71
399
  }
72
400
  /**
73
- * A sink that executes the provided effectful function for every element fed to it.
401
+ * @tsplus static fncts.io.SinkOps environment
402
+ */
403
+
404
+
405
+ function environment(__tsplusTrace) {
406
+ return fromIO_1(() => tsplus_module_11.environment(__tsplusTrace));
407
+ }
408
+ /**
409
+ * @tsplus static fncts.io.SinkOps environmentWith
410
+ */
411
+
412
+
413
+ function environmentWith(f, __tsplusTrace) {
414
+ return fromIO_1(() => tsplus_module_11.environmentWith(f, __tsplusTrace));
415
+ }
416
+ /**
417
+ * @tsplus static fncts.io.SinkOps environmentWithIO
418
+ */
419
+
420
+
421
+ function environmentWithIO(f, __tsplusTrace) {
422
+ return fromIO_1(() => tsplus_module_11.environmentWithIO(f, __tsplusTrace));
423
+ }
424
+ /**
425
+ * @tsplus static fncts.io.SinkOps environmentWithSink
426
+ */
427
+
428
+
429
+ function environmentWithSink(f, __tsplusTrace) {
430
+ return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_11.environmentWith(tsplus_module_12.compose_(f, s => s.channel), __tsplusTrace)));
431
+ }
432
+ /**
433
+ * @tsplus static fncts.io.SinkOps fail
434
+ */
435
+
436
+
437
+ function fail(e) {
438
+ return new tsplus_module_3.Sink(tsplus_module_4.fail(e));
439
+ }
440
+ /**
441
+ * @tsplus static fncts.io.SinkOps failCause
442
+ */
443
+
444
+
445
+ function failCause_1(cause, __tsplusTrace) {
446
+ return new tsplus_module_3.Sink(tsplus_module_5.failCause(cause));
447
+ }
448
+ /**
449
+ * @tsplus static fncts.io.SinkOps failCauseNow
450
+ */
451
+
452
+
453
+ function failCauseNow_1(cause, __tsplusTrace) {
454
+ return new tsplus_module_3.Sink(tsplus_module_5.failCauseNow(cause));
455
+ }
456
+ /**
457
+ * @tsplus static fncts.io.SinkOps failNow
458
+ */
459
+
460
+
461
+ function failNow_1(e, __tsplusTrace) {
462
+ return new tsplus_module_3.Sink(tsplus_module_4.failNow(e));
463
+ }
464
+ /**
465
+ * @tsplus static fncts.io.SinkOps filterInput
466
+ */
467
+
468
+
469
+ function filterInput(self, p, __tsplusTrace) {
470
+ return contramapChunks_1(self, chunk => tsplus_module_2.filter_(chunk, p));
471
+ }
472
+ /**
473
+ * @tsplus static fncts.io.SinkOps filterInputIO
474
+ */
475
+
476
+
477
+ function filterInputIO(self, p, __tsplusTrace) {
478
+ return contramapChunksIO_1(self, chunk => tsplus_module_13.filterIO(chunk, p));
479
+ }
480
+ /**
481
+ * @tsplus fluent fncts.io.Sink findIO
482
+ */
483
+
484
+
485
+ function findIO(self, f, __tsplusTrace) {
486
+ return new tsplus_module_3.Sink(tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => tsplus_module_9.zip_(tsplus_module_8.make(() => tsplus_module_1.empty()), tsplus_module_8.make(() => false))), ([leftoversRef, upstreamDoneRef]) => {
487
+ const upstreamMarker = tsplus_module_4.readWith(inp => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(inp), upstreamMarker), tsplus_module_4.failNow, x => tsplus_module_4.as_(tsplus_module_4.fromIO(() => tsplus_module_6.set_(upstreamDoneRef, true)), () => x));
488
+ const loop = tsplus_module_4.matchChannel_(tsplus_module_4.collectElements(self.channel), tsplus_module_4.failNow, ([leftovers, doneValue]) => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => f(doneValue)), satisfied => tsplus_module_5.apSecond_(tsplus_module_4.fromIO(() => tsplus_module_6.set_(leftoversRef, tsplus_module_2.flatten(leftovers))), tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => tsplus_module_7.get(upstreamDoneRef)), upstreamDone => {
489
+ if (satisfied) return tsplus_module_4.as_(tsplus_module_4.writeNow(tsplus_module_2.flatten(leftovers)), () => tsplus_module_14.just(doneValue));else if (upstreamDone) return tsplus_module_4.as_(tsplus_module_4.writeNow(tsplus_module_2.flatten(leftovers)), () => tsplus_module_14.nothing());else return loop;
490
+ }))));
491
+ return tsplus_module_4.pipeTo_(tsplus_module_4.pipeTo_(upstreamMarker, tsplus_module_4.bufferChunk(leftoversRef)), loop);
492
+ }));
493
+ }
494
+ /**
495
+ * @tsplus fluent fncts.io.Sink flatMap
496
+ */
497
+
498
+
499
+ function flatMap_1(self, f, __tsplusTrace) {
500
+ return matchSink_1(self, failNow_1, f, __tsplusTrace);
501
+ }
502
+ /**
503
+ * @tsplus static fncts.io.SinkOps fromChannel
504
+ * @tsplus static fncts.io.SinkOps __call
505
+ */
506
+
507
+
508
+ function fromChannel(channel) {
509
+ return new tsplus_module_3.Sink(channel);
510
+ }
511
+ /**
512
+ * @tsplus static fncts.io.SinkOps fromPush
513
+ */
514
+
515
+
516
+ function fromPush(push, __tsplusTrace) {
517
+ return new tsplus_module_3.Sink(tsplus_module_4.unwrapScoped(() => tsplus_module_9.map_(push, fromPushPull, __tsplusTrace)));
518
+ }
519
+
520
+ function fromPushPull(push) {
521
+ return tsplus_module_4.readWith(inp => tsplus_module_4.matchChannel_(tsplus_module_4.fromIO(() => push(tsplus_module_14.just(inp))), ([r, leftovers]) => tsplus_module_15.match_(r, e => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftovers), tsplus_module_4.failNow(e)), z => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftovers), tsplus_module_5.succeedNow(z))), () => fromPushPull(push)), tsplus_module_4.failNow, () => tsplus_module_4.matchChannel_(tsplus_module_4.fromIO(() => push(tsplus_module_14.nothing())), ([r, leftovers]) => tsplus_module_15.match_(r, e => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftovers), tsplus_module_4.failNow(e)), z => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftovers), tsplus_module_5.succeedNow(z))), () => tsplus_module_4.fromIO(() => tsplus_module_9.halt(() => new Error("empty sink"), fileName_1 + ":427:37"))));
522
+ }
523
+ /**
524
+ * @tsplus static fncts.io.SinkOps fromQueue
525
+ */
526
+
527
+
528
+ function fromQueue_1(queue) {
529
+ return unwrap_1(() => tsplus_module_9.map_(tsplus_module_9.succeed(queue, fileName_1 + ":436:32"), queue => makeForeachChunk_1(inp => tsplus_module_16.offerAll_(queue, inp), fileName_1 + ":436:72"), fileName_1 + ":436:43"));
530
+ }
531
+ /**
532
+ * @tsplus static fncts.io.SinkOps fromQueueWithShutdown
533
+ */
534
+
535
+
536
+ function fromQueueWithShutdown_1(queue) {
537
+ return unwrapScoped_1(() => tsplus_module_9.map_(tsplus_module_17.acquireRelease(() => tsplus_module_9.succeed(queue, fileName_1 + ":444:15"), queue => tsplus_module_16.shutdown(queue)), queue => fromQueue_1(() => queue), fileName_1 + ":446:11"));
538
+ }
539
+ /**
540
+ * @tsplus static fncts.io.SinkOps fromHub
541
+ */
542
+
543
+
544
+ function fromHub(hub) {
545
+ return fromQueue_1(hub);
546
+ }
547
+ /**
548
+ * @tsplus static fncts.io.SinkOps fromHubWithShutdown
549
+ */
550
+
551
+
552
+ function fromHubWithShutdown(hub) {
553
+ return fromQueueWithShutdown_1(hub);
554
+ }
555
+ /**
556
+ * @tsplus static fncts.io.SinkOps fromIO
557
+ */
558
+
559
+
560
+ function fromIO_1(b) {
561
+ return new tsplus_module_3.Sink(tsplus_module_4.fromIO(b));
562
+ }
563
+ /**
564
+ * @tsplus static fncts.io.SinkOps halt
565
+ */
566
+
567
+
568
+ function halt(defect, __tsplusTrace) {
569
+ return failCause_1(() => tsplus_module_18.halt(defect()), __tsplusTrace);
570
+ }
571
+ /**
572
+ * @tsplus static fncts.io.SinkOps haltNow
573
+ */
574
+
575
+
576
+ function haltNow(defect, __tsplusTrace) {
577
+ return failCauseNow_1(tsplus_module_18.halt(defect), __tsplusTrace);
578
+ }
579
+ /**
580
+ * @tsplus static fncts.io.SinkOps head
581
+ */
582
+
583
+
584
+ function head(__tsplusTrace) {
585
+ return makeFold_1(() => tsplus_module_14.nothing(), elem => tsplus_module_19.isNothing(elem), (s, inp) => tsplus_module_20.match_(s, () => tsplus_module_14.just(inp), () => s), __tsplusTrace);
586
+ }
587
+ /**
588
+ * @tsplus getter fncts.io.Sink ignoreLeftover
589
+ */
590
+
591
+
592
+ function ignoreLeftover_1(self, __tsplusTrace) {
593
+ return new tsplus_module_3.Sink(tsplus_module_4.drain(self.channel));
594
+ }
595
+ /**
596
+ * @tsplus static fncts.io.SinkOps last
597
+ */
598
+
599
+
600
+ function last(__tsplusTrace) {
601
+ return makeFoldLeft_1(() => tsplus_module_14.nothing(), (_, inp) => tsplus_module_14.just(inp));
602
+ }
603
+ /**
604
+ * @tsplus static fncts.io.SinkOps leftover
605
+ */
606
+
607
+
608
+ function leftover(c, __tsplusTrace) {
609
+ return new tsplus_module_3.Sink(tsplus_module_4.write(c));
610
+ }
611
+ /**
612
+ * @tsplus static fncts.io.SinkOps log
613
+ */
614
+
615
+
616
+ function log(message, __tsplusTrace) {
617
+ return fromIO_1(() => tsplus_module_9.log(message, __tsplusTrace));
618
+ }
619
+ /**
620
+ * A sink that collects all of its inputs into a chunk.
74
621
  *
75
- * @tsplus static fncts.io.SinkOps foreach
622
+ * @tsplus static fncts.io.SinkOps collectAll
76
623
  */
77
624
 
78
625
 
79
- function foreach(f) {
80
- return foreachWhile_1(inp => tsplus_module_6.as_(f(inp), () => true));
626
+ function makeCollectAll() {
627
+ return new tsplus_module_3.Sink(collectLoop(tsplus_module_1.empty()));
81
628
  }
82
629
 
83
- function foreachWhileLoop(f, chunk, idx, len, cont) {
84
- if (idx === len) {
85
- return cont;
86
- }
630
+ function collectLoop(state) {
631
+ return tsplus_module_4.readWithCause(inp => collectLoop(tsplus_module_2.concat_(state, inp)), tsplus_module_5.failCauseNow, () => tsplus_module_5.endNow(state));
632
+ }
87
633
 
88
- return tsplus_module_3.catchAll_(tsplus_module_2.flatMap_(tsplus_module_3.fromIO(() => f(tsplus_module_1.unsafeGet_(chunk, idx))), b => b ? foreachWhileLoop(f, chunk, idx + 1, len, cont) : tsplus_module_3.writeNow(tsplus_module_1.drop_(chunk, idx))), e => tsplus_module_2.apSecond_(tsplus_module_3.writeNow(tsplus_module_1.drop_(chunk, idx)), tsplus_module_3.failNow(e)));
634
+ function makeCollectAllN(n) {
635
+ return flatMap_1(fromIO_1(() => tsplus_module_9.succeed(() => new tsplus_module_21.ConcBuilder(), fileName_1 + ":549:32")), builder => map_1(makeFoldUntil_1(() => builder, n, (builder, inp) => builder.append(inp), fileName_1 + ":550:19"), builder => builder.result(), fileName_1 + ":550:95"), fileName_1 + ":549:64");
89
636
  }
90
637
  /**
91
- * A sink that executes the provided effectful function for every element fed to it
92
- * until `f` evaluates to `false`.
638
+ * A sink that executes the provided effectful function for every element fed to it.
93
639
  *
94
- * @tsplus static fncts.io.SinkOps foreachWhile
640
+ * @tsplus static fncts.io.SinkOps foreach
641
+ */
642
+
643
+
644
+ function makeForeach(f, __tsplusTrace) {
645
+ return makeForeachWhile_1(inp => tsplus_module_9.as_(f(inp), () => true), __tsplusTrace);
646
+ }
647
+ /**
648
+ * @tsplus static fncts.io.SinkOps foreachChunk
649
+ */
650
+
651
+
652
+ function makeForeachChunk_1(f, __tsplusTrace) {
653
+ const process = tsplus_module_4.readWithCause(inp => tsplus_module_5.apSecond_(tsplus_module_4.fromIO(() => f(inp)), process), tsplus_module_5.failCauseNow, () => tsplus_module_4.unit);
654
+ return new tsplus_module_3.Sink(process);
655
+ }
656
+ /**
657
+ * A sink that executes the provided effectful function for every element fed to it
658
+ * until `f` evaluates to `false`.
659
+ *
660
+ * @tsplus static fncts.io.SinkOps foreachWhile
661
+ */
662
+
663
+
664
+ function makeForeachWhile_1(f, __tsplusTrace) {
665
+ const process = tsplus_module_4.readWithCause(inp => foreachWhileLoop(f, inp, 0, inp.length, process), tsplus_module_5.failCauseNow, () => tsplus_module_4.unit);
666
+ return new tsplus_module_3.Sink(process);
667
+ }
668
+
669
+ function foreachWhileLoop(f, chunk, idx, len, cont) {
670
+ if (idx === len) {
671
+ return cont;
672
+ }
673
+
674
+ return tsplus_module_4.catchAll_(tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => f(tsplus_module_2.unsafeGet_(chunk, idx))), b => b ? foreachWhileLoop(f, chunk, idx + 1, len, cont) : tsplus_module_4.writeNow(tsplus_module_2.drop_(chunk, idx))), e => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(tsplus_module_2.drop_(chunk, idx)), tsplus_module_4.failNow(e)));
675
+ }
676
+ /**
677
+ * @tsplus static fncts.io.SinkOps foreachChunkWhile
678
+ */
679
+
680
+
681
+ function makeForeachChunkWhile(f, __tsplusTrace) {
682
+ const reader = tsplus_module_4.readWith(inp => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => f(inp)), cont => cont ? reader : tsplus_module_4.unit), tsplus_module_4.failNow, () => tsplus_module_4.unit);
683
+ return new tsplus_module_3.Sink(reader);
684
+ }
685
+ /**
686
+ * @tsplus static fncts.io.SinkOps fold
687
+ */
688
+
689
+
690
+ function makeFold_1(z, contFn, f, __tsplusTrace) {
691
+ return defer_1(() => new tsplus_module_3.Sink(foldReader(z(), contFn, f)));
692
+ }
693
+ /**
694
+ * @tsplus tailRec
695
+ */
696
+
697
+
698
+ function foldChunkSplit(contFn, f, s, chunk, idx, len) {
699
+ var contFn_1 = contFn,
700
+ f_1 = f,
701
+ s_1 = s,
702
+ chunk_1 = chunk,
703
+ idx_1 = idx,
704
+ len_1 = len;
705
+ var contFn_2 = contFn,
706
+ f_2 = f,
707
+ s_2 = s,
708
+ chunk_2 = chunk,
709
+ idx_2 = idx,
710
+ len_2 = len;
711
+
712
+ while (1) {
713
+ if (idx_1 === len_1) {
714
+ return [s_1, tsplus_module_1.empty()];
715
+ } else {
716
+ const s1 = f_1(s_1, tsplus_module_2.unsafeGet_(chunk_1, idx_1));
717
+
718
+ if (contFn_1(s1)) {
719
+ contFn_2 = contFn_1;
720
+ f_2 = f_1;
721
+ s_2 = s1;
722
+ chunk_2 = chunk_1;
723
+ idx_2 = idx_1 + 1;
724
+ len_2 = len_1;
725
+ contFn_1 = contFn_2;
726
+ f_1 = f_2;
727
+ s_1 = s_2;
728
+ chunk_1 = chunk_2;
729
+ idx_1 = idx_2;
730
+ len_1 = len_2;
731
+ continue;
732
+ } else {
733
+ return [s1, tsplus_module_2.drop_(chunk_1, idx_1 + 1)];
734
+ }
735
+ }
736
+ }
737
+ }
738
+
739
+ function foldReader(s, contFn, f) {
740
+ if (!contFn(s)) {
741
+ return tsplus_module_5.succeedNow(s);
742
+ } else {
743
+ return tsplus_module_4.readWith(inp => {
744
+ const [nextS, leftovers] = foldChunkSplit(contFn, f, s, inp, 0, inp.length);
745
+
746
+ if (tsplus_module_2.isNonEmpty(leftovers)) {
747
+ return tsplus_module_4.as_(tsplus_module_4.writeNow(leftovers), () => nextS);
748
+ } else {
749
+ return foldReader(nextS, contFn, f);
750
+ }
751
+ }, _ => tsplus_module_4.failNow(_), _ => tsplus_module_5.succeedNow(_));
752
+ }
753
+ }
754
+ /**
755
+ * @tsplus static fncts.io.SinkOps foldUntil
756
+ */
757
+
758
+
759
+ function makeFoldUntil_1(z, max, f, __tsplusTrace) {
760
+ return unwrap_1(() => tsplus_module_9.map_(tsplus_module_9.succeed(max, __tsplusTrace), max => map_1(makeFold_1(() => [z(), 0], ([_, n]) => n < max, ([o, count], i) => [f(o, i), count + 1], __tsplusTrace), ([s]) => s, __tsplusTrace), __tsplusTrace));
761
+ }
762
+ /**
763
+ * @tsplus static fncts.io.SinkOps foldChunks
764
+ */
765
+
766
+
767
+ function makeFoldChunks_1(z, contFn, f) {
768
+ return defer_1(() => new tsplus_module_3.Sink(foldChunksReader(z(), contFn, f)));
769
+ }
770
+
771
+ function foldChunksReader(s, contFn, f) {
772
+ if (!contFn(s)) {
773
+ return tsplus_module_5.succeedNow(s);
774
+ } else {
775
+ return tsplus_module_4.readWith(inp => {
776
+ const nextS = f(s, inp);
777
+ return foldChunksReader(nextS, contFn, f);
778
+ }, err => tsplus_module_4.failNow(err), _ => tsplus_module_5.succeedNow(_));
779
+ }
780
+ }
781
+ /**
782
+ * @tsplus static fncts.io.SinkOps foldChunksIO
783
+ */
784
+
785
+
786
+ function makeFoldChunksIO_1(z, contFn, f) {
787
+ return defer_1(() => new tsplus_module_3.Sink(foldChunksIOReader(z(), contFn, f)));
788
+ }
789
+
790
+ function foldChunksIOReader(s, contFn, f) {
791
+ if (!contFn(s)) {
792
+ return tsplus_module_5.succeedNow(s);
793
+ } else {
794
+ return tsplus_module_4.readWith(inp => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => f(s, inp)), s => foldChunksIOReader(s, contFn, f)), err => tsplus_module_4.failNow(err), _ => tsplus_module_5.succeedNow(_));
795
+ }
796
+ }
797
+ /**
798
+ * @tsplus static fncts.io.SinkOps foldLeft
799
+ */
800
+
801
+
802
+ function makeFoldLeft_1(z, f) {
803
+ return ignoreLeftover_1(makeFold_1(z, () => true, f, fileName_1 + ":772:19"), fileName_1 + ":772:37");
804
+ }
805
+ /**
806
+ * @tsplus static fncts.io.SinkOps foldLeftChunks
807
+ */
808
+
809
+
810
+ function makeFoldLeftChunks(z, f) {
811
+ return ignoreLeftover_1(makeFoldChunks_1(z, () => true, f), fileName_1 + ":782:43");
812
+ }
813
+ /**
814
+ * @tsplus static fncts.io.SinkOps foldLeftChunksIO
815
+ */
816
+
817
+
818
+ function makeFoldLeftChunksIO(z, f) {
819
+ return makeFoldChunksIO_1(z, () => true, f);
820
+ }
821
+ /**
822
+ * @tsplus static fncts.io.SinkOps foldLeftIO
823
+ */
824
+
825
+
826
+ function makeFoldLeftIO(z, f) {
827
+ return makeFoldIO_1(z, () => true, f);
828
+ }
829
+ /**
830
+ * @tsplus static fncts.io.SinkOps foldIO
831
+ */
832
+
833
+
834
+ function makeFoldIO_1(z, contFn, f) {
835
+ return defer_1(() => new tsplus_module_3.Sink(foldIOReader(z(), contFn, f)));
836
+ }
837
+
838
+ function foldChunkSplitIO(s, contFn, f, chunk, idx, len) {
839
+ if (idx === len) {
840
+ return tsplus_module_9.succeedNow([s, tsplus_module_14.nothing()], fileName_1 + ":822:25");
841
+ } else {
842
+ return tsplus_module_9.flatMap_(f(s, tsplus_module_2.unsafeGet_(chunk, idx)), s1 => {
843
+ if (contFn(s1)) {
844
+ return foldChunkSplitIO(s1, contFn, f, chunk, idx + 1, len);
845
+ } else {
846
+ return tsplus_module_9.succeedNow([s1, tsplus_module_14.just(tsplus_module_2.drop_(chunk, idx + 1))], fileName_1 + ":828:29");
847
+ }
848
+ }, fileName_1 + ":824:36");
849
+ }
850
+ }
851
+
852
+ function foldIOReader(s, contFn, f) {
853
+ if (!contFn(s)) {
854
+ return tsplus_module_5.succeedNow(s);
855
+ } else {
856
+ return tsplus_module_4.readWith(inp => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => foldChunkSplitIO(s, contFn, f, inp, 0, inp.length)), ([nextS, leftovers]) => tsplus_module_20.match_(leftovers, () => foldIOReader(nextS, contFn, f), l => tsplus_module_4.as_(tsplus_module_4.writeNow(l), () => nextS))), err => tsplus_module_4.failNow(err), _ => tsplus_module_5.succeedNow(_));
857
+ }
858
+ }
859
+ /**
860
+ * @tsplus static fncts.io.SinkOps foldUntilIO
861
+ */
862
+
863
+
864
+ function makeFoldUntilIO(z, max, f) {
865
+ return map_1(makeFoldIO_1(() => [z(), 0], ([_, n]) => n < max(), ([o, count], i) => tsplus_module_9.map_(f(o, i), s => [s, count + 1], fileName_1 + ":867:35")), ([s]) => s, fileName_1 + ":868:8");
866
+ }
867
+ /**
868
+ * @tsplus static fncts.io.SinkOps foldWeightedDecompose
869
+ */
870
+
871
+
872
+ function makeFoldWeightedDecompose_1(z, costFn, max, decompose, f) {
873
+ return defer_1(() => {
874
+ /**
875
+ * @tsplus tailRec
876
+ */
877
+ function fold(inp, s, max, dirty, cost, idx) {
878
+ if (idx === inp.length) {
879
+ return [s, cost, dirty, tsplus_module_1.empty()];
880
+ } else {
881
+ const elem = tsplus_module_2.unsafeGet_(inp, idx);
882
+ const total = cost + costFn(s, elem);
883
+
884
+ if (total <= max) {
885
+ return fold(inp, f(s, elem), max, true, total, idx + 1);
886
+ } else {
887
+ const decomposed = decompose(elem);
888
+
889
+ if (decomposed.length <= 1 && !dirty) {
890
+ return [f(s, elem), total, true, tsplus_module_2.drop_(inp, idx + 1)];
891
+ } else if (decomposed.length <= 1 && dirty) {
892
+ return [s, cost, dirty, tsplus_module_2.drop_(inp, idx)];
893
+ } else {
894
+ return fold(tsplus_module_2.concat_(decomposed, tsplus_module_2.drop_(inp, idx + 1)), s, max, dirty, cost, 0);
895
+ }
896
+ }
897
+ }
898
+ }
899
+
900
+ function go(s, cost, dirty, max) {
901
+ return tsplus_module_4.readWith(inp => {
902
+ const [nextS, nextCost, nextDirty, leftovers] = fold(inp, s, max, dirty, cost, 0);
903
+
904
+ if (tsplus_module_2.isNonEmpty(leftovers)) {
905
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftovers), tsplus_module_5.succeedNow(nextS));
906
+ } else if (cost > max) {
907
+ return tsplus_module_5.succeedNow(nextS);
908
+ } else {
909
+ return go(nextS, nextCost, nextDirty, max);
910
+ }
911
+ }, err => tsplus_module_4.failNow(err), _ => tsplus_module_5.succeedNow(s));
912
+ }
913
+
914
+ return new tsplus_module_3.Sink(go(z(), 0, false, max()));
915
+ });
916
+ }
917
+ /**
918
+ * @tsplus static fncts.io.SinkOps foldWeightedDecomposeIO
919
+ */
920
+
921
+
922
+ function makeFoldWeightedDecomposeIO_1(z, costFn, max, decompose, f) {
923
+ return defer_1(() => {
924
+ function fold(inp, s, max, dirty, cost, idx) {
925
+ if (idx === inp.length) {
926
+ return tsplus_module_9.succeedNow([s, cost, dirty, tsplus_module_1.empty()], fileName_1 + ":961:29");
927
+ } else {
928
+ const elem = tsplus_module_2.unsafeGet_(inp, idx);
929
+ return tsplus_module_9.flatMap_(tsplus_module_9.map_(costFn(s, elem), _ => cost + _, fileName_1 + ":965:15"), total => {
930
+ if (total <= max) {
931
+ return tsplus_module_9.flatMap_(f(s, elem), s => fold(inp, s, max, true, total, idx + 1), fileName_1 + ":968:40");
932
+ } else {
933
+ return tsplus_module_9.flatMap_(decompose(elem), decomposed => {
934
+ if (decomposed.length <= 1 && !dirty) {
935
+ return tsplus_module_9.map_(f(s, elem), s => [s, total, true, tsplus_module_2.drop_(inp, idx + 1)], fileName_1 + ":972:40");
936
+ } else if (decomposed.length <= 1 && dirty) {
937
+ return tsplus_module_9.succeedNow([s, cost, dirty, tsplus_module_2.drop_(inp, idx)], fileName_1 + ":974:39");
938
+ } else {
939
+ return fold(tsplus_module_2.concat_(decomposed, tsplus_module_2.drop_(inp, idx + 1)), s, max, dirty, cost, 0);
940
+ }
941
+ }, fileName_1 + ":970:45");
942
+ }
943
+ }, fileName_1 + ":966:19");
944
+ }
945
+ }
946
+
947
+ function go(s, cost, dirty, max) {
948
+ return tsplus_module_4.readWith(inp => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => fold(inp, s, max, dirty, cost, 0)), ([nextS, nextCost, nextDirty, leftovers]) => {
949
+ if (tsplus_module_2.isNonEmpty(leftovers)) {
950
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftovers), tsplus_module_5.succeedNow(nextS));
951
+ } else if (cost > max) {
952
+ return tsplus_module_5.succeedNow(nextS);
953
+ } else {
954
+ return go(nextS, nextCost, nextDirty, max);
955
+ }
956
+ }), err => tsplus_module_4.failNow(err), _ => tsplus_module_5.succeedNow(s));
957
+ }
958
+
959
+ return new tsplus_module_3.Sink(go(z(), 0, false, max()));
960
+ });
961
+ }
962
+ /**
963
+ * @tsplus static fncts.io.SinkOps foldWeighted
964
+ */
965
+
966
+
967
+ function makeFoldWeighted(z, costFn, max, f) {
968
+ return makeFoldWeightedDecompose_1(z, costFn, max, tsplus_module_22.single, f);
969
+ }
970
+ /**
971
+ * @tsplus static fncts.io.SinkOps foldWeightedIO
972
+ */
973
+
974
+
975
+ function makeFoldWeightedIO(z, costFn, max, f) {
976
+ return makeFoldWeightedDecomposeIO_1(z, costFn, max, inp => tsplus_module_9.succeedNow(tsplus_module_22.single(inp), fileName_1 + ":1030:77"), f);
977
+ }
978
+ /**
979
+ * Transforms this sink's result.
980
+ *
981
+ * @tsplus fluent fncts.io.Sink map
982
+ */
983
+
984
+
985
+ function map_1(self, f, __tsplusTrace) {
986
+ return new tsplus_module_3.Sink(tsplus_module_5.map_(self.channel, f));
987
+ }
988
+ /**
989
+ * Transforms the errors emitted by this sink using `f`.
990
+ *
991
+ * @tsplus fluent fncts.io.Sink mapError
992
+ */
993
+
994
+
995
+ function mapError_(self, f, __tsplusTrace) {
996
+ return new tsplus_module_3.Sink(tsplus_module_4.mapError_(self.channel, f));
997
+ }
998
+ /**
999
+ * Effectfully transforms this sink's result.
1000
+ *
1001
+ * @tsplus fluent fncts.io.Sink mapIO
1002
+ */
1003
+
1004
+
1005
+ function mapIO_1(self, f, __tsplusTrace) {
1006
+ return new tsplus_module_3.Sink(tsplus_module_4.mapIO_(self.channel, f));
1007
+ }
1008
+ /**
1009
+ * Runs this sink until it yields a result, then uses that result to create
1010
+ * another sink from the provided function which will continue to run until it
1011
+ * yields a result.
1012
+ *
1013
+ * This function essentially runs sinks in sequence.
1014
+ *
1015
+ * @tsplus fluent fncts.io.Sink matchSink
1016
+ */
1017
+
1018
+
1019
+ function matchSink_1(self, onFailure, onSuccess, __tsplusTrace) {
1020
+ return new tsplus_module_3.Sink(tsplus_module_4.matchChannel_(tsplus_module_4.doneCollect(self.channel), e => onFailure(e).channel, ([leftovers, z]) => tsplus_module_4.defer(() => {
1021
+ const leftoversRef = new _AtomicReference.AtomicReference(tsplus_module_2.filter_(leftovers, c => tsplus_module_2.isNonEmpty(c)));
1022
+ const refReader = tsplus_module_5.flatMap_(tsplus_module_5.succeed(() => leftoversRef.getAndSet(tsplus_module_1.empty())), chunk => tsplus_module_4.writeChunk(chunk));
1023
+ const passthrough = tsplus_module_4.id();
1024
+ const continuationSink = tsplus_module_4.pipeTo_(tsplus_module_5.apSecond_(refReader, passthrough), onSuccess(z).channel);
1025
+ return tsplus_module_5.flatMap_(tsplus_module_4.doneCollect(continuationSink), ([newLeftovers, z1]) => tsplus_module_5.apSecond_(tsplus_module_5.flatMap_(tsplus_module_5.succeed(() => leftoversRef.get), tsplus_module_4.writeChunk), tsplus_module_4.as_(tsplus_module_4.writeChunk(newLeftovers), () => z1)));
1026
+ })));
1027
+ }
1028
+ /**
1029
+ * @tsplus fluent fncts.io.Sink orElse
1030
+ */
1031
+
1032
+
1033
+ function orElse(self, that, __tsplusTrace) {
1034
+ return defer_1(() => new tsplus_module_3.Sink(tsplus_module_4.orElse_(self.channel, that().channel)));
1035
+ }
1036
+ /**
1037
+ * @tsplus fluent fncts.io.Sink provideEnvironment
1038
+ */
1039
+
1040
+
1041
+ function provideEnvironment(self, r, __tsplusTrace) {
1042
+ return new tsplus_module_3.Sink(tsplus_module_4.provideEnvironment_(self.channel, r));
1043
+ }
1044
+ /**
1045
+ * @tsplus fluent fncts.io.Sink race
1046
+ */
1047
+
1048
+
1049
+ function race(self, that) {
1050
+ return map_1(raceBoth_1(self, that), result => tsplus_module_23.merge(result), fileName_1 + ":1136:33");
1051
+ }
1052
+ /**
1053
+ * @tsplus fluent fncts.io.Sink raceBoth
1054
+ */
1055
+
1056
+
1057
+ function raceBoth_1(self, that, capacity = () => 16) {
1058
+ return raceWith_1(self, that, selfDone => tsplus_module_25.done(tsplus_module_9.map_(tsplus_module_9.fromExitNow(selfDone, fileName_1 + ":1149:52"), tsplus_module_24.left, fileName_1 + ":1149:66")), thatDone => tsplus_module_25.done(tsplus_module_9.map_(tsplus_module_9.fromExitNow(thatDone, fileName_1 + ":1150:52"), tsplus_module_24.right, fileName_1 + ":1150:66")), capacity, fileName_1 + ":1147:23");
1059
+ }
1060
+ /**
1061
+ * @tsplus fluent fncts.io.Sink raceWith
1062
+ */
1063
+
1064
+
1065
+ function raceWith_1(self, that, leftDone, rightDone, capacity = () => 16, __tsplusTrace) {
1066
+ const scoped = tsplus_module_9.defer(() => {
1067
+ const that0 = that();
1068
+ const capacity0 = capacity();
1069
+ return tsplus_module_9.flatMap_(tsplus_module_27.makeBounded(capacity()), hub => tsplus_module_9.flatMap_(tsplus_module_4.fromHubScoped(() => hub), c1 => tsplus_module_9.map_(tsplus_module_4.fromHubScoped(() => hub), c2 => {
1070
+ const reader = tsplus_module_4.toHub(() => hub);
1071
+ const writer = tsplus_module_26.mergeWith_(tsplus_module_4.pipeTo_(c1, self.channel), tsplus_module_4.pipeTo_(c2, that0.channel), leftDone, rightDone);
1072
+ const channel = tsplus_module_26.mergeWith_(reader, writer, () => tsplus_module_25.wait(tsplus_module_9.fromExitNow), done => tsplus_module_25.done(tsplus_module_9.fromExitNow(done, __tsplusTrace)));
1073
+ return new tsplus_module_3.Sink(channel);
1074
+ }, __tsplusTrace), __tsplusTrace), __tsplusTrace);
1075
+ }, __tsplusTrace);
1076
+ return unwrapScoped_1(() => scoped);
1077
+ }
1078
+ /**
1079
+ * @tsplus static fncts.io.SinkOps service
1080
+ */
1081
+
1082
+
1083
+ function service(
1084
+ /** @tsplus auto */
1085
+ tag) {
1086
+ const tag_1 = tag;
1087
+ return serviceWith_1(tsplus_module_12.identity, tag_1);
1088
+ }
1089
+ /**
1090
+ * @tsplus static fncts.io.SinkOps serviceWith
1091
+ */
1092
+
1093
+
1094
+ function serviceWith_1(f,
1095
+ /** @tsplus auto */
1096
+ tag) {
1097
+ return fromIO_1(() => tsplus_module_11.serviceWith(f, tag));
1098
+ }
1099
+ /**
1100
+ * @tsplus static fncts.io.SinkOps serviceWithIO
1101
+ */
1102
+
1103
+
1104
+ function serviceWithIO(f,
1105
+ /** @tsplus auto */
1106
+ tag) {
1107
+ return fromIO_1(() => tsplus_module_11.serviceWithIO(f, tag, fileName_1 + ":1210:38"));
1108
+ }
1109
+ /**
1110
+ * @tsplus static fncts.io.SinkOps serviceWithSink
1111
+ */
1112
+
1113
+
1114
+ function serviceWithSink(f,
1115
+ /** @tsplus auto */
1116
+ tag) {
1117
+ return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_11.serviceWith(tsplus_module_12.compose_(f, s => s.channel), tag)));
1118
+ }
1119
+ /**
1120
+ * @tsplus fluent fncts.io.Sink splitWhere
1121
+ */
1122
+
1123
+
1124
+ function splitWhere(self, p) {
1125
+ return new tsplus_module_3.Sink(tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => tsplus_module_8.make(() => tsplus_module_1.empty())), ref => tsplus_module_5.flatMap_(tsplus_module_4.collectElements(tsplus_module_4.pipeToOrFail_(splitter(p, false, ref), self.channel)), ([leftovers, z]) => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => tsplus_module_7.get(ref)), leftover => tsplus_module_5.apSecond_(tsplus_module_4.writeNow(tsplus_module_2.concat_(leftover, tsplus_module_2.flatten(leftovers))), tsplus_module_5.succeedNow(z))))));
1126
+ }
1127
+
1128
+ function splitter(p, written, leftovers) {
1129
+ return tsplus_module_4.readWithCause(inp => {
1130
+ if (tsplus_module_2.isEmpty(inp)) {
1131
+ return splitter(p, written, leftovers);
1132
+ } else if (written) {
1133
+ const index = tsplus_module_28.findIndex(inp, p);
1134
+
1135
+ if (index === -1) {
1136
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(inp), splitter(p, true, leftovers));
1137
+ } else {
1138
+ const [left, right] = tsplus_module_2.splitAt_(inp, index);
1139
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(left), tsplus_module_4.fromIO(() => tsplus_module_6.set_(leftovers, right)));
1140
+ }
1141
+ } else {
1142
+ const index = tsplus_module_28.findIndex(inp, p);
1143
+
1144
+ if (index === -1) {
1145
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(inp), splitter(p, true, leftovers));
1146
+ } else {
1147
+ const [left, right] = tsplus_module_2.splitAt_(inp, Math.max(index, 1));
1148
+ return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(left), tsplus_module_4.fromIO(() => tsplus_module_6.set_(leftovers, right)));
1149
+ }
1150
+ }
1151
+ }, tsplus_module_5.failCauseNow, tsplus_module_5.succeedNow);
1152
+ }
1153
+ /**
1154
+ * @tsplus static fncts.io.SinkOps succeed
1155
+ */
1156
+
1157
+
1158
+ function succeed(z, __tsplusTrace) {
1159
+ return new tsplus_module_3.Sink(tsplus_module_5.succeed(z));
1160
+ }
1161
+ /**
1162
+ * @tsplus static fncts.io.SinkOps succeedNow
1163
+ */
1164
+
1165
+
1166
+ function succeedNow(z, __tsplusTrace) {
1167
+ return new tsplus_module_3.Sink(tsplus_module_5.succeedNow(z));
1168
+ }
1169
+ /**
1170
+ * @tsplus fluent fncts.io.Sink summarized
1171
+ */
1172
+
1173
+
1174
+ function summarized_1(self, summary, f, __tsplusTrace) {
1175
+ return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_9.map_(tsplus_module_9.succeed(summary, __tsplusTrace), summary => tsplus_module_5.flatMap_(tsplus_module_4.fromIO(() => summary), start => tsplus_module_5.flatMap_(self.channel, done => tsplus_module_5.map_(tsplus_module_4.fromIO(() => summary), end => [done, f(start, end)]))), __tsplusTrace)));
1176
+ }
1177
+ /**
1178
+ * @tsplus getter fncts.io.Sink timed
1179
+ */
1180
+
1181
+
1182
+ function timed(self, __tsplusTrace) {
1183
+ return summarized_1(self, () => tsplus_module_29.currentTime, (start, end) => tsplus_module_30.fromInterval(start, end), __tsplusTrace);
1184
+ }
1185
+ /**
1186
+ * @tsplus static fncts.io.SinkOps unwrap
1187
+ */
1188
+
1189
+
1190
+ function unwrap_1(io) {
1191
+ return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_9.map_(io(), sink => sink.channel, fileName_1 + ":1332:42")));
1192
+ }
1193
+ /**
1194
+ * Creates a sink produced from a scoped effect.
1195
+ *
1196
+ * @tsplus static fncts.io.SinkOps unwrapScoped
1197
+ */
1198
+
1199
+
1200
+ function unwrapScoped_1(scoped) {
1201
+ return new tsplus_module_3.Sink(tsplus_module_4.unwrapScoped(() => tsplus_module_9.map_(scoped(), sink => sink.channel, fileName_1 + ":1343:52")));
1202
+ }
1203
+ /**
1204
+ * @tsplus fluent fncts.io.Sink zip
1205
+ */
1206
+
1207
+
1208
+ function zip(self, that) {
1209
+ return zipWith_1(() => self, that, tsplus_module_12.tuple);
1210
+ }
1211
+ /**
1212
+ * @tsplus fluent fncts.io.Sink zipC
1213
+ */
1214
+
1215
+
1216
+ function zipC(self, that) {
1217
+ return zipWithC_1(() => self, that, tsplus_module_12.tuple);
1218
+ }
1219
+ /**
1220
+ * Feeds inputs to this sink until it yields a result, then switches over to
1221
+ * the provided sink until it yields a result, finally combining the two
1222
+ * results with `f`.
1223
+ *
1224
+ * @tsplus fluent fncts.io.Sink zipWith
1225
+ */
1226
+
1227
+
1228
+ function zipWith_1(self, that, f) {
1229
+ return defer_1(() => flatMap_1(self(), z => map_1(that(), z1 => f(z, z1), fileName_1 + ":1378:53"), fileName_1 + ":1378:35"));
1230
+ }
1231
+ /**
1232
+ * Runs both sinks in parallel on the input and combines the results using the
1233
+ * provided function.
1234
+ *
1235
+ * @tsplus fluent fncts.io.Sink zipWithC
95
1236
  */
96
1237
 
97
1238
 
98
- function foreachWhile_1(f) {
99
- const process = tsplus_module_3.readWithCause(inp => foreachWhileLoop(f, inp, 0, inp.length, process), tsplus_module_2.failCauseNow, () => tsplus_module_3.unit);
100
- return new tsplus_module_4.Sink(process);
1239
+ function zipWithC_1(self, that, f) {
1240
+ return defer_1(() => raceWith_1(self(), () => that(), exit => tsplus_module_31.match_(exit, err => tsplus_module_25.done(tsplus_module_9.failCauseNow(err, fileName_1 + ":1397:54")), lz => tsplus_module_25.wait(exit => tsplus_module_31.match_(exit, cause => tsplus_module_9.failCauseNow(cause, fileName_1 + ":1401:43"), rz => tsplus_module_9.succeedNow(f(lz, rz), fileName_1 + ":1402:38")))), exit => tsplus_module_31.match_(exit, err => tsplus_module_25.done(tsplus_module_9.failCauseNow(err, fileName_1 + ":1408:54")), rz => tsplus_module_25.wait(exit => tsplus_module_31.match_(exit, cause => tsplus_module_9.failCauseNow(cause, fileName_1 + ":1412:43"), lz => tsplus_module_9.succeedNow(f(lz, rz), fileName_1 + ":1413:38"))))));
101
1241
  }
102
1242
  //# sourceMappingURL=api.cjs.map