@scottobert/roman-numerals
v1.3.0
Published
Utility functions for working with Roman Numerals
Readme
Utility functions for converting integers to roman numerals and vice versa.
✨ New: Vinculum (Overline) Notation Support
This library now supports vinculum notation (overline) for representing large numbers in Roman numerals (up to 3,999,999).
- Overlines are represented using a Unicode combining overline (U+0305) after each numeral character.
- Example: 5,000 is written as
V 5(V̅), 10,000 asX 5(X̅), etc. - Both conversion and validation functions support this format.
Example Usage
import { romanToInt, intToRoman, isValidRoman } from "@scottobert/roman-numerals";
console.log(intToRoman(5000)); // V̅
console.log(romanToInt("V̅")); // 5000
console.log(intToRoman(1234567)); // M̅C̅C̅X̅X̅X̅I̅I̅I̅CDLXVII
console.log(isValidRoman("M̅C̅M̅X̅C̅I̅V̅")); // trueInstall
npm install @scottobert/roman-numeralsRun tests
npm run testUsage
import { romanToInt, intToRoman } from "@scottobert/roman-numerals";
console.log(romanToInt("MCMXCIV")); // 1994
console.log(intToRoman(1994)); // MCMXCIVNew Feature: Validate Roman Numeral Strings
Check if a string is a valid Roman numeral. This can be useful for input validation before conversion.
Example
import { isValidRoman } from "@scottobert/roman-numerals";
console.log(isValidRoman("MCMXCIV")); // true
console.log(isValidRoman("INVALID")); // falseAuthor
👤 Scott Obert
- GitHub: @scottobert
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2022 Scott Obert. This project is GPL--2.0 licensed.
This README was generated with ❤️ by readme-md-generator
