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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/main.ts +5 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catch-match",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "repository": {
5
5
  "url": "https://github.com/kobzarvs/catch-match"
6
6
  },
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>) => TryReturn<Return, ErrorType>;
26
- other: (handler: ErrrorHandler<ErrorType>) => Pick<TryReturn<Return, ErrorType>, 'finally' | 'value' | 'error'>,
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
- TryReturn<Return> |
34
- (Promise<ResultType<Return>> & TryReturn<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: TryReturn<Return, typeof error> = {
72
+ const chain: CatchReturn<Return, typeof error> = {
76
73
  catch: (err, handler) => {
77
74
  if (result instanceof Promise) {
78
75
  result.then((response) => {