0.5.1 • Published 8 years ago

easy-converter v0.5.1

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

easy-converter

Build Status npm version license

nodejs minimum version Windows Linux OSX

NPM

The ambitious, easy to use unit converter

Introduction

easy-converter is a unit converter that will handle weight, length, area (..) conversions.

For now it supports:

  • Length (distance)
  • Mass (weight)
  • Area
  • Computer storage

Installation:

npm install --save easy-converter

Test:

npm run test

or

npm test

Example:

var easyconverter = require('easy-converter');
var c = new easyconverter();

c.convert(1, 'cm').to('m');

The converter will return NaN in case of an unauthorized conversion.

c.convert(1, 'cm').to('b');
// => NaN

Supported units :

Distance

UnitAbbreviation in easy-converter
milmil
inchin
footft
yardyd
milemi
capefootcp
rodrd
angstromA
nanometern
micronµ
millimetermm
centimetercm
meterm
kilometerkm
light-yearly
light-dayld
light-hourlh
light-minutelm
light-secondls

Weight

UnitAbbreviation in easy-converter
carat (metric)ct
point (metric)pt
dram (avdp)adr
dram (troy)tdr
grain (metric)mgr
grain (troy)tgr
gramg
hundredweight (long)lhwt
hundredweight (short)shwt
kilogramkg
megagramMg
milligrammg
ounce (avdp)aoz
ounce (troy)toz
pennyweightdwt
pound (avdp)alb
pound (metric)lb
pound (troy)tlb
slugslug
stonest
ton-assay (long)lAT
ton-assay (short)sAT
ton (long)ltn
ton (short)stn
ton-metrict
tonne (U.S. metric ton)t

Area

UnitAbbreviation in easy-converter
square inchin2
square footft2
square yardyd2
square milemi2
acreac
hectareha
square millimetermm2
square centimetercm2
square meterm2
square kilometerkm2

Computer storage

UnitAbbreviation in easy-converter
bitb
kilobitkb
megabitMb
gigabitGb
terabitTb
petabitPb
exabitEb
zettabitZb
yottabitYb
nibblenibble
byteB
kilobytekB
megabyteMB
gigabyteGB
terabyteTB
petabytePB
exabyteEB
zettabyteZB
yottabyteYB

How to contribute

Just fork and create a PR! Try to match the coding style and indentation (2 spaces tabs) of the files in this repository.

To add a new converter just add add a module in lib/converters that exports an object containing units as keys and ratios as value the reference unit should have the value of 0.

Example:

module.exports = {
  "a": 1,
  "b": 2,
  "c": 3
}

This means b == 2 a and c == 3 a

Credits

Furey, Edward "Conversion Calculators" From http://www.CalculatorSoup.com - Online Calculator Resource. For the amazing formulas

0.5.1

8 years ago

0.5.0

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago