Creates a new instance of Class given the name of the class and optionally the groups of the class.
The unique name of the class.
The optional list of groups to populate the class with.
A map of functions which convert one unit value to another unit value.
It is used by invoking converters[ fromUnit ][ toUnit ]( value )
.
A map of groups by their units. This map contains the expected case of each unit as well as the lowercase version of the unit as long as it doesn't overwrite another group. Unit case may be important so it has priority.
A list of the groups in this class.
The name of the class.
Adds a group definition to this class. If the group is relative to another group the Group.baseScale and Group.baseUnit are set to appropriate values.
The group definition.
The instance of the group created from the definition.
Adds the unit to this class for the given group. If the lowercase version of the unit has not been mapped yet it will be mapped to the given group.
The unit to map to the group.
The group which has the unit.
The reference to this instance.
Adds the group definitions to this class.
The array of group definitions.
The reference to this instance.
Converts the given number from a given group to a given group. If the two
groups are the same or one or both of the groups are not provided then the
value
provided is returned. If the two groups have differing base units
the Class.converters map is used to convert the value
over to the
proper base. If the Class.converters map is missing a base conversion
zero is returned. This might happen if a group is passed to this function
which does not belong to this class OR if the user has impromperly setup
their own classes.
The number to convert.
The group of the number to convert from.
The group to convert to.
The value to return if a conversion between the two groups could not be made.
The converted number or zero if a base conversion could not be found.
Determines which groups in this class are visible according to the given transform. The groups can be iterated in reverse and can optionally take a related group into consideration (when the system is GIVEN, we want to return the groups with the same system).
The transform which decides what groups are visible.
If the groups of this class should be iterated in reverse.
A related group which may be used for visibility if the Transform.system is System.GIVEN.
A function to invoke with all visible groups found and the
index of that group in the set of visible groups. If false
is returned
by the function iteration of visible groups ceases.
The current visible group.
The index of the current visible group.
Removes the given unit associated to the given group from the class. If the group is not mapped to this unit then this has no effect.
The unit to remove from this class.
The group which has the unit.
The reference to this instance.
Sets the conversion function between the two base units.
The base unit to convert from.
The base unit to convert to.
The function to pass the value to convert.
The reference to this instance.
Updates the Group.classScale value in each group in this class so that there is a baseline for comparing one group to another no matter the base unit. For comparing in the same base, you can use Group.baseScale.
The reference to this instance.
Generated using TypeDoc
A collection of groups and their units with the logic on how to convert between groups with differing base units.
A class is essentially something like "Length" where base units are "inches" and "millimeters" and there are various other groups based off of these base groups like "feet", "centimeters", and "meters".
A class is responsible for being the sole place where conversion is done between different groups in the same class.
Class.convert