Skip to content

Commit b8bf24e

Browse files
committed
Refactor digit group processing for readability
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.
1 parent 190a848 commit b8bf24e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.changeset/gold-guests-attack.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"vn-number": patch
3+
---
4+
5+
Refactor several functions related to reading and processing digit groups in Vietnamese number words. The changes focus on improving code readability, simplifying logic, and making parameter handling more consistent across functions.
6+
7+
### Refactoring and Code Simplification
8+
9+
* Refactored conditional logic in `readFirstGroup` and `readSubsequentGroup` to use concise ternary expressions instead of multi-line if statements, improving readability in `src/read/three-digits.ts`.
10+
* Simplified the implementation of `getDigitWord` by removing the intermediate variable and directly returning the mapped value in `src/read/digits.ts`.
11+
12+
### Consistent Parameter Handling
13+
14+
* Updated `readHundreds` to use `groupLength` instead of a boolean flag, and adjusted calls to `readHundreds`, `readTens`, and `readOnes` to consistently use `groupLength` or derived flags, ensuring more predictable behavior in `src/read/three-digits.ts`. [[1]](diffhunk://#diff-3fec7bfdd409e9017a9411ada902007e8e4e09dfe468f1566e38e002a7b0a521L6-R7) [[2]](diffhunk://#diff-3fec7bfdd409e9017a9411ada902007e8e4e09dfe468f1566e38e002a7b0a521L56-R65)
15+
16+
### Minor Code Quality Improvements
17+
18+
* Added spacing and minor formatting improvements for readability in utility functions such as `allFollowingGroupsAreZero` in `src/read/utils.ts` and `calculateGroupTypes` in `src/read/groups.ts`. [[1]](diffhunk://#diff-3f1a9cf533aed941787f7a40ca3900d359c1da32f1bc1536d2380c3b4968dbb4R26-R31) [[2]](diffhunk://#diff-8c09ad2ec1c3b0524c8cdbfe07826bfc856285b756983a817f609404a880821aR14-R20)
19+
* Refactored the logic in `processGroup` to use a concise conditional expression when choosing between processing the first group or subsequent groups in `src/read/groups.ts`.

0 commit comments

Comments
 (0)