1.0.3 • Published 6 months ago

easy-unit-converter v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Easy Unit Converter

npm version license

NPM

Introduction

A simple and efficient unit conversion tool to seamlessly convert between various units of measurement. Whether you're working with length, weight, area or computer storage, easy-unit-converter offers an easy-to-use solution for all your conversion needs. With support for both standard and custom units, this tool makes unit conversion straightforward and accessible for developers and non-developers alike.

For now it supports:

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

Installation:

npm install --save easy-unit-converter

Test:

npm run test

or

npm test

Example:

const { convert } = require('easy-unit-converter');

// ------------- OR -----------------

import { convert } from "easy-unit-converter";

// You can use the unit name
console.log(convert(1000, "meter").to("kilometer")) // 1

// You can also use the abbreviation of the unit
console.log(convert(1000, "m").to("km")) // 1

// You can get the unit in decimal values
console.log(convert(1000, "meter").to("kilometer", 2)) // 1.00

Supported units :

Distance

UnitAbbreviation
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
carat (metric)ct
point (metric)pt
gramg
kilogramkg
megagramMg
milligrammg
ounceoz
poundlb
stonest
tont

Area

UnitAbbreviation
square inchin2
square footft2
square yardyd2
square milemi2
acreac
hectareha
square millimetermm2
square centimetercm2
square meterm2
square kilometerkm2

Computer storage

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