Skip to content

matthieubosquet/numerals

Repository files navigation

Node.js CI codecov

Numerals

Convert numbers to their form in a numeral system.

Currently only implements the roman numerals system converter.

See also: https://en.wikipedia.org/wiki/List_of_numeral_systems

Try the converter!

How-to?

  • Install the package
npm i numerals
  • Use the package as an ECMAScript module
import { convertNumberToNumeralForm, Language, NumeralForm } from 'numerals';

let x = convertNumberToNumeralForm(8, NumeralForm.Roman, Language.English);

// Outputs VIII
console.log(x);
  • Use the package as a CommonJS module
const { convertNumberToNumeralForm, Language, NumeralForm } = require('numerals')

let x = convertNumberToNumeralForm(8, NumeralForm.Roman, Language.English)

// Outputs VIII
console.log(x);
  • Get the web component
wget https://neig.es/numerals/script/numerals-ui.js
  • Use the web component
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Numerals converter</title>
</head>
<body>
    <numerals-ui></numerals-ui>
    <script src="./script/numerals-ui.js"></script>
</body>
</html>