@fncts/io 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Sink/api.d.ts +217 -36
- package/_cjs/Sink/api.cjs +424 -131
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +1 -1
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +38 -0
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -0
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +38 -0
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -0
- package/_mjs/Sink/api.mjs +414 -129
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +1 -1
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/dropUntilIO.mjs +26 -0
- package/_mjs/collection/immutable/Conc/dropUntilIO.mjs.map +1 -0
- package/_mjs/collection/immutable/Conc/dropWhileIO.mjs +26 -0
- package/_mjs/collection/immutable/Conc/dropWhileIO.mjs.map +1 -0
- package/_src/Sink/api.ts +369 -11
- package/_src/collection/immutable/Conc/dropUntilIO.ts +24 -0
- package/_src/collection/immutable/Conc/dropWhileIO.ts +26 -0
- package/collection/immutable/Conc/dropUntilIO.d.ts +7 -0
- package/collection/immutable/Conc/dropWhileIO.d.ts +7 -0
- package/package.json +3 -3
package/_cjs/Sink/api.cjs
CHANGED
@@ -17,7 +17,7 @@ exports.dimapChunks = dimapChunks;
|
|
17
17
|
exports.dimapChunksIO = dimapChunksIO;
|
18
18
|
exports.dimapIO = dimapIO;
|
19
19
|
exports.drain = void 0;
|
20
|
-
exports.
|
20
|
+
exports.dropWhileIO = dropWhileIO;
|
21
21
|
exports.environment = environment;
|
22
22
|
exports.environmentWith = environmentWith;
|
23
23
|
exports.environmentWithIO = environmentWithIO;
|
@@ -43,6 +43,9 @@ exports.leftover = leftover;
|
|
43
43
|
exports.log = log;
|
44
44
|
exports.makeCollectAll = makeCollectAll;
|
45
45
|
exports.makeCollectAllN = makeCollectAllN;
|
46
|
+
exports.makeDropUntil = makeDropUntil;
|
47
|
+
exports.makeDropUntilIO = makeDropUntilIO;
|
48
|
+
exports.makeDropWhile = makeDropWhile;
|
46
49
|
exports.makeFoldLeft = exports.makeFoldIO = exports.makeFoldChunksIO = exports.makeFoldChunks = exports.makeFold = void 0;
|
47
50
|
exports.makeFoldLeftChunks = makeFoldLeftChunks;
|
48
51
|
exports.makeFoldLeftChunksIO = makeFoldLeftChunksIO;
|
@@ -96,47 +99,51 @@ var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require
|
|
96
99
|
|
97
100
|
var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/collection/immutable/Conc/mapIO"));
|
98
101
|
|
99
|
-
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/
|
102
|
+
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/collection/immutable/Conc/dropUntilIO"));
|
100
103
|
|
101
|
-
var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
104
|
+
var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/collection/immutable/Conc/dropWhileIO"));
|
102
105
|
|
103
|
-
var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/
|
106
|
+
var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/environment"));
|
104
107
|
|
105
|
-
var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
108
|
+
var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/function/api"));
|
106
109
|
|
107
|
-
var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
110
|
+
var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/collection/immutable/Conc/filterIO"));
|
108
111
|
|
109
|
-
var tsplus_module_16 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
112
|
+
var tsplus_module_16 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
|
110
113
|
|
111
|
-
var tsplus_module_17 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
114
|
+
var tsplus_module_17 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Either/destructors"));
|
112
115
|
|
113
|
-
var tsplus_module_18 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
116
|
+
var tsplus_module_18 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Queue/api/operations"));
|
114
117
|
|
115
|
-
var tsplus_module_19 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
118
|
+
var tsplus_module_19 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/acquireRelease"));
|
116
119
|
|
117
|
-
var tsplus_module_20 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
120
|
+
var tsplus_module_20 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Cause/api"));
|
118
121
|
|
119
|
-
var tsplus_module_21 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
122
|
+
var tsplus_module_21 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/definition"));
|
120
123
|
|
121
|
-
var tsplus_module_22 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
124
|
+
var tsplus_module_22 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/destructors"));
|
122
125
|
|
123
|
-
var tsplus_module_23 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
126
|
+
var tsplus_module_23 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc"));
|
124
127
|
|
125
|
-
var tsplus_module_24 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
128
|
+
var tsplus_module_24 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/constructors"));
|
126
129
|
|
127
|
-
var tsplus_module_25 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
130
|
+
var tsplus_module_25 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Either/api"));
|
128
131
|
|
129
|
-
var tsplus_module_26 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
132
|
+
var tsplus_module_26 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Either/constructors"));
|
130
133
|
|
131
|
-
var tsplus_module_27 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/
|
134
|
+
var tsplus_module_27 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/internal/MergeDecision"));
|
132
135
|
|
133
|
-
var tsplus_module_28 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
136
|
+
var tsplus_module_28 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Channel/api/mergeWith"));
|
134
137
|
|
135
|
-
var tsplus_module_29 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/
|
138
|
+
var tsplus_module_29 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Hub/api"));
|
136
139
|
|
137
|
-
var tsplus_module_30 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
140
|
+
var tsplus_module_30 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/Iterable/api"));
|
138
141
|
|
139
|
-
var tsplus_module_31 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
142
|
+
var tsplus_module_31 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Clock/api"));
|
143
|
+
|
144
|
+
var tsplus_module_32 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Duration/api"));
|
145
|
+
|
146
|
+
var tsplus_module_33 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Exit/api"));
|
140
147
|
|
141
148
|
var _AtomicReference = /*#__PURE__*/require("@fncts/base/internal/AtomicReference");
|
142
149
|
|
@@ -217,44 +224,56 @@ const zipWithC = zipWithC_1;
|
|
217
224
|
exports.zipWithC = zipWithC;
|
218
225
|
|
219
226
|
/**
|
227
|
+
* Like {@link zip}, but keeps only the result from this sink
|
228
|
+
*
|
220
229
|
* @tsplus fluent fncts.io.Sink apFirst
|
221
230
|
*/
|
222
231
|
function apFirst(self, that) {
|
223
|
-
return zipWith_1(() => self, that, (z, _) => z);
|
232
|
+
return zipWith_1(() => self, that, (z, _) => z, fileName_1 + ":14:22");
|
224
233
|
}
|
225
234
|
/**
|
235
|
+
* Like {@link zipC}, but keeps only the result from this sink
|
236
|
+
*
|
226
237
|
* @tsplus fluent fncts.io.Sink apFirstC
|
227
238
|
*/
|
228
239
|
|
229
240
|
|
230
241
|
function apFirstC(self, that) {
|
231
|
-
return zipWithC_1(() => self, that, (z, _) => z);
|
242
|
+
return zipWithC_1(() => self, that, (z, _) => z, fileName_1 + ":26:23");
|
232
243
|
}
|
233
244
|
/**
|
245
|
+
* Like {@link zip}, but keeps only the result from the `that` sink
|
246
|
+
*
|
234
247
|
* @tsplus fluent fncts.io.Sink apSecond
|
235
248
|
*/
|
236
249
|
|
237
250
|
|
238
|
-
function apSecond(self, that) {
|
239
|
-
return zipWith_1(() => self, that, (_, z1) => z1);
|
251
|
+
function apSecond(self, that, __tsplusTrace) {
|
252
|
+
return zipWith_1(() => self, that, (_, z1) => z1, __tsplusTrace);
|
240
253
|
}
|
241
254
|
/**
|
255
|
+
* Like {@link zipC}, but keeps only the result from the `that` sink
|
256
|
+
*
|
242
257
|
* @tsplus fluent fncts.io.Sink apSecondC
|
243
258
|
*/
|
244
259
|
|
245
260
|
|
246
|
-
function apSecondC(self, that) {
|
247
|
-
return zipWithC_1(() => self, that, (_, z1) => z1);
|
261
|
+
function apSecondC(self, that, __tsplusTrace) {
|
262
|
+
return zipWithC_1(() => self, that, (_, z1) => z1, __tsplusTrace);
|
248
263
|
}
|
249
264
|
/**
|
265
|
+
* Replaces this sink's result with the provided value.
|
266
|
+
*
|
250
267
|
* @tsplus fluent fncts.io.Sink as
|
251
268
|
*/
|
252
269
|
|
253
270
|
|
254
|
-
function as(self, z) {
|
255
|
-
return map_1(self, () => z(),
|
271
|
+
function as(self, z, __tsplusTrace) {
|
272
|
+
return map_1(self, () => z(), __tsplusTrace);
|
256
273
|
}
|
257
274
|
/**
|
275
|
+
* Repeatedly runs the sink and accumulates its results into a chunk
|
276
|
+
*
|
258
277
|
* @tsplus fluent fncts.io.Sink collectAll
|
259
278
|
*/
|
260
279
|
|
@@ -263,6 +282,10 @@ function collectAll(self, __tsplusTrace) {
|
|
263
282
|
return collectAllWhileWith_1(self, () => tsplus_module_1.empty(), () => true, (s, z) => tsplus_module_2.append_(s, z), __tsplusTrace);
|
264
283
|
}
|
265
284
|
/**
|
285
|
+
* Repeatedly runs the sink for as long as its results satisfy the predicate
|
286
|
+
* `p`. The sink's results will be accumulated using the stepping function
|
287
|
+
* `f`.
|
288
|
+
*
|
266
289
|
* @tsplus fluent fncts.io.Sink collectAllWhileWith
|
267
290
|
*/
|
268
291
|
|
@@ -288,6 +311,9 @@ function collectAllWhileWith_1(self, z, p, f, __tsplusTrace) {
|
|
288
311
|
}));
|
289
312
|
}
|
290
313
|
/**
|
314
|
+
* Collects the leftovers from the stream when the sink succeeds and returns
|
315
|
+
* them as part of the sink's result
|
316
|
+
*
|
291
317
|
* @tsplus getter fncts.io.Sink collectLeftover
|
292
318
|
*/
|
293
319
|
|
@@ -296,77 +322,101 @@ function collectLeftover(self, __tsplusTrace) {
|
|
296
322
|
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
323
|
}
|
298
324
|
/**
|
325
|
+
* Transforms this sink's input elements.
|
326
|
+
*
|
299
327
|
* @tsplus fluent fncts.io.Sink contramap
|
300
328
|
*/
|
301
329
|
|
302
330
|
|
303
|
-
function contramap_1(self, f) {
|
304
|
-
return contramapChunks_1(self, chunk => tsplus_module_2.map_(chunk, f));
|
331
|
+
function contramap_1(self, f, __tsplusTrace) {
|
332
|
+
return contramapChunks_1(self, chunk => tsplus_module_2.map_(chunk, f), __tsplusTrace);
|
305
333
|
}
|
306
334
|
/**
|
335
|
+
* Transforms this sink's input chunks. `f` must preserve chunking-invariance
|
336
|
+
*
|
307
337
|
* @tsplus fluent fncts.io.Sink contramapChunks
|
308
338
|
*/
|
309
339
|
|
310
340
|
|
311
|
-
function contramapChunks_1(self, f) {
|
341
|
+
function contramapChunks_1(self, f, __tsplusTrace) {
|
312
342
|
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
343
|
return new tsplus_module_3.Sink(tsplus_module_4.pipeTo_(loop, self.channel));
|
314
344
|
}
|
315
345
|
/**
|
346
|
+
* Effectfully transforms this sink's input chunks. `f` must preserve
|
347
|
+
* chunking-invariance
|
348
|
+
*
|
316
349
|
* @tsplus fluent fncts.io.Sink contramapChunksIO
|
317
350
|
*/
|
318
351
|
|
319
352
|
|
320
|
-
function contramapChunksIO_1(self, f) {
|
353
|
+
function contramapChunksIO_1(self, f, __tsplusTrace) {
|
321
354
|
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
355
|
return new tsplus_module_3.Sink(tsplus_module_4.pipeToOrFail_(loop, self.channel));
|
323
356
|
}
|
324
357
|
/**
|
358
|
+
* Effectfully transforms this sink's input elements.
|
359
|
+
*
|
325
360
|
* @tsplus fluent fncts.io.Sink contramapIO
|
326
361
|
*/
|
327
362
|
|
328
363
|
|
329
|
-
function contramapIO_1(self, f) {
|
330
|
-
return contramapChunksIO_1(self, chunk => tsplus_module_10.mapIO_(chunk, f));
|
364
|
+
function contramapIO_1(self, f, __tsplusTrace) {
|
365
|
+
return contramapChunksIO_1(self, chunk => tsplus_module_10.mapIO_(chunk, f), __tsplusTrace);
|
331
366
|
}
|
332
367
|
/**
|
368
|
+
* Transforms both inputs and result of this sink using the provided
|
369
|
+
* functions.
|
370
|
+
*
|
333
371
|
* @tsplus fluent fncts.io.Sink dimap
|
334
372
|
*/
|
335
373
|
|
336
374
|
|
337
|
-
function dimap(self, f, g) {
|
338
|
-
return map_1(contramap_1(self, f), g,
|
375
|
+
function dimap(self, f, g, __tsplusTrace) {
|
376
|
+
return map_1(contramap_1(self, f, __tsplusTrace), g, __tsplusTrace);
|
339
377
|
}
|
340
378
|
/**
|
379
|
+
* Transforms both input chunks and result of this sink using the provided
|
380
|
+
* functions.
|
381
|
+
*
|
341
382
|
* @tsplus fluent fncts.io.Sink dimapChunks
|
342
383
|
*/
|
343
384
|
|
344
385
|
|
345
|
-
function dimapChunks(self, f, g) {
|
346
|
-
return map_1(contramapChunks_1(self, f), g,
|
386
|
+
function dimapChunks(self, f, g, __tsplusTrace) {
|
387
|
+
return map_1(contramapChunks_1(self, f, __tsplusTrace), g, __tsplusTrace);
|
347
388
|
}
|
348
389
|
/**
|
390
|
+
* Effectfully transforms both input chunks and result of this sink using the
|
391
|
+
* provided functions. `f` and `g` must preserve chunking-invariance
|
392
|
+
*
|
349
393
|
* @tsplus fluent fncts.io.Sink dimapChunksIO
|
350
394
|
*/
|
351
395
|
|
352
396
|
|
353
|
-
function dimapChunksIO(self, f, g) {
|
354
|
-
return mapIO_1(contramapChunksIO_1(self, f), g,
|
397
|
+
function dimapChunksIO(self, f, g, __tsplusTrace) {
|
398
|
+
return mapIO_1(contramapChunksIO_1(self, f, __tsplusTrace), g, __tsplusTrace);
|
355
399
|
}
|
356
400
|
/**
|
401
|
+
* Effectfully transforms both inputs and result of this sink using the
|
402
|
+
* provided functions.
|
403
|
+
*
|
357
404
|
* @tsplus fluent fncts.io.Sink dimapIO
|
358
405
|
*/
|
359
406
|
|
360
407
|
|
361
|
-
function dimapIO(self, f, g) {
|
362
|
-
return mapIO_1(contramapIO_1(self, f), g,
|
408
|
+
function dimapIO(self, f, g, __tsplusTrace) {
|
409
|
+
return mapIO_1(contramapIO_1(self, f, __tsplusTrace), g, __tsplusTrace);
|
363
410
|
}
|
364
411
|
/**
|
412
|
+
* Returns a lazily constructed sink that may require effects for its
|
413
|
+
* creation.
|
414
|
+
*
|
365
415
|
* @tsplus static fncts.io.SinkOps defer
|
366
416
|
*/
|
367
417
|
|
368
418
|
|
369
|
-
function defer_1(sink) {
|
419
|
+
function defer_1(sink, __tsplusTrace) {
|
370
420
|
return new tsplus_module_3.Sink(tsplus_module_4.defer(() => sink().channel));
|
371
421
|
}
|
372
422
|
|
@@ -379,12 +429,45 @@ const drainLoop = /*#__PURE__*/tsplus_module_4.readWithCause(() => drainLoop, ts
|
|
379
429
|
|
380
430
|
const drain = /*#__PURE__*/new tsplus_module_3.Sink(drainLoop);
|
381
431
|
/**
|
382
|
-
*
|
432
|
+
* Drops incoming elements until the predicate `p` is satisfied.
|
433
|
+
*
|
434
|
+
* @tsplus static fncts.io.SinkOps dropUntil
|
383
435
|
*/
|
384
436
|
|
385
437
|
exports.drain = drain;
|
386
438
|
|
387
|
-
function
|
439
|
+
function makeDropUntil(p, __tsplusTrace) {
|
440
|
+
const loop = tsplus_module_4.readWith(inp => {
|
441
|
+
const leftover = tsplus_module_2.dropUntil(inp, p);
|
442
|
+
const more = tsplus_module_2.isEmpty(leftover);
|
443
|
+
|
444
|
+
if (more) {
|
445
|
+
return loop;
|
446
|
+
} else {
|
447
|
+
return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftover), tsplus_module_4.id());
|
448
|
+
}
|
449
|
+
}, tsplus_module_4.failNow, () => tsplus_module_4.unit);
|
450
|
+
return new tsplus_module_3.Sink(loop);
|
451
|
+
}
|
452
|
+
/**
|
453
|
+
* Drops incoming elements until the effectful predicate `p` is satisfied.
|
454
|
+
*
|
455
|
+
* @tsplus static fncts.io.SinkOps dropUntilIO
|
456
|
+
*/
|
457
|
+
|
458
|
+
|
459
|
+
function makeDropUntilIO(p, __tsplusTrace) {
|
460
|
+
const loop = tsplus_module_4.readWith(inp => tsplus_module_4.unwrap(() => tsplus_module_9.map_(tsplus_module_11.dropUntilIO(inp, p, __tsplusTrace), leftover => tsplus_module_2.isEmpty(leftover) ? loop : tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftover), tsplus_module_4.id()), __tsplusTrace)), tsplus_module_4.failNow, () => tsplus_module_4.unit);
|
461
|
+
return new tsplus_module_3.Sink(loop);
|
462
|
+
}
|
463
|
+
/**
|
464
|
+
* Drops incoming elements as long as the predicate `p` is satisfied.
|
465
|
+
*
|
466
|
+
* @tsplus static fncts.io.SinkOps dropWhile
|
467
|
+
*/
|
468
|
+
|
469
|
+
|
470
|
+
function makeDropWhile(predicate, __tsplusTrace) {
|
388
471
|
const loop = tsplus_module_4.readWith(inp => {
|
389
472
|
const leftover = tsplus_module_2.dropWhile_(inp, predicate);
|
390
473
|
const more = tsplus_module_2.isEmpty(leftover);
|
@@ -398,46 +481,70 @@ function dropWhile(predicate) {
|
|
398
481
|
return new tsplus_module_3.Sink(loop);
|
399
482
|
}
|
400
483
|
/**
|
484
|
+
* Drops incoming elements as long as the effectful predicate `p` is
|
485
|
+
* satisfied.
|
486
|
+
*
|
487
|
+
* @tsplus static fncts.io.SinkOps dropWhileIO
|
488
|
+
*/
|
489
|
+
|
490
|
+
|
491
|
+
function dropWhileIO(p, __tsplusTrace) {
|
492
|
+
const loop = tsplus_module_4.readWith(inp => tsplus_module_4.unwrap(() => tsplus_module_9.map_(tsplus_module_12.dropWhileIO(inp, p, __tsplusTrace), leftover => tsplus_module_2.isEmpty(leftover) ? loop : tsplus_module_5.apSecond_(tsplus_module_4.writeNow(leftover), tsplus_module_4.id()), __tsplusTrace)), tsplus_module_4.failNow, () => tsplus_module_4.unit);
|
493
|
+
return new tsplus_module_3.Sink(loop);
|
494
|
+
}
|
495
|
+
/**
|
496
|
+
* Accesses the whole environment of the sink.
|
497
|
+
*
|
401
498
|
* @tsplus static fncts.io.SinkOps environment
|
402
499
|
*/
|
403
500
|
|
404
501
|
|
405
502
|
function environment(__tsplusTrace) {
|
406
|
-
return fromIO_1(() =>
|
503
|
+
return fromIO_1(() => tsplus_module_13.environment(__tsplusTrace), __tsplusTrace);
|
407
504
|
}
|
408
505
|
/**
|
506
|
+
* Accesses the environment of the sink.
|
507
|
+
*
|
409
508
|
* @tsplus static fncts.io.SinkOps environmentWith
|
410
509
|
*/
|
411
510
|
|
412
511
|
|
413
512
|
function environmentWith(f, __tsplusTrace) {
|
414
|
-
return fromIO_1(() =>
|
513
|
+
return fromIO_1(() => tsplus_module_13.environmentWith(f, __tsplusTrace), __tsplusTrace);
|
415
514
|
}
|
416
515
|
/**
|
516
|
+
* Accesses the environment of the sink in the context of an effect.
|
517
|
+
*
|
417
518
|
* @tsplus static fncts.io.SinkOps environmentWithIO
|
418
519
|
*/
|
419
520
|
|
420
521
|
|
421
522
|
function environmentWithIO(f, __tsplusTrace) {
|
422
|
-
return fromIO_1(() =>
|
523
|
+
return fromIO_1(() => tsplus_module_13.environmentWithIO(f, __tsplusTrace), __tsplusTrace);
|
423
524
|
}
|
424
525
|
/**
|
526
|
+
* Accesses the environment of the sink in the context of a sink.
|
527
|
+
*
|
425
528
|
* @tsplus static fncts.io.SinkOps environmentWithSink
|
426
529
|
*/
|
427
530
|
|
428
531
|
|
429
532
|
function environmentWithSink(f, __tsplusTrace) {
|
430
|
-
return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() =>
|
533
|
+
return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_13.environmentWith(tsplus_module_14.compose_(f, s => s.channel), __tsplusTrace)));
|
431
534
|
}
|
432
535
|
/**
|
536
|
+
* A sink that always fails with the specified error.
|
537
|
+
*
|
433
538
|
* @tsplus static fncts.io.SinkOps fail
|
434
539
|
*/
|
435
540
|
|
436
541
|
|
437
|
-
function fail(e) {
|
542
|
+
function fail(e, __tsplusTrace) {
|
438
543
|
return new tsplus_module_3.Sink(tsplus_module_4.fail(e));
|
439
544
|
}
|
440
545
|
/**
|
546
|
+
* Creates a sink halting with a specified cause.
|
547
|
+
*
|
441
548
|
* @tsplus static fncts.io.SinkOps failCause
|
442
549
|
*/
|
443
550
|
|
@@ -446,6 +553,8 @@ function failCause_1(cause, __tsplusTrace) {
|
|
446
553
|
return new tsplus_module_3.Sink(tsplus_module_5.failCause(cause));
|
447
554
|
}
|
448
555
|
/**
|
556
|
+
* Creates a sink halting with a specified cause.
|
557
|
+
*
|
449
558
|
* @tsplus static fncts.io.SinkOps failCauseNow
|
450
559
|
*/
|
451
560
|
|
@@ -454,6 +563,8 @@ function failCauseNow_1(cause, __tsplusTrace) {
|
|
454
563
|
return new tsplus_module_3.Sink(tsplus_module_5.failCauseNow(cause));
|
455
564
|
}
|
456
565
|
/**
|
566
|
+
* A sink that always fails with the specified error.
|
567
|
+
*
|
457
568
|
* @tsplus static fncts.io.SinkOps failNow
|
458
569
|
*/
|
459
570
|
|
@@ -462,22 +573,28 @@ function failNow_1(e, __tsplusTrace) {
|
|
462
573
|
return new tsplus_module_3.Sink(tsplus_module_4.failNow(e));
|
463
574
|
}
|
464
575
|
/**
|
576
|
+
* Filters the sink's input with the given predicate
|
577
|
+
*
|
465
578
|
* @tsplus static fncts.io.SinkOps filterInput
|
466
579
|
*/
|
467
580
|
|
468
581
|
|
469
582
|
function filterInput(self, p, __tsplusTrace) {
|
470
|
-
return contramapChunks_1(self, chunk => tsplus_module_2.filter_(chunk, p));
|
583
|
+
return contramapChunks_1(self, chunk => tsplus_module_2.filter_(chunk, p), __tsplusTrace);
|
471
584
|
}
|
472
585
|
/**
|
586
|
+
* Filters the sink's input with the given IO predicate
|
587
|
+
*
|
473
588
|
* @tsplus static fncts.io.SinkOps filterInputIO
|
474
589
|
*/
|
475
590
|
|
476
591
|
|
477
592
|
function filterInputIO(self, p, __tsplusTrace) {
|
478
|
-
return contramapChunksIO_1(self, chunk =>
|
593
|
+
return contramapChunksIO_1(self, chunk => tsplus_module_15.filterIO(chunk, p), __tsplusTrace);
|
479
594
|
}
|
480
595
|
/**
|
596
|
+
* Creates a sink that produces values until one verifies the predicate `f`.
|
597
|
+
*
|
481
598
|
* @tsplus fluent fncts.io.Sink findIO
|
482
599
|
*/
|
483
600
|
|
@@ -486,12 +603,18 @@ function findIO(self, f, __tsplusTrace) {
|
|
486
603
|
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
604
|
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
605
|
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)), () =>
|
606
|
+
if (satisfied) return tsplus_module_4.as_(tsplus_module_4.writeNow(tsplus_module_2.flatten(leftovers)), () => tsplus_module_16.just(doneValue));else if (upstreamDone) return tsplus_module_4.as_(tsplus_module_4.writeNow(tsplus_module_2.flatten(leftovers)), () => tsplus_module_16.nothing());else return loop;
|
490
607
|
}))));
|
491
608
|
return tsplus_module_4.pipeTo_(tsplus_module_4.pipeTo_(upstreamMarker, tsplus_module_4.bufferChunk(leftoversRef)), loop);
|
492
609
|
}));
|
493
610
|
}
|
494
611
|
/**
|
612
|
+
* Runs this sink until it yields a result, then uses that result to create
|
613
|
+
* another sink from the provided function which will continue to run until it
|
614
|
+
* yields a result.
|
615
|
+
*
|
616
|
+
* This function essentially runs sinks in sequence.
|
617
|
+
*
|
495
618
|
* @tsplus fluent fncts.io.Sink flatMap
|
496
619
|
*/
|
497
620
|
|
@@ -500,6 +623,8 @@ function flatMap_1(self, f, __tsplusTrace) {
|
|
500
623
|
return matchSink_1(self, failNow_1, f, __tsplusTrace);
|
501
624
|
}
|
502
625
|
/**
|
626
|
+
* Creates a sink from a {@link Channel}
|
627
|
+
*
|
503
628
|
* @tsplus static fncts.io.SinkOps fromChannel
|
504
629
|
* @tsplus static fncts.io.SinkOps __call
|
505
630
|
*/
|
@@ -509,6 +634,8 @@ function fromChannel(channel) {
|
|
509
634
|
return new tsplus_module_3.Sink(channel);
|
510
635
|
}
|
511
636
|
/**
|
637
|
+
* Creates a sink from a chunk processing function.
|
638
|
+
*
|
512
639
|
* @tsplus static fncts.io.SinkOps fromPush
|
513
640
|
*/
|
514
641
|
|
@@ -518,73 +645,93 @@ function fromPush(push, __tsplusTrace) {
|
|
518
645
|
}
|
519
646
|
|
520
647
|
function fromPushPull(push) {
|
521
|
-
return tsplus_module_4.readWith(inp => tsplus_module_4.matchChannel_(tsplus_module_4.fromIO(() => push(
|
648
|
+
return tsplus_module_4.readWith(inp => tsplus_module_4.matchChannel_(tsplus_module_4.fromIO(() => push(tsplus_module_16.just(inp))), ([r, leftovers]) => tsplus_module_17.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_16.nothing())), ([r, leftovers]) => tsplus_module_17.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 + ":591:37"))));
|
522
649
|
}
|
523
650
|
/**
|
651
|
+
* Create a sink which enqueues each element into the specified queue.
|
652
|
+
*
|
524
653
|
* @tsplus static fncts.io.SinkOps fromQueue
|
525
654
|
*/
|
526
655
|
|
527
656
|
|
528
|
-
function fromQueue_1(queue) {
|
529
|
-
return unwrap_1(() => tsplus_module_9.map_(tsplus_module_9.succeed(queue,
|
657
|
+
function fromQueue_1(queue, __tsplusTrace) {
|
658
|
+
return unwrap_1(() => tsplus_module_9.map_(tsplus_module_9.succeed(queue, __tsplusTrace), queue => makeForeachChunk_1(inp => tsplus_module_18.offerAll_(queue, inp), __tsplusTrace), __tsplusTrace));
|
530
659
|
}
|
531
660
|
/**
|
661
|
+
* Create a sink which enqueues each element into the specified queue. The
|
662
|
+
* queue will be shutdown once the stream is closed.
|
663
|
+
*
|
532
664
|
* @tsplus static fncts.io.SinkOps fromQueueWithShutdown
|
533
665
|
*/
|
534
666
|
|
535
667
|
|
536
|
-
function fromQueueWithShutdown_1(queue) {
|
537
|
-
return unwrapScoped_1(() => tsplus_module_9.map_(
|
668
|
+
function fromQueueWithShutdown_1(queue, __tsplusTrace) {
|
669
|
+
return unwrapScoped_1(() => tsplus_module_9.map_(tsplus_module_19.acquireRelease(() => tsplus_module_9.succeed(queue, __tsplusTrace), queue => tsplus_module_18.shutdown(queue)), queue => fromQueue_1(() => queue, __tsplusTrace), __tsplusTrace), __tsplusTrace);
|
538
670
|
}
|
539
671
|
/**
|
672
|
+
* Create a sink which publishes each element to the specified hub.
|
673
|
+
*
|
540
674
|
* @tsplus static fncts.io.SinkOps fromHub
|
541
675
|
*/
|
542
676
|
|
543
677
|
|
544
|
-
function fromHub(hub) {
|
545
|
-
return fromQueue_1(hub);
|
678
|
+
function fromHub(hub, __tsplusTrace) {
|
679
|
+
return fromQueue_1(hub, __tsplusTrace);
|
546
680
|
}
|
547
681
|
/**
|
682
|
+
* Create a sink which publishes each element to the specified hub. The hub
|
683
|
+
* will be shutdown once the stream is closed.
|
684
|
+
*
|
548
685
|
* @tsplus static fncts.io.SinkOps fromHubWithShutdown
|
549
686
|
*/
|
550
687
|
|
551
688
|
|
552
|
-
function fromHubWithShutdown(hub) {
|
553
|
-
return fromQueueWithShutdown_1(hub);
|
689
|
+
function fromHubWithShutdown(hub, __tsplusTrace) {
|
690
|
+
return fromQueueWithShutdown_1(hub, __tsplusTrace);
|
554
691
|
}
|
555
692
|
/**
|
693
|
+
* Creates a single-value sink produced from an effect
|
694
|
+
*
|
556
695
|
* @tsplus static fncts.io.SinkOps fromIO
|
557
696
|
*/
|
558
697
|
|
559
698
|
|
560
|
-
function fromIO_1(b) {
|
699
|
+
function fromIO_1(b, __tsplusTrace) {
|
561
700
|
return new tsplus_module_3.Sink(tsplus_module_4.fromIO(b));
|
562
701
|
}
|
563
702
|
/**
|
703
|
+
* Creates a sink halting with the specified unchecked value.
|
704
|
+
*
|
564
705
|
* @tsplus static fncts.io.SinkOps halt
|
565
706
|
*/
|
566
707
|
|
567
708
|
|
568
709
|
function halt(defect, __tsplusTrace) {
|
569
|
-
return failCause_1(() =>
|
710
|
+
return failCause_1(() => tsplus_module_20.halt(defect()), __tsplusTrace);
|
570
711
|
}
|
571
712
|
/**
|
713
|
+
* Creates a sink halting with the specified unchecked value.
|
714
|
+
*
|
572
715
|
* @tsplus static fncts.io.SinkOps haltNow
|
573
716
|
*/
|
574
717
|
|
575
718
|
|
576
719
|
function haltNow(defect, __tsplusTrace) {
|
577
|
-
return failCauseNow_1(
|
720
|
+
return failCauseNow_1(tsplus_module_20.halt(defect), __tsplusTrace);
|
578
721
|
}
|
579
722
|
/**
|
723
|
+
* Creates a sink containing the first value.
|
724
|
+
*
|
580
725
|
* @tsplus static fncts.io.SinkOps head
|
581
726
|
*/
|
582
727
|
|
583
728
|
|
584
729
|
function head(__tsplusTrace) {
|
585
|
-
return makeFold_1(() =>
|
730
|
+
return makeFold_1(() => tsplus_module_16.nothing(), elem => tsplus_module_21.isNothing(elem), (s, inp) => tsplus_module_22.match_(s, () => tsplus_module_16.just(inp), () => s), __tsplusTrace);
|
586
731
|
}
|
587
732
|
/**
|
733
|
+
* Drains the remaining elements from the stream after the sink finishes
|
734
|
+
*
|
588
735
|
* @tsplus getter fncts.io.Sink ignoreLeftover
|
589
736
|
*/
|
590
737
|
|
@@ -593,14 +740,19 @@ function ignoreLeftover_1(self, __tsplusTrace) {
|
|
593
740
|
return new tsplus_module_3.Sink(tsplus_module_4.drain(self.channel));
|
594
741
|
}
|
595
742
|
/**
|
743
|
+
* Creates a sink containing the last value.
|
744
|
+
*
|
596
745
|
* @tsplus static fncts.io.SinkOps last
|
597
746
|
*/
|
598
747
|
|
599
748
|
|
600
749
|
function last(__tsplusTrace) {
|
601
|
-
return makeFoldLeft_1(() =>
|
750
|
+
return makeFoldLeft_1(() => tsplus_module_16.nothing(), (_, inp) => tsplus_module_16.just(inp));
|
602
751
|
}
|
603
752
|
/**
|
753
|
+
* Creates a sink that does not consume any input but provides the given chunk
|
754
|
+
* as its leftovers
|
755
|
+
*
|
604
756
|
* @tsplus static fncts.io.SinkOps leftover
|
605
757
|
*/
|
606
758
|
|
@@ -609,12 +761,14 @@ function leftover(c, __tsplusTrace) {
|
|
609
761
|
return new tsplus_module_3.Sink(tsplus_module_4.write(c));
|
610
762
|
}
|
611
763
|
/**
|
764
|
+
* Logs the specified message at the current log level.
|
765
|
+
*
|
612
766
|
* @tsplus static fncts.io.SinkOps log
|
613
767
|
*/
|
614
768
|
|
615
769
|
|
616
770
|
function log(message, __tsplusTrace) {
|
617
|
-
return fromIO_1(() => tsplus_module_9.log(message, __tsplusTrace));
|
771
|
+
return fromIO_1(() => tsplus_module_9.log(message, __tsplusTrace), __tsplusTrace);
|
618
772
|
}
|
619
773
|
/**
|
620
774
|
* A sink that collects all of its inputs into a chunk.
|
@@ -630,9 +784,16 @@ function makeCollectAll() {
|
|
630
784
|
function collectLoop(state) {
|
631
785
|
return tsplus_module_4.readWithCause(inp => collectLoop(tsplus_module_2.concat_(state, inp)), tsplus_module_5.failCauseNow, () => tsplus_module_5.endNow(state));
|
632
786
|
}
|
787
|
+
/**
|
788
|
+
* A sink that collects first `n` elements into a chunk. Note that the chunk
|
789
|
+
* is preallocated and must fit in memory.
|
790
|
+
*
|
791
|
+
* @tsplus static fncts.io.SinkOps collectAllN
|
792
|
+
*/
|
793
|
+
|
633
794
|
|
634
795
|
function makeCollectAllN(n) {
|
635
|
-
return flatMap_1(fromIO_1(() => tsplus_module_9.succeed(() => new
|
796
|
+
return flatMap_1(fromIO_1(() => tsplus_module_9.succeed(() => new tsplus_module_23.ConcBuilder(), fileName_1 + ":755:32"), fileName_1 + ":755:21"), builder => map_1(makeFoldUntil_1(() => builder, n, (builder, inp) => builder.append(inp), fileName_1 + ":756:19"), builder => builder.result(), fileName_1 + ":756:95"), fileName_1 + ":755:64");
|
636
797
|
}
|
637
798
|
/**
|
638
799
|
* A sink that executes the provided effectful function for every element fed to it.
|
@@ -645,6 +806,9 @@ function makeForeach(f, __tsplusTrace) {
|
|
645
806
|
return makeForeachWhile_1(inp => tsplus_module_9.as_(f(inp), () => true), __tsplusTrace);
|
646
807
|
}
|
647
808
|
/**
|
809
|
+
* A sink that executes the provided effectful function for every chunk fed to
|
810
|
+
* it.
|
811
|
+
*
|
648
812
|
* @tsplus static fncts.io.SinkOps foreachChunk
|
649
813
|
*/
|
650
814
|
|
@@ -674,6 +838,9 @@ function foreachWhileLoop(f, chunk, idx, len, cont) {
|
|
674
838
|
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
839
|
}
|
676
840
|
/**
|
841
|
+
* A sink that executes the provided effectful function for every chunk fed to
|
842
|
+
* it until `f` evaluates to `false`.
|
843
|
+
*
|
677
844
|
* @tsplus static fncts.io.SinkOps foreachChunkWhile
|
678
845
|
*/
|
679
846
|
|
@@ -683,12 +850,15 @@ function makeForeachChunkWhile(f, __tsplusTrace) {
|
|
683
850
|
return new tsplus_module_3.Sink(reader);
|
684
851
|
}
|
685
852
|
/**
|
853
|
+
* A sink that folds its inputs with the provided function, termination
|
854
|
+
* predicate and initial state.
|
855
|
+
*
|
686
856
|
* @tsplus static fncts.io.SinkOps fold
|
687
857
|
*/
|
688
858
|
|
689
859
|
|
690
860
|
function makeFold_1(z, contFn, f, __tsplusTrace) {
|
691
|
-
return defer_1(() => new tsplus_module_3.Sink(foldReader(z(), contFn, f)));
|
861
|
+
return defer_1(() => new tsplus_module_3.Sink(foldReader(z(), contFn, f)), __tsplusTrace);
|
692
862
|
}
|
693
863
|
/**
|
694
864
|
* @tsplus tailRec
|
@@ -752,6 +922,11 @@ function foldReader(s, contFn, f) {
|
|
752
922
|
}
|
753
923
|
}
|
754
924
|
/**
|
925
|
+
* Creates a sink that folds elements of type `In` into a structure of type
|
926
|
+
* `S` until `max` elements have been folded.
|
927
|
+
*
|
928
|
+
* Like {@link foldWeighted}, but with a constant cost function of 1.
|
929
|
+
*
|
755
930
|
* @tsplus static fncts.io.SinkOps foldUntil
|
756
931
|
*/
|
757
932
|
|
@@ -760,12 +935,17 @@ function makeFoldUntil_1(z, max, f, __tsplusTrace) {
|
|
760
935
|
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
936
|
}
|
762
937
|
/**
|
938
|
+
* A sink that folds its input chunks with the provided function, termination
|
939
|
+
* predicate and initial state. `contFn` condition is checked only for the
|
940
|
+
* initial value and at the end of processing of each chunk. `f` and `contFn`
|
941
|
+
* must preserve chunking-invariance.
|
942
|
+
*
|
763
943
|
* @tsplus static fncts.io.SinkOps foldChunks
|
764
944
|
*/
|
765
945
|
|
766
946
|
|
767
|
-
function makeFoldChunks_1(z, contFn, f) {
|
768
|
-
return defer_1(() => new tsplus_module_3.Sink(foldChunksReader(z(), contFn, f)));
|
947
|
+
function makeFoldChunks_1(z, contFn, f, __tsplusTrace) {
|
948
|
+
return defer_1(() => new tsplus_module_3.Sink(foldChunksReader(z(), contFn, f)), __tsplusTrace);
|
769
949
|
}
|
770
950
|
|
771
951
|
function foldChunksReader(s, contFn, f) {
|
@@ -779,12 +959,17 @@ function foldChunksReader(s, contFn, f) {
|
|
779
959
|
}
|
780
960
|
}
|
781
961
|
/**
|
962
|
+
* A sink that effectfully folds its input chunks with the provided function,
|
963
|
+
* termination predicate and initial state. `contFn` condition is checked only
|
964
|
+
* for the initial value and at the end of processing of each chunk. `f` and
|
965
|
+
* `contFn` must preserve chunking-invariance.
|
966
|
+
*
|
782
967
|
* @tsplus static fncts.io.SinkOps foldChunksIO
|
783
968
|
*/
|
784
969
|
|
785
970
|
|
786
|
-
function makeFoldChunksIO_1(z, contFn, f) {
|
787
|
-
return defer_1(() => new tsplus_module_3.Sink(foldChunksIOReader(z(), contFn, f)));
|
971
|
+
function makeFoldChunksIO_1(z, contFn, f, __tsplusTrace) {
|
972
|
+
return defer_1(() => new tsplus_module_3.Sink(foldChunksIOReader(z(), contFn, f)), __tsplusTrace);
|
788
973
|
}
|
789
974
|
|
790
975
|
function foldChunksIOReader(s, contFn, f) {
|
@@ -795,57 +980,71 @@ function foldChunksIOReader(s, contFn, f) {
|
|
795
980
|
}
|
796
981
|
}
|
797
982
|
/**
|
983
|
+
* A sink that folds its inputs with the provided function and initial state.
|
984
|
+
*
|
798
985
|
* @tsplus static fncts.io.SinkOps foldLeft
|
799
986
|
*/
|
800
987
|
|
801
988
|
|
802
989
|
function makeFoldLeft_1(z, f) {
|
803
|
-
return ignoreLeftover_1(makeFold_1(z, () => true, f, fileName_1 + ":
|
990
|
+
return ignoreLeftover_1(makeFold_1(z, () => true, f, fileName_1 + ":1006:19"), fileName_1 + ":1006:37");
|
804
991
|
}
|
805
992
|
/**
|
993
|
+
* A sink that folds its input chunks with the provided function and initial
|
994
|
+
* state. `f` must preserve chunking-invariance.
|
995
|
+
*
|
806
996
|
* @tsplus static fncts.io.SinkOps foldLeftChunks
|
807
997
|
*/
|
808
998
|
|
809
999
|
|
810
1000
|
function makeFoldLeftChunks(z, f) {
|
811
|
-
return ignoreLeftover_1(makeFoldChunks_1(z, () => true, f), fileName_1 + ":
|
1001
|
+
return ignoreLeftover_1(makeFoldChunks_1(z, () => true, f, fileName_1 + ":1019:25"), fileName_1 + ":1019:43");
|
812
1002
|
}
|
813
1003
|
/**
|
1004
|
+
* A sink that effectfully folds its input chunks with the provided function
|
1005
|
+
* and initial state. `f` must preserve chunking-invariance.
|
1006
|
+
*
|
814
1007
|
* @tsplus static fncts.io.SinkOps foldLeftChunksIO
|
815
1008
|
*/
|
816
1009
|
|
817
1010
|
|
818
|
-
function makeFoldLeftChunksIO(z, f) {
|
819
|
-
return makeFoldChunksIO_1(z, () => true, f);
|
1011
|
+
function makeFoldLeftChunksIO(z, f, __tsplusTrace) {
|
1012
|
+
return makeFoldChunksIO_1(z, () => true, f, __tsplusTrace);
|
820
1013
|
}
|
821
1014
|
/**
|
1015
|
+
* A sink that effectfully folds its inputs with the provided function and
|
1016
|
+
* initial state.
|
1017
|
+
*
|
822
1018
|
* @tsplus static fncts.io.SinkOps foldLeftIO
|
823
1019
|
*/
|
824
1020
|
|
825
1021
|
|
826
|
-
function makeFoldLeftIO(z, f) {
|
1022
|
+
function makeFoldLeftIO(z, f, __tsplusTrace) {
|
827
1023
|
return makeFoldIO_1(z, () => true, f);
|
828
1024
|
}
|
829
1025
|
/**
|
1026
|
+
* A sink that effectfully folds its inputs with the provided function,
|
1027
|
+
* termination predicate and initial state.
|
1028
|
+
*
|
830
1029
|
* @tsplus static fncts.io.SinkOps foldIO
|
831
1030
|
*/
|
832
1031
|
|
833
1032
|
|
834
1033
|
function makeFoldIO_1(z, contFn, f) {
|
835
|
-
return defer_1(() => new tsplus_module_3.Sink(foldIOReader(z(), contFn, f)));
|
1034
|
+
return defer_1(() => new tsplus_module_3.Sink(foldIOReader(z(), contFn, f)), fileName_1 + ":1061:20");
|
836
1035
|
}
|
837
1036
|
|
838
1037
|
function foldChunkSplitIO(s, contFn, f, chunk, idx, len) {
|
839
1038
|
if (idx === len) {
|
840
|
-
return tsplus_module_9.succeedNow([s,
|
1039
|
+
return tsplus_module_9.succeedNow([s, tsplus_module_16.nothing()], fileName_1 + ":1073:25");
|
841
1040
|
} else {
|
842
1041
|
return tsplus_module_9.flatMap_(f(s, tsplus_module_2.unsafeGet_(chunk, idx)), s1 => {
|
843
1042
|
if (contFn(s1)) {
|
844
1043
|
return foldChunkSplitIO(s1, contFn, f, chunk, idx + 1, len);
|
845
1044
|
} else {
|
846
|
-
return tsplus_module_9.succeedNow([s1,
|
1045
|
+
return tsplus_module_9.succeedNow([s1, tsplus_module_16.just(tsplus_module_2.drop_(chunk, idx + 1))], fileName_1 + ":1079:29");
|
847
1046
|
}
|
848
|
-
}, fileName_1 + ":
|
1047
|
+
}, fileName_1 + ":1075:36");
|
849
1048
|
}
|
850
1049
|
}
|
851
1050
|
|
@@ -853,23 +1052,44 @@ function foldIOReader(s, contFn, f) {
|
|
853
1052
|
if (!contFn(s)) {
|
854
1053
|
return tsplus_module_5.succeedNow(s);
|
855
1054
|
} 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]) =>
|
1055
|
+
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_22.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
1056
|
}
|
858
1057
|
}
|
859
1058
|
/**
|
1059
|
+
* Creates a sink that effectfully folds elements of type `In` into a
|
1060
|
+
* structure of type `S` until `max` elements have been folded.
|
1061
|
+
*
|
1062
|
+
* Like {@link makeFoldWeightedIO}, but with a constant cost function of 1.
|
1063
|
+
*
|
860
1064
|
* @tsplus static fncts.io.SinkOps foldUntilIO
|
861
1065
|
*/
|
862
1066
|
|
863
1067
|
|
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],
|
1068
|
+
function makeFoldUntilIO(z, max, f, __tsplusTrace) {
|
1069
|
+
return map_1(makeFoldIO_1(() => [z(), 0], ([_, n]) => n < max(), ([o, count], i) => tsplus_module_9.map_(f(o, i), s => [s, count + 1], __tsplusTrace)), ([s]) => s, __tsplusTrace);
|
866
1070
|
}
|
867
1071
|
/**
|
1072
|
+
* Creates a sink that folds elements of type `In` into a structure of type
|
1073
|
+
* `S`, until `max` worth of elements (determined by the `costFn`) have been
|
1074
|
+
* folded.
|
1075
|
+
*
|
1076
|
+
* The `decompose` function will be used for decomposing elements that cause
|
1077
|
+
* an `S` aggregate to cross `max` into smaller elements.
|
1078
|
+
*
|
1079
|
+
*
|
1080
|
+
* Be vigilant with this function, it has to generate "simpler" values or the
|
1081
|
+
* fold may never end. A value is considered indivisible if `decompose` yields
|
1082
|
+
* the empty chunk or a single-valued chunk. In these cases, there is no other
|
1083
|
+
* choice than to yield a value that will cross the threshold.
|
1084
|
+
*
|
1085
|
+
* The {@link makeFoldWeightedDecomposeIO} allows the decompose function to return a
|
1086
|
+
* `IO` value, and consequently it allows the sink to fail.
|
1087
|
+
*
|
868
1088
|
* @tsplus static fncts.io.SinkOps foldWeightedDecompose
|
869
1089
|
*/
|
870
1090
|
|
871
1091
|
|
872
|
-
function makeFoldWeightedDecompose_1(z, costFn, max, decompose, f) {
|
1092
|
+
function makeFoldWeightedDecompose_1(z, costFn, max, decompose, f, __tsplusTrace) {
|
873
1093
|
return defer_1(() => {
|
874
1094
|
/**
|
875
1095
|
* @tsplus tailRec
|
@@ -912,35 +1132,46 @@ function makeFoldWeightedDecompose_1(z, costFn, max, decompose, f) {
|
|
912
1132
|
}
|
913
1133
|
|
914
1134
|
return new tsplus_module_3.Sink(go(z(), 0, false, max()));
|
915
|
-
});
|
1135
|
+
}, __tsplusTrace);
|
916
1136
|
}
|
917
1137
|
/**
|
1138
|
+
* Creates a sink that effectfully folds elements of type `In` into a
|
1139
|
+
* structure of type `S`, until `max` worth of elements (determined by the
|
1140
|
+
* `costFn`) have been folded.
|
1141
|
+
*
|
1142
|
+
* The `decompose` function will be used for decomposing elements that cause
|
1143
|
+
* an `S` aggregate to cross `max` into smaller elements. Be vigilant with
|
1144
|
+
* this function, it has to generate "simpler" values or the fold may never
|
1145
|
+
* end. A value is considered indivisible if `decompose` yields the empty
|
1146
|
+
* chunk or a single-valued chunk. In these cases, there is no other choice
|
1147
|
+
* than to yield a value that will cross the threshold.
|
1148
|
+
*
|
918
1149
|
* @tsplus static fncts.io.SinkOps foldWeightedDecomposeIO
|
919
1150
|
*/
|
920
1151
|
|
921
1152
|
|
922
|
-
function makeFoldWeightedDecomposeIO_1(z, costFn, max, decompose, f) {
|
1153
|
+
function makeFoldWeightedDecomposeIO_1(z, costFn, max, decompose, f, __tsplusTrace) {
|
923
1154
|
return defer_1(() => {
|
924
1155
|
function fold(inp, s, max, dirty, cost, idx) {
|
925
1156
|
if (idx === inp.length) {
|
926
|
-
return tsplus_module_9.succeedNow([s, cost, dirty, tsplus_module_1.empty()],
|
1157
|
+
return tsplus_module_9.succeedNow([s, cost, dirty, tsplus_module_1.empty()], __tsplusTrace);
|
927
1158
|
} else {
|
928
1159
|
const elem = tsplus_module_2.unsafeGet_(inp, idx);
|
929
|
-
return tsplus_module_9.flatMap_(tsplus_module_9.map_(costFn(s, elem), _ => cost + _,
|
1160
|
+
return tsplus_module_9.flatMap_(tsplus_module_9.map_(costFn(s, elem), _ => cost + _, __tsplusTrace), total => {
|
930
1161
|
if (total <= max) {
|
931
|
-
return tsplus_module_9.flatMap_(f(s, elem), s => fold(inp, s, max, true, total, idx + 1),
|
1162
|
+
return tsplus_module_9.flatMap_(f(s, elem), s => fold(inp, s, max, true, total, idx + 1), __tsplusTrace);
|
932
1163
|
} else {
|
933
1164
|
return tsplus_module_9.flatMap_(decompose(elem), decomposed => {
|
934
1165
|
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)],
|
1166
|
+
return tsplus_module_9.map_(f(s, elem), s => [s, total, true, tsplus_module_2.drop_(inp, idx + 1)], __tsplusTrace);
|
936
1167
|
} else if (decomposed.length <= 1 && dirty) {
|
937
|
-
return tsplus_module_9.succeedNow([s, cost, dirty, tsplus_module_2.drop_(inp, idx)],
|
1168
|
+
return tsplus_module_9.succeedNow([s, cost, dirty, tsplus_module_2.drop_(inp, idx)], __tsplusTrace);
|
938
1169
|
} else {
|
939
1170
|
return fold(tsplus_module_2.concat_(decomposed, tsplus_module_2.drop_(inp, idx + 1)), s, max, dirty, cost, 0);
|
940
1171
|
}
|
941
|
-
},
|
1172
|
+
}, __tsplusTrace);
|
942
1173
|
}
|
943
|
-
},
|
1174
|
+
}, __tsplusTrace);
|
944
1175
|
}
|
945
1176
|
}
|
946
1177
|
|
@@ -957,23 +1188,41 @@ function makeFoldWeightedDecomposeIO_1(z, costFn, max, decompose, f) {
|
|
957
1188
|
}
|
958
1189
|
|
959
1190
|
return new tsplus_module_3.Sink(go(z(), 0, false, max()));
|
960
|
-
});
|
1191
|
+
}, __tsplusTrace);
|
961
1192
|
}
|
962
1193
|
/**
|
1194
|
+
* Creates a sink that folds elements of type `In` into a structure of type
|
1195
|
+
* `S`, until `max` worth of elements (determined by the `costFn`) have been
|
1196
|
+
* folded.
|
1197
|
+
*
|
1198
|
+
* @note
|
1199
|
+
* Elements that have an individual cost larger than `max` will force the
|
1200
|
+
* sink to cross the `max` cost. See {@link makeFoldWeightedDecompose} for a variant
|
1201
|
+
* that can handle these cases.
|
1202
|
+
*
|
963
1203
|
* @tsplus static fncts.io.SinkOps foldWeighted
|
964
1204
|
*/
|
965
1205
|
|
966
1206
|
|
967
|
-
function makeFoldWeighted(z, costFn, max, f) {
|
968
|
-
return makeFoldWeightedDecompose_1(z, costFn, max,
|
1207
|
+
function makeFoldWeighted(z, costFn, max, f, __tsplusTrace) {
|
1208
|
+
return makeFoldWeightedDecompose_1(z, costFn, max, tsplus_module_24.single, f, __tsplusTrace);
|
969
1209
|
}
|
970
1210
|
/**
|
1211
|
+
* Creates a sink that effectfully folds elements of type `In` into a
|
1212
|
+
* structure of type `S`, until `max` worth of elements (determined by the
|
1213
|
+
* `costFn`) have been folded.
|
1214
|
+
*
|
1215
|
+
* @note
|
1216
|
+
* Elements that have an individual cost larger than `max` will force the
|
1217
|
+
* sink to cross the `max` cost. See {@link makeFoldWeightedDecomposeIO} for a
|
1218
|
+
* variant that can handle these cases.
|
1219
|
+
*
|
971
1220
|
* @tsplus static fncts.io.SinkOps foldWeightedIO
|
972
1221
|
*/
|
973
1222
|
|
974
1223
|
|
975
|
-
function makeFoldWeightedIO(z, costFn, max, f) {
|
976
|
-
return makeFoldWeightedDecomposeIO_1(z, costFn, max, inp => tsplus_module_9.succeedNow(
|
1224
|
+
function makeFoldWeightedIO(z, costFn, max, f, __tsplusTrace) {
|
1225
|
+
return makeFoldWeightedDecomposeIO_1(z, costFn, max, inp => tsplus_module_9.succeedNow(tsplus_module_24.single(inp), __tsplusTrace), f, __tsplusTrace);
|
977
1226
|
}
|
978
1227
|
/**
|
979
1228
|
* Transforms this sink's result.
|
@@ -1026,14 +1275,19 @@ function matchSink_1(self, onFailure, onSuccess, __tsplusTrace) {
|
|
1026
1275
|
})));
|
1027
1276
|
}
|
1028
1277
|
/**
|
1278
|
+
* Switch to another sink in case of failure
|
1279
|
+
*
|
1029
1280
|
* @tsplus fluent fncts.io.Sink orElse
|
1030
1281
|
*/
|
1031
1282
|
|
1032
1283
|
|
1033
1284
|
function orElse(self, that, __tsplusTrace) {
|
1034
|
-
return defer_1(() => new tsplus_module_3.Sink(tsplus_module_4.orElse_(self.channel, that().channel)));
|
1285
|
+
return defer_1(() => new tsplus_module_3.Sink(tsplus_module_4.orElse_(self.channel, that().channel)), __tsplusTrace);
|
1035
1286
|
}
|
1036
1287
|
/**
|
1288
|
+
* Provides the sink with its required environment, which eliminates its
|
1289
|
+
* dependency on `R`.
|
1290
|
+
*
|
1037
1291
|
* @tsplus fluent fncts.io.Sink provideEnvironment
|
1038
1292
|
*/
|
1039
1293
|
|
@@ -1042,22 +1296,31 @@ function provideEnvironment(self, r, __tsplusTrace) {
|
|
1042
1296
|
return new tsplus_module_3.Sink(tsplus_module_4.provideEnvironment_(self.channel, r));
|
1043
1297
|
}
|
1044
1298
|
/**
|
1299
|
+
* Runs both sinks in parallel on the input, returning the result or the
|
1300
|
+
* error from the one that finishes first.
|
1301
|
+
*
|
1045
1302
|
* @tsplus fluent fncts.io.Sink race
|
1046
1303
|
*/
|
1047
1304
|
|
1048
1305
|
|
1049
|
-
function race(self, that) {
|
1050
|
-
return map_1(raceBoth_1(self, that), result =>
|
1306
|
+
function race(self, that, __tsplusTrace) {
|
1307
|
+
return map_1(raceBoth_1(self, that), result => tsplus_module_25.merge(result), __tsplusTrace);
|
1051
1308
|
}
|
1052
1309
|
/**
|
1310
|
+
* Runs both sinks in parallel on the input, returning the result or the error
|
1311
|
+
* from the one that finishes first.
|
1312
|
+
*
|
1053
1313
|
* @tsplus fluent fncts.io.Sink raceBoth
|
1054
1314
|
*/
|
1055
1315
|
|
1056
1316
|
|
1057
|
-
function raceBoth_1(self, that, capacity = () => 16) {
|
1058
|
-
return raceWith_1(self, that, selfDone =>
|
1317
|
+
function raceBoth_1(self, that, capacity = () => 16, __tsplusTrace) {
|
1318
|
+
return raceWith_1(self, that, selfDone => tsplus_module_27.done(tsplus_module_9.map_(tsplus_module_9.fromExitNow(selfDone, __tsplusTrace), tsplus_module_26.left, __tsplusTrace)), thatDone => tsplus_module_27.done(tsplus_module_9.map_(tsplus_module_9.fromExitNow(thatDone, __tsplusTrace), tsplus_module_26.right, __tsplusTrace)), capacity, __tsplusTrace);
|
1059
1319
|
}
|
1060
1320
|
/**
|
1321
|
+
* Runs both sinks in parallel on the input, using the specified merge
|
1322
|
+
* function as soon as one result or the other has been computed.
|
1323
|
+
*
|
1061
1324
|
* @tsplus fluent fncts.io.Sink raceWith
|
1062
1325
|
*/
|
1063
1326
|
|
@@ -1066,16 +1329,18 @@ function raceWith_1(self, that, leftDone, rightDone, capacity = () => 16, __tspl
|
|
1066
1329
|
const scoped = tsplus_module_9.defer(() => {
|
1067
1330
|
const that0 = that();
|
1068
1331
|
const capacity0 = capacity();
|
1069
|
-
return tsplus_module_9.flatMap_(
|
1332
|
+
return tsplus_module_9.flatMap_(tsplus_module_29.makeBounded(capacity()), hub => tsplus_module_9.flatMap_(tsplus_module_4.fromHubScoped(() => hub), c1 => tsplus_module_9.map_(tsplus_module_4.fromHubScoped(() => hub), c2 => {
|
1070
1333
|
const reader = tsplus_module_4.toHub(() => hub);
|
1071
|
-
const writer =
|
1072
|
-
const channel =
|
1334
|
+
const writer = tsplus_module_28.mergeWith_(tsplus_module_4.pipeTo_(c1, self.channel), tsplus_module_4.pipeTo_(c2, that0.channel), leftDone, rightDone);
|
1335
|
+
const channel = tsplus_module_28.mergeWith_(reader, writer, () => tsplus_module_27.wait(tsplus_module_9.fromExitNow), done => tsplus_module_27.done(tsplus_module_9.fromExitNow(done, __tsplusTrace)));
|
1073
1336
|
return new tsplus_module_3.Sink(channel);
|
1074
1337
|
}, __tsplusTrace), __tsplusTrace), __tsplusTrace);
|
1075
1338
|
}, __tsplusTrace);
|
1076
|
-
return unwrapScoped_1(() => scoped);
|
1339
|
+
return unwrapScoped_1(() => scoped, __tsplusTrace);
|
1077
1340
|
}
|
1078
1341
|
/**
|
1342
|
+
* Accesses the specified service in the environment of the effect.
|
1343
|
+
*
|
1079
1344
|
* @tsplus static fncts.io.SinkOps service
|
1080
1345
|
*/
|
1081
1346
|
|
@@ -1084,9 +1349,11 @@ function service(
|
|
1084
1349
|
/** @tsplus auto */
|
1085
1350
|
tag) {
|
1086
1351
|
const tag_1 = tag;
|
1087
|
-
return serviceWith_1(
|
1352
|
+
return serviceWith_1(tsplus_module_14.identity, tag_1);
|
1088
1353
|
}
|
1089
1354
|
/**
|
1355
|
+
* Accesses the specified service in the environment of the sink.
|
1356
|
+
*
|
1090
1357
|
* @tsplus static fncts.io.SinkOps serviceWith
|
1091
1358
|
*/
|
1092
1359
|
|
@@ -1094,9 +1361,12 @@ tag) {
|
|
1094
1361
|
function serviceWith_1(f,
|
1095
1362
|
/** @tsplus auto */
|
1096
1363
|
tag) {
|
1097
|
-
return fromIO_1(() =>
|
1364
|
+
return fromIO_1(() => tsplus_module_13.serviceWith(f, tag), fileName_1 + ":1526:21");
|
1098
1365
|
}
|
1099
1366
|
/**
|
1367
|
+
* Accesses the specified service in the environment of the sink in the
|
1368
|
+
* context of an effect.
|
1369
|
+
*
|
1100
1370
|
* @tsplus static fncts.io.SinkOps serviceWithIO
|
1101
1371
|
*/
|
1102
1372
|
|
@@ -1104,9 +1374,12 @@ tag) {
|
|
1104
1374
|
function serviceWithIO(f,
|
1105
1375
|
/** @tsplus auto */
|
1106
1376
|
tag) {
|
1107
|
-
return fromIO_1(() =>
|
1377
|
+
return fromIO_1(() => tsplus_module_13.serviceWithIO(f, tag, fileName_1 + ":1539:38"), fileName_1 + ":1539:21");
|
1108
1378
|
}
|
1109
1379
|
/**
|
1380
|
+
* Accesses the specified service in the environment of the sink in the
|
1381
|
+
* context of a sink.
|
1382
|
+
*
|
1110
1383
|
* @tsplus static fncts.io.SinkOps serviceWithSink
|
1111
1384
|
*/
|
1112
1385
|
|
@@ -1114,14 +1387,18 @@ tag) {
|
|
1114
1387
|
function serviceWithSink(f,
|
1115
1388
|
/** @tsplus auto */
|
1116
1389
|
tag) {
|
1117
|
-
return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() =>
|
1390
|
+
return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_13.serviceWith(tsplus_module_14.compose_(f, s => s.channel), tag)));
|
1118
1391
|
}
|
1119
1392
|
/**
|
1393
|
+
* Splits the sink on the specified predicate, returning a new sink that
|
1394
|
+
* consumes elements until an element after the first satisfies the specified
|
1395
|
+
* predicate.
|
1396
|
+
*
|
1120
1397
|
* @tsplus fluent fncts.io.Sink splitWhere
|
1121
1398
|
*/
|
1122
1399
|
|
1123
1400
|
|
1124
|
-
function splitWhere(self, p) {
|
1401
|
+
function splitWhere(self, p, __tsplusTrace) {
|
1125
1402
|
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
1403
|
}
|
1127
1404
|
|
@@ -1130,7 +1407,7 @@ function splitter(p, written, leftovers) {
|
|
1130
1407
|
if (tsplus_module_2.isEmpty(inp)) {
|
1131
1408
|
return splitter(p, written, leftovers);
|
1132
1409
|
} else if (written) {
|
1133
|
-
const index =
|
1410
|
+
const index = tsplus_module_30.findIndex(inp, p);
|
1134
1411
|
|
1135
1412
|
if (index === -1) {
|
1136
1413
|
return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(inp), splitter(p, true, leftovers));
|
@@ -1139,7 +1416,7 @@ function splitter(p, written, leftovers) {
|
|
1139
1416
|
return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(left), tsplus_module_4.fromIO(() => tsplus_module_6.set_(leftovers, right)));
|
1140
1417
|
}
|
1141
1418
|
} else {
|
1142
|
-
const index =
|
1419
|
+
const index = tsplus_module_30.findIndex(inp, p);
|
1143
1420
|
|
1144
1421
|
if (index === -1) {
|
1145
1422
|
return tsplus_module_5.apSecond_(tsplus_module_4.writeNow(inp), splitter(p, true, leftovers));
|
@@ -1151,6 +1428,8 @@ function splitter(p, written, leftovers) {
|
|
1151
1428
|
}, tsplus_module_5.failCauseNow, tsplus_module_5.succeedNow);
|
1152
1429
|
}
|
1153
1430
|
/**
|
1431
|
+
* A sink that immediately ends with the specified value.
|
1432
|
+
*
|
1154
1433
|
* @tsplus static fncts.io.SinkOps succeed
|
1155
1434
|
*/
|
1156
1435
|
|
@@ -1159,6 +1438,8 @@ function succeed(z, __tsplusTrace) {
|
|
1159
1438
|
return new tsplus_module_3.Sink(tsplus_module_5.succeed(z));
|
1160
1439
|
}
|
1161
1440
|
/**
|
1441
|
+
* A sink that immediately ends with the specified value.
|
1442
|
+
*
|
1162
1443
|
* @tsplus static fncts.io.SinkOps succeedNow
|
1163
1444
|
*/
|
1164
1445
|
|
@@ -1167,6 +1448,9 @@ function succeedNow(z, __tsplusTrace) {
|
|
1167
1448
|
return new tsplus_module_3.Sink(tsplus_module_5.succeedNow(z));
|
1168
1449
|
}
|
1169
1450
|
/**
|
1451
|
+
* Summarize a sink by running an effect when the sink starts and again when
|
1452
|
+
* it completes
|
1453
|
+
*
|
1170
1454
|
* @tsplus fluent fncts.io.Sink summarized
|
1171
1455
|
*/
|
1172
1456
|
|
@@ -1180,15 +1464,17 @@ function summarized_1(self, summary, f, __tsplusTrace) {
|
|
1180
1464
|
|
1181
1465
|
|
1182
1466
|
function timed(self, __tsplusTrace) {
|
1183
|
-
return summarized_1(self, () =>
|
1467
|
+
return summarized_1(self, () => tsplus_module_31.currentTime, (start, end) => tsplus_module_32.fromInterval(start, end), __tsplusTrace);
|
1184
1468
|
}
|
1185
1469
|
/**
|
1470
|
+
* Creates a sink produced from an effect.
|
1471
|
+
*
|
1186
1472
|
* @tsplus static fncts.io.SinkOps unwrap
|
1187
1473
|
*/
|
1188
1474
|
|
1189
1475
|
|
1190
1476
|
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 + ":
|
1477
|
+
return new tsplus_module_3.Sink(tsplus_module_4.unwrap(() => tsplus_module_9.map_(io(), sink => sink.channel, fileName_1 + ":1678:42")));
|
1192
1478
|
}
|
1193
1479
|
/**
|
1194
1480
|
* Creates a sink produced from a scoped effect.
|
@@ -1197,24 +1483,31 @@ function unwrap_1(io) {
|
|
1197
1483
|
*/
|
1198
1484
|
|
1199
1485
|
|
1200
|
-
function unwrapScoped_1(scoped) {
|
1201
|
-
return new tsplus_module_3.Sink(tsplus_module_4.unwrapScoped(() => tsplus_module_9.map_(scoped(), sink => sink.channel,
|
1486
|
+
function unwrapScoped_1(scoped, __tsplusTrace) {
|
1487
|
+
return new tsplus_module_3.Sink(tsplus_module_4.unwrapScoped(() => tsplus_module_9.map_(scoped(), sink => sink.channel, __tsplusTrace)));
|
1202
1488
|
}
|
1203
1489
|
/**
|
1490
|
+
* Feeds inputs to this sink until it yields a result, then switches over to
|
1491
|
+
* the provided sink until it yields a result, finally combining the two
|
1492
|
+
* results into a tuple.
|
1493
|
+
*
|
1204
1494
|
* @tsplus fluent fncts.io.Sink zip
|
1205
1495
|
*/
|
1206
1496
|
|
1207
1497
|
|
1208
|
-
function zip(self, that) {
|
1209
|
-
return zipWith_1(() => self, that,
|
1498
|
+
function zip(self, that, __tsplusTrace) {
|
1499
|
+
return zipWith_1(() => self, that, tsplus_module_14.tuple, __tsplusTrace);
|
1210
1500
|
}
|
1211
1501
|
/**
|
1502
|
+
* Runs both sinks in parallel on the input and combines the results in a
|
1503
|
+
* tuple.
|
1504
|
+
*
|
1212
1505
|
* @tsplus fluent fncts.io.Sink zipC
|
1213
1506
|
*/
|
1214
1507
|
|
1215
1508
|
|
1216
|
-
function zipC(self, that) {
|
1217
|
-
return zipWithC_1(() => self, that,
|
1509
|
+
function zipC(self, that, __tsplusTrace) {
|
1510
|
+
return zipWithC_1(() => self, that, tsplus_module_14.tuple, __tsplusTrace);
|
1218
1511
|
}
|
1219
1512
|
/**
|
1220
1513
|
* Feeds inputs to this sink until it yields a result, then switches over to
|
@@ -1225,8 +1518,8 @@ function zipC(self, that) {
|
|
1225
1518
|
*/
|
1226
1519
|
|
1227
1520
|
|
1228
|
-
function zipWith_1(self, that, f) {
|
1229
|
-
return defer_1(() => flatMap_1(self(), z => map_1(that(), z1 => f(z, z1),
|
1521
|
+
function zipWith_1(self, that, f, __tsplusTrace) {
|
1522
|
+
return defer_1(() => flatMap_1(self(), z => map_1(that(), z1 => f(z, z1), __tsplusTrace), __tsplusTrace), __tsplusTrace);
|
1230
1523
|
}
|
1231
1524
|
/**
|
1232
1525
|
* Runs both sinks in parallel on the input and combines the results using the
|
@@ -1236,7 +1529,7 @@ function zipWith_1(self, that, f) {
|
|
1236
1529
|
*/
|
1237
1530
|
|
1238
1531
|
|
1239
|
-
function zipWithC_1(self, that, f) {
|
1240
|
-
return defer_1(() => raceWith_1(self(), () => that(), exit =>
|
1532
|
+
function zipWithC_1(self, that, f, __tsplusTrace) {
|
1533
|
+
return defer_1(() => raceWith_1(self(), () => that(), exit => tsplus_module_33.match_(exit, err => tsplus_module_27.done(tsplus_module_9.failCauseNow(err, __tsplusTrace)), lz => tsplus_module_27.wait(exit => tsplus_module_33.match_(exit, cause => tsplus_module_9.failCauseNow(cause, __tsplusTrace), rz => tsplus_module_9.succeedNow(f(lz, rz), __tsplusTrace)))), exit => tsplus_module_33.match_(exit, err => tsplus_module_27.done(tsplus_module_9.failCauseNow(err, __tsplusTrace)), rz => tsplus_module_27.wait(exit => tsplus_module_33.match_(exit, cause => tsplus_module_9.failCauseNow(cause, __tsplusTrace), lz => tsplus_module_9.succeedNow(f(lz, rz), __tsplusTrace))))), __tsplusTrace);
|
1241
1534
|
}
|
1242
1535
|
//# sourceMappingURL=api.cjs.map
|