@chubbyts/chubbyts-throwable-to-error 1.1.1 → 1.2.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/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.1.1
33
+ npm i @chubbyts/chubbyts-throwable-to-error@^1.2.0
34
34
  ```
35
35
 
36
36
  ## Usage
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwableToError = void 0;
4
+ const throwableToError = (e) => {
5
+ if (e instanceof Error) {
6
+ return e;
7
+ }
8
+ const error = new Error(typeof e === 'object' ? `${JSON.stringify(e)}` : `${String(e)}`);
9
+ // eslint-disable-next-line functional/immutable-data
10
+ error.name = typeof e;
11
+ // eslint-disable-next-line functional/immutable-data
12
+ error.stack = undefined;
13
+ return error;
14
+ };
15
+ exports.throwableToError = throwableToError;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwableToError = void 0;
4
- const throwableToError = (e) => {
1
+ export const throwableToError = (e) => {
5
2
  if (e instanceof Error) {
6
3
  return e;
7
4
  }
@@ -12,4 +9,3 @@ const throwableToError = (e) => {
12
9
  error.stack = undefined;
13
10
  return error;
14
11
  };
15
- exports.throwableToError = throwableToError;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@chubbyts/chubbyts-throwable-to-error",
3
- "version": "1.1.1",
3
+ "type": "module",
4
+ "version": "1.2.0",
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": "rm -rf ./dist && tsc -b ./tsconfig.types.json ./tsconfig.esm.json ./tsconfig.cjs.json && node ./rename-commonjs.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
- "test": "jest",
19
- "infection": "stryker run",
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": "./*.js",
50
+ "default": "./*.js"
51
+ }
52
+ },
44
53
  "engines": {
45
54
  "node": ">=16"
46
55
  },
47
56
  "dependencies": {},
48
57
  "devDependencies": {
49
- "@chubbyts/chubbyts-eslint": "^1.1.2",
50
- "@stryker-mutator/core": "^7.1.0",
51
- "@stryker-mutator/jest-runner": "^7.1.0",
58
+ "@chubbyts/chubbyts-eslint": "^2.0.2",
59
+ "@chubbyts/chubbyts-packaging": "^1.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.1",
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",