refactor(studio): extract pure helpers to src/util.js (step 2) - #17
Conversation
Move 9 state-free helpers (_parseTimeInput, _formatTime, _formatDate, _esc, Path_stem, _eqLabel, _compLabel, _polarToCartesian, _describeArc) out of the IIFE into src/util.js, imported back by the same names (call sites unchanged). Adds package.json (type:module, npm test) so the reusable CI runs the new tests/util.test.mjs real-import tests. main.js 2856 -> 2799. Move-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR extracts several state-free helper functions from ChangesUtility extraction cohort
Estimated code review effort: 2 (Simple) | ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR continues the Studio ES-module migration by extracting a set of pure, state-free helper functions from src/main.js into a dedicated src/util.js module, then validating the new module via real ES-module imports using Node’s built-in test runner.
Changes:
- Added
src/util.jsexporting nine pure helpers, keeping the original names to preserve existing call sites. - Updated
src/main.jsto import the extracted helpers and removed the inlined helper implementations. - Added Node test coverage for the helpers (
tests/util.test.mjs) and introduced a minimalpackage.jsonto run those tests vianpm test.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/util.test.mjs | Adds Node node:test coverage for the extracted utility helpers via real ESM import. |
| src/util.js | New module containing extracted pure helpers (exported under existing names). |
| src/main.js | Imports helpers from ./util.js and removes their previous in-file definitions. |
| package.json | Introduces ESM mode and an npm test script to run Node tests. |
| CHANGELOG.md | Documents migration step 2 and the new test/CI entrypoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot on #17: use 'node --test' (auto-discovery, no shell glob that breaks on Windows); correct the _formatDate comment (new Date doesn't throw; toLocaleDateString renders in host timezone, not UTC). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Step 2 of the studio migration. Moves 9 state-free helpers out of the IIFE into
src/util.js:_parseTimeInput,_formatTime,_formatDate,_esc,Path_stem,_eqLabel,_compLabel,_polarToCartesian,_describeArcmain.jsimports them by the same names, so call sites are unchanged. Addspackage.json(type:module,npm test) so the reusable CI runs the newtests/util.test.mjsreal-import tests.main.js2856 → 2799. Move-only, no behaviour change.Tests
node --test7/7,pytest25/25 (backend unaffected). Codex preflight: 0.Summary by CodeRabbit
M:SSwith optional milliseconds) and consistent time display formatting.