catch-match 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/main.ts +5 -8
package/package.json
CHANGED
package/src/main.ts
CHANGED
@@ -22,16 +22,13 @@ export type CatchReturn<Return, ErrorType = any> =
|
|
22
22
|
FinallyReturn<Return, ErrorType> &
|
23
23
|
OtherReturn<Return, ErrorType> &
|
24
24
|
{
|
25
|
-
catch: (error: ErrorType | ErrorType[], handler: ErrrorHandler<ErrorType>) =>
|
26
|
-
other: (handler: ErrrorHandler<ErrorType>) => Pick<
|
25
|
+
catch: (error: ErrorType | ErrorType[], handler: ErrrorHandler<ErrorType>) => PromisedTryReturn<Return>;
|
26
|
+
other: (handler: ErrrorHandler<ErrorType>) => Pick<PromisedTryReturn<Return>, 'finally' | 'value' | 'error'>,
|
27
27
|
}
|
28
28
|
|
29
|
-
export type TryReturn<Return, ErrorType = any> =
|
30
|
-
CatchReturn<Return, ErrorType>
|
31
|
-
|
32
29
|
export type PromisedTryReturn<Return> =
|
33
|
-
|
34
|
-
(Promise<ResultType<Return>> &
|
30
|
+
CatchReturn<Return> |
|
31
|
+
(Promise<ResultType<Return>> & CatchReturn<Return>)
|
35
32
|
|
36
33
|
export function $try<Return>(body: TryBody<Return>): PromisedTryReturn<Return> {
|
37
34
|
let caught = false;
|
@@ -72,7 +69,7 @@ export function $try<Return>(body: TryBody<Return>): PromisedTryReturn<Return> {
|
|
72
69
|
}
|
73
70
|
}
|
74
71
|
|
75
|
-
const chain:
|
72
|
+
const chain: CatchReturn<Return, typeof error> = {
|
76
73
|
catch: (err, handler) => {
|
77
74
|
if (result instanceof Promise) {
|
78
75
|
result.then((response) => {
|