Skip to content

Comments

Optimization#25

Merged
Zubs merged 3 commits intomasterfrom
optimization
Oct 11, 2025
Merged

Optimization#25
Zubs merged 3 commits intomasterfrom
optimization

Conversation

@Zubs
Copy link
Owner

@Zubs Zubs commented Oct 11, 2025

This pull request refactors and improves the Roman numeral utility functions in both the JavaScript (index.js) and TypeScript (src/index.ts) files. The most significant changes include simplifying the logic for validating and converting Roman numerals and improving error handling and documentation.

Functionality and logic improvements:

  • Refactored the toRoman function to use a mapping approach for converting numbers to Roman numerals, replacing the previous verbose logic with a more concise and maintainable loop. This also changes error handling from returning Error objects to throwing exceptions for invalid input. [1] [2]
  • Improved the isRoman function by replacing the use of forEach with a standard for loop for checking the maximum allowed occurrences of Roman numeral characters, making the logic clearer and ensuring early exit on invalid input. [1] [2]

Documentation and type improvements:

  • Fixed typos and clarified the JSDoc comments for the getCount function in both files, improving code readability and developer experience. [1] [2]

@Zubs Zubs merged commit 9901d34 into master Oct 11, 2025
2 of 3 checks passed
@Zubs Zubs deleted the optimization branch October 11, 2025 16:00
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.

1 participant