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 🙏

© 2026 – Pkg Stats / Ryan Hefner

unit-converter-package-roshan

v1.0.0

Published

Simple unit conversion utilities

Readme

unit-converter-package-roshan

A lightweight, type-safe unit conversion utility for JavaScript and TypeScript projects.

Supports length and temperature conversions with zero dependencies and full tree-shaking support.


✨ Features

  • 📏 Length conversion (cm, m, km)
  • 🌡️ Temperature conversion (celsius, fahrenheit, kelvin)
  • ⚡ Fast and lightweight
  • 🧠 Fully typed (TypeScript)
  • 🌳 Tree-shakeable
  • 🚫 No external dependencies
  • 🧪 Tested with Jest

📦 Installation

npm install unit-converter-package-roshan

or

yarn add unit-converter-package-roshan

🚀 Usage

Importing

import {
  convertLength,
  convertTemperature,
  LengthUnit,
  TemperatureUnit
} from "unit-converter-package-roshan";

📏 Length Conversion

Supported Units

  • cm
  • m
  • km

Example

convertLength(100, "cm", "m"); // 1
convertLength(2, "km", "m");   // 2000
convertLength(1500, "m", "km"); // 1.5

Type Safety

const unit: LengthUnit = "cm"; // ✅
const wrongUnit: LengthUnit = "mm"; // ❌ TypeScript error

🌡️ Temperature Conversion

Supported Units

  • celsius
  • fahrenheit
  • kelvin

Example

convertTemperature(0, "celsius", "fahrenheit"); // 32
convertTemperature(32, "fahrenheit", "celsius"); // 0
convertTemperature(0, "celsius", "kelvin"); // 273.15

Floating Point Precision

For temperature conversions, floating-point math is used. Use rounding if required:

const value = convertTemperature(32, "fahrenheit", "kelvin");
value.toFixed(2); // "273.15"

🧠 API Reference

convertLength

convertLength(
  value: number,
  from: LengthUnit,
  to: LengthUnit
): number

convertTemperature

convertTemperature(
  value: number,
  from: TemperatureUnit,
  to: TemperatureUnit
): number

🧪 Testing

This package is tested using Jest.

npm test

🌳 Tree Shaking

This package uses ES Modules and supports tree-shaking:

import { convertLength } from "unit-converter-package-roshan";

Unused functions are excluded from the final bundle.


🛠️ Built With

  • TypeScript
  • Jest
  • Zero runtime dependencies

🧩 Roadmap

Planned enhancements:

  • Weight units (g, kg, lb)
  • Time units (s, min, hr)
  • Speed units (m/s, km/h)
  • Chainable API
  • Optional rounding helpers

🤝 Contributing

Pull requests are welcome.

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for your changes
  4. Submit a pull request

📄 License

MIT License © Roshan