@chubbyts/chubbyts-throwable-to-error 2.0.2 → 2.1.0
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 +3 -3
- package/dist/src/throwable-to-error.d.ts +1 -0
- package/dist/src/throwable-to-error.js +11 -0
- package/package.json +19 -12
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -23,14 +23,14 @@ It converts any throwable into an Error.
|
|
|
23
23
|
|
|
24
24
|
## Requirements
|
|
25
25
|
|
|
26
|
-
* node:
|
|
26
|
+
* node: 20
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
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@^2.0
|
|
33
|
+
npm i @chubbyts/chubbyts-throwable-to-error@^2.1.0
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Usage
|
|
@@ -47,6 +47,6 @@ try {
|
|
|
47
47
|
|
|
48
48
|
## Copyright
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
2026 Dominik Zogg
|
|
51
51
|
|
|
52
52
|
[1]: https://www.npmjs.com/package/@chubbyts/chubbyts-throwable-to-error
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const throwableToError: (e: unknown) => Error;
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chubbyts/chubbyts-throwable-to-error",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "It converts any throwable into an Error.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"chubbyts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"infection": "stryker run",
|
|
19
19
|
"lint-fix": "eslint src tests eslint.config.js vitest.config.ts --fix",
|
|
20
20
|
"lint": "eslint src tests",
|
|
21
|
-
"prepare": "
|
|
21
|
+
"prepare": "pnpm run build",
|
|
22
22
|
"test": "vitest"
|
|
23
23
|
},
|
|
24
24
|
"prettier": {
|
|
@@ -38,19 +38,26 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
41
|
+
"node": ">=20"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@chubbyts/chubbyts-eslint": "^
|
|
45
|
-
"@stryker-mutator/core": "^9.0
|
|
46
|
-
"@stryker-mutator/vitest-runner": "^9.0
|
|
47
|
-
"@types/node": "^
|
|
48
|
-
"@vitest/coverage-v8": "^
|
|
49
|
-
"prettier": "^3.
|
|
50
|
-
"typescript": "^
|
|
51
|
-
"vitest": "^
|
|
44
|
+
"@chubbyts/chubbyts-eslint": "^5.0.0",
|
|
45
|
+
"@stryker-mutator/core": "^9.6.0",
|
|
46
|
+
"@stryker-mutator/vitest-runner": "^9.6.0",
|
|
47
|
+
"@types/node": "^25.6.0",
|
|
48
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
49
|
+
"prettier": "^3.8.2",
|
|
50
|
+
"typescript": "^6.0.2",
|
|
51
|
+
"vitest": "^4.1.4"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"pnpm": {
|
|
57
|
+
"onlyBuiltDependencies": [
|
|
58
|
+
"esbuild",
|
|
59
|
+
"unrs-resolver"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319"
|
|
56
63
|
}
|