@chubbyts/chubbyts-throwable-to-error 1.1.1 → 1.2.1
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
CHANGED
|
@@ -30,7 +30,7 @@ It converts any throwable into an Error.
|
|
|
30
30
|
Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-throwable-to-error][1].
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
|
-
npm i @chubbyts/chubbyts-throwable-to-error@^1.
|
|
33
|
+
npm i @chubbyts/chubbyts-throwable-to-error@^1.2.1
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Usage
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const throwableToError = (e) => {
|
|
2
|
+
if (e instanceof Error) {
|
|
3
|
+
return e;
|
|
4
|
+
}
|
|
5
|
+
const error = new Error(typeof e === 'object' ? `${JSON.stringify(e)}` : `${String(e)}`);
|
|
6
|
+
// eslint-disable-next-line functional/immutable-data
|
|
7
|
+
error.name = typeof e;
|
|
8
|
+
// eslint-disable-next-line functional/immutable-data
|
|
9
|
+
error.stack = undefined;
|
|
10
|
+
return error;
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chubbyts/chubbyts-throwable-to-error",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.2.1",
|
|
4
5
|
"description": "It converts any throwable into an Error.",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"chubbyts",
|
|
@@ -11,14 +12,14 @@
|
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"repository": "chubbyts/chubbyts-throwable-to-error",
|
|
13
14
|
"scripts": {
|
|
15
|
+
"build": "node ./build.js",
|
|
14
16
|
"cs-fix": "prettier --write src tests",
|
|
15
17
|
"cs": "prettier --check src tests",
|
|
18
|
+
"infection": "stryker run",
|
|
16
19
|
"lint-fix": "eslint src tests --fix",
|
|
17
20
|
"lint": "eslint src tests",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"build": "rm -Rf dist && tsc",
|
|
21
|
-
"prepare": "npm run build"
|
|
21
|
+
"prepare": "npm run build",
|
|
22
|
+
"test": "jest"
|
|
22
23
|
},
|
|
23
24
|
"jest": {
|
|
24
25
|
"preset": "ts-jest",
|
|
@@ -41,16 +42,25 @@
|
|
|
41
42
|
"files": [
|
|
42
43
|
"dist"
|
|
43
44
|
],
|
|
45
|
+
"exports": {
|
|
46
|
+
"./*": {
|
|
47
|
+
"types": "./*.d.ts",
|
|
48
|
+
"require": "./*.cjs",
|
|
49
|
+
"import": "./*.mjs",
|
|
50
|
+
"default": "./*.mjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
44
53
|
"engines": {
|
|
45
54
|
"node": ">=16"
|
|
46
55
|
},
|
|
47
56
|
"dependencies": {},
|
|
48
57
|
"devDependencies": {
|
|
49
|
-
"@chubbyts/chubbyts-eslint": "^
|
|
50
|
-
"@
|
|
51
|
-
"@stryker-mutator/
|
|
58
|
+
"@chubbyts/chubbyts-eslint": "^2.0.3",
|
|
59
|
+
"@chubbyts/chubbyts-packaging": "^2.0.3",
|
|
60
|
+
"@stryker-mutator/core": "^7.1.1",
|
|
61
|
+
"@stryker-mutator/jest-runner": "^7.1.1",
|
|
52
62
|
"@types/jest": "^29.5.3",
|
|
53
|
-
"@types/node": "^20.4.
|
|
63
|
+
"@types/node": "^20.4.4",
|
|
54
64
|
"jest": "^29.6.1",
|
|
55
65
|
"prettier": "^3.0.0",
|
|
56
66
|
"ts-jest": "^29.1.1",
|
|
File without changes
|