effect 4.0.0-beta.68 → 4.0.0-beta.69
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/Channel.d.ts.map +1 -1
- package/dist/Channel.js +1 -1
- package/dist/Channel.js.map +1 -1
- package/dist/Effect.d.ts +485 -485
- package/dist/Effect.js +218 -218
- package/dist/index.d.ts +21 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -29
- package/dist/index.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +1 -1
- package/dist/unstable/ai/index.js +1 -1
- package/dist/unstable/cli/Flag.d.ts +23 -0
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +23 -0
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +2 -0
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +27 -0
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +30 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +1 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +3 -0
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +3 -0
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts.map +1 -1
- package/dist/unstable/cli/internal/help.js +10 -0
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +3 -0
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/index.d.ts +1 -1
- package/dist/unstable/cluster/index.js +1 -1
- package/dist/unstable/observability/index.d.ts +1 -1
- package/dist/unstable/observability/index.js +1 -1
- package/dist/unstable/process/index.d.ts +1 -1
- package/dist/unstable/process/index.js +1 -1
- package/dist/unstable/reactivity/index.d.ts +2 -3
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +2 -3
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcWorker.js +1 -1
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/sql/Migrator.d.ts +6 -4
- package/dist/unstable/sql/Migrator.d.ts.map +1 -1
- package/dist/unstable/sql/Migrator.js +9 -7
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/index.d.ts +0 -1
- package/dist/unstable/sql/index.d.ts.map +1 -1
- package/dist/unstable/sql/index.js +0 -1
- package/dist/unstable/sql/index.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +5 -9
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +3 -3
- package/src/Channel.ts +6 -1
- package/src/Effect.ts +491 -491
- package/src/index.ts +21 -29
- package/src/unstable/ai/index.ts +1 -1
- package/src/unstable/cli/Flag.ts +24 -0
- package/src/unstable/cli/Param.ts +32 -0
- package/src/unstable/cli/index.ts +1 -1
- package/src/unstable/cli/internal/command.ts +3 -0
- package/src/unstable/cli/internal/completions/descriptor.ts +3 -0
- package/src/unstable/cli/internal/help.ts +10 -0
- package/src/unstable/cli/internal/parser.ts +3 -0
- package/src/unstable/cluster/index.ts +1 -1
- package/src/unstable/observability/index.ts +1 -1
- package/src/unstable/process/index.ts +1 -1
- package/src/unstable/reactivity/index.ts +2 -3
- package/src/unstable/rpc/RpcWorker.ts +3 -1
- package/src/unstable/sql/Migrator.ts +9 -7
- package/src/unstable/sql/index.ts +0 -1
- package/src/unstable/workflow/WorkflowEngine.ts +7 -11
package/dist/Effect.js
CHANGED
|
@@ -21,7 +21,7 @@ export const TypeId = core.EffectTypeId;
|
|
|
21
21
|
/**
|
|
22
22
|
* Tests if a value is an `Effect`.
|
|
23
23
|
*
|
|
24
|
-
* **Example** (
|
|
24
|
+
* **Example** (Checking whether a value is an Effect)
|
|
25
25
|
*
|
|
26
26
|
* ```ts
|
|
27
27
|
* import { Effect } from "effect"
|
|
@@ -52,7 +52,7 @@ export const isEffect = core.isEffect;
|
|
|
52
52
|
* `Result` in the same output shape. Use `discard: true` to ignore successful
|
|
53
53
|
* values and return `void`.
|
|
54
54
|
*
|
|
55
|
-
* **Example** (
|
|
55
|
+
* **Example** (Collecting tuple results in order)
|
|
56
56
|
*
|
|
57
57
|
* ```ts
|
|
58
58
|
* import { Console, Effect } from "effect"
|
|
@@ -73,7 +73,7 @@ export const isEffect = core.isEffect;
|
|
|
73
73
|
* // [ 42, 'Hello' ]
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
|
-
* **Example** (
|
|
76
|
+
* **Example** (Collecting iterable results in order)
|
|
77
77
|
*
|
|
78
78
|
* ```ts
|
|
79
79
|
* import { Console, Effect } from "effect"
|
|
@@ -94,7 +94,7 @@ export const isEffect = core.isEffect;
|
|
|
94
94
|
* // [ 1, 2, 3 ]
|
|
95
95
|
* ```
|
|
96
96
|
*
|
|
97
|
-
* **Example** (
|
|
97
|
+
* **Example** (Collecting struct results by key)
|
|
98
98
|
*
|
|
99
99
|
* ```ts
|
|
100
100
|
* import { Console, Effect } from "effect"
|
|
@@ -115,7 +115,7 @@ export const isEffect = core.isEffect;
|
|
|
115
115
|
* // { a: 42, b: 'Hello' }
|
|
116
116
|
* ```
|
|
117
117
|
*
|
|
118
|
-
* **Example** (
|
|
118
|
+
* **Example** (Collecting record results by key)
|
|
119
119
|
*
|
|
120
120
|
* ```ts
|
|
121
121
|
* import { Console, Effect } from "effect"
|
|
@@ -136,7 +136,7 @@ export const isEffect = core.isEffect;
|
|
|
136
136
|
* // { key1: 1, key2: 2 }
|
|
137
137
|
* ```
|
|
138
138
|
*
|
|
139
|
-
* **Example** (
|
|
139
|
+
* **Example** (Stopping on the first failure)
|
|
140
140
|
*
|
|
141
141
|
* ```ts
|
|
142
142
|
* import { Console, Effect } from "effect"
|
|
@@ -176,7 +176,7 @@ export const all = internal.all;
|
|
|
176
176
|
* This function runs every effect and never fails. Use `concurrency` to control
|
|
177
177
|
* parallelism.
|
|
178
178
|
*
|
|
179
|
-
* **Example** (
|
|
179
|
+
* **Example** (Separating successes and failures)
|
|
180
180
|
*
|
|
181
181
|
* ```ts
|
|
182
182
|
* import { Effect } from "effect"
|
|
@@ -203,7 +203,7 @@ export const partition = internal.partition;
|
|
|
203
203
|
* Use `discard: true` to ignore successful values while still validating all
|
|
204
204
|
* elements.
|
|
205
205
|
*
|
|
206
|
-
* **Example** (
|
|
206
|
+
* **Example** (Validating every element)
|
|
207
207
|
*
|
|
208
208
|
* ```ts
|
|
209
209
|
* import { Effect } from "effect"
|
|
@@ -236,7 +236,7 @@ export const validate = internal.validate;
|
|
|
236
236
|
* The predicate receives the element and its index. Evaluation short-circuits
|
|
237
237
|
* as soon as an element matches.
|
|
238
238
|
*
|
|
239
|
-
* **Example** (
|
|
239
|
+
* **Example** (Finding the first successful match)
|
|
240
240
|
*
|
|
241
241
|
* ```ts
|
|
242
242
|
* import { Effect } from "effect"
|
|
@@ -284,7 +284,7 @@ export const findFirstFilter = internal.findFirstFilter;
|
|
|
284
284
|
*
|
|
285
285
|
* @see {@link all} for combining multiple effects into one.
|
|
286
286
|
*
|
|
287
|
-
* **Example** (
|
|
287
|
+
* **Example** (Mapping over an iterable with effects)
|
|
288
288
|
*
|
|
289
289
|
* ```ts
|
|
290
290
|
* import { Console, Effect } from "effect"
|
|
@@ -305,7 +305,7 @@ export const findFirstFilter = internal.findFirstFilter;
|
|
|
305
305
|
* // [ 2, 4, 6, 8, 10 ]
|
|
306
306
|
* ```
|
|
307
307
|
*
|
|
308
|
-
* **Example** (
|
|
308
|
+
* **Example** (Running effects without collecting results)
|
|
309
309
|
*
|
|
310
310
|
* ```ts
|
|
311
311
|
* import { Console, Effect } from "effect"
|
|
@@ -335,7 +335,7 @@ export const forEach = internal.forEach;
|
|
|
335
335
|
/**
|
|
336
336
|
* Executes a body effect repeatedly while a condition holds true.
|
|
337
337
|
*
|
|
338
|
-
* **Example** (
|
|
338
|
+
* **Example** (Repeating an effectful loop)
|
|
339
339
|
*
|
|
340
340
|
* ```ts
|
|
341
341
|
* import { Effect } from "effect"
|
|
@@ -389,7 +389,7 @@ export const whileLoop = internal.whileLoop;
|
|
|
389
389
|
*
|
|
390
390
|
* @see {@link tryPromise} for a version that can handle failures.
|
|
391
391
|
*
|
|
392
|
-
* **Example** (
|
|
392
|
+
* **Example** (Wrapping a non-rejecting Promise)
|
|
393
393
|
*
|
|
394
394
|
* ```ts
|
|
395
395
|
* import { Effect } from "effect"
|
|
@@ -439,7 +439,7 @@ export const promise = internal.promise;
|
|
|
439
439
|
* An optional `AbortSignal` can be provided to allow for interruption of the
|
|
440
440
|
* wrapped `Promise` API.
|
|
441
441
|
*
|
|
442
|
-
* **Example** (
|
|
442
|
+
* **Example** (Wrapping a fetch request that may fail)
|
|
443
443
|
*
|
|
444
444
|
* ```ts
|
|
445
445
|
* import { Effect } from "effect"
|
|
@@ -455,7 +455,7 @@ export const promise = internal.promise;
|
|
|
455
455
|
* const program = getTodo(1)
|
|
456
456
|
* ```
|
|
457
457
|
*
|
|
458
|
-
* **Example** (
|
|
458
|
+
* **Example** (Mapping Promise rejections to a tagged error)
|
|
459
459
|
*
|
|
460
460
|
* ```ts
|
|
461
461
|
* import { Data, Effect } from "effect"
|
|
@@ -490,7 +490,7 @@ export const tryPromise = internal.tryPromise;
|
|
|
490
490
|
*
|
|
491
491
|
* @see {@link fail} to create an effect that represents a failure.
|
|
492
492
|
*
|
|
493
|
-
* **Example** (Creating a
|
|
493
|
+
* **Example** (Creating a successful effect)
|
|
494
494
|
*
|
|
495
495
|
* ```ts
|
|
496
496
|
* import { Effect } from "effect"
|
|
@@ -509,7 +509,7 @@ export const succeed = internal.succeed;
|
|
|
509
509
|
/**
|
|
510
510
|
* Returns an effect which succeeds with `None`.
|
|
511
511
|
*
|
|
512
|
-
* **Example** (
|
|
512
|
+
* **Example** (Succeeding with Option.none)
|
|
513
513
|
*
|
|
514
514
|
* ```ts
|
|
515
515
|
* import { Effect } from "effect"
|
|
@@ -527,7 +527,7 @@ export const succeedNone = internal.succeedNone;
|
|
|
527
527
|
/**
|
|
528
528
|
* Returns an effect which succeeds with the value wrapped in a `Some`.
|
|
529
529
|
*
|
|
530
|
-
* **Example** (
|
|
530
|
+
* **Example** (Succeeding with Option.some)
|
|
531
531
|
*
|
|
532
532
|
* ```ts
|
|
533
533
|
* import { Effect } from "effect"
|
|
@@ -556,7 +556,7 @@ export const succeedSome = internal.succeedSome;
|
|
|
556
556
|
* - **Handling Circular Dependencies**: Useful in managing circular dependencies, such as recursive functions that need to avoid eager evaluation to prevent stack overflow.
|
|
557
557
|
* - **Unifying Return Types**: Can help TypeScript unify return types in situations where multiple branches of logic return different effects, simplifying type inference.
|
|
558
558
|
*
|
|
559
|
-
* **Example** (
|
|
559
|
+
* **Example** (Lazily evaluating side effects)
|
|
560
560
|
*
|
|
561
561
|
* ```ts
|
|
562
562
|
* import { Effect } from "effect"
|
|
@@ -574,7 +574,7 @@ export const succeedSome = internal.succeedSome;
|
|
|
574
574
|
* console.log(Effect.runSync(good)) // Output: 2
|
|
575
575
|
* ```
|
|
576
576
|
*
|
|
577
|
-
* **Example** (
|
|
577
|
+
* **Example** (Suspending recursive Fibonacci evaluation)
|
|
578
578
|
*
|
|
579
579
|
* ```ts
|
|
580
580
|
* import { Effect } from "effect"
|
|
@@ -600,7 +600,7 @@ export const succeedSome = internal.succeedSome;
|
|
|
600
600
|
* // Output: 3524578
|
|
601
601
|
* ```
|
|
602
602
|
*
|
|
603
|
-
* **Example** (
|
|
603
|
+
* **Example** (Helping TypeScript infer recursive effect types)
|
|
604
604
|
*
|
|
605
605
|
* ```ts
|
|
606
606
|
* import { Effect } from "effect"
|
|
@@ -648,7 +648,7 @@ export const suspend = internal.suspend;
|
|
|
648
648
|
*
|
|
649
649
|
* @see {@link try_ | try} for a version that can handle failures.
|
|
650
650
|
*
|
|
651
|
-
* **Example** (
|
|
651
|
+
* **Example** (Capturing synchronous logging in an Effect)
|
|
652
652
|
*
|
|
653
653
|
* ```ts
|
|
654
654
|
* import { Effect } from "effect"
|
|
@@ -696,7 +696,7 @@ undefined_ as undefined };
|
|
|
696
696
|
* Use `Effect.callback` when integrating APIs that complete through callbacks
|
|
697
697
|
* instead of returning a `Promise`.
|
|
698
698
|
*
|
|
699
|
-
* **Example** (
|
|
699
|
+
* **Example** (Integrating callback APIs)
|
|
700
700
|
*
|
|
701
701
|
* ```ts
|
|
702
702
|
* import { Effect } from "effect"
|
|
@@ -721,7 +721,7 @@ export const callback = internal.callback;
|
|
|
721
721
|
* Returns an effect that will never produce anything. The moral equivalent of
|
|
722
722
|
* `while(true) {}`, only without the wasted CPU cycles.
|
|
723
723
|
*
|
|
724
|
-
* **Example** (
|
|
724
|
+
* **Example** (Creating a never-ending effect)
|
|
725
725
|
*
|
|
726
726
|
* ```ts
|
|
727
727
|
* import { Effect } from "effect"
|
|
@@ -744,7 +744,7 @@ export const never = internal.never;
|
|
|
744
744
|
* An `Effect` containing an empty record `{}`, used as the starting point for
|
|
745
745
|
* do notation chains.
|
|
746
746
|
*
|
|
747
|
-
* **Example** (
|
|
747
|
+
* **Example** (Starting do notation)
|
|
748
748
|
*
|
|
749
749
|
* ```ts
|
|
750
750
|
* import { Effect, pipe } from "effect"
|
|
@@ -800,7 +800,7 @@ export const bind = internal.bind;
|
|
|
800
800
|
* explicit control over the execution of effects. You can `yield*` values from
|
|
801
801
|
* effects and return the final result at the end.
|
|
802
802
|
*
|
|
803
|
-
* **Example** (
|
|
803
|
+
* **Example** (Sequencing effects with generators)
|
|
804
804
|
*
|
|
805
805
|
* ```ts
|
|
806
806
|
* import { Data, Effect } from "effect"
|
|
@@ -848,7 +848,7 @@ export const gen = internal.gen;
|
|
|
848
848
|
*
|
|
849
849
|
* @see {@link succeed} to create an effect that represents a successful value.
|
|
850
850
|
*
|
|
851
|
-
* **Example** (Creating a
|
|
851
|
+
* **Example** (Creating a failed effect)
|
|
852
852
|
*
|
|
853
853
|
* ```ts
|
|
854
854
|
* import { Data, Effect } from "effect"
|
|
@@ -872,7 +872,7 @@ export const fail = internal.fail;
|
|
|
872
872
|
* This function is useful when you need to create an error effect but want to
|
|
873
873
|
* defer the computation of the error value until the effect is actually run.
|
|
874
874
|
*
|
|
875
|
-
* **Example** (
|
|
875
|
+
* **Example** (Lazily creating failures)
|
|
876
876
|
*
|
|
877
877
|
* ```ts
|
|
878
878
|
* import { Data, Effect } from "effect"
|
|
@@ -895,7 +895,7 @@ export const failSync = internal.failSync;
|
|
|
895
895
|
* This function allows you to create effects that fail with complex error
|
|
896
896
|
* structures, including multiple errors, defects, interruptions, and more.
|
|
897
897
|
*
|
|
898
|
-
* **Example** (
|
|
898
|
+
* **Example** (Failing with a full Cause)
|
|
899
899
|
*
|
|
900
900
|
* ```ts
|
|
901
901
|
* import { Cause, Effect } from "effect"
|
|
@@ -918,7 +918,7 @@ export const failCause = internal.failCause;
|
|
|
918
918
|
* This function is useful when you need to create a failure effect with a
|
|
919
919
|
* complex cause but want to defer the computation until the effect is run.
|
|
920
920
|
*
|
|
921
|
-
* **Example** (
|
|
921
|
+
* **Example** (Lazily creating a Cause)
|
|
922
922
|
*
|
|
923
923
|
* ```ts
|
|
924
924
|
* import { Cause, Effect } from "effect"
|
|
@@ -954,7 +954,7 @@ export const failCauseSync = internal.failCauseSync;
|
|
|
954
954
|
*
|
|
955
955
|
* @see {@link die} for a variant that dies with an already computed defect.
|
|
956
956
|
*
|
|
957
|
-
* **Example** (
|
|
957
|
+
* **Example** (Failing when division by zero)
|
|
958
958
|
*
|
|
959
959
|
* ```ts
|
|
960
960
|
* import { Effect } from "effect"
|
|
@@ -1003,7 +1003,7 @@ export {
|
|
|
1003
1003
|
* @see {@link sync} if the effectful computation is synchronous and does not
|
|
1004
1004
|
* throw errors.
|
|
1005
1005
|
*
|
|
1006
|
-
* **Example** (
|
|
1006
|
+
* **Example** (Parsing JSON with typed error mapping)
|
|
1007
1007
|
*
|
|
1008
1008
|
* ```ts
|
|
1009
1009
|
* import { Effect } from "effect"
|
|
@@ -1023,7 +1023,7 @@ export {
|
|
|
1023
1023
|
* // Output: Exit.failure with Error
|
|
1024
1024
|
* ```
|
|
1025
1025
|
*
|
|
1026
|
-
* **Example** (
|
|
1026
|
+
* **Example** (Mapping synchronous exceptions to a tagged error)
|
|
1027
1027
|
*
|
|
1028
1028
|
* ```ts
|
|
1029
1029
|
* import { Data, Effect } from "effect"
|
|
@@ -1047,7 +1047,7 @@ try_ as try };
|
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Yields control back to the Effect runtime, allowing other fibers to execute.
|
|
1049
1049
|
*
|
|
1050
|
-
* **Example** (
|
|
1050
|
+
* **Example** (Yielding to other fibers)
|
|
1051
1051
|
*
|
|
1052
1052
|
* ```ts
|
|
1053
1053
|
* import { Effect } from "effect"
|
|
@@ -1068,7 +1068,7 @@ export const yieldNow = internal.yieldNow;
|
|
|
1068
1068
|
/**
|
|
1069
1069
|
* Yields control back to the Effect runtime with a specified priority, allowing other fibers to execute.
|
|
1070
1070
|
*
|
|
1071
|
-
* **Example** (
|
|
1071
|
+
* **Example** (Yielding with priority)
|
|
1072
1072
|
*
|
|
1073
1073
|
* ```ts
|
|
1074
1074
|
* import { Effect } from "effect"
|
|
@@ -1089,7 +1089,7 @@ export const yieldNowWith = internal.yieldNowWith;
|
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Provides access to the current fiber within an effect computation.
|
|
1091
1091
|
*
|
|
1092
|
-
* **Example** (
|
|
1092
|
+
* **Example** (Reading the current fiber)
|
|
1093
1093
|
*
|
|
1094
1094
|
* ```ts
|
|
1095
1095
|
* import { Effect } from "effect"
|
|
@@ -1112,7 +1112,7 @@ export const withFiber = core.withFiber;
|
|
|
1112
1112
|
/**
|
|
1113
1113
|
* Converts a `Result` to an `Effect`.
|
|
1114
1114
|
*
|
|
1115
|
-
* **Example** (
|
|
1115
|
+
* **Example** (Converting a Result into an Effect)
|
|
1116
1116
|
*
|
|
1117
1117
|
* ```ts
|
|
1118
1118
|
* import { Effect, Result } from "effect"
|
|
@@ -1138,7 +1138,7 @@ export const fromResult = internal.fromResult;
|
|
|
1138
1138
|
* `Option.some` becomes a successful effect with the contained value, while
|
|
1139
1139
|
* `Option.none` becomes a failed effect with `NoSuchElementError`.
|
|
1140
1140
|
*
|
|
1141
|
-
* **Example** (
|
|
1141
|
+
* **Example** (Converting an Option into an Effect)
|
|
1142
1142
|
*
|
|
1143
1143
|
* ```ts
|
|
1144
1144
|
* import { Effect, Option } from "effect"
|
|
@@ -1162,7 +1162,7 @@ export const fromOption = internal.fromOption;
|
|
|
1162
1162
|
* Converts a nullable value to an `Effect`, failing with a `NoSuchElementError`
|
|
1163
1163
|
* when the value is `null` or `undefined`.
|
|
1164
1164
|
*
|
|
1165
|
-
* **Example** (
|
|
1165
|
+
* **Example** (Failing on nullish values)
|
|
1166
1166
|
*
|
|
1167
1167
|
* ```ts
|
|
1168
1168
|
* import { Console, Effect } from "effect"
|
|
@@ -1217,7 +1217,7 @@ export const fromNullishOr = internal.fromNullishOr;
|
|
|
1217
1217
|
* step produces a new `Effect` while flattening any nested effects that may
|
|
1218
1218
|
* occur.
|
|
1219
1219
|
*
|
|
1220
|
-
* **Example** (
|
|
1220
|
+
* **Example** (Sequencing dependent effects)
|
|
1221
1221
|
*
|
|
1222
1222
|
* ```ts
|
|
1223
1223
|
* import { Data, Effect, pipe } from "effect"
|
|
@@ -1255,7 +1255,7 @@ export const flatMap = internal.flatMap;
|
|
|
1255
1255
|
/**
|
|
1256
1256
|
* Flattens an `Effect` that produces another `Effect` into a single effect.
|
|
1257
1257
|
*
|
|
1258
|
-
* **Example** (
|
|
1258
|
+
* **Example** (Flattening nested effects)
|
|
1259
1259
|
*
|
|
1260
1260
|
* ```ts
|
|
1261
1261
|
* import { Console, Effect } from "effect"
|
|
@@ -1302,7 +1302,7 @@ export const flatten = internal.flatten;
|
|
|
1302
1302
|
* Failures or requirements from either effect are preserved in the returned
|
|
1303
1303
|
* effect.
|
|
1304
1304
|
*
|
|
1305
|
-
* **Example** (
|
|
1305
|
+
* **Example** (Sequencing a discount calculation after fetching a total)
|
|
1306
1306
|
*
|
|
1307
1307
|
* ```ts
|
|
1308
1308
|
* import { Data, Effect, pipe } from "effect"
|
|
@@ -1423,7 +1423,7 @@ export const tap = internal.tap;
|
|
|
1423
1423
|
* The resulting effect cannot fail directly because all recoverable failures
|
|
1424
1424
|
* are represented inside the `Result` type.
|
|
1425
1425
|
*
|
|
1426
|
-
* **Example** (
|
|
1426
|
+
* **Example** (Capturing success or failure as Result)
|
|
1427
1427
|
*
|
|
1428
1428
|
* ```ts
|
|
1429
1429
|
* import { Effect } from "effect"
|
|
@@ -1456,7 +1456,7 @@ export const result = internal.result;
|
|
|
1456
1456
|
* Success values become `Option.some`, recoverable failures become
|
|
1457
1457
|
* `Option.none`, and defects still fail the effect.
|
|
1458
1458
|
*
|
|
1459
|
-
* **Example** (
|
|
1459
|
+
* **Example** (Capturing success or failure as Option)
|
|
1460
1460
|
*
|
|
1461
1461
|
* ```ts
|
|
1462
1462
|
* import { Console, Effect, Option } from "effect"
|
|
@@ -1494,7 +1494,7 @@ export const option = internal.option;
|
|
|
1494
1494
|
* the `Exit.Failure` type. The error type is set to `never`, indicating that
|
|
1495
1495
|
* the effect is structured to never fail directly.
|
|
1496
1496
|
*
|
|
1497
|
-
* **Example** (
|
|
1497
|
+
* **Example** (Capturing completion as Exit)
|
|
1498
1498
|
*
|
|
1499
1499
|
* ```ts
|
|
1500
1500
|
* import { Effect } from "effect"
|
|
@@ -1541,7 +1541,7 @@ export const exit = internal.exit;
|
|
|
1541
1541
|
* effect is not modified. Instead, a new effect is returned with the updated
|
|
1542
1542
|
* value.
|
|
1543
1543
|
*
|
|
1544
|
-
* **Example** (Adding a
|
|
1544
|
+
* **Example** (Adding a service charge)
|
|
1545
1545
|
*
|
|
1546
1546
|
* ```ts
|
|
1547
1547
|
* import { Effect, pipe } from "effect"
|
|
@@ -1573,7 +1573,7 @@ export const map = internal.map;
|
|
|
1573
1573
|
* `as` allows you to ignore the original value inside an effect and
|
|
1574
1574
|
* replace it with a new constant value.
|
|
1575
1575
|
*
|
|
1576
|
-
* **Example** (Replacing a
|
|
1576
|
+
* **Example** (Replacing a success value)
|
|
1577
1577
|
*
|
|
1578
1578
|
* ```ts
|
|
1579
1579
|
* import { Effect, pipe } from "effect"
|
|
@@ -1594,7 +1594,7 @@ export const as = internal.as;
|
|
|
1594
1594
|
* in an `Option` value. If the original `Effect` value fails, the returned
|
|
1595
1595
|
* `Effect` value will also fail.
|
|
1596
1596
|
*
|
|
1597
|
-
* **Example** (
|
|
1597
|
+
* **Example** (Wrapping success in Option.some)
|
|
1598
1598
|
*
|
|
1599
1599
|
* ```ts
|
|
1600
1600
|
* import { Effect } from "effect"
|
|
@@ -1615,7 +1615,7 @@ export const asSome = internal.asSome;
|
|
|
1615
1615
|
* succeed. If the original `Effect` value fails, the returned `Effect` value
|
|
1616
1616
|
* will fail with the same error.
|
|
1617
1617
|
*
|
|
1618
|
-
* **Example** (
|
|
1618
|
+
* **Example** (Discarding success values)
|
|
1619
1619
|
*
|
|
1620
1620
|
* ```ts
|
|
1621
1621
|
* import { Effect } from "effect"
|
|
@@ -1639,7 +1639,7 @@ export const asVoid = internal.asVoid;
|
|
|
1639
1639
|
* be helpful in scenarios where you want to handle a success as a failure or
|
|
1640
1640
|
* treat an error as a valid result.
|
|
1641
1641
|
*
|
|
1642
|
-
* **Example** (
|
|
1642
|
+
* **Example** (Swapping success and failure channels)
|
|
1643
1643
|
*
|
|
1644
1644
|
* ```ts
|
|
1645
1645
|
* import { Effect } from "effect"
|
|
@@ -1674,7 +1674,7 @@ export const flip = internal.flip;
|
|
|
1674
1674
|
* @see {@link zipWith} for a version that combines the results with a custom function.
|
|
1675
1675
|
* @see {@link validate} for a version that accumulates errors.
|
|
1676
1676
|
*
|
|
1677
|
-
* **Example** (Combining
|
|
1677
|
+
* **Example** (Combining two effects sequentially)
|
|
1678
1678
|
*
|
|
1679
1679
|
* ```ts
|
|
1680
1680
|
* import { Effect } from "effect"
|
|
@@ -1701,7 +1701,7 @@ export const flip = internal.flip;
|
|
|
1701
1701
|
* // [ 1, 'hello' ]
|
|
1702
1702
|
* ```
|
|
1703
1703
|
*
|
|
1704
|
-
* **Example** (Combining
|
|
1704
|
+
* **Example** (Combining two effects concurrently)
|
|
1705
1705
|
*
|
|
1706
1706
|
* ```ts
|
|
1707
1707
|
* import { Effect } from "effect"
|
|
@@ -1744,7 +1744,7 @@ export const zip = internal.zip;
|
|
|
1744
1744
|
* By default, the effects are run sequentially. To execute them concurrently,
|
|
1745
1745
|
* use the `{ concurrent: true }` option.
|
|
1746
1746
|
*
|
|
1747
|
-
* **Example** (Combining
|
|
1747
|
+
* **Example** (Combining two success values with a function)
|
|
1748
1748
|
*
|
|
1749
1749
|
* ```ts
|
|
1750
1750
|
* import { Effect } from "effect"
|
|
@@ -1814,7 +1814,7 @@ catch_ as catch };
|
|
|
1814
1814
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
1815
1815
|
* field is used to identify and match errors.
|
|
1816
1816
|
*
|
|
1817
|
-
* **Example** (
|
|
1817
|
+
* **Example** (Handling a tagged error)
|
|
1818
1818
|
*
|
|
1819
1819
|
* ```ts
|
|
1820
1820
|
* import { Effect } from "effect"
|
|
@@ -1857,7 +1857,7 @@ export const catchTag = internal.catchTag;
|
|
|
1857
1857
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
1858
1858
|
* field is used to identify and match errors.
|
|
1859
1859
|
*
|
|
1860
|
-
* **Example** (
|
|
1860
|
+
* **Example** (Handling multiple tagged errors)
|
|
1861
1861
|
*
|
|
1862
1862
|
* ```ts
|
|
1863
1863
|
* import { Data, Effect } from "effect"
|
|
@@ -1892,7 +1892,7 @@ export const catchTags = internal.catchTags;
|
|
|
1892
1892
|
* Use this to handle nested error causes without removing the parent error
|
|
1893
1893
|
* from the error channel. The handler receives the unwrapped reason.
|
|
1894
1894
|
*
|
|
1895
|
-
* **Example** (
|
|
1895
|
+
* **Example** (Handling an error reason)
|
|
1896
1896
|
*
|
|
1897
1897
|
* ```ts
|
|
1898
1898
|
* import { Data, Effect } from "effect"
|
|
@@ -1926,7 +1926,7 @@ export const catchReason = internal.catchReason;
|
|
|
1926
1926
|
/**
|
|
1927
1927
|
* Catches multiple reasons within a tagged error using an object of handlers.
|
|
1928
1928
|
*
|
|
1929
|
-
* **Example** (
|
|
1929
|
+
* **Example** (Handling multiple error reasons)
|
|
1930
1930
|
*
|
|
1931
1931
|
* ```ts
|
|
1932
1932
|
* import { Data, Effect } from "effect"
|
|
@@ -1963,7 +1963,7 @@ export const catchReasons = internal.catchReasons;
|
|
|
1963
1963
|
* Promotes nested reason errors into the Effect error channel, replacing
|
|
1964
1964
|
* the parent error.
|
|
1965
1965
|
*
|
|
1966
|
-
* **Example** (
|
|
1966
|
+
* **Example** (Extracting the reason from a tagged error)
|
|
1967
1967
|
*
|
|
1968
1968
|
* ```ts
|
|
1969
1969
|
* import { Data, Effect } from "effect"
|
|
@@ -2008,7 +2008,7 @@ export const unwrapReason = internal.unwrapReason;
|
|
|
2008
2008
|
* they often indicate serious issues. However, in some cases, such as
|
|
2009
2009
|
* dynamically loaded plugins, controlled recovery might be needed.
|
|
2010
2010
|
*
|
|
2011
|
-
* **Example** (
|
|
2011
|
+
* **Example** (Recovering from full failure causes)
|
|
2012
2012
|
*
|
|
2013
2013
|
* ```ts
|
|
2014
2014
|
* import { Cause, Console, Effect } from "effect"
|
|
@@ -2050,7 +2050,7 @@ export const catchCause = internal.catchCause;
|
|
|
2050
2050
|
* they often indicate serious issues. In some cases, such as dynamically loaded
|
|
2051
2051
|
* plugins, controlled recovery may be needed.
|
|
2052
2052
|
*
|
|
2053
|
-
* **Example** (
|
|
2053
|
+
* **Example** (Recovering from defects)
|
|
2054
2054
|
*
|
|
2055
2055
|
* ```ts
|
|
2056
2056
|
* import { Console, Effect } from "effect"
|
|
@@ -2082,7 +2082,7 @@ export const catchDefect = internal.catchDefect;
|
|
|
2082
2082
|
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
2083
2083
|
* interrupts are not caught.
|
|
2084
2084
|
*
|
|
2085
|
-
* **Example** (
|
|
2085
|
+
* **Example** (Recovering when a predicate matches)
|
|
2086
2086
|
*
|
|
2087
2087
|
* ```ts
|
|
2088
2088
|
* import { Data, Effect, Filter } from "effect"
|
|
@@ -2125,7 +2125,7 @@ export const catchFilter = internal.catchFilter;
|
|
|
2125
2125
|
* Success values become `Option.some`, `NoSuchElementError` becomes
|
|
2126
2126
|
* `Option.none`, and all other errors are preserved.
|
|
2127
2127
|
*
|
|
2128
|
-
* **Example** (
|
|
2128
|
+
* **Example** (Recovering from missing Option values)
|
|
2129
2129
|
*
|
|
2130
2130
|
* ```ts
|
|
2131
2131
|
* import { Effect, Option } from "effect"
|
|
@@ -2148,7 +2148,7 @@ export const catchNoSuchElement = internal.catchNoSuchElement;
|
|
|
2148
2148
|
* that match a specific predicate. This is useful when you want to handle
|
|
2149
2149
|
* only certain types of errors while letting others propagate.
|
|
2150
2150
|
*
|
|
2151
|
-
* **Example** (
|
|
2151
|
+
* **Example** (Recovering from selected causes)
|
|
2152
2152
|
*
|
|
2153
2153
|
* ```ts
|
|
2154
2154
|
* import { Cause, Console, Effect } from "effect"
|
|
@@ -2195,7 +2195,7 @@ export const catchCauseFilter = internal.catchCauseFilter;
|
|
|
2195
2195
|
* @see {@link mapBoth} for a version that operates on both channels.
|
|
2196
2196
|
* @see {@link mapError} if you want to replace the error with a new one.
|
|
2197
2197
|
*
|
|
2198
|
-
* **Example** (
|
|
2198
|
+
* **Example** (Transforming the error channel)
|
|
2199
2199
|
*
|
|
2200
2200
|
* ```ts
|
|
2201
2201
|
* import { Data, Effect } from "effect"
|
|
@@ -2228,7 +2228,7 @@ export const mapError = internal.mapError;
|
|
|
2228
2228
|
* the error and the success values without altering the overall success or
|
|
2229
2229
|
* failure status of the effect.
|
|
2230
2230
|
*
|
|
2231
|
-
* **Example** (
|
|
2231
|
+
* **Example** (Transforming success and failure channels)
|
|
2232
2232
|
*
|
|
2233
2233
|
* ```ts
|
|
2234
2234
|
* import { Data, Effect } from "effect"
|
|
@@ -2265,7 +2265,7 @@ export const mapBoth = internal.mapBoth;
|
|
|
2265
2265
|
*
|
|
2266
2266
|
* @see {@link mapError} to transform the error before converting it into a defect with {@link orDie}.
|
|
2267
2267
|
*
|
|
2268
|
-
* **Example** (
|
|
2268
|
+
* **Example** (Converting typed failures into defects)
|
|
2269
2269
|
*
|
|
2270
2270
|
* ```ts
|
|
2271
2271
|
* import { Data, Effect } from "effect"
|
|
@@ -2301,7 +2301,7 @@ export const orDie = internal.orDie;
|
|
|
2301
2301
|
* operation passed to `tapError` fails, that error is also represented in the
|
|
2302
2302
|
* returned effect's error channel.
|
|
2303
2303
|
*
|
|
2304
|
-
* **Example** (
|
|
2304
|
+
* **Example** (Running effects on failure)
|
|
2305
2305
|
*
|
|
2306
2306
|
* ```ts
|
|
2307
2307
|
* import { Console, Effect } from "effect"
|
|
@@ -2331,7 +2331,7 @@ export const tapError = internal.tapError;
|
|
|
2331
2331
|
* list of tags. When the handler succeeds, the original failure is preserved;
|
|
2332
2332
|
* if the handler fails, its error is also included in the returned effect.
|
|
2333
2333
|
*
|
|
2334
|
-
* **Example** (
|
|
2334
|
+
* **Example** (Running effects for tagged failures)
|
|
2335
2335
|
*
|
|
2336
2336
|
* ```ts
|
|
2337
2337
|
* import { Console, Data, Effect } from "effect"
|
|
@@ -2370,7 +2370,7 @@ export const tapErrorTag = internal.tapErrorTag;
|
|
|
2370
2370
|
* the operation succeeds, the original cause is preserved. If the operation
|
|
2371
2371
|
* fails, its error is also represented in the returned effect.
|
|
2372
2372
|
*
|
|
2373
|
-
* **Example** (
|
|
2373
|
+
* **Example** (Observing full failure causes)
|
|
2374
2374
|
*
|
|
2375
2375
|
* ```ts
|
|
2376
2376
|
* import { Cause, Console, Effect } from "effect"
|
|
@@ -2398,7 +2398,7 @@ export const tapCause = internal.tapCause;
|
|
|
2398
2398
|
* the cause matches a specific predicate. This is useful for conditional logging,
|
|
2399
2399
|
* monitoring, or other side effects based on the type of failure.
|
|
2400
2400
|
*
|
|
2401
|
-
* **Example** (
|
|
2401
|
+
* **Example** (Observing selected failure causes)
|
|
2402
2402
|
*
|
|
2403
2403
|
* ```ts
|
|
2404
2404
|
* import { Cause, Console, Effect } from "effect"
|
|
@@ -2438,7 +2438,7 @@ export const tapCauseFilter = internal.tapCauseFilter;
|
|
|
2438
2438
|
* operation succeeds, the original defect is preserved; if the operation fails,
|
|
2439
2439
|
* its error is also represented in the returned effect.
|
|
2440
2440
|
*
|
|
2441
|
-
* **Example** (
|
|
2441
|
+
* **Example** (Observing defects)
|
|
2442
2442
|
*
|
|
2443
2443
|
* ```ts
|
|
2444
2444
|
* import { Console, Effect } from "effect"
|
|
@@ -2481,7 +2481,7 @@ export const tapDefect = internal.tapDefect;
|
|
|
2481
2481
|
*
|
|
2482
2482
|
* Yields between attempts so other fibers can run.
|
|
2483
2483
|
*
|
|
2484
|
-
* **Example** (
|
|
2484
|
+
* **Example** (Retrying until success)
|
|
2485
2485
|
*
|
|
2486
2486
|
* ```ts
|
|
2487
2487
|
* import { Console, Effect } from "effect"
|
|
@@ -2528,7 +2528,7 @@ export const eventually = internal.eventually;
|
|
|
2528
2528
|
* Use `retry` when typed failures may be transient, such as network issues or
|
|
2529
2529
|
* temporary resource unavailability.
|
|
2530
2530
|
*
|
|
2531
|
-
* **Example** (
|
|
2531
|
+
* **Example** (Retrying with a schedule)
|
|
2532
2532
|
*
|
|
2533
2533
|
* ```ts
|
|
2534
2534
|
* import { Data, Effect, Schedule } from "effect"
|
|
@@ -2577,7 +2577,7 @@ export const retry = internalSchedule.retry;
|
|
|
2577
2577
|
*
|
|
2578
2578
|
* @see {@link retry} for a version that does not run a fallback effect.
|
|
2579
2579
|
*
|
|
2580
|
-
* **Example** (
|
|
2580
|
+
* **Example** (Falling back after retries are exhausted)
|
|
2581
2581
|
*
|
|
2582
2582
|
* ```ts
|
|
2583
2583
|
* import { Console, Data, Effect, Schedule } from "effect"
|
|
@@ -2626,7 +2626,7 @@ export const retryOrElse = internalSchedule.retryOrElse;
|
|
|
2626
2626
|
* failures, defects, and interruptions. Use `unsandbox` to restore the original
|
|
2627
2627
|
* typed error channel after cause-level handling.
|
|
2628
2628
|
*
|
|
2629
|
-
* **Example** (
|
|
2629
|
+
* **Example** (Exposing failures as causes)
|
|
2630
2630
|
*
|
|
2631
2631
|
* ```ts
|
|
2632
2632
|
* import { Cause, Effect } from "effect"
|
|
@@ -2661,7 +2661,7 @@ export const sandbox = internal.sandbox;
|
|
|
2661
2661
|
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
2662
2662
|
* and `message` to prepend a custom log message.
|
|
2663
2663
|
*
|
|
2664
|
-
* **Example** (
|
|
2664
|
+
* **Example** (Discarding success and failure values)
|
|
2665
2665
|
*
|
|
2666
2666
|
* ```ts
|
|
2667
2667
|
* import { Effect } from "effect"
|
|
@@ -2696,7 +2696,7 @@ export const ignore = internal.ignore;
|
|
|
2696
2696
|
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
2697
2697
|
* and `message` to prepend a custom log message.
|
|
2698
2698
|
*
|
|
2699
|
-
* **Example** (
|
|
2699
|
+
* **Example** (Ignoring failures and logging causes)
|
|
2700
2700
|
*
|
|
2701
2701
|
* ```ts
|
|
2702
2702
|
* import { Effect } from "effect"
|
|
@@ -2719,7 +2719,7 @@ export const ignoreCause = internal.ignoreCause;
|
|
|
2719
2719
|
* and retry timing is derived per step (the first attempt uses the remaining
|
|
2720
2720
|
* attempts schedule; later retries apply the step schedule at least once).
|
|
2721
2721
|
*
|
|
2722
|
-
* **Example** (
|
|
2722
|
+
* **Example** (Retrying with an execution plan)
|
|
2723
2723
|
*
|
|
2724
2724
|
* ```ts
|
|
2725
2725
|
* import { Context, Effect, ExecutionPlan, Layer } from "effect"
|
|
@@ -2770,7 +2770,7 @@ export const withErrorReporting = internal.withErrorReporting;
|
|
|
2770
2770
|
*
|
|
2771
2771
|
* Defects and interruptions are not recovered by this operator.
|
|
2772
2772
|
*
|
|
2773
|
-
* **Example** (
|
|
2773
|
+
* **Example** (Replacing failures with a value)
|
|
2774
2774
|
*
|
|
2775
2775
|
* ```ts
|
|
2776
2776
|
* import { Effect } from "effect"
|
|
@@ -2816,7 +2816,7 @@ export const orElseSucceed = internal.orElseSucceed;
|
|
|
2816
2816
|
* attempting multiple APIs, reading configuration from several sources, or
|
|
2817
2817
|
* trying alternative resource locations in order.
|
|
2818
2818
|
*
|
|
2819
|
-
* **Example** (
|
|
2819
|
+
* **Example** (Trying alternatives until one succeeds)
|
|
2820
2820
|
*
|
|
2821
2821
|
* ```ts
|
|
2822
2822
|
* import { Effect } from "effect"
|
|
@@ -2856,7 +2856,7 @@ export const firstSuccessOf = internal.firstSuccessOf;
|
|
|
2856
2856
|
*
|
|
2857
2857
|
* @see {@link timeoutOrElse} for a version that allows specifying both success and timeout handlers.
|
|
2858
2858
|
*
|
|
2859
|
-
* **Example** (
|
|
2859
|
+
* **Example** (Failing when work takes too long)
|
|
2860
2860
|
*
|
|
2861
2861
|
* ```ts
|
|
2862
2862
|
* import { Effect } from "effect"
|
|
@@ -2904,7 +2904,7 @@ export const timeout = internal.timeout;
|
|
|
2904
2904
|
* @see {@link timeout} for a version that raises a `TimeoutException`.
|
|
2905
2905
|
* @see {@link timeoutOrElse} for a version that allows specifying both success and timeout handlers.
|
|
2906
2906
|
*
|
|
2907
|
-
* **Example** (
|
|
2907
|
+
* **Example** (Returning None on timeout)
|
|
2908
2908
|
*
|
|
2909
2909
|
* ```ts
|
|
2910
2910
|
* import { Effect } from "effect"
|
|
@@ -2942,7 +2942,7 @@ export const timeoutOption = internal.timeoutOption;
|
|
|
2942
2942
|
* This function is useful when you want to set a maximum duration for an operation
|
|
2943
2943
|
* and provide an alternative action if the timeout is exceeded.
|
|
2944
2944
|
*
|
|
2945
|
-
* **Example** (
|
|
2945
|
+
* **Example** (Falling back on timeout)
|
|
2946
2946
|
*
|
|
2947
2947
|
* ```ts
|
|
2948
2948
|
* import { Console, Effect } from "effect"
|
|
@@ -2978,7 +2978,7 @@ export const timeoutOrElse = internal.timeoutOrElse;
|
|
|
2978
2978
|
* Returns an effect that is delayed from this effect by the specified
|
|
2979
2979
|
* `Duration`.
|
|
2980
2980
|
*
|
|
2981
|
-
* **Example** (
|
|
2981
|
+
* **Example** (Delaying an effect)
|
|
2982
2982
|
*
|
|
2983
2983
|
* ```ts
|
|
2984
2984
|
* import { Console, Effect } from "effect"
|
|
@@ -3000,7 +3000,7 @@ export const delay = internal.delay;
|
|
|
3000
3000
|
* Returns an effect that suspends the current fiber for the specified duration
|
|
3001
3001
|
* without blocking a JavaScript thread.
|
|
3002
3002
|
*
|
|
3003
|
-
* **Example** (
|
|
3003
|
+
* **Example** (Pausing without blocking)
|
|
3004
3004
|
*
|
|
3005
3005
|
* ```ts
|
|
3006
3006
|
* import { Console, Effect } from "effect"
|
|
@@ -3026,7 +3026,7 @@ export const sleep = internal.sleep;
|
|
|
3026
3026
|
* The original success, failure, or interruption is preserved; only the success
|
|
3027
3027
|
* value is paired with the duration.
|
|
3028
3028
|
*
|
|
3029
|
-
* **Example** (
|
|
3029
|
+
* **Example** (Measuring execution time)
|
|
3030
3030
|
*
|
|
3031
3031
|
* ```ts
|
|
3032
3032
|
* import { Console, Duration, Effect } from "effect"
|
|
@@ -3061,7 +3061,7 @@ export const timed = internal.timed;
|
|
|
3061
3061
|
*
|
|
3062
3062
|
* @see {@link race} for a version that handles only two effects.
|
|
3063
3063
|
*
|
|
3064
|
-
* **Example** (
|
|
3064
|
+
* **Example** (Racing many effects)
|
|
3065
3065
|
*
|
|
3066
3066
|
* ```ts
|
|
3067
3067
|
* import { Duration, Effect } from "effect"
|
|
@@ -3091,7 +3091,7 @@ export const raceAll = internal.raceAll;
|
|
|
3091
3091
|
* `raceAll` when early failures should be ignored until a success occurs or
|
|
3092
3092
|
* all effects fail.
|
|
3093
3093
|
*
|
|
3094
|
-
* **Example** (
|
|
3094
|
+
* **Example** (Taking the first settled result)
|
|
3095
3095
|
*
|
|
3096
3096
|
* ```ts
|
|
3097
3097
|
* import { Duration, Effect } from "effect"
|
|
@@ -3117,7 +3117,7 @@ export const raceAllFirst = internal.raceAllFirst;
|
|
|
3117
3117
|
* If one effect succeeds, the other is interrupted and `onWinner` can observe the
|
|
3118
3118
|
* winning fiber. If both fail, the race fails.
|
|
3119
3119
|
*
|
|
3120
|
-
* **Example** (
|
|
3120
|
+
* **Example** (Racing two effects)
|
|
3121
3121
|
*
|
|
3122
3122
|
* ```ts
|
|
3123
3123
|
* import { Console, Duration, Effect } from "effect"
|
|
@@ -3144,7 +3144,7 @@ export const race = internal.race;
|
|
|
3144
3144
|
*
|
|
3145
3145
|
* The losing effect is interrupted, and `onWinner` can observe the winning fiber.
|
|
3146
3146
|
*
|
|
3147
|
-
* **Example** (
|
|
3147
|
+
* **Example** (Observing the winning fiber)
|
|
3148
3148
|
*
|
|
3149
3149
|
* ```ts
|
|
3150
3150
|
* import { Console, Duration, Effect } from "effect"
|
|
@@ -3175,7 +3175,7 @@ export const raceFirst = internal.raceFirst;
|
|
|
3175
3175
|
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
3176
3176
|
* predicate.
|
|
3177
3177
|
*
|
|
3178
|
-
* **Example** (
|
|
3178
|
+
* **Example** (Filtering success values)
|
|
3179
3179
|
*
|
|
3180
3180
|
* ```ts
|
|
3181
3181
|
* import { Effect } from "effect"
|
|
@@ -3217,7 +3217,7 @@ export const filterMapEffect = internal.filterMapEffect;
|
|
|
3217
3217
|
* `orElse` effect can produce an alternative value or perform additional
|
|
3218
3218
|
* computations.
|
|
3219
3219
|
*
|
|
3220
|
-
* **Example** (
|
|
3220
|
+
* **Example** (Filtering with a fallback effect)
|
|
3221
3221
|
*
|
|
3222
3222
|
* ```ts
|
|
3223
3223
|
* import { Effect } from "effect"
|
|
@@ -3255,7 +3255,7 @@ export const filterMapOrElse = internal.filterMapOrElse;
|
|
|
3255
3255
|
* predicate evaluates to `false`, the effect fails with either a custom
|
|
3256
3256
|
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
3257
3257
|
*
|
|
3258
|
-
* **Example** (
|
|
3258
|
+
* **Example** (Filtering with a custom failure)
|
|
3259
3259
|
*
|
|
3260
3260
|
* ```ts
|
|
3261
3261
|
* import { Effect } from "effect"
|
|
@@ -3303,7 +3303,7 @@ export const filterMapOrFail = internal.filterMapOrFail;
|
|
|
3303
3303
|
* Use this when an effectful check decides whether to run another effect while
|
|
3304
3304
|
* representing the skipped case explicitly.
|
|
3305
3305
|
*
|
|
3306
|
-
* **Example** (
|
|
3306
|
+
* **Example** (Conditionally running an effect)
|
|
3307
3307
|
*
|
|
3308
3308
|
* ```ts
|
|
3309
3309
|
* import { Console, Effect } from "effect"
|
|
@@ -3347,7 +3347,7 @@ export const when = internal.when;
|
|
|
3347
3347
|
*
|
|
3348
3348
|
* @see {@link matchEffect} if you need to perform side effects in the handlers.
|
|
3349
3349
|
*
|
|
3350
|
-
* **Example** (
|
|
3350
|
+
* **Example** (Matching success and failure values)
|
|
3351
3351
|
*
|
|
3352
3352
|
* ```ts
|
|
3353
3353
|
* import { Data, Effect } from "effect"
|
|
@@ -3400,7 +3400,7 @@ export const match = internal.match;
|
|
|
3400
3400
|
* optimal performance for resolved effects. This is particularly useful in
|
|
3401
3401
|
* scenarios where you frequently work with already computed values.
|
|
3402
3402
|
*
|
|
3403
|
-
* **Example** (
|
|
3403
|
+
* **Example** (Pattern matching eagerly when possible)
|
|
3404
3404
|
*
|
|
3405
3405
|
* ```ts
|
|
3406
3406
|
* import { Effect } from "effect"
|
|
@@ -3435,7 +3435,7 @@ export const matchEager = internal.matchEager;
|
|
|
3435
3435
|
* regular failures, defects, or interruptions. You can provide specific
|
|
3436
3436
|
* handling logic for each failure type based on the cause.
|
|
3437
3437
|
*
|
|
3438
|
-
* **Example** (
|
|
3438
|
+
* **Example** (Matching on success or failure causes)
|
|
3439
3439
|
*
|
|
3440
3440
|
* ```ts
|
|
3441
3441
|
* import { Cause, Effect } from "effect"
|
|
@@ -3474,7 +3474,7 @@ export const matchCause = internal.matchCause;
|
|
|
3474
3474
|
* and you want to avoid the overhead of the effect pipeline. For pending effects,
|
|
3475
3475
|
* it automatically falls back to the regular `matchCause` behavior.
|
|
3476
3476
|
*
|
|
3477
|
-
* **Example** (
|
|
3477
|
+
* **Example** (Eagerly matching already completed effects)
|
|
3478
3478
|
*
|
|
3479
3479
|
* ```ts
|
|
3480
3480
|
* import { Effect } from "effect"
|
|
@@ -3511,7 +3511,7 @@ export const matchCauseEffectEager = internal.matchCauseEffectEager;
|
|
|
3511
3511
|
* you to respond accordingly while performing side effects (like logging or
|
|
3512
3512
|
* other operations).
|
|
3513
3513
|
*
|
|
3514
|
-
* **Example** (
|
|
3514
|
+
* **Example** (Effectfully matching on causes)
|
|
3515
3515
|
*
|
|
3516
3516
|
* ```ts
|
|
3517
3517
|
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
@@ -3570,7 +3570,7 @@ export const matchCauseEffect = internal.matchCauseEffect;
|
|
|
3570
3570
|
* @see {@link match} if you don't need side effects and only want to handle the
|
|
3571
3571
|
* result or failure.
|
|
3572
3572
|
*
|
|
3573
|
-
* **Example** (
|
|
3573
|
+
* **Example** (Matching success and failure with effectful handlers)
|
|
3574
3574
|
*
|
|
3575
3575
|
* ```ts
|
|
3576
3576
|
* import { Data, Effect } from "effect"
|
|
@@ -3679,7 +3679,7 @@ export const isSuccess = internal.isSuccess;
|
|
|
3679
3679
|
* in the effect's environment. This can be useful for debugging, introspection,
|
|
3680
3680
|
* or when you need to pass the entire context to another function.
|
|
3681
3681
|
*
|
|
3682
|
-
* **Example** (
|
|
3682
|
+
* **Example** (Reading the full context)
|
|
3683
3683
|
*
|
|
3684
3684
|
* ```ts
|
|
3685
3685
|
* import { Console, Context, Effect, Option } from "effect"
|
|
@@ -3719,7 +3719,7 @@ export const context = internal.context;
|
|
|
3719
3719
|
* computations based on all available services. This is useful when you need
|
|
3720
3720
|
* to conditionally execute logic based on what services are available.
|
|
3721
3721
|
*
|
|
3722
|
-
* **Example** (
|
|
3722
|
+
* **Example** (Deriving values from the context)
|
|
3723
3723
|
*
|
|
3724
3724
|
* ```ts
|
|
3725
3725
|
* import { Console, Context, Effect, Option } from "effect"
|
|
@@ -3763,7 +3763,7 @@ export const contextWith = internal.contextWith;
|
|
|
3763
3763
|
* to build the layer every time; by default, layers are shared between provide
|
|
3764
3764
|
* calls.
|
|
3765
3765
|
*
|
|
3766
|
-
* **Example** (
|
|
3766
|
+
* **Example** (Providing dependencies with a layer)
|
|
3767
3767
|
*
|
|
3768
3768
|
* ```ts
|
|
3769
3769
|
* import { Context, Effect, Layer } from "effect"
|
|
@@ -3802,7 +3802,7 @@ export const provide = internalLayer.provide;
|
|
|
3802
3802
|
* that contains all the required services. It removes the provided services
|
|
3803
3803
|
* from the effect's requirements, making them available to the effect.
|
|
3804
3804
|
*
|
|
3805
|
-
* **Example** (
|
|
3805
|
+
* **Example** (Providing a complete context)
|
|
3806
3806
|
*
|
|
3807
3807
|
* ```ts
|
|
3808
3808
|
* import { Context, Effect } from "effect"
|
|
@@ -3837,7 +3837,7 @@ export const provideContext = internal.provideContext;
|
|
|
3837
3837
|
/**
|
|
3838
3838
|
* Accesses a service from the context.
|
|
3839
3839
|
*
|
|
3840
|
-
* **Example** (
|
|
3840
|
+
* **Example** (Accessing a required service)
|
|
3841
3841
|
*
|
|
3842
3842
|
* ```ts
|
|
3843
3843
|
* import { Context, Effect } from "effect"
|
|
@@ -3868,7 +3868,7 @@ export const service = internal.service;
|
|
|
3868
3868
|
* available, it returns `None`. Unlike `service`, this function does not
|
|
3869
3869
|
* require the service to be present in the environment.
|
|
3870
3870
|
*
|
|
3871
|
-
* **Example** (
|
|
3871
|
+
* **Example** (Accessing an optional service)
|
|
3872
3872
|
*
|
|
3873
3873
|
* ```ts
|
|
3874
3874
|
* import { Context, Effect, Option } from "effect"
|
|
@@ -3902,7 +3902,7 @@ export const serviceOption = internal.serviceOption;
|
|
|
3902
3902
|
* This function allows you to transform the context required by an effect,
|
|
3903
3903
|
* providing part of the context and leaving the rest to be fulfilled later.
|
|
3904
3904
|
*
|
|
3905
|
-
* **Example** (
|
|
3905
|
+
* **Example** (Updating the context before running)
|
|
3906
3906
|
*
|
|
3907
3907
|
* ```ts
|
|
3908
3908
|
* import { Context, Effect } from "effect"
|
|
@@ -3943,7 +3943,7 @@ export const updateContext = internal.updateContext;
|
|
|
3943
3943
|
* The service must be available in the effect's context; `updateService`
|
|
3944
3944
|
* replaces it for the wrapped effect with the value returned by the updater.
|
|
3945
3945
|
*
|
|
3946
|
-
* **Example** (
|
|
3946
|
+
* **Example** (Replacing a service for one effect)
|
|
3947
3947
|
*
|
|
3948
3948
|
* ```ts
|
|
3949
3949
|
* import { Console, Context, Effect } from "effect"
|
|
@@ -3982,7 +3982,7 @@ export const updateService = internal.updateService;
|
|
|
3982
3982
|
*
|
|
3983
3983
|
* @see {@link provide} for providing multiple layers to an effect.
|
|
3984
3984
|
*
|
|
3985
|
-
* **Example** (
|
|
3985
|
+
* **Example** (Providing a service value)
|
|
3986
3986
|
*
|
|
3987
3987
|
* ```ts
|
|
3988
3988
|
* import { Console, Context, Effect } from "effect"
|
|
@@ -4027,7 +4027,7 @@ export const provideService = internal.provideService;
|
|
|
4027
4027
|
* and leaves any other requirements to be provided later. Acquisition failures
|
|
4028
4028
|
* are included in the returned effect's error channel.
|
|
4029
4029
|
*
|
|
4030
|
-
* **Example** (
|
|
4030
|
+
* **Example** (Providing a service with an effect)
|
|
4031
4031
|
*
|
|
4032
4032
|
* ```ts
|
|
4033
4033
|
* import { Console, Context, Effect } from "effect"
|
|
@@ -4077,7 +4077,7 @@ export const provideServiceEffect = internal.provideServiceEffect;
|
|
|
4077
4077
|
/**
|
|
4078
4078
|
* Sets the concurrency level for parallel operations within an effect.
|
|
4079
4079
|
*
|
|
4080
|
-
* **Example** (
|
|
4080
|
+
* **Example** (Setting local concurrency)
|
|
4081
4081
|
*
|
|
4082
4082
|
* ```ts
|
|
4083
4083
|
* import { Console, Effect } from "effect"
|
|
@@ -4113,7 +4113,7 @@ export const withConcurrency = internal.withConcurrency;
|
|
|
4113
4113
|
/**
|
|
4114
4114
|
* Returns the current scope for resource management.
|
|
4115
4115
|
*
|
|
4116
|
-
* **Example** (
|
|
4116
|
+
* **Example** (Accessing the current scope)
|
|
4117
4117
|
*
|
|
4118
4118
|
* ```ts
|
|
4119
4119
|
* import { Console, Effect } from "effect"
|
|
@@ -4148,7 +4148,7 @@ export const scope = internal.scope;
|
|
|
4148
4148
|
* ensuring that their finalizers are run as soon as this workflow completes
|
|
4149
4149
|
* execution, whether by success, failure, or interruption.
|
|
4150
4150
|
*
|
|
4151
|
-
* **Example** (
|
|
4151
|
+
* **Example** (Running a scoped acquisition)
|
|
4152
4152
|
*
|
|
4153
4153
|
* ```ts
|
|
4154
4154
|
* import { Console, Effect } from "effect"
|
|
@@ -4179,7 +4179,7 @@ export const scoped = internal.scoped;
|
|
|
4179
4179
|
/**
|
|
4180
4180
|
* Creates a scoped effect by providing access to the scope.
|
|
4181
4181
|
*
|
|
4182
|
-
* **Example** (
|
|
4182
|
+
* **Example** (Working with an explicit scope)
|
|
4183
4183
|
*
|
|
4184
4184
|
* ```ts
|
|
4185
4185
|
* import { Console, Effect, Scope } from "effect"
|
|
@@ -4229,7 +4229,7 @@ export const scopedWith = internal.scopedWith;
|
|
|
4229
4229
|
* By default, acquisition is protected by an uninterruptible region. Pass
|
|
4230
4230
|
* `{ interruptible: true }` to allow the acquisition effect to be interrupted.
|
|
4231
4231
|
*
|
|
4232
|
-
* **Example** (
|
|
4232
|
+
* **Example** (Acquiring and releasing a resource)
|
|
4233
4233
|
*
|
|
4234
4234
|
* ```ts
|
|
4235
4235
|
* import { Console, Effect, Exit } from "effect"
|
|
@@ -4286,7 +4286,7 @@ export const acquireRelease = internal.acquireRelease;
|
|
|
4286
4286
|
*
|
|
4287
4287
|
* @see [JavaScript `using` declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using)
|
|
4288
4288
|
*
|
|
4289
|
-
* **Example** (
|
|
4289
|
+
* **Example** (Acquiring a disposable resource)
|
|
4290
4290
|
*
|
|
4291
4291
|
* ```ts
|
|
4292
4292
|
* import sqlite from "node:sqlite";
|
|
@@ -4333,7 +4333,7 @@ export const acquireDisposable = internal.acquireDisposable;
|
|
|
4333
4333
|
* is not desired, errors produced by the `release` `Effect` value can be caught
|
|
4334
4334
|
* and ignored.
|
|
4335
4335
|
*
|
|
4336
|
-
* **Example** (
|
|
4336
|
+
* **Example** (Using a resource with cleanup)
|
|
4337
4337
|
*
|
|
4338
4338
|
* ```ts
|
|
4339
4339
|
* import { Console, Effect, Exit } from "effect"
|
|
@@ -4392,7 +4392,7 @@ export const acquireUseRelease = internal.acquireUseRelease;
|
|
|
4392
4392
|
* whether the effect succeeds or fails. They're commonly used for resource
|
|
4393
4393
|
* cleanup, logging, or other side effects that should always occur.
|
|
4394
4394
|
*
|
|
4395
|
-
* **Example** (
|
|
4395
|
+
* **Example** (Registering scope finalizers)
|
|
4396
4396
|
*
|
|
4397
4397
|
* ```ts
|
|
4398
4398
|
* import { Console, Effect, Exit } from "effect"
|
|
@@ -4437,7 +4437,7 @@ export const addFinalizer = internal.addFinalizer;
|
|
|
4437
4437
|
* should generally not be used for releasing resources. For higher-level
|
|
4438
4438
|
* logic built on `ensuring`, see the `acquireRelease` family of methods.
|
|
4439
4439
|
*
|
|
4440
|
-
* **Example** (
|
|
4440
|
+
* **Example** (Always running cleanup)
|
|
4441
4441
|
*
|
|
4442
4442
|
* ```ts
|
|
4443
4443
|
* import { Console, Effect } from "effect"
|
|
@@ -4471,7 +4471,7 @@ export const ensuring = internal.ensuring;
|
|
|
4471
4471
|
* Runs the specified effect if this effect fails, providing the error to the
|
|
4472
4472
|
* effect if it exists. The provided effect will not be interrupted.
|
|
4473
4473
|
*
|
|
4474
|
-
* **Example** (
|
|
4474
|
+
* **Example** (Running cleanup on failure)
|
|
4475
4475
|
*
|
|
4476
4476
|
* ```ts
|
|
4477
4477
|
* import { Cause, Console, Data, Effect } from "effect"
|
|
@@ -4499,7 +4499,7 @@ export const onError = internal.onError;
|
|
|
4499
4499
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
4500
4500
|
* provided predicate.
|
|
4501
4501
|
*
|
|
4502
|
-
* **Example** (
|
|
4502
|
+
* **Example** (Running cleanup for selected failures)
|
|
4503
4503
|
*
|
|
4504
4504
|
* ```ts
|
|
4505
4505
|
* import { Cause, Console, Effect } from "effect"
|
|
@@ -4544,7 +4544,7 @@ export const onExitPrimitive = internal.onExitPrimitive;
|
|
|
4544
4544
|
* Ensures that a cleanup functions runs, whether this effect succeeds, fails,
|
|
4545
4545
|
* or is interrupted.
|
|
4546
4546
|
*
|
|
4547
|
-
* **Example** (
|
|
4547
|
+
* **Example** (Observing every exit)
|
|
4548
4548
|
*
|
|
4549
4549
|
* ```ts
|
|
4550
4550
|
* import { Console, Effect, Exit } from "effect"
|
|
@@ -4572,7 +4572,7 @@ export const onExit = internal.onExit;
|
|
|
4572
4572
|
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
4573
4573
|
* predicate.
|
|
4574
4574
|
*
|
|
4575
|
-
* **Example** (
|
|
4575
|
+
* **Example** (Observing selected exits)
|
|
4576
4576
|
*
|
|
4577
4577
|
* ```ts
|
|
4578
4578
|
* import { Console, Effect, Exit } from "effect"
|
|
@@ -4624,7 +4624,7 @@ export const onExitFilter = internal.onExitFilter;
|
|
|
4624
4624
|
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
4625
4625
|
* additional effect for manually invalidating the cached value.
|
|
4626
4626
|
*
|
|
4627
|
-
* **Example** (
|
|
4627
|
+
* **Example** (Memoizing an effect until invalidated)
|
|
4628
4628
|
*
|
|
4629
4629
|
* ```ts
|
|
4630
4630
|
* import { Console, Effect } from "effect"
|
|
@@ -4698,7 +4698,7 @@ export const cached = internal.cached;
|
|
|
4698
4698
|
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
4699
4699
|
* additional effect for manually invalidating the cached value.
|
|
4700
4700
|
*
|
|
4701
|
-
* **Example** (
|
|
4701
|
+
* **Example** (Memoizing an effect with TTL)
|
|
4702
4702
|
*
|
|
4703
4703
|
* ```ts
|
|
4704
4704
|
* import { Console, Effect } from "effect"
|
|
@@ -4766,7 +4766,7 @@ export const cachedWithTTL = internal.cachedWithTTL;
|
|
|
4766
4766
|
* @see {@link cachedWithTTL} for a similar function that caches the result for
|
|
4767
4767
|
* a specified duration but does not include an effect for manual invalidation.
|
|
4768
4768
|
*
|
|
4769
|
-
* **Example** (
|
|
4769
|
+
* **Example** (Memoizing with TTL and invalidation)
|
|
4770
4770
|
*
|
|
4771
4771
|
* ```ts
|
|
4772
4772
|
* import { Console, Effect } from "effect"
|
|
@@ -4811,7 +4811,7 @@ export const cachedInvalidateWithTTL = internal.cachedInvalidateWithTTL;
|
|
|
4811
4811
|
/**
|
|
4812
4812
|
* Returns an effect that is immediately interrupted.
|
|
4813
4813
|
*
|
|
4814
|
-
* **Example** (
|
|
4814
|
+
* **Example** (Creating an interrupted effect)
|
|
4815
4815
|
*
|
|
4816
4816
|
* ```ts
|
|
4817
4817
|
* import { Effect } from "effect"
|
|
@@ -4832,7 +4832,7 @@ export const interrupt = internal.interrupt;
|
|
|
4832
4832
|
/**
|
|
4833
4833
|
* Returns a new effect that allows the effect to be interruptible.
|
|
4834
4834
|
*
|
|
4835
|
-
* **Example** (
|
|
4835
|
+
* **Example** (Allowing interruption)
|
|
4836
4836
|
*
|
|
4837
4837
|
* ```ts
|
|
4838
4838
|
* import { Effect } from "effect"
|
|
@@ -4853,7 +4853,7 @@ export const interruptible = internal.interruptible;
|
|
|
4853
4853
|
/**
|
|
4854
4854
|
* Runs the specified finalizer effect if this effect is interrupted.
|
|
4855
4855
|
*
|
|
4856
|
-
* **Example** (
|
|
4856
|
+
* **Example** (Running cleanup on interruption)
|
|
4857
4857
|
*
|
|
4858
4858
|
* ```ts
|
|
4859
4859
|
* import { Console, Effect, Fiber } from "effect"
|
|
@@ -4878,7 +4878,7 @@ export const onInterrupt = internal.onInterrupt;
|
|
|
4878
4878
|
/**
|
|
4879
4879
|
* Returns a new effect that disables interruption for the given effect.
|
|
4880
4880
|
*
|
|
4881
|
-
* **Example** (
|
|
4881
|
+
* **Example** (Preventing interruption)
|
|
4882
4882
|
*
|
|
4883
4883
|
* ```ts
|
|
4884
4884
|
* import { Console, Effect, Fiber } from "effect"
|
|
@@ -4904,7 +4904,7 @@ export const uninterruptible = internal.uninterruptible;
|
|
|
4904
4904
|
* Disables interruption and provides a restore function to restore the
|
|
4905
4905
|
* interruptible state within the effect.
|
|
4906
4906
|
*
|
|
4907
|
-
* **Example** (
|
|
4907
|
+
* **Example** (Restoring interruption in protected regions)
|
|
4908
4908
|
*
|
|
4909
4909
|
* ```ts
|
|
4910
4910
|
* import { Console, Effect } from "effect"
|
|
@@ -4936,7 +4936,7 @@ export const uninterruptibleMask = internal.uninterruptibleMask;
|
|
|
4936
4936
|
* `restore` function. This function can be used to restore the interruptibility
|
|
4937
4937
|
* of any specific region of code.
|
|
4938
4938
|
*
|
|
4939
|
-
* **Example** (
|
|
4939
|
+
* **Example** (Controlling interruptibility locally)
|
|
4940
4940
|
*
|
|
4941
4941
|
* ```ts
|
|
4942
4942
|
* import { Console, Effect } from "effect"
|
|
@@ -4973,7 +4973,7 @@ export const abortSignal = internal.abortSignal;
|
|
|
4973
4973
|
/**
|
|
4974
4974
|
* Repeats this effect forever (until the first error).
|
|
4975
4975
|
*
|
|
4976
|
-
* **Example** (
|
|
4976
|
+
* **Example** (Repeating forever)
|
|
4977
4977
|
*
|
|
4978
4978
|
* ```ts
|
|
4979
4979
|
* import { Console, Effect, Fiber } from "effect"
|
|
@@ -5023,7 +5023,7 @@ export const forever = internal.forever;
|
|
|
5023
5023
|
* delays, limiting recursions, or dynamically adjusting based on the outcome of
|
|
5024
5024
|
* each execution.
|
|
5025
5025
|
*
|
|
5026
|
-
* **Example** (
|
|
5026
|
+
* **Example** (Repeating successful effects with a schedule)
|
|
5027
5027
|
*
|
|
5028
5028
|
* ```ts
|
|
5029
5029
|
* // Success Example
|
|
@@ -5036,7 +5036,7 @@ export const forever = internal.forever;
|
|
|
5036
5036
|
* // Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
|
|
5037
5037
|
* ```
|
|
5038
5038
|
*
|
|
5039
|
-
* **Example** (
|
|
5039
|
+
* **Example** (Stopping repetition on failure)
|
|
5040
5040
|
*
|
|
5041
5041
|
* ```ts
|
|
5042
5042
|
* // Failure Example
|
|
@@ -5077,7 +5077,7 @@ export const repeat = internalSchedule.repeat;
|
|
|
5077
5077
|
* otherwise it receives `None`. If the schedule completes normally, the
|
|
5078
5078
|
* returned effect succeeds with the schedule's output.
|
|
5079
5079
|
*
|
|
5080
|
-
* **Example** (
|
|
5080
|
+
* **Example** (Recovering after repetition stops)
|
|
5081
5081
|
*
|
|
5082
5082
|
* ```ts
|
|
5083
5083
|
* import { Console, Effect, Option, Schedule } from "effect"
|
|
@@ -5123,7 +5123,7 @@ export const replicate = internal.replicate;
|
|
|
5123
5123
|
*
|
|
5124
5124
|
* Use `concurrency` to control parallelism and `discard: true` to ignore results.
|
|
5125
5125
|
*
|
|
5126
|
-
* **Example** (
|
|
5126
|
+
* **Example** (Replicating an effect)
|
|
5127
5127
|
*
|
|
5128
5128
|
* ```ts
|
|
5129
5129
|
* import { Console, Effect } from "effect"
|
|
@@ -5150,7 +5150,7 @@ export const replicateEffect = internal.replicateEffect;
|
|
|
5150
5150
|
* fails, and otherwise succeeds with the schedule output when the schedule
|
|
5151
5151
|
* completes.
|
|
5152
5152
|
*
|
|
5153
|
-
* **Example** (
|
|
5153
|
+
* **Example** (Scheduling repeated execution)
|
|
5154
5154
|
*
|
|
5155
5155
|
* ```ts
|
|
5156
5156
|
* import { Console, Effect, Schedule } from "effect"
|
|
@@ -5193,7 +5193,7 @@ export const schedule = /*#__PURE__*/dual(2, (self, schedule) => scheduleFrom(se
|
|
|
5193
5193
|
* succeeds with the schedule output when the schedule completes and fails if
|
|
5194
5194
|
* the effect or schedule fails.
|
|
5195
5195
|
*
|
|
5196
|
-
* **Example** (
|
|
5196
|
+
* **Example** (Scheduling from an initial value)
|
|
5197
5197
|
*
|
|
5198
5198
|
* ```ts
|
|
5199
5199
|
* import { Console, Effect, Schedule } from "effect"
|
|
@@ -5225,7 +5225,7 @@ export const scheduleFrom = internalSchedule.scheduleFrom;
|
|
|
5225
5225
|
/**
|
|
5226
5226
|
* Returns the current tracer from the context.
|
|
5227
5227
|
*
|
|
5228
|
-
* **Example** (
|
|
5228
|
+
* **Example** (Accessing the current tracer)
|
|
5229
5229
|
*
|
|
5230
5230
|
* ```ts
|
|
5231
5231
|
* import { Effect } from "effect"
|
|
@@ -5244,7 +5244,7 @@ export const tracer = internal.tracer;
|
|
|
5244
5244
|
/**
|
|
5245
5245
|
* Provides a tracer to an effect.
|
|
5246
5246
|
*
|
|
5247
|
-
* **Example** (
|
|
5247
|
+
* **Example** (Providing a tracer)
|
|
5248
5248
|
*
|
|
5249
5249
|
* ```ts
|
|
5250
5250
|
* import { Effect } from "effect"
|
|
@@ -5270,7 +5270,7 @@ export const withTracer = internal.withTracer;
|
|
|
5270
5270
|
* When `enabled` is `false`, spans created inside the effect are not registered
|
|
5271
5271
|
* with the current tracer and do not propagate as normal trace parents.
|
|
5272
5272
|
*
|
|
5273
|
-
* **Example** (
|
|
5273
|
+
* **Example** (Enabling or disabling tracing)
|
|
5274
5274
|
*
|
|
5275
5275
|
* ```ts
|
|
5276
5276
|
* import { Effect } from "effect"
|
|
@@ -5289,7 +5289,7 @@ export const withTracerEnabled = internal.withTracerEnabled;
|
|
|
5289
5289
|
/**
|
|
5290
5290
|
* Enables or disables tracer timing for the given Effect.
|
|
5291
5291
|
*
|
|
5292
|
-
* **Example** (
|
|
5292
|
+
* **Example** (Enabling or disabling tracing timing)
|
|
5293
5293
|
*
|
|
5294
5294
|
* ```ts
|
|
5295
5295
|
* import { Effect } from "effect"
|
|
@@ -5308,7 +5308,7 @@ export const withTracerTiming = internal.withTracerTiming;
|
|
|
5308
5308
|
/**
|
|
5309
5309
|
* Adds an annotation to each span in this effect.
|
|
5310
5310
|
*
|
|
5311
|
-
* **Example** (
|
|
5311
|
+
* **Example** (Annotating all spans)
|
|
5312
5312
|
*
|
|
5313
5313
|
* ```ts
|
|
5314
5314
|
* import { Effect } from "effect"
|
|
@@ -5336,7 +5336,7 @@ export const annotateSpans = internal.annotateSpans;
|
|
|
5336
5336
|
/**
|
|
5337
5337
|
* Adds an annotation to the current span if available.
|
|
5338
5338
|
*
|
|
5339
|
-
* **Example** (
|
|
5339
|
+
* **Example** (Annotating the current span)
|
|
5340
5340
|
*
|
|
5341
5341
|
* ```ts
|
|
5342
5342
|
* import { Effect } from "effect"
|
|
@@ -5366,7 +5366,7 @@ export const annotateCurrentSpan = internal.annotateCurrentSpan;
|
|
|
5366
5366
|
* The effect fails with `NoSuchElementError` when there is no active local
|
|
5367
5367
|
* `Span`.
|
|
5368
5368
|
*
|
|
5369
|
-
* **Example** (
|
|
5369
|
+
* **Example** (Reading the current span)
|
|
5370
5370
|
*
|
|
5371
5371
|
* ```ts
|
|
5372
5372
|
* import { Effect } from "effect"
|
|
@@ -5393,7 +5393,7 @@ export const currentSpan = internal.currentSpan;
|
|
|
5393
5393
|
* present, and fails with `NoSuchElementError` when no parent span is
|
|
5394
5394
|
* available.
|
|
5395
5395
|
*
|
|
5396
|
-
* **Example** (
|
|
5396
|
+
* **Example** (Reading the parent span)
|
|
5397
5397
|
*
|
|
5398
5398
|
* ```ts
|
|
5399
5399
|
* import { Effect } from "effect"
|
|
@@ -5424,7 +5424,7 @@ export const currentParentSpan = internal.currentParentSpan;
|
|
|
5424
5424
|
* These annotations are applied to spans created inside the context, such as
|
|
5425
5425
|
* spans created by `withSpan`, `useSpan`, or `makeSpan`.
|
|
5426
5426
|
*
|
|
5427
|
-
* **Example** (
|
|
5427
|
+
* **Example** (Providing span annotations)
|
|
5428
5428
|
*
|
|
5429
5429
|
* ```ts
|
|
5430
5430
|
* import { Effect } from "effect"
|
|
@@ -5457,7 +5457,7 @@ export const spanAnnotations = internal.spanAnnotations;
|
|
|
5457
5457
|
* These links are attached to spans created inside the context. Span links
|
|
5458
5458
|
* connect related spans without making one span the parent of another.
|
|
5459
5459
|
*
|
|
5460
|
-
* **Example** (
|
|
5460
|
+
* **Example** (Providing span links)
|
|
5461
5461
|
*
|
|
5462
5462
|
* ```ts
|
|
5463
5463
|
* import { Effect } from "effect"
|
|
@@ -5481,7 +5481,7 @@ export const spanLinks = internal.spanLinks;
|
|
|
5481
5481
|
* parent-child relationship. For example, you might want to link spans from
|
|
5482
5482
|
* parallel operations or connect spans across different traces.
|
|
5483
5483
|
*
|
|
5484
|
-
* **Example** (
|
|
5484
|
+
* **Example** (Linking one span to another span)
|
|
5485
5485
|
*
|
|
5486
5486
|
* ```ts
|
|
5487
5487
|
* import { Effect } from "effect"
|
|
@@ -5504,7 +5504,7 @@ export const spanLinks = internal.spanLinks;
|
|
|
5504
5504
|
* })
|
|
5505
5505
|
* ```
|
|
5506
5506
|
*
|
|
5507
|
-
* **Example** (
|
|
5507
|
+
* **Example** (Linking multiple spans at once)
|
|
5508
5508
|
*
|
|
5509
5509
|
* ```ts
|
|
5510
5510
|
* import { Effect } from "effect"
|
|
@@ -5536,7 +5536,7 @@ export const linkSpans = internal.linkSpans;
|
|
|
5536
5536
|
* automatically. Use `withSpan`, `useSpan`, or `makeSpanScoped` when the span
|
|
5537
5537
|
* should be installed as context or closed automatically.
|
|
5538
5538
|
*
|
|
5539
|
-
* **Example** (
|
|
5539
|
+
* **Example** (Creating a span manually)
|
|
5540
5540
|
*
|
|
5541
5541
|
* ```ts
|
|
5542
5542
|
* import { Effect } from "effect"
|
|
@@ -5559,7 +5559,7 @@ export const makeSpan = internal.makeSpan;
|
|
|
5559
5559
|
* The span is not added to the current span stack, so no child spans will be
|
|
5560
5560
|
* created for it.
|
|
5561
5561
|
*
|
|
5562
|
-
* **Example** (
|
|
5562
|
+
* **Example** (Creating a scoped standalone span)
|
|
5563
5563
|
*
|
|
5564
5564
|
* ```ts
|
|
5565
5565
|
* import { Effect } from "effect"
|
|
@@ -5585,7 +5585,7 @@ export const makeSpanScoped = internal.makeSpanScoped;
|
|
|
5585
5585
|
* The span is not added to the current span stack, so no child spans will be
|
|
5586
5586
|
* created for it.
|
|
5587
5587
|
*
|
|
5588
|
-
* **Example** (
|
|
5588
|
+
* **Example** (Running an effect with a standalone span)
|
|
5589
5589
|
*
|
|
5590
5590
|
* ```ts
|
|
5591
5591
|
* import { Effect } from "effect"
|
|
@@ -5607,7 +5607,7 @@ export const useSpan = internal.useSpan;
|
|
|
5607
5607
|
/**
|
|
5608
5608
|
* Wraps the effect with a new span for tracing.
|
|
5609
5609
|
*
|
|
5610
|
-
* **Example** (
|
|
5610
|
+
* **Example** (Wrapping an effect in a child span)
|
|
5611
5611
|
*
|
|
5612
5612
|
* ```ts
|
|
5613
5613
|
* import { Effect } from "effect"
|
|
@@ -5631,7 +5631,7 @@ export const withSpan = internal.withSpan;
|
|
|
5631
5631
|
*
|
|
5632
5632
|
* The span is ended when the Scope is finalized.
|
|
5633
5633
|
*
|
|
5634
|
-
* **Example** (
|
|
5634
|
+
* **Example** (Creating a scoped child span)
|
|
5635
5635
|
*
|
|
5636
5636
|
* ```ts
|
|
5637
5637
|
* import { Effect } from "effect"
|
|
@@ -5652,7 +5652,7 @@ export const withSpanScoped = internal.withSpanScoped;
|
|
|
5652
5652
|
/**
|
|
5653
5653
|
* Adds the provided span to the current span stack.
|
|
5654
5654
|
*
|
|
5655
|
-
* **Example** (
|
|
5655
|
+
* **Example** (Setting a parent span)
|
|
5656
5656
|
*
|
|
5657
5657
|
* ```ts
|
|
5658
5658
|
* import { Effect } from "effect"
|
|
@@ -5678,7 +5678,7 @@ export const withParentSpan = internal.withParentSpan;
|
|
|
5678
5678
|
* @category Requests & Batching
|
|
5679
5679
|
* @since 2.0.0
|
|
5680
5680
|
*
|
|
5681
|
-
* **Example** (
|
|
5681
|
+
* **Example** (Executing a request through a resolver)
|
|
5682
5682
|
*
|
|
5683
5683
|
* ```ts
|
|
5684
5684
|
* import { Console, Effect, Exit, Request, RequestResolver } from "effect"
|
|
@@ -5738,7 +5738,7 @@ export const requestUnsafe = internalRequest.requestUnsafe;
|
|
|
5738
5738
|
* fibers leak. This behavior is called "auto supervision", and if this
|
|
5739
5739
|
* behavior is not desired, you may use the `forkDetach` or `forkIn` methods.
|
|
5740
5740
|
*
|
|
5741
|
-
* **Example** (
|
|
5741
|
+
* **Example** (Forking a child fiber)
|
|
5742
5742
|
*
|
|
5743
5743
|
* ```ts
|
|
5744
5744
|
* import { Effect, Fiber } from "effect"
|
|
@@ -5769,7 +5769,7 @@ export const forkChild = internal.forkChild;
|
|
|
5769
5769
|
* Forks the effect in the specified scope. The fiber will be interrupted
|
|
5770
5770
|
* when the scope is closed.
|
|
5771
5771
|
*
|
|
5772
|
-
* **Example** (
|
|
5772
|
+
* **Example** (Forking into a supplied scope)
|
|
5773
5773
|
*
|
|
5774
5774
|
* ```ts
|
|
5775
5775
|
* import { Effect } from "effect"
|
|
@@ -5797,7 +5797,7 @@ export const forkIn = internal.forkIn;
|
|
|
5797
5797
|
/**
|
|
5798
5798
|
* Forks the fiber in a `Scope`, interrupting it when the scope is closed.
|
|
5799
5799
|
*
|
|
5800
|
-
* **Example** (
|
|
5800
|
+
* **Example** (Forking into the current scope)
|
|
5801
5801
|
*
|
|
5802
5802
|
* ```ts
|
|
5803
5803
|
* import { Effect } from "effect"
|
|
@@ -5833,7 +5833,7 @@ export const forkScoped = internal.forkScoped;
|
|
|
5833
5833
|
* new fiber is attached to the global scope, when the fiber executing the
|
|
5834
5834
|
* returned effect terminates, the forked fiber will continue running.
|
|
5835
5835
|
*
|
|
5836
|
-
* **Example** (
|
|
5836
|
+
* **Example** (Forking a detached fiber)
|
|
5837
5837
|
*
|
|
5838
5838
|
* ```ts
|
|
5839
5839
|
* import { Effect } from "effect"
|
|
@@ -5873,7 +5873,7 @@ export const awaitAllChildren = internal.awaitAllChildren;
|
|
|
5873
5873
|
/**
|
|
5874
5874
|
* Access the fiber currently executing the effect.
|
|
5875
5875
|
*
|
|
5876
|
-
* **Example** (
|
|
5876
|
+
* **Example** (Accessing the current fiber)
|
|
5877
5877
|
*
|
|
5878
5878
|
* ```ts
|
|
5879
5879
|
* import { Console, Effect } from "effect"
|
|
@@ -5891,7 +5891,7 @@ export const fiber = internal.fiber;
|
|
|
5891
5891
|
/**
|
|
5892
5892
|
* Access the current fiber id executing the effect.
|
|
5893
5893
|
*
|
|
5894
|
-
* **Example** (
|
|
5894
|
+
* **Example** (Accessing the current fiber id)
|
|
5895
5895
|
*
|
|
5896
5896
|
* ```ts
|
|
5897
5897
|
* import { Effect } from "effect"
|
|
@@ -5924,7 +5924,7 @@ export const fiberId = internal.fiberId;
|
|
|
5924
5924
|
* Unless you specifically need a `Promise` or synchronous operation,
|
|
5925
5925
|
* `runFork` is a good default choice.
|
|
5926
5926
|
*
|
|
5927
|
-
* **Example** (Running an
|
|
5927
|
+
* **Example** (Running an effect in the background)
|
|
5928
5928
|
*
|
|
5929
5929
|
* ```ts
|
|
5930
5930
|
* import { Console, Effect, Fiber, Schedule } from "effect"
|
|
@@ -5952,7 +5952,7 @@ export const runFork = internal.runFork;
|
|
|
5952
5952
|
/**
|
|
5953
5953
|
* Runs an effect in the background with the provided services.
|
|
5954
5954
|
*
|
|
5955
|
-
* **Example** (
|
|
5955
|
+
* **Example** (Running with services in the background)
|
|
5956
5956
|
*
|
|
5957
5957
|
* ```ts
|
|
5958
5958
|
* import { Context, Effect } from "effect"
|
|
@@ -5985,7 +5985,7 @@ export const runForkWith = internal.runForkWith;
|
|
|
5985
5985
|
*
|
|
5986
5986
|
* The returned interruptor calls `fiber.interruptUnsafe`, optionally with an interruptor id.
|
|
5987
5987
|
*
|
|
5988
|
-
* **Example** (
|
|
5988
|
+
* **Example** (Running with services and a callback)
|
|
5989
5989
|
*
|
|
5990
5990
|
* ```ts
|
|
5991
5991
|
* import { Console, Context, Effect, Exit } from "effect"
|
|
@@ -6029,7 +6029,7 @@ export const runCallbackWith = internal.runCallbackWith;
|
|
|
6029
6029
|
* The interruptor calls `fiber.interruptUnsafe` with the optional interruptor
|
|
6030
6030
|
* id.
|
|
6031
6031
|
*
|
|
6032
|
-
* **Example** (
|
|
6032
|
+
* **Example** (Running with a callback)
|
|
6033
6033
|
*
|
|
6034
6034
|
* ```ts
|
|
6035
6035
|
* import { Console, Effect, Exit } from "effect"
|
|
@@ -6075,7 +6075,7 @@ export const runCallback = internal.runCallback;
|
|
|
6075
6075
|
*
|
|
6076
6076
|
* @see {@link runPromiseExit} for a version that returns an `Exit` type instead of rejecting.
|
|
6077
6077
|
*
|
|
6078
|
-
* **Example** (Running a
|
|
6078
|
+
* **Example** (Running a successful effect as a Promise)
|
|
6079
6079
|
*
|
|
6080
6080
|
* ```ts
|
|
6081
6081
|
* import { Effect } from "effect"
|
|
@@ -6084,7 +6084,7 @@ export const runCallback = internal.runCallback;
|
|
|
6084
6084
|
* // Output: 1
|
|
6085
6085
|
* ```
|
|
6086
6086
|
*
|
|
6087
|
-
* **Example** (
|
|
6087
|
+
* **Example** (Running effects as promises)
|
|
6088
6088
|
*
|
|
6089
6089
|
* ```ts
|
|
6090
6090
|
* //Example: Handling a Failing Effect as a Rejected Promise
|
|
@@ -6102,7 +6102,7 @@ export const runPromise = internal.runPromise;
|
|
|
6102
6102
|
/**
|
|
6103
6103
|
* Executes an effect as a Promise with the provided services.
|
|
6104
6104
|
*
|
|
6105
|
-
* **Example** (
|
|
6105
|
+
* **Example** (Running with services as a promise)
|
|
6106
6106
|
*
|
|
6107
6107
|
* ```ts
|
|
6108
6108
|
* import { Context, Effect } from "effect"
|
|
@@ -6145,7 +6145,7 @@ export const runPromiseWith = internal.runPromiseWith;
|
|
|
6145
6145
|
* - If it fails, the failure information is provided as a `Failure` containing
|
|
6146
6146
|
* a `Cause` type.
|
|
6147
6147
|
*
|
|
6148
|
-
* **Example** (
|
|
6148
|
+
* **Example** (Observing promise results as Exit)
|
|
6149
6149
|
*
|
|
6150
6150
|
* ```ts
|
|
6151
6151
|
* import { Effect } from "effect"
|
|
@@ -6180,7 +6180,7 @@ export const runPromiseExit = internal.runPromiseExit;
|
|
|
6180
6180
|
/**
|
|
6181
6181
|
* Runs an effect and returns a Promise of Exit with provided services.
|
|
6182
6182
|
*
|
|
6183
|
-
* **Example** (
|
|
6183
|
+
* **Example** (Running with services as an Exit promise)
|
|
6184
6184
|
*
|
|
6185
6185
|
* ```ts
|
|
6186
6186
|
* import { Context, Effect, Exit } from "effect"
|
|
@@ -6227,7 +6227,7 @@ export const runPromiseExitWith = internal.runPromiseExitWith;
|
|
|
6227
6227
|
* @see {@link runSyncExit} for a version that returns an `Exit` type instead of
|
|
6228
6228
|
* throwing an error.
|
|
6229
6229
|
*
|
|
6230
|
-
* **Example** (
|
|
6230
|
+
* **Example** (Running a synchronous effect)
|
|
6231
6231
|
*
|
|
6232
6232
|
* ```ts
|
|
6233
6233
|
* import { Effect } from "effect"
|
|
@@ -6244,7 +6244,7 @@ export const runPromiseExitWith = internal.runPromiseExitWith;
|
|
|
6244
6244
|
* // Output: 1
|
|
6245
6245
|
* ```
|
|
6246
6246
|
*
|
|
6247
|
-
* **Example** (
|
|
6247
|
+
* **Example** (Throwing for failed or async effects)
|
|
6248
6248
|
*
|
|
6249
6249
|
* ```ts
|
|
6250
6250
|
* import { Effect } from "effect"
|
|
@@ -6275,7 +6275,7 @@ export const runSync = internal.runSync;
|
|
|
6275
6275
|
/**
|
|
6276
6276
|
* Executes an effect synchronously with provided services.
|
|
6277
6277
|
*
|
|
6278
|
-
* **Example** (
|
|
6278
|
+
* **Example** (Running synchronously with services)
|
|
6279
6279
|
*
|
|
6280
6280
|
* ```ts
|
|
6281
6281
|
* import { Context, Effect } from "effect"
|
|
@@ -6323,7 +6323,7 @@ export const runSyncWith = internal.runSyncWith;
|
|
|
6323
6323
|
* return an `Failure` with a `Die` cause, indicating that the effect cannot be
|
|
6324
6324
|
* resolved synchronously.
|
|
6325
6325
|
*
|
|
6326
|
-
* **Example** (
|
|
6326
|
+
* **Example** (Observing synchronous results as Exit)
|
|
6327
6327
|
*
|
|
6328
6328
|
* ```ts
|
|
6329
6329
|
* import { Effect } from "effect"
|
|
@@ -6349,7 +6349,7 @@ export const runSyncWith = internal.runSyncWith;
|
|
|
6349
6349
|
* // }
|
|
6350
6350
|
* ```
|
|
6351
6351
|
*
|
|
6352
|
-
* **Example** (
|
|
6352
|
+
* **Example** (Capturing async work as a Die cause)
|
|
6353
6353
|
*
|
|
6354
6354
|
* ```ts
|
|
6355
6355
|
* import { Effect } from "effect"
|
|
@@ -6378,7 +6378,7 @@ export const runSyncExit = internal.runSyncExit;
|
|
|
6378
6378
|
/**
|
|
6379
6379
|
* Runs an effect synchronously with provided services, returning an Exit result.
|
|
6380
6380
|
*
|
|
6381
|
-
* **Example** (
|
|
6381
|
+
* **Example** (Running synchronously with services as Exit)
|
|
6382
6382
|
*
|
|
6383
6383
|
* ```ts
|
|
6384
6384
|
* import { Context, Effect, Exit } from "effect"
|
|
@@ -6420,7 +6420,7 @@ export const runSyncExitWith = internal.runSyncExitWith;
|
|
|
6420
6420
|
*
|
|
6421
6421
|
* `Effect.fnUntraced` also acts as a `pipe` function, so you can append transforms after the body.
|
|
6422
6422
|
*
|
|
6423
|
-
* **Example** (
|
|
6423
|
+
* **Example** (Defining untraced effect functions)
|
|
6424
6424
|
*
|
|
6425
6425
|
* ```ts
|
|
6426
6426
|
* import { Console, Effect } from "effect"
|
|
@@ -6442,7 +6442,7 @@ export const fnUntraced = internal.fnUntraced;
|
|
|
6442
6442
|
*
|
|
6443
6443
|
* Pipeable functions run after the body and can transform the resulting Effect.
|
|
6444
6444
|
*
|
|
6445
|
-
* **Example** (
|
|
6445
|
+
* **Example** (Defining traced effect functions)
|
|
6446
6446
|
*
|
|
6447
6447
|
* ```ts
|
|
6448
6448
|
* import { Console, Effect } from "effect"
|
|
@@ -6473,7 +6473,7 @@ export const fn = internal.fn;
|
|
|
6473
6473
|
* Retrieves the `Clock` service from the context and provides it to the
|
|
6474
6474
|
* specified effectful function.
|
|
6475
6475
|
*
|
|
6476
|
-
* **Example** (
|
|
6476
|
+
* **Example** (Accessing the Clock service)
|
|
6477
6477
|
*
|
|
6478
6478
|
* ```ts
|
|
6479
6479
|
* import { Console, Effect } from "effect"
|
|
@@ -6503,7 +6503,7 @@ export const clockWith = internal.clockWith;
|
|
|
6503
6503
|
* If no level is provided, the logger uses the fiber's current log level and
|
|
6504
6504
|
* extracts any `Cause` values from the message list.
|
|
6505
6505
|
*
|
|
6506
|
-
* **Example** (
|
|
6506
|
+
* **Example** (Logging at a dynamic level)
|
|
6507
6507
|
*
|
|
6508
6508
|
* ```ts
|
|
6509
6509
|
* import { Effect } from "effect"
|
|
@@ -6522,7 +6522,7 @@ export const logWithLevel = internal.logWithLevel;
|
|
|
6522
6522
|
/**
|
|
6523
6523
|
* Logs one or more messages using the default log level.
|
|
6524
6524
|
*
|
|
6525
|
-
* **Example** (
|
|
6525
|
+
* **Example** (Logging at the default level)
|
|
6526
6526
|
*
|
|
6527
6527
|
* ```ts
|
|
6528
6528
|
* import { Effect } from "effect"
|
|
@@ -6550,7 +6550,7 @@ export const log = /*#__PURE__*/internal.logWithLevel();
|
|
|
6550
6550
|
/**
|
|
6551
6551
|
* Logs one or more messages at the FATAL level.
|
|
6552
6552
|
*
|
|
6553
|
-
* **Example** (
|
|
6553
|
+
* **Example** (Logging fatal messages)
|
|
6554
6554
|
*
|
|
6555
6555
|
* ```ts
|
|
6556
6556
|
* import { Effect } from "effect"
|
|
@@ -6579,7 +6579,7 @@ export const logFatal = /*#__PURE__*/internal.logWithLevel("Fatal");
|
|
|
6579
6579
|
/**
|
|
6580
6580
|
* Logs one or more messages at the WARNING level.
|
|
6581
6581
|
*
|
|
6582
|
-
* **Example** (
|
|
6582
|
+
* **Example** (Logging warnings)
|
|
6583
6583
|
*
|
|
6584
6584
|
* ```ts
|
|
6585
6585
|
* import { Effect } from "effect"
|
|
@@ -6609,7 +6609,7 @@ export const logWarning = /*#__PURE__*/internal.logWithLevel("Warn");
|
|
|
6609
6609
|
/**
|
|
6610
6610
|
* Logs one or more messages at the ERROR level.
|
|
6611
6611
|
*
|
|
6612
|
-
* **Example** (
|
|
6612
|
+
* **Example** (Logging errors)
|
|
6613
6613
|
*
|
|
6614
6614
|
* ```ts
|
|
6615
6615
|
* import { Effect } from "effect"
|
|
@@ -6642,7 +6642,7 @@ export const logError = /*#__PURE__*/internal.logWithLevel("Error");
|
|
|
6642
6642
|
/**
|
|
6643
6643
|
* Logs one or more messages at the INFO level.
|
|
6644
6644
|
*
|
|
6645
|
-
* **Example** (
|
|
6645
|
+
* **Example** (Logging information)
|
|
6646
6646
|
*
|
|
6647
6647
|
* ```ts
|
|
6648
6648
|
* import { Effect } from "effect"
|
|
@@ -6670,7 +6670,7 @@ export const logInfo = /*#__PURE__*/internal.logWithLevel("Info");
|
|
|
6670
6670
|
/**
|
|
6671
6671
|
* Logs one or more messages at the DEBUG level.
|
|
6672
6672
|
*
|
|
6673
|
-
* **Example** (
|
|
6673
|
+
* **Example** (Logging debug messages)
|
|
6674
6674
|
*
|
|
6675
6675
|
* ```ts
|
|
6676
6676
|
* import { Effect } from "effect"
|
|
@@ -6699,7 +6699,7 @@ export const logDebug = /*#__PURE__*/internal.logWithLevel("Debug");
|
|
|
6699
6699
|
/**
|
|
6700
6700
|
* Logs one or more messages at the TRACE level.
|
|
6701
6701
|
*
|
|
6702
|
-
* **Example** (
|
|
6702
|
+
* **Example** (Logging trace messages)
|
|
6703
6703
|
*
|
|
6704
6704
|
* ```ts
|
|
6705
6705
|
* import { Effect } from "effect"
|
|
@@ -6731,7 +6731,7 @@ export const logTrace = /*#__PURE__*/internal.logWithLevel("Trace");
|
|
|
6731
6731
|
/**
|
|
6732
6732
|
* Adds a logger to the set of loggers which will output logs for this effect.
|
|
6733
6733
|
*
|
|
6734
|
-
* **Example** (
|
|
6734
|
+
* **Example** (Adding a logger to an effect)
|
|
6735
6735
|
*
|
|
6736
6736
|
* ```ts
|
|
6737
6737
|
* import { Effect, Logger } from "effect"
|
|
@@ -6760,7 +6760,7 @@ export const withLogger = /*#__PURE__*/dual(2, (effect, logger) => internal.upda
|
|
|
6760
6760
|
/**
|
|
6761
6761
|
* Adds an annotation to each log line in this effect.
|
|
6762
6762
|
*
|
|
6763
|
-
* **Example** (
|
|
6763
|
+
* **Example** (Adding log annotations)
|
|
6764
6764
|
*
|
|
6765
6765
|
* ```ts
|
|
6766
6766
|
* import { Effect } from "effect"
|
|
@@ -6805,7 +6805,7 @@ export const annotateLogs = /*#__PURE__*/dual(args => isEffect(args[0]), (effect
|
|
|
6805
6805
|
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
6806
6806
|
* restores the previous annotations when the scope closes.
|
|
6807
6807
|
*
|
|
6808
|
-
* **Example** (
|
|
6808
|
+
* **Example** (Adding scoped log annotations)
|
|
6809
6809
|
*
|
|
6810
6810
|
* ```ts
|
|
6811
6811
|
* import { Effect } from "effect"
|
|
@@ -6828,7 +6828,7 @@ export const annotateLogsScoped = internal.annotateLogsScoped;
|
|
|
6828
6828
|
/**
|
|
6829
6829
|
* Adds a span to each log line in this effect.
|
|
6830
6830
|
*
|
|
6831
|
-
* **Example** (
|
|
6831
|
+
* **Example** (Adding a log span)
|
|
6832
6832
|
*
|
|
6833
6833
|
* ```ts
|
|
6834
6834
|
* import { Effect } from "effect"
|
|
@@ -6869,7 +6869,7 @@ export const withLogSpan = /*#__PURE__*/dual(2, (effect, label) => internal.flat
|
|
|
6869
6869
|
* Also accepts an optional function which can be used to map the `Exit` value
|
|
6870
6870
|
* of the `Effect` into a valid `Input` for the `Metric`.
|
|
6871
6871
|
*
|
|
6872
|
-
* **Example** (
|
|
6872
|
+
* **Example** (Incrementing a metric for each execution)
|
|
6873
6873
|
*
|
|
6874
6874
|
* ```ts
|
|
6875
6875
|
* import { Effect, Metric } from "effect"
|
|
@@ -6889,7 +6889,7 @@ export const withLogSpan = /*#__PURE__*/dual(2, (effect, label) => internal.flat
|
|
|
6889
6889
|
* )
|
|
6890
6890
|
* ```
|
|
6891
6891
|
*
|
|
6892
|
-
* **Example** (
|
|
6892
|
+
* **Example** (Mapping exits before updating a metric)
|
|
6893
6893
|
*
|
|
6894
6894
|
* ```ts
|
|
6895
6895
|
* import { Effect, Exit, Metric } from "effect"
|
|
@@ -6924,7 +6924,7 @@ export const track = /*#__PURE__*/dual(args => isEffect(args[0]), (self, metric,
|
|
|
6924
6924
|
* Also accepts an optional function which can be used to map the success value
|
|
6925
6925
|
* of the `Effect` into a valid `Input` for the `Metric`.
|
|
6926
6926
|
*
|
|
6927
|
-
* **Example** (
|
|
6927
|
+
* **Example** (Counting successful results)
|
|
6928
6928
|
*
|
|
6929
6929
|
* ```ts
|
|
6930
6930
|
* import { Effect, Metric } from "effect"
|
|
@@ -6943,7 +6943,7 @@ export const track = /*#__PURE__*/dual(args => isEffect(args[0]), (self, metric,
|
|
|
6943
6943
|
* )
|
|
6944
6944
|
* ```
|
|
6945
6945
|
*
|
|
6946
|
-
* **Example** (
|
|
6946
|
+
* **Example** (Mapping successes before tracking)
|
|
6947
6947
|
*
|
|
6948
6948
|
* ```ts
|
|
6949
6949
|
* import { Effect, Metric } from "effect"
|
|
@@ -6975,7 +6975,7 @@ export const trackSuccesses = /*#__PURE__*/dual(args => isEffect(args[0]), (self
|
|
|
6975
6975
|
* Also accepts an optional function which can be used to map the error value
|
|
6976
6976
|
* of the `Effect` into a valid `Input` for the `Metric`.
|
|
6977
6977
|
*
|
|
6978
|
-
* **Example** (
|
|
6978
|
+
* **Example** (Counting expected failures)
|
|
6979
6979
|
*
|
|
6980
6980
|
* ```ts
|
|
6981
6981
|
* import { Effect, Metric } from "effect"
|
|
@@ -6994,7 +6994,7 @@ export const trackSuccesses = /*#__PURE__*/dual(args => isEffect(args[0]), (self
|
|
|
6994
6994
|
* )
|
|
6995
6995
|
* ```
|
|
6996
6996
|
*
|
|
6997
|
-
* **Example** (
|
|
6997
|
+
* **Example** (Mapping errors before tracking)
|
|
6998
6998
|
*
|
|
6999
6999
|
* ```ts
|
|
7000
7000
|
* import { Data, Effect, Metric } from "effect"
|
|
@@ -7028,7 +7028,7 @@ export const trackErrors = /*#__PURE__*/dual(args => isEffect(args[0]), (self, m
|
|
|
7028
7028
|
* Also accepts an optional function which can be used to map the defect value
|
|
7029
7029
|
* of the `Effect` into a valid `Input` for the `Metric`.
|
|
7030
7030
|
*
|
|
7031
|
-
* **Example** (
|
|
7031
|
+
* **Example** (Counting defects)
|
|
7032
7032
|
*
|
|
7033
7033
|
* ```ts
|
|
7034
7034
|
* import { Effect, Metric } from "effect"
|
|
@@ -7047,7 +7047,7 @@ export const trackErrors = /*#__PURE__*/dual(args => isEffect(args[0]), (self, m
|
|
|
7047
7047
|
* )
|
|
7048
7048
|
* ```
|
|
7049
7049
|
*
|
|
7050
|
-
* **Example** (
|
|
7050
|
+
* **Example** (Mapping defects before tracking)
|
|
7051
7051
|
*
|
|
7052
7052
|
* ```ts
|
|
7053
7053
|
* import { Effect, Metric } from "effect"
|
|
@@ -7083,7 +7083,7 @@ export const trackDefects = /*#__PURE__*/dual(args => isEffect(args[0]), (self,
|
|
|
7083
7083
|
* that the wrapped `Effect` took to complete into a valid `Input` for the
|
|
7084
7084
|
* `Metric`.
|
|
7085
7085
|
*
|
|
7086
|
-
* **Example** (
|
|
7086
|
+
* **Example** (Recording execution duration)
|
|
7087
7087
|
*
|
|
7088
7088
|
* ```ts
|
|
7089
7089
|
* import { Effect, Metric } from "effect"
|
|
@@ -7100,7 +7100,7 @@ export const trackDefects = /*#__PURE__*/dual(args => isEffect(args[0]), (self,
|
|
|
7100
7100
|
* )
|
|
7101
7101
|
* ```
|
|
7102
7102
|
*
|
|
7103
|
-
* **Example** (
|
|
7103
|
+
* **Example** (Mapping duration before tracking)
|
|
7104
7104
|
*
|
|
7105
7105
|
* ```ts
|
|
7106
7106
|
* import { Duration, Effect, Metric } from "effect"
|
|
@@ -7139,7 +7139,7 @@ export const trackDuration = /*#__PURE__*/dual(args => isEffect(args[0]), (self,
|
|
|
7139
7139
|
* - a journal that stores any non committed change to TxRef values
|
|
7140
7140
|
* - a retry flag to know if the transaction should be retried
|
|
7141
7141
|
*
|
|
7142
|
-
* **Example** (
|
|
7142
|
+
* **Example** (Building transactions)
|
|
7143
7143
|
*
|
|
7144
7144
|
* ```ts
|
|
7145
7145
|
* import { Effect } from "effect"
|
|
@@ -7174,7 +7174,7 @@ export class Transaction extends /*#__PURE__*/Context.Service()("effect/Effect/T
|
|
|
7174
7174
|
* The outermost `tx` call creates the transaction boundary and commits or rolls back the full
|
|
7175
7175
|
* composed transaction.
|
|
7176
7176
|
*
|
|
7177
|
-
* **Example** (
|
|
7177
|
+
* **Example** (Running a transaction)
|
|
7178
7178
|
*
|
|
7179
7179
|
* ```ts
|
|
7180
7180
|
* import { Effect, TxRef } from "effect"
|
|
@@ -7283,7 +7283,7 @@ function clearTransaction(state) {
|
|
|
7283
7283
|
* @category Transactions
|
|
7284
7284
|
* @since 4.0.0
|
|
7285
7285
|
*
|
|
7286
|
-
* **Example** (
|
|
7286
|
+
* **Example** (Retrying transactions)
|
|
7287
7287
|
*
|
|
7288
7288
|
* ```ts
|
|
7289
7289
|
* import { Effect, TxRef } from "effect"
|
|
@@ -7328,7 +7328,7 @@ export const txRetry = /*#__PURE__*/flatMap(Transaction, state => {
|
|
|
7328
7328
|
* callback errors and `onSyncError` to turn synchronous throws into typed
|
|
7329
7329
|
* failures; otherwise synchronous throws become defects.
|
|
7330
7330
|
*
|
|
7331
|
-
* **Example** (
|
|
7331
|
+
* **Example** (Converting callbacks to effects)
|
|
7332
7332
|
*
|
|
7333
7333
|
* ```ts
|
|
7334
7334
|
* import { Effect } from "effect"
|
|
@@ -7344,7 +7344,7 @@ export const txRetry = /*#__PURE__*/flatMap(Transaction, state => {
|
|
|
7344
7344
|
* // Output: contents of package.json
|
|
7345
7345
|
* ```
|
|
7346
7346
|
*
|
|
7347
|
-
* **Example** (
|
|
7347
|
+
* **Example** (Mapping callback errors to typed failures)
|
|
7348
7348
|
*
|
|
7349
7349
|
* ```ts
|
|
7350
7350
|
* import { Effect } from "effect"
|
|
@@ -7386,7 +7386,7 @@ export const effectify = (fn, onError, onSyncError) => (...args) => callback(res
|
|
|
7386
7386
|
* This function provides compile-time type checking to ensure that the success
|
|
7387
7387
|
* value of an effect conforms to a specific type constraint.
|
|
7388
7388
|
*
|
|
7389
|
-
* **Example** (
|
|
7389
|
+
* **Example** (Constraining the success type)
|
|
7390
7390
|
*
|
|
7391
7391
|
* ```ts
|
|
7392
7392
|
* import { Effect } from "effect"
|
|
@@ -7413,7 +7413,7 @@ export const satisfiesSuccessType = () => effect => effect;
|
|
|
7413
7413
|
* This function provides compile-time type checking to ensure that the error
|
|
7414
7414
|
* type of an effect conforms to a specific type constraint.
|
|
7415
7415
|
*
|
|
7416
|
-
* **Example** (
|
|
7416
|
+
* **Example** (Constraining the error type)
|
|
7417
7417
|
*
|
|
7418
7418
|
* ```ts
|
|
7419
7419
|
* import { Data, Effect } from "effect"
|
|
@@ -7442,7 +7442,7 @@ export const satisfiesErrorType = () => effect => effect;
|
|
|
7442
7442
|
* This function provides compile-time type checking to ensure that the
|
|
7443
7443
|
* requirements (context) type of an effect conforms to a specific type constraint.
|
|
7444
7444
|
*
|
|
7445
|
-
* **Example** (
|
|
7445
|
+
* **Example** (Constraining the services type)
|
|
7446
7446
|
*
|
|
7447
7447
|
* ```ts
|
|
7448
7448
|
* import { Effect } from "effect"
|
|
@@ -7479,7 +7479,7 @@ export const satisfiesServicesType = () => effect => effect;
|
|
|
7479
7479
|
* - For **Failure effects**: Returns the failure as-is without applying the mapping
|
|
7480
7480
|
* - For **Pending effects**: Falls back to the regular `map` behavior
|
|
7481
7481
|
*
|
|
7482
|
-
* **Example** (
|
|
7482
|
+
* **Example** (Mapping already completed effects)
|
|
7483
7483
|
*
|
|
7484
7484
|
* ```ts
|
|
7485
7485
|
* import { Effect } from "effect"
|
|
@@ -7513,7 +7513,7 @@ export const mapEager = internal.mapEager;
|
|
|
7513
7513
|
* - For **Failure effects**: Applies the mapping function immediately to the error
|
|
7514
7514
|
* - For **Pending effects**: Falls back to the regular `mapError` behavior
|
|
7515
7515
|
*
|
|
7516
|
-
* **Example** (
|
|
7516
|
+
* **Example** (Mapping errors eagerly when possible)
|
|
7517
7517
|
*
|
|
7518
7518
|
* ```ts
|
|
7519
7519
|
* import { Effect } from "effect"
|
|
@@ -7550,7 +7550,7 @@ export const mapErrorEager = internal.mapErrorEager;
|
|
|
7550
7550
|
* - For **Failure effects**: Applies the `onFailure` function immediately to the error
|
|
7551
7551
|
* - For **Pending effects**: Falls back to the regular `mapBoth` behavior
|
|
7552
7552
|
*
|
|
7553
|
-
* **Example** (
|
|
7553
|
+
* **Example** (Mapping both channels eagerly when possible)
|
|
7554
7554
|
*
|
|
7555
7555
|
* ```ts
|
|
7556
7556
|
* import { Effect } from "effect"
|
|
@@ -7589,7 +7589,7 @@ export const mapBothEager = internal.mapBothEager;
|
|
|
7589
7589
|
* - For **Failure effects**: Returns the failure as-is without applying the flatMap
|
|
7590
7590
|
* - For **Pending effects**: Falls back to the regular `flatMap` behavior
|
|
7591
7591
|
*
|
|
7592
|
-
* **Example** (
|
|
7592
|
+
* **Example** (Flat mapping eagerly when possible)
|
|
7593
7593
|
*
|
|
7594
7594
|
* ```ts
|
|
7595
7595
|
* import { Effect } from "effect"
|
|
@@ -7626,7 +7626,7 @@ export const flatMapEager = internal.flatMapEager;
|
|
|
7626
7626
|
* - For **Failure effects**: Applies the catch function immediately to the error
|
|
7627
7627
|
* - For **Pending effects**: Falls back to the regular `catch` behavior
|
|
7628
7628
|
*
|
|
7629
|
-
* **Example** (
|
|
7629
|
+
* **Example** (Catching failures eagerly when possible)
|
|
7630
7630
|
*
|
|
7631
7631
|
* ```ts
|
|
7632
7632
|
* import { Effect } from "effect"
|
|
@@ -7663,7 +7663,7 @@ export const catchEager = internal.catchEager;
|
|
|
7663
7663
|
* Executes generator functions eagerly when all yielded effects are synchronous,
|
|
7664
7664
|
* stopping at the first async effect and deferring to normal execution.
|
|
7665
7665
|
*
|
|
7666
|
-
* **Example** (
|
|
7666
|
+
* **Example** (Defining eager untraced effect functions)
|
|
7667
7667
|
*
|
|
7668
7668
|
* ```ts
|
|
7669
7669
|
* import { Effect } from "effect"
|