A simple Ember addon for converting between units.
Run this command in your project
ember install ember-convert-units
This addon can be used in two ways
/*
@param {number} quantity
@param {string} units
@param {string} newUnits
@returns {number} The quantity expressed in the new units
*/
function convertUnits(quantity, units, { to: newUnits }) { ... }
Example
import { convertUnits } from 'ember-convert-units';
convertUnits(2, 'pounds', { to: 'grams' }); // 907.18474
convertUnits(5, 'mi', { to: 'km' }); // 8.04672
Example
generates the text
907.18474 grams
8.04672 km
For more details see register-units.js.
Unit | Names |
---|---|
Nanometers | nanometres, nanometers, nm |
Micrometers | micrometres, micrometers, μm |
Millimeters | millimetres, millimeters, mm |
Centimeters | centimetres, centimeters, cm |
Meters | metres, meters, m |
Kilometers | kilometres, kilometers, km |
Inches | inches, in |
Feet | feet, ft |
Yards | yards, yd |
Miles | miles, mi |
Unit | Names |
---|---|
Micrograms | micrograms, μg |
Milligrams | milligrams, mg |
Grams | grams, g |
Killograms | kilograms, kg |
Tonnes | tonnes, metric ton |
Tons (US) | tons, ton |
Ounces | ounces, oz |
Pounds | pounds, lb |
Unit | Names |
---|---|
Nanoseconds | nanoseconds, ns |
Microseconds | microseconds, µs |
Milliseconds | milliseconds, ms |
Seconds | seconds, s |
Minutes | minutes, min |
Hours | hours, h |
Unit | Names |
---|---|
degrees Fahrenheit | degrees Fahrenheit, deg F, fahrenheit |
degrees Celsius | degrees Celsius, deg C, celsius |
Kelvin | kelvin |
Unit | Names |
---|---|
Meters per Second | m/s |
Meters per Hour | m/h |
Kilometers per Hour | km/h, kph |
Feet per Second | ft/s |
Feet per Hour | ft/h |
Miles per Hour | mi/h, mph |
Unit | Names |
---|---|
Nanopascals | nanopascals, npa |
Micropascals | micropascals, μpa |
Millipascals | millipascals, mpa |
Centipascals | centipascals, cpa |
Pascals | pascals, pa |
Kilopascals | kilopascals, kpa |
Nanobars | nanobars, nbar |
Microbars | microbars, μbar |
Millibars | millibars, mbar |
Centibars | centibars, cbar |
Bars | bars, bar |
Kilobars | kilobars, kbar |
Pounds per Square Inch | psi |
Atmosphere | atmosphere, at |
Unit | Names |
---|---|
Litres | litres, liters, L, l |
Millilitres | millilitres, milliliters, ml, mL |
Gallons | gallons, gal |
Quart | quart, qt |
Pint | pint, pt |
Fluid Ounces | fluid ounces, fl oz |
Acre Inch | acre inch, acre in, acre*in, acre*inch |
Acre Foot | acre foot, acre ft, acre*ft, acre*foot |
- Area
- Digital Storage
- Data Transfer Rate
Feel free to contribute new units if you need them!