1.0.0 • Published 5 years ago

romanarabic v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Library romanarabic

Convert Romans to Arabic and vice Versa

Contains two functions:

  • arabicToRomanNumbers(value)
  • romanToArabicNumbers(value)

arabicToRomanNumbers(value)

Optional value is a number. If value is:

less than 0

Returns roman numerals of value with a minus sign. F.e. -1 -> -I

0 or no value

Returns nulla

any positive number

Returns the Roman numeral

no number

Throws an error

romanToArabicNumbers(value)

Optional value is a Roman numeral string. If value is:

less than 0

Returns a negative number. F.e -IV -> -4

nulla or no value

Returns 0

any positive Roman number

Returns the number

any invalid Roman number

Throws an error

Prepare

Run:

npm install

To run the example:

npm run example

To test the library:

npm run test

Usage

Put romanarabic.js to your source code directory and:

const toRoman = require('./romanarabic').arabicToRomanNumbers;
const toArabic = require('./romanarabic').romanToArabicNumbers;

Example

const toRoman = require('./romanarabic').arabicToRomanNumbers;
const toArabic = require('./romanarabic').romanToArabicNumbers;

console.log(toRoman(45));   
//output XLV

console.log(toArabic('XXIV'));
//output 24
1.0.0

5 years ago