Simple lightweight library to convert temperature, mass, speed, and length
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
spec adds browser test Aug 15, 2014
test adds precision Aug 16, 2014
.gitignore adds browser test Aug 15, 2014
LICENSE Initial commit Aug 13, 2014
README.md Highlight code blocks Aug 19, 2014
bower.json update changes Aug 15, 2014
conversion.js adds precision Aug 16, 2014
conversion.min.js adds precision Aug 16, 2014
gruntfile.js adds browser test Aug 15, 2014
index.html adds browser test Aug 15, 2014
index.js adds index.js for npm Aug 15, 2014
package.json Change pkg name May 3, 2017

README.md

[MIT License]

A lightweight javascript conversion library for translating temperature, speed, mass and length values.

Note: The numbers are rounded up to the nearest 4th decimal point

Usage

Install using bower or npm:

bower install conversion.js
npm install conversion.js

Then load up a node console and try it out:

var convert = require('conversion.js');
// or load a script tag if using in the client

convert(1, 'mps').toKph();
convert(2, 'kilograms').toMetricTons()
convert(2, 'yards', { precision: 2 }).toCentimeters()

Api

// Temperature
.toCelsius
.toFahrenheit
.toKelvin

// Length
.toKilometers
.toMeters
.toCentimeters
.toMillimeters
.toMiles
.toYards
.toInches
.toFeet
.toNauticalMiles

// Mass
.toMetricTons
.toKilograms
.toGrams
.toMilligrams
.toMcgs
.toLongTons
.toShortTons
.toStones
.toPounds
.toOunces

// Speed
.toMph // Miles per hour
.toFps // Feet per second
.toMps // Meters per second
.toKph // To kilometers per hour
.toKnot // To Knot

Options

{
  precision: 4 // The decimal cutoff point at where it is rounded up
}

License

Conversion.js is freely distributable under the terms of the MIT license.