romannumbersjs
v1.0.4
Published
Convert Arabic numbers to Roman and opposite
Maintainers
Readme
RomanNumbersJS
Convert Arabic numbers to Roman and vice versa in JavaScript.
Installation
npm install romannumbersjsUsage
CommonJS (Node.js)
const { convertToRoman, convertToArabic } = require("romannumbersjs");
convertToRoman(2024); // "MMXXIV"
convertToArabic("XII"); // 12ES Module
import { convertToRoman, convertToArabic } from "romannumbersjs";CDN (Browser)
<script src="https://unpkg.com/[email protected]/dist/index.min.js"></script>
<script>
convertToRoman(999); // "CMXCIX"
convertToArabic("CMXCIX"); // 999
</script>API
| Function | Parameter | Returns |
|----------|-----------|---------|
| convertToRoman(num) | Number between 1-3999 | Roman numeral string |
| convertToArabic(str) | Roman numeral string | Arabic number, or -1 for invalid input |
Project Structure
src/
index.ts TypeScript source
__test__/
index.test.js Jest tests
dist/ Build output (CJS + minified)
docs/ GitHub Pages deploy (generated)
docs-template/ Template files with %%VERSION%% placeholders
scripts/
deploy.js Deploy script (version replacement)
.github/workflows/
deploy.yml CI/CD pipelineDevelopment
npm installBuild
npm run buildTypeScript compilation + minify: dist/index.js, dist/index.min.js, dist/index.d.ts
Testing
npm testDeploy (GitHub Pages)
npm run deployThe scripts/deploy.js script:
- Copies
docs-template/contents todocs/ - Copies
dist/index.min.jstodocs/ - Replaces
%%VERSION%%placeholders with the version frompackage.json
CI/CD
The .github/workflows/deploy.yml automatically:
- Runs the build (
tsc+terser) - Runs the tests
- Generates the
docs/folder with the correct version - Deploys to GitHub Pages
Every push/merge to the main branch automatically deploys.
License
MIT
