@fncts/io 0.0.35 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Fiber/constructors.d.ts +5 -0
- package/Push/api.d.ts +70 -41
- package/Push/definition.d.ts +11 -13
- package/Push/internal.d.ts +7 -11
- package/RefSubject/Atomic.d.ts +8 -11
- package/RefSubject/Synchronized/definition.d.ts +4 -6
- package/RefSubject/api.d.ts +0 -1
- package/RefSubject/definition.d.ts +6 -8
- package/STM/definition.d.ts +17 -0
- package/Sink/api.d.ts +6 -6
- package/Subject/Atomic.d.ts +4 -6
- package/Subject/definition.d.ts +2 -2
- package/_cjs/Fiber/constructors.cjs +10 -2
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Push/api.cjs +206 -175
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/definition.cjs +12 -13
- package/_cjs/Push/definition.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +37 -29
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/RefSubject/Atomic.cjs +15 -19
- package/_cjs/RefSubject/Atomic.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +9 -10
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
- package/_cjs/RefSubject/api.cjs +5 -6
- package/_cjs/RefSubject/api.cjs.map +1 -1
- package/_cjs/RefSubject/definition.cjs.map +1 -1
- package/_cjs/STM/api.cjs +2 -2
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +13 -13
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +4 -5
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +7 -1
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Push/api.mjs +194 -173
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Push/definition.mjs +9 -10
- package/_mjs/Push/definition.mjs.map +1 -1
- package/_mjs/Push/internal.mjs +33 -22
- package/_mjs/Push/internal.mjs.map +1 -1
- package/_mjs/RefSubject/Atomic.mjs +15 -19
- package/_mjs/RefSubject/Atomic.mjs.map +1 -1
- package/_mjs/RefSubject/Synchronized/definition.mjs +9 -10
- package/_mjs/RefSubject/Synchronized/definition.mjs.map +1 -1
- package/_mjs/RefSubject/api.mjs +6 -7
- package/_mjs/RefSubject/api.mjs.map +1 -1
- package/_mjs/RefSubject/definition.mjs.map +1 -1
- package/_mjs/STM/api.mjs +2 -2
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/STM/definition.mjs.map +1 -1
- package/_mjs/Sink/api.mjs +10 -10
- package/_mjs/Sink/api.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +4 -5
- package/_mjs/Subject/Atomic.mjs.map +1 -1
- package/_src/Fiber/constructors.ts +5 -0
- package/_src/IO/definition.ts +0 -1
- package/_src/Layer/api.ts +0 -1
- package/_src/Push/api.ts +270 -335
- package/_src/Push/definition.ts +13 -17
- package/_src/Push/internal.ts +63 -31
- package/_src/RefSubject/Atomic.ts +16 -22
- package/_src/RefSubject/Synchronized/definition.ts +6 -9
- package/_src/RefSubject/api.ts +9 -12
- package/_src/RefSubject/definition.ts +6 -8
- package/_src/STM/api.ts +0 -5
- package/_src/STM/definition.ts +6 -0
- package/_src/Sink/api.ts +9 -9
- package/_src/Subject/Atomic.ts +6 -8
- package/_src/Subject/definition.ts +2 -2
- package/package.json +2 -2
package/_src/Push/definition.ts
CHANGED
@@ -15,7 +15,7 @@ export class Push<R, E, A> {
|
|
15
15
|
readonly _E: (_: never) => E;
|
16
16
|
readonly _A: (_: never) => A;
|
17
17
|
};
|
18
|
-
constructor(readonly run: <R1>(emitter:
|
18
|
+
constructor(readonly run: <R1>(emitter: Sink<R1, E, A>) => IO<R | R1, never, unknown>) {}
|
19
19
|
}
|
20
20
|
|
21
21
|
export declare namespace Push {
|
@@ -25,33 +25,29 @@ export declare namespace Push {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
/**
|
28
|
-
* @tsplus type fncts.io.Push.
|
29
|
-
* @tsplus companion fncts.io.Push.
|
28
|
+
* @tsplus type fncts.io.Push.Sink
|
29
|
+
* @tsplus companion fncts.io.Push.SinkOps
|
30
30
|
*/
|
31
|
-
export class
|
31
|
+
export class Sink<R, E, A> {
|
32
32
|
constructor(
|
33
|
-
readonly
|
34
|
-
readonly
|
35
|
-
readonly end: IO<R, never, void>,
|
33
|
+
readonly event: (value: A) => IO<R, never, void>,
|
34
|
+
readonly error: (cause: Cause<E>) => IO<R, never, void>,
|
36
35
|
) {}
|
37
36
|
}
|
38
37
|
|
39
38
|
/**
|
40
39
|
* @tsplus static fncts.io.PushOps __call
|
41
40
|
*/
|
42
|
-
export function makePush<R, E, A>(
|
43
|
-
run: <R1>(emitter: Emitter<R1, E, A>) => IO<R | R1 | Scope, never, unknown>,
|
44
|
-
): Push<R, E, A> {
|
41
|
+
export function makePush<R, E, A>(run: <R1>(sink: Sink<R1, E, A>) => IO<R | R1, never, unknown>): Push<R, E, A> {
|
45
42
|
return new Push(run);
|
46
43
|
}
|
47
44
|
|
48
45
|
/**
|
49
|
-
* @tsplus static fncts.io.Push.
|
46
|
+
* @tsplus static fncts.io.Push.SinkOps __call
|
50
47
|
*/
|
51
|
-
export function
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
return new Emitter(emit, failCause, end);
|
48
|
+
export function makeSink<R, E, A>(
|
49
|
+
value: (value: A) => IO<R, never, unknown>,
|
50
|
+
error: (cause: Cause<E>) => IO<R, never, unknown>,
|
51
|
+
): Sink<R, E, A> {
|
52
|
+
return new Sink(value, error);
|
57
53
|
}
|
package/_src/Push/internal.ts
CHANGED
@@ -1,39 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
): IO<R
|
6
|
-
return
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
import type { RuntimeFiber } from "@fncts/io/Fiber";
|
2
|
+
|
3
|
+
export function withScopedFork<R, E, A>(
|
4
|
+
f: (fork: <R, E, A>(io: IO<R, E, A>) => IO<R, never, RuntimeFiber<E, A>>) => IO<R, E, A>,
|
5
|
+
): IO<R, E, A> {
|
6
|
+
return IO.bracketExit(
|
7
|
+
Scope.make,
|
8
|
+
(scope) => f((io) => io.forkIn(scope)),
|
9
|
+
(scope, exit) => scope.close(exit),
|
10
|
+
);
|
11
11
|
}
|
12
12
|
|
13
|
-
export
|
14
|
-
|
13
|
+
export function withSwitch<R, E, A>(f: (fork: <R>(io: URIO<R, void>) => URIO<R, void>) => IO<R, E, A>) {
|
14
|
+
return withScopedFork((fork) =>
|
15
|
+
Do((Δ) => {
|
16
|
+
const ref = Δ(Ref.Synchronized.make<Fiber<never, void>>(Fiber.unit));
|
17
|
+
|
18
|
+
const switchFork = <R>(io: URIO<R, void>) => {
|
19
|
+
return ref.updateIO((currentFiber) => currentFiber.interruptFork.flatMap(() => fork(io)));
|
20
|
+
};
|
21
|
+
|
22
|
+
Δ(f(switchFork));
|
23
|
+
|
24
|
+
const fiber = Δ(ref.get);
|
15
25
|
|
16
|
-
|
17
|
-
|
26
|
+
Δ(fiber.join.when(fiber !== undefined));
|
27
|
+
}),
|
28
|
+
);
|
18
29
|
}
|
19
30
|
|
20
|
-
export function
|
21
|
-
|
31
|
+
export function withUnboundedConcurrency<R, E, A>(
|
32
|
+
f: (fork: <R>(io: URIO<R, void>) => URIO<R, RuntimeFiber<never, void>>) => IO<R, E, A>,
|
33
|
+
) {
|
34
|
+
return withScopedFork((fork) =>
|
35
|
+
Do((Δ) => {
|
36
|
+
const fibers = Δ(IO.succeed(new Set<RuntimeFiber<never, void>>()));
|
37
|
+
Δ(
|
38
|
+
f((io) =>
|
39
|
+
Do((Δ) => {
|
40
|
+
const fiber = Δ(fork(io));
|
41
|
+
Δ(IO(fibers.add(fiber)));
|
42
|
+
Δ(fork(fiber.join.ensuring(IO(fibers.delete(fiber)))));
|
43
|
+
return fiber;
|
44
|
+
}),
|
45
|
+
),
|
46
|
+
);
|
47
|
+
Δ(Fiber.joinAll(fibers));
|
48
|
+
}),
|
49
|
+
);
|
22
50
|
}
|
23
51
|
|
24
|
-
export
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
52
|
+
export function withExhaust<R, E, A>(f: (fork: <R>(io: URIO<R, void>) => URIO<R, void>) => IO<R, E, A>) {
|
53
|
+
return withScopedFork((fork) =>
|
54
|
+
Do((Δ) => {
|
55
|
+
const ref = Δ(Ref.make<RuntimeFiber<never, void> | null>(null));
|
56
|
+
const reset = ref.set(null);
|
57
|
+
|
58
|
+
const exhaustFork = <R>(io: IO<R, never, void>) =>
|
59
|
+
io
|
60
|
+
.ensuring(reset)
|
61
|
+
.fork.flatMap((fiber) => ref.set(fiber))
|
62
|
+
.whenRef(ref, (fiber) => fiber === null).asUnit;
|
63
|
+
|
64
|
+
Δ(f(exhaustFork));
|
65
|
+
|
66
|
+
const fiber = Δ(ref.get);
|
67
|
+
|
68
|
+
Δ(IO.defer(fiber === null ? IO.unit : fiber.join));
|
69
|
+
}),
|
70
|
+
);
|
39
71
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Sink } from "@fncts/io/Push";
|
2
2
|
|
3
3
|
import { AtomicReference } from "@fncts/base/internal/AtomicReference";
|
4
4
|
import { Hold, Push } from "@fncts/io/Push";
|
@@ -7,7 +7,7 @@ import { RefSubjectInternal } from "@fncts/io/RefSubject/definition";
|
|
7
7
|
|
8
8
|
export class AtomicRefSubject<E, A> extends RefSubjectInternal<never, E, A, A> {
|
9
9
|
readonly stream = new Hold<never, E, A>(Push.never);
|
10
|
-
readonly maybeRef = new Atomic(this.stream.
|
10
|
+
readonly maybeRef = new Atomic(this.stream.current);
|
11
11
|
readonly ref = new AtomicEmitRef(
|
12
12
|
new AtomicDimapRef(
|
13
13
|
this.maybeRef,
|
@@ -19,7 +19,7 @@ export class AtomicRefSubject<E, A> extends RefSubjectInternal<never, E, A, A> {
|
|
19
19
|
|
20
20
|
constructor(readonly initial: A) {
|
21
21
|
super();
|
22
|
-
this.stream.
|
22
|
+
this.stream.current.set(Just(initial));
|
23
23
|
}
|
24
24
|
|
25
25
|
get get() {
|
@@ -38,30 +38,24 @@ export class AtomicRefSubject<E, A> extends RefSubjectInternal<never, E, A, A> {
|
|
38
38
|
return this.ref.modify(f);
|
39
39
|
}
|
40
40
|
|
41
|
-
run<R>(emitter:
|
41
|
+
run<R>(emitter: Sink<R, E, A>): IO<R, never, unknown> {
|
42
42
|
return this.stream.run(emitter);
|
43
43
|
}
|
44
44
|
|
45
|
-
|
46
|
-
return this.stream.
|
45
|
+
event(value: A): IO<never, never, void> {
|
46
|
+
return this.stream.event(value);
|
47
47
|
}
|
48
48
|
|
49
|
-
|
50
|
-
return this.stream.
|
49
|
+
error(cause: Cause<E>): IO<never, never, void> {
|
50
|
+
return this.stream.error(cause);
|
51
51
|
}
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
unsafeEmit(value: A): void {
|
56
|
-
this.stream.emit(value).unsafeRunFiber();
|
57
|
-
}
|
58
|
-
|
59
|
-
unsafeFailCause(cause: Cause<E>): void {
|
60
|
-
this.stream.failCause(cause).unsafeRunFiber();
|
53
|
+
unsafeEvent(value: A): void {
|
54
|
+
this.stream.event(value).unsafeRunFiber();
|
61
55
|
}
|
62
56
|
|
63
|
-
|
64
|
-
this.stream.
|
57
|
+
unsafeError(cause: Cause<E>): void {
|
58
|
+
this.stream.error(cause).unsafeRunFiber();
|
65
59
|
}
|
66
60
|
|
67
61
|
get unsafeGet(): A {
|
@@ -97,7 +91,7 @@ class AtomicDimapRef<A, B> extends Atomic<B> {
|
|
97
91
|
}
|
98
92
|
|
99
93
|
class AtomicEmitRef<E, A> extends Atomic<A> {
|
100
|
-
constructor(readonly ref: Atomic<A>, readonly
|
94
|
+
constructor(readonly ref: Atomic<A>, readonly sink: Sink<never, E, A>) {
|
101
95
|
super(ref.value);
|
102
96
|
}
|
103
97
|
|
@@ -111,14 +105,14 @@ class AtomicEmitRef<E, A> extends Atomic<A> {
|
|
111
105
|
|
112
106
|
unsafeSet(value: A) {
|
113
107
|
this.ref.unsafeSet(value);
|
114
|
-
this.
|
108
|
+
this.sink.event(value).unsafeRunFiber();
|
115
109
|
}
|
116
110
|
|
117
111
|
set(value: A, __tsplusTrace?: string) {
|
118
|
-
return this.ref.set(value) < this.
|
112
|
+
return this.ref.set(value) < this.sink.event(value);
|
119
113
|
}
|
120
114
|
|
121
115
|
modify<B>(f: (a: A) => readonly [B, A], __tsplusTrace?: string) {
|
122
|
-
return this.ref.modify(f) < this.ref.get.flatMap((value) => this.
|
116
|
+
return this.ref.modify(f) < this.ref.get.flatMap((value) => this.sink.event(value));
|
123
117
|
}
|
124
118
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { RefSubject } from "../definition.js";
|
2
2
|
import type { Cause } from "@fncts/base/data/Cause";
|
3
|
-
import type {
|
4
|
-
import type { Scope } from "@fncts/io/Scope";
|
3
|
+
import type { Sink } from "@fncts/io/Push";
|
5
4
|
|
6
5
|
import { IO } from "@fncts/io/IO";
|
7
6
|
|
@@ -44,7 +43,7 @@ export class SynchronizedRefSubjectInternal<R, E, A, B>
|
|
44
43
|
return this.withPermit(this.ref.set(a));
|
45
44
|
}
|
46
45
|
|
47
|
-
run<R1>(emitter:
|
46
|
+
run<R1>(emitter: Sink<R1, E, B>): IO<R | R1, never, void> {
|
48
47
|
return this.ref.run(emitter);
|
49
48
|
}
|
50
49
|
|
@@ -56,16 +55,14 @@ export class SynchronizedRefSubjectInternal<R, E, A, B>
|
|
56
55
|
return this.withPermit(this.ref.get.flatMap(f).flatMap(([b, a]) => this.ref.set(a).as(b)));
|
57
56
|
}
|
58
57
|
|
59
|
-
|
60
|
-
return this.withPermit(this.ref.
|
58
|
+
event(value: A): IO<R, never, void> {
|
59
|
+
return this.withPermit(this.ref.event(value));
|
61
60
|
}
|
62
61
|
|
63
|
-
|
64
|
-
return this.withPermit(this.ref.
|
62
|
+
error(cause: Cause<E>): IO<R, never, void> {
|
63
|
+
return this.withPermit(this.ref.error(cause));
|
65
64
|
}
|
66
65
|
|
67
|
-
end: IO<R, never, void> = this.withPermit(this.ref.end);
|
68
|
-
|
69
66
|
withPermit<R, E, A>(io: IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> {
|
70
67
|
return this.semaphore.withPermit(io);
|
71
68
|
}
|
package/_src/RefSubject/api.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { tuple } from "@fncts/base/data/function";
|
2
|
-
import {
|
2
|
+
import { Sink } from "@fncts/io/Push";
|
3
3
|
import { AtomicRefSubject } from "@fncts/io/RefSubject/Atomic";
|
4
4
|
|
5
5
|
import { RefSubject } from "./definition.js";
|
@@ -64,26 +64,23 @@ class Dimap<R, E, A, B, C, D> extends RefSubjectInternal<R, E, C, D> {
|
|
64
64
|
});
|
65
65
|
}
|
66
66
|
|
67
|
-
run<R1>(emitter:
|
67
|
+
run<R1>(emitter: Sink<R1, E, D>): IO<R | R1, never, void> {
|
68
68
|
return this.ref.run(
|
69
|
-
|
70
|
-
(value) => emitter.
|
71
|
-
(cause) => emitter.
|
72
|
-
emitter.end,
|
69
|
+
Sink(
|
70
|
+
(value) => emitter.event(this.g(value)),
|
71
|
+
(cause) => emitter.error(cause),
|
73
72
|
),
|
74
73
|
);
|
75
74
|
}
|
76
75
|
|
77
|
-
|
78
|
-
return this.ref.
|
76
|
+
event(value: C): IO<R, never, void> {
|
77
|
+
return this.ref.event(this.f(value));
|
79
78
|
}
|
80
79
|
|
81
|
-
|
82
|
-
return this.ref.
|
80
|
+
error(cause: Cause<E>): IO<R, never, void> {
|
81
|
+
return this.ref.error(cause);
|
83
82
|
}
|
84
83
|
|
85
|
-
end: IO<R, never, void> = this.ref.end;
|
86
|
-
|
87
84
|
get unsafeGet(): D {
|
88
85
|
return this.g(this.ref.unsafeGet);
|
89
86
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Sink } from "../Push.js";
|
2
2
|
import type { Push } from "../Push.js";
|
3
3
|
import type { ModifiableRef, ReadableRef, WritableRef } from "../Ref.js";
|
4
4
|
import type { SynchronizedRefSubject } from "@fncts/io/RefSubject/Synchronized/definition";
|
@@ -10,7 +10,7 @@ import { RefVariance } from "../Ref.js";
|
|
10
10
|
/**
|
11
11
|
* @tsplus type fncts.io.Push.RefSubject
|
12
12
|
*/
|
13
|
-
export interface RefSubject<out R, in out E, in A, out B> extends Push<R, E, B>,
|
13
|
+
export interface RefSubject<out R, in out E, in A, out B> extends Push<R, E, B>, Sink<R, E, A> {}
|
14
14
|
|
15
15
|
/**
|
16
16
|
* @tsplus type fncts.io.Push.RefSubjectOps
|
@@ -29,7 +29,7 @@ export abstract class RefSubjectInternal<R, E, A, B>
|
|
29
29
|
WritableRef<R, never, A>,
|
30
30
|
ModifiableRef<R, R, never, never, A, B>,
|
31
31
|
Push<R, E, B>,
|
32
|
-
|
32
|
+
Sink<R, E, A>
|
33
33
|
{
|
34
34
|
readonly [PushTypeId]: PushTypeId = PushTypeId;
|
35
35
|
declare [RefVariance]: {
|
@@ -52,13 +52,11 @@ export abstract class RefSubjectInternal<R, E, A, B>
|
|
52
52
|
|
53
53
|
abstract modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string): IO<R, never, C>;
|
54
54
|
|
55
|
-
abstract run<R1>(emitter:
|
55
|
+
abstract run<R1>(emitter: Sink<R1, E, B>): IO<R | R1, never, void>;
|
56
56
|
|
57
|
-
abstract
|
57
|
+
abstract error(cause: Cause<E>): IO<R, never, void>;
|
58
58
|
|
59
|
-
abstract
|
60
|
-
|
61
|
-
abstract end: IO<R, never, void>;
|
59
|
+
abstract event(value: A): IO<R, never, void>;
|
62
60
|
|
63
61
|
abstract get unsafeGet(): B;
|
64
62
|
}
|
package/_src/STM/api.ts
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
import type { Journal } from "./internal/Journal.js";
|
2
2
|
|
3
3
|
import { identity } from "@fncts/base/data/function";
|
4
|
-
import { AtomicReference } from "@fncts/base/internal/AtomicReference";
|
5
|
-
import { TxnId } from "@fncts/io/TxnId";
|
6
4
|
|
7
5
|
import { ContramapEnvironment, Effect, HaltException, STM } from "./definition.js";
|
8
|
-
import { CommitState } from "./internal/CommitState.js";
|
9
|
-
import { tryCommitAsync, tryCommitSync } from "./internal/Journal.js";
|
10
|
-
import { TryCommitTag } from "./internal/TryCommit.js";
|
11
6
|
|
12
7
|
/**
|
13
8
|
* Maps the success value of this effect to the specified constant value.
|
package/_src/STM/definition.ts
CHANGED
@@ -40,6 +40,12 @@ export abstract class STM<R, E, A> {
|
|
40
40
|
};
|
41
41
|
}
|
42
42
|
|
43
|
+
export declare namespace STM {
|
44
|
+
type EnvironmentOf<X> = [X] extends [{ [STMVariance]: { _R: () => infer R } }] ? R : never;
|
45
|
+
type ErrorOf<X> = [X] extends [{ [STMVariance]: { _E: () => infer E } }] ? E : never;
|
46
|
+
type ValueOf<X> = [X] extends [{ [STMVariance]: { _A: () => infer A } }] ? A : never;
|
47
|
+
}
|
48
|
+
|
43
49
|
/**
|
44
50
|
* @tsplus unify fncts.io.STM
|
45
51
|
*/
|
package/_src/Sink/api.ts
CHANGED
@@ -17,7 +17,7 @@ export function zipLeft<In, L, R1, E1, In1 extends In, L1 extends L, Z1>(
|
|
17
17
|
}
|
18
18
|
|
19
19
|
/**
|
20
|
-
* Like {@link
|
20
|
+
* Like {@link zipConcurrent}, but keeps only the result from this sink
|
21
21
|
*
|
22
22
|
* @tsplus pipeable fncts.io.Sink zipLeftC
|
23
23
|
*/
|
@@ -26,7 +26,7 @@ export function zipLeftC<In, L, R1, E1, In1 extends In, L1 extends L, Z1>(
|
|
26
26
|
__tsplusTrace?: string,
|
27
27
|
) {
|
28
28
|
return <R, E, Z>(self: Sink<R, E, In, L, Z>): Sink<R | R1, E | E1, In & In1, L | L1, Z> => {
|
29
|
-
return self.
|
29
|
+
return self.zipWithConcurrent(that, (z, _) => z);
|
30
30
|
};
|
31
31
|
}
|
32
32
|
|
@@ -45,7 +45,7 @@ export function zipRight<In, L, R1, E1, In1 extends In, L1 extends L, Z1>(
|
|
45
45
|
}
|
46
46
|
|
47
47
|
/**
|
48
|
-
* Like {@link
|
48
|
+
* Like {@link zipConcurrent}, but keeps only the result from the `that` sink
|
49
49
|
*
|
50
50
|
* @tsplus pipeable fncts.io.Sink zipRightC
|
51
51
|
*/
|
@@ -54,7 +54,7 @@ export function zipRightC<In, L, R1, E1, In1 extends In, L1 extends L, Z1>(
|
|
54
54
|
__tsplusTrace?: string,
|
55
55
|
) {
|
56
56
|
return <R, E, Z>(self: Sink<R, E, In, L, Z>): Sink<R | R1, E | E1, In & In1, L | L1, Z1> => {
|
57
|
-
return self.
|
57
|
+
return self.zipWithConcurrent(that, (_, z1) => z1);
|
58
58
|
};
|
59
59
|
}
|
60
60
|
|
@@ -1704,14 +1704,14 @@ export function zip<In, L, R1, E1, In1 extends In, L1 extends L, Z1>(
|
|
1704
1704
|
* Runs both sinks in parallel on the input and combines the results in a
|
1705
1705
|
* tuple.
|
1706
1706
|
*
|
1707
|
-
* @tsplus pipeable fncts.io.Sink
|
1707
|
+
* @tsplus pipeable fncts.io.Sink zipConcurrent
|
1708
1708
|
*/
|
1709
|
-
export function
|
1709
|
+
export function zipConcurrent<In, L, R1, E1, In1 extends In, L1 extends L, Z1>(
|
1710
1710
|
that: Lazy<Sink<R1, E1, In1, L1, Z1>>,
|
1711
1711
|
__tsplusTrace?: string,
|
1712
1712
|
) {
|
1713
1713
|
return <R, E, Z>(self: Sink<R, E, In, L, Z>): Sink<R | R1, E | E1, In & In1, L | L1, readonly [Z, Z1]> => {
|
1714
|
-
return self.
|
1714
|
+
return self.zipWithConcurrent(that, Function.tuple);
|
1715
1715
|
};
|
1716
1716
|
}
|
1717
1717
|
|
@@ -1736,9 +1736,9 @@ export function zipWith<In, L, Z, R1, E1, In1 extends In, L1 extends L, Z1, Z2>(
|
|
1736
1736
|
* Runs both sinks in parallel on the input and combines the results using the
|
1737
1737
|
* provided function.
|
1738
1738
|
*
|
1739
|
-
* @tsplus pipeable fncts.io.Sink
|
1739
|
+
* @tsplus pipeable fncts.io.Sink zipWithConcurrent
|
1740
1740
|
*/
|
1741
|
-
export function
|
1741
|
+
export function zipWithConcurrent<Z, R1, E1, In1, L1, Z1, Z2>(
|
1742
1742
|
that: Lazy<Sink<R1, E1, In1, L1, Z1>>,
|
1743
1743
|
f: (z: Z, z1: Z1) => Z2,
|
1744
1744
|
__tsplusTrace?: string,
|
package/_src/Subject/Atomic.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Sink } from "@fncts/io/Push/definition";
|
2
2
|
import type { Subject } from "@fncts/io/Subject/definition";
|
3
3
|
|
4
4
|
import { Multicast, Push } from "@fncts/io/Push";
|
@@ -16,17 +16,15 @@ export class AtomicSubject<E, A> implements Subject<never, E, A> {
|
|
16
16
|
|
17
17
|
readonly stream = new Multicast<never, E, A>(Push.never);
|
18
18
|
|
19
|
-
run<R>(emitter:
|
19
|
+
run<R>(emitter: Sink<R, E, A>): IO<R, never, unknown> {
|
20
20
|
return this.stream.run(emitter);
|
21
21
|
}
|
22
22
|
|
23
|
-
|
24
|
-
return this.stream.
|
23
|
+
event(value: A): IO<never, never, void> {
|
24
|
+
return this.stream.event(value);
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
return this.stream.
|
27
|
+
error(cause: Cause<E>): IO<never, never, void> {
|
28
|
+
return this.stream.error(cause);
|
29
29
|
}
|
30
|
-
|
31
|
-
end = this.stream.end;
|
32
30
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Push,Sink } from "../Push.js";
|
2
2
|
|
3
3
|
export const SubjectTypeId = Symbol.for("fncts.io.Push.Subject");
|
4
4
|
export type SubjectTypeId = typeof SubjectTypeId;
|
@@ -6,7 +6,7 @@ export type SubjectTypeId = typeof SubjectTypeId;
|
|
6
6
|
/**
|
7
7
|
* @tsplus type fncts.io.Push.Subject
|
8
8
|
*/
|
9
|
-
export interface Subject<R, E, A> extends Push<R, E, A>,
|
9
|
+
export interface Subject<R, E, A> extends Push<R, E, A>, Sink<R, E, A> {
|
10
10
|
readonly [SubjectTypeId]: SubjectTypeId;
|
11
11
|
}
|
12
12
|
|