catch-match 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -94,31 +94,9 @@ console.log(result); // {error: undefined, result: [1, 2, 3]}
94
94
  ## Example 3
95
95
 
96
96
  ```javascript
97
- const result = $try(context => {
98
- context.tmp = 'any context data';
99
- console.log('start', context);
100
- // ...
97
+ const result = $try(() => {
101
98
  throw SyntaxError;
102
- }).catch([TypeError, ReferenceError], (context) => {
103
- // noop
104
- }).other((error, context) => {
105
- // error: SyntaxError
106
- // context: {tmp: 'any context data'}
107
- context.unexpectedError = true;
108
- }).finally(({value, context, error}) => {
109
- // value: undefined
110
- // context: {tmp: 'any context data', unexpectedError: true}
111
- // error: SyntaxError
112
- if (!error) {
113
- return value.reverse();
114
- }
115
- });
116
-
117
- console.log(result);
118
- // {
119
- // value: undefined
120
- // context: {tmp: 'any context data', unexpectedError: true}
121
- // error: SyntaxError
122
- // }
99
+ })
123
100
 
101
+ console.log(result); // { error: SyntaxError, result: undefined }
124
102
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catch-match",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "repository": {
5
5
  "url": "https://github.com/kobzarvs/catch-match"
6
6
  },
@@ -211,16 +211,13 @@ test('should be return result without branches', () => {
211
211
  let matchOther = jest.fn();
212
212
  let matchFinally = jest.fn();
213
213
 
214
- class CustomError extends Error {
215
- }
216
-
217
214
  const result = $try(() => {
218
- throw CustomError;
215
+ throw SyntaxError;
219
216
  });
220
217
 
221
218
  expect(matchCustomError).not.toBeCalled();
222
219
  expect(matchArrayOfErrors).not.toBeCalled();
223
220
  expect(matchOther).not.toBeCalled();
224
221
  expect(matchFinally).not.toBeCalled();
225
- expect(result).toMatchObject({ error: CustomError, result: undefined });
222
+ expect(result).toMatchObject({ error: SyntaxError, result: undefined });
226
223
  });