new UnitDatabase()
Queries the unit database from the station.
There is no reason to call this constructor directly; rather use the
static accessor functions.
Methods
-
<static> get( [callbacks])
-
Asynchronously retrieve the unit database from the station. The network
call to the station will only happen once: the same database instance will
be resolved no matter how many times this function is called.Parameters:
Name Type Argument Description callbacks
Object <optional>
Properties
Name Type Argument Description ok
function <optional>
(Deprecated: use Promise) ok callback,
will receive aUnitDatabase
instance populated with data retrieved from
the stationfail
function <optional>
(Deprecated: use Promise) fail callback
batch
baja.comm.Batch <optional>
batch to use for the network
requestReturns:
- Type
- Promise
-
convertUnit(type, unit)
-
Convert a unit from metric to English or vice versa.
Parameters:
Name Type Description type
String metric
to convert from English to metric;english
to convert from metric to English`unit
baja.Unit the unit to convert
Returns:
the converted unit. If the unit cannot be
converted, the same unit will be returned directly.- Type
- baja.Unit
-
getQuantities()
-
Get all quantities contained in the unit database.
Returns:
- Type
- Array.<baja.UnitDatabase.Quantity>
-
getUnit(name)
-
Retrieve the unit instance with the given name.
Parameters:
Name Type Description name
String the desired unit name
Returns:
the unit, or
null
if not found- Type
- baja.Unit | null