FormatterSpec Class

A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format. Once created the FormatterSpec will be able to format quantity values with synchronous calls.

Methods

Name Description
constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps, azimuthBaseConversion?: UnitConversionProps, revolutionConversion?: UnitConversionProps): FormatterSpec Constructor  
applyFormatting(magnitude: number): string Format a quantity value.  
create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec> Static Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter.  
getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]> Static Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string.  

Properties

Name Type Description
_azimuthBaseConversion Protected UnitConversionProps | undefined    
_conversions Protected UnitConversionSpec[]    
_format Protected Format    
_name Protected string    
_persistenceUnit Protected UnitProps    
_revolutionConversion Protected UnitConversionProps | undefined    
azimuthBaseConversion Accessor ReadOnly undefined | UnitConversionProps    
format Accessor ReadOnly Format    
name Accessor ReadOnly string    
persistenceUnit Accessor ReadOnly UnitProps    
revolutionConversion Accessor ReadOnly undefined | UnitConversionProps    
unitConversions Accessor ReadOnly UnitConversionSpec[] Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string.  

Defined in

Last Updated: 17 December, 2024