- getUnitsForQuantity(quantity)
Get all units registered for quantity
Converts a units serialized representation to it's deserialized representation
Param |
---|
unitString |
Converts a unit to it's serialized representation
Param |
---|
unit |
Convert an amount to it's serialized representation
Param |
---|
amount |
Convert a serialized amount to it's deserialized representation
Param |
---|
amountString |
- Amount
- .defaultComparer ⇒
number
- .create(value, unit, decimalCount) ⇒
Amount.<T>
- .toString(amount) ⇒
string
- .neg(amount)
- .isQuantity(quantity, amount)
- .plus(left, right) ⇒
- .minus(left, right) ⇒
- .times(left, right)
- .divide(left, right)
- .equals(left, right) ⇒
boolean
- .lessThan(left, right) ⇒
boolean
- .greaterThan(left, right) ⇒
boolean
- .roundDown(step, amount)
- .roundUp(step, amount)
- .abs(amount)
- .valueAs(toUnit, amount)
- .defaultComparer ⇒
Default comparer
Returns: number
- Comparer value
Param | Type | Description |
---|---|---|
left | Amount |
The left-hand amount |
right | Amount |
The right-hand amount |
Creates an amount that represents the an exact/absolute value in the specified unit. For example if you create an exact amount of 2 degrees Fahrenheit that will represent -16.6666667 degrees Celsius.
Returns: Amount.<T>
- The created amount.
Param | Type | Description |
---|---|---|
value | number |
The numeric value of the amount. |
unit | Unit.<T> |
The unit of the amount. |
decimalCount | number | undefined |
The decimalCount of the amount. |
Returns a string representation of an Amount.
Returns: string
- String representation of the Amount.
Param | Type | Description |
---|---|---|
amount | Amount |
The amount. |
Negation unary operator.
Param | Type | Description |
---|---|---|
amount | Amount.<T> |
The amount. |
Determines if an Amount is of a quantity.
Param | Type | Description |
---|---|---|
quantity | Quantity |
Quantity to check for. |
amount | Amount.<T> |
The amount to check. |
Adds two amounts together. The two amounts amounts must have the same quantity. The resulting amount will be of the same quantity as the two amounts. The resulting amount will have it's decimal count set from the most granular amount.
Returns: left + right
Param | Description |
---|---|
left | The left-hand amount. |
right | The right-hand |
Substracts two amounts from each other. The two amounts amounts must have the same quantity. The resulting amount will be of the same quantity as the two amounts. The resulting amount will have it's decimal count set from the most granular amount.
Returns: left + right
Param | Description |
---|---|
left | The left-hand amount. |
right | The right-hand |
Multiplies an amount with a number. The resulting amount has the same unit and decimal count as the original amount.
Param | Description |
---|---|
left | The amount to multiply |
right | The number to multiply with |
Divides an amount with a number. The resulting amount has the same unit and decimal count as the original amount.
Param | Description |
---|---|
left | The amount to divide |
right | The number to divide by |
Compares to amounts for equality
Returns: boolean
- True if the amounts are equal, false otherwise.
Param | Type | Description |
---|---|---|
left | Amount |
The left-hand Amount. |
right | Amount |
The right-hand Amount. |
Checks if one Amount is less than another.
Returns: boolean
- True if the left-hand is less than the right-hand, false otherwise.
Param | Type | Description |
---|---|---|
left | Amount |
The left-hand Amount. |
right | Amount |
The right-hand Amount. |
Checks if one Amount is greater than another.
Returns: boolean
- True if the left-hand is less than the right-hand, false otherwise.
Param | Type | Description |
---|---|---|
left | Amount |
The left-hand Amount. |
right | Amount |
The right-hand Amount. |
Param | Description |
---|---|
step | Rounding step, for example 5.0 Celsius will round 23 to 20. |
amount | Amount to round. |
Param | Description |
---|---|
step | Rounding step, for example 5.0 Celsius will round 23 to 25. |
amount | Amount to round. |
Gets the absolute amount (equivalent of Math.Abs())
Param | Description |
---|---|
amount | The amount to get the aboslute amount from. |
Gets the value of the amount as a number in the specified unit
Param | Description |
---|---|
toUnit | The unit to get the amount in. |
amount | The amount to get the value from. |
Holds the dimensionless unit ONE
Creates a base unit having the specified symbol.
Param | Description |
---|---|
quantity | The quantity of the resulting unit. |
symbol | The symbol of this base unit. |
Creates an alternate unit for the specified unit identified by the specified symbol.
Param | Description |
---|---|
symbol | The symbol for this alternate unit. |
parent | Parent the system unit from which this alternate unit is derived. |
Returns the product of the specified units.
Returns: left * right
Param | Description |
---|---|
quantity | The quantity of the resulting unit. |
left | The left unit operand. |
right | The right unit operand. |
Returns the quotient of the specified units.
Returns: left / right
Param | Description |
---|---|
quantity | The quantity of the resulting unit. |
left | The dividend unit operand. |
right | The divisor unit operand. |
Converts numeric values from a unit to another unit.
Returns: The converted numeric value.
Param | Description |
---|---|
value | The numeric value to convert. |
fromUnit | The unit from which to convert the numeric value. |
toUnit | The unit to which to convert the numeric value. |
Get all units registered for quantity
Param |
---|
quantity |