Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dok/conversion.js
Simple lightweight library to convert temperature, mass, speed, and length
https://github.com/dok/conversion.js
Last synced: 13 days ago
JSON representation
Simple lightweight library to convert temperature, mass, speed, and length
- Host: GitHub
- URL: https://github.com/dok/conversion.js
- Owner: dok
- License: mit
- Created: 2014-08-13T17:37:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-03T02:27:52.000Z (over 7 years ago)
- Last Synced: 2024-10-10T16:41:51.096Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 29
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[[![MIT License][license-image]][license-url]]
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:
```shell
bower install conversion.js
``````shell
npm install conversion.js
```Then load up a node console and try it out:
```js
var convert = require('conversion.js');
// or load a script tag if using in the clientconvert(1, 'mps').toKph();
convert(2, 'kilograms').toMetricTons()
convert(2, 'yards', { precision: 2 }).toCentimeters()
```
## Api```js
// 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
```js
{
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](LICENSE).
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE