$k. Measurement

new Measurement(value, unitopt)

Parameters:
NameTypeAttributesDescription
valueobject

The measurement's numeric value in the given unit or a $k.Attribute with base unit.

unit$k.Unit<optional>

The value's unit. If the first argument is a $k.Attribute, the attribute's value will be converted to this unit. If the first argument is a number or interval, this argument is mandatory.

Methods

(static) parse(string, QuantityKindopt, languageopt)

Parses a string consisting of a sequence of values and unit symbols. If the parameter quantityKind is not set, the function tries to guess the quantity kind based on the unit symbols used.

Parameters:
NameTypeAttributesDescription
stringstring

The string representation of the measurement

QuantityKindobject<optional>

The optional QuantityKind of the measurement

languagelanguage<optional>

Language of the string

Since
  • 5.4.2

baseValue() → {number}

Since
  • 5.4.2
Deprecated
  • This function is deprecated and might be removed in future releases
Returns:

The value in relation to the unit with factor 1.

Type: 
number

quantityKind() → {MeasurementScale}

Returns the quantity kind of the measurement.

Since
  • 5.4.2
Returns:
Type: 
MeasurementScale

toBaseUnit() → {$k.Measurement}

Since
  • 5.4.2
Deprecated
  • This function is deprecated and might be removed in future releases
Returns:

A measurement of same absolut value in the measurements's base unit or undefined, if the measurement's quantity kind has no unit with factor 1.

Type: 
$k.Measurement

toUnit(unit, languageopt) → {$k.Measurement}

Returns a measurement of same absolut value in the given unit.

Parameters:
NameTypeAttributesDescription
unit$k.Unit

The target unit

languagestring<optional>

Optional language to determine the target unit

Since
  • 5.4.2
Returns:
Type: 
$k.Measurement

unit() → {MeasurementScale}

Returns the (base) unit of the measurement.

Since
  • 5.4.2
Returns:
Type: 
MeasurementScale

value(unitopt) → {number}

Parameters:
NameTypeAttributesDescription
unit$k.Unit<optional>

Optional unit in which the measurement value is returned.

Since
  • 5.4.0
Returns:

Returns the value of the measurement.

Type: 
number

valueOf()

The returned value is only applicable for comparison between measurements and has no other defined semantics.

valueString(unitsopt, languageopt) → {string}

Returns the string representation of the measurement. If the units parameter is not set, the measurement's unit or quantity kind is used.

Parameters:
NameTypeAttributesDescription
unitsarray<optional>

the units to use

languagestring<optional>

the language to use

Since
  • 5.4.0
Returns:
Type: 
string