# typescript-roman-numbers-converter

> TypeScript package that converts arabic number to roman notation

Latest version **1.2.3** (published 2023-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install typescript-roman-numbers-converter
pnpm add typescript-roman-numbers-converter
yarn add typescript-roman-numbers-converter
bun add typescript-roman-numbers-converter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2023-04-06 |
| First published | 2022-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Davide Cifariello |
| Maintainers | d9c4 |
| Keywords | typescript, roman number, roman, converter, format |

## Links

- npm: https://www.npmjs.com/package/typescript-roman-numbers-converter
- Repository: https://github.com/d9c4/typescript-roman-numbers-converter
- Homepage: https://github.com/d9c4/typescript-roman-numbers-converter#readme
- Issues: https://github.com/d9c4/typescript-roman-numbers-converter/issues
- npm.io page: https://npm.io/package/typescript-roman-numbers-converter

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^18.15.11

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.2.3 (latest) — 2023-04-06
- 1.2.2 — 2022-04-02
- 1.2.1 — 2022-03-30
- 1.2.0 — 2022-03-30
- 1.1.0 — 2022-03-29
- 1.0.0 — 2022-03-29
- 0.0.1 — 2022-03-29

## README

[![NPM](https://nodei.co/npm/typescript-roman-numbers-converter.png?compact=true)](https://nodei.co/npm/typescript-roman-numbers-converter/)


Typescript Roman Numbers Converter
==============
[![NPM](https://img.shields.io/npm/l/typescript-roman-numbers-converter?style=flat-square)](#)

A simple and easy to use Typescript package that converts a given arabic number to roman number format
## Installation

<pre><code>$ npm install --save typescript-roman-numbers-converter</code></pre>

## How to use it

First of all import the package:

<pre><code>import { toRoman } from "typescript-roman-numbers-converter";</code></pre>

### toRoman

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.

<pre>
<code>
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
</code>
</pre>

### toArabic

Converts the given **string** into a **number** that represents the same value in arabic notation.

<pre>
<code>
let a: number;
let r: string;

r = "XXXII"
a = toArabic(a); //a is now equal to 32
</code>
</pre>

### isRoman

Returns true if the given **string** is a valid written roman number

<pre>
<code>
let b = isRoman("MCM"); //b is true
let b_2 = isRoman("ABC"); //b_2 is false
</code>
</pre>



### RomanNumber class

Is the class that holds the value of the roman numeral

<pre>
<code>
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;
  }
}
</code>
</pre>

### toRomanLarge, toRomanLargeStr

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.

<pre>
<code>
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"
</code>
</pre>

---
_Source: https://npm.io/package/typescript-roman-numbers-converter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
