codeweaver 3.0.6 → 3.0.7
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
|
@@ -11,18 +11,18 @@ function parseIntegerStrict(input: string): number {
|
|
|
11
11
|
|
|
12
12
|
// Empty or just sign is invalid
|
|
13
13
|
if (s.length === 0 || s === "+" || s === "-") {
|
|
14
|
-
throw new
|
|
14
|
+
throw new TypeError("Invalid integer");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// Use a regex to ensure the entire string is an optional sign followed by digits
|
|
18
18
|
if (!/^[+-]?\d+$/.test(s)) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new TypeError("Invalid integer");
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Safe parse
|
|
23
23
|
const n = Number(s);
|
|
24
24
|
if (!Number.isSafeInteger(n)) {
|
|
25
|
-
throw new
|
|
25
|
+
throw new TypeError("Integer out of safe range");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return n;
|
|
@@ -41,7 +41,7 @@ export function stringToInteger(input: string): number {
|
|
|
41
41
|
try {
|
|
42
42
|
return parseIntegerStrict(input);
|
|
43
43
|
} catch {
|
|
44
|
-
throw new
|
|
44
|
+
throw new TypeError("The input parameter must be a valid integer.");
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -68,7 +68,7 @@ export function stringToBoolean(input: string): boolean {
|
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
throw new
|
|
71
|
+
throw new TypeError(
|
|
72
72
|
"The input parameter must be a boolean (e.g., true/false, 1/0)."
|
|
73
73
|
);
|
|
74
74
|
}
|
|
@@ -89,12 +89,12 @@ export function stringToNumber(input: string): number {
|
|
|
89
89
|
|
|
90
90
|
// Allow finite numbers only
|
|
91
91
|
if (!Number.isFinite(n)) {
|
|
92
|
-
throw new
|
|
92
|
+
throw new TypeError("Invalid number");
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
return n;
|
|
96
96
|
} catch {
|
|
97
|
-
throw new
|
|
97
|
+
throw new TypeError("The input parameter must be a valid number.");
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -71,9 +71,11 @@ export class WorkerPool<T, R> {
|
|
|
71
71
|
|
|
72
72
|
// Map all items using a round-robin distribution across workers
|
|
73
73
|
async mapAll(items: T[]): Promise<R[]> {
|
|
74
|
-
if (!Array.isArray(items))
|
|
75
|
-
|
|
74
|
+
if (!Array.isArray(items)) {
|
|
75
|
+
throw new TypeError("Items must be an array");
|
|
76
|
+
}
|
|
76
77
|
|
|
78
|
+
const results: R[] = new Array(items.length);
|
|
77
79
|
const workerCount = this.workers.length;
|
|
78
80
|
const tasks: Promise<void>[] = items.map((payload, idx) => {
|
|
79
81
|
const workerIndex = idx % workerCount;
|