Creates a convertible with the passed value and unit.
It is not recommended to create a convertible this way. Instead
use the collection's .from(value: number, unit: string)
or .Convertible(value: number, unit: string)
method.
Recommended way to create a convertible:
the convertible's value
the convertible's unit
The convertible's unit. Changes through converting.
The convertible's value. Changes through converting.
Converts the convertible to the passed unit and returns the convertible itself.
the target unit
the convertible itself
Converts the convertible to the best possible unit. In this case the best means having as few digits as possible before the decimal point. Returns the convertible itself.
whether to remain in the same unit system (default is true
)
the convertible itself
Compares this convertible semantically to another. Returns -1
, 0
,
or 1
as this convertible is less than, equal to, or greater
than the passed convertible.
the convertible to be compared
-1
, 0
, or 1
as this convertible is less than, equal to, or greater
than the passed convertible
Creates a copy of the convertible.
a copy of the convertible
Returns whether this convertible is semantically equal to the passed convertible.
the convertible to be compared
whether this convertible is semantically equal to the passed convertible
Returns the convertible as formatted string.
The first argument specifies the string's format (see example), the second one additional format options.
Currently there is only the format option length
. Setting this to "long"
will result in a long unit symbol
(e.g. "meter" or "meters"), "short"
will result in a short unit symbol (e.g. "m").
the string's format
additional format options
the convertible as formatted string
Returns whether this convertible is semantically greater than the passed convertible.
the convertible to be compared
whether this convertible is semantically greater than the passed convertible
Returns whether this convertible is semantically greater than or equal to the passed convertible.
the convertible to be compared
whether this convertible is semantically greater than or equal to the passed convertible
Returns whether this convertible is semantically less than the passed convertible.
the convertible to be compared
whether this convertible is semantically less than the passed convertible
Returns whether this convertible is semantically less than or equal to the passed convertible.
the convertible to be compared
whether this convertible is semantically less than or equal to the passed convertible
Returns an array of units to which the convertible can be converted.
an array of units to which the convertible can be converted
Converts the convertible to the passed unit and returns the conversion's result.
the target unit
the conversion's result
Returns the convertible as short string.
Generated using TypeDoc
A convertible combines a number with a unit. It offers several methods to convert itself into different units and therefore is the key concept behind converting in simple-units.