@byloth/core 2.2.1 → 2.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byloth/core",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "An unopinionated collection of useful functions and classes that I use widely in all my projects. 🔧",
5
5
  "keywords": [
6
6
  "Core",
@@ -50,15 +50,15 @@
50
50
  "types": "src/index.ts",
51
51
  "devDependencies": {
52
52
  "@byloth/eslint-config-typescript": "^3.2.2",
53
- "@eslint/compat": "^1.4.1",
54
- "@types/node": "^22.19.0",
55
- "@vitest/coverage-v8": "^4.0.8",
53
+ "@eslint/compat": "^2.0.0",
54
+ "@types/node": "^22.19.1",
55
+ "@vitest/coverage-v8": "^4.0.12",
56
56
  "eslint": "^9.39.1",
57
57
  "husky": "^9.1.7",
58
- "jsdom": "^27.1.0",
58
+ "jsdom": "^27.2.0",
59
59
  "typescript": "^5.9.3",
60
- "vite": "^7.2.2",
61
- "vitest": "^4.0.8"
60
+ "vite": "^7.2.4",
61
+ "vitest": "^4.0.12"
62
62
  },
63
63
  "scripts": {
64
64
  "dev": "vite",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "2.2.1";
1
+ export const VERSION = "2.2.2";
2
2
 
3
3
  export type { Constructor, Interval, Timeout, ValueOf } from "./core/types.js";
4
4
 
@@ -16,8 +16,7 @@
16
16
  * // Uncaught Exception: The game saves may be corrupted. Try to restart the game.
17
17
  * // at /src/game/index.ts:37:15
18
18
  * // at /src/main.ts:23:17
19
- * //
20
- * // Caused by SyntaxError: Unexpected end of JSON input
19
+ * // Caused by: SyntaxError: Unexpected end of JSON input
21
20
  * // at /src/models/saves.ts:47:17
22
21
  * // at /src/game/index.ts:12:9
23
22
  * // at /src/main.ts:23:17
@@ -59,6 +58,7 @@ export default class Exception extends Error
59
58
  const exc = new Exception(error.message);
60
59
 
61
60
  exc.stack = error.stack;
61
+ exc.cause = error.cause;
62
62
  exc.name = error.name;
63
63
 
64
64
  return exc;
@@ -89,18 +89,6 @@ export default class Exception extends Error
89
89
 
90
90
  this.cause = cause;
91
91
  this.name = name;
92
-
93
- if (cause)
94
- {
95
- if (cause instanceof Error)
96
- {
97
- this.stack += `\n\nCaused by ${cause.stack}`;
98
- }
99
- else
100
- {
101
- this.stack += `\n\nCaused by ${cause}`;
102
- }
103
- }
104
92
  }
105
93
 
106
94
  public readonly [Symbol.toStringTag]: string = "Exception";
@@ -1066,7 +1066,7 @@ export default class SmartAsyncIterator<T, R = void, N = undefined> implements A
1066
1066
  * {
1067
1067
  * try
1068
1068
  * {
1069
- * if (value > 5) { throw new Error("The index is too high."); }
1069
+ * if (value > 5) { throw new Exception("The index is too high."); }
1070
1070
  *
1071
1071
  * console.log(value); // 1, 2, 3, 4, 5
1072
1072
  * }
@@ -939,7 +939,7 @@ export default class SmartIterator<T, R = void, N = undefined> implements Iterat
939
939
  * {
940
940
  * try
941
941
  * {
942
- * if (value > 5) { throw new Error("The index is too high."); }
942
+ * if (value > 5) { throw new Exception("The index is too high."); }
943
943
  *
944
944
  * console.log(value); // 1, 2, 3, 4, 5
945
945
  * }
@@ -261,10 +261,10 @@ export default class SmartPromise<T = void> implements Promise<T>
261
261
  * ```ts
262
262
  * const promise = new SmartPromise((resolve, reject) =>
263
263
  * {
264
- * setTimeout(() => reject(new Error("An unknown error occurred.")), 1_000);
264
+ * setTimeout(() => reject(new Exception("An unknown error occurred.")), 1_000);
265
265
  * });
266
266
  *
267
- * promise.catch(); // Uncaught Error: An unknown error occurred.
267
+ * promise.catch(); // "Uncaught Exception: An unknown error occurred."
268
268
  * ```
269
269
  *
270
270
  * ---
@@ -288,10 +288,10 @@ export default class SmartPromise<T = void> implements Promise<T>
288
288
  * ```ts
289
289
  * const promise = new SmartPromise((resolve, reject) =>
290
290
  * {
291
- * setTimeout(() => reject(new Error("An unknown error occurred.")), 1_000);
291
+ * setTimeout(() => reject(new Exception("An unknown error occurred.")), 1_000);
292
292
  * });
293
293
  *
294
- * promise.catch((reason) => console.error(reason)); // "Error: An unknown error occurred."
294
+ * promise.catch((reason) => console.error(reason)); // "Uncaught Exception: An unknown error occurred."
295
295
  * ```
296
296
  *
297
297
  * ---
@@ -21,7 +21,7 @@ import type { MaybePromise, PromiseExecutor } from "./types.js";
21
21
  *
22
22
  * promise
23
23
  * .then((result) => console.log(result)) // "Hello, World!"
24
- * .catch((error) => console.error(error)); // TimeoutException: The operation has timed out.
24
+ * .catch((error) => console.error(error)); // "Uncaught TimeoutException: The operation has timed out."
25
25
  * ```
26
26
  *
27
27
  * ---