units-shake

0.2.2 • Public • Published

units-shake

Simple library of unit conversion functions that can be individually imported as required (and minimised using tree shaking, hence the name).

Currently Supported Conversions

Pressure

  • inches of mercury (inHg)
  • millimeters of mercury (mmHg) or (torr)
  • pounds per square inch (psi)
  • kilopascals (kPa)
  • millibars (mb) or hectopascals (hPa)
  • pascal (Pa)
  • bar

Speed

  • kilometers per hour (km/h)
  • knots (kn)
  • metres per second (m/s)
  • miles per hour (mph)

Temperature

  • degrees fahrenheit (°F)
  • degrees celsius (°C)
  • kelvin (K)

Length

  • meters (m)
  • kilometers (km)
  • millimeters (mm)
  • miles (mi)
  • yards (yd)
  • feet (ft)
  • feet and inches (f'i")
  • inches (in)
  • mils (mil)
  • nautical miles (nmi)

Usage

All conversion functions are in the format ${type}${fromUnit}to${toUnit}. ${type} the type of value it is, e.g. pressure, temperature, speed, or length. ${fromUnit} is the unit you want to convert from. ${toUnit} is the unit you want to convert to. The units are those that are listed above without alphabetic characters, e.g. inHg, bar, kmh', and C`

Typescript Usage

import { temperatureFtoC } from 'units-shake/ts/temperature';

console.log(`72°F equals ${temperatureFtoC(72)}°C`);

ES6 Usage

import { temperatureFtoC } from 'units-shake/temperature';

console.log(`72°F equals ${temperatureFtoC(72)}°C`);

ES5 Usage

var temp = require('units-shake/es5/temperature');

console.log('72°F equals ' + temperatureFtoC(72) + '°C');

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i units-shake

    Weekly Downloads

    26

    Version

    0.2.2

    License

    GPL-3.0

    Unpacked Size

    195 kB

    Total Files

    20

    Last publish

    Collaborators

    • bytesnz