Format Class

Beta  

A class used to define the specifications for formatting quantity values. This class is typically loaded by reading FormatProps.

Methods

Name Description
constructor(name: string): Format Constructor  
clone(options?: CloneOptions): Format Clone Format  
fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> Populates this Format with the values from the provided.  
hasFormatTraitSet(formatTrait: FormatTraits): boolean This method returns true if the formatTrait is set in this Format object.  
toJSON(): FormatProps Returns a JSON object that contain the specification for this Format.  
createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps): Promise<Format> Static Create a Format from FormatProps  
formatTraitsToArray(currentFormatTrait: FormatTraits): string[] Static Method used when generating a JSON object that represents this Format.  
formatTypeToString(type: FormatType): string Static Method used when generating a JSON object that represents this Format.  
getTraitString(trait: FormatTraits): "trailZeroes" | "keepSingleZero" | "zeroEmpty" | "keepDecimalPoint" | "applyRounding" | "fractionDash" | "showUnitLabel" | "prependUnitLabel" | "use1000Separator" | "exponentOnlyNegative" Static Get string used in FormatProps  
isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits): boolean Static    
parseDecimalPrecision(jsonObjPrecision: number): DecimalPrecision Static This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision.  
parseFormatTrait(stringToCheck: string, currentFormatTrait: number): FormatTraits Static This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatTrait.  
parseFormatTraits(formatTraitsFromJson: undefined | string | string[]): undefined | FormatTraits Static Get FormatTrait from entry in FormatProps  
parseFormatType(jsonObjType: string, formatName: string): FormatType Static This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType.  
parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision Static This method validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision.  
parsePrecision(precision: number, formatName: string, type: FormatType): DecimalPrecision | FractionalPrecision Static This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision.  
parseScientificType(scientificType: string, formatName: string): ScientificType Static This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ScientificType.  
parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption Static This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ShowSignOption.  
scientificTypeToString(scientificType: ScientificType): string Static    
showSignOptionToString(showSign: ShowSignOption): string Static Method used when generating a JSON object that represents this Format.  

Properties

Name Type Description
_customProps Protected undefined | any    
_decimalSeparator Protected string    
_formatTraits Protected FormatTraits    
_includeZero Protected boolean    
_minWidth Protected undefined | number    
_precision Protected number    
_roundFactor Protected number    
_scientificType Protected undefined | ScientificType    
_showSignOption Protected ShowSignOption    
_spacer Protected string    
_stationOffsetSize Protected undefined | number    
_stationSeparator Protected string    
_thousandSeparator Protected string    
_type Protected FormatType    
_units Protected undefined | [UnitProps, undefined | string][]    
_uomSeparator Protected string    
customProps Accessor ReadOnly any    
decimalSeparator Accessor ReadOnly string    
formatTraits Accessor ReadOnly FormatTraits    
hasUnits Accessor ReadOnly boolean    
includeZero Accessor ReadOnly boolean    
minWidth Accessor ReadOnly undefined | number    
name Accessor ReadOnly string    
precision Accessor ReadOnly DecimalPrecision | FractionalPrecision    
roundFactor Accessor ReadOnly number    
scientificType Accessor ReadOnly undefined | ScientificType    
showSignOption Accessor ReadOnly ShowSignOption    
spacer Accessor ReadOnly string    
stationOffsetSize Accessor ReadOnly undefined | number    
stationSeparator Accessor ReadOnly string    
thousandSeparator Accessor ReadOnly string    
type Accessor ReadOnly FormatType    
units Accessor ReadOnly undefined | [UnitProps, undefined | string][]    
uomSeparator Accessor ReadOnly string    

Defined in

Last Updated: 12 June, 2024