Class: UnitFormatter
Defined in: src/garminsdk/graphics/text/UnitFormatter.ts:10
A utility class for creating Garmin unit formatters.
Each unit formatter is a function which generates output strings from input measurement units.
Constructors
Constructor
new UnitFormatter():
UnitFormatter
Returns
UnitFormatter
Methods
create()
static
create(defaultString
,charCase
): (unit
) =>string
Defined in: src/garminsdk/graphics/text/UnitFormatter.ts:101
Creates a function which formats measurement units to strings representing their abbreviated names.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
defaultString | string | '' | The string to output when the input unit cannot be formatted. Defaults to the empty string. |
charCase | "normal" | "upper" | "lower" | 'normal' | The case to enforce on the output string. Defaults to 'normal' . |
Returns
A function which formats measurement units to strings representing their abbreviated names.
(
unit
):string
Parameters
Parameter | Type |
---|---|
unit | Unit <any > |
Returns
string
getUnitTextMap()
static
getUnitTextMap():Readonly
<Partial
<Record
<string
,Readonly
<Partial
<Record
<string
,string
>>>>>>
Defined in: src/garminsdk/graphics/text/UnitFormatter.ts:159
Gets a mapping of unit family and name to text used by UnitFormatter to format units. The returned object maps unit families to objects that map unit names within each family to formatted text.
Returns
Readonly
<Partial
<Record
<string
, Readonly
<Partial
<Record
<string
, string
>>>>>>
A mapping of unit family and name to text used by UnitFormatter to format units.