effect 3.16.12 → 3.16.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Array.js +2 -2
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +8 -8
- package/dist/dts/Effect.d.ts +1 -121
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/esm/Array.js +2 -2
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Array.ts +8 -8
- package/src/Effect.ts +1 -117
- package/src/internal/core-effect.ts +24 -11
- package/src/internal/version.ts +1 -1
package/dist/dts/Array.d.ts
CHANGED
|
@@ -2926,8 +2926,8 @@ export declare const setNonEmptyLast: {
|
|
|
2926
2926
|
* ```ts
|
|
2927
2927
|
* import { Array } from "effect"
|
|
2928
2928
|
*
|
|
2929
|
-
* const result = Array.rotate(['a', 'b', 'c', 'd'], 2)
|
|
2930
|
-
* console.log(result) // ['
|
|
2929
|
+
* const result = Array.rotate(['a', 'b', 'c', 'd', 'e'], 2)
|
|
2930
|
+
* console.log(result) // [ 'd', 'e', 'a', 'b', 'c' ]
|
|
2931
2931
|
* ```
|
|
2932
2932
|
*
|
|
2933
2933
|
* @since 2.0.0
|
|
@@ -2942,8 +2942,8 @@ export declare const rotate: {
|
|
|
2942
2942
|
* ```ts
|
|
2943
2943
|
* import { Array } from "effect"
|
|
2944
2944
|
*
|
|
2945
|
-
* const result = Array.rotate(['a', 'b', 'c', 'd'], 2)
|
|
2946
|
-
* console.log(result) // ['
|
|
2945
|
+
* const result = Array.rotate(['a', 'b', 'c', 'd', 'e'], 2)
|
|
2946
|
+
* console.log(result) // [ 'd', 'e', 'a', 'b', 'c' ]
|
|
2947
2947
|
* ```
|
|
2948
2948
|
*
|
|
2949
2949
|
* @since 2.0.0
|
|
@@ -2958,8 +2958,8 @@ export declare const rotate: {
|
|
|
2958
2958
|
* ```ts
|
|
2959
2959
|
* import { Array } from "effect"
|
|
2960
2960
|
*
|
|
2961
|
-
* const result = Array.rotate(['a', 'b', 'c', 'd'], 2)
|
|
2962
|
-
* console.log(result) // ['
|
|
2961
|
+
* const result = Array.rotate(['a', 'b', 'c', 'd', 'e'], 2)
|
|
2962
|
+
* console.log(result) // [ 'd', 'e', 'a', 'b', 'c' ]
|
|
2963
2963
|
* ```
|
|
2964
2964
|
*
|
|
2965
2965
|
* @since 2.0.0
|
|
@@ -2974,8 +2974,8 @@ export declare const rotate: {
|
|
|
2974
2974
|
* ```ts
|
|
2975
2975
|
* import { Array } from "effect"
|
|
2976
2976
|
*
|
|
2977
|
-
* const result = Array.rotate(['a', 'b', 'c', 'd'], 2)
|
|
2978
|
-
* console.log(result) // ['
|
|
2977
|
+
* const result = Array.rotate(['a', 'b', 'c', 'd', 'e'], 2)
|
|
2978
|
+
* console.log(result) // [ 'd', 'e', 'a', 'b', 'c' ]
|
|
2979
2979
|
* ```
|
|
2980
2980
|
*
|
|
2981
2981
|
* @since 2.0.0
|
package/dist/dts/Effect.d.ts
CHANGED
|
@@ -6712,66 +6712,6 @@ export declare const catchSomeDefect: {
|
|
|
6712
6712
|
* @category Error handling
|
|
6713
6713
|
*/
|
|
6714
6714
|
export declare const catchTag: {
|
|
6715
|
-
/**
|
|
6716
|
-
* Catches and handles specific errors by their `_tag` field, which is used as a
|
|
6717
|
-
* discriminator.
|
|
6718
|
-
*
|
|
6719
|
-
* **When to Use**
|
|
6720
|
-
*
|
|
6721
|
-
* `catchTag` is useful when your errors are tagged with a readonly `_tag` field
|
|
6722
|
-
* that identifies the error type. You can use this function to handle specific
|
|
6723
|
-
* error types by matching the `_tag` value. This allows for precise error
|
|
6724
|
-
* handling, ensuring that only specific errors are caught and handled.
|
|
6725
|
-
*
|
|
6726
|
-
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
6727
|
-
* field is used to identify and match errors.
|
|
6728
|
-
*
|
|
6729
|
-
* **Example** (Handling Errors by Tag)
|
|
6730
|
-
*
|
|
6731
|
-
* ```ts
|
|
6732
|
-
* import { Effect, Random } from "effect"
|
|
6733
|
-
*
|
|
6734
|
-
* class HttpError {
|
|
6735
|
-
* readonly _tag = "HttpError"
|
|
6736
|
-
* }
|
|
6737
|
-
*
|
|
6738
|
-
* class ValidationError {
|
|
6739
|
-
* readonly _tag = "ValidationError"
|
|
6740
|
-
* }
|
|
6741
|
-
*
|
|
6742
|
-
* // ┌─── Effect<string, HttpError | ValidationError, never>
|
|
6743
|
-
* // ▼
|
|
6744
|
-
* const program = Effect.gen(function* () {
|
|
6745
|
-
* const n1 = yield* Random.next
|
|
6746
|
-
* const n2 = yield* Random.next
|
|
6747
|
-
* if (n1 < 0.5) {
|
|
6748
|
-
* yield* Effect.fail(new HttpError())
|
|
6749
|
-
* }
|
|
6750
|
-
* if (n2 < 0.5) {
|
|
6751
|
-
* yield* Effect.fail(new ValidationError())
|
|
6752
|
-
* }
|
|
6753
|
-
* return "some result"
|
|
6754
|
-
* })
|
|
6755
|
-
*
|
|
6756
|
-
* // ┌─── Effect<string, ValidationError, never>
|
|
6757
|
-
* // ▼
|
|
6758
|
-
* const recovered = program.pipe(
|
|
6759
|
-
* // Only handle HttpError errors
|
|
6760
|
-
* Effect.catchTag("HttpError", (_HttpError) =>
|
|
6761
|
-
* Effect.succeed("Recovering from HttpError")
|
|
6762
|
-
* )
|
|
6763
|
-
* )
|
|
6764
|
-
* ```
|
|
6765
|
-
*
|
|
6766
|
-
* @see {@link catchTags} for a version that allows you to handle multiple error
|
|
6767
|
-
* types at once.
|
|
6768
|
-
*
|
|
6769
|
-
* @since 2.0.0
|
|
6770
|
-
* @category Error handling
|
|
6771
|
-
*/
|
|
6772
|
-
<E, const K extends RA.NonEmptyReadonlyArray<E extends {
|
|
6773
|
-
_tag: string;
|
|
6774
|
-
} ? E["_tag"] : never>>(...tags: K): <A, R>(self: Effect<A, E, R> & "missing error handler") => never;
|
|
6775
6715
|
/**
|
|
6776
6716
|
* Catches and handles specific errors by their `_tag` field, which is used as a
|
|
6777
6717
|
* discriminator.
|
|
@@ -6895,67 +6835,7 @@ export declare const catchTag: {
|
|
|
6895
6835
|
*/
|
|
6896
6836
|
<A, E, R, const K extends RA.NonEmptyReadonlyArray<E extends {
|
|
6897
6837
|
_tag: string;
|
|
6898
|
-
} ? E["_tag"] : never
|
|
6899
|
-
/**
|
|
6900
|
-
* Catches and handles specific errors by their `_tag` field, which is used as a
|
|
6901
|
-
* discriminator.
|
|
6902
|
-
*
|
|
6903
|
-
* **When to Use**
|
|
6904
|
-
*
|
|
6905
|
-
* `catchTag` is useful when your errors are tagged with a readonly `_tag` field
|
|
6906
|
-
* that identifies the error type. You can use this function to handle specific
|
|
6907
|
-
* error types by matching the `_tag` value. This allows for precise error
|
|
6908
|
-
* handling, ensuring that only specific errors are caught and handled.
|
|
6909
|
-
*
|
|
6910
|
-
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
6911
|
-
* field is used to identify and match errors.
|
|
6912
|
-
*
|
|
6913
|
-
* **Example** (Handling Errors by Tag)
|
|
6914
|
-
*
|
|
6915
|
-
* ```ts
|
|
6916
|
-
* import { Effect, Random } from "effect"
|
|
6917
|
-
*
|
|
6918
|
-
* class HttpError {
|
|
6919
|
-
* readonly _tag = "HttpError"
|
|
6920
|
-
* }
|
|
6921
|
-
*
|
|
6922
|
-
* class ValidationError {
|
|
6923
|
-
* readonly _tag = "ValidationError"
|
|
6924
|
-
* }
|
|
6925
|
-
*
|
|
6926
|
-
* // ┌─── Effect<string, HttpError | ValidationError, never>
|
|
6927
|
-
* // ▼
|
|
6928
|
-
* const program = Effect.gen(function* () {
|
|
6929
|
-
* const n1 = yield* Random.next
|
|
6930
|
-
* const n2 = yield* Random.next
|
|
6931
|
-
* if (n1 < 0.5) {
|
|
6932
|
-
* yield* Effect.fail(new HttpError())
|
|
6933
|
-
* }
|
|
6934
|
-
* if (n2 < 0.5) {
|
|
6935
|
-
* yield* Effect.fail(new ValidationError())
|
|
6936
|
-
* }
|
|
6937
|
-
* return "some result"
|
|
6938
|
-
* })
|
|
6939
|
-
*
|
|
6940
|
-
* // ┌─── Effect<string, ValidationError, never>
|
|
6941
|
-
* // ▼
|
|
6942
|
-
* const recovered = program.pipe(
|
|
6943
|
-
* // Only handle HttpError errors
|
|
6944
|
-
* Effect.catchTag("HttpError", (_HttpError) =>
|
|
6945
|
-
* Effect.succeed("Recovering from HttpError")
|
|
6946
|
-
* )
|
|
6947
|
-
* )
|
|
6948
|
-
* ```
|
|
6949
|
-
*
|
|
6950
|
-
* @see {@link catchTags} for a version that allows you to handle multiple error
|
|
6951
|
-
* types at once.
|
|
6952
|
-
*
|
|
6953
|
-
* @since 2.0.0
|
|
6954
|
-
* @category Error handling
|
|
6955
|
-
*/
|
|
6956
|
-
<A, E, R, const K extends RA.NonEmptyReadonlyArray<E extends {
|
|
6957
|
-
_tag: string;
|
|
6958
|
-
} ? E["_tag"] : never>, R1, E1, A1>(self: Effect<A, E, R>, ...args: [...tags: K, f: (e: Extract<NoInfer<E>, {
|
|
6838
|
+
} ? E["_tag"] : never>, A1, E1, R1>(self: Effect<A, E, R>, ...args: [...tags: K, f: (e: Extract<NoInfer<E>, {
|
|
6959
6839
|
_tag: K[number];
|
|
6960
6840
|
}>) => Effect<A1, E1, R1>]): Effect<A | A1, Exclude<E, {
|
|
6961
6841
|
_tag: K[number];
|