Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including metric-cnv with all npm packages installed. Try it out:

var metricCnv = require("metric-cnv")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

metric-cnv v0.0.3

metric conversion utility

📏🌡️ MetricCnv

metric conversion utility.

badgen badgen

Demo

Usage

$ npm install metric-cnv --save

import { kgToLbs, lbsToKg } from 'metric-cnv'
// or
var { kgToLbs, lbsToKg } = require('metric-cnv')
Or include it via jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/metric-cnv@0.0.3/build/index.min.js"></script>
metriccnv.kgToLbs(1) // 2

Methods & Examples

Mass

  • kgToLbs(Number, [precision]) : String
    Kilograms to Pounds (kg to lbs)
kgToLbs(1) // 2
kgToLbs(1, 2) // 2.20
kgToLbs(1, 4) // 2.2046
  • lbsToKg(Number, [precision]) : String
    Pounds to Kilograms (lbs to kg)
lbsToKg(1) // 0
lbsToKg(1, 2) // 0.45
lbsToKg(1, 4) // 0.4536

Temperature

  • fahrenheitToCelsius(Number, [precision]) : String
fahrenheitToCelsius(71) // 22
fahrenheitToCelsius(71, 2) // 21.67
  • celsiusToFahrenheit(Number, [precision]) : String
celsiusToFahrenheit(22) // 72
celsiusToFahrenheit(22, 2) // 71.60

Speed

  • kmToMile(Number, [precision]) : String
kmToMile(100) // 62
kmToMile(100, 2) // 62.14
  • mileToKm(Number, [precision]) : String
mileToKm(100) // 161
mileToKm(100, 2) // 160.93

Notes

  • Works both in Node.js and in the browser.
  • All pull requests are welcome, feel free 😊.

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free