@fncts/io 0.0.42 → 0.0.44
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/IO/api.d.ts +11 -5
- package/IO.d.ts +1 -0
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +2 -8
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +14 -23
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeWith.cjs +4 -16
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +18 -33
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +2 -8
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
- package/_cjs/IO/api/asyncInterrupt.cjs +4 -7
- package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
- package/_cjs/IO/api.cjs +31 -47
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +3 -6
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +11 -0
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +2 -5
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Push/api.cjs +1 -4
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Ref/Derived.cjs +8 -35
- package/_cjs/Ref/Derived.cjs.map +1 -1
- package/_cjs/Ref/DerivedAll.cjs +8 -35
- package/_cjs/Ref/DerivedAll.cjs.map +1 -1
- package/_cjs/STM/api/core-api.cjs +1 -4
- package/_cjs/STM/api/core-api.cjs.map +1 -1
- package/_cjs/STM/api.cjs +4 -16
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/Schedule/api.cjs +1 -7
- package/_cjs/Schedule/api.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +1 -7
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Stream/api/zipAllWith.cjs +1 -4
- package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWithChunks.cjs +1 -4
- package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +16 -37
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/TRef/definition.cjs +20 -74
- package/_cjs/TRef/definition.cjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +2 -8
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs.map +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +14 -23
- package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
- package/_mjs/Channel/api/mergeWith.mjs +4 -16
- package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
- package/_mjs/Channel/api.mjs +18 -33
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +2 -8
- package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
- package/_mjs/IO/api/asyncInterrupt.mjs +4 -7
- package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
- package/_mjs/IO/api.mjs +29 -45
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +3 -6
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +1 -0
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/Layer/api.mjs +2 -5
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Push/api.mjs +1 -4
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Ref/Derived.mjs +8 -35
- package/_mjs/Ref/Derived.mjs.map +1 -1
- package/_mjs/Ref/DerivedAll.mjs +8 -35
- package/_mjs/Ref/DerivedAll.mjs.map +1 -1
- package/_mjs/STM/api/core-api.mjs +1 -4
- package/_mjs/STM/api/core-api.mjs.map +1 -1
- package/_mjs/STM/api.mjs +4 -16
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/Schedule/api.mjs +1 -7
- package/_mjs/Schedule/api.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +1 -7
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Stream/api/zipAllWith.mjs +1 -4
- package/_mjs/Stream/api/zipAllWith.mjs.map +1 -1
- package/_mjs/Stream/api/zipWithChunks.mjs +1 -4
- package/_mjs/Stream/api/zipWithChunks.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +16 -37
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/TRef/definition.mjs +20 -74
- package/_mjs/TRef/definition.mjs.map +1 -1
- package/_src/Channel/api/mapOutConcurrentIO.ts +5 -5
- package/_src/Channel/api/mergeAllWith.ts +9 -9
- package/_src/Channel/api/mergeWith.ts +16 -16
- package/_src/Channel/api.ts +12 -32
- package/_src/Channel/internal/SingleProducerAsyncInput.ts +2 -2
- package/_src/IO/api/asyncInterrupt.ts +4 -4
- package/_src/IO/api.ts +46 -40
- package/_src/IO/runtime.ts +3 -6
- package/_src/IO.ts +1 -0
- package/_src/Layer/api.ts +1 -4
- package/_src/Push/api.ts +4 -4
- package/_src/Ref/Derived.ts +18 -20
- package/_src/Ref/DerivedAll.ts +18 -21
- package/_src/STM/api/core-api.ts +1 -1
- package/_src/STM/api.ts +4 -4
- package/_src/Schedule/api.ts +8 -8
- package/_src/Sink/api.ts +8 -8
- package/_src/Stream/api/zipAllWith.ts +4 -4
- package/_src/Stream/api/zipWithChunks.ts +4 -4
- package/_src/Stream/api.ts +20 -22
- package/_src/TRef/definition.ts +33 -36
- package/_src/index.ts +1 -0
- package/index.d.ts +1 -0
- package/package.json +4 -4
package/_src/Stream/api.ts
CHANGED
@@ -3,7 +3,7 @@ import type { Canceler } from "../IO.js";
|
|
3
3
|
import type { PDequeue, PEnqueue, PQueue } from "../Queue.js";
|
4
4
|
import type { SinkEndReason } from "./internal/SinkEndReason.js";
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { identity, tuple } from "@fncts/base/data/function";
|
7
7
|
|
8
8
|
import { MergeDecision } from "../Channel/internal/MergeDecision.js";
|
9
9
|
import { Hub } from "../Hub.js";
|
@@ -56,9 +56,7 @@ export function aggregateAsyncWithin<R1, E1, A1, B, R2, C>(
|
|
56
56
|
__tsplusTrace?: string,
|
57
57
|
) {
|
58
58
|
return <R, E, A extends A1>(stream: Stream<R, E, A>): Stream<R | R1 | R2, E | E1, B> => {
|
59
|
-
return stream
|
60
|
-
.aggregateAsyncWithinEither(sink, schedule)
|
61
|
-
.filterMap((cb) => cb.match({ Left: () => Nothing(), Right: Maybe.just }));
|
59
|
+
return stream.aggregateAsyncWithinEither(sink, schedule).filterMap((cb) => cb.match(() => Nothing(), Maybe.just));
|
62
60
|
};
|
63
61
|
}
|
64
62
|
|
@@ -167,14 +165,14 @@ export function aggregateAsyncWithinEither<R1, E1, A1, B, R2, C>(
|
|
167
165
|
(scheduleExit, sinkFiber) =>
|
168
166
|
IO.fromExit(scheduleExit).matchCauseIO(
|
169
167
|
(cause) =>
|
170
|
-
cause.failureOrCause.match(
|
171
|
-
|
168
|
+
cause.failureOrCause.match(
|
169
|
+
() =>
|
172
170
|
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
173
171
|
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
174
|
-
|
172
|
+
(cause) =>
|
175
173
|
handoff.offer(HandoffSignal.Halt(cause)).forkDaemon >
|
176
174
|
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Nothing())),
|
177
|
-
|
175
|
+
),
|
178
176
|
(c) =>
|
179
177
|
handoff.offer(HandoffSignal.End(new ScheduleEnd())).forkDaemon >
|
180
178
|
sinkFiber.join.map(([leftovers, b]) => handleSide(leftovers, b, Just(c))),
|
@@ -257,8 +255,8 @@ export function asyncInterrupt<R, E, A>(
|
|
257
255
|
}),
|
258
256
|
),
|
259
257
|
);
|
260
|
-
return eitherStream.match(
|
261
|
-
|
258
|
+
return eitherStream.match(
|
259
|
+
(canceler) => {
|
262
260
|
const loop: Channel<never, unknown, unknown, unknown, E, Conc<A>, void> = Channel.unwrap(
|
263
261
|
output.take
|
264
262
|
.flatMap((take) => take.done)
|
@@ -269,8 +267,8 @@ export function asyncInterrupt<R, E, A>(
|
|
269
267
|
);
|
270
268
|
return new Stream(loop).ensuring(canceler);
|
271
269
|
},
|
272
|
-
|
273
|
-
|
270
|
+
(stream) => Stream.unwrap(output.shutdown.as(stream)),
|
271
|
+
);
|
274
272
|
}),
|
275
273
|
);
|
276
274
|
}
|
@@ -338,10 +336,10 @@ export function asyncIO<R, E, A, R1 = R, E1 = E>(
|
|
338
336
|
.matchCauseIO(
|
339
337
|
(cause) =>
|
340
338
|
output.shutdown.as(
|
341
|
-
cause.failureOrCause.match(
|
342
|
-
|
343
|
-
|
344
|
-
|
339
|
+
cause.failureOrCause.match(
|
340
|
+
(maybeError) => maybeError.match(() => Channel.endNow(undefined), Channel.failNow),
|
341
|
+
Channel.failCauseNow,
|
342
|
+
),
|
345
343
|
),
|
346
344
|
(as) => IO.succeed(Channel.writeNow(as) > loop),
|
347
345
|
),
|
@@ -579,7 +577,7 @@ function bufferSignalConsumer<R, E, A>(
|
|
579
577
|
*/
|
580
578
|
export function catchAll<R1, E, E1, A1>(f: (e: E) => Stream<R1, E1, A1>, __tsplusTrace?: string) {
|
581
579
|
return <R, A>(stream: Stream<R, E, A>): Stream<R | R1, E1, A | A1> => {
|
582
|
-
return stream.catchAllCause((cause) => cause.failureOrCause.match(
|
580
|
+
return stream.catchAllCause((cause) => cause.failureOrCause.match(f, Stream.failCauseNow));
|
583
581
|
};
|
584
582
|
}
|
585
583
|
|
@@ -3230,7 +3228,7 @@ export function toPull<R, E, A>(
|
|
3230
3228
|
__tsplusTrace?: string,
|
3231
3229
|
): IO<R | Scope, never, IO<R, Maybe<E>, Conc<A>>> {
|
3232
3230
|
return stream.channel.toPull.map((io) =>
|
3233
|
-
io.mapError(Maybe.just).flatMap((r) => r.match(
|
3231
|
+
io.mapError(Maybe.just).flatMap((r) => r.match(() => IO.failNow(Nothing()), IO.succeedNow)),
|
3234
3232
|
);
|
3235
3233
|
}
|
3236
3234
|
|
@@ -3487,22 +3485,22 @@ export function zipWithLatest<A, R1, E1, B, C>(fb: Stream<R1, E1, B>, f: (a: A,
|
|
3487
3485
|
Stream.repeatIOMaybe(left)
|
3488
3486
|
.mergeEither(Stream.repeatIOMaybe(right))
|
3489
3487
|
.mapIO((ab) =>
|
3490
|
-
ab.match(
|
3491
|
-
|
3488
|
+
ab.match(
|
3489
|
+
(leftChunk) =>
|
3492
3490
|
latest.modify(([_, rightLatest]) =>
|
3493
3491
|
tuple(
|
3494
3492
|
leftChunk.map((a) => f(a, rightLatest)),
|
3495
3493
|
tuple(leftChunk.unsafeGet(leftChunk.length - 1), rightLatest),
|
3496
3494
|
),
|
3497
3495
|
),
|
3498
|
-
|
3496
|
+
(rightChunk) =>
|
3499
3497
|
latest.modify(([leftLatest, _]) =>
|
3500
3498
|
tuple(
|
3501
3499
|
rightChunk.map((b) => f(leftLatest, b)),
|
3502
3500
|
tuple(leftLatest, rightChunk.unsafeGet(rightChunk.length - 1)),
|
3503
3501
|
),
|
3504
3502
|
),
|
3505
|
-
|
3503
|
+
),
|
3506
3504
|
)
|
3507
3505
|
.flatMap(Stream.fromChunkNow),
|
3508
3506
|
),
|
package/_src/TRef/definition.ts
CHANGED
@@ -162,8 +162,8 @@ export class Derived<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
162
162
|
(getEither, setEither, value, atomic) =>
|
163
163
|
new Derived((f) =>
|
164
164
|
f(
|
165
|
-
(s) => getEither(s).match(
|
166
|
-
(c) => ca(c).flatMap((a) => setEither(a).match(
|
165
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
166
|
+
(c) => ca(c).flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
|
167
167
|
value,
|
168
168
|
atomic,
|
169
169
|
),
|
@@ -181,11 +181,11 @@ export class Derived<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
181
181
|
(getEither, setEither, value, atomic) =>
|
182
182
|
new DerivedAll((f) =>
|
183
183
|
f(
|
184
|
-
(s) => getEither(s).match(
|
184
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
185
185
|
(c) => (s) =>
|
186
186
|
getEither(s)
|
187
|
-
.match(
|
188
|
-
.flatMap((a) => setEither(a).match(
|
187
|
+
.match((e) => Either.left(ec(e)), ca(c))
|
188
|
+
.flatMap((a) => setEither(a).match((e) => Either.left(ea(e)), Either.right)),
|
189
189
|
value,
|
190
190
|
atomic,
|
191
191
|
),
|
@@ -195,29 +195,27 @@ export class Derived<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
195
195
|
|
196
196
|
get get(): STM<never, EB, B> {
|
197
197
|
return this.use((getEither, _setEither, value, _atomic) =>
|
198
|
-
value.get.flatMap((s) => getEither(s).match(
|
198
|
+
value.get.flatMap((s) => getEither(s).match(STM.failNow, STM.succeedNow)),
|
199
199
|
);
|
200
200
|
}
|
201
201
|
|
202
202
|
set(a: A, __tsplusTrace?: string | undefined): STM<never, EA, void> {
|
203
|
-
return this.use((_getEither, setEither, value, _atomic) =>
|
204
|
-
setEither(a).match({ Left: STM.failNow, Right: (s) => value.set(s) }),
|
205
|
-
);
|
203
|
+
return this.use((_getEither, setEither, value, _atomic) => setEither(a).match(STM.failNow, (s) => value.set(s)));
|
206
204
|
}
|
207
205
|
|
208
206
|
modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): STM<never, EA | EB, C> {
|
209
207
|
return this.use((getEither, setEither, value, _atomic) =>
|
210
208
|
value.modify((s) =>
|
211
|
-
getEither(s).match(
|
212
|
-
|
213
|
-
|
209
|
+
getEither(s).match(
|
210
|
+
(e) => [Either.left<EA | EB, C>(e), s],
|
211
|
+
(a1) => {
|
214
212
|
const [b, a2] = f(a1);
|
215
|
-
return setEither(a2).match(
|
216
|
-
|
217
|
-
|
218
|
-
|
213
|
+
return setEither(a2).match(
|
214
|
+
(e) => [Either.left(e), s],
|
215
|
+
(s) => [Either.right(b), s],
|
216
|
+
);
|
219
217
|
},
|
220
|
-
|
218
|
+
),
|
221
219
|
),
|
222
220
|
).absolve;
|
223
221
|
}
|
@@ -258,9 +256,8 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
258
256
|
(getEither, setEither, value, atomic) =>
|
259
257
|
new DerivedAll((f) =>
|
260
258
|
f(
|
261
|
-
(s) => getEither(s).match(
|
262
|
-
(c) => (s) =>
|
263
|
-
ca(c).flatMap((a) => setEither(a)(s).match({ Left: (e) => Either.left(ea(e)), Right: Either.right })),
|
259
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
260
|
+
(c) => (s) => ca(c).flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
|
264
261
|
value,
|
265
262
|
atomic,
|
266
263
|
),
|
@@ -278,11 +275,11 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
278
275
|
(getEither, setEither, value, atomic) =>
|
279
276
|
new DerivedAll((f) =>
|
280
277
|
f(
|
281
|
-
(s) => getEither(s).match(
|
278
|
+
(s) => getEither(s).match((e) => Either.left(eb(e)), bd),
|
282
279
|
(c) => (s) =>
|
283
280
|
getEither(s)
|
284
|
-
.match(
|
285
|
-
.flatMap((a) => setEither(a)(s).match(
|
281
|
+
.match((e) => Either.left(ec(e)), ca(c))
|
282
|
+
.flatMap((a) => setEither(a)(s).match((e) => Either.left(ea(e)), Either.right)),
|
286
283
|
value,
|
287
284
|
atomic,
|
288
285
|
),
|
@@ -292,17 +289,17 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
292
289
|
|
293
290
|
get get(): STM<never, EB, B> {
|
294
291
|
return this.use((getEither, _setEither, value, _atomic) =>
|
295
|
-
value.get.flatMap((s) => getEither(s).match(
|
292
|
+
value.get.flatMap((s) => getEither(s).match(STM.failNow, STM.succeedNow)),
|
296
293
|
);
|
297
294
|
}
|
298
295
|
|
299
296
|
set(a: A, __tsplusTrace?: string | undefined): STM<never, EA, void> {
|
300
297
|
return this.use((_getEither, setEither, value, _atomic) =>
|
301
298
|
value.modify((s) =>
|
302
|
-
setEither(a)(s).match(
|
303
|
-
|
304
|
-
|
305
|
-
|
299
|
+
setEither(a)(s).match(
|
300
|
+
(e) => [Either.left(e), s] as [Either<EA, void>, typeof s],
|
301
|
+
(s) => [Either.right(undefined), s],
|
302
|
+
),
|
306
303
|
),
|
307
304
|
).absolve;
|
308
305
|
}
|
@@ -310,16 +307,16 @@ export class DerivedAll<EA, EB, A, B> extends TRefInternal<EA, EB, A, B> {
|
|
310
307
|
modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): STM<never, EA | EB, C> {
|
311
308
|
return this.use((getEither, setEither, value, atomic) =>
|
312
309
|
value.modify((s) =>
|
313
|
-
getEither(s).match(
|
314
|
-
|
315
|
-
|
310
|
+
getEither(s).match(
|
311
|
+
(e) => [Either.left<EA | EB, C>(e), s],
|
312
|
+
(a1) => {
|
316
313
|
const [b, a2] = f(a1);
|
317
|
-
return setEither(a2)(s).match(
|
318
|
-
|
319
|
-
|
320
|
-
|
314
|
+
return setEither(a2)(s).match(
|
315
|
+
(e) => [Either.left(e), s],
|
316
|
+
(s) => [Either.right(b), s],
|
317
|
+
);
|
321
318
|
},
|
322
|
-
|
319
|
+
),
|
323
320
|
),
|
324
321
|
).absolve;
|
325
322
|
}
|
package/_src/index.ts
CHANGED
@@ -38,6 +38,7 @@ export type {} from "./IO.js";
|
|
38
38
|
export type {} from "./Hub.js";
|
39
39
|
export type {} from "./Future.js";
|
40
40
|
export type {} from "./FiberStatus.js";
|
41
|
+
export type {} from "./FiberSet.js";
|
41
42
|
export type {} from "./FiberScope.js";
|
42
43
|
export type {} from "./FiberRefs.js";
|
43
44
|
export type {} from "./FiberRef.js";
|
package/index.d.ts
CHANGED
@@ -36,6 +36,7 @@ export type {} from "./IO.js";
|
|
36
36
|
export type {} from "./Hub.js";
|
37
37
|
export type {} from "./Future.js";
|
38
38
|
export type {} from "./FiberStatus.js";
|
39
|
+
export type {} from "./FiberSet.js";
|
39
40
|
export type {} from "./FiberScope.js";
|
40
41
|
export type {} from "./FiberRefs.js";
|
41
42
|
export type {} from "./FiberRef.js";
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fncts/io",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.44",
|
4
4
|
"dependencies": {
|
5
|
-
"@fncts/base": "0.0.
|
6
|
-
"@fncts/transformers": "0.0.
|
7
|
-
"@fncts/typelevel": "0.0.
|
5
|
+
"@fncts/base": "0.0.36",
|
6
|
+
"@fncts/transformers": "0.0.9",
|
7
|
+
"@fncts/typelevel": "0.0.18"
|
8
8
|
},
|
9
9
|
"exports": {
|
10
10
|
"./*": {
|