Closed Shoelace closed 4 years ago
I guess "base unit" refers to "SI base units" (cf. https://en.wikipedia.org/wiki/SI_base_unit) and there's no such unit for areas.
@orontee is right. toBase
returns a quantity with units only composed of "base" units (SI).
Regarding areas, m2
is not really a base unit but a unit based on the SI unit of length
.
BTW, you could use something like below to achieve what you want to do :
let getBaseUnits = kind => {
return Qty(Qty.getUnits(kind)[0]).toBase().units();
};
getBaseUnits('area');
I am closing the issue but feel free to reopen if needed.
thanks @gentooboontoo , i'll see what I can do with that snippet. :)
Hi, love the library.. trying to use it in my project.
i want to let my user select "default" unit types for any of the kinds. ie length -> km, mass -> pound , speed -> knot or whatever. so i tried to create a table of "kinds" with their associated "units" and i've hit 2 issues.
( see https://jsfiddle.net/shoelace/anxqj0g2/ for my example )
ideally i'd like a function like
Qty.getbaseUnit('area') ==> m2
(or hectare ) orqty.Base() ==> m2
which brings me to
Qty.getUnits( kind );
eg for area
and
m2
is not inQty.getUnits( 'area' );
am i missing something? is there a better way of doing this?