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

lighthouse-unit-converter

v1.0.7

Published

Fast native C++ unit converter with support for length, mass, temperature, time, and volume conversions

Downloads

719

Readme

lighthouse-unit-converter

A fast native C++ unit converter for Node.js with support for multiple unit categories.

Installation

npm install lighthouse-unit-converter

No build tools required! The package includes a pure JavaScript fallback that works everywhere. For better performance, the native C++ addon will be used if build tools are available.

Optional: Enable Native Performance

For ~10x faster conversions, install build tools:

Windows:

  • Install Visual Studio Build Tools: https://visualstudio.microsoft.com/downloads/
  • Select "Desktop development with C++" workload

macOS:

xcode-select --install

Linux:

sudo apt-get install build-essential python3

Then reinstall: npm install lighthouse-unit-converter

Features

  • Fast native C++ implementation
  • Support for multiple categories: length, mass, temperature, time, and volume
  • Zero dependencies (except build tools)
  • Type-safe conversions

Usage

const converter = require('lighthouse-unit-converter');

// Convert units
console.log(converter.convert(10, "m", "ft"));  // 32.8084 (meters to feet)
console.log(converter.convert(100, "celsius", "fahrenheit"));  // 212
console.log(converter.convert(5, "mi", "km"));  // 8.04672

// Get available categories
console.log(converter.getCategories());  // ['length', 'mass', 'temperature', 'time', 'volume', 'angle', 'pace', 'speed']

// Get units for a specific category
console.log(converter.getUnits("length"));  // ['mm', 'cm', 'm', 'km', 'in', 'ft', 'yd', 'mi', 'nmi']
console.log(converter.getUnits("angle"));   // ['rad', 'deg', 'grad', 'arcmin', 'arcsec']

Supported Units

Length

  • mm, cm, m, km, in, ft, yd, mi, nmi

Mass

  • mg, g, kg, lb, oz, ton, tonne

Temperature

  • celsius, kelvin, fahrenheit

Time

  • ms, s, min, hr, day, week

Volume

  • ml, l, gal, qt, pt, cup, floz

Angle

  • rad (radian), deg (degree), grad (gradian), arcmin (arcminute), arcsec (arcsecond)

Pace

  • min/km (minute per kilometer), s/m (second per meter), min/mi (minute per mile), s/ft (second per foot)

Speed

  • m/s (meter per second), km/h (kilometer per hour), mph (mile per hour), knot, ft/s (foot per second)

API

convert(value, fromUnit, toUnit)

Convert a value from one unit to another.

Parameters:

  • value (number): The value to convert
  • fromUnit (string): The source unit
  • toUnit (string): The target unit

Returns: number - The converted value

getCategories()

Get all available unit categories.

Returns: string[] - Array of category names

getUnits(category)

Get all units for a specific category.

Parameters:

  • category (string): The category name

Returns: string[] - Array of unit names

Building from Source

npm install
npm run install

Adding New Units

All unit definitions are stored in units.json. To add new units:

  1. Edit units.json to add your unit with its conversion factor
  2. Run npm run generate to regenerate the C++ and JavaScript files
  3. Test: npm test

Example adding a new unit:

{
  "length": {
    "base": "meter",
    "units": {
      "furlong": 201.168  // Add new unit here
    }
  }
}

Requirements

  • Node.js >= 16.0.0
  • Python 3.x (for node-gyp)
  • C++ compiler with C++17 support

License

ISC