catch-match 2.0.1 → 3.0.3
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/README.md +48 -1
- package/dist/__tests__/main.test.d.ts +1 -0
- package/dist/__tests__/main.test.js +440 -0
- package/dist/__tests__/main.test.js.map +1 -0
- package/dist/main.d.ts +16 -11
- package/dist/main.js +82 -28
- package/dist/main.js.map +1 -1
- package/package.json +8 -2
- package/src/__tests__/main.test.ts +485 -206
- package/src/main.ts +101 -48
package/README.md
CHANGED
@@ -21,7 +21,7 @@ try {
|
|
21
21
|
### javascript
|
22
22
|
```javascript
|
23
23
|
try {
|
24
|
-
error; // error
|
24
|
+
error; // error instruction
|
25
25
|
} catch (err) {
|
26
26
|
switch(err.constructor) {
|
27
27
|
case ReferenceError:
|
@@ -39,6 +39,10 @@ try {
|
|
39
39
|
//> final
|
40
40
|
```
|
41
41
|
|
42
|
+
## Features
|
43
|
+
|
44
|
+
Supporting sync/async functions
|
45
|
+
|
42
46
|
## Getting started
|
43
47
|
|
44
48
|
```shell
|
@@ -100,3 +104,46 @@ const result = $try(() => {
|
|
100
104
|
|
101
105
|
console.log(result); // { error: SyntaxError, result: undefined }
|
102
106
|
```
|
107
|
+
|
108
|
+
## Promises example
|
109
|
+
|
110
|
+
```typescript
|
111
|
+
class AuthError extends Error {}
|
112
|
+
|
113
|
+
function proc(event: string) {
|
114
|
+
return $try(() => new Promise((resolve, reject) => {
|
115
|
+
switch (event) {
|
116
|
+
case 'resolve':
|
117
|
+
resolve('resolved')
|
118
|
+
break;
|
119
|
+
case 'reject':
|
120
|
+
reject('rejected')
|
121
|
+
break;
|
122
|
+
case 'syntax':
|
123
|
+
throw SyntaxError
|
124
|
+
case 'auth':
|
125
|
+
throw AuthError
|
126
|
+
case 'error':
|
127
|
+
throw 'error'
|
128
|
+
default:
|
129
|
+
throw 'other errors'
|
130
|
+
}
|
131
|
+
}).catch('error', () => {
|
132
|
+
// console.log('error')
|
133
|
+
}).catch([SyntaxError, AuthError], (error) => {
|
134
|
+
// console.log(error)
|
135
|
+
}).other((error) => {
|
136
|
+
// console.log(error)
|
137
|
+
}).finally(({ value, error }) => {
|
138
|
+
// console.log({ value, error })
|
139
|
+
})
|
140
|
+
}
|
141
|
+
|
142
|
+
await proc('resolve') // { value: 'resolved' }}
|
143
|
+
await proc('reject') // { error: 'rejected' }
|
144
|
+
|
145
|
+
await proc('syntax') // { error: SyntaxError }
|
146
|
+
await proc('auth') // { error: AuthError }
|
147
|
+
await proc('error') // { error: 'error' }
|
148
|
+
await proc('other') // { error: 'other errors' }
|
149
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,440 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import $try from '../main';
|
11
|
+
describe('sync version', () => {
|
12
|
+
test('should be return result from `finally` branch', () => {
|
13
|
+
let matchReferenceError = jest.fn();
|
14
|
+
let matchArrayOfErrors = jest.fn();
|
15
|
+
let matchOther = jest.fn();
|
16
|
+
let matchFinally = jest.fn();
|
17
|
+
const result = $try(() => {
|
18
|
+
return [1, 2, 3];
|
19
|
+
}).catch(ReferenceError, () => {
|
20
|
+
matchReferenceError();
|
21
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
22
|
+
matchArrayOfErrors(error);
|
23
|
+
}).other((error) => {
|
24
|
+
matchOther(error);
|
25
|
+
}).finally(({ value, error }) => {
|
26
|
+
matchFinally({ value, error });
|
27
|
+
});
|
28
|
+
expect(matchReferenceError).not.toBeCalled();
|
29
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
30
|
+
expect(matchOther).not.toBeCalled();
|
31
|
+
expect(matchFinally).toBeCalled();
|
32
|
+
expect(result).toMatchObject({ error: undefined, value: [1, 2, 3] });
|
33
|
+
});
|
34
|
+
test('should be match single exception', () => {
|
35
|
+
let matchReferenceError = jest.fn();
|
36
|
+
let matchArrayOfErrors = jest.fn();
|
37
|
+
let matchOther = jest.fn();
|
38
|
+
let matchFinally = jest.fn();
|
39
|
+
const result = $try(() => {
|
40
|
+
throw ReferenceError;
|
41
|
+
}).catch(ReferenceError, () => {
|
42
|
+
matchReferenceError();
|
43
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
44
|
+
matchArrayOfErrors(error);
|
45
|
+
}).other((error) => {
|
46
|
+
matchOther(error);
|
47
|
+
}).finally(({ value, error }) => {
|
48
|
+
matchFinally({ value, error });
|
49
|
+
return value; // ?
|
50
|
+
});
|
51
|
+
expect(matchReferenceError).toBeCalled();
|
52
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
53
|
+
expect(matchOther).not.toBeCalled();
|
54
|
+
expect(matchFinally).toBeCalled();
|
55
|
+
expect(result).toMatchObject({ error: ReferenceError, value: undefined });
|
56
|
+
});
|
57
|
+
test('should be match array of exceptions', () => {
|
58
|
+
let matchReferenceError = jest.fn();
|
59
|
+
let matchArrayOfErrors = jest.fn();
|
60
|
+
let matchOther = jest.fn();
|
61
|
+
let matchFinally = jest.fn();
|
62
|
+
const result = $try(() => {
|
63
|
+
throw SyntaxError;
|
64
|
+
}).catch(ReferenceError, () => {
|
65
|
+
matchReferenceError();
|
66
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
67
|
+
matchArrayOfErrors(error);
|
68
|
+
}).other((error) => {
|
69
|
+
matchOther(error);
|
70
|
+
}).finally(({ value, error }) => {
|
71
|
+
matchFinally({ value, error });
|
72
|
+
return value; // ?
|
73
|
+
});
|
74
|
+
expect(matchReferenceError).not.toBeCalled();
|
75
|
+
expect(matchArrayOfErrors).toBeCalledWith(SyntaxError);
|
76
|
+
expect(matchOther).not.toBeCalled();
|
77
|
+
expect(matchFinally).toBeCalled();
|
78
|
+
expect(result).toMatchObject({ error: SyntaxError, value: undefined });
|
79
|
+
});
|
80
|
+
test('should be match any type of exception', () => {
|
81
|
+
let matchReferenceError = jest.fn();
|
82
|
+
let matchArrayOfErrors = jest.fn();
|
83
|
+
let matchOther = jest.fn();
|
84
|
+
let matchFinally = jest.fn();
|
85
|
+
const result = $try(() => {
|
86
|
+
throw 'error';
|
87
|
+
}).catch(ReferenceError, () => {
|
88
|
+
matchReferenceError();
|
89
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
90
|
+
matchArrayOfErrors(error);
|
91
|
+
}).other((error) => {
|
92
|
+
matchOther(error);
|
93
|
+
}).finally(({ value, error }) => {
|
94
|
+
matchFinally({ value, error });
|
95
|
+
return value; // ?
|
96
|
+
});
|
97
|
+
expect(matchReferenceError).not.toBeCalled();
|
98
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
99
|
+
expect(matchOther).toBeCalled();
|
100
|
+
expect(matchFinally).toBeCalled();
|
101
|
+
expect(result).toMatchObject({ error: 'error', value: undefined });
|
102
|
+
});
|
103
|
+
test('should be match custom exceptions', () => {
|
104
|
+
let matchCustomError = jest.fn();
|
105
|
+
let matchArrayOfErrors = jest.fn();
|
106
|
+
let matchOther = jest.fn();
|
107
|
+
let matchFinally = jest.fn();
|
108
|
+
class CustomError extends Error {
|
109
|
+
}
|
110
|
+
const result = $try(() => {
|
111
|
+
throw CustomError;
|
112
|
+
}).catch(CustomError, () => {
|
113
|
+
matchCustomError();
|
114
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
115
|
+
matchArrayOfErrors(error);
|
116
|
+
}).other((error) => {
|
117
|
+
matchOther(error);
|
118
|
+
}).finally(({ value, error }) => {
|
119
|
+
matchFinally({ value, error });
|
120
|
+
});
|
121
|
+
expect(matchCustomError).toBeCalled();
|
122
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
123
|
+
expect(matchOther).not.toBeCalled();
|
124
|
+
expect(matchFinally).toBeCalled();
|
125
|
+
expect(result).toMatchObject({ error: CustomError, value: undefined });
|
126
|
+
});
|
127
|
+
test('should be return result from `finally` branch without `other`', () => {
|
128
|
+
let matchCustomError = jest.fn();
|
129
|
+
let matchArrayOfErrors = jest.fn();
|
130
|
+
let matchOther = jest.fn();
|
131
|
+
let matchFinally = jest.fn();
|
132
|
+
class CustomError extends Error {
|
133
|
+
}
|
134
|
+
const result = $try(() => {
|
135
|
+
throw CustomError;
|
136
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
137
|
+
matchArrayOfErrors(error);
|
138
|
+
}).finally(({ value, error }) => {
|
139
|
+
matchFinally({ value, error });
|
140
|
+
return value; // ?
|
141
|
+
});
|
142
|
+
expect(matchCustomError).not.toBeCalled();
|
143
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
144
|
+
expect(matchOther).not.toBeCalled();
|
145
|
+
expect(matchFinally).toBeCalled();
|
146
|
+
expect(result).toMatchObject({ error: CustomError, value: undefined });
|
147
|
+
});
|
148
|
+
test('should be return result from `catch` branch', () => {
|
149
|
+
let matchCustomError = jest.fn();
|
150
|
+
let matchArrayOfErrors = jest.fn();
|
151
|
+
let matchOther = jest.fn();
|
152
|
+
let matchFinally = jest.fn();
|
153
|
+
class CustomError extends Error {
|
154
|
+
}
|
155
|
+
const result = $try(() => {
|
156
|
+
throw CustomError;
|
157
|
+
}).catch([TypeError, SyntaxError], (error) => {
|
158
|
+
matchArrayOfErrors(error);
|
159
|
+
});
|
160
|
+
expect(matchCustomError).not.toBeCalled();
|
161
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
162
|
+
expect(matchOther).not.toBeCalled();
|
163
|
+
expect(matchFinally).not.toBeCalled();
|
164
|
+
expect(result).toMatchObject({ error: CustomError, value: undefined });
|
165
|
+
});
|
166
|
+
test('should be return result from `other` branch', () => {
|
167
|
+
let matchCustomError = jest.fn();
|
168
|
+
let matchArrayOfErrors = jest.fn();
|
169
|
+
let matchOther = jest.fn();
|
170
|
+
let matchFinally = jest.fn();
|
171
|
+
class CustomError extends Error {
|
172
|
+
}
|
173
|
+
const result = $try(() => {
|
174
|
+
throw CustomError;
|
175
|
+
}).other((error) => {
|
176
|
+
matchOther(error);
|
177
|
+
});
|
178
|
+
expect(matchCustomError).not.toBeCalled();
|
179
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
180
|
+
expect(matchOther).toBeCalledWith(CustomError);
|
181
|
+
expect(matchFinally).not.toBeCalled();
|
182
|
+
expect(result).toMatchObject({ error: CustomError, value: undefined });
|
183
|
+
});
|
184
|
+
test('should be return result without branches', () => {
|
185
|
+
let matchCustomError = jest.fn();
|
186
|
+
let matchArrayOfErrors = jest.fn();
|
187
|
+
let matchOther = jest.fn();
|
188
|
+
let matchFinally = jest.fn();
|
189
|
+
const result = $try(() => {
|
190
|
+
throw SyntaxError;
|
191
|
+
});
|
192
|
+
expect(matchCustomError).not.toBeCalled();
|
193
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
194
|
+
expect(matchOther).not.toBeCalled();
|
195
|
+
expect(matchFinally).not.toBeCalled();
|
196
|
+
expect(result).toMatchObject({ error: SyntaxError, value: undefined });
|
197
|
+
});
|
198
|
+
});
|
199
|
+
/**
|
200
|
+
* async tests
|
201
|
+
*/
|
202
|
+
describe('promised version', () => {
|
203
|
+
test('resolve try', () => __awaiter(void 0, void 0, void 0, function* () {
|
204
|
+
let matchCustomError = jest.fn();
|
205
|
+
let matchArrayOfErrors = jest.fn();
|
206
|
+
let matchOther = jest.fn();
|
207
|
+
let matchFinally = jest.fn();
|
208
|
+
const result = $try(() => {
|
209
|
+
return Promise.resolve(42);
|
210
|
+
});
|
211
|
+
yield result;
|
212
|
+
expect(matchCustomError).not.toBeCalled();
|
213
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
214
|
+
expect(matchOther).not.toBeCalled();
|
215
|
+
expect(matchFinally).not.toBeCalled();
|
216
|
+
expect(result).toBeInstanceOf(Promise);
|
217
|
+
expect(yield result).toEqual({
|
218
|
+
value: 42,
|
219
|
+
error: undefined,
|
220
|
+
});
|
221
|
+
}));
|
222
|
+
test('reject try', () => __awaiter(void 0, void 0, void 0, function* () {
|
223
|
+
let matchCustomError = jest.fn();
|
224
|
+
let matchArrayOfErrors = jest.fn();
|
225
|
+
let matchOther = jest.fn();
|
226
|
+
let matchFinally = jest.fn();
|
227
|
+
const result = $try(() => {
|
228
|
+
return Promise.reject(42);
|
229
|
+
});
|
230
|
+
expect(matchCustomError).not.toBeCalled();
|
231
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
232
|
+
expect(matchOther).not.toBeCalled();
|
233
|
+
expect(matchFinally).not.toBeCalled();
|
234
|
+
expect(result).toBeInstanceOf(Promise);
|
235
|
+
expect(yield result).toEqual({
|
236
|
+
value: undefined,
|
237
|
+
error: 42,
|
238
|
+
});
|
239
|
+
}));
|
240
|
+
test('throw try', () => __awaiter(void 0, void 0, void 0, function* () {
|
241
|
+
const result = $try(() => {
|
242
|
+
return new Promise(() => {
|
243
|
+
throw new Error('error');
|
244
|
+
});
|
245
|
+
});
|
246
|
+
expect(result).toBeInstanceOf(Promise);
|
247
|
+
expect(yield result).toEqual({
|
248
|
+
value: undefined,
|
249
|
+
error: Error('error'),
|
250
|
+
});
|
251
|
+
}));
|
252
|
+
test('resolve try.catch', () => __awaiter(void 0, void 0, void 0, function* () {
|
253
|
+
let matchError = jest.fn();
|
254
|
+
let matchSyntaxError = jest.fn();
|
255
|
+
let matchOther = jest.fn();
|
256
|
+
const result = $try(() => {
|
257
|
+
return Promise.resolve(42);
|
258
|
+
}).catch(Error, () => {
|
259
|
+
matchError();
|
260
|
+
}).catch(SyntaxError, () => {
|
261
|
+
matchSyntaxError();
|
262
|
+
}).other((error) => {
|
263
|
+
matchOther(error);
|
264
|
+
});
|
265
|
+
expect(matchError).not.toBeCalled();
|
266
|
+
expect(matchSyntaxError).not.toBeCalled();
|
267
|
+
expect(matchOther).not.toBeCalled();
|
268
|
+
expect(result).toBeInstanceOf(Promise);
|
269
|
+
expect(yield result).toEqual({
|
270
|
+
value: 42,
|
271
|
+
error: undefined,
|
272
|
+
});
|
273
|
+
}));
|
274
|
+
test('reject try.catch', () => __awaiter(void 0, void 0, void 0, function* () {
|
275
|
+
let matchError = jest.fn();
|
276
|
+
let matchOther = jest.fn();
|
277
|
+
const result = $try(() => {
|
278
|
+
return Promise.reject(123);
|
279
|
+
}).catch(Error, () => {
|
280
|
+
matchOther();
|
281
|
+
}).catch(123, () => {
|
282
|
+
matchError();
|
283
|
+
}).catch('error', () => {
|
284
|
+
matchOther();
|
285
|
+
});
|
286
|
+
yield result; //?
|
287
|
+
expect(matchOther).not.toBeCalled();
|
288
|
+
expect(matchError).toBeCalled();
|
289
|
+
expect(result).toBeInstanceOf(Promise);
|
290
|
+
expect(yield result).toEqual({
|
291
|
+
value: undefined,
|
292
|
+
error: 123,
|
293
|
+
});
|
294
|
+
}));
|
295
|
+
test('throw try.catch', () => __awaiter(void 0, void 0, void 0, function* () {
|
296
|
+
let matchError = jest.fn();
|
297
|
+
let matchOther = jest.fn();
|
298
|
+
const result = $try(() => {
|
299
|
+
return new Promise(() => {
|
300
|
+
throw 'error';
|
301
|
+
});
|
302
|
+
}).catch(Error, () => {
|
303
|
+
matchOther();
|
304
|
+
}).catch(123, () => {
|
305
|
+
matchError();
|
306
|
+
}).catch('error', () => {
|
307
|
+
matchOther();
|
308
|
+
});
|
309
|
+
expect(result).toBeInstanceOf(Promise);
|
310
|
+
expect(yield result).toEqual({
|
311
|
+
value: undefined,
|
312
|
+
error: 'error',
|
313
|
+
});
|
314
|
+
expect(matchOther).toBeCalledTimes(1);
|
315
|
+
expect(matchError).not.toBeCalled();
|
316
|
+
}));
|
317
|
+
test('resolve try.other', () => __awaiter(void 0, void 0, void 0, function* () {
|
318
|
+
let matchCustomError = jest.fn();
|
319
|
+
let matchArrayOfErrors = jest.fn();
|
320
|
+
let matchOther = jest.fn();
|
321
|
+
let matchFinally = jest.fn();
|
322
|
+
const result = $try(() => {
|
323
|
+
return Promise.resolve('ok');
|
324
|
+
}).other(({ value, error }) => {
|
325
|
+
matchOther({ value, error });
|
326
|
+
});
|
327
|
+
expect(result).toBeInstanceOf(Promise);
|
328
|
+
expect(yield result).toEqual({
|
329
|
+
value: 'ok',
|
330
|
+
error: undefined,
|
331
|
+
});
|
332
|
+
expect(matchCustomError).not.toBeCalled();
|
333
|
+
expect(matchArrayOfErrors).not.toBeCalled();
|
334
|
+
expect(matchOther).not.toBeCalled();
|
335
|
+
expect(matchFinally).not.toBeCalled();
|
336
|
+
}));
|
337
|
+
test('reject try.other', () => __awaiter(void 0, void 0, void 0, function* () {
|
338
|
+
let matchError = jest.fn();
|
339
|
+
let matchOther = jest.fn();
|
340
|
+
const result = $try(() => {
|
341
|
+
return Promise.reject('error');
|
342
|
+
}).catch('error1', () => {
|
343
|
+
matchError();
|
344
|
+
}).catch('error2', () => {
|
345
|
+
matchError();
|
346
|
+
}).other((error) => {
|
347
|
+
matchOther(error);
|
348
|
+
});
|
349
|
+
expect(result).toBeInstanceOf(Promise);
|
350
|
+
expect(yield result).toEqual({
|
351
|
+
value: undefined,
|
352
|
+
error: 'error',
|
353
|
+
});
|
354
|
+
expect(matchError).not.toBeCalled();
|
355
|
+
expect(matchOther).toBeCalledWith('error');
|
356
|
+
}));
|
357
|
+
test('throw try.other', () => __awaiter(void 0, void 0, void 0, function* () {
|
358
|
+
let matchError = jest.fn();
|
359
|
+
let matchOther = jest.fn();
|
360
|
+
const result = $try(() => {
|
361
|
+
return new Promise(() => {
|
362
|
+
throw 'error';
|
363
|
+
});
|
364
|
+
}).catch('error1', () => {
|
365
|
+
matchError();
|
366
|
+
}).catch('error2', () => {
|
367
|
+
matchError();
|
368
|
+
}).other((error) => {
|
369
|
+
matchOther(error);
|
370
|
+
});
|
371
|
+
expect(result).toBeInstanceOf(Promise);
|
372
|
+
expect(yield result).toEqual({
|
373
|
+
value: undefined,
|
374
|
+
error: 'error',
|
375
|
+
});
|
376
|
+
expect(matchError).not.toBeCalled();
|
377
|
+
expect(matchOther).toBeCalledWith('error');
|
378
|
+
}));
|
379
|
+
test('when throw should be match array or exception', () => __awaiter(void 0, void 0, void 0, function* () {
|
380
|
+
let matchSingleError = jest.fn();
|
381
|
+
let matchArrayError = jest.fn();
|
382
|
+
let matchOther = jest.fn();
|
383
|
+
let matchFinally = jest.fn();
|
384
|
+
const attach = (ctx) => {
|
385
|
+
return ctx.catch(SyntaxError, () => {
|
386
|
+
matchSingleError(SyntaxError);
|
387
|
+
}).catch([ReferenceError, SyntaxError], (error) => {
|
388
|
+
matchArrayError(error);
|
389
|
+
}).other((error) => {
|
390
|
+
matchOther(error);
|
391
|
+
}).finally(({ value, error }) => {
|
392
|
+
matchFinally({ value, error });
|
393
|
+
});
|
394
|
+
};
|
395
|
+
const testSingle = $try(() => new Promise(() => {
|
396
|
+
throw SyntaxError;
|
397
|
+
}));
|
398
|
+
const testArray = $try(() => new Promise(() => {
|
399
|
+
throw ReferenceError;
|
400
|
+
}));
|
401
|
+
const testOther = $try(() => new Promise(() => {
|
402
|
+
throw TypeError;
|
403
|
+
}));
|
404
|
+
const testResolve = $try(() => new Promise((resolve) => {
|
405
|
+
resolve('ok');
|
406
|
+
}));
|
407
|
+
const testReject = $try(() => new Promise((_, reject) => {
|
408
|
+
reject('reject');
|
409
|
+
}));
|
410
|
+
const resultSingle = attach(testSingle);
|
411
|
+
const resultArray = attach(testArray);
|
412
|
+
const resultOther = attach(testOther);
|
413
|
+
const resultResolve = attach(testResolve);
|
414
|
+
const resultReject = attach(testReject);
|
415
|
+
expect(resultSingle).toBeInstanceOf(Promise);
|
416
|
+
expect(resultArray).toBeInstanceOf(Promise);
|
417
|
+
expect(resultOther).toBeInstanceOf(Promise);
|
418
|
+
expect(resultResolve).toBeInstanceOf(Promise);
|
419
|
+
expect(resultReject).toBeInstanceOf(Promise);
|
420
|
+
expect(yield resultSingle).toEqual({
|
421
|
+
value: undefined,
|
422
|
+
error: SyntaxError,
|
423
|
+
});
|
424
|
+
expect(yield resultArray).toEqual({
|
425
|
+
value: undefined,
|
426
|
+
error: ReferenceError,
|
427
|
+
});
|
428
|
+
expect(yield resultOther).toEqual({
|
429
|
+
value: undefined,
|
430
|
+
error: TypeError,
|
431
|
+
});
|
432
|
+
expect(yield resultResolve).toEqual({
|
433
|
+
value: 'ok',
|
434
|
+
});
|
435
|
+
expect(yield resultReject).toEqual({
|
436
|
+
error: 'reject',
|
437
|
+
});
|
438
|
+
}));
|
439
|
+
});
|
440
|
+
//# sourceMappingURL=main.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"main.test.js","sourceRoot":"","sources":["../../src/__tests__/main.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAA2B,MAAM,SAAS,CAAC;AAElD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACzD,IAAI,mBAAmB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE;YACvB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,EAAE;YAC5B,mBAAmB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,KAA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AC;QAC9C,MAAM,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE7C,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC,OAAO,CAAC;YACjC,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,WAAW,CAAC,CAAC,OAAO,CAAC;YAChC,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,WAAW,CAAC,CAAC,OAAO,CAAC;YAChC,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,aAAa,CAAC,CAAC,OAAO,CAAC;YAClC,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC,OAAO,CAAC;YACjC,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/main.d.ts
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
-
declare type
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
export declare type ErrrorHandler<ErrorType> = (error?: ErrorType) => void;
|
2
|
+
export declare type FinallyCallback<Result, ErrorType = any> = (params: ResultType<Result, ErrorType>) => void;
|
3
|
+
export declare type TryBody<Result> = () => Result | Promise<Result> | never;
|
4
|
+
export declare type ResultType<Result, ErrorType = any> = {
|
5
|
+
value?: Result;
|
6
|
+
error?: ErrorType;
|
5
7
|
};
|
6
|
-
export declare
|
7
|
-
|
8
|
-
|
9
|
-
finally: (callback: (params: InternalData<T>) => T) => InternalData<T>;
|
10
|
-
};
|
11
|
-
finally: (callback: (params: InternalData<T>) => T) => InternalData<T>;
|
8
|
+
export declare type FinallyReturn<Return, ErrorType = any> = ResultType<Return, ErrorType>;
|
9
|
+
export declare type OtherReturn<Return, ErrorType = any> = FinallyReturn<Return, ErrorType> & {
|
10
|
+
finally: (callback: FinallyCallback<Return, ErrorType>) => ResultType<Return, ErrorType>;
|
12
11
|
};
|
13
|
-
export
|
12
|
+
export declare type CatchReturn<Return, ErrorType = any> = FinallyReturn<Return, ErrorType> & OtherReturn<Return, ErrorType> & {
|
13
|
+
catch: (error: ErrorType | ErrorType[], handler: ErrrorHandler<ErrorType>) => PromisedTryReturn<Return>;
|
14
|
+
other: (handler: ErrrorHandler<ErrorType>) => Pick<PromisedTryReturn<Return>, 'finally' | 'value' | 'error'>;
|
15
|
+
};
|
16
|
+
export declare type PromisedTryReturn<Return> = CatchReturn<Return> | (Promise<ResultType<Return>> & CatchReturn<Return>);
|
17
|
+
export declare function $try<Return>(body: TryBody<Return>): PromisedTryReturn<Return>;
|
18
|
+
export default $try;
|