catch-match 1.0.0 → 1.0.4
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/LICENSE +1 -1
- package/README.md +36 -2
- package/package.json +2 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
## Motivation
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
### java
|
7
6
|
```java
|
8
7
|
try {
|
9
8
|
...
|
@@ -18,6 +17,41 @@ try {
|
|
18
17
|
}
|
19
18
|
```
|
20
19
|
|
20
|
+
### javascript
|
21
|
+
```javascript
|
22
|
+
try {
|
23
|
+
error; // error intruction
|
24
|
+
} catch (err) {
|
25
|
+
switch(err.constructor) {
|
26
|
+
case ReferenceError:
|
27
|
+
case SyntaxError:
|
28
|
+
console.error(`${err.constructor.name}: ${err.message}`);
|
29
|
+
break;
|
30
|
+
default:
|
31
|
+
console.error('other error:', err);
|
32
|
+
}
|
33
|
+
} finally {
|
34
|
+
console.log('final')
|
35
|
+
}
|
36
|
+
|
37
|
+
//> ReferenceError: error is not defined
|
38
|
+
//> final
|
39
|
+
```
|
40
|
+
|
41
|
+
## Getting started
|
42
|
+
|
43
|
+
```shell
|
44
|
+
yarn add catch-match
|
45
|
+
|
46
|
+
or
|
47
|
+
|
48
|
+
npm install catch-match
|
49
|
+
```
|
50
|
+
|
51
|
+
```javascript
|
52
|
+
import { _try } from 'catch-match';
|
53
|
+
```
|
54
|
+
|
21
55
|
## Example 1
|
22
56
|
```javascript
|
23
57
|
const result = _try(context => {
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "catch-match",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.4",
|
4
4
|
"repository": {
|
5
5
|
"url": "https://github.com/kobzarvs/catch-match"
|
6
6
|
},
|
7
|
+
"keywords": ["try", "catch", "match", "pattern", "errors", "exceptions", "throw", "finally"],
|
7
8
|
"type": "module",
|
8
9
|
"main": "dist/main.js",
|
9
10
|
"scripts": {
|