@eomm/convert-units
![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)
A handy utility for converting between quantities in different units.
Install
npm install @eomm/convert-units
Usage
@eomm/convert-units
has a simple chained API that is easy to read.
Here's how you move between the metric units for volume:
var convert = require('@eomm/convert-units')
convert(1).from('l').to('ml')
Jump from imperial to metric units the same way:
convert(1).from('lb').to('kg')
Just be careful not to ask for an impossible conversion:
convert(1).from('oz').to('fl-oz')
You can ask convert-units
to select the best unit for you. You can also optionally explicitly exclude orders of magnitude or specify a cut off number for selecting the best representation.
convert(12000).from('mm').toBest()
convert(12000).from('mm').toBest({ exclude: ['m'] })
convert(900).from('mm').toBest({ cutOffNumber: 10 });
convert(1000).from('mm').toBest({ cutOffNumber: 10 })
You can get a list of the measurement types supported with .measures
convert().measures()
If you ever want to know the possible conversions for a unit, just use .possibilities
convert().from('l').possibilities()
convert().from('kg').possibilities()
You can also get the possible conversions for a measure:
convert().possibilities('mass')
You can also get the all the available units:
convert().possibilities()
To get a detailed description of a unit, use describe
convert().describe('kg')
To get detailed descriptions of all units, use list
.
convert().list()
You can also get detailed descriptions of all units for a measure:
convert().list('mass')
Supported Units
Length
- mm
- cm
- m
- in
- ft-us
- ft
- fathom
- mi
- nMi
Area
Mass
Volume
- mm3
- cm3
- ml
- l
- kl
- m3
- km3
- tsp
- Tbs
- in3
- fl-oz
- cup
- pnt
- qt
- gal
- ft3
- yd3
Volume Flow Rate
- mm3/s
- cm3/s
- ml/s
- cl/s
- dl/s
- l/s
- l/min
- l/h
- kl/s
- kl/min
- kl/h
- m3/s
- m3/min
- m3/h
- km3/s
- tsp/s
- Tbs/s
- in3/s
- in3/min
- in3/h
- fl-oz/s
- fl-oz/min
- fl-oz/h
- cup/s
- pnt/s
- pnt/min
- pnt/h
- qt/s
- gal/s
- gal/min
- gal/h
- ft3/s
- ft3/min
- ft3/h
- yd3/s
- yd3/min
- yd3/h'
Temperature
Time
- ns
- mu
- ms
- s
- min
- h
- d
- week
- month
- year
Frequency
- Hz
- mHz
- kHz
- MHz
- GHz
- THz
- rpm
- deg/s
- rad/s
Speed
Pace
- s/m
- min/km
- s/km
- s/ft
- min/km
- s/mi
Pressure
Digital
Illuminance
Parts-Per
Voltage
Current
Power
Apparent Power
Reactive Power
Energy
Reactive Energy
Angle
Charge
Force
Acceleration
Acknowledgements
This project has been forked from ben-ng/convert-units. All the credits before the commit d950cd1 goes to the ben-ng/convert-units project contributors. After, the project will be maintained by the me (Eomm).
License
Licensed under MIT.