Skip to main content

Class: CompoundUnit<F>

A unit of measure composed of the multiplicative combination of multiple elementary units.

Type parameters

NameType
Fextends string

Hierarchy

Constructors

constructor

new CompoundUnit<F>(family, numerator, denominator, name?): CompoundUnit<F>

Constructor.

Type parameters

NameType
Fextends string

Parameters

NameTypeDescription
familyFThe family to which this unit belongs.
numeratorCompoundableUnit<string>[]An array of CompoundableUnits containing all the units in the numerator of the compound unit.
denominatorCompoundableUnit<string>[]An array of CompoundableUnits containing all the units in the denominator of the compound unit.
name?stringThe name of this unit. If not defined, one will be automatically generated.

Returns

CompoundUnit<F>

Overrides

AbstractUnit.constructor

Defined in

src/sdk/math/NumberUnit.ts:842

Properties

family

Readonly family: F

This unit's family.

Overrides

AbstractUnit.family

Defined in

src/sdk/math/NumberUnit.ts:829


name

Readonly name: string

The name of this unit.

Inherited from

AbstractUnit.name

Defined in

src/sdk/math/NumberUnit.ts:756


scaleFactor

Protected Readonly scaleFactor: number

Defined in

src/sdk/math/NumberUnit.ts:833

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.

Overrides

AbstractUnit.canConvert

Defined in

src/sdk/math/NumberUnit.ts:887


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.

Overrides

AbstractUnit.convertFrom

Defined in

src/sdk/math/NumberUnit.ts:901


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.

Overrides

AbstractUnit.convertTo

Defined in

src/sdk/math/NumberUnit.ts:892


createNumber

createNumber(value): NumberUnit<F, CompoundUnit<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, CompoundUnit<F>>

A NumberUnit of this unit type.

Inherited from

AbstractUnit.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.

Inherited from

AbstractUnit.equals

Defined in

src/sdk/math/NumberUnit.ts:776