Skip to content

Conversation

@hckhanh
Copy link
Owner

@hckhanh hckhanh commented Nov 12, 2025

This pull request refactors several functions related to reading and processing digit groups in Vietnamese number words, focusing on code readability, logic simplification, and consistent parameter handling. Minor formatting and code quality improvements are also included, along with updates to development dependencies.

Refactoring and Code Simplification

  • Replaced multi-line if statements with concise ternary expressions in readFirstGroup and readSubsequentGroup to improve readability in src/read/three-digits.ts.
  • Simplified the getDigitWord function by removing the intermediate variable and returning the mapped value directly in src/read/digits.ts.

Consistent Parameter Handling

  • Updated readHundreds to use groupLength instead of a boolean flag, and made related changes in calls to readHundreds, readTens, and readOnes for more predictable behavior in src/read/three-digits.ts. [1] [2]

Minor Code Quality Improvements

  • Added spacing and minor formatting for readability in utility functions such as allFollowingGroupsAreZero in src/read/utils.ts and calculateGroupTypes in src/read/groups.ts. [1] [2]

Dependency Updates

  • Updated development dependencies in package.json, including @biomejs/biome, syncpack, and tsdown to their latest versions.

Refactored multiple functions to use concise conditional expressions, improving readability and reducing code verbosity. These changes enhance maintainability without altering existing functionality.
Copilot AI review requested due to automatic review settings November 12, 2025 09:04
@hckhanh hckhanh self-assigned this Nov 12, 2025
@codecov-commenter
Copy link

codecov-commenter commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (21ee7ac) to head (fe2cfa9).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #75   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          245       238    -7     
  Branches        82        80    -2     
=========================================
- Hits           245       238    -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot finished reviewing on behalf of hckhanh November 12, 2025 09:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors conditional expressions in the Vietnamese number reading utilities to use ternary operators instead of if-statements, along with minor formatting improvements (blank lines).

  • Converts simple if-return statements to ternary operators across multiple functions
  • Removes an intermediate variable in getDigitWord for more concise code
  • Adds blank lines to improve code structure and readability

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/read/utils.ts Added blank lines for better code structure in allFollowingGroupsAreZero
src/read/three-digits.ts Converted conditional expressions to ternary operators in readHundreds, readTens, readFirstGroup, and readSubsequentGroup; added blank line in readOnes
src/read/groups.ts Converted if-else to ternary in processGroup with helpful inline comment; added blank lines in calculateGroupTypes
src/read/digits.ts Removed intermediate variable in getDigitWord for more concise code

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 12, 2025

CodSpeed Performance Report

Merging #75 will improve performances by 16.51%

Comparing optimize (fe2cfa9) with main (5c00605)

Summary

⚡ 1 improvement
✅ 63 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
display financial dashboard (20 metrics) 901.8 µs 774 µs +16.51%

Simplified the `readTens` function by replacing nested ternary operators with straightforward conditional statements. This improves readability and maintains the same functionality.
Reversed the ternary operator condition to improve code clarity and consistency with other similar functions. This adjustment maintains the original functionality while enhancing readability.
Replaced the `hasHundredsPosition` parameter with `groupLength` to improve clarity and make the function more versatile. Updated dependent code to reflect this change and maintain consistent behavior.
Renamed and refactored the variable `len > 1` to `hasTensPosition` for improved readability and intent clarity. Updated its usage across the function to enhance maintainability without changing the existing behavior.
Improved code readability and consistency in functions handling Vietnamese number words. Simplified conditionals, standardized parameter usage, and enhanced formatting to ensure maintainability without altering functionality.
Upgraded several devDependencies including `@biomejs/biome`, `syncpack`, and `tsdown` to the latest versions. This ensures compatibility with the latest features and improvements while maintaining stability. Updated the `pnpm-lock.yaml` to reflect these changes.
Replaced a nested ternary operator with explicit conditional statements in `groups.ts`. This enhances code readability and aligns with the consistent structure of similar functions. No functionality was altered.
Improved readability, simplified logic, and standardized parameter handling in functions processing Vietnamese number words. Made minor formatting updates, enhanced code quality, and updated development dependencies in `package.json`.
@hckhanh hckhanh merged commit 2ea7e8e into main Nov 12, 2025
5 checks passed
@hckhanh hckhanh deleted the optimize branch November 12, 2025 09:34
@sonarqubecloud
Copy link

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.

3 participants