-
Notifications
You must be signed in to change notification settings - Fork 1
Simplify conditional expressions in reading utilities #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Refactored multiple functions to use concise conditional expressions, improving readability and reducing code verbosity. These changes enhance maintainability without altering existing functionality.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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
getDigitWordfor 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 Performance ReportMerging #75 will improve performances by 16.51%Comparing Summary
Benchmarks breakdown
|
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`.
|



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
readFirstGroupandreadSubsequentGroupto improve readability insrc/read/three-digits.ts.getDigitWordfunction by removing the intermediate variable and returning the mapped value directly insrc/read/digits.ts.Consistent Parameter Handling
readHundredsto usegroupLengthinstead of a boolean flag, and made related changes in calls toreadHundreds,readTens, andreadOnesfor more predictable behavior insrc/read/three-digits.ts. [1] [2]Minor Code Quality Improvements
allFollowingGroupsAreZeroinsrc/read/utils.tsandcalculateGroupTypesinsrc/read/groups.ts. [1] [2]Dependency Updates
package.json, including@biomejs/biome,syncpack, andtsdownto their latest versions.