effect 4.0.0-beta.17 → 4.0.0-beta.19
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/Array.d.ts +127 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +5 -4
- package/dist/Cache.js.map +1 -1
- package/dist/Channel.d.ts +97 -11
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +72 -29
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Effect.d.ts +337 -437
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +118 -134
- package/dist/Effect.js.map +1 -1
- package/dist/Filter.d.ts +0 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +0 -13
- package/dist/Filter.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +40 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/Option.d.ts +22 -15
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +14 -7
- package/dist/Option.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Record.d.ts +24 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Sink.d.ts +11 -11
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +198 -386
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +103 -59
- package/dist/Stream.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +196 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +84 -83
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +24 -24
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +14 -14
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +415 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +7 -7
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +99 -42
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +3 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +0 -9
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +1 -1
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +1 -1
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Sharding.js +1 -1
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +1 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +3 -3
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +190 -342
- package/src/Cache.ts +6 -5
- package/src/Channel.ts +506 -102
- package/src/Chunk.ts +81 -268
- package/src/Effect.ts +437 -518
- package/src/Filter.ts +0 -57
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +105 -50
- package/src/Option.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Record.ts +43 -152
- package/src/Sink.ts +75 -23
- package/src/Stream.ts +442 -502
- package/src/Trie.ts +18 -17
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +332 -285
- package/src/TxHashSet.ts +111 -116
- package/src/TxPriorityQueue.ts +767 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +29 -32
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/index.ts +45 -0
- package/src/internal/effect.ts +368 -163
- package/src/internal/hashMap.ts +7 -5
- package/src/internal/trie.ts +16 -9
- package/src/unstable/ai/Tool.ts +0 -9
- package/src/unstable/cli/Command.ts +6 -4
- package/src/unstable/cluster/K8sHttpClient.ts +4 -4
- package/src/unstable/cluster/Sharding.ts +1 -1
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/rpc/RpcServer.ts +1 -7
- package/src/unstable/socket/Socket.ts +9 -11
package/dist/Effect.d.ts
CHANGED
|
@@ -636,7 +636,7 @@ export declare const all: <const Arg extends Iterable<Effect<any, any, any>> | R
|
|
|
636
636
|
readonly mode?: "default" | "result" | undefined;
|
|
637
637
|
}>(arg: Arg, options?: O) => All.Return<Arg, O>;
|
|
638
638
|
/**
|
|
639
|
-
* Applies an effectful
|
|
639
|
+
* Applies an effectful `Filter` to each element and partitions failures and
|
|
640
640
|
* successes.
|
|
641
641
|
*
|
|
642
642
|
* The returned tuple is `[excluded, satisfying]`, where:
|
|
@@ -649,10 +649,10 @@ export declare const all: <const Arg extends Iterable<Effect<any, any, any>> | R
|
|
|
649
649
|
*
|
|
650
650
|
* @example
|
|
651
651
|
* ```ts
|
|
652
|
-
* import { Effect } from "effect"
|
|
652
|
+
* import { Effect, Result } from "effect"
|
|
653
653
|
*
|
|
654
654
|
* const program = Effect.partition([0, 1, 2, 3], (n) =>
|
|
655
|
-
* n % 2 === 0 ?
|
|
655
|
+
* Effect.succeed(n % 2 === 0 ? Result.fail(`${n} is even`) : Result.succeed(n))
|
|
656
656
|
* )
|
|
657
657
|
*
|
|
658
658
|
* Effect.runPromise(program).then(console.log)
|
|
@@ -664,7 +664,7 @@ export declare const all: <const Arg extends Iterable<Effect<any, any, any>> | R
|
|
|
664
664
|
*/
|
|
665
665
|
export declare const partition: {
|
|
666
666
|
/**
|
|
667
|
-
* Applies an effectful
|
|
667
|
+
* Applies an effectful `Filter` to each element and partitions failures and
|
|
668
668
|
* successes.
|
|
669
669
|
*
|
|
670
670
|
* The returned tuple is `[excluded, satisfying]`, where:
|
|
@@ -677,10 +677,10 @@ export declare const partition: {
|
|
|
677
677
|
*
|
|
678
678
|
* @example
|
|
679
679
|
* ```ts
|
|
680
|
-
* import { Effect } from "effect"
|
|
680
|
+
* import { Effect, Result } from "effect"
|
|
681
681
|
*
|
|
682
682
|
* const program = Effect.partition([0, 1, 2, 3], (n) =>
|
|
683
|
-
* n % 2 === 0 ?
|
|
683
|
+
* Effect.succeed(n % 2 === 0 ? Result.fail(`${n} is even`) : Result.succeed(n))
|
|
684
684
|
* )
|
|
685
685
|
*
|
|
686
686
|
* Effect.runPromise(program).then(console.log)
|
|
@@ -690,11 +690,11 @@ export declare const partition: {
|
|
|
690
690
|
* @since 3.0.0
|
|
691
691
|
* @category Collecting
|
|
692
692
|
*/
|
|
693
|
-
<A,
|
|
693
|
+
<A, Pass, Fail, E, R>(filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, E, R, [i: number]>, options?: {
|
|
694
694
|
readonly concurrency?: Concurrency | undefined;
|
|
695
|
-
}): (elements: Iterable<A>) => Effect<[excluded: Array<
|
|
695
|
+
}): (elements: Iterable<A>) => Effect<[excluded: Array<Fail>, satisfying: Array<Pass>], E, R>;
|
|
696
696
|
/**
|
|
697
|
-
* Applies an effectful
|
|
697
|
+
* Applies an effectful `Filter` to each element and partitions failures and
|
|
698
698
|
* successes.
|
|
699
699
|
*
|
|
700
700
|
* The returned tuple is `[excluded, satisfying]`, where:
|
|
@@ -707,10 +707,10 @@ export declare const partition: {
|
|
|
707
707
|
*
|
|
708
708
|
* @example
|
|
709
709
|
* ```ts
|
|
710
|
-
* import { Effect } from "effect"
|
|
710
|
+
* import { Effect, Result } from "effect"
|
|
711
711
|
*
|
|
712
712
|
* const program = Effect.partition([0, 1, 2, 3], (n) =>
|
|
713
|
-
* n % 2 === 0 ?
|
|
713
|
+
* Effect.succeed(n % 2 === 0 ? Result.fail(`${n} is even`) : Result.succeed(n))
|
|
714
714
|
* )
|
|
715
715
|
*
|
|
716
716
|
* Effect.runPromise(program).then(console.log)
|
|
@@ -720,9 +720,9 @@ export declare const partition: {
|
|
|
720
720
|
* @since 3.0.0
|
|
721
721
|
* @category Collecting
|
|
722
722
|
*/
|
|
723
|
-
<A,
|
|
723
|
+
<A, Pass, Fail, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, E, R, [i: number]>, options?: {
|
|
724
724
|
readonly concurrency?: Concurrency | undefined;
|
|
725
|
-
}): Effect<[excluded: Array<
|
|
725
|
+
}): Effect<[excluded: Array<Fail>, satisfying: Array<Pass>], E, R>;
|
|
726
726
|
};
|
|
727
727
|
/**
|
|
728
728
|
* Applies an effectful function to each element and accumulates all failures.
|
|
@@ -4746,15 +4746,14 @@ export declare const catchDefect: {
|
|
|
4746
4746
|
<A, E, R, A2, E2, R2>(self: Effect<A, E, R>, f: (defect: unknown) => Effect<A2, E2, R2>): Effect<A | A2, E | E2, R | R2>;
|
|
4747
4747
|
};
|
|
4748
4748
|
/**
|
|
4749
|
-
* Recovers from specific errors using a `
|
|
4750
|
-
* `Refinement`.
|
|
4749
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4751
4750
|
*
|
|
4752
4751
|
* **When to Use**
|
|
4753
4752
|
*
|
|
4754
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4755
|
-
* `
|
|
4756
|
-
*
|
|
4757
|
-
*
|
|
4753
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4754
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4755
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4756
|
+
* interrupts are not caught.
|
|
4758
4757
|
*
|
|
4759
4758
|
* **Previously Known As**
|
|
4760
4759
|
*
|
|
@@ -4781,7 +4780,7 @@ export declare const catchDefect: {
|
|
|
4781
4780
|
*
|
|
4782
4781
|
* // With a Filter
|
|
4783
4782
|
* const recovered2 = program.pipe(
|
|
4784
|
-
* Effect.
|
|
4783
|
+
* Effect.catchFilter(
|
|
4785
4784
|
* Filter.tagged("NotFound"),
|
|
4786
4785
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4787
4786
|
* )
|
|
@@ -4793,15 +4792,14 @@ export declare const catchDefect: {
|
|
|
4793
4792
|
*/
|
|
4794
4793
|
export declare const catchIf: {
|
|
4795
4794
|
/**
|
|
4796
|
-
* Recovers from specific errors using a `
|
|
4797
|
-
* `Refinement`.
|
|
4795
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4798
4796
|
*
|
|
4799
4797
|
* **When to Use**
|
|
4800
4798
|
*
|
|
4801
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4802
|
-
* `
|
|
4803
|
-
*
|
|
4804
|
-
*
|
|
4799
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4800
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4801
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4802
|
+
* interrupts are not caught.
|
|
4805
4803
|
*
|
|
4806
4804
|
* **Previously Known As**
|
|
4807
4805
|
*
|
|
@@ -4828,7 +4826,7 @@ export declare const catchIf: {
|
|
|
4828
4826
|
*
|
|
4829
4827
|
* // With a Filter
|
|
4830
4828
|
* const recovered2 = program.pipe(
|
|
4831
|
-
* Effect.
|
|
4829
|
+
* Effect.catchFilter(
|
|
4832
4830
|
* Filter.tagged("NotFound"),
|
|
4833
4831
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4834
4832
|
* )
|
|
@@ -4840,15 +4838,14 @@ export declare const catchIf: {
|
|
|
4840
4838
|
*/
|
|
4841
4839
|
<E, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(refinement: Predicate.Refinement<NoInfer<E>, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4842
4840
|
/**
|
|
4843
|
-
* Recovers from specific errors using a `
|
|
4844
|
-
* `Refinement`.
|
|
4841
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4845
4842
|
*
|
|
4846
4843
|
* **When to Use**
|
|
4847
4844
|
*
|
|
4848
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4849
|
-
* `
|
|
4850
|
-
*
|
|
4851
|
-
*
|
|
4845
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4846
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4847
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4848
|
+
* interrupts are not caught.
|
|
4852
4849
|
*
|
|
4853
4850
|
* **Previously Known As**
|
|
4854
4851
|
*
|
|
@@ -4875,7 +4872,7 @@ export declare const catchIf: {
|
|
|
4875
4872
|
*
|
|
4876
4873
|
* // With a Filter
|
|
4877
4874
|
* const recovered2 = program.pipe(
|
|
4878
|
-
* Effect.
|
|
4875
|
+
* Effect.catchFilter(
|
|
4879
4876
|
* Filter.tagged("NotFound"),
|
|
4880
4877
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4881
4878
|
* )
|
|
@@ -4885,17 +4882,16 @@ export declare const catchIf: {
|
|
|
4885
4882
|
* @since 2.0.0
|
|
4886
4883
|
* @category Error Handling
|
|
4887
4884
|
*/
|
|
4888
|
-
<E,
|
|
4885
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(predicate: Predicate.Predicate<NoInfer<E>>, f: (e: NoInfer<E>) => Effect<A2, E2, R2>, orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4889
4886
|
/**
|
|
4890
|
-
* Recovers from specific errors using a `
|
|
4891
|
-
* `Refinement`.
|
|
4887
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4892
4888
|
*
|
|
4893
4889
|
* **When to Use**
|
|
4894
4890
|
*
|
|
4895
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4896
|
-
* `
|
|
4897
|
-
*
|
|
4898
|
-
*
|
|
4891
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4892
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4893
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4894
|
+
* interrupts are not caught.
|
|
4899
4895
|
*
|
|
4900
4896
|
* **Previously Known As**
|
|
4901
4897
|
*
|
|
@@ -4922,7 +4918,7 @@ export declare const catchIf: {
|
|
|
4922
4918
|
*
|
|
4923
4919
|
* // With a Filter
|
|
4924
4920
|
* const recovered2 = program.pipe(
|
|
4925
|
-
* Effect.
|
|
4921
|
+
* Effect.catchFilter(
|
|
4926
4922
|
* Filter.tagged("NotFound"),
|
|
4927
4923
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4928
4924
|
* )
|
|
@@ -4934,15 +4930,14 @@ export declare const catchIf: {
|
|
|
4934
4930
|
*/
|
|
4935
4931
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(self: Effect<A, E, R>, refinement: Predicate.Refinement<E, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4936
4932
|
/**
|
|
4937
|
-
* Recovers from specific errors using a `
|
|
4938
|
-
* `Refinement`.
|
|
4933
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4939
4934
|
*
|
|
4940
4935
|
* **When to Use**
|
|
4941
4936
|
*
|
|
4942
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4943
|
-
* `
|
|
4944
|
-
*
|
|
4945
|
-
*
|
|
4937
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4938
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4939
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4940
|
+
* interrupts are not caught.
|
|
4946
4941
|
*
|
|
4947
4942
|
* **Previously Known As**
|
|
4948
4943
|
*
|
|
@@ -4969,7 +4964,7 @@ export declare const catchIf: {
|
|
|
4969
4964
|
*
|
|
4970
4965
|
* // With a Filter
|
|
4971
4966
|
* const recovered2 = program.pipe(
|
|
4972
|
-
* Effect.
|
|
4967
|
+
* Effect.catchFilter(
|
|
4973
4968
|
* Filter.tagged("NotFound"),
|
|
4974
4969
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4975
4970
|
* )
|
|
@@ -4979,7 +4974,29 @@ export declare const catchIf: {
|
|
|
4979
4974
|
* @since 2.0.0
|
|
4980
4975
|
* @category Error Handling
|
|
4981
4976
|
*/
|
|
4982
|
-
<A, E, R,
|
|
4977
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(self: Effect<A, E, R>, predicate: Predicate.Predicate<E>, f: (e: E) => Effect<A2, E2, R2>, orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4978
|
+
};
|
|
4979
|
+
/**
|
|
4980
|
+
* Recovers from specific errors using a `Filter`.
|
|
4981
|
+
*
|
|
4982
|
+
* @since 4.0.0
|
|
4983
|
+
* @category Error Handling
|
|
4984
|
+
*/
|
|
4985
|
+
export declare const catchFilter: {
|
|
4986
|
+
/**
|
|
4987
|
+
* Recovers from specific errors using a `Filter`.
|
|
4988
|
+
*
|
|
4989
|
+
* @since 4.0.0
|
|
4990
|
+
* @category Error Handling
|
|
4991
|
+
*/
|
|
4992
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4993
|
+
/**
|
|
4994
|
+
* Recovers from specific errors using a `Filter`.
|
|
4995
|
+
*
|
|
4996
|
+
* @since 4.0.0
|
|
4997
|
+
* @category Error Handling
|
|
4998
|
+
*/
|
|
4999
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4983
5000
|
};
|
|
4984
5001
|
/**
|
|
4985
5002
|
* Catches `NoSuchElementError` failures and converts them to `Option.none`.
|
|
@@ -5085,7 +5102,7 @@ export declare const catchCauseIf: {
|
|
|
5085
5102
|
* @since 4.0.0
|
|
5086
5103
|
* @category Error Handling
|
|
5087
5104
|
*/
|
|
5088
|
-
<E,
|
|
5105
|
+
<E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>;
|
|
5089
5106
|
/**
|
|
5090
5107
|
* Recovers from specific failures based on a predicate.
|
|
5091
5108
|
*
|
|
@@ -5124,7 +5141,29 @@ export declare const catchCauseIf: {
|
|
|
5124
5141
|
* @since 4.0.0
|
|
5125
5142
|
* @category Error Handling
|
|
5126
5143
|
*/
|
|
5127
|
-
<A, E, R, B, E2, R2
|
|
5144
|
+
<A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, E | E2, R | R2>;
|
|
5145
|
+
};
|
|
5146
|
+
/**
|
|
5147
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5148
|
+
*
|
|
5149
|
+
* @since 4.0.0
|
|
5150
|
+
* @category Error Handling
|
|
5151
|
+
*/
|
|
5152
|
+
export declare const catchCauseFilter: {
|
|
5153
|
+
/**
|
|
5154
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5155
|
+
*
|
|
5156
|
+
* @since 4.0.0
|
|
5157
|
+
* @category Error Handling
|
|
5158
|
+
*/
|
|
5159
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
|
|
5160
|
+
/**
|
|
5161
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5162
|
+
*
|
|
5163
|
+
* @since 4.0.0
|
|
5164
|
+
* @category Error Handling
|
|
5165
|
+
*/
|
|
5166
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
|
|
5128
5167
|
};
|
|
5129
5168
|
/**
|
|
5130
5169
|
* The `mapError` function is used to transform or modify the error
|
|
@@ -5731,7 +5770,7 @@ export declare const tapCauseIf: {
|
|
|
5731
5770
|
* @since 4.0.0
|
|
5732
5771
|
* @category Sequencing
|
|
5733
5772
|
*/
|
|
5734
|
-
<E,
|
|
5773
|
+
<E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
|
|
5735
5774
|
/**
|
|
5736
5775
|
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5737
5776
|
*
|
|
@@ -5760,7 +5799,29 @@ export declare const tapCauseIf: {
|
|
|
5760
5799
|
* @since 4.0.0
|
|
5761
5800
|
* @category Sequencing
|
|
5762
5801
|
*/
|
|
5763
|
-
<A, E, R,
|
|
5802
|
+
<A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
|
|
5803
|
+
};
|
|
5804
|
+
/**
|
|
5805
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5806
|
+
*
|
|
5807
|
+
* @since 4.0.0
|
|
5808
|
+
* @category Sequencing
|
|
5809
|
+
*/
|
|
5810
|
+
export declare const tapCauseFilter: {
|
|
5811
|
+
/**
|
|
5812
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5813
|
+
*
|
|
5814
|
+
* @since 4.0.0
|
|
5815
|
+
* @category Sequencing
|
|
5816
|
+
*/
|
|
5817
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
|
|
5818
|
+
/**
|
|
5819
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5820
|
+
*
|
|
5821
|
+
* @since 4.0.0
|
|
5822
|
+
* @category Sequencing
|
|
5823
|
+
*/
|
|
5824
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
|
|
5764
5825
|
};
|
|
5765
5826
|
/**
|
|
5766
5827
|
* Inspect severe errors or defects (non-recoverable failures) in an effect.
|
|
@@ -7682,12 +7743,12 @@ export declare const raceFirst: {
|
|
|
7682
7743
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7683
7744
|
};
|
|
7684
7745
|
/**
|
|
7685
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7686
|
-
* predicate
|
|
7746
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7747
|
+
* predicate.
|
|
7687
7748
|
*
|
|
7688
7749
|
* @example
|
|
7689
7750
|
* ```ts
|
|
7690
|
-
* import { Effect
|
|
7751
|
+
* import { Effect } from "effect"
|
|
7691
7752
|
*
|
|
7692
7753
|
* // Sync predicate
|
|
7693
7754
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7695,10 +7756,7 @@ export declare const raceFirst: {
|
|
|
7695
7756
|
* // Effectful predicate
|
|
7696
7757
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7697
7758
|
*
|
|
7698
|
-
* //
|
|
7699
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7700
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7701
|
-
* )
|
|
7759
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7702
7760
|
* ```
|
|
7703
7761
|
*
|
|
7704
7762
|
* @since 2.0.0
|
|
@@ -7706,12 +7764,12 @@ export declare const raceFirst: {
|
|
|
7706
7764
|
*/
|
|
7707
7765
|
export declare const filter: {
|
|
7708
7766
|
/**
|
|
7709
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7710
|
-
* predicate
|
|
7767
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7768
|
+
* predicate.
|
|
7711
7769
|
*
|
|
7712
7770
|
* @example
|
|
7713
7771
|
* ```ts
|
|
7714
|
-
* import { Effect
|
|
7772
|
+
* import { Effect } from "effect"
|
|
7715
7773
|
*
|
|
7716
7774
|
* // Sync predicate
|
|
7717
7775
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7719,10 +7777,7 @@ export declare const filter: {
|
|
|
7719
7777
|
* // Effectful predicate
|
|
7720
7778
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7721
7779
|
*
|
|
7722
|
-
* //
|
|
7723
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7724
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7725
|
-
* )
|
|
7780
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7726
7781
|
* ```
|
|
7727
7782
|
*
|
|
7728
7783
|
* @since 2.0.0
|
|
@@ -7730,12 +7785,12 @@ export declare const filter: {
|
|
|
7730
7785
|
*/
|
|
7731
7786
|
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7732
7787
|
/**
|
|
7733
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7734
|
-
* predicate
|
|
7788
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7789
|
+
* predicate.
|
|
7735
7790
|
*
|
|
7736
7791
|
* @example
|
|
7737
7792
|
* ```ts
|
|
7738
|
-
* import { Effect
|
|
7793
|
+
* import { Effect } from "effect"
|
|
7739
7794
|
*
|
|
7740
7795
|
* // Sync predicate
|
|
7741
7796
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7743,10 +7798,7 @@ export declare const filter: {
|
|
|
7743
7798
|
* // Effectful predicate
|
|
7744
7799
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7745
7800
|
*
|
|
7746
|
-
* //
|
|
7747
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7748
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7749
|
-
* )
|
|
7801
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7750
7802
|
* ```
|
|
7751
7803
|
*
|
|
7752
7804
|
* @since 2.0.0
|
|
@@ -7754,12 +7806,12 @@ export declare const filter: {
|
|
|
7754
7806
|
*/
|
|
7755
7807
|
<A>(predicate: Predicate.Predicate<NoInfer<A>>): (elements: Iterable<A>) => Effect<Array<A>>;
|
|
7756
7808
|
/**
|
|
7757
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7758
|
-
* predicate
|
|
7809
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7810
|
+
* predicate.
|
|
7759
7811
|
*
|
|
7760
7812
|
* @example
|
|
7761
7813
|
* ```ts
|
|
7762
|
-
* import { Effect
|
|
7814
|
+
* import { Effect } from "effect"
|
|
7763
7815
|
*
|
|
7764
7816
|
* // Sync predicate
|
|
7765
7817
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7767,25 +7819,22 @@ export declare const filter: {
|
|
|
7767
7819
|
* // Effectful predicate
|
|
7768
7820
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7769
7821
|
*
|
|
7770
|
-
* //
|
|
7771
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7772
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7773
|
-
* )
|
|
7822
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7774
7823
|
* ```
|
|
7775
7824
|
*
|
|
7776
7825
|
* @since 2.0.0
|
|
7777
7826
|
* @category Filtering
|
|
7778
7827
|
*/
|
|
7779
|
-
<A,
|
|
7828
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
7780
7829
|
readonly concurrency?: Concurrency | undefined;
|
|
7781
|
-
}): (
|
|
7830
|
+
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
7782
7831
|
/**
|
|
7783
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7784
|
-
* predicate
|
|
7832
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7833
|
+
* predicate.
|
|
7785
7834
|
*
|
|
7786
7835
|
* @example
|
|
7787
7836
|
* ```ts
|
|
7788
|
-
* import { Effect
|
|
7837
|
+
* import { Effect } from "effect"
|
|
7789
7838
|
*
|
|
7790
7839
|
* // Sync predicate
|
|
7791
7840
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7793,25 +7842,20 @@ export declare const filter: {
|
|
|
7793
7842
|
* // Effectful predicate
|
|
7794
7843
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7795
7844
|
*
|
|
7796
|
-
* //
|
|
7797
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7798
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7799
|
-
* )
|
|
7845
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7800
7846
|
* ```
|
|
7801
7847
|
*
|
|
7802
7848
|
* @since 2.0.0
|
|
7803
7849
|
* @category Filtering
|
|
7804
7850
|
*/
|
|
7805
|
-
<A, B
|
|
7806
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7807
|
-
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
7851
|
+
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>;
|
|
7808
7852
|
/**
|
|
7809
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7810
|
-
* predicate
|
|
7853
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7854
|
+
* predicate.
|
|
7811
7855
|
*
|
|
7812
7856
|
* @example
|
|
7813
7857
|
* ```ts
|
|
7814
|
-
* import { Effect
|
|
7858
|
+
* import { Effect } from "effect"
|
|
7815
7859
|
*
|
|
7816
7860
|
* // Sync predicate
|
|
7817
7861
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7819,25 +7863,20 @@ export declare const filter: {
|
|
|
7819
7863
|
* // Effectful predicate
|
|
7820
7864
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7821
7865
|
*
|
|
7822
|
-
* //
|
|
7823
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7824
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7825
|
-
* )
|
|
7866
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7826
7867
|
* ```
|
|
7827
7868
|
*
|
|
7828
7869
|
* @since 2.0.0
|
|
7829
7870
|
* @category Filtering
|
|
7830
7871
|
*/
|
|
7831
|
-
<A
|
|
7832
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7833
|
-
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
7872
|
+
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>;
|
|
7834
7873
|
/**
|
|
7835
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7836
|
-
* predicate
|
|
7874
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7875
|
+
* predicate.
|
|
7837
7876
|
*
|
|
7838
7877
|
* @example
|
|
7839
7878
|
* ```ts
|
|
7840
|
-
* import { Effect
|
|
7879
|
+
* import { Effect } from "effect"
|
|
7841
7880
|
*
|
|
7842
7881
|
* // Sync predicate
|
|
7843
7882
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7845,116 +7884,63 @@ export declare const filter: {
|
|
|
7845
7884
|
* // Effectful predicate
|
|
7846
7885
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7847
7886
|
*
|
|
7848
|
-
* //
|
|
7849
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7850
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7851
|
-
* )
|
|
7887
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7852
7888
|
* ```
|
|
7853
7889
|
*
|
|
7854
7890
|
* @since 2.0.0
|
|
7855
7891
|
* @category Filtering
|
|
7856
7892
|
*/
|
|
7857
|
-
<A,
|
|
7893
|
+
<A, E, R>(iterable: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
7894
|
+
readonly concurrency?: Concurrency | undefined;
|
|
7895
|
+
}): Effect<Array<A>, E, R>;
|
|
7896
|
+
};
|
|
7897
|
+
/**
|
|
7898
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7899
|
+
*
|
|
7900
|
+
* @since 4.0.0
|
|
7901
|
+
* @category Filtering
|
|
7902
|
+
*/
|
|
7903
|
+
export declare const filterMap: {
|
|
7858
7904
|
/**
|
|
7859
|
-
* Filters elements of an iterable
|
|
7860
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7861
|
-
*
|
|
7862
|
-
* @example
|
|
7863
|
-
* ```ts
|
|
7864
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7865
|
-
*
|
|
7866
|
-
* // Sync predicate
|
|
7867
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7868
|
-
*
|
|
7869
|
-
* // Effectful predicate
|
|
7870
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7871
|
-
*
|
|
7872
|
-
* // FilterEffect
|
|
7873
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7874
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7875
|
-
* )
|
|
7876
|
-
* ```
|
|
7905
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7877
7906
|
*
|
|
7878
|
-
* @since
|
|
7907
|
+
* @since 4.0.0
|
|
7879
7908
|
* @category Filtering
|
|
7880
7909
|
*/
|
|
7881
|
-
<A>(
|
|
7910
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7882
7911
|
/**
|
|
7883
|
-
* Filters elements of an iterable
|
|
7884
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7885
|
-
*
|
|
7886
|
-
* @example
|
|
7887
|
-
* ```ts
|
|
7888
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7912
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7889
7913
|
*
|
|
7890
|
-
*
|
|
7891
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7892
|
-
*
|
|
7893
|
-
* // Effectful predicate
|
|
7894
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7895
|
-
*
|
|
7896
|
-
* // FilterEffect
|
|
7897
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7898
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7899
|
-
* )
|
|
7900
|
-
* ```
|
|
7901
|
-
*
|
|
7902
|
-
* @since 2.0.0
|
|
7914
|
+
* @since 4.0.0
|
|
7903
7915
|
* @category Filtering
|
|
7904
7916
|
*/
|
|
7905
7917
|
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>;
|
|
7918
|
+
};
|
|
7919
|
+
/**
|
|
7920
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7921
|
+
*
|
|
7922
|
+
* @since 4.0.0
|
|
7923
|
+
* @category Filtering
|
|
7924
|
+
*/
|
|
7925
|
+
export declare const filterMapEffect: {
|
|
7906
7926
|
/**
|
|
7907
|
-
*
|
|
7908
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7909
|
-
*
|
|
7910
|
-
* @example
|
|
7911
|
-
* ```ts
|
|
7912
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7913
|
-
*
|
|
7914
|
-
* // Sync predicate
|
|
7915
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7916
|
-
*
|
|
7917
|
-
* // Effectful predicate
|
|
7918
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7927
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7919
7928
|
*
|
|
7920
|
-
*
|
|
7921
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7922
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7923
|
-
* )
|
|
7924
|
-
* ```
|
|
7925
|
-
*
|
|
7926
|
-
* @since 2.0.0
|
|
7929
|
+
* @since 4.0.0
|
|
7927
7930
|
* @category Filtering
|
|
7928
7931
|
*/
|
|
7929
|
-
<A, B, X, E, R>(
|
|
7932
|
+
<A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7930
7933
|
readonly concurrency?: Concurrency | undefined;
|
|
7931
|
-
}): Effect<Array<B>, E, R>;
|
|
7934
|
+
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
7932
7935
|
/**
|
|
7933
|
-
*
|
|
7934
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7935
|
-
*
|
|
7936
|
-
* @example
|
|
7937
|
-
* ```ts
|
|
7938
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7939
|
-
*
|
|
7940
|
-
* // Sync predicate
|
|
7941
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7936
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7942
7937
|
*
|
|
7943
|
-
*
|
|
7944
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7945
|
-
*
|
|
7946
|
-
* // FilterEffect
|
|
7947
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7948
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7949
|
-
* )
|
|
7950
|
-
* ```
|
|
7951
|
-
*
|
|
7952
|
-
* @since 2.0.0
|
|
7938
|
+
* @since 4.0.0
|
|
7953
7939
|
* @category Filtering
|
|
7954
7940
|
*/
|
|
7955
|
-
<A, E, R>(
|
|
7941
|
+
<A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7956
7942
|
readonly concurrency?: Concurrency | undefined;
|
|
7957
|
-
}): Effect<Array<
|
|
7943
|
+
}): Effect<Array<B>, E, R>;
|
|
7958
7944
|
};
|
|
7959
7945
|
/**
|
|
7960
7946
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -8048,7 +8034,7 @@ export declare const filterOrElse: {
|
|
|
8048
8034
|
* @since 2.0.0
|
|
8049
8035
|
* @category Filtering
|
|
8050
8036
|
*/
|
|
8051
|
-
<A,
|
|
8037
|
+
<A, C, E2, R2>(predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>;
|
|
8052
8038
|
/**
|
|
8053
8039
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
8054
8040
|
*
|
|
@@ -8110,7 +8096,29 @@ export declare const filterOrElse: {
|
|
|
8110
8096
|
* @since 2.0.0
|
|
8111
8097
|
* @category Filtering
|
|
8112
8098
|
*/
|
|
8113
|
-
<A, E, R,
|
|
8099
|
+
<A, E, R, C, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): Effect<A | C, E | E2, R | R2>;
|
|
8100
|
+
};
|
|
8101
|
+
/**
|
|
8102
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8103
|
+
*
|
|
8104
|
+
* @since 4.0.0
|
|
8105
|
+
* @category Filtering
|
|
8106
|
+
*/
|
|
8107
|
+
export declare const filterMapOrElse: {
|
|
8108
|
+
/**
|
|
8109
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8110
|
+
*
|
|
8111
|
+
* @since 4.0.0
|
|
8112
|
+
* @category Filtering
|
|
8113
|
+
*/
|
|
8114
|
+
<A, B, X, C, E2, R2>(filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>;
|
|
8115
|
+
/**
|
|
8116
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8117
|
+
*
|
|
8118
|
+
* @since 4.0.0
|
|
8119
|
+
* @category Filtering
|
|
8120
|
+
*/
|
|
8121
|
+
<A, E, R, B, X, C, E2, R2>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): Effect<B | C, E | E2, R | R2>;
|
|
8114
8122
|
};
|
|
8115
8123
|
/**
|
|
8116
8124
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
@@ -8231,7 +8239,7 @@ export declare const filterOrFail: {
|
|
|
8231
8239
|
* @since 2.0.0
|
|
8232
8240
|
* @category Filtering
|
|
8233
8241
|
*/
|
|
8234
|
-
<A, B
|
|
8242
|
+
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8235
8243
|
/**
|
|
8236
8244
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8237
8245
|
*
|
|
@@ -8261,7 +8269,7 @@ export declare const filterOrFail: {
|
|
|
8261
8269
|
* @since 2.0.0
|
|
8262
8270
|
* @category Filtering
|
|
8263
8271
|
*/
|
|
8264
|
-
<A
|
|
8272
|
+
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
|
|
8265
8273
|
/**
|
|
8266
8274
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8267
8275
|
*
|
|
@@ -8291,7 +8299,7 @@ export declare const filterOrFail: {
|
|
|
8291
8299
|
* @since 2.0.0
|
|
8292
8300
|
* @category Filtering
|
|
8293
8301
|
*/
|
|
8294
|
-
<A
|
|
8302
|
+
<A, E, R, E2, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): Effect<B, E2 | E, R>;
|
|
8295
8303
|
/**
|
|
8296
8304
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8297
8305
|
*
|
|
@@ -8321,7 +8329,7 @@ export declare const filterOrFail: {
|
|
|
8321
8329
|
* @since 2.0.0
|
|
8322
8330
|
* @category Filtering
|
|
8323
8331
|
*/
|
|
8324
|
-
<A,
|
|
8332
|
+
<A, E, R, E2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): Effect<A, E2 | E, R>;
|
|
8325
8333
|
/**
|
|
8326
8334
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8327
8335
|
*
|
|
@@ -8351,7 +8359,7 @@ export declare const filterOrFail: {
|
|
|
8351
8359
|
* @since 2.0.0
|
|
8352
8360
|
* @category Filtering
|
|
8353
8361
|
*/
|
|
8354
|
-
<A, E, R,
|
|
8362
|
+
<A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>;
|
|
8355
8363
|
/**
|
|
8356
8364
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8357
8365
|
*
|
|
@@ -8381,127 +8389,43 @@ export declare const filterOrFail: {
|
|
|
8381
8389
|
* @since 2.0.0
|
|
8382
8390
|
* @category Filtering
|
|
8383
8391
|
*/
|
|
8384
|
-
<A, E, R
|
|
8392
|
+
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>;
|
|
8393
|
+
};
|
|
8394
|
+
/**
|
|
8395
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8396
|
+
*
|
|
8397
|
+
* @since 4.0.0
|
|
8398
|
+
* @category Filtering
|
|
8399
|
+
*/
|
|
8400
|
+
export declare const filterMapOrFail: {
|
|
8385
8401
|
/**
|
|
8386
|
-
* Filters an effect
|
|
8402
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8387
8403
|
*
|
|
8388
|
-
*
|
|
8389
|
-
*
|
|
8390
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8391
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8392
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8393
|
-
*
|
|
8394
|
-
* @example
|
|
8395
|
-
* ```ts
|
|
8396
|
-
* import { Effect } from "effect"
|
|
8397
|
-
*
|
|
8398
|
-
* // An effect that produces a number
|
|
8399
|
-
* const program = Effect.succeed(5)
|
|
8400
|
-
*
|
|
8401
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8402
|
-
* const filtered = Effect.filterOrFail(
|
|
8403
|
-
* program,
|
|
8404
|
-
* (n) => n % 2 === 0,
|
|
8405
|
-
* (n) => `Expected even number, got ${n}`
|
|
8406
|
-
* )
|
|
8407
|
-
*
|
|
8408
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8409
|
-
* ```
|
|
8410
|
-
*
|
|
8411
|
-
* @since 2.0.0
|
|
8404
|
+
* @since 4.0.0
|
|
8412
8405
|
* @category Filtering
|
|
8413
8406
|
*/
|
|
8414
|
-
<A,
|
|
8407
|
+
<A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>;
|
|
8415
8408
|
/**
|
|
8416
|
-
* Filters an effect
|
|
8417
|
-
*
|
|
8418
|
-
* **Details**
|
|
8419
|
-
*
|
|
8420
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8421
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8422
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8423
|
-
*
|
|
8424
|
-
* @example
|
|
8425
|
-
* ```ts
|
|
8426
|
-
* import { Effect } from "effect"
|
|
8427
|
-
*
|
|
8428
|
-
* // An effect that produces a number
|
|
8429
|
-
* const program = Effect.succeed(5)
|
|
8430
|
-
*
|
|
8431
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8432
|
-
* const filtered = Effect.filterOrFail(
|
|
8433
|
-
* program,
|
|
8434
|
-
* (n) => n % 2 === 0,
|
|
8435
|
-
* (n) => `Expected even number, got ${n}`
|
|
8436
|
-
* )
|
|
8409
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8437
8410
|
*
|
|
8438
|
-
*
|
|
8439
|
-
* ```
|
|
8440
|
-
*
|
|
8441
|
-
* @since 2.0.0
|
|
8411
|
+
* @since 4.0.0
|
|
8442
8412
|
* @category Filtering
|
|
8443
8413
|
*/
|
|
8444
|
-
<A,
|
|
8414
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8445
8415
|
/**
|
|
8446
|
-
* Filters an effect
|
|
8447
|
-
*
|
|
8448
|
-
* **Details**
|
|
8449
|
-
*
|
|
8450
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8451
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8452
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8453
|
-
*
|
|
8454
|
-
* @example
|
|
8455
|
-
* ```ts
|
|
8456
|
-
* import { Effect } from "effect"
|
|
8457
|
-
*
|
|
8458
|
-
* // An effect that produces a number
|
|
8459
|
-
* const program = Effect.succeed(5)
|
|
8416
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8460
8417
|
*
|
|
8461
|
-
*
|
|
8462
|
-
* const filtered = Effect.filterOrFail(
|
|
8463
|
-
* program,
|
|
8464
|
-
* (n) => n % 2 === 0,
|
|
8465
|
-
* (n) => `Expected even number, got ${n}`
|
|
8466
|
-
* )
|
|
8467
|
-
*
|
|
8468
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8469
|
-
* ```
|
|
8470
|
-
*
|
|
8471
|
-
* @since 2.0.0
|
|
8418
|
+
* @since 4.0.0
|
|
8472
8419
|
* @category Filtering
|
|
8473
8420
|
*/
|
|
8474
|
-
<A, E, R>(self: Effect<A, E, R>,
|
|
8421
|
+
<A, E, R, B, X, E2>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>, orFailWith: (x: X) => E2): Effect<B, E2 | E, R>;
|
|
8475
8422
|
/**
|
|
8476
|
-
* Filters an effect
|
|
8477
|
-
*
|
|
8478
|
-
* **Details**
|
|
8479
|
-
*
|
|
8480
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8481
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8482
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8483
|
-
*
|
|
8484
|
-
* @example
|
|
8485
|
-
* ```ts
|
|
8486
|
-
* import { Effect } from "effect"
|
|
8487
|
-
*
|
|
8488
|
-
* // An effect that produces a number
|
|
8489
|
-
* const program = Effect.succeed(5)
|
|
8490
|
-
*
|
|
8491
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8492
|
-
* const filtered = Effect.filterOrFail(
|
|
8493
|
-
* program,
|
|
8494
|
-
* (n) => n % 2 === 0,
|
|
8495
|
-
* (n) => `Expected even number, got ${n}`
|
|
8496
|
-
* )
|
|
8497
|
-
*
|
|
8498
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8499
|
-
* ```
|
|
8423
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8500
8424
|
*
|
|
8501
|
-
* @since
|
|
8425
|
+
* @since 4.0.0
|
|
8502
8426
|
* @category Filtering
|
|
8503
8427
|
*/
|
|
8504
|
-
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B,
|
|
8428
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8505
8429
|
};
|
|
8506
8430
|
/**
|
|
8507
8431
|
* Conditionally executes an effect based on a boolean condition.
|
|
@@ -11279,7 +11203,7 @@ export declare const onError: {
|
|
|
11279
11203
|
};
|
|
11280
11204
|
/**
|
|
11281
11205
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11282
|
-
*
|
|
11206
|
+
* provided predicate.
|
|
11283
11207
|
*
|
|
11284
11208
|
* @example
|
|
11285
11209
|
* ```ts
|
|
@@ -11303,7 +11227,7 @@ export declare const onError: {
|
|
|
11303
11227
|
export declare const onErrorIf: {
|
|
11304
11228
|
/**
|
|
11305
11229
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11306
|
-
*
|
|
11230
|
+
* provided predicate.
|
|
11307
11231
|
*
|
|
11308
11232
|
* @example
|
|
11309
11233
|
* ```ts
|
|
@@ -11324,10 +11248,10 @@ export declare const onErrorIf: {
|
|
|
11324
11248
|
* @since 4.0.0
|
|
11325
11249
|
* @category Resource Management & Finalization
|
|
11326
11250
|
*/
|
|
11327
|
-
<E,
|
|
11251
|
+
<E, XE, XR>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11328
11252
|
/**
|
|
11329
11253
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11330
|
-
*
|
|
11254
|
+
* provided predicate.
|
|
11331
11255
|
*
|
|
11332
11256
|
* @example
|
|
11333
11257
|
* ```ts
|
|
@@ -11348,7 +11272,29 @@ export declare const onErrorIf: {
|
|
|
11348
11272
|
* @since 4.0.0
|
|
11349
11273
|
* @category Resource Management & Finalization
|
|
11350
11274
|
*/
|
|
11351
|
-
<A, E, R, XE, XR
|
|
11275
|
+
<A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11276
|
+
};
|
|
11277
|
+
/**
|
|
11278
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11279
|
+
*
|
|
11280
|
+
* @since 4.0.0
|
|
11281
|
+
* @category Resource Management & Finalization
|
|
11282
|
+
*/
|
|
11283
|
+
export declare const onErrorFilter: {
|
|
11284
|
+
/**
|
|
11285
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11286
|
+
*
|
|
11287
|
+
* @since 4.0.0
|
|
11288
|
+
* @category Resource Management & Finalization
|
|
11289
|
+
*/
|
|
11290
|
+
<A, E, EB, X, XE, XR>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11291
|
+
/**
|
|
11292
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11293
|
+
*
|
|
11294
|
+
* @since 4.0.0
|
|
11295
|
+
* @category Resource Management & Finalization
|
|
11296
|
+
*/
|
|
11297
|
+
<A, E, R, EB, X, XE, XR>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11352
11298
|
};
|
|
11353
11299
|
/**
|
|
11354
11300
|
* The low level primitive that powers `onExit`.
|
|
@@ -11442,20 +11388,20 @@ export declare const onExit: {
|
|
|
11442
11388
|
<A, E, R, XE = never, XR = never>(self: Effect<A, E, R>, f: (exit: Exit.Exit<A, E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11443
11389
|
};
|
|
11444
11390
|
/**
|
|
11445
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11446
|
-
*
|
|
11447
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11391
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11392
|
+
* predicate.
|
|
11448
11393
|
*
|
|
11449
11394
|
* @example
|
|
11450
11395
|
* ```ts
|
|
11451
|
-
* import { Console, Effect, Exit
|
|
11452
|
-
*
|
|
11453
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11396
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11454
11397
|
*
|
|
11455
11398
|
* const program = Effect.onExitIf(
|
|
11456
11399
|
* Effect.succeed(42),
|
|
11457
|
-
*
|
|
11458
|
-
* (
|
|
11400
|
+
* Exit.isSuccess,
|
|
11401
|
+
* (exit) =>
|
|
11402
|
+
* Exit.isSuccess(exit)
|
|
11403
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11404
|
+
* : Effect.void
|
|
11459
11405
|
* )
|
|
11460
11406
|
* ```
|
|
11461
11407
|
*
|
|
@@ -11464,49 +11410,71 @@ export declare const onExit: {
|
|
|
11464
11410
|
*/
|
|
11465
11411
|
export declare const onExitIf: {
|
|
11466
11412
|
/**
|
|
11467
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11468
|
-
*
|
|
11469
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11413
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11414
|
+
* predicate.
|
|
11470
11415
|
*
|
|
11471
11416
|
* @example
|
|
11472
11417
|
* ```ts
|
|
11473
|
-
* import { Console, Effect, Exit
|
|
11474
|
-
*
|
|
11475
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11418
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11476
11419
|
*
|
|
11477
11420
|
* const program = Effect.onExitIf(
|
|
11478
11421
|
* Effect.succeed(42),
|
|
11479
|
-
*
|
|
11480
|
-
* (
|
|
11422
|
+
* Exit.isSuccess,
|
|
11423
|
+
* (exit) =>
|
|
11424
|
+
* Exit.isSuccess(exit)
|
|
11425
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11426
|
+
* : Effect.void
|
|
11481
11427
|
* )
|
|
11482
11428
|
* ```
|
|
11483
11429
|
*
|
|
11484
11430
|
* @since 4.0.0
|
|
11485
11431
|
* @category Resource Management & Finalization
|
|
11486
11432
|
*/
|
|
11487
|
-
<A, E, XE, XR
|
|
11433
|
+
<A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11488
11434
|
/**
|
|
11489
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11490
|
-
*
|
|
11491
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11435
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11436
|
+
* predicate.
|
|
11492
11437
|
*
|
|
11493
11438
|
* @example
|
|
11494
11439
|
* ```ts
|
|
11495
|
-
* import { Console, Effect, Exit
|
|
11496
|
-
*
|
|
11497
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11440
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11498
11441
|
*
|
|
11499
11442
|
* const program = Effect.onExitIf(
|
|
11500
11443
|
* Effect.succeed(42),
|
|
11501
|
-
*
|
|
11502
|
-
* (
|
|
11444
|
+
* Exit.isSuccess,
|
|
11445
|
+
* (exit) =>
|
|
11446
|
+
* Exit.isSuccess(exit)
|
|
11447
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11448
|
+
* : Effect.void
|
|
11503
11449
|
* )
|
|
11504
11450
|
* ```
|
|
11505
11451
|
*
|
|
11506
11452
|
* @since 4.0.0
|
|
11507
11453
|
* @category Resource Management & Finalization
|
|
11508
11454
|
*/
|
|
11509
|
-
<A, E, R, XE, XR
|
|
11455
|
+
<A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11456
|
+
};
|
|
11457
|
+
/**
|
|
11458
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11459
|
+
*
|
|
11460
|
+
* @since 4.0.0
|
|
11461
|
+
* @category Resource Management & Finalization
|
|
11462
|
+
*/
|
|
11463
|
+
export declare const onExitFilter: {
|
|
11464
|
+
/**
|
|
11465
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11466
|
+
*
|
|
11467
|
+
* @since 4.0.0
|
|
11468
|
+
* @category Resource Management & Finalization
|
|
11469
|
+
*/
|
|
11470
|
+
<A, E, XE, XR, B, X>(filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11471
|
+
/**
|
|
11472
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11473
|
+
*
|
|
11474
|
+
* @since 4.0.0
|
|
11475
|
+
* @category Resource Management & Finalization
|
|
11476
|
+
*/
|
|
11477
|
+
<A, E, R, XE, XR, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11510
11478
|
};
|
|
11511
11479
|
/**
|
|
11512
11480
|
* Returns an effect that lazily computes a result and caches it for subsequent
|
|
@@ -17427,118 +17395,63 @@ declare const Transaction_base: ServiceMap.ServiceClass<Transaction, "effect/Eff
|
|
|
17427
17395
|
export declare class Transaction extends Transaction_base {
|
|
17428
17396
|
}
|
|
17429
17397
|
/**
|
|
17430
|
-
*
|
|
17431
|
-
* transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17398
|
+
* Accesses the current transaction state within an active transaction.
|
|
17432
17399
|
*
|
|
17433
|
-
*
|
|
17434
|
-
*
|
|
17435
|
-
*
|
|
17436
|
-
* accessed transactional values changes.
|
|
17437
|
-
*
|
|
17438
|
-
* - any of the accessed transactional values change during the execution of the transaction
|
|
17439
|
-
* due to a different transaction committing before the current.
|
|
17440
|
-
*
|
|
17441
|
-
* - parent transaction retry, if you have a transaction within another transaction and
|
|
17442
|
-
* the parent retries the child will also retry together with the parent.
|
|
17400
|
+
* This function requires `Transaction` in the context and does NOT create or strip
|
|
17401
|
+
* transaction boundaries. Use it to interact with the transaction journal (e.g. in
|
|
17402
|
+
* `TxRef` internals). To define a transaction boundary, use {@link transaction}.
|
|
17443
17403
|
*
|
|
17444
17404
|
* @example
|
|
17445
17405
|
* ```ts
|
|
17446
17406
|
* import { Effect, TxRef } from "effect"
|
|
17447
17407
|
*
|
|
17448
17408
|
* const program = Effect.gen(function*() {
|
|
17449
|
-
* const
|
|
17450
|
-
* const ref2 = yield* TxRef.make(0)
|
|
17451
|
-
*
|
|
17452
|
-
* // All operations within atomic block succeed or fail together
|
|
17453
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17454
|
-
* yield* TxRef.set(ref1, 10)
|
|
17455
|
-
* yield* TxRef.set(ref2, 20)
|
|
17456
|
-
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
17457
|
-
* console.log(`Transaction sum: ${sum}`)
|
|
17458
|
-
* }))
|
|
17459
|
-
*
|
|
17460
|
-
* console.log(`Final ref1: ${yield* TxRef.get(ref1)}`) // 10
|
|
17461
|
-
* console.log(`Final ref2: ${yield* TxRef.get(ref2)}`) // 20
|
|
17462
|
-
* })
|
|
17463
|
-
* ```
|
|
17464
|
-
*
|
|
17465
|
-
* @since 4.0.0
|
|
17466
|
-
* @category Transactions
|
|
17467
|
-
*/
|
|
17468
|
-
export declare const atomic: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17469
|
-
/**
|
|
17470
|
-
* Executes a function within a transaction context, providing access to the transaction state.
|
|
17471
|
-
*
|
|
17472
|
-
* @example
|
|
17473
|
-
* ```ts
|
|
17474
|
-
* import { Effect, TxRef } from "effect"
|
|
17475
|
-
*
|
|
17476
|
-
* const program = Effect.atomicWith((txState) =>
|
|
17477
|
-
* Effect.gen(function*() {
|
|
17478
|
-
* const ref = yield* TxRef.make(0)
|
|
17479
|
-
*
|
|
17480
|
-
* // Access transaction state for debugging
|
|
17481
|
-
* console.log(`Journal size: ${txState.journal.size}`)
|
|
17482
|
-
* console.log(`Retry flag: ${txState.retry}`)
|
|
17409
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
17483
17410
|
*
|
|
17411
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17484
17412
|
* yield* TxRef.set(ref, 42)
|
|
17485
17413
|
* return yield* TxRef.get(ref)
|
|
17486
|
-
* })
|
|
17487
|
-
* )
|
|
17488
|
-
*
|
|
17489
|
-
* Effect.runPromise(program).then(console.log) // 42
|
|
17414
|
+
* }))
|
|
17415
|
+
* })
|
|
17490
17416
|
* ```
|
|
17491
17417
|
*
|
|
17492
17418
|
* @since 4.0.0
|
|
17493
17419
|
* @category Transactions
|
|
17494
17420
|
*/
|
|
17495
|
-
export declare const
|
|
17421
|
+
export declare const withTxState: <A, E, R>(f: (state: Transaction["Service"]) => Effect<A, E, R>) => Effect<A, E, R | Transaction>;
|
|
17496
17422
|
/**
|
|
17497
|
-
*
|
|
17423
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
17424
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17498
17425
|
*
|
|
17499
|
-
*
|
|
17426
|
+
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
17500
17427
|
*
|
|
17501
|
-
*
|
|
17502
|
-
*
|
|
17503
|
-
* This ensures complete isolation between different transaction scopes.
|
|
17428
|
+
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
17429
|
+
* accessed transactional values changes.
|
|
17504
17430
|
*
|
|
17505
|
-
*
|
|
17506
|
-
*
|
|
17507
|
-
* - Parent transaction failures don't affect isolated transactions
|
|
17508
|
-
* - Isolated transaction failures don't affect parent transactions
|
|
17509
|
-
* - Each transaction has its own journal and retry logic
|
|
17431
|
+
* - any of the accessed transactional values change during the execution of the transaction
|
|
17432
|
+
* due to a different transaction committing before the current.
|
|
17510
17433
|
*
|
|
17511
|
-
*
|
|
17512
|
-
*
|
|
17513
|
-
* - For implementing independent operations that shouldn't be affected by outer transactions
|
|
17514
|
-
* - When building transaction-based systems where isolation is critical
|
|
17434
|
+
* Each call to `transaction` always creates a new isolated transaction boundary with its own
|
|
17435
|
+
* journal and retry logic.
|
|
17515
17436
|
*
|
|
17516
17437
|
* @example
|
|
17517
17438
|
* ```ts
|
|
17518
17439
|
* import { Effect, TxRef } from "effect"
|
|
17519
17440
|
*
|
|
17520
17441
|
* const program = Effect.gen(function*() {
|
|
17521
|
-
* const ref1 = yield* TxRef.make(0)
|
|
17522
|
-
* const ref2 = yield* TxRef.make(
|
|
17442
|
+
* const ref1 = yield* Effect.transaction(TxRef.make(0))
|
|
17443
|
+
* const ref2 = yield* Effect.transaction(TxRef.make(0))
|
|
17523
17444
|
*
|
|
17524
|
-
* //
|
|
17525
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17526
|
-
* yield* TxRef.set(ref1, 10)
|
|
17527
|
-
*
|
|
17528
|
-
* // This atomic operation composes with the parent
|
|
17529
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17530
|
-
* yield* TxRef.set(ref1, 20) // Part of same transaction
|
|
17531
|
-
* }))
|
|
17532
|
-
* }))
|
|
17533
|
-
*
|
|
17534
|
-
* // Isolated transaction - ref2 will be in its own transaction
|
|
17445
|
+
* // All operations within transaction block succeed or fail together
|
|
17535
17446
|
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17536
|
-
* yield* TxRef.set(
|
|
17447
|
+
* yield* TxRef.set(ref1, 10)
|
|
17448
|
+
* yield* TxRef.set(ref2, 20)
|
|
17449
|
+
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
17450
|
+
* console.log(`Transaction sum: ${sum}`)
|
|
17537
17451
|
* }))
|
|
17538
17452
|
*
|
|
17539
|
-
*
|
|
17540
|
-
*
|
|
17541
|
-
* return { ref1: val1, ref2: val2 }
|
|
17453
|
+
* console.log(`Final ref1: ${yield* Effect.transaction(TxRef.get(ref1))}`) // 10
|
|
17454
|
+
* console.log(`Final ref2: ${yield* Effect.transaction(TxRef.get(ref2))}`) // 20
|
|
17542
17455
|
* })
|
|
17543
17456
|
* ```
|
|
17544
17457
|
*
|
|
@@ -17547,34 +17460,21 @@ export declare const atomicWith: <A, E, R>(f: (state: Transaction["Service"]) =>
|
|
|
17547
17460
|
*/
|
|
17548
17461
|
export declare const transaction: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17549
17462
|
/**
|
|
17550
|
-
*
|
|
17463
|
+
* Like {@link transaction} but provides access to the transaction state.
|
|
17551
17464
|
*
|
|
17552
|
-
*
|
|
17553
|
-
* within another transaction. This ensures complete isolation between transaction scopes.
|
|
17465
|
+
* Always creates a new isolated transaction boundary with its own journal and retry logic.
|
|
17554
17466
|
*
|
|
17555
17467
|
* @example
|
|
17556
17468
|
* ```ts
|
|
17557
17469
|
* import { Effect, TxRef } from "effect"
|
|
17558
17470
|
*
|
|
17559
|
-
* const program = Effect.transactionWith((
|
|
17471
|
+
* const program = Effect.transactionWith((_txState) =>
|
|
17560
17472
|
* Effect.gen(function*() {
|
|
17561
17473
|
* const ref = yield* TxRef.make(0)
|
|
17562
|
-
*
|
|
17563
|
-
* // This transaction is isolated - it has its own journal
|
|
17564
|
-
* // txState.journal is independent of any parent transaction
|
|
17565
|
-
*
|
|
17566
17474
|
* yield* TxRef.set(ref, 42)
|
|
17567
17475
|
* return yield* TxRef.get(ref)
|
|
17568
17476
|
* })
|
|
17569
17477
|
* )
|
|
17570
|
-
*
|
|
17571
|
-
* // Even when nested in another atomic block, this transaction is isolated
|
|
17572
|
-
* const nestedProgram = Effect.atomic(
|
|
17573
|
-
* Effect.gen(function*() {
|
|
17574
|
-
* const result = yield* program // Runs in its own isolated transaction
|
|
17575
|
-
* return result
|
|
17576
|
-
* })
|
|
17577
|
-
* )
|
|
17578
17478
|
* ```
|
|
17579
17479
|
*
|
|
17580
17480
|
* @since 4.0.0
|
|
@@ -17596,16 +17496,16 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
|
|
|
17596
17496
|
*
|
|
17597
17497
|
* const program = Effect.gen(function*() {
|
|
17598
17498
|
* // create a transactional reference
|
|
17599
|
-
* const ref = yield* TxRef.make(0)
|
|
17499
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
17600
17500
|
*
|
|
17601
17501
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
17602
17502
|
* yield* Effect.forkChild(Effect.forever(
|
|
17603
17503
|
* // update to transactional value
|
|
17604
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
17504
|
+
* Effect.transaction(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
17605
17505
|
* ))
|
|
17606
17506
|
*
|
|
17607
17507
|
* // the following will retry 10 times until the `ref` value is 10
|
|
17608
|
-
* yield* Effect.
|
|
17508
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17609
17509
|
* const value = yield* TxRef.get(ref)
|
|
17610
17510
|
* if (value < 10) {
|
|
17611
17511
|
* yield* Effect.log(`retry due to value: ${value}`)
|