Skip to content

Commit 0bc7bca

Browse files
author
DavidQ
committed
Move numeric edge helpers to shared math
1 parent 0d6d260 commit 0bc7bca

8 files changed

Lines changed: 30 additions & 15 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MODEL: GPT-5.4-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_REPO_STRUCTURE_68_MOVE_MAP_ID_HELPERS_TO_SHARED.md exactly.
5-
Package to <project folder>/tmp/BUILD_PR_REPO_STRUCTURE_68_MOVE_MAP_ID_HELPERS_TO_SHARED_delta.zip
4+
Execute docs/pr/BUILD_PR_REPO_STRUCTURE_69_MOVE_MAP_NUMERIC_EDGE_HELPERS_TO_SHARED_MATH.md exactly.
5+
Package to <project folder>/tmp/BUILD_PR_REPO_STRUCTURE_69_MOVE_MAP_NUMERIC_EDGE_HELPERS_TO_SHARED_MATH_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Move id helpers to shared utils
1+
Move numeric edge helpers to shared math

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: numeric edge helpers
1+
Next: final inspector cleanup
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
id helpers consolidation
1+
numeric helpers consolidation

docs/dev/reports/file_tree.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
src/engine/debug/inspectors/shared/inspectorUtils.js
2-
src/shared/utils/idUtils.js
2+
src/shared/math/numberNormalization.js
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# BUILD PR — Move Numeric Edge Helpers to Shared Math
2+
3+
## Files
4+
- src/engine/debug/inspectors/shared/inspectorUtils.js
5+
- src/shared/math/numberNormalization.js
6+
7+
## Actions
8+
- move remaining numeric edge helpers into shared math
9+
- import from shared
10+
11+
## Constraints
12+
- exact files only
13+
- no refactor

src/engine/debug/inspectors/shared/inspectorUtils.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ inspectorUtils.js
88
import { asPositiveInteger } from "../../../../shared/utils/numberUtils.js";
99
import { sanitizeText } from "../../../../shared/utils/stringUtils.js";
1010
import { createId, isValidId } from "../../../../shared/utils/idUtils.js";
11+
import { asFinite, asNonNegativeInteger } from "../../../../shared/math/numberNormalization.js";
1112

1213
export { sanitizeText };
1314
export { createId, isValidId };
15+
export { asFinite, asNonNegativeInteger };
1416

1517
export function asObject(value) {
1618
return value !== null && typeof value === "object" && !Array.isArray(value)
@@ -22,15 +24,6 @@ export function asArray(value) {
2224
return Array.isArray(value) ? value : [];
2325
}
2426

25-
export function asFinite(value, fallback = 0) {
26-
return Number.isFinite(value) ? Number(value) : fallback;
27-
}
28-
29-
export function asNonNegativeInteger(value, fallback = 0) {
30-
const normalized = Math.floor(asFinite(value, fallback));
31-
return normalized >= 0 ? normalized : Math.max(0, Math.floor(asFinite(fallback, 0)));
32-
}
33-
3427
export { asPositiveInteger };
3528

3629
export function cloneJson(value) {

src/shared/math/numberNormalization.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ export function sanitizePositiveNumber(value, fallback) {
1717
return number > 0 ? number : fallback;
1818
}
1919

20+
export function asFinite(value, fallback = 0) {
21+
return Number.isFinite(value) ? Number(value) : fallback;
22+
}
23+
24+
export function asNonNegativeInteger(value, fallback = 0) {
25+
const normalized = Math.floor(asFinite(value, fallback));
26+
return normalized >= 0 ? normalized : Math.max(0, Math.floor(asFinite(fallback, 0)));
27+
}
28+
2029
export function roundNumber(value) {
2130
if (!Number.isFinite(value)) {
2231
return value;

0 commit comments

Comments
 (0)