Skip to main content

Class: UnitFormatter

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

create(defaultString?, charCase?): (unit: Unit<any>) => string

Creates a function which formats measurement units to strings representing their abbreviated names.

Parameters

NameTypeDefault valueDescription
defaultStringstring''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

fn

A function which formats measurement units to strings representing their abbreviated names.

▸ (unit): string

Parameters
NameType
unitUnit<any>
Returns

string

Defined in

src/garminsdk/graphics/text/UnitFormatter.ts:73


getUnitTextMap

getUnitTextMap(): Readonly<Partial<Record<string, Readonly<Partial<Record<string, string>>>>>>

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.

Defined in

src/garminsdk/graphics/text/UnitFormatter.ts:131