dkin-om / romanice

A JavaScript library for converting to/from Roman numerals.

Home Page:https://npm.im/romanice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

romanice - Convert to/from Roman numerals

NPM

Version Build Status Coverage Status License

A JavaScript library for converting to/from Roman numerals, e.g., 3888MMMDCCCLXXXVIII, 38888ↂↂↂↁↀↀↀⅮⅭⅭⅭⅬⅩⅩⅩⅤⅠⅠⅠ

Install

npm install romanice

Import

CommonJS

const Romanice = require('romanice');

ES6

import * as Romanice from 'romanice';

Browser

<script src="https://cdn.jsdelivr.net/npm/romanice/dist/romanice.min.js"></script>

Usage

Standard - I, V, X, L, C, D, M

const { romanice } = Romanice;
const standardConverter = romanice();

const roman = standardConverter.toRoman(3888);
// roman === 'MMMDCCCLXXXVIII'

const decimal = standardConverter.fromRoman('MMMCMXCIX');
// decimal === 3999

Unicode - , , , , , , , ,

const { romanice, symbols } = Romanice;
const unicodeConverter = romanice(symbols.UNICODE);

const roman = unicodeConverter.toRoman(38888);
// roman === 'ↂↂↂↁↀↀↀⅮⅭⅭⅭⅬⅩⅩⅩⅤⅠⅠⅠ'

const decimal = unicodeConverter.fromRoman('ↂↂↂↀↂⅭↀⅩⅭⅠⅩ');
// decimal === 39999

Syntax

romanice([symbols])

symbols - Array of Roman numeral symbols representing the character set. If omitted, assumes the standard symbols ['I', 'V', 'X', 'L', 'C', 'D', 'M'].

License

MIT

About

A JavaScript library for converting to/from Roman numerals.

https://npm.im/romanice

License:MIT License


Languages

Language:JavaScript 100.0%