Socket
Book a DemoInstallSign in
Socket

roman-utils

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roman-utils

Package for parsing ints to roman digit and roman digits to ints

1.0.5
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Roman Utils

A lightweight and flexible TypeScript utility for converting between Roman numerals and integers. Easily convert numbers in both directions while optionally tracking conversion history.

✨ Features

  • Convert Roman numerals to integers
  • Convert integers to Roman numerals
  • Optional history tracking of all conversions
  • Simple API with strong typing

📦 Installation

npm install roman-utils

Or with Yarn:

yarn add roman-utils

🚀 Usage

import { RomanUtils } from 'roman-utils';

const utils = new RomanUtils(true); // true enables history recording

// Integer to Roman const result1 = utils.parse(1999); console.log(result1); // { direction: 'intToRoman', romanNumber: 'MCMXCIX', intNumber: 1999 }

// Roman to Integer const result2 = utils.parse('XLII'); console.log(result2); // { direction: 'romanToInt', romanNumber: 'XLII', intNumber: 42 }

// Access conversion history console.log(utils.record);

// Clear history utils.clearHistory();

🧠 API Reference

new RomanUtils(keepRecord: boolean = true)

Creates an instance of the converter.

  • keepRecord (optional): Whether to keep a history of conversions.

parse(input: string | number): RomanConversionRecord

Parses either a Roman numeral (as a string) or an integer (as a number) and returns a conversion record.

clearHistory(): void

Clears the internal history record.

record: RomanConversionRecord[]

An array of all previous conversions (if history is enabled).

🧱 Types

type ConversionDirection = 'romanToInt' | 'intToRoman';

type RomanConversionRecord = { direction?: ConversionDirection; romanNumber?: string; intNumber?: number; };

📁 Project Structure

roman-utils/
├── req/
│   ├── IntToRoman.ts
│   └── RomanToInt.ts
├── RomanUtils.ts

🛠 Dependencies

No external runtime dependencies.

📄 License

MIT License. See LICENSE for details.

Made with ❤️ by @pSkywalker

Keywords

roman

FAQs

Package last updated on 16 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.