@fncts/io 0.0.49 → 0.0.50
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/foreachExec.d.ts +18 -0
- package/Push/Bounds.d.ts +4 -0
- package/Push/FlattenStrategy.d.ts +47 -0
- package/Push/IndexedBuffer.d.ts +19 -0
- package/Push/MergeStrategy.d.ts +19 -0
- package/Push/Operator/IOLoopOperator.d.ts +61 -0
- package/Push/Operator/IOOperator.d.ts +63 -0
- package/Push/Operator/LoopOperator.d.ts +50 -0
- package/Push/Operator/SyncOperator.d.ts +41 -0
- package/Push/Operator.d.ts +4 -0
- package/Push/Producer/IOProducer.d.ts +41 -0
- package/Push/Producer/SyncProducer.d.ts +61 -0
- package/Push/Producer.d.ts +1 -0
- package/Push/Sink.d.ts +65 -0
- package/Push/api.d.ts +78 -161
- package/Push/definition.d.ts +92 -19
- package/Push/internal.d.ts +3 -0
- package/Push.d.ts +6 -0
- package/Ref/Synchronized/definition.d.ts +32 -9
- package/Ref/definition.d.ts +12 -0
- package/Scope/api.d.ts +16 -1
- package/Sink/definition.d.ts +5 -6
- package/Subject/Atomic.d.ts +19 -9
- package/Subject/DeferredRef.d.ts +17 -0
- package/Subject/Hold.d.ts +19 -0
- package/Subject/RefSubject/Atomic.d.ts +41 -0
- package/Subject/RefSubject/Derived.d.ts +43 -0
- package/Subject/RefSubject/RefSubject.d.ts +27 -0
- package/Subject/definition.d.ts +14 -2
- package/Subject.d.ts +2 -0
- package/SubscriptionRef.d.ts +0 -1
- package/_cjs/IO/api/foreachExec.cjs +29 -4
- package/_cjs/IO/api/foreachExec.cjs.map +1 -1
- package/_cjs/Push/Bounds.cjs +2 -0
- package/_cjs/Push/Bounds.cjs.map +1 -0
- package/_cjs/Push/FlattenStrategy.cjs +95 -0
- package/_cjs/Push/FlattenStrategy.cjs.map +1 -0
- package/_cjs/Push/IndexedBuffer.cjs +70 -0
- package/_cjs/Push/IndexedBuffer.cjs.map +1 -0
- package/_cjs/Push/MergeStrategy.cjs +45 -0
- package/_cjs/Push/MergeStrategy.cjs.map +1 -0
- package/_cjs/Push/Operator/IOLoopOperator.cjs +225 -0
- package/_cjs/Push/Operator/IOLoopOperator.cjs.map +1 -0
- package/_cjs/Push/Operator/IOOperator.cjs +104 -0
- package/_cjs/Push/Operator/IOOperator.cjs.map +1 -0
- package/_cjs/Push/Operator/LoopOperator.cjs +165 -0
- package/_cjs/Push/Operator/LoopOperator.cjs.map +1 -0
- package/_cjs/Push/Operator/SyncOperator.cjs +78 -0
- package/_cjs/Push/Operator/SyncOperator.cjs.map +1 -0
- package/_cjs/Push/Operator.cjs +2 -0
- package/_cjs/Push/Operator.cjs.map +1 -0
- package/_cjs/Push/Producer/IOProducer.cjs +67 -0
- package/_cjs/Push/Producer/IOProducer.cjs.map +1 -0
- package/_cjs/Push/Producer/SyncProducer.cjs +107 -0
- package/_cjs/Push/Producer/SyncProducer.cjs.map +1 -0
- package/_cjs/Push/Producer.cjs +2 -0
- package/_cjs/Push/Producer.cjs.map +1 -0
- package/_cjs/Push/Sink.cjs +219 -0
- package/_cjs/Push/Sink.cjs.map +1 -0
- package/_cjs/Push/api.cjs +339 -383
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/definition.cjs +79 -22
- package/_cjs/Push/definition.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +31 -26
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/Push.cjs +66 -0
- package/_cjs/Push.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +12 -12
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
- package/_cjs/Ref/definition.cjs.map +1 -1
- package/_cjs/Scope/api.cjs +28 -7
- package/_cjs/Scope/api.cjs.map +1 -1
- package/_cjs/Sink/definition.cjs +2 -3
- package/_cjs/Sink/definition.cjs.map +1 -1
- package/_cjs/Stream/definition.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +45 -10
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_cjs/Subject/DeferredRef.cjs +53 -0
- package/_cjs/Subject/DeferredRef.cjs.map +1 -0
- package/_cjs/Subject/Hold.cjs +41 -0
- package/_cjs/Subject/Hold.cjs.map +1 -0
- package/_cjs/Subject/RefSubject/Atomic.cjs +130 -0
- package/_cjs/Subject/RefSubject/Atomic.cjs.map +1 -0
- package/_cjs/Subject/RefSubject/Derived.cjs +98 -0
- package/_cjs/Subject/RefSubject/Derived.cjs.map +1 -0
- package/_cjs/Subject/RefSubject/RefSubject.cjs +19 -0
- package/_cjs/Subject/RefSubject/RefSubject.cjs.map +1 -0
- package/_cjs/Subject/definition.cjs +16 -1
- package/_cjs/Subject/definition.cjs.map +1 -1
- package/_cjs/Subject.cjs +22 -0
- package/_cjs/Subject.cjs.map +1 -1
- package/_cjs/SubscriptionRef.cjs +0 -1
- package/_cjs/SubscriptionRef.cjs.map +1 -1
- package/_mjs/IO/api/foreachExec.mjs +27 -4
- package/_mjs/IO/api/foreachExec.mjs.map +1 -1
- package/_mjs/Push/Bounds.mjs +2 -0
- package/_mjs/Push/Bounds.mjs.map +1 -0
- package/_mjs/Push/FlattenStrategy.mjs +86 -0
- package/_mjs/Push/FlattenStrategy.mjs.map +1 -0
- package/_mjs/Push/IndexedBuffer.mjs +61 -0
- package/_mjs/Push/IndexedBuffer.mjs.map +1 -0
- package/_mjs/Push/MergeStrategy.mjs +34 -0
- package/_mjs/Push/MergeStrategy.mjs.map +1 -0
- package/_mjs/Push/Operator/IOLoopOperator.mjs +208 -0
- package/_mjs/Push/Operator/IOLoopOperator.mjs.map +1 -0
- package/_mjs/Push/Operator/IOOperator.mjs +91 -0
- package/_mjs/Push/Operator/IOOperator.mjs.map +1 -0
- package/_mjs/Push/Operator/LoopOperator.mjs +151 -0
- package/_mjs/Push/Operator/LoopOperator.mjs.map +1 -0
- package/_mjs/Push/Operator/SyncOperator.mjs +67 -0
- package/_mjs/Push/Operator/SyncOperator.mjs.map +1 -0
- package/_mjs/Push/Operator.mjs +2 -0
- package/_mjs/Push/Operator.mjs.map +1 -0
- package/_mjs/Push/Producer/IOProducer.mjs +55 -0
- package/_mjs/Push/Producer/IOProducer.mjs.map +1 -0
- package/_mjs/Push/Producer/SyncProducer.mjs +90 -0
- package/_mjs/Push/Producer/SyncProducer.mjs.map +1 -0
- package/_mjs/Push/Producer.mjs +2 -0
- package/_mjs/Push/Producer.mjs.map +1 -0
- package/_mjs/Push/Sink.mjs +206 -0
- package/_mjs/Push/Sink.mjs.map +1 -0
- package/_mjs/Push/api.mjs +311 -344
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Push/definition.mjs +73 -18
- package/_mjs/Push/definition.mjs.map +1 -1
- package/_mjs/Push/internal.mjs +30 -26
- package/_mjs/Push/internal.mjs.map +1 -1
- package/_mjs/Push.mjs +7 -1
- package/_mjs/Push.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs +12 -12
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/Ref/definition.mjs.map +1 -1
- package/_mjs/Scope/api.mjs +22 -4
- package/_mjs/Scope/api.mjs.map +1 -1
- package/_mjs/Sink/definition.mjs +2 -3
- package/_mjs/Sink/definition.mjs.map +1 -1
- package/_mjs/Stream/definition.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +46 -10
- package/_mjs/Subject/Atomic.mjs.map +1 -1
- package/_mjs/Subject/DeferredRef.mjs +45 -0
- package/_mjs/Subject/DeferredRef.mjs.map +1 -0
- package/_mjs/Subject/Hold.mjs +33 -0
- package/_mjs/Subject/Hold.mjs.map +1 -0
- package/_mjs/Subject/RefSubject/Atomic.mjs +122 -0
- package/_mjs/Subject/RefSubject/Atomic.mjs.map +1 -0
- package/_mjs/Subject/RefSubject/Derived.mjs +90 -0
- package/_mjs/Subject/RefSubject/Derived.mjs.map +1 -0
- package/_mjs/Subject/RefSubject/RefSubject.mjs +12 -0
- package/_mjs/Subject/RefSubject/RefSubject.mjs.map +1 -0
- package/_mjs/Subject/definition.mjs +14 -0
- package/_mjs/Subject/definition.mjs.map +1 -1
- package/_mjs/Subject.mjs +2 -0
- package/_mjs/Subject.mjs.map +1 -1
- package/_mjs/SubscriptionRef.mjs +0 -1
- package/_mjs/SubscriptionRef.mjs.map +1 -1
- package/_src/IO/api/foreachExec.ts +47 -0
- package/_src/Push/Bounds.ts +4 -0
- package/_src/Push/FlattenStrategy.ts +137 -0
- package/_src/Push/IndexedBuffer.ts +79 -0
- package/_src/Push/MergeStrategy.ts +59 -0
- package/_src/Push/Operator/IOLoopOperator.ts +413 -0
- package/_src/Push/Operator/IOOperator.ts +173 -0
- package/_src/Push/Operator/LoopOperator.ts +242 -0
- package/_src/Push/Operator/SyncOperator.ts +107 -0
- package/_src/Push/Operator.ts +7 -0
- package/_src/Push/Producer/IOProducer.ts +83 -0
- package/_src/Push/Producer/SyncProducer.ts +105 -0
- package/_src/Push/Producer.ts +0 -0
- package/_src/Push/Sink.ts +302 -0
- package/_src/Push/api.ts +387 -513
- package/_src/Push/definition.ts +216 -23
- package/_src/Push/internal.ts +11 -0
- package/_src/Push.ts +7 -1
- package/_src/Ref/Synchronized/definition.ts +81 -37
- package/_src/Ref/definition.ts +26 -0
- package/_src/Scope/api.ts +22 -0
- package/_src/Sink/definition.ts +4 -5
- package/_src/Stream/definition.ts +0 -1
- package/_src/Subject/Atomic.ts +68 -11
- package/_src/Subject/DeferredRef.ts +44 -0
- package/_src/Subject/Hold.ts +48 -0
- package/_src/Subject/RefSubject/Atomic.ts +193 -0
- package/_src/Subject/RefSubject/Derived.ts +179 -0
- package/_src/Subject/RefSubject/RefSubject.ts +90 -0
- package/_src/Subject/definition.ts +21 -3
- package/_src/Subject.ts +5 -3
- package/_src/SubscriptionRef.ts +1 -1
- package/_src/index.ts +49 -50
- package/index.d.ts +0 -1
- package/package.json +4 -4
- package/RefSubject/Atomic.d.ts +0 -34
- package/RefSubject/Synchronized/api.d.ts +0 -9
- package/RefSubject/Synchronized/definition.d.ts +0 -39
- package/RefSubject/api.d.ts +0 -120
- package/RefSubject/definition.d.ts +0 -52
- package/RefSubject.d.ts +0 -3
- package/_cjs/RefSubject/Atomic.cjs +0 -107
- package/_cjs/RefSubject/Atomic.cjs.map +0 -1
- package/_cjs/RefSubject/Synchronized/api.cjs +0 -22
- package/_cjs/RefSubject/Synchronized/api.cjs.map +0 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +0 -55
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +0 -1
- package/_cjs/RefSubject/api.cjs +0 -251
- package/_cjs/RefSubject/api.cjs.map +0 -1
- package/_cjs/RefSubject/definition.cjs +0 -26
- package/_cjs/RefSubject/definition.cjs.map +0 -1
- package/_cjs/RefSubject.cjs +0 -39
- package/_cjs/RefSubject.cjs.map +0 -1
- package/_mjs/RefSubject/Atomic.mjs +0 -99
- package/_mjs/RefSubject/Atomic.mjs.map +0 -1
- package/_mjs/RefSubject/Synchronized/api.mjs +0 -15
- package/_mjs/RefSubject/Synchronized/api.mjs.map +0 -1
- package/_mjs/RefSubject/Synchronized/definition.mjs +0 -47
- package/_mjs/RefSubject/Synchronized/definition.mjs.map +0 -1
- package/_mjs/RefSubject/api.mjs +0 -229
- package/_mjs/RefSubject/api.mjs.map +0 -1
- package/_mjs/RefSubject/definition.mjs +0 -19
- package/_mjs/RefSubject/definition.mjs.map +0 -1
- package/_mjs/RefSubject.mjs +0 -5
- package/_mjs/RefSubject.mjs.map +0 -1
- package/_src/RefSubject/Atomic.ts +0 -129
- package/_src/RefSubject/Synchronized/api.ts +0 -14
- package/_src/RefSubject/Synchronized/definition.ts +0 -76
- package/_src/RefSubject/api.ts +0 -253
- package/_src/RefSubject/definition.ts +0 -70
- package/_src/RefSubject.ts +0 -5
package/_mjs/RefSubject/api.mjs
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
const fileName_1 = "(@fncts/io) src/RefSubject/api.ts";
|
|
2
|
-
import * as tsplus_module_1 from "@fncts/io/IO/api";
|
|
3
|
-
import * as tsplus_module_2 from "@fncts/io/Push/definition";
|
|
4
|
-
import * as tsplus_module_3 from "@fncts/base/data/function/api";
|
|
5
|
-
import * as tsplus_module_4 from "@fncts/base/data/Maybe/api";
|
|
6
|
-
export const unsafeMake = unsafeMake_1;
|
|
7
|
-
export const dimap = dimap_1;
|
|
8
|
-
export const modify = modify_1;
|
|
9
|
-
import { tuple } from "@fncts/base/data/function";
|
|
10
|
-
import { Sink } from "@fncts/io/Push";
|
|
11
|
-
import { AtomicRefSubject } from "@fncts/io/RefSubject/Atomic";
|
|
12
|
-
import { RefSubjectInternal } from "./definition.mjs";
|
|
13
|
-
import { concrete } from "./definition.mjs";
|
|
14
|
-
/**
|
|
15
|
-
* @tsplus static fncts.io.Push.RefSubjectOps unsafeMake
|
|
16
|
-
*/
|
|
17
|
-
function unsafeMake_1(initial) {
|
|
18
|
-
return new AtomicRefSubject(initial);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @tsplus static fncts.io.Push.RefSubjectOps make
|
|
22
|
-
* @tsplus static fncts.io.Push.RefSubjectOps __call
|
|
23
|
-
*/
|
|
24
|
-
export function make(initial) {
|
|
25
|
-
return tsplus_module_1.succeed(() => unsafeMake_1(initial()), fileName_1 + ":21:12");
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Reads the value from the `Ref`.
|
|
29
|
-
*
|
|
30
|
-
* @tsplus getter fncts.io.Push.RefSubject get
|
|
31
|
-
*/
|
|
32
|
-
export function get(self, __tsplusTrace) {
|
|
33
|
-
void 0;
|
|
34
|
-
return self.get;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Writes a new value to the `Ref`, with a guarantee of immediate
|
|
38
|
-
* consistency (at some cost to performance).
|
|
39
|
-
*
|
|
40
|
-
* @tsplus pipeable fncts.io.Push.RefSubject set
|
|
41
|
-
*/
|
|
42
|
-
export function set(a, __tsplusTrace) {
|
|
43
|
-
return self => {
|
|
44
|
-
void 0;
|
|
45
|
-
return self.set(a);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
class Dimap extends RefSubjectInternal {
|
|
49
|
-
constructor(ref, f, g) {
|
|
50
|
-
super();
|
|
51
|
-
this.ref = ref;
|
|
52
|
-
this.f = f;
|
|
53
|
-
this.g = g;
|
|
54
|
-
}
|
|
55
|
-
get get() {
|
|
56
|
-
return tsplus_module_1.map(this.g, fileName_1 + ":57:28")(this.ref.get);
|
|
57
|
-
}
|
|
58
|
-
set(value) {
|
|
59
|
-
return this.ref.set(this.f(value));
|
|
60
|
-
}
|
|
61
|
-
modify(f, __tsplusTrace) {
|
|
62
|
-
return tsplus_module_1.flatMap(c => {
|
|
63
|
-
const o = f(c);
|
|
64
|
-
return tsplus_module_1.zipRight(tsplus_module_1.succeedNow(o[0], fileName_1 + ":67:44"), fileName_1 + ":67:30")(this.set(o[1]));
|
|
65
|
-
}, fileName_1 + ":65:28")(this.get);
|
|
66
|
-
}
|
|
67
|
-
run(emitter) {
|
|
68
|
-
return this.ref.run(tsplus_module_2.makeSink(value => emitter.event(this.g(value)), cause => emitter.error(cause)));
|
|
69
|
-
}
|
|
70
|
-
event(value) {
|
|
71
|
-
return this.ref.event(this.f(value));
|
|
72
|
-
}
|
|
73
|
-
error(cause) {
|
|
74
|
-
return this.ref.error(cause);
|
|
75
|
-
}
|
|
76
|
-
get unsafeGet() {
|
|
77
|
-
return this.g(this.ref.unsafeGet);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Transforms both the `set` and `get` values of the `Ref` with the
|
|
82
|
-
* specified functions.
|
|
83
|
-
*
|
|
84
|
-
* @tsplus pipeable fncts.io.Push.RefSubject dimap
|
|
85
|
-
*/
|
|
86
|
-
function dimap_1(f, g, __tsplusTrace) {
|
|
87
|
-
return self => {
|
|
88
|
-
void 0;
|
|
89
|
-
return new Dimap(self, f, g);
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Transforms the `set` value of the `Ref` with the specified function.
|
|
94
|
-
*
|
|
95
|
-
* @tsplus pipeable fncts.io.Push.RefSubject contramap
|
|
96
|
-
*/
|
|
97
|
-
export function contramap(f, __tsplusTrace) {
|
|
98
|
-
return self => {
|
|
99
|
-
return dimap_1(f, tsplus_module_3.identity, __tsplusTrace)(self);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Transforms the `get` value of the `Ref` with the specified function.
|
|
104
|
-
*
|
|
105
|
-
* @tsplus pipeable fncts.io.Push.RefSubject map
|
|
106
|
-
*/
|
|
107
|
-
export function map(f, __tsplusTrace) {
|
|
108
|
-
return ref => {
|
|
109
|
-
return dimap_1(tsplus_module_3.identity, f, __tsplusTrace)(ref);
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Atomically modifies the `Ref` with the specified function, which
|
|
114
|
-
* computes a return value for the modification. This is a more powerful
|
|
115
|
-
* version of `update`.
|
|
116
|
-
*
|
|
117
|
-
* @tsplus pipeable fncts.io.Push.RefSubject modify
|
|
118
|
-
*/
|
|
119
|
-
function modify_1(f, __tsplusTrace) {
|
|
120
|
-
return self => {
|
|
121
|
-
void 0;
|
|
122
|
-
return self.modify(f, __tsplusTrace);
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Atomically modifies the `Ref` with the specified partial function,
|
|
127
|
-
* which computes a return value for the modification if the function is
|
|
128
|
-
* defined on the current value otherwise it returns a default value. This
|
|
129
|
-
* is a more powerful version of `updateJust`.
|
|
130
|
-
*
|
|
131
|
-
* @tsplus pipeable fncts.io.Push.RefSubject modifyJust
|
|
132
|
-
*/
|
|
133
|
-
export function modifyJust(def, f, __tsplusTrace) {
|
|
134
|
-
return self => {
|
|
135
|
-
return modify_1(a => tsplus_module_4.getOrElse(() => tuple(def, a))(f(a)), __tsplusTrace)(self);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Atomically writes the specified value to the `Ref`, returning the value
|
|
140
|
-
* immediately before modification.
|
|
141
|
-
*
|
|
142
|
-
* @tsplus pipeable fncts.io.Push.RefSubject getAndSet
|
|
143
|
-
*/
|
|
144
|
-
export function getAndSet(a, __tsplusTrace) {
|
|
145
|
-
return self => {
|
|
146
|
-
return modify_1(a0 => tuple(a0, a), __tsplusTrace)(self);
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Atomically modifies the `Ref` with the specified function, returning
|
|
151
|
-
* the value immediately before modification.
|
|
152
|
-
*
|
|
153
|
-
* @tsplus pipeable fncts.io.Push.RefSubject getAndUpdate
|
|
154
|
-
*/
|
|
155
|
-
export function getAndUpdate(f, __tsplusTrace) {
|
|
156
|
-
return self => {
|
|
157
|
-
return modify_1(a0 => tuple(a0, f(a0)), __tsplusTrace)(self);
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Atomically modifies the `Ref` with the specified partial function,
|
|
162
|
-
* returning the value immediately before modification. If the function is
|
|
163
|
-
* undefined on the current value it doesn't change it.
|
|
164
|
-
*
|
|
165
|
-
* @tsplus pipeable fncts.io.Push.RefSubject getAndUpdateJust
|
|
166
|
-
*/
|
|
167
|
-
export function getAndUpdateJust(f, __tsplusTrace) {
|
|
168
|
-
return self => {
|
|
169
|
-
return modify_1(a0 => tuple(a0, tsplus_module_4.getOrElse(() => a0)(f(a0))), __tsplusTrace)(self);
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Atomically modifies the `Ref` with the specified function.
|
|
174
|
-
*
|
|
175
|
-
* @tsplus pipeable fncts.io.Push.RefSubject update
|
|
176
|
-
*/
|
|
177
|
-
export function update(f, __tsplusTrace) {
|
|
178
|
-
return self => {
|
|
179
|
-
return modify_1(a0 => tuple(undefined, f(a0)), __tsplusTrace)(self);
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Atomically modifies the `Ref` with the specified function and returns
|
|
184
|
-
* the updated value.
|
|
185
|
-
*
|
|
186
|
-
* @tsplus pipeable fncts.io.Push.RefSubject updateAndGet
|
|
187
|
-
*/
|
|
188
|
-
export function updateAndGet(f, __tsplusTrace) {
|
|
189
|
-
return self => {
|
|
190
|
-
return modify_1(a0 => {
|
|
191
|
-
const r = f(a0);
|
|
192
|
-
return tuple(r, r);
|
|
193
|
-
}, __tsplusTrace)(self);
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Atomically modifies the `Ref` with the specified partial function. If
|
|
198
|
-
* the function is undefined on the current value it doesn't change it.
|
|
199
|
-
*
|
|
200
|
-
* @tsplus pipeable fncts.io.Push.RefSubject updateJust
|
|
201
|
-
*/
|
|
202
|
-
export function updateJust(f, __tsplusTrace) {
|
|
203
|
-
return self => {
|
|
204
|
-
return modify_1(a0 => tuple(undefined, tsplus_module_4.getOrElse(() => a0)(f(a0))), __tsplusTrace)(self);
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Atomically modifies the `Ref` with the specified partial function. If
|
|
209
|
-
* the function is undefined on the current value it returns the old value
|
|
210
|
-
* without changing it.
|
|
211
|
-
*
|
|
212
|
-
* @tsplus pipeable fncts.io.Push.RefSubject updateJustAndGet
|
|
213
|
-
*/
|
|
214
|
-
export function updateJustAndGet(f, __tsplusTrace) {
|
|
215
|
-
return self => {
|
|
216
|
-
return modify_1(a0 => {
|
|
217
|
-
const r = tsplus_module_4.getOrElse(() => a0)(f(a0));
|
|
218
|
-
return tuple(r, r);
|
|
219
|
-
}, __tsplusTrace)(self);
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* @tsplus getter fncts.io.Push.RefSubject unsafeGet
|
|
224
|
-
*/
|
|
225
|
-
export function unsafeGet(self) {
|
|
226
|
-
void 0;
|
|
227
|
-
return self.unsafeGet;
|
|
228
|
-
}
|
|
229
|
-
//# sourceMappingURL=api.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":["unsafeMake","unsafeMake_1","dimap","dimap_1","modify","modify_1","tuple","Sink","AtomicRefSubject","RefSubjectInternal","concrete","initial","make","tsplus_module_1","succeed","fileName_1","get","self","__tsplusTrace","set","a","Dimap","constructor","ref","f","g","map","value","flatMap","c","o","zipRight","succeedNow","run","emitter","tsplus_module_2","makeSink","event","cause","error","unsafeGet","contramap","tsplus_module_3","identity","modifyJust","def","tsplus_module_4","getOrElse","getAndSet","a0","getAndUpdate","getAndUpdateJust","update","undefined","updateAndGet","r","updateJust","updateJustAndGet"],"sources":["../../_src/RefSubject/api.ts"],"sourcesContent":[null],"mappings":";;;;;aAWgBA,UAAU,GAAAC,YAAA;aAuFVC,KAAK,GAAAC,OAAA;aAoCLC,MAAM,GAAAC,QAAA;AAtItB,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,gBAAgB,QAAQ,6BAA6B;AAG9D,SAASC,kBAAkB,QAAQ,kBAAiB;AACpD,SAASC,QAAQ,QAAQ,kBAAiB;AAE1C;;;AAGA,SAAAT,aAA8BU,OAAU;EACtC,OAAO,IAAIH,gBAAgB,CAACG,OAAO,CAAC;AACtC;AAEA;;;;AAIA,OAAM,SAAUC,IAAIA,CAAID,OAAgB;EACtC,OAAOE,eAAA,CAAAC,OAAA,OAAGb,YAAA,CAAsBU,OAAO,EAAE,CAAC,EAAAI,UAAA,YAAC;AAC7C;AAEA;;;;;AAKA,OAAM,SAAUC,GAAGA,CAAaC,IAA4B,EAAEC,aAAsB;EAClF;EACA,OAAOD,IAAI,CAACD,GAAG;AACjB;AAEA;;;;;;AAMA,OAAM,SAAUG,GAAGA,CAAIC,CAAI,EAAEF,aAAsB;EACjD,OAAiBD,IAA4B,IAAwB;IACnE;IACA,OAAOA,IAAI,CAACE,GAAG,CAACC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N,aAAsB;EACpE,OAAcD,IAA4B,IAAI;IAC5C,OAAOZ,QAAA,CAAa4C,EAAE,IAAI;MACxB,MAAMM,CAAC,GAAG/B,CAAC,CAACyB,EAAE,CAAC;MACf,OAAO3C,KAAK,CAACiD,CAAC,EAAEA,CAAC,CAAC;IACpB,CAAC,EAL2CrC,aAAA,EAErCD,IAAI,CAGT;EACJ,CAAC;AACH;AAEA;;;;;;AAMA,OAAM,SAAUuC,UAAUA,CAAIhC,CAAqB,EAAEN,aAAsB;EACzE,OAAcD,IAA4B,IAAwB;IAChE,OAAOZ,QAAA,CAAa4C,EAAE,IAAK3C,KAAK,CAAC+C,SAAS,EAAEP,eAAA,CAAAC,SAAA,OAAgBE,EAAE,EAAlBzB,CAAC,CAACyB,EAAE,CAAC,CAAc,CAAC,EAFf/B,aAAA,EAE1CD,IAAI,CAAsD;EACnE,CAAC;AACH;AAEA;;;;;;;AAOA,OAAM,SAAUwC,gBAAgBA,CAAIjC,CAAqB,EAAEN,aAAsB;EAC/E,OAAcD,IAA4B,IAAqB;IAC7D,OAAOZ,QAAA,CAAa4C,EAAE,IAAI;MACxB,MAAMM,CAAC,GAAGT,eAAA,CAAAC,SAAA,OAAgBE,EAAE,EAAlBzB,CAAC,CAACyB,EAAE,CAAC,CAAc;MAC7B,OAAO3C,KAAK,CAACiD,CAAC,EAAEA,CAAC,CAAC;IACpB,CAAC,EALsDrC,aAAA,EAEhDD,IAAI,CAGT;EACJ,CAAC;AACH;AAEA;;;AAGA,OAAM,SAAUuB,SAASA,CAAavB,IAA4B;EAChE;EACA,OAAOA,IAAI,CAACuB,SAAS;AACvB","ignoreList":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { PushTypeId } from "../Push.mjs";
|
|
3
|
-
import { PushVariance } from "../Push.mjs";
|
|
4
|
-
import { RefVariance } from "../Ref.mjs";
|
|
5
|
-
export const RefSubject = {};
|
|
6
|
-
export class RefSubjectInternal {
|
|
7
|
-
constructor() {
|
|
8
|
-
this[_a] = PushTypeId;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
_a = PushTypeId;
|
|
12
|
-
/**
|
|
13
|
-
* @tsplus static fncts.io.Push.RefSubjectOps concrete
|
|
14
|
-
* @tsplus macro remove
|
|
15
|
-
*/
|
|
16
|
-
export function concrete(_) {
|
|
17
|
-
//
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=definition.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definition.mjs","names":["PushTypeId","PushVariance","RefVariance","RefSubject","RefSubjectInternal","constructor","_a","concrete","_"],"sources":["../../_src/RefSubject/definition.ts"],"sourcesContent":[null],"mappings":";AAKA,SAASA,UAAU,QAAQ,aAAY;AACvC,SAASC,YAAY,QAAQ,aAAY;AACzC,SAASC,WAAW,QAAQ,YAAW;AAYvC,OAAO,MAAMC,UAAU,GAAkB,EAAE;AAM3C,OAAM,MAAgBC,kBAAkB;EAAxCC,YAAA;IAQW,KAAAC,EAAA,CAAY,GAAeN,UAAU;EA4BhD;;KA5BYA,UAAU;AA8BtB;;;;AAIA,OAAM,SAAUO,QAAQA,CAAaC,CAAyB;EAC5D;AAAA","ignoreList":[]}
|
package/_mjs/RefSubject.mjs
DELETED
package/_mjs/RefSubject.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RefSubject.mjs","names":[],"sources":["../_src/RefSubject.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA,cAAc,sBAAqB;AACnC,cAAc,yBAAwB;AACtC,cAAc,6BAA4B","ignoreList":[]}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import type { Sink } from "@fncts/io/Push";
|
|
2
|
-
|
|
3
|
-
import { AtomicReference } from "@fncts/base/internal/AtomicReference";
|
|
4
|
-
import { Hold, Push } from "@fncts/io/Push";
|
|
5
|
-
import { Atomic } from "@fncts/io/Ref";
|
|
6
|
-
import { RefSubjectInternal } from "@fncts/io/RefSubject/definition";
|
|
7
|
-
|
|
8
|
-
export class AtomicRefSubject<E, A> extends RefSubjectInternal<never, E, A, A> {
|
|
9
|
-
readonly stream = new Hold<never, E, A>(Push.never);
|
|
10
|
-
readonly maybeRef = new Atomic(this.stream.current);
|
|
11
|
-
readonly ref = new AtomicEmitRef(
|
|
12
|
-
new AtomicDimapRef(
|
|
13
|
-
this.maybeRef,
|
|
14
|
-
(v) => v.getOrElse(this.initial),
|
|
15
|
-
(a) => Just(a),
|
|
16
|
-
),
|
|
17
|
-
this.stream,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
constructor(readonly initial: A) {
|
|
21
|
-
super();
|
|
22
|
-
this.stream.current.set(Just(initial));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get get() {
|
|
26
|
-
return this.ref.get;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
set(value: A, __tsplusTrace?: string) {
|
|
30
|
-
return this.ref.set(value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
modify<E, A, B>(
|
|
34
|
-
this: AtomicRefSubject<E, A>,
|
|
35
|
-
f: (a: A) => readonly [B, A],
|
|
36
|
-
__tsplusTrace?: string,
|
|
37
|
-
): IO<never, never, B> {
|
|
38
|
-
return this.ref.modify(f);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
run<R>(emitter: Sink<R, E, A>): IO<R, never, unknown> {
|
|
42
|
-
return this.stream.run(emitter);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
event(value: A): IO<never, never, void> {
|
|
46
|
-
return this.stream.event(value);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
error(cause: Cause<E>): IO<never, never, void> {
|
|
50
|
-
return this.stream.error(cause);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
unsafeEvent(value: A): void {
|
|
54
|
-
this.stream.event(value).unsafeRunFiber();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
unsafeError(cause: Cause<E>): void {
|
|
58
|
-
this.stream.error(cause).unsafeRunFiber();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get unsafeGet(): A {
|
|
62
|
-
return this.ref.unsafeGet;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class AtomicDimapRef<A, B> extends Atomic<B> {
|
|
67
|
-
constructor(
|
|
68
|
-
readonly ref: Atomic<A>,
|
|
69
|
-
readonly f: (a: A) => B,
|
|
70
|
-
readonly g: (b: B) => A,
|
|
71
|
-
) {
|
|
72
|
-
const value = new (class extends AtomicReference<B> {
|
|
73
|
-
constructor(
|
|
74
|
-
readonly ref: AtomicReference<A>,
|
|
75
|
-
readonly f: (a: A) => B,
|
|
76
|
-
readonly g: (b: B) => A,
|
|
77
|
-
) {
|
|
78
|
-
super(f(ref.initial));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get get() {
|
|
82
|
-
return this.f(this.ref.get);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
set(value: B) {
|
|
86
|
-
this.ref.set(this.g(value));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
compareAndSet(old: B, value: B): boolean {
|
|
90
|
-
return this.ref.compareAndSet(this.g(old), this.g(value));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
getAndSet(value: B): B {
|
|
94
|
-
return this.f(this.ref.getAndSet(this.g(value)));
|
|
95
|
-
}
|
|
96
|
-
})(ref.value, f, g);
|
|
97
|
-
super(value);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
class AtomicEmitRef<E, A> extends Atomic<A> {
|
|
102
|
-
constructor(
|
|
103
|
-
readonly ref: Atomic<A>,
|
|
104
|
-
readonly sink: Sink<never, E, A>,
|
|
105
|
-
) {
|
|
106
|
-
super(ref.value);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
get get() {
|
|
110
|
-
return this.ref.get;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
get unsafeGet(): A {
|
|
114
|
-
return this.ref.unsafeGet;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
unsafeSet(value: A) {
|
|
118
|
-
this.ref.unsafeSet(value);
|
|
119
|
-
this.sink.event(value).unsafeRunFiber();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
set(value: A, __tsplusTrace?: string) {
|
|
123
|
-
return this.ref.set(value) < this.sink.event(value);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
modify<B>(f: (a: A) => readonly [B, A], __tsplusTrace?: string) {
|
|
127
|
-
return this.ref.modify(f) < this.ref.get.flatMap((value) => this.sink.event(value));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { concrete, RefSubject } from "@fncts/io/RefSubject";
|
|
2
|
-
import { SynchronizedRefSubjectInternal } from "@fncts/io/RefSubject/Synchronized/definition";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @tsplus static fncts.io.Push.RefSubject.SynchronizedOps make
|
|
6
|
-
* @tsplus static fncts.io.Push.RefSubject.SynchronizedOps __call
|
|
7
|
-
*/
|
|
8
|
-
export function make<A>(initial: Lazy<A>): UIO<RefSubject.Synchronized<never, never, A, A>> {
|
|
9
|
-
return Do((Δ) => {
|
|
10
|
-
const ref = Δ(RefSubject.make(initial));
|
|
11
|
-
const semaphore = Δ(TSemaphore(1).commit);
|
|
12
|
-
return new SynchronizedRefSubjectInternal(semaphore, (concrete(ref), ref));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { RefSubject } from "../definition.js";
|
|
2
|
-
import type { Cause } from "@fncts/base/data/Cause";
|
|
3
|
-
import type { Sink } from "@fncts/io/Push";
|
|
4
|
-
|
|
5
|
-
import { IO } from "@fncts/io/IO";
|
|
6
|
-
|
|
7
|
-
import { RefSubjectInternal } from "../definition.js";
|
|
8
|
-
|
|
9
|
-
export const SynchronizedRefSubjectTypeId = Symbol.for("fncts.io.Push.SynchronizedRefSubject");
|
|
10
|
-
export type SynchronizedRefSubjectTypeId = typeof SynchronizedRefSubjectTypeId;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @tsplus type fncts.io.Push.RefSubject.Synchronized
|
|
14
|
-
*/
|
|
15
|
-
export interface SynchronizedRefSubject<R, E, A, B> extends RefSubject<R, E, A, B> {
|
|
16
|
-
readonly [SynchronizedRefSubjectTypeId]: SynchronizedRefSubjectTypeId;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @tsplus type fncts.io.Push.RefSubject.SynchronizedOps
|
|
21
|
-
*/
|
|
22
|
-
export interface SynchronizedRefSubjectOps {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @tsplus static fncts.io.Push.RefSubjectOps Synchronized
|
|
26
|
-
*/
|
|
27
|
-
export const Synchronized: SynchronizedRefSubjectOps = {};
|
|
28
|
-
|
|
29
|
-
export class SynchronizedRefSubjectInternal<R, E, A, B>
|
|
30
|
-
extends RefSubjectInternal<R, E, A, B>
|
|
31
|
-
implements SynchronizedRefSubject<R, E, A, B>
|
|
32
|
-
{
|
|
33
|
-
readonly [SynchronizedRefSubjectTypeId]: SynchronizedRefSubjectTypeId = SynchronizedRefSubjectTypeId;
|
|
34
|
-
constructor(
|
|
35
|
-
readonly semaphore: TSemaphore,
|
|
36
|
-
readonly ref: RefSubjectInternal<R, E, A, B>,
|
|
37
|
-
) {
|
|
38
|
-
super();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get get(): IO<R, never, B> {
|
|
42
|
-
return this.withPermit(this.ref.get);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
set(a: A, __tsplusTrace?: string | undefined): IO<R, never, void> {
|
|
46
|
-
return this.withPermit(this.ref.set(a));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
run<R1>(emitter: Sink<R1, E, B>): IO<R | R1, never, void> {
|
|
50
|
-
return this.ref.run(emitter);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
modify<C>(f: (b: B) => readonly [C, A], __tsplusTrace?: string | undefined): IO<R, never, C> {
|
|
54
|
-
return this.modifyIO((a) => IO.succeedNow(f(a)));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
modifyIO<R1, E1, C>(f: (b: B) => IO<R1, E1, readonly [C, A]>, __tsplusTrace?: string): IO<R | R1, E1, C> {
|
|
58
|
-
return this.withPermit(this.ref.get.flatMap(f).flatMap(([b, a]) => this.ref.set(a).as(b)));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
event(value: A): IO<R, never, void> {
|
|
62
|
-
return this.withPermit(this.ref.event(value));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
error(cause: Cause<E>): IO<R, never, void> {
|
|
66
|
-
return this.withPermit(this.ref.error(cause));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
withPermit<R, E, A>(io: IO<R, E, A>, __tsplusTrace?: string): IO<R, E, A> {
|
|
70
|
-
return this.semaphore.withPermit(io);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get unsafeGet(): B {
|
|
74
|
-
return this.ref.unsafeGet;
|
|
75
|
-
}
|
|
76
|
-
}
|