effect 4.0.0-beta.83 → 4.0.0-beta.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +64 -64
- package/dist/Array.js +26 -26
- package/dist/Cache.d.ts +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cause.d.ts +68 -68
- package/dist/Cause.js +47 -47
- package/dist/Channel.d.ts +5 -5
- package/dist/Channel.js +3 -3
- package/dist/Clock.d.ts +1 -1
- package/dist/Clock.js +1 -1
- package/dist/Combiner.d.ts +9 -9
- package/dist/Combiner.js +8 -8
- package/dist/Config.d.ts +15 -94
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +22 -70
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +58 -74
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +66 -41
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +1 -1
- package/dist/Console.js +1 -1
- package/dist/Data.d.ts +15 -15
- package/dist/Data.js +3 -3
- package/dist/DateTime.d.ts +6 -6
- package/dist/DateTime.js +2 -2
- package/dist/Duration.d.ts +3 -3
- package/dist/Duration.js +3 -3
- package/dist/Effect.d.ts +84 -45
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +72 -33
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +7 -7
- package/dist/Equal.js +5 -5
- package/dist/Equivalence.d.ts +17 -17
- package/dist/Equivalence.js +13 -13
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.js +3 -3
- package/dist/Formatter.d.ts +5 -5
- package/dist/Formatter.js +4 -4
- package/dist/Function.d.ts +10 -10
- package/dist/Function.js +3 -3
- package/dist/HashMap.d.ts +3 -3
- package/dist/HashMap.js +1 -1
- package/dist/Iterable.d.ts +6 -6
- package/dist/Iterable.js +2 -2
- package/dist/JsonPatch.d.ts +2 -2
- package/dist/Layer.d.ts +1 -1
- package/dist/Layer.js +1 -1
- package/dist/Logger.d.ts +1 -1
- package/dist/Logger.js +1 -1
- package/dist/Match.d.ts +8 -8
- package/dist/Match.js +8 -8
- package/dist/Metric.d.ts +3 -3
- package/dist/Metric.js +3 -3
- package/dist/Optic.d.ts +30 -30
- package/dist/Optic.js +12 -12
- package/dist/Option.d.ts +7 -7
- package/dist/Option.js +7 -7
- package/dist/Order.d.ts +23 -23
- package/dist/Order.js +20 -20
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.js +1 -1
- package/dist/Predicate.d.ts +88 -88
- package/dist/Predicate.js +47 -47
- package/dist/PubSub.d.ts +3 -3
- package/dist/PubSub.js +3 -3
- package/dist/Reducer.d.ts +1 -1
- package/dist/Reducer.js +1 -1
- package/dist/Result.d.ts +18 -18
- package/dist/Result.js +8 -8
- package/dist/Runtime.d.ts +1 -1
- package/dist/Runtime.js +1 -1
- package/dist/Schema.d.ts +265 -120
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +285 -116
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +13 -9
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +48 -48
- package/dist/SchemaGetter.js +44 -44
- package/dist/SchemaIssue.d.ts +3 -3
- package/dist/SchemaIssue.js +3 -3
- package/dist/SchemaParser.d.ts +122 -22
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +186 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +96 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +20 -20
- package/dist/SchemaTransformation.js +18 -18
- package/dist/Stream.d.ts +3 -3
- package/dist/Stream.js +2 -2
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +1 -1
- package/dist/String.js +1 -1
- package/dist/Struct.d.ts +1 -1
- package/dist/Struct.js +1 -1
- package/dist/Types.d.ts +13 -13
- package/dist/internal/effect.js +23 -10
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/cause.d.ts +2 -0
- package/dist/internal/schema/cause.d.ts.map +1 -0
- package/dist/internal/schema/cause.js +24 -0
- package/dist/internal/schema/cause.js.map +1 -0
- package/dist/internal/schema/schema.d.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +21 -8
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +3 -3
- package/dist/testing/TestSchema.js +1 -1
- package/dist/unstable/ai/AiError.d.ts +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/cli/Prompt.js +2 -2
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +3 -4
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +15 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +1 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +65 -65
- package/src/Cache.ts +1 -1
- package/src/Cause.ts +68 -68
- package/src/Channel.ts +5 -5
- package/src/Clock.ts +1 -1
- package/src/Combiner.ts +9 -9
- package/src/Config.ts +40 -108
- package/src/ConfigProvider.ts +139 -100
- package/src/Console.ts +1 -1
- package/src/Data.ts +15 -15
- package/src/DateTime.ts +6 -6
- package/src/Duration.ts +3 -3
- package/src/Effect.ts +89 -45
- package/src/Equal.ts +7 -7
- package/src/Equivalence.ts +17 -17
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +5 -5
- package/src/Function.ts +10 -10
- package/src/HashMap.ts +3 -3
- package/src/Iterable.ts +6 -6
- package/src/JsonPatch.ts +2 -2
- package/src/Layer.ts +1 -1
- package/src/Logger.ts +1 -1
- package/src/Match.ts +8 -8
- package/src/Metric.ts +3 -3
- package/src/Optic.ts +30 -30
- package/src/Option.ts +7 -7
- package/src/Order.ts +23 -23
- package/src/Pool.ts +1 -1
- package/src/Predicate.ts +88 -88
- package/src/PubSub.ts +3 -3
- package/src/Reducer.ts +1 -1
- package/src/Result.ts +20 -20
- package/src/Runtime.ts +1 -1
- package/src/Schema.ts +314 -131
- package/src/SchemaAST.ts +20 -11
- package/src/SchemaGetter.ts +48 -48
- package/src/SchemaIssue.ts +3 -3
- package/src/SchemaParser.ts +197 -58
- package/src/SchemaRepresentation.ts +73 -3
- package/src/SchemaTransformation.ts +20 -20
- package/src/Stream.ts +4 -4
- package/src/String.ts +1 -1
- package/src/Struct.ts +1 -1
- package/src/Types.ts +13 -13
- package/src/internal/effect.ts +29 -10
- package/src/internal/schema/cause.ts +26 -0
- package/src/internal/schema/schema.ts +36 -10
- package/src/testing/TestSchema.ts +3 -3
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/cli/Prompt.ts +1 -1
- package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
- package/src/unstable/rpc/Rpc.ts +1 -1
- package/src/unstable/rpc/RpcGroup.ts +3 -4
- package/src/unstable/sql/SqlResolver.ts +15 -2
- package/src/unstable/workflow/Activity.ts +2 -0
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
package/dist/Data.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export declare namespace TaggedEnum {
|
|
|
168
168
|
* `this["A"]`, `this["B"]`, etc. as placeholders for the generics. The
|
|
169
169
|
* `Count` parameter declares how many generics are used (up to 4).
|
|
170
170
|
*
|
|
171
|
-
* **Example** (
|
|
171
|
+
* **Example** (Defining a generic tagged enum)
|
|
172
172
|
*
|
|
173
173
|
* ```ts
|
|
174
174
|
* import { Data } from "effect"
|
|
@@ -289,7 +289,7 @@ export declare namespace TaggedEnum {
|
|
|
289
289
|
*
|
|
290
290
|
* Use to select one full tagged-union variant by its `_tag` value.
|
|
291
291
|
*
|
|
292
|
-
* **Example** (
|
|
292
|
+
* **Example** (Extracting a variant type)
|
|
293
293
|
*
|
|
294
294
|
* ```ts
|
|
295
295
|
* import type { Data } from "effect"
|
|
@@ -463,7 +463,7 @@ export declare namespace TaggedEnum {
|
|
|
463
463
|
* on the tag being globally unique and the value being produced by your
|
|
464
464
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
465
465
|
*
|
|
466
|
-
* **Example** (
|
|
466
|
+
* **Example** (Creating and matching tagged enum values)
|
|
467
467
|
*
|
|
468
468
|
* ```ts
|
|
469
469
|
* import { Data } from "effect"
|
|
@@ -488,7 +488,7 @@ export declare namespace TaggedEnum {
|
|
|
488
488
|
* console.log(msg) // "/missing not found"
|
|
489
489
|
* ```
|
|
490
490
|
*
|
|
491
|
-
* **Example** (
|
|
491
|
+
* **Example** (Defining a generic tagged enum)
|
|
492
492
|
*
|
|
493
493
|
* ```ts
|
|
494
494
|
* import { Data } from "effect"
|
|
@@ -536,7 +536,7 @@ export declare const taggedEnum: {
|
|
|
536
536
|
* on the tag being globally unique and the value being produced by your
|
|
537
537
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
538
538
|
*
|
|
539
|
-
* **Example** (
|
|
539
|
+
* **Example** (Creating and matching tagged enum values)
|
|
540
540
|
*
|
|
541
541
|
* ```ts
|
|
542
542
|
* import { Data } from "effect"
|
|
@@ -561,7 +561,7 @@ export declare const taggedEnum: {
|
|
|
561
561
|
* console.log(msg) // "/missing not found"
|
|
562
562
|
* ```
|
|
563
563
|
*
|
|
564
|
-
* **Example** (
|
|
564
|
+
* **Example** (Defining a generic tagged enum)
|
|
565
565
|
*
|
|
566
566
|
* ```ts
|
|
567
567
|
* import { Data } from "effect"
|
|
@@ -613,7 +613,7 @@ export declare const taggedEnum: {
|
|
|
613
613
|
* on the tag being globally unique and the value being produced by your
|
|
614
614
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
615
615
|
*
|
|
616
|
-
* **Example** (
|
|
616
|
+
* **Example** (Creating and matching tagged enum values)
|
|
617
617
|
*
|
|
618
618
|
* ```ts
|
|
619
619
|
* import { Data } from "effect"
|
|
@@ -638,7 +638,7 @@ export declare const taggedEnum: {
|
|
|
638
638
|
* console.log(msg) // "/missing not found"
|
|
639
639
|
* ```
|
|
640
640
|
*
|
|
641
|
-
* **Example** (
|
|
641
|
+
* **Example** (Defining a generic tagged enum)
|
|
642
642
|
*
|
|
643
643
|
* ```ts
|
|
644
644
|
* import { Data } from "effect"
|
|
@@ -690,7 +690,7 @@ export declare const taggedEnum: {
|
|
|
690
690
|
* on the tag being globally unique and the value being produced by your
|
|
691
691
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
692
692
|
*
|
|
693
|
-
* **Example** (
|
|
693
|
+
* **Example** (Creating and matching tagged enum values)
|
|
694
694
|
*
|
|
695
695
|
* ```ts
|
|
696
696
|
* import { Data } from "effect"
|
|
@@ -715,7 +715,7 @@ export declare const taggedEnum: {
|
|
|
715
715
|
* console.log(msg) // "/missing not found"
|
|
716
716
|
* ```
|
|
717
717
|
*
|
|
718
|
-
* **Example** (
|
|
718
|
+
* **Example** (Defining a generic tagged enum)
|
|
719
719
|
*
|
|
720
720
|
* ```ts
|
|
721
721
|
* import { Data } from "effect"
|
|
@@ -767,7 +767,7 @@ export declare const taggedEnum: {
|
|
|
767
767
|
* on the tag being globally unique and the value being produced by your
|
|
768
768
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
769
769
|
*
|
|
770
|
-
* **Example** (
|
|
770
|
+
* **Example** (Creating and matching tagged enum values)
|
|
771
771
|
*
|
|
772
772
|
* ```ts
|
|
773
773
|
* import { Data } from "effect"
|
|
@@ -792,7 +792,7 @@ export declare const taggedEnum: {
|
|
|
792
792
|
* console.log(msg) // "/missing not found"
|
|
793
793
|
* ```
|
|
794
794
|
*
|
|
795
|
-
* **Example** (
|
|
795
|
+
* **Example** (Defining a generic tagged enum)
|
|
796
796
|
*
|
|
797
797
|
* ```ts
|
|
798
798
|
* import { Data } from "effect"
|
|
@@ -844,7 +844,7 @@ export declare const taggedEnum: {
|
|
|
844
844
|
* on the tag being globally unique and the value being produced by your
|
|
845
845
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
846
846
|
*
|
|
847
|
-
* **Example** (
|
|
847
|
+
* **Example** (Creating and matching tagged enum values)
|
|
848
848
|
*
|
|
849
849
|
* ```ts
|
|
850
850
|
* import { Data } from "effect"
|
|
@@ -869,7 +869,7 @@ export declare const taggedEnum: {
|
|
|
869
869
|
* console.log(msg) // "/missing not found"
|
|
870
870
|
* ```
|
|
871
871
|
*
|
|
872
|
-
* **Example** (
|
|
872
|
+
* **Example** (Defining a generic tagged enum)
|
|
873
873
|
*
|
|
874
874
|
* ```ts
|
|
875
875
|
* import { Data } from "effect"
|
|
@@ -954,7 +954,7 @@ export declare const Error: new <A extends Record<string, any> = {}>(args: Types
|
|
|
954
954
|
* The `_tag` is excluded from the constructor argument. Yielding an instance
|
|
955
955
|
* inside `Effect.gen` fails the effect with this error.
|
|
956
956
|
*
|
|
957
|
-
* **Example** (
|
|
957
|
+
* **Example** (Recovering by tag)
|
|
958
958
|
*
|
|
959
959
|
* ```ts
|
|
960
960
|
* import { Data, Effect } from "effect"
|
package/dist/Data.js
CHANGED
|
@@ -101,7 +101,7 @@ export const TaggedClass = tag => class extends Class {
|
|
|
101
101
|
* on the tag being globally unique and the value being produced by your
|
|
102
102
|
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
103
103
|
*
|
|
104
|
-
* **Example** (
|
|
104
|
+
* **Example** (Creating and matching tagged enum values)
|
|
105
105
|
*
|
|
106
106
|
* ```ts
|
|
107
107
|
* import { Data } from "effect"
|
|
@@ -126,7 +126,7 @@ export const TaggedClass = tag => class extends Class {
|
|
|
126
126
|
* console.log(msg) // "/missing not found"
|
|
127
127
|
* ```
|
|
128
128
|
*
|
|
129
|
-
* **Example** (
|
|
129
|
+
* **Example** (Defining a generic tagged enum)
|
|
130
130
|
*
|
|
131
131
|
* ```ts
|
|
132
132
|
* import { Data } from "effect"
|
|
@@ -229,7 +229,7 @@ export const Error = core.Error;
|
|
|
229
229
|
* The `_tag` is excluded from the constructor argument. Yielding an instance
|
|
230
230
|
* inside `Effect.gen` fails the effect with this error.
|
|
231
231
|
*
|
|
232
|
-
* **Example** (
|
|
232
|
+
* **Example** (Recovering by tag)
|
|
233
233
|
*
|
|
234
234
|
* ```ts
|
|
235
235
|
* import { Data, Effect } from "effect"
|
package/dist/DateTime.d.ts
CHANGED
|
@@ -2974,7 +2974,7 @@ export declare const mapEpochMillis: {
|
|
|
2974
2974
|
* `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
|
|
2975
2975
|
* receive the UTC instant.
|
|
2976
2976
|
*
|
|
2977
|
-
* **Example** (
|
|
2977
|
+
* **Example** (Applying time zone adjusted Dates)
|
|
2978
2978
|
*
|
|
2979
2979
|
* ```ts
|
|
2980
2980
|
* import { DateTime } from "effect"
|
|
@@ -2999,7 +2999,7 @@ export declare const withDate: {
|
|
|
2999
2999
|
* `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
|
|
3000
3000
|
* receive the UTC instant.
|
|
3001
3001
|
*
|
|
3002
|
-
* **Example** (
|
|
3002
|
+
* **Example** (Applying time zone adjusted Dates)
|
|
3003
3003
|
*
|
|
3004
3004
|
* ```ts
|
|
3005
3005
|
* import { DateTime } from "effect"
|
|
@@ -3024,7 +3024,7 @@ export declare const withDate: {
|
|
|
3024
3024
|
* `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
|
|
3025
3025
|
* receive the UTC instant.
|
|
3026
3026
|
*
|
|
3027
|
-
* **Example** (
|
|
3027
|
+
* **Example** (Applying time zone adjusted Dates)
|
|
3028
3028
|
*
|
|
3029
3029
|
* ```ts
|
|
3030
3030
|
* import { DateTime } from "effect"
|
|
@@ -3049,7 +3049,7 @@ export declare const withDate: {
|
|
|
3049
3049
|
* This ignores any associated time zone. Use `DateTime.withDate` when the
|
|
3050
3050
|
* callback should receive the time-zone-adjusted wall-clock date.
|
|
3051
3051
|
*
|
|
3052
|
-
* **Example** (
|
|
3052
|
+
* **Example** (Applying UTC Dates)
|
|
3053
3053
|
*
|
|
3054
3054
|
* ```ts
|
|
3055
3055
|
* import { DateTime } from "effect"
|
|
@@ -3073,7 +3073,7 @@ export declare const withDateUtc: {
|
|
|
3073
3073
|
* This ignores any associated time zone. Use `DateTime.withDate` when the
|
|
3074
3074
|
* callback should receive the time-zone-adjusted wall-clock date.
|
|
3075
3075
|
*
|
|
3076
|
-
* **Example** (
|
|
3076
|
+
* **Example** (Applying UTC Dates)
|
|
3077
3077
|
*
|
|
3078
3078
|
* ```ts
|
|
3079
3079
|
* import { DateTime } from "effect"
|
|
@@ -3097,7 +3097,7 @@ export declare const withDateUtc: {
|
|
|
3097
3097
|
* This ignores any associated time zone. Use `DateTime.withDate` when the
|
|
3098
3098
|
* callback should receive the time-zone-adjusted wall-clock date.
|
|
3099
3099
|
*
|
|
3100
|
-
* **Example** (
|
|
3100
|
+
* **Example** (Applying UTC Dates)
|
|
3101
3101
|
*
|
|
3102
3102
|
* ```ts
|
|
3103
3103
|
* import { DateTime } from "effect"
|
package/dist/DateTime.js
CHANGED
|
@@ -1554,7 +1554,7 @@ export const mapEpochMillis = Internal.mapEpochMillis;
|
|
|
1554
1554
|
* `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
|
|
1555
1555
|
* receive the UTC instant.
|
|
1556
1556
|
*
|
|
1557
|
-
* **Example** (
|
|
1557
|
+
* **Example** (Applying time zone adjusted Dates)
|
|
1558
1558
|
*
|
|
1559
1559
|
* ```ts
|
|
1560
1560
|
* import { DateTime } from "effect"
|
|
@@ -1578,7 +1578,7 @@ export const withDate = Internal.withDate;
|
|
|
1578
1578
|
* This ignores any associated time zone. Use `DateTime.withDate` when the
|
|
1579
1579
|
* callback should receive the time-zone-adjusted wall-clock date.
|
|
1580
1580
|
*
|
|
1581
|
-
* **Example** (
|
|
1581
|
+
* **Example** (Applying UTC Dates)
|
|
1582
1582
|
*
|
|
1583
1583
|
* ```ts
|
|
1584
1584
|
* import { DateTime } from "effect"
|
package/dist/Duration.d.ts
CHANGED
|
@@ -304,7 +304,7 @@ export declare const negate: (self: Duration) => Duration;
|
|
|
304
304
|
/**
|
|
305
305
|
* A Duration representing zero time.
|
|
306
306
|
*
|
|
307
|
-
* **Example** (
|
|
307
|
+
* **Example** (Referencing the zero duration)
|
|
308
308
|
*
|
|
309
309
|
* ```ts
|
|
310
310
|
* import { Duration } from "effect"
|
|
@@ -319,7 +319,7 @@ export declare const zero: Duration;
|
|
|
319
319
|
/**
|
|
320
320
|
* A Duration representing infinite time.
|
|
321
321
|
*
|
|
322
|
-
* **Example** (
|
|
322
|
+
* **Example** (Referencing infinite duration)
|
|
323
323
|
*
|
|
324
324
|
* ```ts
|
|
325
325
|
* import { Duration } from "effect"
|
|
@@ -334,7 +334,7 @@ export declare const infinity: Duration;
|
|
|
334
334
|
/**
|
|
335
335
|
* A Duration representing negative infinite time.
|
|
336
336
|
*
|
|
337
|
-
* **Example** (
|
|
337
|
+
* **Example** (Referencing negative infinite duration)
|
|
338
338
|
*
|
|
339
339
|
* ```ts
|
|
340
340
|
* import { Duration } from "effect"
|
package/dist/Duration.js
CHANGED
|
@@ -424,7 +424,7 @@ export const negate = self => {
|
|
|
424
424
|
/**
|
|
425
425
|
* A Duration representing zero time.
|
|
426
426
|
*
|
|
427
|
-
* **Example** (
|
|
427
|
+
* **Example** (Referencing the zero duration)
|
|
428
428
|
*
|
|
429
429
|
* ```ts
|
|
430
430
|
* import { Duration } from "effect"
|
|
@@ -439,7 +439,7 @@ export const zero = /*#__PURE__*/make(0);
|
|
|
439
439
|
/**
|
|
440
440
|
* A Duration representing infinite time.
|
|
441
441
|
*
|
|
442
|
-
* **Example** (
|
|
442
|
+
* **Example** (Referencing infinite duration)
|
|
443
443
|
*
|
|
444
444
|
* ```ts
|
|
445
445
|
* import { Duration } from "effect"
|
|
@@ -454,7 +454,7 @@ export const infinity = /*#__PURE__*/make(Infinity);
|
|
|
454
454
|
/**
|
|
455
455
|
* A Duration representing negative infinite time.
|
|
456
456
|
*
|
|
457
|
-
* **Example** (
|
|
457
|
+
* **Example** (Referencing negative infinite duration)
|
|
458
458
|
*
|
|
459
459
|
* ```ts
|
|
460
460
|
* import { Duration } from "effect"
|
package/dist/Effect.d.ts
CHANGED
|
@@ -1150,8 +1150,8 @@ export declare const whileLoop: <A, E, R>(options: {
|
|
|
1150
1150
|
*/
|
|
1151
1151
|
export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Effect<A>;
|
|
1152
1152
|
/**
|
|
1153
|
-
* Creates an `Effect`
|
|
1154
|
-
*
|
|
1153
|
+
* Creates an `Effect` from an asynchronous computation that may throw or
|
|
1154
|
+
* reject, mapping failures into the error channel.
|
|
1155
1155
|
*
|
|
1156
1156
|
* **When to use**
|
|
1157
1157
|
*
|
|
@@ -1161,19 +1161,24 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
|
|
|
1161
1161
|
*
|
|
1162
1162
|
* **Details**
|
|
1163
1163
|
*
|
|
1164
|
-
*
|
|
1164
|
+
* The promise thunk is evaluated when the effect runs. If it returns a promise
|
|
1165
|
+
* that resolves, the resolved value becomes the success value. If the thunk
|
|
1166
|
+
* throws before returning a promise, or if the returned promise rejects, the
|
|
1167
|
+
* thrown or rejected value is mapped into the error channel.
|
|
1165
1168
|
*
|
|
1166
|
-
*
|
|
1169
|
+
* Passing the thunk directly maps failures to {@link Cause.UnknownError}.
|
|
1170
|
+
* Passing `{ try, catch }` uses `catch` to map failures to an error of type
|
|
1171
|
+
* `E`.
|
|
1167
1172
|
*
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
* function maps it to an error of type `E`.
|
|
1173
|
+
* The thunk receives an `AbortSignal` that is aborted if the effect is
|
|
1174
|
+
* interrupted. The underlying asynchronous operation only stops if it observes
|
|
1175
|
+
* that signal.
|
|
1172
1176
|
*
|
|
1173
|
-
*
|
|
1177
|
+
* **Gotchas**
|
|
1174
1178
|
*
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1179
|
+
* If `catch` throws while mapping the error, that thrown value is treated as a
|
|
1180
|
+
* defect. Return the error value you want in the error channel instead of
|
|
1181
|
+
* throwing it.
|
|
1177
1182
|
*
|
|
1178
1183
|
* **Example** (Wrapping a fetch request that may fail)
|
|
1179
1184
|
*
|
|
@@ -1982,7 +1987,7 @@ export declare const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Ef
|
|
|
1982
1987
|
* The error channel of the resulting effect is of type `never`, indicating that
|
|
1983
1988
|
* it cannot recover from this failure.
|
|
1984
1989
|
*
|
|
1985
|
-
* **Example** (Failing
|
|
1990
|
+
* **Example** (Failing on division by zero)
|
|
1986
1991
|
*
|
|
1987
1992
|
* ```ts
|
|
1988
1993
|
* import { Effect } from "effect"
|
|
@@ -2006,52 +2011,53 @@ export declare const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Ef
|
|
|
2006
2011
|
* @since 2.0.0
|
|
2007
2012
|
*/
|
|
2008
2013
|
export declare const die: (defect: unknown) => Effect<never>;
|
|
2009
|
-
declare const try_: <A, E>(options: {
|
|
2010
|
-
try: LazyArg<A>;
|
|
2011
|
-
catch: (error: unknown) => E;
|
|
2012
|
-
}) => Effect<A, E>;
|
|
2014
|
+
declare const try_: <A, E = Cause.UnknownError>(options: {
|
|
2015
|
+
readonly try: LazyArg<A>;
|
|
2016
|
+
readonly catch: (error: unknown) => E;
|
|
2017
|
+
} | LazyArg<A>) => Effect<A, E>;
|
|
2013
2018
|
export {
|
|
2014
2019
|
/**
|
|
2015
|
-
* Creates an `Effect`
|
|
2016
|
-
*
|
|
2020
|
+
* Creates an `Effect` from a synchronous computation that may throw, mapping
|
|
2021
|
+
* thrown values into the error channel.
|
|
2017
2022
|
*
|
|
2018
2023
|
* **When to use**
|
|
2019
2024
|
*
|
|
2020
2025
|
* Use when you need to perform synchronous operations that might throw, such
|
|
2021
|
-
* as parsing JSON, and
|
|
2026
|
+
* as parsing JSON, and want thrown exceptions captured as Effect errors.
|
|
2022
2027
|
*
|
|
2023
2028
|
* **Details**
|
|
2024
2029
|
*
|
|
2025
|
-
*
|
|
2030
|
+
* The thunk is evaluated when the effect runs. If it returns normally, the
|
|
2031
|
+
* returned value becomes the success value. If it throws, the thrown value is
|
|
2032
|
+
* mapped into the error channel.
|
|
2026
2033
|
*
|
|
2027
|
-
*
|
|
2034
|
+
* Passing the thunk directly maps failures to {@link Cause.UnknownError}.
|
|
2035
|
+
* Passing `{ try, catch }` uses `catch` to map failures to an error of type
|
|
2036
|
+
* `E`.
|
|
2028
2037
|
*
|
|
2029
|
-
*
|
|
2030
|
-
*
|
|
2031
|
-
*
|
|
2032
|
-
*
|
|
2038
|
+
* **Gotchas**
|
|
2039
|
+
*
|
|
2040
|
+
* If `catch` throws while mapping the error, that thrown value is treated as
|
|
2041
|
+
* a defect. Return the error value you want in the error channel instead of
|
|
2042
|
+
* throwing it.
|
|
2033
2043
|
*
|
|
2034
|
-
* **Example** (Parsing JSON
|
|
2044
|
+
* **Example** (Parsing JSON)
|
|
2035
2045
|
*
|
|
2036
2046
|
* ```ts
|
|
2037
2047
|
* import { Effect } from "effect"
|
|
2038
2048
|
*
|
|
2039
2049
|
* const parseJSON = (input: string) =>
|
|
2040
|
-
* Effect.try(
|
|
2041
|
-
* try: () => JSON.parse(input),
|
|
2042
|
-
* catch: (error) => error as Error
|
|
2043
|
-
* })
|
|
2050
|
+
* Effect.try(() => JSON.parse(input))
|
|
2044
2051
|
*
|
|
2045
2052
|
* // Success case
|
|
2046
2053
|
* Effect.runPromise(parseJSON("{\"name\": \"Alice\"}")).then(console.log)
|
|
2047
2054
|
* // Output: { name: "Alice" }
|
|
2048
2055
|
*
|
|
2049
|
-
* // Failure case
|
|
2056
|
+
* // Failure case maps the thrown value to UnknownError
|
|
2050
2057
|
* Effect.runPromiseExit(parseJSON("invalid json")).then(console.log)
|
|
2051
|
-
* // Output: Exit.failure with Error
|
|
2052
2058
|
* ```
|
|
2053
2059
|
*
|
|
2054
|
-
* **Example** (Mapping
|
|
2060
|
+
* **Example** (Mapping exceptions to a tagged error)
|
|
2055
2061
|
*
|
|
2056
2062
|
* ```ts
|
|
2057
2063
|
* import { Data, Effect } from "effect"
|
|
@@ -2192,6 +2198,39 @@ export declare const fromResult: <A, E>(result: Result.Result<A, E>) => Effect<A
|
|
|
2192
2198
|
* @since 4.0.0
|
|
2193
2199
|
*/
|
|
2194
2200
|
export declare const fromOption: <A>(option: Option<A>) => Effect<A, Cause.NoSuchElementError>;
|
|
2201
|
+
/**
|
|
2202
|
+
* Converts an `Option` of an `Effect` into an `Effect` of an `Option`.
|
|
2203
|
+
*
|
|
2204
|
+
* **When to use**
|
|
2205
|
+
*
|
|
2206
|
+
* Use when an effect should run only when an optional value is present, while
|
|
2207
|
+
* preserving absence as a successful `None`.
|
|
2208
|
+
*
|
|
2209
|
+
* **Details**
|
|
2210
|
+
*
|
|
2211
|
+
* - `None` becomes an effect that succeeds with `None`
|
|
2212
|
+
* - `Some(effect)` runs the inner effect and wraps its success value in `Some`
|
|
2213
|
+
* - Inner failures are preserved in the resulting effect
|
|
2214
|
+
*
|
|
2215
|
+
* **Example** (Transposing an Option of an Effect)
|
|
2216
|
+
*
|
|
2217
|
+
* ```ts
|
|
2218
|
+
* import { Effect, Option } from "effect"
|
|
2219
|
+
*
|
|
2220
|
+
* const some = Option.some(Effect.succeed(42))
|
|
2221
|
+
*
|
|
2222
|
+
* // ┌─── Effect<Option<number>, never, never>
|
|
2223
|
+
* // ▼
|
|
2224
|
+
* const program = Effect.transposeOption(some)
|
|
2225
|
+
*
|
|
2226
|
+
* Effect.runPromise(program).then(console.log)
|
|
2227
|
+
* // Output: { _id: 'Option', _tag: 'Some', value: 42 }
|
|
2228
|
+
* ```
|
|
2229
|
+
*
|
|
2230
|
+
* @category converting
|
|
2231
|
+
* @since 3.13.0
|
|
2232
|
+
*/
|
|
2233
|
+
export declare const transposeOption: <A = never, E = never, R = never>(self: Option<Effect<A, E, R>>) => Effect<Option<A>, E, R>;
|
|
2195
2234
|
/**
|
|
2196
2235
|
* Converts a nullable value to an `Effect`, failing with a `NoSuchElementError`
|
|
2197
2236
|
* when the value is `null` or `undefined`.
|
|
@@ -2238,7 +2277,7 @@ export declare const fromNullishOr: <A>(value: A) => Effect<NonNullable<A>, Caus
|
|
|
2238
2277
|
* Since effects are immutable, `flatMap` always returns a new effect instead of
|
|
2239
2278
|
* changing the original one.
|
|
2240
2279
|
*
|
|
2241
|
-
* **Example** (
|
|
2280
|
+
* **Example** (Choosing flatMap syntax variants)
|
|
2242
2281
|
*
|
|
2243
2282
|
* ```ts
|
|
2244
2283
|
* import { Effect, pipe } from "effect"
|
|
@@ -2305,7 +2344,7 @@ export declare const flatMap: {
|
|
|
2305
2344
|
* Since effects are immutable, `flatMap` always returns a new effect instead of
|
|
2306
2345
|
* changing the original one.
|
|
2307
2346
|
*
|
|
2308
|
-
* **Example** (
|
|
2347
|
+
* **Example** (Choosing flatMap syntax variants)
|
|
2309
2348
|
*
|
|
2310
2349
|
* ```ts
|
|
2311
2350
|
* import { Effect, pipe } from "effect"
|
|
@@ -2372,7 +2411,7 @@ export declare const flatMap: {
|
|
|
2372
2411
|
* Since effects are immutable, `flatMap` always returns a new effect instead of
|
|
2373
2412
|
* changing the original one.
|
|
2374
2413
|
*
|
|
2375
|
-
* **Example** (
|
|
2414
|
+
* **Example** (Choosing flatMap syntax variants)
|
|
2376
2415
|
*
|
|
2377
2416
|
* ```ts
|
|
2378
2417
|
* import { Effect, pipe } from "effect"
|
|
@@ -2460,7 +2499,7 @@ export declare const flatten: <A, E, R, E2, R2>(self: Effect<Effect<A, E, R>, E2
|
|
|
2460
2499
|
* Failures or requirements from either effect are preserved in the returned
|
|
2461
2500
|
* effect.
|
|
2462
2501
|
*
|
|
2463
|
-
* **Example** (
|
|
2502
|
+
* **Example** (Choosing andThen syntax variants)
|
|
2464
2503
|
*
|
|
2465
2504
|
* ```ts
|
|
2466
2505
|
* import { Effect, pipe } from "effect"
|
|
@@ -2536,7 +2575,7 @@ export declare const andThen: {
|
|
|
2536
2575
|
* Failures or requirements from either effect are preserved in the returned
|
|
2537
2576
|
* effect.
|
|
2538
2577
|
*
|
|
2539
|
-
* **Example** (
|
|
2578
|
+
* **Example** (Choosing andThen syntax variants)
|
|
2540
2579
|
*
|
|
2541
2580
|
* ```ts
|
|
2542
2581
|
* import { Effect, pipe } from "effect"
|
|
@@ -2612,7 +2651,7 @@ export declare const andThen: {
|
|
|
2612
2651
|
* Failures or requirements from either effect are preserved in the returned
|
|
2613
2652
|
* effect.
|
|
2614
2653
|
*
|
|
2615
|
-
* **Example** (
|
|
2654
|
+
* **Example** (Choosing andThen syntax variants)
|
|
2616
2655
|
*
|
|
2617
2656
|
* ```ts
|
|
2618
2657
|
* import { Effect, pipe } from "effect"
|
|
@@ -2688,7 +2727,7 @@ export declare const andThen: {
|
|
|
2688
2727
|
* Failures or requirements from either effect are preserved in the returned
|
|
2689
2728
|
* effect.
|
|
2690
2729
|
*
|
|
2691
|
-
* **Example** (
|
|
2730
|
+
* **Example** (Choosing andThen syntax variants)
|
|
2692
2731
|
*
|
|
2693
2732
|
* ```ts
|
|
2694
2733
|
* import { Effect, pipe } from "effect"
|
|
@@ -2764,7 +2803,7 @@ export declare const andThen: {
|
|
|
2764
2803
|
* Failures or requirements from either effect are preserved in the returned
|
|
2765
2804
|
* effect.
|
|
2766
2805
|
*
|
|
2767
|
-
* **Example** (
|
|
2806
|
+
* **Example** (Choosing andThen syntax variants)
|
|
2768
2807
|
*
|
|
2769
2808
|
* ```ts
|
|
2770
2809
|
* import { Effect, pipe } from "effect"
|
|
@@ -3250,7 +3289,7 @@ export declare const exit: <A, E, R>(self: Effect<A, E, R>) => Effect<Exit.Exit<
|
|
|
3250
3289
|
* effect is not modified. Instead, a new effect is returned with the updated
|
|
3251
3290
|
* value.
|
|
3252
3291
|
*
|
|
3253
|
-
* **Example** (
|
|
3292
|
+
* **Example** (Choosing map syntax variants)
|
|
3254
3293
|
*
|
|
3255
3294
|
* ```ts
|
|
3256
3295
|
* import { Effect, pipe } from "effect"
|
|
@@ -3306,7 +3345,7 @@ export declare const map: {
|
|
|
3306
3345
|
* effect is not modified. Instead, a new effect is returned with the updated
|
|
3307
3346
|
* value.
|
|
3308
3347
|
*
|
|
3309
|
-
* **Example** (
|
|
3348
|
+
* **Example** (Choosing map syntax variants)
|
|
3310
3349
|
*
|
|
3311
3350
|
* ```ts
|
|
3312
3351
|
* import { Effect, pipe } from "effect"
|
|
@@ -3362,7 +3401,7 @@ export declare const map: {
|
|
|
3362
3401
|
* effect is not modified. Instead, a new effect is returned with the updated
|
|
3363
3402
|
* value.
|
|
3364
3403
|
*
|
|
3365
|
-
* **Example** (
|
|
3404
|
+
* **Example** (Choosing map syntax variants)
|
|
3366
3405
|
*
|
|
3367
3406
|
* ```ts
|
|
3368
3407
|
* import { Effect, pipe } from "effect"
|
|
@@ -11965,7 +12004,7 @@ export declare const acquireDisposable: <A extends AsyncDisposable | Disposable,
|
|
|
11965
12004
|
* is not desired, errors produced by the `release` `Effect` value can be caught
|
|
11966
12005
|
* and ignored.
|
|
11967
12006
|
*
|
|
11968
|
-
* **Example** (
|
|
12007
|
+
* **Example** (Acquiring resources with cleanup)
|
|
11969
12008
|
*
|
|
11970
12009
|
* ```ts
|
|
11971
12010
|
* import { Console, Effect, Exit } from "effect"
|