@camc314/units
v1.0.1
Published
Units is a series of tools for converting between different units and prefixes
Downloads
7
Readme
Units
Units is a series of tools for converting between different units and prefixes
Convert Distance
Supported units:
- miles
- meters
- yard
- feet
- inch
import { ConvertDistance } from '@camc314/units';
console.log(ConvertDistance(5, { inputUnit: 'miles', outputUnit: 'meters' })); // returns ~8000 m
Convert Temperature
Supported units:
- Kelvin
- Celcius
- Fahrenheit
import { ConvertDistance } from '@camc314/units';
console.log(
ConvertDistance(32, { inputUnit: 'celcius', outputUnit: 'kelvin' })
); // returns 305.15
Convert Mass
Supported units:
- tonne
- gram
- stone
- pound
- ounce
import { ConvertDistance } from '@camc314/units';
console.log(ConvertMass(16, { inputUnit: 'ounce', outputUnit: 'pound' })); // returns 1
Add prefixes
Adds a prefix to a number For example going from 1000 (meters) to 1 kilo (meter)
- yotta
- zetta
- exa
- peta
- tera
- giga
- mega
- kilo
- hecto
- deca
- none
- deci
- centi
- milli
- micro
- nano
- pico
- femto
- atto
- zepto
- yocto
import { addPrefix } from '@cam314/units';
addPrefix(1000, 'kilo'); // 1000 -> 1
Remove prefixes
Removes a prefix from a number For example going from 1 kilo (meter) to 1000 (meters)
- yotta
- zetta
- exa
- peta
- tera
- giga
- mega
- kilo
- hecto
- deca
- none
- deci
- centi
- milli
- micro
- nano
- pico
- femto
- atto
- zepto
- yocto
import { removePrefix } from '@cam314/units';
removePrefix(1, 'kilo'); // 1 -> 1000
From prefix to prefix
Move from one prefix to another For example going from 1 kilo (meter) to 1,000,000 milli (meters)
import { fromPrefixToPrefix } from '@cam314/units';
fromPrefixToPrefix(1, 'kilo', 'milli'); // 1 -> 1,000,000