Skip to content

refactor(format): centralize number formatting - #720

Open
Marvelg256 wants to merge 1 commit into
StableRoute-Org:mainfrom
Marvelg256:refactor/format-01-number-module
Open

refactor(format): centralize number formatting#720
Marvelg256 wants to merge 1 commit into
StableRoute-Org:mainfrom
Marvelg256:refactor/format-01-number-module

Conversation

@Marvelg256

Copy link
Copy Markdown

Extract shared formatDecimals, formatCurrency, and formatPercent functions into src/lib/format.ts. Replace inline .toFixed calls in quote and status views with the new shared helpers. Refactor formatStroops to delegate to formatDecimals internally, eliminating the last raw toFixed in the module.

  • formatDecimals(value, fractionDigits): fixed decimal places + thousands separators
  • formatCurrency(value, symbol): currency amount (2 decimals) with configurable suffix
  • formatPercent(decimal, fractionDigits): decimal-to-percentage with % suffix

25 tests, 100% coverage. No new dependencies. Output unchanged.

Closes #496

Summary

Related Issue

Type Of Change

  • Bug fix
  • Feature
  • Documentation
  • Refactor or maintenance

Testing

  • npm run lint
  • npm test
  • npm run build

Contributor Checklist

  • Branch name follows type/area-slug where possible.
  • Tests were added or updated for new UI or behaviour.
  • Documentation was updated for visible or API-facing changes.
  • Accessibility was considered according to the Accessibility Conformance Statement (keyboard, screen-reader, color contrast, and reduced motion).
  • No unrelated CI workflow changes are included.

Notes For Reviewers


💬 Join the StableRoute Discord for questions, reviews, and faster merges.

Extract shared formatDecimals, formatCurrency, and formatPercent functions
into src/lib/format.ts. Replace inline .toFixed calls in quote and status
views with the new shared helpers. Refactor formatStroops to delegate to
formatDecimals internally, eliminating the last raw toFixed in the module.

- formatDecimals(value, fractionDigits): fixed decimal places + thousands separators
- formatCurrency(value, symbol): currency amount (2 decimals) with configurable suffix
- formatPercent(decimal, fractionDigits): decimal-to-percentage with % suffix

25 tests, 100% coverage. No new dependencies. Output unchanged.

Closes StableRoute-Org#496
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract a shared number-formatting module for the pairs and stats views

1 participant