Skip to main content

Class: AbstractUnit<F>

A unit of measurement.

Type parameters

NameType
Fextends string

Hierarchy

Implements

Constructors

constructor

new AbstractUnit<F>(name): AbstractUnit<F>

Constructor.

Type parameters

NameType
Fextends string

Parameters

NameTypeDescription
namestringThe name of this unit.

Returns

AbstractUnit<F>

Defined in

src/sdk/math/NumberUnit.ts:756

Properties

family

Readonly Abstract family: F

This unit's family.

Implementation of

Unit.family

Defined in

src/sdk/math/NumberUnit.ts:750


name

Readonly name: string

The name of this unit.

Implementation of

Unit.name

Defined in

src/sdk/math/NumberUnit.ts:756

Methods

canConvert

canConvert(otherUnit): boolean

Checks whether conversions between this unit and another unit are possible.

Parameters

NameTypeDescription
otherUnitUnit<string>The other unit.

Returns

boolean

Whether conversions between this unit and another unit are possible.

Implementation of

Unit.canConvert

Defined in

src/sdk/math/NumberUnit.ts:760


convertFrom

convertFrom(value, fromUnit): number

Converts a value of another unit to this unit.

Parameters

NameTypeDescription
valuenumberThe value to convert.
fromUnitUnit<F>The unit from which to convert.

Returns

number

The converted value.

Throws

Error if attempting an invalid conversion.

Implementation of

Unit.convertFrom

Defined in

src/sdk/math/NumberUnit.ts:768


convertTo

convertTo(value, toUnit): number

Converts a value of this unit to another unit.

Parameters

NameTypeDescription
valuenumberThe value to convert.
toUnitUnit<F>The unit to which to convert.

Returns

number

The converted value.

Throws

Error if attempting an invalid conversion.

Implementation of

Unit.convertTo

Defined in

src/sdk/math/NumberUnit.ts:765


createNumber

createNumber(value): NumberUnit<F, AbstractUnit<F>>

Creates a NumberUnit with a specified initial value of this unit type.

Parameters

NameTypeDescription
valuenumberThe numeric value of the new NumberUnit.

Returns

NumberUnit<F, AbstractUnit<F>>

A NumberUnit of this unit type.

Implementation of

Unit.createNumber

Defined in

src/sdk/math/NumberUnit.ts:771


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

NameTypeDescription
otherUnit<string>The other unit to which to compare.

Returns

boolean

Whether this unit is equal to the comparison.

Implementation of

Unit.equals

Defined in

src/sdk/math/NumberUnit.ts:776