@typed/fx 1.22.2 → 1.24.0
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/Idle.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 +3 -2
- 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.map +1 -1
- package/dist/cjs/internal/helpers.js.map +1 -1
- package/dist/cjs/internal/keyed.js +1 -1
- package/dist/cjs/internal/keyed.js.map +1 -1
- package/dist/cjs/internal/provide.js.map +1 -1
- package/dist/cjs/internal/share.js.map +1 -1
- package/dist/cjs/internal/sync-producer.js.map +1 -1
- package/dist/dts/AsyncData.d.ts +53 -53
- package/dist/dts/AsyncData.d.ts.map +1 -1
- package/dist/dts/Emitter.d.ts +7 -7
- package/dist/dts/Emitter.d.ts.map +1 -1
- package/dist/dts/Form.d.ts +14 -14
- package/dist/dts/Form.d.ts.map +1 -1
- package/dist/dts/FormEntry.d.ts +11 -11
- package/dist/dts/FormEntry.d.ts.map +1 -1
- package/dist/dts/Fx.d.ts +417 -417
- 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 +12 -12
- 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 +136 -136
- package/dist/dts/RefSubject.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +63 -63
- 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 +13 -13
- 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 +33 -33
- package/dist/dts/Versioned.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/internal/DeferredRef.d.ts +8 -8
- 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 +6 -6
- package/dist/dts/internal/effect-loop-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-operator.d.ts +16 -16
- package/dist/dts/internal/effect-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-producer.d.ts +13 -13
- package/dist/dts/internal/effect-producer.d.ts.map +1 -1
- package/dist/dts/internal/helpers.d.ts +26 -26
- 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 +12 -12
- package/dist/dts/internal/protos.d.ts.map +1 -1
- package/dist/dts/internal/provide.d.ts +15 -15
- package/dist/dts/internal/provide.d.ts.map +1 -1
- package/dist/dts/internal/share.d.ts +11 -11
- 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 +6 -6
- 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/Idle.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 +3 -1
- 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.map +1 -1
- package/dist/esm/internal/helpers.js.map +1 -1
- package/dist/esm/internal/keyed.js +1 -1
- package/dist/esm/internal/keyed.js.map +1 -1
- package/dist/esm/internal/provide.js.map +1 -1
- package/dist/esm/internal/share.js.map +1 -1
- package/dist/esm/internal/sync-producer.js.map +1 -1
- package/package.json +6 -6
- package/src/AsyncData.ts +142 -144
- package/src/Emitter.ts +13 -13
- package/src/Form.ts +55 -55
- package/src/FormEntry.ts +39 -39
- package/src/Fx.ts +788 -789
- package/src/Guard.ts +43 -43
- package/src/Idle.ts +26 -26
- package/src/Match.ts +60 -61
- package/src/Pull.ts +42 -43
- package/src/Push.ts +195 -195
- package/src/RefArray.ts +121 -119
- package/src/RefChunk.ts +98 -97
- package/src/RefHashMap.ts +79 -79
- package/src/RefHashSet.ts +40 -39
- package/src/RefSubject.ts +574 -565
- package/src/Sink.ts +303 -303
- package/src/Stream.ts +27 -27
- package/src/Subject.ts +48 -46
- package/src/Typeclass.ts +2 -2
- package/src/Versioned.ts +97 -97
- package/src/index.ts +1 -1
- package/src/internal/DeferredRef.ts +7 -7
- package/src/internal/core.ts +768 -781
- package/src/internal/effect-loop-operator.ts +7 -7
- package/src/internal/effect-operator.ts +23 -23
- package/src/internal/effect-producer.ts +38 -38
- package/src/internal/helpers.ts +51 -51
- package/src/internal/keyed.ts +21 -21
- package/src/internal/loop-operator.ts +2 -2
- package/src/internal/operator.ts +2 -2
- package/src/internal/protos.ts +15 -15
- package/src/internal/provide.ts +27 -27
- package/src/internal/share.ts +25 -25
- package/src/internal/sync-operator.ts +4 -4
- package/src/internal/sync-producer.ts +15 -15
- package/src/internal/withKey.ts +13 -13
|
@@ -216,14 +216,14 @@ export function fuseLoopOperators<A, B, C, D, E>(
|
|
|
216
216
|
})
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
export function compileLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<
|
|
219
|
+
export function compileLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<any, any, R>) {
|
|
220
220
|
return matchSyncLoopOperator(operator, {
|
|
221
221
|
Loop: (op) => Sink.loop(sink, op.seed, op.f),
|
|
222
222
|
FilterMapLoop: (op) => Sink.filterMapLoop(sink, op.seed, op.f)
|
|
223
223
|
})
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
export function compileCauseLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<
|
|
226
|
+
export function compileCauseLoopOperatorSink<R>(operator: SyncLoopOperator, sink: Sink.Sink<any, any, R>) {
|
|
227
227
|
return matchSyncLoopOperator(operator, {
|
|
228
228
|
Loop: (op) => Sink.loopCause(sink, op.seed, op.f),
|
|
229
229
|
FilterMapLoop: (op) => Sink.filterMapLoopCause(sink, op.seed, op.f)
|
package/src/internal/operator.ts
CHANGED
|
@@ -68,7 +68,7 @@ export function fuseOperators(first: Operator, second: Operator): Operator {
|
|
|
68
68
|
})
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export function compileOperatorSink<R, R2>(operator: Operator, sink: Sink<
|
|
71
|
+
export function compileOperatorSink<R, R2>(operator: Operator, sink: Sink<any, any, R>): Sink<any, any, R | R2> {
|
|
72
72
|
return matchOperator(operator, {
|
|
73
73
|
SyncOperator: (op) => SyncOp.compileSyncOperatorSink(op, sink),
|
|
74
74
|
EffectOperator: (op) => EffectOp.compileEffectOperatorSink(op, sink),
|
|
@@ -77,7 +77,7 @@ export function compileOperatorSink<R, R2>(operator: Operator, sink: Sink<R, any
|
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export function compileOperatorSinkCause<R, R2>(operator: Operator, sink: Sink<
|
|
80
|
+
export function compileOperatorSinkCause<R, R2>(operator: Operator, sink: Sink<any, any, R>): Sink<any, any, R | R2> {
|
|
81
81
|
return matchOperator(operator, {
|
|
82
82
|
SyncOperator: (op) => SyncOp.compileCauseSyncOperatorSink(op, sink),
|
|
83
83
|
EffectOperator: (op) => EffectOp.compileCauseEffectOperatorSink(op, sink),
|
package/src/internal/protos.ts
CHANGED
|
@@ -12,27 +12,27 @@ const Variance: Fx.Variance<never, never, never> = {
|
|
|
12
12
|
_A: identity
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export abstract class FxBase<
|
|
16
|
-
readonly [TypeId]: Fx.Variance<
|
|
15
|
+
export abstract class FxBase<A, E, R> implements Fx<A, E, R> {
|
|
16
|
+
readonly [TypeId]: Fx.Variance<A, E, R> = Variance
|
|
17
17
|
|
|
18
|
-
abstract run<R2>(sink: Sink<
|
|
18
|
+
abstract run<R2>(sink: Sink<A, E, R2>): Effect.Effect<unknown, never, R | R2>
|
|
19
19
|
|
|
20
20
|
pipe() {
|
|
21
21
|
return pipeArguments(this, arguments)
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export abstract class FxEffectBase<
|
|
26
|
-
implements Fx<
|
|
25
|
+
export abstract class FxEffectBase<A, E, R, B, E2, R2> extends Effectable.StructuralClass<B, E2, R2>
|
|
26
|
+
implements Fx<A, E, R>, Effect.Effect<B, E2, R2>
|
|
27
27
|
{
|
|
28
|
-
readonly [TypeId]: Fx.Variance<
|
|
28
|
+
readonly [TypeId]: Fx.Variance<A, E, R> = Variance
|
|
29
29
|
|
|
30
|
-
abstract run<R3>(sink: Sink<
|
|
30
|
+
abstract run<R3>(sink: Sink<A, E, R3>): Effect.Effect<unknown, never, R | R3>
|
|
31
31
|
|
|
32
|
-
abstract toEffect(): Effect.Effect<
|
|
32
|
+
abstract toEffect(): Effect.Effect<B, E2, R2>
|
|
33
33
|
|
|
34
|
-
protected _effect: Effect.Effect<
|
|
35
|
-
commit(): Effect.Effect<
|
|
34
|
+
protected _effect: Effect.Effect<B, E2, R2> | undefined
|
|
35
|
+
commit(): Effect.Effect<B, E2, R2> {
|
|
36
36
|
if (this._effect === undefined) {
|
|
37
37
|
return (this._effect = this.toEffect())
|
|
38
38
|
} else {
|
|
@@ -41,13 +41,13 @@ export abstract class FxEffectBase<R, E, A, R2, E2, B> extends Effectable.Struct
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export abstract class EffectBase<
|
|
45
|
-
implements Effect.Effect<
|
|
44
|
+
export abstract class EffectBase<A, E, R> extends Effectable.StructuralClass<A, E, R>
|
|
45
|
+
implements Effect.Effect<A, E, R>
|
|
46
46
|
{
|
|
47
|
-
abstract toEffect(): Effect.Effect<
|
|
47
|
+
abstract toEffect(): Effect.Effect<A, E, R>
|
|
48
48
|
|
|
49
|
-
private _effect: Effect.Effect<
|
|
50
|
-
commit(): Effect.Effect<
|
|
49
|
+
private _effect: Effect.Effect<A, E, R> | undefined
|
|
50
|
+
commit(): Effect.Effect<A, E, R> {
|
|
51
51
|
if (this._effect === undefined) {
|
|
52
52
|
return (this._effect = this.toEffect())
|
|
53
53
|
} else {
|
package/src/internal/provide.ts
CHANGED
|
@@ -6,12 +6,12 @@ import * as Runtime from "effect/Runtime"
|
|
|
6
6
|
import * as RuntimeFlags from "effect/RuntimeFlags"
|
|
7
7
|
import type * as Scope from "effect/Scope"
|
|
8
8
|
|
|
9
|
-
export type Provide<
|
|
9
|
+
export type Provide<A, E, R> =
|
|
10
10
|
| ProvideContext<A>
|
|
11
|
-
| ProvideLayer<
|
|
11
|
+
| ProvideLayer<A, E, R>
|
|
12
12
|
| ProvideRuntime<A>
|
|
13
13
|
| ProvideService<A, any>
|
|
14
|
-
| ProvideServiceEffect<
|
|
14
|
+
| ProvideServiceEffect<A, any, E, R>
|
|
15
15
|
|
|
16
16
|
export interface ProvideContext<A> {
|
|
17
17
|
readonly _tag: "ProvideContext"
|
|
@@ -23,12 +23,12 @@ export const ProvideContext = <A>(i0: Context.Context<A>): ProvideContext<A> =>
|
|
|
23
23
|
i0
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
export interface ProvideLayer<
|
|
26
|
+
export interface ProvideLayer<A, E, R> {
|
|
27
27
|
readonly _tag: "ProvideLayer"
|
|
28
|
-
readonly i0: Layer.Layer<
|
|
28
|
+
readonly i0: Layer.Layer<A, E, R>
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const ProvideLayer = <
|
|
31
|
+
export const ProvideLayer = <A, E, R>(i0: Layer.Layer<A, E, R>): ProvideLayer<A, E, R> => ({
|
|
32
32
|
_tag: "ProvideLayer",
|
|
33
33
|
i0
|
|
34
34
|
})
|
|
@@ -45,16 +45,16 @@ export const ProvideService = <I, S>(i0: Context.Tag<I, S>, i1: S): ProvideServi
|
|
|
45
45
|
i1
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
export interface ProvideServiceEffect<
|
|
48
|
+
export interface ProvideServiceEffect<I, S, E, R> {
|
|
49
49
|
readonly _tag: "ProvideServiceEffect"
|
|
50
50
|
readonly i0: Context.Tag<I, S>
|
|
51
|
-
readonly i1: Effect.Effect<
|
|
51
|
+
readonly i1: Effect.Effect<S, E, R>
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export const ProvideServiceEffect = <
|
|
54
|
+
export const ProvideServiceEffect = <I, S, E, R>(
|
|
55
55
|
i0: Context.Tag<I, S>,
|
|
56
|
-
i1: Effect.Effect<
|
|
57
|
-
): ProvideServiceEffect<
|
|
56
|
+
i1: Effect.Effect<S, E, R>
|
|
57
|
+
): ProvideServiceEffect<I, S, E, R> => ({
|
|
58
58
|
_tag: "ProvideServiceEffect",
|
|
59
59
|
i0,
|
|
60
60
|
i1
|
|
@@ -70,34 +70,34 @@ export const ProvideRuntime = <A>(i0: Runtime.Runtime<A>): ProvideRuntime<A> =>
|
|
|
70
70
|
i0
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
export function matchProvide<
|
|
74
|
-
self: Provide<
|
|
73
|
+
export function matchProvide<A, E, R, B>(
|
|
74
|
+
self: Provide<A, E, R>,
|
|
75
75
|
matchers: {
|
|
76
76
|
readonly ProvideContext: (i0: Context.Context<A>) => B
|
|
77
77
|
readonly ProvideRuntime: (i0: Runtime.Runtime<A>) => B
|
|
78
|
-
readonly ProvideLayer: (i0: Layer.Layer<
|
|
78
|
+
readonly ProvideLayer: (i0: Layer.Layer<A, E, R>) => B
|
|
79
79
|
readonly ProvideService: (tag: Context.Tag<A, any>, service: any) => B
|
|
80
|
-
readonly ProvideServiceEffect: (tag: Context.Tag<A, any>, service: Effect.Effect<
|
|
80
|
+
readonly ProvideServiceEffect: (tag: Context.Tag<A, any>, service: Effect.Effect<any, E, R>) => B
|
|
81
81
|
}
|
|
82
82
|
): B {
|
|
83
83
|
return matchers[self._tag](self.i0 as any, (self as any).i1)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export function merge<
|
|
87
|
-
self: Provide<
|
|
88
|
-
that: Provide<
|
|
89
|
-
): Provide<
|
|
86
|
+
export function merge<A, E, R, B, E2, R2>(
|
|
87
|
+
self: Provide<A, E, R>,
|
|
88
|
+
that: Provide<B, E2, R2>
|
|
89
|
+
): Provide<A | B, E | E2, Exclude<R, B> | R2> {
|
|
90
90
|
return ProvideLayer(Layer.provideMerge(toLayer(self), toLayer(that)))
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export function buildWithScope<
|
|
94
|
-
provide: Provide<
|
|
93
|
+
export function buildWithScope<A, E, R>(
|
|
94
|
+
provide: Provide<A, E, R>,
|
|
95
95
|
scope: Scope.Scope
|
|
96
96
|
) {
|
|
97
97
|
return Layer.buildWithScope(toLayer(provide), scope)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export function toLayer<
|
|
100
|
+
export function toLayer<A, E, R>(provide: Provide<A, E, R>): Layer.Layer<A, E, R> {
|
|
101
101
|
switch (provide._tag) {
|
|
102
102
|
case "ProvideContext":
|
|
103
103
|
return Layer.succeedContext(provide.i0)
|
|
@@ -112,14 +112,14 @@ export function toLayer<R, E, A>(provide: Provide<R, E, A>): Layer.Layer<R, E, A
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
export function provideToEffect<
|
|
116
|
-
effect: Effect.Effect<
|
|
117
|
-
provide: Provide<
|
|
118
|
-
): Effect.Effect<Exclude<R, S> | R2
|
|
115
|
+
export function provideToEffect<A, E, R, R2 = never, E2 = never, S = never>(
|
|
116
|
+
effect: Effect.Effect<A, E, R>,
|
|
117
|
+
provide: Provide<S, E, R2>
|
|
118
|
+
): Effect.Effect<A, E | E2, Exclude<R, S> | R2> {
|
|
119
119
|
return Effect.provide(effect, toLayer(provide))
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export function runtimeToLayer<R>(runtime: Runtime.Runtime<R>): Layer.Layer<
|
|
122
|
+
export function runtimeToLayer<R>(runtime: Runtime.Runtime<R>): Layer.Layer<R> {
|
|
123
123
|
// Calculate patch
|
|
124
124
|
const patchRefs = FiberRefsPatch.diff(Runtime.defaultRuntime.fiberRefs, runtime.fiberRefs)
|
|
125
125
|
const patchFlags = RuntimeFlags.diff(Runtime.defaultRuntime.runtimeFlags, runtime.runtimeFlags)
|
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<
|
|
33
|
-
_FxFiber: MutableRef.MutableRef<Option.Option<Fiber.Fiber<
|
|
32
|
+
export class Share<A, E, R, R2> extends FxBase<A, E, R | R2 | Scope.Scope> {
|
|
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(
|
|
@@ -53,7 +53,7 @@ export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
|
|
|
53
53
|
)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
private initialize(): Effect.Effect<R | R2
|
|
56
|
+
private initialize(): Effect.Effect<unknown, never, R | R2> {
|
|
57
57
|
return Effect.suspend(() => {
|
|
58
58
|
if (this._RefCount.increment() === 1) {
|
|
59
59
|
return this.i0.run(this.i1).pipe(
|
|
@@ -80,7 +80,7 @@ export class Share<R, E, A, R2> extends FxBase<R | R2 | Scope.Scope, E, A> {
|
|
|
80
80
|
})
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
private interrupt(): Effect.Effect<R | R2
|
|
83
|
+
private interrupt(): Effect.Effect<void, never, R | R2> {
|
|
84
84
|
return Effect.suspend(() => {
|
|
85
85
|
const fiber = Option.getOrNull(MutableRef.getAndSet(this._FxFiber, Option.none()))
|
|
86
86
|
|
|
@@ -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,8 +47,8 @@ export const matchSyncProducer = <A, R>(
|
|
|
47
47
|
|
|
48
48
|
export function runSink<A, R, E>(
|
|
49
49
|
producer: SyncProducer<A>,
|
|
50
|
-
sink: Sink<
|
|
51
|
-
): Effect.Effect<
|
|
50
|
+
sink: Sink<A, E, R>
|
|
51
|
+
): Effect.Effect<unknown, never, R> {
|
|
52
52
|
return matchSyncProducer(producer, {
|
|
53
53
|
Success: (a) => sink.onSuccess(a),
|
|
54
54
|
FromSync: (a) => Effect.suspend(() => sink.onSuccess(a())),
|
|
@@ -61,7 +61,7 @@ export function runReduce<A, B>(
|
|
|
61
61
|
producer: SyncProducer<A>,
|
|
62
62
|
initial: B,
|
|
63
63
|
f: (b: B, a: any) => B
|
|
64
|
-
): Effect.Effect<
|
|
64
|
+
): Effect.Effect<B> {
|
|
65
65
|
return matchSyncProducer(producer, {
|
|
66
66
|
Success: (a) => syncOnce(() => f(initial, a)),
|
|
67
67
|
FromSync: (a) => syncOnce(() => f(initial, a())),
|
|
@@ -70,11 +70,11 @@ 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
|
-
f: (b: B, a: any) => Effect.Effect<
|
|
77
|
-
): Effect.Effect<
|
|
76
|
+
f: (b: B, a: any) => Effect.Effect<B, E2, R2>
|
|
77
|
+
): Effect.Effect<B, E2, R2> {
|
|
78
78
|
return matchSyncProducer(producer, {
|
|
79
79
|
Success: (a) => effectOnce(() => f(initial, a)),
|
|
80
80
|
FromSync: (a) => Effect.suspend(() => f(initial, a())),
|
|
@@ -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,8 +96,8 @@ 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<
|
|
100
|
-
let effect: Effect.Effect<
|
|
99
|
+
function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<A, never, R2>): Effect.Effect<unknown, never, R2> {
|
|
100
|
+
let effect: Effect.Effect<any, never, R2> = Effect.unit
|
|
101
101
|
|
|
102
102
|
for (const item of array) {
|
|
103
103
|
effect = Effect.zipRight(effect, sink.onSuccess(item))
|
|
@@ -106,7 +106,7 @@ function iterableToSink<A, R2>(array: Iterable<A>, sink: Sink<R2, never, A>): Ef
|
|
|
106
106
|
return effect
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export const syncOnce = <A>(f: () => A): Effect.Effect<
|
|
109
|
+
export const syncOnce = <A>(f: () => A): Effect.Effect<A> => {
|
|
110
110
|
let memoized: Option.Option<A> = Option.none()
|
|
111
111
|
const get = () => {
|
|
112
112
|
if (Option.isSome(memoized)) {
|
|
@@ -121,7 +121,7 @@ export const syncOnce = <A>(f: () => A): Effect.Effect<never, never, 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,12 +133,12 @@ export const effectOnce = <R, E, A>(f: () => Effect.Effect<R, E, A>): 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
|
-
f: (a: A) => Effect.Effect<
|
|
139
|
-
): Effect.Effect<
|
|
138
|
+
f: (a: A) => Effect.Effect<B, E2, R2>
|
|
139
|
+
): Effect.Effect<void, E2, R2> {
|
|
140
140
|
return matchSyncProducer(producer, {
|
|
141
|
-
Success: (a): Effect.Effect<
|
|
141
|
+
Success: (a): Effect.Effect<void, E2, R2> => f(a),
|
|
142
142
|
FromSync: (a) => Effect.suspend(() => f(a())),
|
|
143
143
|
FromArray: (a) => Effect.forEach(a, f, DISCARD),
|
|
144
144
|
FromIterable: (a) => Effect.forEach(a, f, DISCARD)
|
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
|
}
|