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: 0): 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: 0): string[] Static Method used when generating a JSON object that represents this Format.  
formatTypeToString(type: FormatType.Decimal): string Static Method used when generating a JSON object that represents this Format.  
getTraitString(trait: 0): "trailZeroes" = undefined | "keepSingleZero" = undefined | "zeroEmpty" = undefined | "keepDecimalPoint" = undefined | "applyRounding" = undefined | "fractionDash" = undefined | "showUnitLabel" = undefined | "prependUnitLabel" = undefined | "use1000Separator" = undefined | "exponentOnlyNegative" = undefined Static Get string used in FormatProps  
isFormatTraitSetInProps(formatProps: FormatProps, trait: 0): 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): 0 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: string | string[] | undefined): undefined | TrailZeroes | KeepSingleZero | ZeroEmpty | KeepDecimalPoint | ApplyRounding | FractionDash | ShowUnitLabel | PrependUnitLabel | Use1000Separator | ExponentOnlyNegative Static Get FormatTrait from entry in FormatProps  
parseFormatType(jsonObjType: string, formatName: string): FormatType.Decimal 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.Decimal): 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.OnlyNegative 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.OnlyNegative): 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 0    
_includeZero Protected boolean    
_minWidth Protected undefined | number    
_precision Protected number    
_roundFactor Protected number    
_scientificType Protected undefined | ScientificType    
_showSignOption Protected ShowSignOption.OnlyNegative    
_spacer Protected string    
_stationOffsetSize Protected undefined | number    
_stationSeparator Protected string    
_thousandSeparator Protected string    
_type Protected FormatType.Decimal    
_units Protected undefined | Array<[UnitProps, string | undefined]>    
_uomSeparator Protected string    
customProps Accessor ReadOnly any    
decimalSeparator Accessor ReadOnly string    
formatTraits Accessor ReadOnly 0    
hasUnits Accessor ReadOnly boolean    
includeZero Accessor ReadOnly boolean    
minWidth Accessor ReadOnly number | undefined    
name Accessor ReadOnly string    
precision Accessor ReadOnly DecimalPrecision | FractionalPrecision    
roundFactor Accessor ReadOnly number    
scientificType Accessor ReadOnly ScientificType | undefined    
showSignOption Accessor ReadOnly ShowSignOption.OnlyNegative    
spacer Accessor ReadOnly string    
stationOffsetSize Accessor ReadOnly number | undefined    
stationSeparator Accessor ReadOnly string    
thousandSeparator Accessor ReadOnly string    
type Accessor ReadOnly FormatType.Decimal    
units Accessor ReadOnly Array<[UnitProps, string | undefined]> | undefined    
uomSeparator Accessor ReadOnly string    

Defined in

Last Updated: 12 July, 2021