Skip to content

Releases: hckhanh/vn-number

[email protected]

12 Nov 09:37
c12b4b1

Choose a tag to compare

Patch Changes

  • 2ea7e8e: 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.

[email protected]

04 Nov 12:43

Choose a tag to compare

Patch Changes

  • 6c3cdee: Exclude test and benchmark files from the JSR package

[email protected]

04 Nov 08:59
a8bffa5

Choose a tag to compare

Patch Changes

  • e9b3f15: Simplified readVnNumber string conversion to improve performance
  • e9b3f15: Fixed logic to repeat "tỷ" based on group position dynamically, ensuring accurate representation for billions, octillions, and undecillions.

v2.0.0

03 Nov 13:45
014b6b1

Choose a tag to compare

Major Changes

  • 4b7c059: Performance Optimization & Code Quality Improvements

    Breaking Changes

    • Refactored from OOP to functional programming: Removed class-based architecture (NumberReader, Numbers, Thousand, Million, Billion, Zerofill classes) in favor of pure functional approach
    • Internal implementation completely restructured for better performance and maintainability
    • Note: Public API (readVnNumber) remains unchanged and fully compatible

    Performance Improvements

    • Eliminated class instantiation overhead: No more object creation for each 3-digit group
    • Removed property access overhead: Direct string index access instead of class properties
    • Eliminated inheritance chain lookups: Flat function calls instead of prototype chain traversal
    • Removed dynamic dispatch: Direct function calls instead of class lookup maps
    • Optimized string operations: More efficient concatenation patterns
    • Benchmarks: Maintained excellent performance (2.3-6.8M ops/sec for typical use cases)

    Code Quality

    • Reduced cognitive complexity: Refactored complex functions to meet SonarCloud standards (<15 complexity)
      • readThreeDigits: Complexity reduced from 27 to <15
      • readVnNumber: Complexity reduced from 37 to <15
    • Better code organization: Split monolithic file into 5 focused modules:
      • digits.ts - Digit mapping and conversion
      • utils.ts - Utility functions for grouping and validation
      • three-digits.ts - Three-digit group reading logic
      • groups.ts - Group type calculation and processing
      • index.ts - Clean public API entry point
    • Improved maintainability: Smaller, focused functions with single responsibilities
    • Better testability: Individual modules can be tested in isolation

    Testing

    • Expanded test coverage: Increased from 42 to 68 tests (+62% increase)
    • Comprehensive edge case coverage: Added extensive tests for:
      • All leading zero patterns (001, 068, 060, etc.)
      • All tens patterns (10-99) with special rules
      • All hundreds patterns (100-999)
      • Mixed magnitude numbers
      • Boundary values at each magnitude level
      • All Vietnamese reading rules (mốt, lăm, lẻ, không trăm)
    • 91 total tests passing (68 for read module, 23 for format module)

    Internal Changes

    • Removed 12 files (old class implementations and their tests)
    • Added 4 new modular files with clear separation of concerns
    • Maintained 100% backward compatibility for public API

Patch Changes

  • 4b7c059: Optimize logic of formatNumber function

v1.6.1

03 Nov 08:12

Choose a tag to compare

Patch Changes

  • 59d9cfb: Fix configurations for release workflow

1.5.7

01 Mar 13:56
8ee1df2

Choose a tag to compare

1.5.7 (2024-03-01)

Bug Fixes

  • types: update README and enhance code documentation (8ee1df2)

1.5.6

28 Feb 04:41
6b9edf4

Choose a tag to compare

1.5.6 (2024-02-28)

Bug Fixes

  • build: Add release note section and ignore all .*rc.json file pattern from release (6b9edf4)

1.5.5

28 Feb 04:30
7bc083b

Choose a tag to compare

1.5.5 (2024-02-28)

Performance Improvements

  • read: Improve error handling and refactor NumberReader (627299b)

1.5.4

28 Feb 02:05
4f62f6b

Choose a tag to compare

  • Update content in documentation