Class: UnitsHelper
Class to help with units formatting.
Table of contents
Properties
Methods
Constructors
Properties
MAGNITUDE_MAP
▪ Static
Readonly
MAGNITUDE_MAP: Object
Map units.
Methods
formatBest
▸ Static
formatBest(value
, decimalPlaces?
): string
Format the value in the best units.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
value | number | undefined | The value to format. |
decimalPlaces | number | 2 | The number of decimal places to display. |
Returns
string
The formated value.
formatUnits
▸ Static
formatUnits(value
, magnitude
, decimalPlaces?
): string
Format the value in the best units.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
value | number | undefined | The value to format. |
magnitude | Magnitudes | undefined | The magnitude to format with. |
decimalPlaces | number | 2 | The number of decimal places to display. |
Returns
string
The formated value.
calculateBest
▸ Static
calculateBest(value
): Magnitudes
Format the value in the best units.
Parameters
Name | Type | Description |
---|---|---|
value | number | The value to format. |
Returns
The best units for the value.
convertUnits
▸ Static
convertUnits(value
, from
, to
): number
Convert the value to different units.
Parameters
Name | Type | Description |
---|---|---|
value | number | The value to convert. |
from | Magnitudes | The from magnitude. |
to | Magnitudes | The to magnitude. |
Returns
number
The formatted unit.
Constructors
constructor
• new UnitsHelper()