Skip to main content

Class: UnitFormatter

Defined in: workingtitle-instruments-epic2/shared/Components/NumberDisplays/UnitFormatter.ts:8

A utility class for creating Epic 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: workingtitle-instruments-epic2/shared/Components/NumberDisplays/UnitFormatter.ts:73

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

Parameters​

ParameterTypeDefault 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​

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

(unit): string

Parameters​
ParameterType
unitUnit<any>
Returns​

string


getUnitTextMap()​

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

Defined in: workingtitle-instruments-epic2/shared/Components/NumberDisplays/UnitFormatter.ts:131

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.