@typed/fx 1.23.0 → 1.24.1
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/dist/cjs/AsyncData.js.map +1 -1
- package/dist/cjs/Form.js.map +1 -1
- package/dist/cjs/FormEntry.js.map +1 -1
- package/dist/cjs/Fx.js +1 -1
- package/dist/cjs/Fx.js.map +1 -1
- package/dist/cjs/Match.js.map +1 -1
- package/dist/cjs/Pull.js +5 -3
- package/dist/cjs/Pull.js.map +1 -1
- package/dist/cjs/RefArray.js.map +1 -1
- package/dist/cjs/RefChunk.js.map +1 -1
- package/dist/cjs/RefHashSet.js.map +1 -1
- package/dist/cjs/RefSubject.js +24 -24
- package/dist/cjs/RefSubject.js.map +1 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Subject.js.map +1 -1
- package/dist/cjs/Versioned.js.map +1 -1
- package/dist/cjs/internal/core.js +3 -2
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/keyed.js.map +1 -1
- package/dist/cjs/internal/provide.js.map +1 -1
- package/dist/dts/AsyncData.d.ts +36 -36
- package/dist/dts/AsyncData.d.ts.map +1 -1
- package/dist/dts/Emitter.d.ts +2 -2
- package/dist/dts/Form.d.ts +6 -6
- package/dist/dts/Form.d.ts.map +1 -1
- package/dist/dts/FormEntry.d.ts +8 -8
- package/dist/dts/Fx.d.ts +414 -414
- package/dist/dts/Fx.d.ts.map +1 -1
- package/dist/dts/Guard.d.ts +21 -21
- package/dist/dts/Guard.d.ts.map +1 -1
- package/dist/dts/Idle.d.ts +3 -3
- package/dist/dts/Idle.d.ts.map +1 -1
- package/dist/dts/Match.d.ts +16 -16
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/Pull.d.ts +5 -5
- package/dist/dts/Pull.d.ts.map +1 -1
- package/dist/dts/Push.d.ts +40 -40
- package/dist/dts/Push.d.ts.map +1 -1
- package/dist/dts/RefArray.d.ts +59 -59
- package/dist/dts/RefArray.d.ts.map +1 -1
- package/dist/dts/RefChunk.d.ts +45 -45
- package/dist/dts/RefChunk.d.ts.map +1 -1
- package/dist/dts/RefHashMap.d.ts +35 -35
- package/dist/dts/RefHashMap.d.ts.map +1 -1
- package/dist/dts/RefHashSet.d.ts +17 -17
- package/dist/dts/RefHashSet.d.ts.map +1 -1
- package/dist/dts/RefSubject.d.ts +127 -127
- package/dist/dts/RefSubject.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +60 -60
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +11 -11
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Subject.d.ts +10 -10
- package/dist/dts/Subject.d.ts.map +1 -1
- package/dist/dts/Typeclass.d.ts +1 -1
- package/dist/dts/Typeclass.d.ts.map +1 -1
- package/dist/dts/Versioned.d.ts +28 -28
- package/dist/dts/Versioned.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/internal/DeferredRef.d.ts +1 -1
- package/dist/dts/internal/DeferredRef.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts +191 -191
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/effect-loop-operator.d.ts +2 -2
- package/dist/dts/internal/effect-loop-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-operator.d.ts +9 -9
- package/dist/dts/internal/effect-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-producer.d.ts +10 -10
- package/dist/dts/internal/effect-producer.d.ts.map +1 -1
- package/dist/dts/internal/helpers.d.ts +16 -16
- package/dist/dts/internal/helpers.d.ts.map +1 -1
- package/dist/dts/internal/keyed.d.ts +1 -1
- package/dist/dts/internal/keyed.d.ts.map +1 -1
- package/dist/dts/internal/loop-operator.d.ts +2 -2
- package/dist/dts/internal/loop-operator.d.ts.map +1 -1
- package/dist/dts/internal/operator.d.ts +2 -2
- package/dist/dts/internal/operator.d.ts.map +1 -1
- package/dist/dts/internal/protos.d.ts +7 -7
- package/dist/dts/internal/protos.d.ts.map +1 -1
- package/dist/dts/internal/provide.d.ts +10 -10
- package/dist/dts/internal/provide.d.ts.map +1 -1
- package/dist/dts/internal/share.d.ts +10 -10
- package/dist/dts/internal/share.d.ts.map +1 -1
- package/dist/dts/internal/sync-operator.d.ts +2 -2
- package/dist/dts/internal/sync-operator.d.ts.map +1 -1
- package/dist/dts/internal/sync-producer.d.ts +4 -4
- package/dist/dts/internal/sync-producer.d.ts.map +1 -1
- package/dist/dts/internal/withKey.d.ts +1 -1
- package/dist/dts/internal/withKey.d.ts.map +1 -1
- package/dist/esm/AsyncData.js.map +1 -1
- package/dist/esm/Form.js.map +1 -1
- package/dist/esm/FormEntry.js.map +1 -1
- package/dist/esm/Fx.js +1 -1
- package/dist/esm/Fx.js.map +1 -1
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Pull.js +3 -3
- package/dist/esm/Pull.js.map +1 -1
- package/dist/esm/RefArray.js.map +1 -1
- package/dist/esm/RefChunk.js.map +1 -1
- package/dist/esm/RefHashSet.js.map +1 -1
- package/dist/esm/RefSubject.js +19 -18
- package/dist/esm/RefSubject.js.map +1 -1
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Subject.js.map +1 -1
- package/dist/esm/Versioned.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/core.js +3 -2
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/keyed.js.map +1 -1
- package/dist/esm/internal/provide.js.map +1 -1
- package/package.json +2 -2
- package/src/AsyncData.ts +71 -73
- package/src/Emitter.ts +5 -5
- package/src/Form.ts +27 -27
- package/src/FormEntry.ts +29 -29
- package/src/Fx.ts +735 -734
- package/src/Guard.ts +39 -39
- package/src/Idle.ts +4 -4
- package/src/Match.ts +57 -58
- package/src/Pull.ts +35 -36
- package/src/Push.ts +170 -170
- package/src/RefArray.ts +114 -112
- package/src/RefChunk.ts +93 -92
- package/src/RefHashMap.ts +71 -71
- package/src/RefHashSet.ts +40 -39
- package/src/RefSubject.ts +457 -448
- package/src/Sink.ts +235 -235
- package/src/Stream.ts +20 -20
- package/src/Subject.ts +34 -32
- package/src/Typeclass.ts +2 -2
- package/src/Versioned.ts +75 -75
- package/src/index.ts +1 -1
- package/src/internal/DeferredRef.ts +1 -1
- package/src/internal/core.ts +694 -706
- package/src/internal/effect-loop-operator.ts +3 -3
- package/src/internal/effect-operator.ts +12 -12
- package/src/internal/effect-producer.ts +25 -25
- package/src/internal/helpers.ts +18 -18
- package/src/internal/keyed.ts +18 -18
- package/src/internal/loop-operator.ts +2 -2
- package/src/internal/operator.ts +2 -2
- package/src/internal/protos.ts +8 -8
- package/src/internal/provide.ts +19 -19
- package/src/internal/share.ts +22 -22
- package/src/internal/sync-operator.ts +4 -4
- package/src/internal/sync-producer.ts +6 -6
- package/src/internal/withKey.ts +13 -13
package/src/internal/share.ts
CHANGED
|
@@ -10,10 +10,10 @@ import * as Subject from "../Subject.js"
|
|
|
10
10
|
import { withScopedFork } from "./helpers.js"
|
|
11
11
|
import { FxBase } from "./protos.js"
|
|
12
12
|
|
|
13
|
-
export function share<
|
|
14
|
-
fx: Fx<
|
|
15
|
-
subject: Subject.Subject<
|
|
16
|
-
): Fx<R | R2 | Scope.Scope
|
|
13
|
+
export function share<A, E, R, R2>(
|
|
14
|
+
fx: Fx<A, E, R>,
|
|
15
|
+
subject: Subject.Subject<A, E, R2>
|
|
16
|
+
): Fx<A, E, R | R2 | Scope.Scope> {
|
|
17
17
|
return new Share(fx, subject)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -29,18 +29,18 @@ class RefCounter {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export class Share<
|
|
32
|
+
export class Share<A, E, R, R2> extends FxBase<A, E, R | R2 | Scope.Scope> {
|
|
33
33
|
_FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<unknown>>> = MutableRef.make(Option.none())
|
|
34
34
|
_RefCount = new RefCounter()
|
|
35
35
|
|
|
36
36
|
constructor(
|
|
37
|
-
readonly i0: Fx<
|
|
38
|
-
readonly i1: Subject.Subject<
|
|
37
|
+
readonly i0: Fx<A, E, R>,
|
|
38
|
+
readonly i1: Subject.Subject<A, E, R2>
|
|
39
39
|
) {
|
|
40
40
|
super()
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
run<R3>(sink: Sink<
|
|
43
|
+
run<R3>(sink: Sink<A, E, R3>): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope> {
|
|
44
44
|
return withScopedFork(
|
|
45
45
|
(fork) =>
|
|
46
46
|
Effect.flatMap(
|
|
@@ -89,24 +89,24 @@ export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export function multicast<
|
|
93
|
-
fx: Fx<
|
|
94
|
-
): Fx<R | Scope.Scope
|
|
95
|
-
return new Share(fx, Subject.unsafeMake<
|
|
92
|
+
export function multicast<A, E, R>(
|
|
93
|
+
fx: Fx<A, E, R>
|
|
94
|
+
): Fx<A, E, R | Scope.Scope> {
|
|
95
|
+
return new Share(fx, Subject.unsafeMake<A, E>(0))
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export function hold<
|
|
99
|
-
fx: Fx<
|
|
100
|
-
): Fx<R | Scope.Scope
|
|
101
|
-
return new Share(fx, Subject.unsafeMake<
|
|
98
|
+
export function hold<A, E, R>(
|
|
99
|
+
fx: Fx<A, E, R>
|
|
100
|
+
): Fx<A, E, R | Scope.Scope> {
|
|
101
|
+
return new Share(fx, Subject.unsafeMake<A, E>(1))
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export const replay: {
|
|
105
|
-
(capacity: number): <
|
|
106
|
-
<
|
|
107
|
-
} = dual(2, function replay<
|
|
108
|
-
fx: Fx<
|
|
105
|
+
(capacity: number): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>
|
|
106
|
+
<A, E, R>(fx: Fx<A, E, R>, capacity: number): Fx<A, E, R>
|
|
107
|
+
} = dual(2, function replay<A, E, R>(
|
|
108
|
+
fx: Fx<A, E, R>,
|
|
109
109
|
capacity: number
|
|
110
|
-
): Fx<R | Scope.Scope
|
|
111
|
-
return new Share(fx, Subject.unsafeMake<
|
|
110
|
+
): Fx<A, E, R | Scope.Scope> {
|
|
111
|
+
return new Share(fx, Subject.unsafeMake<A, E>(capacity))
|
|
112
112
|
})
|
|
@@ -80,8 +80,8 @@ export function matchSyncOperator<A>(operator: SyncOperator, matchers: {
|
|
|
80
80
|
|
|
81
81
|
export function compileSyncOperatorSink<R>(
|
|
82
82
|
operator: SyncOperator,
|
|
83
|
-
sink: Sink.Sink<
|
|
84
|
-
): Sink.Sink<
|
|
83
|
+
sink: Sink.Sink<any, any, R>
|
|
84
|
+
): Sink.Sink<any, any, R> {
|
|
85
85
|
return matchSyncOperator(operator, {
|
|
86
86
|
Map: (op) => Sink.map(sink, op.f),
|
|
87
87
|
Filter: (op) => Sink.filter(sink, op.f),
|
|
@@ -91,8 +91,8 @@ export function compileSyncOperatorSink<R>(
|
|
|
91
91
|
|
|
92
92
|
export function compileCauseSyncOperatorSink<R>(
|
|
93
93
|
operator: SyncOperator,
|
|
94
|
-
sink: Sink.Sink<
|
|
95
|
-
): Sink.Sink<
|
|
94
|
+
sink: Sink.Sink<any, any, R>
|
|
95
|
+
): Sink.Sink<any, any, R> {
|
|
96
96
|
return matchSyncOperator(operator, {
|
|
97
97
|
Map: (op) => Sink.make((a) => sink.onFailure(op.f(a)), sink.onSuccess),
|
|
98
98
|
Filter: (op) => Sink.make((a) => op.f(a) ? sink.onFailure(a) : Effect.unit, sink.onSuccess),
|
|
@@ -47,7 +47,7 @@ export const matchSyncProducer = <A, R>(
|
|
|
47
47
|
|
|
48
48
|
export function runSink<A, R, E>(
|
|
49
49
|
producer: SyncProducer<A>,
|
|
50
|
-
sink: Sink<
|
|
50
|
+
sink: Sink<A, E, R>
|
|
51
51
|
): Effect.Effect<unknown, never, R> {
|
|
52
52
|
return matchSyncProducer(producer, {
|
|
53
53
|
Success: (a) => sink.onSuccess(a),
|
|
@@ -70,7 +70,7 @@ export function runReduce<A, B>(
|
|
|
70
70
|
})
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export function runReduceEffect<A,
|
|
73
|
+
export function runReduceEffect<A, B, E2, R2>(
|
|
74
74
|
producer: SyncProducer<A>,
|
|
75
75
|
initial: B,
|
|
76
76
|
f: (b: B, a: any) => Effect.Effect<B, E2, R2>
|
|
@@ -83,7 +83,7 @@ export function runReduceEffect<A, R2, E2, B>(
|
|
|
83
83
|
})
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
function arrayToSink<A, R2>(array: ReadonlyArray<A>, sink: Sink<
|
|
86
|
+
function arrayToSink<A, R2>(array: ReadonlyArray<A>, sink: Sink<A, never, R2>): Effect.Effect<unknown, never, R2> {
|
|
87
87
|
if (array.length === 0) return Effect.unit
|
|
88
88
|
else if (array.length === 1) return sink.onSuccess(array[0])
|
|
89
89
|
else {
|
|
@@ -96,7 +96,7 @@ function arrayToSink<A, R2>(array: ReadonlyArray<A>, sink: Sink<R2, never, A>):
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<
|
|
99
|
+
function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<A, never, R2>): Effect.Effect<unknown, never, R2> {
|
|
100
100
|
let effect: Effect.Effect<any, never, R2> = Effect.unit
|
|
101
101
|
|
|
102
102
|
for (const item of array) {
|
|
@@ -121,7 +121,7 @@ export const syncOnce = <A>(f: () => A): Effect.Effect<A> => {
|
|
|
121
121
|
return Effect.sync(get)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
export const effectOnce = <
|
|
124
|
+
export const effectOnce = <A, E, R>(f: () => Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => {
|
|
125
125
|
let memoized: Option.Option<A> = Option.none()
|
|
126
126
|
|
|
127
127
|
return Effect.suspend(() => {
|
|
@@ -133,7 +133,7 @@ export const effectOnce = <R, E, A>(f: () => Effect.Effect<A, E, R>): Effect.Eff
|
|
|
133
133
|
})
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
export function runEffect<A,
|
|
136
|
+
export function runEffect<A, B, E2, R2>(
|
|
137
137
|
producer: SyncProducer<A>,
|
|
138
138
|
f: (a: A) => Effect.Effect<B, E2, R2>
|
|
139
139
|
): Effect.Effect<void, E2, R2> {
|
package/src/internal/withKey.ts
CHANGED
|
@@ -9,28 +9,28 @@ import * as Sink from "../Sink.js"
|
|
|
9
9
|
import { withSwitchFork } from "./helpers.js"
|
|
10
10
|
import { FxBase } from "./protos.js"
|
|
11
11
|
|
|
12
|
-
export function withKey<
|
|
13
|
-
fx: Fx<
|
|
14
|
-
options: WithKeyOptions<A, B,
|
|
15
|
-
): Fx<R | R2 | Scope.Scope
|
|
12
|
+
export function withKey<A, E, R, B extends PropertyKey, C, E2, R2>(
|
|
13
|
+
fx: Fx<A, E, R>,
|
|
14
|
+
options: WithKeyOptions<A, B, C, E2, R2>
|
|
15
|
+
): Fx<C, E | E2, R | R2 | Scope.Scope> {
|
|
16
16
|
return new WithKey(fx, options)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
class WithKey<
|
|
20
|
-
constructor(readonly fx: Fx<
|
|
19
|
+
class WithKey<A, E, R, B extends PropertyKey, C, E2, R2> extends FxBase<C, E | E2, R | R2 | Scope.Scope> {
|
|
20
|
+
constructor(readonly fx: Fx<A, E, R>, readonly options: WithKeyOptions<A, B, C, E2, R2>) {
|
|
21
21
|
super()
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
run<R3>(sink: Sink.Sink<
|
|
24
|
+
run<R3>(sink: Sink.Sink<C, E | E2, R3>) {
|
|
25
25
|
return runWithKey(this.fx, this.options, sink)
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function runWithKey<
|
|
30
|
-
fx: Fx<
|
|
31
|
-
options: WithKeyOptions<A, B,
|
|
32
|
-
sink: Sink.Sink<
|
|
33
|
-
) {
|
|
29
|
+
function runWithKey<A, E, R, B extends PropertyKey, C, E2, R2, R3>(
|
|
30
|
+
fx: Fx<A, E, R>,
|
|
31
|
+
options: WithKeyOptions<A, B, C, E2, R2>,
|
|
32
|
+
sink: Sink.Sink<C, E | E2, R3>
|
|
33
|
+
): Effect.Effect<unknown, never, R | R2 | R3 | Scope.Scope> {
|
|
34
34
|
return withSwitchFork((fork) => {
|
|
35
35
|
let previous: Option.Option<WithKeyState<A, B>> = Option.none()
|
|
36
36
|
|
|
@@ -78,5 +78,5 @@ function runWithKey<R, E, A, B extends PropertyKey, R2, E2, C, R3>(
|
|
|
78
78
|
type WithKeyState<A, B> = {
|
|
79
79
|
value: A
|
|
80
80
|
key: B
|
|
81
|
-
ref: RefSubject.RefSubject<
|
|
81
|
+
ref: RefSubject.RefSubject<A>
|
|
82
82
|
}
|