Giter VIP home page Giter VIP logo

ember-convert-units's Introduction

ember-convert-units

A simple Ember addon for converting between units.

Table of Contents

Installing

Run this command in your project

ember install ember-convert-units

Usage

This addon can be used in two ways

Pure Function

/*
 @param {number} quantity
 @param {string} units
 @param {string} newUnits
 @returns {number} The quantity expressed in the new units
*/

function convertUnits(quantity, units, { to: newUnits }) { ... }

Example

import { convertUnits } from 'ember-convert-units';

convertUnits(2, 'pounds', { to: 'grams' }); // 907.18474
convertUnits(5, 'mi', { to: 'km' }); // 8.04672

Template Helper

{{!--
  @param {number} quantity
  @param {string} units
  @param {string} newUnits 
  @returns {number} The quantity expressed in the new units
--}}

{{convert-units quantity units to=newUnits}}

Example

{{convert-units 2 'pounds' to='grams'}} grams
{{convert-units 5 'mi' to='km'}} km

generates the text

907.18474 grams
8.04672 km

Supported Units

For more details see register-units.js.

Length

Unit Names
Nanometers nanometres, nanometers, nm
Micrometers micrometres, micrometers, μm
Millimeters millimetres, millimeters, mm
Centimeters centimetres, centimeters, cm
Meters metres, meters, m
Kilometers kilometres, kilometers, km
Inches inches, in
Feet feet, ft
Yards yards, yd
Miles miles, mi

Mass

Unit Names
Micrograms micrograms, μg
Milligrams milligrams, mg
Grams grams, g
Killograms kilograms, kg
Tonnes tonnes, metric ton
Tons (US) tons, ton
Ounces ounces, oz
Pounds pounds, lb

Time

Unit Names
Nanoseconds nanoseconds, ns
Microseconds microseconds, µs
Milliseconds milliseconds, ms
Seconds seconds, s
Minutes minutes, min
Hours hours, h

Temperature

Unit Names
degrees Fahrenheit degrees Fahrenheit, deg F, fahrenheit
degrees Celsius degrees Celsius, deg C, celsius
Kelvin kelvin

Speed

Unit Names
Meters per Second m/s
Meters per Hour m/h
Kilometers per Hour km/h, kph
Feet per Second ft/s
Feet per Hour ft/h
Miles per Hour mi/h, mph

Pressure

Unit Names
Nanopascals nanopascals, npa
Micropascals micropascals, μpa
Millipascals millipascals, mpa
Centipascals centipascals, cpa
Pascals pascals, pa
Kilopascals kilopascals, kpa
Nanobars nanobars, nbar
Microbars microbars, μbar
Millibars millibars, mbar
Centibars centibars, cbar
Bars bars, bar
Kilobars kilobars, kbar
Pounds per Square Inch psi
Atmosphere atmosphere, at

Volume

Unit Names
Litres litres, liters, L, l
Millilitres millilitres, milliliters, ml, mL
Gallons gallons, gal
Quart quart, qt
Pint pint, pt
Fluid Ounces fluid ounces, fl oz
Acre Inch acre inch, acre in, acre*in, acre*inch
Acre Foot acre foot, acre ft, acre*ft, acre*foot

Not currently supported

  • Area
  • Digital Storage
  • Data Transfer Rate

Feel free to contribute new units if you need them!

ember-convert-units's People

Contributors

ember-tomster avatar joshkinabrew avatar mmun avatar techn1x avatar

Stargazers

 avatar

Watchers

 avatar

ember-convert-units's Issues

Migrate from bower to npm

I know this repo hasn't been touched in a while, but bower's old and crusty....

I might have a go at this if I get some more time, but you're welcome to beat me to it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.