@typed/fx 2.0.0-beta.0 → 2.0.0-beta.2
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/README.md +24 -1
- package/dist/Fx/combinators/additive.d.ts +94 -0
- package/dist/Fx/combinators/additive.d.ts.map +1 -0
- package/dist/Fx/combinators/additive.js +92 -0
- package/dist/Fx/combinators/catch.d.ts +61 -0
- package/dist/Fx/combinators/catch.d.ts.map +1 -1
- package/dist/Fx/combinators/catch.js +54 -0
- package/dist/Fx/combinators/changesWithEffect.d.ts +20 -0
- package/dist/Fx/combinators/changesWithEffect.d.ts.map +1 -0
- package/dist/Fx/combinators/changesWithEffect.js +28 -0
- package/dist/Fx/combinators/dropUntil.d.ts +29 -0
- package/dist/Fx/combinators/dropUntil.d.ts.map +1 -0
- package/dist/Fx/combinators/dropUntil.js +23 -0
- package/dist/Fx/combinators/flatMapConcurrently.d.ts.map +1 -1
- package/dist/Fx/combinators/flatMapConcurrently.js +3 -2
- package/dist/Fx/combinators/index.d.ts +10 -0
- package/dist/Fx/combinators/index.d.ts.map +1 -1
- package/dist/Fx/combinators/index.js +10 -0
- package/dist/Fx/combinators/keyed.d.ts +1 -1
- package/dist/Fx/combinators/keyed.d.ts.map +1 -1
- package/dist/Fx/combinators/mapBoth.d.ts +21 -0
- package/dist/Fx/combinators/mapBoth.d.ts.map +1 -0
- package/dist/Fx/combinators/mapBoth.js +14 -0
- package/dist/Fx/combinators/mapError.d.ts +17 -0
- package/dist/Fx/combinators/mapError.d.ts.map +1 -0
- package/dist/Fx/combinators/mapError.js +16 -0
- package/dist/Fx/combinators/provide.d.ts +34 -1
- package/dist/Fx/combinators/provide.d.ts.map +1 -1
- package/dist/Fx/combinators/provide.js +27 -0
- package/dist/Fx/combinators/result.d.ts +23 -0
- package/dist/Fx/combinators/result.d.ts.map +1 -0
- package/dist/Fx/combinators/result.js +32 -0
- package/dist/Fx/combinators/scan.d.ts +33 -0
- package/dist/Fx/combinators/scan.d.ts.map +1 -0
- package/dist/Fx/combinators/scan.js +38 -0
- package/dist/Fx/combinators/skip.d.ts +13 -0
- package/dist/Fx/combinators/skip.d.ts.map +1 -1
- package/dist/Fx/combinators/skip.js +11 -0
- package/dist/Fx/combinators/skipWhile.d.ts +49 -0
- package/dist/Fx/combinators/skipWhile.d.ts.map +1 -0
- package/dist/Fx/combinators/skipWhile.js +66 -0
- package/dist/Fx/combinators/slice.d.ts +13 -0
- package/dist/Fx/combinators/slice.d.ts.map +1 -1
- package/dist/Fx/combinators/slice.js +11 -0
- package/dist/Fx/combinators/take.d.ts +13 -0
- package/dist/Fx/combinators/take.d.ts.map +1 -1
- package/dist/Fx/combinators/take.js +11 -0
- package/dist/Fx/combinators/takeUntil.d.ts +14 -0
- package/dist/Fx/combinators/takeUntil.d.ts.map +1 -1
- package/dist/Fx/combinators/takeUntil.js +14 -0
- package/dist/Fx/combinators/takeWhile.d.ts +29 -0
- package/dist/Fx/combinators/takeWhile.d.ts.map +1 -0
- package/dist/Fx/combinators/takeWhile.js +23 -0
- package/dist/Fx/combinators/zip.d.ts +75 -0
- package/dist/Fx/combinators/zip.d.ts.map +1 -0
- package/dist/Fx/combinators/zip.js +100 -0
- package/dist/Fx/constructors/at.d.ts +2 -2
- package/dist/Fx/constructors/at.d.ts.map +1 -1
- package/dist/Fx/constructors/periodic.d.ts +1 -1
- package/dist/Fx/constructors/periodic.d.ts.map +1 -1
- package/dist/Push/Push.d.ts +64 -1
- package/dist/Push/Push.d.ts.map +1 -1
- package/dist/Push/Push.js +57 -0
- package/dist/RefSubject/RefArray.d.ts.map +1 -1
- package/dist/RefSubject/RefArray.js +2 -1
- package/dist/RefSubject/RefChunk.d.ts.map +1 -1
- package/dist/RefSubject/RefChunk.js +2 -1
- package/dist/RefSubject/RefDateTime.d.ts +4 -4
- package/dist/RefSubject/RefDateTime.d.ts.map +1 -1
- package/dist/RefSubject/RefHashMap.d.ts.map +1 -1
- package/dist/RefSubject/RefHashMap.js +5 -1
- package/dist/RefSubject/RefIterable.d.ts +1 -1
- package/dist/RefSubject/RefIterable.d.ts.map +1 -1
- package/dist/RefSubject/RefIterable.js +6 -1
- package/dist/RefSubject/RefRecord.d.ts.map +1 -1
- package/dist/RefSubject/RefRecord.js +3 -2
- package/dist/RefSubject/RefSubject.d.ts +48 -1
- package/dist/RefSubject/RefSubject.d.ts.map +1 -1
- package/dist/RefSubject/RefSubject.js +80 -1
- package/dist/RefSubject/RefTrie.d.ts +7 -7
- package/dist/RefSubject/RefTrie.d.ts.map +1 -1
- package/dist/RefSubject/RefTrie.js +8 -3
- package/dist/Sink/combinators.d.ts +57 -0
- package/dist/Sink/combinators.d.ts.map +1 -1
- package/dist/Sink/combinators.js +104 -1
- package/dist/Versioned/Versioned.d.ts +30 -0
- package/dist/Versioned/Versioned.d.ts.map +1 -1
- package/dist/Versioned/Versioned.js +18 -0
- package/package.json +10 -6
- package/src/Fx/combinators/additive.ts +142 -0
- package/src/Fx/combinators/catch.ts +256 -0
- package/src/Fx/combinators/changesWithEffect.ts +66 -0
- package/src/Fx/combinators/dropUntil.ts +47 -0
- package/src/Fx/combinators/flatMapConcurrently.ts +5 -2
- package/src/Fx/combinators/index.ts +10 -0
- package/src/Fx/combinators/keyed.ts +2 -2
- package/src/Fx/combinators/mapBoth.ts +40 -0
- package/src/Fx/combinators/mapError.ts +28 -0
- package/src/Fx/combinators/provide.ts +63 -1
- package/src/Fx/combinators/result.ts +39 -0
- package/src/Fx/combinators/scan.ts +82 -0
- package/src/Fx/combinators/skip.ts +21 -0
- package/src/Fx/combinators/skipWhile.ts +100 -0
- package/src/Fx/combinators/slice.ts +23 -0
- package/src/Fx/combinators/take.ts +21 -0
- package/src/Fx/combinators/takeUntil.ts +38 -0
- package/src/Fx/combinators/takeWhile.ts +47 -0
- package/src/Fx/combinators/zip.ts +175 -0
- package/src/Fx/constructors/at.ts +3 -3
- package/src/Fx/constructors/periodic.ts +1 -1
- package/src/Fx.additive-combinators.test.ts +126 -0
- package/src/Fx.catch-additive.test.ts +206 -0
- package/src/Fx.catch.test.ts +1 -2
- package/src/Fx.dropUntil.test.ts +61 -0
- package/src/Fx.lifecycle.test.ts +1 -2
- package/src/Fx.mapError-mapBoth.test.ts +101 -0
- package/src/Fx.provide-combinators.test.ts +94 -0
- package/src/Fx.result-changesWithEffect.test.ts +112 -0
- package/src/Fx.scan.test.ts +73 -0
- package/src/Fx.takeWhile-skipWhile.test.ts +84 -0
- package/src/Fx.zip-merge-additive.test.ts +171 -0
- package/src/Fx.zip.test.ts +133 -0
- package/src/Push/Push.ts +170 -1
- package/src/Push.additive.test.ts +256 -0
- package/src/RefSubject/RefArray.ts +4 -1
- package/src/RefSubject/RefChunk.ts +2 -1
- package/src/RefSubject/RefDateTime.ts +6 -6
- package/src/RefSubject/RefHashMap.ts +10 -1
- package/src/RefSubject/RefIterable.ts +11 -2
- package/src/RefSubject/RefRecord.ts +9 -2
- package/src/RefSubject/RefSubject.ts +108 -9
- package/src/RefSubject/RefTrie.ts +19 -10
- package/src/RefSubject.additive-parity.test.ts +101 -0
- package/src/Sink/combinators.ts +123 -1
- package/src/Sink.combinators.test.ts +88 -0
- package/src/Sink.reduce-collect-head-last.test.ts +107 -0
- package/src/Versioned/Versioned.ts +76 -0
- package/src/Versioned.filterMap.test.ts +91 -0
- package/tsconfig.json +0 -6
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./catch.js";
|
|
2
|
+
export * from "./changesWithEffect.js";
|
|
2
3
|
export * from "./causes.js";
|
|
3
4
|
export * from "./compact.js";
|
|
4
5
|
export * from "./continueWith.js";
|
|
6
|
+
export * from "./dropUntil.js";
|
|
7
|
+
export * from "./additive.js";
|
|
5
8
|
export * from "./ensuring.js";
|
|
6
9
|
export * from "./exhaustLatestMap.js";
|
|
7
10
|
export * from "./exhaustLatestMapEffect.js";
|
|
@@ -29,23 +32,30 @@ export * from "./loopCause.js";
|
|
|
29
32
|
export * from "./loopCauseEffect.js";
|
|
30
33
|
export * from "./loopEffect.js";
|
|
31
34
|
export * from "./map.js";
|
|
35
|
+
export * from "./mapBoth.js";
|
|
32
36
|
export * from "./mapEffect.js";
|
|
37
|
+
export * from "./mapError.js";
|
|
33
38
|
export * from "./mergeAll.js";
|
|
34
39
|
export * from "./mergeOrdered.js";
|
|
35
40
|
export * from "./onError.js";
|
|
36
41
|
export * from "./onExit.js";
|
|
37
42
|
export * from "./onInterrupt.js";
|
|
38
43
|
export * from "./provide.js";
|
|
44
|
+
export * from "./result.js";
|
|
45
|
+
export * from "./scan.js";
|
|
39
46
|
export * from "./skip.js";
|
|
40
47
|
export * from "./skipRepeats.js";
|
|
48
|
+
export * from "./skipWhile.js";
|
|
41
49
|
export * from "./skipRepeatsWith.js";
|
|
42
50
|
export * from "./slice.js";
|
|
43
51
|
export * from "./switchMap.js";
|
|
44
52
|
export * from "./switchMapEffect.js";
|
|
45
53
|
export * from "./take.js";
|
|
46
54
|
export * from "./takeUntil.js";
|
|
55
|
+
export * from "./takeWhile.js";
|
|
47
56
|
export * from "./tapEffect.js";
|
|
48
57
|
export * from "./tuple.js";
|
|
49
58
|
export * from "./unwrap.js";
|
|
50
59
|
export * from "./unwrapScoped.js";
|
|
51
60
|
export * from "./when.js";
|
|
61
|
+
export * from "./zip.js";
|
|
@@ -20,7 +20,7 @@ export interface KeyedOptions<A, B, C, E2, R2> {
|
|
|
20
20
|
/**
|
|
21
21
|
* Optional debounce duration for emission.
|
|
22
22
|
*/
|
|
23
|
-
readonly debounce?: Duration.
|
|
23
|
+
readonly debounce?: Duration.Input;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Efficiently transforms a list of values into a list of Fx streams, using keys to track identity.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/keyed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAQ5C,OAAO,KAAK,KAAK,MAAM,c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AAC,CAAC;IACzF;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;CACpC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,EAAE;IAClB,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAClC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GACrC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAChG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EACxC,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GACrC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;CAetD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Fx } from "../Fx.js";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms both the success and error channels of an Fx using the provided options.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `Effect.mapBoth`: `onSuccess` maps emitted values, `onFailure` maps the
|
|
6
|
+
* typed failure (via `Cause.map`); defects and interrupts are preserved.
|
|
7
|
+
*
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
* @category combinators
|
|
10
|
+
*/
|
|
11
|
+
export declare const mapBoth: {
|
|
12
|
+
<E, E2, A, A2>(options: {
|
|
13
|
+
readonly onFailure: (e: E) => E2;
|
|
14
|
+
readonly onSuccess: (a: A) => A2;
|
|
15
|
+
}): <R>(self: Fx<A, E, R>) => Fx<A2, E2, R>;
|
|
16
|
+
<A, E, R, E2, A2>(self: Fx<A, E, R>, options: {
|
|
17
|
+
readonly onFailure: (e: E) => E2;
|
|
18
|
+
readonly onSuccess: (a: A) => A2;
|
|
19
|
+
}): Fx<A2, E2, R>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=mapBoth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapBoth.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/mapBoth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE;IACpB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE;QACtB,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QACjC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;KAClC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAE5C,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EACd,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACjB,OAAO,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;KAAE,GAC9E,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;CAelB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
3
|
+
import { make as makeSink } from "../../Sink/Sink.js";
|
|
4
|
+
import { make } from "../constructors/make.js";
|
|
5
|
+
/**
|
|
6
|
+
* Transforms both the success and error channels of an Fx using the provided options.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `Effect.mapBoth`: `onSuccess` maps emitted values, `onFailure` maps the
|
|
9
|
+
* typed failure (via `Cause.map`); defects and interrupts are preserved.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category combinators
|
|
13
|
+
*/
|
|
14
|
+
export const mapBoth = dual(2, (self, options) => make((sink) => self.run(makeSink((cause) => sink.onFailure(Cause.map(cause, options.onFailure)), (a) => sink.onSuccess(options.onSuccess(a))))));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Fx } from "../Fx.js";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms the error channel of an Fx using the provided function.
|
|
4
|
+
*
|
|
5
|
+
* Failures (Cause) are mapped via `Cause.map`, so only the typed failure (`Fail`)
|
|
6
|
+
* is transformed; defects and interrupts are preserved unchanged.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `Effect.mapError`.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
* @category combinators
|
|
12
|
+
*/
|
|
13
|
+
export declare const mapError: {
|
|
14
|
+
<E, E2>(f: (e: E) => E2): <A, R>(self: Fx<A, E, R>) => Fx<A, E2, R>;
|
|
15
|
+
<A, E, R, E2>(self: Fx<A, E, R>, f: (e: E) => E2): Fx<A, E2, R>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=mapError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapError.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/mapError.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAE;IACrB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAEpE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;CAOjE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
3
|
+
import { make as makeSink } from "../../Sink/Sink.js";
|
|
4
|
+
import { make } from "../constructors/make.js";
|
|
5
|
+
/**
|
|
6
|
+
* Transforms the error channel of an Fx using the provided function.
|
|
7
|
+
*
|
|
8
|
+
* Failures (Cause) are mapped via `Cause.map`, so only the typed failure (`Fail`)
|
|
9
|
+
* is transformed; defects and interrupts are preserved unchanged.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors `Effect.mapError`.
|
|
12
|
+
*
|
|
13
|
+
* @since 1.0.0
|
|
14
|
+
* @category combinators
|
|
15
|
+
*/
|
|
16
|
+
export const mapError = dual(2, (self, f) => make((sink) => self.run(makeSink((cause) => sink.onFailure(Cause.map(cause, f)), sink.onSuccess))));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import * as Layer from "effect/Layer";
|
|
2
|
-
import
|
|
3
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
3
4
|
import type { Fx } from "../Fx.js";
|
|
4
5
|
/**
|
|
5
6
|
* Provides context to an Fx from a Layer.
|
|
@@ -20,4 +21,36 @@ export declare const provideServices: {
|
|
|
20
21
|
<R2>(services: ServiceMap.ServiceMap<R2>): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, Exclude<R, R2>>;
|
|
21
22
|
<A, E, R, R2>(fx: Fx<A, E, R>, services: ServiceMap.ServiceMap<R2>): Fx<A, E, Exclude<R, R2>>;
|
|
22
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Provides a single service to an Fx.
|
|
26
|
+
*
|
|
27
|
+
* Equivalent to `provideServices(fx, ServiceMap.make(tag, service))`. The service
|
|
28
|
+
* is available for the entire Fx stream, scoped to the stream lifetime.
|
|
29
|
+
*
|
|
30
|
+
* @param tag - The service tag (identifier).
|
|
31
|
+
* @param service - The service implementation.
|
|
32
|
+
* @returns An `Fx` with the required service provided.
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
* @category combinators
|
|
35
|
+
*/
|
|
36
|
+
export declare const provideService: {
|
|
37
|
+
<Id, S>(tag: ServiceMap.Service<Id, S>, service: S): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, Exclude<R, Id>>;
|
|
38
|
+
<A, E, R, Id, S>(fx: Fx<A, E, R>, tag: ServiceMap.Service<Id, S>, service: S): Fx<A, E, Exclude<R, Id>>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Provides a single service to an Fx by running an effect that produces the service.
|
|
42
|
+
*
|
|
43
|
+
* The effect is run when the Fx is run; the resulting service is provided to the
|
|
44
|
+
* entire stream. Equivalent to `provide(fx, Layer.effect(tag, serviceEffect))`.
|
|
45
|
+
*
|
|
46
|
+
* @param tag - The service tag (identifier).
|
|
47
|
+
* @param serviceEffect - Effect that produces the service (may have its own requirements).
|
|
48
|
+
* @returns An `Fx` with the required service provided.
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
* @category combinators
|
|
51
|
+
*/
|
|
52
|
+
export declare const provideServiceEffect: {
|
|
53
|
+
<Id, S, E2, R2>(tag: ServiceMap.Service<Id, S>, serviceEffect: Effect.Effect<S, E2, R2>): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E | E2, Exclude<R, Id> | R2>;
|
|
54
|
+
<A, E, R, Id, S, E2, R2>(fx: Fx<A, E, R>, tag: ServiceMap.Service<Id, S>, serviceEffect: Effect.Effect<S, E2, R2>): Fx<A, E | E2, Exclude<R, Id> | R2>;
|
|
55
|
+
};
|
|
23
56
|
//# sourceMappingURL=provide.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provide.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/provide.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provide.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/provide.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,EAAE;IACpB,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,EACzB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAC7B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,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,CAAC,EAAE,EAAE,CAAC,CAAC,EAC9B,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GACtC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;CAQvC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import * as Exit from "effect/Exit";
|
|
|
3
3
|
import { dual } from "effect/Function";
|
|
4
4
|
import * as Layer from "effect/Layer";
|
|
5
5
|
import * as Scope from "effect/Scope";
|
|
6
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
6
7
|
import { make } from "../constructors/make.js";
|
|
7
8
|
/**
|
|
8
9
|
* Provides context to an Fx from a Layer.
|
|
@@ -25,3 +26,29 @@ export const provide = dual(2, (fx, layer) => make(Effect.fnUntraced(function* (
|
|
|
25
26
|
return yield* fx.run(sink).pipe(Effect.provideServices(servicesExit.value), Effect.onExit((exit) => Scope.close(scope, exit)));
|
|
26
27
|
})));
|
|
27
28
|
export const provideServices = dual(2, (fx, services) => provide(fx, Layer.succeedServices(services)));
|
|
29
|
+
/**
|
|
30
|
+
* Provides a single service to an Fx.
|
|
31
|
+
*
|
|
32
|
+
* Equivalent to `provideServices(fx, ServiceMap.make(tag, service))`. The service
|
|
33
|
+
* is available for the entire Fx stream, scoped to the stream lifetime.
|
|
34
|
+
*
|
|
35
|
+
* @param tag - The service tag (identifier).
|
|
36
|
+
* @param service - The service implementation.
|
|
37
|
+
* @returns An `Fx` with the required service provided.
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
* @category combinators
|
|
40
|
+
*/
|
|
41
|
+
export const provideService = dual(3, (fx, tag, service) => provideServices(fx, ServiceMap.make(tag, service)));
|
|
42
|
+
/**
|
|
43
|
+
* Provides a single service to an Fx by running an effect that produces the service.
|
|
44
|
+
*
|
|
45
|
+
* The effect is run when the Fx is run; the resulting service is provided to the
|
|
46
|
+
* entire stream. Equivalent to `provide(fx, Layer.effect(tag, serviceEffect))`.
|
|
47
|
+
*
|
|
48
|
+
* @param tag - The service tag (identifier).
|
|
49
|
+
* @param serviceEffect - Effect that produces the service (may have its own requirements).
|
|
50
|
+
* @returns An `Fx` with the required service provided.
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
* @category combinators
|
|
53
|
+
*/
|
|
54
|
+
export const provideServiceEffect = dual(3, (fx, tag, serviceEffect) => provide(fx, Layer.effect(tag, serviceEffect)));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
2
|
+
import * as Result from "effect/Result";
|
|
3
|
+
import type { Fx } from "../Fx.js";
|
|
4
|
+
/**
|
|
5
|
+
* Materializes success and failure of an Fx as `Result` values.
|
|
6
|
+
*
|
|
7
|
+
* - **Success**: each emitted value is wrapped as `Result.succeed(value)`.
|
|
8
|
+
* - **Failure**: any failure (including typed error, defect, and interrupt) is
|
|
9
|
+
* materialized as `Result.fail(cause)`. The output error type is `Cause<E>`,
|
|
10
|
+
* so defects and interrupts are explicitly represented in the `Result` and
|
|
11
|
+
* the resulting Fx has error type `never`.
|
|
12
|
+
*
|
|
13
|
+
* The resulting Fx never fails at the stream level; all outcomes are emitted as
|
|
14
|
+
* `Result<A, Cause<E>>`. Consumers can use `Result.match` or `Result.isSuccess` /
|
|
15
|
+
* `Result.isFailure` to handle success vs failure (including defect/interrupt).
|
|
16
|
+
*
|
|
17
|
+
* @param fx - The `Fx` stream.
|
|
18
|
+
* @returns An `Fx` emitting `Result<A, Cause<E>>`.
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
* @category combinators
|
|
21
|
+
*/
|
|
22
|
+
export declare const result: <A, E, R>(fx: Fx<A, E, R>) => Fx<Result.Result<A, Cause.Cause<E>>, never, R>;
|
|
23
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as Result from "effect/Result";
|
|
2
|
+
import { make } from "../constructors/make.js";
|
|
3
|
+
/**
|
|
4
|
+
* Materializes success and failure of an Fx as `Result` values.
|
|
5
|
+
*
|
|
6
|
+
* - **Success**: each emitted value is wrapped as `Result.succeed(value)`.
|
|
7
|
+
* - **Failure**: any failure (including typed error, defect, and interrupt) is
|
|
8
|
+
* materialized as `Result.fail(cause)`. The output error type is `Cause<E>`,
|
|
9
|
+
* so defects and interrupts are explicitly represented in the `Result` and
|
|
10
|
+
* the resulting Fx has error type `never`.
|
|
11
|
+
*
|
|
12
|
+
* The resulting Fx never fails at the stream level; all outcomes are emitted as
|
|
13
|
+
* `Result<A, Cause<E>>`. Consumers can use `Result.match` or `Result.isSuccess` /
|
|
14
|
+
* `Result.isFailure` to handle success vs failure (including defect/interrupt).
|
|
15
|
+
*
|
|
16
|
+
* @param fx - The `Fx` stream.
|
|
17
|
+
* @returns An `Fx` emitting `Result<A, Cause<E>>`.
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @category combinators
|
|
20
|
+
*/
|
|
21
|
+
export const result = (fx) => make((sink) => fx.run(new ResultSink(sink)));
|
|
22
|
+
class ResultSink {
|
|
23
|
+
sink;
|
|
24
|
+
onSuccess;
|
|
25
|
+
onFailure;
|
|
26
|
+
constructor(sink) {
|
|
27
|
+
this.sink = sink;
|
|
28
|
+
const s = sink;
|
|
29
|
+
this.onSuccess = (value) => s.onSuccess(Result.succeed(value));
|
|
30
|
+
this.onFailure = (cause) => s.onSuccess(Result.fail(cause));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type { Fx } from "../Fx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Scans the stream with a pure function, emitting the accumulated state after each element.
|
|
5
|
+
* Emits the initial value first, then for each input `a` emits `f(state, a)` and updates state.
|
|
6
|
+
*
|
|
7
|
+
* Semantics align with Effect Stream's `scan`: output is `initial`, `f(initial, a1)`, `f(..., a2)`, ...
|
|
8
|
+
*
|
|
9
|
+
* @param initial - Initial state (first value emitted).
|
|
10
|
+
* @param f - Reducer `(state, value) => nextState`.
|
|
11
|
+
* @returns An `Fx` that emits the accumulated state at each step.
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
* @category combinators
|
|
14
|
+
*/
|
|
15
|
+
export declare const scan: {
|
|
16
|
+
<S, A>(initial: S, f: (s: S, a: A) => S): <E, R>(fx: Fx<A, E, R>) => Fx<S, E, R>;
|
|
17
|
+
<A, E, R, S>(fx: Fx<A, E, R>, initial: S, f: (s: S, a: A) => S): Fx<S, E, R>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Scans the stream with an effectful function, emitting the accumulated state after each element.
|
|
21
|
+
* Emits the initial value first, then for each input `a` runs `f(state, a)` and emits the resulting state.
|
|
22
|
+
*
|
|
23
|
+
* @param initial - Initial state (first value emitted).
|
|
24
|
+
* @param f - Effectful reducer `(state, value) => Effect<nextState>`.
|
|
25
|
+
* @returns An `Fx` that emits the accumulated state at each step.
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
* @category combinators
|
|
28
|
+
*/
|
|
29
|
+
export declare const scanEffect: {
|
|
30
|
+
<S, A, E2, R2>(initial: S, f: (s: S, a: A) => Effect.Effect<S, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Fx<S, E | E2, R | R2>;
|
|
31
|
+
<A, E, R, S, E2, R2>(fx: Fx<A, E, R>, initial: S, f: (s: S, a: A) => Effect.Effect<S, E2, R2>): Fx<S, E | E2, R | R2>;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAGnC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAe9E,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EACX,OAAO,EAAE,CAAC,EACV,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAC1C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EACjB,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACf,OAAO,EAAE,CAAC,EACV,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAC1C,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;CAwB1B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { dual, pipe } from "effect/Function";
|
|
3
|
+
import { loop as sinkLoop, loopEffect as sinkLoopEffect } from "../../Sink/combinators.js";
|
|
4
|
+
import { make } from "../constructors/make.js";
|
|
5
|
+
/**
|
|
6
|
+
* Scans the stream with a pure function, emitting the accumulated state after each element.
|
|
7
|
+
* Emits the initial value first, then for each input `a` emits `f(state, a)` and updates state.
|
|
8
|
+
*
|
|
9
|
+
* Semantics align with Effect Stream's `scan`: output is `initial`, `f(initial, a1)`, `f(..., a2)`, ...
|
|
10
|
+
*
|
|
11
|
+
* @param initial - Initial state (first value emitted).
|
|
12
|
+
* @param f - Reducer `(state, value) => nextState`.
|
|
13
|
+
* @returns An `Fx` that emits the accumulated state at each step.
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
* @category combinators
|
|
16
|
+
*/
|
|
17
|
+
export const scan = dual(3, (fx, initial, f) => make((sink) => Effect.gen(function* () {
|
|
18
|
+
yield* sink.onSuccess(initial);
|
|
19
|
+
yield* fx.run(sinkLoop(sink, initial, (s, a) => {
|
|
20
|
+
const next = f(s, a);
|
|
21
|
+
return [next, next];
|
|
22
|
+
}));
|
|
23
|
+
})));
|
|
24
|
+
/**
|
|
25
|
+
* Scans the stream with an effectful function, emitting the accumulated state after each element.
|
|
26
|
+
* Emits the initial value first, then for each input `a` runs `f(state, a)` and emits the resulting state.
|
|
27
|
+
*
|
|
28
|
+
* @param initial - Initial state (first value emitted).
|
|
29
|
+
* @param f - Effectful reducer `(state, value) => Effect<nextState>`.
|
|
30
|
+
* @returns An `Fx` that emits the accumulated state at each step.
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
* @category combinators
|
|
33
|
+
*/
|
|
34
|
+
export const scanEffect = dual(3, (fx, initial, f) => make((sink) => Effect.gen(function* () {
|
|
35
|
+
const services = yield* Effect.services();
|
|
36
|
+
yield* sink.onSuccess(initial);
|
|
37
|
+
yield* fx.run(sinkLoopEffect(sink, initial, (s, a) => pipe(f(s, a), Effect.catchCause((cause) => sink.onFailure(cause).pipe(Effect.as(s))), Effect.map((next) => [next, next]), Effect.provideServices(services))));
|
|
38
|
+
})));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import type { Fx } from "../Fx.js";
|
|
2
3
|
/**
|
|
3
4
|
* Skips the first `n` elements of an Fx.
|
|
@@ -11,4 +12,16 @@ export declare const skip: {
|
|
|
11
12
|
(n: number): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>;
|
|
12
13
|
<A, E, R>(fx: Fx<A, E, R>, n: number): Fx<A, E, R>;
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Skips the first `n` elements where `n` is produced by an Effect.
|
|
17
|
+
*
|
|
18
|
+
* @param count - Effect that produces the number of elements to skip.
|
|
19
|
+
* @returns An `Fx` that emits values after the first `n` elements.
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
* @category combinators
|
|
22
|
+
*/
|
|
23
|
+
export declare const skipEffect: {
|
|
24
|
+
<E2, R2>(count: Effect.Effect<number, E2, R2>): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E | E2, R | R2>;
|
|
25
|
+
<A, E, R, E2, R2>(fx: Fx<A, E, R>, count: Effect.Effect<number, E2, R2>): Fx<A, E | E2, R | R2>;
|
|
26
|
+
};
|
|
14
27
|
//# sourceMappingURL=skip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/skip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/skip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAInC;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEvD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAIpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,EAAE,EAAE,EAAE,EACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,GACnC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;CAKjG,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import { dual } from "effect/Function";
|
|
2
3
|
import { slice } from "./slice.js";
|
|
4
|
+
import { unwrap } from "./unwrap.js";
|
|
3
5
|
/**
|
|
4
6
|
* Skips the first `n` elements of an Fx.
|
|
5
7
|
*
|
|
@@ -9,3 +11,12 @@ import { slice } from "./slice.js";
|
|
|
9
11
|
* @category combinators
|
|
10
12
|
*/
|
|
11
13
|
export const skip = dual(2, (fx, n) => slice(fx, { skip: n, take: Infinity }));
|
|
14
|
+
/**
|
|
15
|
+
* Skips the first `n` elements where `n` is produced by an Effect.
|
|
16
|
+
*
|
|
17
|
+
* @param count - Effect that produces the number of elements to skip.
|
|
18
|
+
* @returns An `Fx` that emits values after the first `n` elements.
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
* @category combinators
|
|
21
|
+
*/
|
|
22
|
+
export const skipEffect = dual(2, (fx, count) => unwrap(Effect.map(count, (n) => skip(fx, n))));
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type { Fx } from "../Fx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Skips elements from an Fx while a predicate returns true.
|
|
5
|
+
* Emits from the first element for which the predicate returns false (including that element) and all following elements.
|
|
6
|
+
*
|
|
7
|
+
* @param predicate - The predicate function.
|
|
8
|
+
* @returns An `Fx` that emits once the predicate first fails.
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
* @category combinators
|
|
11
|
+
*/
|
|
12
|
+
export declare const skipWhile: {
|
|
13
|
+
<A>(predicate: (a: A) => boolean): <E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>;
|
|
14
|
+
<A, E, R>(fx: Fx<A, E, R>, predicate: (a: A) => boolean): Fx<A, E, R>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Skips elements from an Fx while an effectful predicate returns true.
|
|
18
|
+
* Emits from the first element for which the predicate effect succeeds with false (including that element) and all following elements.
|
|
19
|
+
*
|
|
20
|
+
* @param predicate - Effectful predicate function.
|
|
21
|
+
* @returns An `Fx` that emits once the predicate first fails.
|
|
22
|
+
* @since 1.0.0
|
|
23
|
+
* @category combinators
|
|
24
|
+
*/
|
|
25
|
+
export declare const skipWhileEffect: {
|
|
26
|
+
<A, E2, R2>(predicate: (a: A) => Effect.Effect<boolean, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Fx<A, E | E2, R | R2>;
|
|
27
|
+
<A, E, R, E2, R2>(fx: Fx<A, E, R>, predicate: (a: A) => Effect.Effect<boolean, E2, R2>): Fx<A, E | E2, R | R2>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Alias of `skipWhile` for Effect parity (`dropWhile` naming).
|
|
31
|
+
*
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
* @category combinators
|
|
34
|
+
*/
|
|
35
|
+
export declare const dropWhile: {
|
|
36
|
+
<A>(predicate: (a: A) => boolean): <E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>;
|
|
37
|
+
<A, E, R>(fx: Fx<A, E, R>, predicate: (a: A) => boolean): Fx<A, E, R>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Alias of `skipWhileEffect` for Effect parity (`dropWhileEffect` naming).
|
|
41
|
+
*
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
* @category combinators
|
|
44
|
+
*/
|
|
45
|
+
export declare const dropWhileEffect: {
|
|
46
|
+
<A, E2, R2>(predicate: (a: A) => Effect.Effect<boolean, E2, R2>): <E, R>(fx: Fx<A, E, R>) => Fx<A, E | E2, R | R2>;
|
|
47
|
+
<A, E, R, E2, R2>(fx: Fx<A, E, R>, predicate: (a: A) => Effect.Effect<boolean, E2, R2>): Fx<A, E | E2, R | R2>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=skipWhile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skipWhile.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/skipWhile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAGnC;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE;IACtB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OA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ErC,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,eAAe;KAjDzB,CAAC,EAAE,EAAE,EAAE,EAAE,aACG,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,GAClD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;KAClD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MACV,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,aACJ,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,GAClD,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;CA2CoB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
3
|
+
import * as Ref from "effect/Ref";
|
|
4
|
+
import { make as makeFx } from "../constructors/make.js";
|
|
5
|
+
import { make as makeSink } from "../../Sink/Sink.js";
|
|
6
|
+
/**
|
|
7
|
+
* Skips elements from an Fx while a predicate returns true.
|
|
8
|
+
* Emits from the first element for which the predicate returns false (including that element) and all following elements.
|
|
9
|
+
*
|
|
10
|
+
* @param predicate - The predicate function.
|
|
11
|
+
* @returns An `Fx` that emits once the predicate first fails.
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
* @category combinators
|
|
14
|
+
*/
|
|
15
|
+
export const skipWhile = dual(2, (fx, predicate) => makeFx((sink) => Effect.gen(function* () {
|
|
16
|
+
const skippingRef = yield* Ref.make(true);
|
|
17
|
+
const skipSink = makeSink(sink.onFailure, (a) => Effect.gen(function* () {
|
|
18
|
+
const skipping = yield* Ref.get(skippingRef);
|
|
19
|
+
if (skipping) {
|
|
20
|
+
if (predicate(a))
|
|
21
|
+
return;
|
|
22
|
+
yield* Ref.set(skippingRef, false);
|
|
23
|
+
}
|
|
24
|
+
return yield* sink.onSuccess(a);
|
|
25
|
+
}));
|
|
26
|
+
return yield* fx.run(skipSink);
|
|
27
|
+
})));
|
|
28
|
+
/**
|
|
29
|
+
* Skips elements from an Fx while an effectful predicate returns true.
|
|
30
|
+
* Emits from the first element for which the predicate effect succeeds with false (including that element) and all following elements.
|
|
31
|
+
*
|
|
32
|
+
* @param predicate - Effectful predicate function.
|
|
33
|
+
* @returns An `Fx` that emits once the predicate first fails.
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
* @category combinators
|
|
36
|
+
*/
|
|
37
|
+
export const skipWhileEffect = dual(2, (fx, predicate) => makeFx((sink) => Effect.gen(function* () {
|
|
38
|
+
const skippingRef = yield* Ref.make(true);
|
|
39
|
+
const skipSink = makeSink(sink.onFailure, (a) => Effect.matchCauseEffect(predicate(a), {
|
|
40
|
+
onFailure: sink.onFailure,
|
|
41
|
+
onSuccess: (ok) => Effect.gen(function* () {
|
|
42
|
+
const skipping = yield* Ref.get(skippingRef);
|
|
43
|
+
if (skipping) {
|
|
44
|
+
if (ok)
|
|
45
|
+
return;
|
|
46
|
+
yield* Ref.set(skippingRef, false);
|
|
47
|
+
}
|
|
48
|
+
return yield* sink.onSuccess(a);
|
|
49
|
+
}),
|
|
50
|
+
}));
|
|
51
|
+
return yield* fx.run(skipSink);
|
|
52
|
+
})));
|
|
53
|
+
/**
|
|
54
|
+
* Alias of `skipWhile` for Effect parity (`dropWhile` naming).
|
|
55
|
+
*
|
|
56
|
+
* @since 1.0.0
|
|
57
|
+
* @category combinators
|
|
58
|
+
*/
|
|
59
|
+
export const dropWhile = skipWhile;
|
|
60
|
+
/**
|
|
61
|
+
* Alias of `skipWhileEffect` for Effect parity (`dropWhileEffect` naming).
|
|
62
|
+
*
|
|
63
|
+
* @since 1.0.0
|
|
64
|
+
* @category combinators
|
|
65
|
+
*/
|
|
66
|
+
export const dropWhileEffect = skipWhileEffect;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import type { Fx } from "../Fx.js";
|
|
2
3
|
/**
|
|
3
4
|
* Defines the bounds for slicing an Fx stream.
|
|
@@ -20,4 +21,16 @@ export declare const slice: {
|
|
|
20
21
|
(bounds: Bounds): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>;
|
|
21
22
|
<A, E, R>(fx: Fx<A, E, R>, bounds: Bounds): Fx<A, E, R>;
|
|
22
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Slices an Fx with bounds produced by an Effect.
|
|
26
|
+
*
|
|
27
|
+
* @param bounds - Effect that produces slice bounds.
|
|
28
|
+
* @returns An `Fx` representing the slice.
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
* @category combinators
|
|
31
|
+
*/
|
|
32
|
+
export declare const sliceEffect: {
|
|
33
|
+
<E2, R2>(bounds: Effect.Effect<Bounds, E2, R2>): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E | E2, R | R2>;
|
|
34
|
+
<A, E, R, E2, R2>(fx: Fx<A, E, R>, bounds: Effect.Effect<Bounds, E2, R2>): Fx<A, E | E2, R | R2>;
|
|
35
|
+
};
|
|
23
36
|
//# sourceMappingURL=slice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/slice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/slice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAGnC;;;;GAIG;AACH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1,6 +1,8 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import { dual } from "effect/Function";
|
|
2
3
|
import * as sinkCore from "../../Sink/combinators.js";
|
|
3
4
|
import { make } from "../constructors/make.js";
|
|
5
|
+
import { unwrap } from "./unwrap.js";
|
|
4
6
|
/**
|
|
5
7
|
* Slices an Fx by skipping a number of elements and then taking a number of elements.
|
|
6
8
|
*
|
|
@@ -10,3 +12,12 @@ import { make } from "../constructors/make.js";
|
|
|
10
12
|
* @category combinators
|
|
11
13
|
*/
|
|
12
14
|
export const slice = dual(2, (fx, bounds) => make((sink) => sinkCore.slice(sink, bounds, (sink) => fx.run(sink))));
|
|
15
|
+
/**
|
|
16
|
+
* Slices an Fx with bounds produced by an Effect.
|
|
17
|
+
*
|
|
18
|
+
* @param bounds - Effect that produces slice bounds.
|
|
19
|
+
* @returns An `Fx` representing the slice.
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
* @category combinators
|
|
22
|
+
*/
|
|
23
|
+
export const sliceEffect = dual(2, (fx, bounds) => unwrap(Effect.map(bounds, (b) => slice(fx, b))));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import type { Fx } from "../Fx.js";
|
|
2
3
|
/**
|
|
3
4
|
* Takes the first `n` elements from an Fx and then completes.
|
|
@@ -11,4 +12,16 @@ export declare const take: {
|
|
|
11
12
|
(n: number): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, R>;
|
|
12
13
|
<A, E, R>(fx: Fx<A, E, R>, n: number): Fx<A, E, R>;
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Takes the first `n` elements where `n` is produced by an Effect.
|
|
17
|
+
*
|
|
18
|
+
* @param count - Effect that produces the number of elements to take.
|
|
19
|
+
* @returns An `Fx` that emits at most `n` elements.
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
* @category combinators
|
|
22
|
+
*/
|
|
23
|
+
export declare const takeEffect: {
|
|
24
|
+
<E2, R2>(count: Effect.Effect<number, E2, R2>): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E | E2, R | R2>;
|
|
25
|
+
<A, E, R, E2, R2>(fx: Fx<A, E, R>, count: Effect.Effect<number, E2, R2>): Fx<A, E | E2, R | R2>;
|
|
26
|
+
};
|
|
14
27
|
//# sourceMappingURL=take.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/take.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../../src/Fx/combinators/take.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAInC;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEvD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC6C,CAAC;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,EAAE,EAAE,EAAE,EACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,GACnC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,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