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 callbacksObject <optional>
Properties
Name Type Argument Description okfunction <optional>
(Deprecated: use Promise) ok callback,
will receive aUnitDatabaseinstance populated with data retrieved from
the stationfailfunction <optional>
(Deprecated: use Promise) fail callback
batchbaja.comm.Batch <optional>
batch to use for the network
requestReturns:
- Type
- Promise.<baja.UnitDatabase>
-
convertUnit(unitConversion, unit)
-
Convert a unit from metric to English or vice versa.
Parameters:
Name Type Description unitConversionString | number | baja.FrozenEnum metricto convert
from English to metric;englishto convert from metric to English. Also
accepts baja:UnitConversion instances or ordinals.unitbaja.Unit the unit to convert
Returns:
the converted unit. If the unit cannot be
converted, the same unit will be returned directly. If no unit given,
returns null.- Type
- baja.Unit | null
-
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 nameString | baja.Unit the desired unit name. If a baja.Unit is
passed, it will just be returned back directly.Returns:
the unit, or
nullif not found- Type
- baja.Unit | null