
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
typescript-roman-numbers-converter
Advanced tools
TypeScript package that converts arabic number to roman notation
A simple and easy to use Typescript package that converts a given arabic number to roman number format
$ npm install --save typescript-roman-numbers-converter
First of all import the package:
import { toRoman } from "typescript-roman-numbers-converter";
Converts the given number into a string that represents the same value in roman notation. Due to limitations, we cannot convert decimal numbers, numbers below 1 and numbers bigger than 3999.
let a: number;
let r: string;
a = 32
r = toRoman(a); //r is now equal to "XXXII"
let a_2 = -12
r = toRoman(a_2); //r is now "" due to limitations
Converts the given string into a number that represents the same value in arabic notation.
let a: number;
let r: string;
r = "XXXII"
a = toArabic(a); //a is now equal to 32
Returns true if the given string is a valid written roman number
let b = isRoman("MCM"); //b is true
let b_2 = isRoman("ABC"); //b_2 is false
Is the class that holds the value of the roman numeral
class RomanNumber {
//holds the numeric value of the number
num: number;
//holds the roman numeral that represents the value of `num`
str: string;
// elaborations fields for use the large conversion
baseUnits: number = 0;
thousands: number = 0;
constructor(num: number, str: string) {
this.num = num;
this.str = str;
}
}
toRomanLarge converts the arab number passed as parameter to an instance of RomanNumber class. With this method we can convert numbers bigger than 3999. The string representation of the converted number wraps the thousands with an underscore and round braces. toRomanLargeStr is returns the value of str after calling toRomanLarge.
let a: number;
let r: RomanNumber(0,'');
let r_2: string;
a = 1350021
r = toRomanLarge(a); //r is now equal to {num: 1350021, str: "(_MCCCL)XXI", baseUnits: 21, thousands: 1350}
r_2 = toRomanLargeStr(a); //r_2 is now equal to "(_MCCCL)XXI"
FAQs
TypeScript package that converts arabic number to roman notation
The npm package typescript-roman-numbers-converter receives a total of 228 weekly downloads. As such, typescript-roman-numbers-converter popularity was classified as not popular.
We found that typescript-roman-numbers-converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.