JSPM

conversion.js

0.0.5
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 21
    • Score
      100M100P100Q29939F

    Simple lightweight conversion library for temperature, mass, speed, and length

    Package Exports

    • conversion.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (conversion.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    [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

    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.