UnitExpression
Methods
-
dimensions() → {Dimensions}
-
Returns a Dimensions object that represents the unit dimensions of this UnitExpression.
Returns:
Dimensions -
div(rhs) → {UnitExpression}
-
Divides this UnitExpression by another UnitExpression and returns the result as another UnitExpression. Logically, this operation is implemented by inverting the divisor `rhs` and performing a multiplication operation.
Parameters:
Name Type Description rhs
UnitExpression Returns:
UnitExpression -
mult(rhs) → {UnitExpression}
-
Multiplies this UnitExpression by another UnitExpression and returns the result as another UnitExpression. Logically, this operation is implemented by concatenating all of the terms together and combining like bases.
Parameters:
Name Type Description rhs
UnitExpression Returns:
UnitExpression -
pow(power) → {UnitExpression}
-
Exponentiates this UnitExpression by the given power and returns the result as another UnitExpression.
Parameters:
Name Type Description power
number Returns:
UnitExpression -
simplify() → {UnitExpression}
-
Simplifies the UnitExpression by combining like Terms.
Returns:
UnitExpression -
terms() → {array.<Term>}
-
Returns an immutable array of Terms that make up the UnitExpression.
Returns:
array.<Term> -
toBaseUnits() → {UnitExpression}
-
Recursively breaks down this UnitExpression into its constituent Terms and each Term into its constituent BaseUnits, until only BaseUnits are left.
Returns:
UnitExpression -
toMap() → {object}
-
Projects this UnitExpression onto an equivalent map, where each unit type becomes a key, and the value is the sum of all the powers of the Terms of that type.
Returns:
object -
toString() → {string}
-
Returns a string representation of the given UnitExpression. For example, the string representation of a UnitExpression that represents "meters per second squared" will be "m/s^2".
Returns:
string