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

measurement-unit-converter

v1.4.3

Published

It is a npm package for converting units, including Angle, Area, Length, Mass, Speed, Temperature, Time, Volume

Downloads

10

Readme

Measurement Unit Converter

It is a npm package for converting units, including: Angle, Area, Length, Mass, Speed, Temperature, Time, and Volume.

Adding the following function:

  • Solve the problem of floating-point precision after unit conversion

Install

npm install measurement-unit-converter

How to use

Import

This line of code should be added at the begin of the code. In this example we import the enum LengthUnit and the function convertUnits.

import { LengthUnit, convertUnits } from './measurement-unit-converter';

Angle

const milliradians = 10;
const circles = convertUnits(milliradians, AngleUnit.MILLIRADIAN, AngleUnit.CIRCLE);
console.log(`${milliradians} milliradians are ${circles} circles`); // Output: "10 milliradians are 0.0015915494309189536 circles"

| Enum AngleUnit | | --- | | ARCMINUTE | | ARCSECOND | | CIRCLE | | DEGREE | | GON | | GRADIAN | | MILLIRADIAN | | MIL_NATO | | MIL_USSR | | MIL_SWEDEN | | OCTANT | | QUADRANT | | RADIAN | | REVOLUTION | | SEXTANT | | SIGN | | TURN |

Area

const squareInches = 10;
const squareMillimeters = convertUnits(squareInches, AreaUnit.SQUARE_INCH, AreaUnit.SQUARE_MILLIMETER);
console.log(`${squareInches} square inches are ${squareMillimeters} square millimeters`); // Output: "10 square inches are 6451.6 square millimeters"

| Enum AreaUnit | | --- | | ACRE | | ARE | | ARPENT | | BARN | | CIRCULAR_INCH | | CIRCULAR_MIL | | CUERDA | | HECTARE | | PLAZA | | ROOD | | SECTION | | SQUARE_CENTIMETER | | SQUARE_CHAIN | | SQUARE_DECAMETER | | SQUARE_DECIMETER | | SQUARE_FOOT | | SQUARE_HECTOMETER | | SQUARE_INCH | | SQUARE_KILOMETER | | SQUARE_METER | | SQUARE_MICROMETER | | SQUARE_MILE | | SQUARE_MILLIMETER | | SQUARE_NANOMETER | | SQUARE_PERCH | | SQUARE_POLE | | SQUARE_ROD | | SQUARE_YARD | | STREMMA | | TAHULLA | | TOWNSHIP | | VARAS_CASTELLANAS_CUAD | | VARAS_CONUQUERAS_CUAD |

Length

const meters = 10;
const feets = convertUnits(meters, LengthUnit.METER, LengthUnit.FOOT);
console.log(`${meters} meters are ${feets} feets`); // Output: "10 meters are 32.8084 feets"

| Enum LengthUnit | | --- | | ANGSTROM | | ASTRONOMICAL_UNIT | | BARLEYCORN | | CABLE | | CENTIMETER | | CHAIN | | DECIMETER | | ELL | | FATHOM | | FOOT | | FOOT_US_SURVEY | | FURLONG | | HAND | | HECTOMETER | | INCH | | KILOMETER | | LIGHT_YEAR | | METER | | MICROMETER | | MIL | | MILE | | MILLIMETER | | NANOMETER | | NAUTICAL_MILE | | PARSEC | | PICA | | PICOMETER | | VARA_CASTELLANA | | VARA_CONUQUERA | | YARD |

Mass

const pounds = 10;
const kilograms = convertUnits(pounds, WeightUnit.POUND, WeightUnit.KILOGRAM);
console.log(`${pounds} pounds are ${kilograms} kilograms`); // Output: "10 pounds are 4.53592 kilograms"

| Enum WeightUnit | | --- | | CARAT | | DECAGRAM | | EARTH_MASS | | FEMTOGRAM | | GRAIN | | GRAM | | HECTOGRAM | | HUNDREDWEIGHT_UK | | HUNDREDWEIGHT_US | | KILOGRAM | | KILOTON | | LONG_TON | | MEGATONNE | | MICROGRAM | | MILLIGRAM | | NANOGRAM | | OUNCE | | PICOGRAM | | POUND | | SHORT_TON | | SLUG | | SOLAR_MASS | | STONE_UK | | STONE_US | | TONNE |

Speed

const kilometersPerHour = 10;
const metersPerSecond = convertUnits(pints, SpeedUnit.KILOMETER_PER_HOUR, SpeedUnit.METER_PER_SECOND);
console.log(`${kilometersPerHour} kilometers per hour are ${metersPerSecond} meters per second`); // Output: "10 kilometers per hour are 2.7778 meters per second"

| Enum SpeedUnit | | --- | | CENTIMETER_PER_HOUR | | CENTIMETER_PER_MINUTE | | CENTIMETER_PER_SECOND | | EARTHS_VELOCITY | | FOOT_PER_HOUR | | FOOT_PER_MINUTE | | FOOT_PER_SECOND | | KILOMETER_PER_HOUR | | KILOMETER_PER_MINUTE | | KILOMETER_PER_SECOND | | KNOT | | MACH | | METER_PER_HOUR | | METER_PER_MINUTE | | METER_PER_SECOND | | MILE_PER_HOUR | | MILE_PER_MINUTE | | MILE_PER_SECOND | | MILLIMETER_PER_HOUR | | MILLIMETER_PER_MINUTE | | MILLIMETER_PER_SECOND | | NAUTICAL_MILE_PER_DAY | | NAUTICAL_MILE_PER_HOUR | | YARD_PER_HOUR | | YARD_PER_MINUTE | | YARD_PER_SECOND |

Temperature

const fahrenheit = 10;
const kelvin = convertUnits(fahrenheit, TemperatureUnit.FAHRENHEIT, TemperatureUnit.KELVIN);
console.log(`${fahrenheit} fahrenheit are ${kelvin} kelvin`); // Output: "10 fahrenheit are 260.92777777777775 kelvin"

| Enum TemperatureUnit | | --- | | CELSIUS | | FAHRENHEIT | | KELVIN | | RANKINE | | REAUMUR |

Time

const years = 10;
const microseconds = convertUnits(years, TimeUnit.YEAR, TimeUnit.MICROSECOND);
console.log(`${years} years are ${microseconds} microseconds`); // Output: "10 years are 315360000000000 microseconds"

| Enum TimeUnit | | --- | | CENTURY | | DAY | | DECADE | | FEMTOSECOND | | FORTNIGHT | | HOUR | | MICROSECOND | | MILLENNIUM | | MILLISECOND | | MINUTE | | MONTH | | MONTH_SYNODIC | | NANOSECOND | | PICOSECOND | | SECOND | | SHAKE | | WEEK | | YEAR | | YEAR_GREGORIAN | | YEAR_JULIAN | | YEAR_LEAP | | YEAR_TROPICAL |

Volume

const pintsUK = 10;
const cubicCentimeters = convertUnits(pintsUK, VolumeUnit.PINT_UK, VolumeUnit.CUBIC_CENTIMETER);
console.log(`${pintsUK} pints UK are ${cubicCentimeters} cubic centimeters`); // Output: "10 pints UK are 5682.61249997643 cubic centimeters"

| Enum VolumeUnit | | --- | | ACRE_FOOT | | BARREL_OIL | | BARREL_UK | | BARREL_US | | CENTILITER | | CUBIC_CENTIMETER | | CUBIC_DECAMETER | | CUBIC_DECIMETER | | CUBIC_FOOT | | CUBIC_INCH | | CUBIC_KILOMETER | | CUBIC_METER | | CUBIC_MILE | | CUBIC_MILLIMETER | | CUBIC_YARD | | CUP_UK | | CUP_US | | DECALITER | | DECILITER | | DRAM | | FLUID_OUNCE_UK | | FLUID_OUNCE_US | | GALLON_UK | | GALLON_US | | GIGALITER | | GILL_UK | | GILL_US | | KILOLITER | | LITER | | MEGALITER | | MICROLITER | | MILLILITER | | NANOLITER | | PICOLITER | | PINT_UK | | PINT_US | | QUART_UK | | QUART_US | | TABLESPOON | | TEASPOON |