npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

toroman

v1.2.1

Published

Convert any number less than 4000 to roman numerals and back to integer

Downloads

23

Readme

toroman

A minimalist library for Roman numeral operations.

🚀 Features

  • Convert Arabic numerals to Roman numerals Ⅶ
  • Convert Roman numerals to Arabic numerals 🔢
  • Validate Roman numerals ✅
  • Add Roman numerals ➕
  • Subtract Roman numerals ➖
  • Get Roman numerals within a range 📡

📦 Installation

It can be installed with npm.

npm i toroman

📥 Usage

const roman = require("toRoman");

🔄 Convert integer to Roman numerals: toRoman

/**
 * toRoman - Convert an integer to Roman numerals
 * @param { number } value Integer to be converted to Roman numerals
 * @returns { string } Roman numeral representation of the input value
 */
function toRoman(value: number): string | Error {}

🔵 Example

console.log(roman.toRoman(765));

// Returns DCCLXV

🔁 Convert Roman numeral to integer: fromRoman

/**
 * fromRoman - Convert Roman numeral to integer
 * @param { string } value Roman numeral to be converted to integer
 * @returns { number } Integer representation of the input value
 */
export function fromRoman(value: string): number | Error {}

🔵 Example

console.log(roman.fromRoman("DCCLXV"));

// Returns 765

🔍 Confirm if string is valid Roman numeral: isRoman

/**
 * isRoman - Confirm that string is a valid Roman numeral
 * @param { string } value String to be tested
 * @returns { boolean } true or false
 */
export function isRoman(value: string): true | Error {}

🔵 Example

console.log(roman.isRoman("MMMCCXXXIV"));

// Returns true

➕ Sum Roman numerals and get output as Roman numeral or numbers: sum

/**
 * @param args Roman numerals to be added
 * @returns { string } Final Roman numeral
 */
export function sum(
  expected: "number" | "roman",
  ...args: string[]
): string | number | Error {}

🔵 Example

console.log(roman.sum("number", "X", "MXC"));

// Returns 1100

➖ Get difference between two Roman numerals and get output as Roman numeral or numbers: diff

/**
 * @param expected { string } Expected response type
 * @param numerals { string[] } Roman numerals to subtract
 * @returns { string | number }
 */
export function diff(expected: "number" | "roman", numerals: string[]) {}

🔵 Example

console.log(roman.diff("number", ["X", "MXC"]));

// Returns 1080

📡 Get a range of Roman numerals: range

/**
 * Get range of Roman numerals
 * @param end { string | number } Value to stop at
 * @param start { string | number } Value to start from
 * @param intervals { string | number } Difference between values
 */
export function range(
  end: string | number,
  start: string | number = "I",
  intervals: string | number = "I"
): string[] | Error {}

🔵 Examples

console.log(roman.range(7));

// Returns [ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII' ]
console.log(roman.range("IX"));

// Returns [ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX' ]
console.log(roman.range(12, 7));

// Returns [ 'VII', 'VIII', 'IX', 'X', 'XI', 'XII' ]
console.log(roman.range(12, "IX"));

// Returns [ 'IX', 'X', 'XI', 'XII' ]
console.log(roman.range(22, 3, 5));

// Returns [ 'III', 'VIII', 'XIII', 'XVIII' ]

✨ Found this project useful?

If you found this project useful or you like what you see, then please consider giving it a :star: on Github and sharing it with your social media folks 🙂.