2.2.0 • Published 12 months ago

@akapok/ember-unit-converter-helper v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

ember-unit-converter-helper

This helper allow you to convert a number from a unit to another. Like meters in decimeters, litres to millilitres, seconds to hours...

Table of Contents

Compatibility

  • Ember.js v4.4 or above
  • Ember CLI v4.4 or above
  • Node.js v16 or above

Installation

Via NPM

npm install @akapok/ember-unit-converter-helper

Via Ember-CLI

ember install @akapok/ember-unit-converter-helper

Usage

Arguments

This addon provides a single helper called convert. It accepts 5 arguments | Arguments | Type | Description | Mandatory ? | Default | | :--- | :----: | :----: | :--- | :--- | | value | Number | The value you want to convert | Yes | N/A | | from | String | The abbrevation of the unit you convert from | Yes | N/A | | to | String | The abbrevation of the unit you convert to | Yes | N/A | | withUnit | Boolean | Do you want the result to be displayed with the unit abbrevation ? | No | Yes | | digit | Number | The amount of digit you want to keep | No | No limit set |

Basic Use

In your code:

<!-- We want to convert 1 meters into millimeters-->
{{convert value=1 from="m" to="mm" withUnit=false}}

The result:

1000mm

Without the unit abbrevation

In your code:

{{convert value=1 from="m" to="mm" withUnit=false}}

The result:

1000

With a limited amount of digits

In your code:

{{convert value=134.678 from="m" to="km" digits=2}}

The result:

0.13km (instead of 0.134678km)

:warning: Warning: The digit option also round your result. For example 0.146 with 2 digits returns 0.15

Supported units

Distance

NameAbbrevation
Femtometerfm
Picometerpm
Nanometernm
Micrometerμm
Millimetermm
Centimetercm
Decimeterdm
Meterm
Decameterdam
Hectometerhm
Kilometerkm
Inchin
Footft
Yardyd
Milemi
Nautical Milenmi

Weight

NameAbbrevation
Femtogramfg
Picogrampg
Nanogramng
Microgramμg
Milligrammg
Centigramcg
Decigramdg
Gramg
Decagramdag
Hectogramhg
Kilogramkg
Poundlb
Ounceoz

Volume

NameAbbrevation
Femtolitrefl
Picolitrepl
Nanolitrenl
Microlitreμl
Millilitreml
Centilitrecl
Decilitredl
Litrel
Decalitredal
Hectolitrehl
Kilolitrekl
Gallon (UK)UK gal
Gallon (US)US gal
Fluid ounce (UK)UK fl oz
Fluid ounce (US)US fl oz
Pint (UK)UK pt
Pint (US)US pt

Time

NameAbbrevation
Seconds
Minutemin
Hourh
Dayd
Weekw
Yeary

Luminous intensity

NameAbbrevation
Femtocandelafcd
Picocandelapcd
Nanocandelancd
Microcandelaμcd
Millicandelamcd
Centicandelaccd
Decicandeladcd
Candelacd
Decacandeladacd
Hectocandelahcd
Kilocandelakcd
Candlepowercp

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.