Interface: Unit<F>
A unit of measurement.
Type parameters
Name | Type |
---|---|
F | extends string |
Hierarchy
Unit
Implemented by
Properties
family
• Readonly
family: F
This unit's family.
Defined in
src/sdk/math/NumberUnit.ts:692
name
• Readonly
name: string
This unit's name.
Defined in
src/sdk/math/NumberUnit.ts:695
Methods
canConvert
▸ canConvert(otherUnit
): boolean
Checks whether conversions between this unit and another unit are possible.
Parameters
Name | Type | Description |
---|---|---|
otherUnit | Unit <string > | The other unit. |
Returns
boolean
Whether conversions between this unit and another unit are possible.
Defined in
src/sdk/math/NumberUnit.ts:702
convertFrom
▸ convertFrom(value
, fromUnit
): number
Converts a value of another unit to this unit.
Parameters
Name | Type | Description |
---|---|---|
value | number | The value to convert. |
fromUnit | Unit <F > | The unit from which to convert. |
Returns
number
The converted value.
Throws
Error if attempting an invalid conversion.
Defined in
src/sdk/math/NumberUnit.ts:720
convertTo
▸ convertTo(value
, toUnit
): number
Converts a value of this unit to another unit.
Parameters
Name | Type | Description |
---|---|---|
value | number | The value to convert. |
toUnit | Unit <F > | The unit to which to convert. |
Returns
number
The converted value.
Throws
Error if attempting an invalid conversion.
Defined in
src/sdk/math/NumberUnit.ts:711
createNumber
▸ createNumber(value
): NumberUnit
<F
, Unit
<F
>>
Creates a NumberUnit with a specified initial value of this unit type.
Parameters
Name | Type | Description |
---|---|---|
value | number | The numeric value of the new NumberUnit. |
Returns
NumberUnit
<F
, Unit
<F
>>
A NumberUnit of this unit type.
Defined in
src/sdk/math/NumberUnit.ts:727
equals
▸ equals(other
): boolean
Checks whether this unit is equal to another unit. Returns true if and only if the other unit belongs to the same family and has the same name as this unit.
Parameters
Name | Type | Description |
---|---|---|
other | Unit <string > | The other unit to which to compare. |
Returns
boolean
Whether this unit is equal to the comparison.
Defined in
src/sdk/math/NumberUnit.ts:735