Skip to content

Commit 5c8a5c1

Browse files
author
DavidQ
committed
Promote asObject/asArray into shared utils and remove duplicates from debug network utilities.
1 parent 6edf7ff commit 5c8a5c1

9 files changed

Lines changed: 27 additions & 42 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ MODEL: GPT-5.4-codex
22
REASONING: high
33

44
COMMAND:
5-
Execute exactly docs/pr/BUILD_PR_SHARED_EXTRACTION_53_ASTEROIDS_NUMBER_SANITIZERS_TO_SHARED_MATH.md.
6-
Modify only the exact target files listed in the PR doc.
7-
Do not expand scope.
8-
Package the delta zip to:
9-
<project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_53_ASTEROIDS_NUMBER_SANITIZERS_TO_SHARED_MATH_delta.zip
5+
Execute exactly docs/pr/BUILD_PR_SHARED_EXTRACTION_54_ASOBJECT_ASARRAY_TO_SHARED_UTILS.md.
6+
Modify only listed files.
7+
Package to:
8+
<project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_54_ASOBJECT_ASARRAY_TO_SHARED_UTILS_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 Asteroids-local number sanitizers into src/shared/math/numberNormalization.js and replace local definitions with shared imports.
1+
Promote asObject/asArray into shared utils and remove duplicates from debug network utilities.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
After commit, inspect remaining number-related helpers and continue with the next exact shared-math extraction cluster only if exact files and consumer replacement are known.
1+
After commit, identify next duplicate cluster (likely normalizeNumber or string utils) with exact files only.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
- Promote Asteroids-local finite/positive number sanitizers into canonical shared math
2-
- Remove local numeric helper duplication from AsteroidsWorld.js
3-
- Preserve exact behavior and existing gameplay usage
1+
- Consolidated asObject/asArray into shared utils
2+
- Removed duplicates from debug network utilities

docs/dev/reports/file_tree.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
src/shared/math/numberNormalization.js
2-
games/Asteroids/game/AsteroidsWorld.js
3-
docs/pr/BUILD_PR_SHARED_EXTRACTION_53_ASTEROIDS_NUMBER_SANITIZERS_TO_SHARED_MATH.md
4-
docs/dev/codex_commands.md
5-
docs/dev/commit_comment.txt
6-
docs/dev/next_command.txt
7-
docs/dev/reports/file_tree.txt
8-
docs/dev/reports/change_summary.txt
9-
docs/dev/reports/validation_checklist.txt
1+
src/shared/utils/objectUtils.js
2+
src/shared/utils/networkDebugUtils.js
3+
src/engine/debug/network/shared/networkDebugUtils.js
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# Validation Checklist
2-
- Confirm only the exact target files were modified
3-
- Confirm no wildcard or repo-wide scanning was introduced into the implementation
4-
- Confirm imports resolve correctly after the change
5-
- Confirm no dead local helper remains in the touched files for this PR purpose
6-
- Confirm no unrelated refactor or formatting-only churn was introduced
7-
- Confirm no non-number helper in AsteroidsWorld.js was changed
1+
- Exact files only
2+
- No duplicate helpers remain
3+
- Imports resolve
4+
- No behavior change

src/engine/debug/network/shared/networkDebugUtils.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ networkDebugUtils.js
66
*/
77

88
import { asNumber } from "../../../../shared/math/numberNormalization.js";
9+
import { asObject, asArray } from "../../../../shared/utils/objectUtils.js";
910

1011
export function sanitizeText(value) {
1112
return typeof value === "string" ? value.trim() : "";
1213
}
1314

14-
export function asObject(value) {
15-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
16-
}
17-
18-
export function asArray(value) {
19-
return Array.isArray(value) ? value : [];
20-
}
15+
export { asObject, asArray };
2116

2217
export { asNumber };
2318

src/shared/utils/networkDebugUtils.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import { asNumber } from "../math/numberNormalization.js";
2+
import { asObject, asArray } from "./objectUtils.js";
23

34
function sanitizeText(value) {
45
return typeof value === "string" ? value.trim() : "";
56
}
67

7-
function asObject(value) {
8-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
9-
}
10-
11-
function asArray(value) {
12-
return Array.isArray(value) ? value : [];
13-
}
14-
158
function toSafeKey(value) {
169
return sanitizeText(value);
1710
}

src/shared/utils/objectUtils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@ function isPlainObject(value) {
1313
return !!value && typeof value === 'object' && !Array.isArray(value);
1414
}
1515

16-
export { isObject, isPlainObject };
16+
function asObject(value) {
17+
return isObject(value) ? value : {};
18+
}
19+
20+
function asArray(value) {
21+
return Array.isArray(value) ? value : [];
22+
}
23+
24+
export { isObject, isPlainObject, asObject, asArray };

0 commit comments

Comments
 (0)