@fmasclef/units
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Units converter

Convert units with ease using this lib. The following dimensions are available:

  • length
  • volume

compliance codecov code style: prettier

Usage

Method signature is convert(value: number, from: TUnit, to: TUnit). For instance, to convert 1 meter in inches, do the folowing:

ESM

import { convert } from "@fmasclef/units";
const value = convert(1, 'm', 'in');

CJS

const units = require("@fmasclef/units");
const value = units.convert(1, 'm', 'in');

Dimensions

length

system unit name
metric Qm Quettameter
Rm Ronnameter
Ym Yottameter
Zm Zettameter
Em Exameter
Pm Petameter
Tm Terameter
Gm Gigameter
Mm Megameter
km Kilometer
hm Hectometer
dam Decameter
m Meter
dm Decimeter
cm Centimeter
mm Millimeter
µm Micrometer
nm Nanometer
pm Picometer
fm Femtometer
am Attometer
zm Zeptometer
ym Yoctometer
rm Rontometer
qm Quectometer
imperial mil Mil
in Inch
yd Yard
ft-us US Survey Foot
ft Foot
fathom Fathom
mi Mile
nMi Nautical Mile
printing pt Point

volumes

system unit name
metric mm3 Cubic Millimeter
cm3 Cubic Centimeter
ml Millilitre
cl Centilitre
dl Decilitre
l Litre
kl Kilolitre
Ml Megalitre
Gl Gigalitre
m3 Cubic meter
km3 Cubic kilometer
imperial tsp Teaspoon
Tbs Tablespoon
in3 Cubic inch
fl-oz Fluid Ounce
cup Cup
pnt Pint
qt Quart
gal Gallon
ft3 Cubic foot
yd3 Cubic yard

Made & maintained with ❤️ in Lille. Freely inspired by convert-units.

CC-BY-SA 4.0

Package Sidebar

Install

npm i @fmasclef/units

Weekly Downloads

5

Version

1.0.0

License

CC BY-SA 4.0

Unpacked Size

22.2 kB

Total Files

14

Last publish

Collaborators

  • fmasclef