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

1.0.1 • Public • Published

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)

Supported prefixes:
  • 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)

Supported prefixes:
  • 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

Readme

Keywords

none

Package Sidebar

Install

npm i @camc314/units

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

39.5 kB

Total Files

29

Last publish

Collaborators

  • camc314