import { formatNumber } from '@angular/common' ; import { CurrencySymbol } from '@signumjs/util' ; export interface AmountFormattingOptions { isShortForm : boolean ; noUnit : boolean ; locale : string ; } const DefaultFormattingOptions = { isShortForm : false , noUnit : false , locale : 'en' , } ; export function formatAmount ( value , formattingOptions = DefaultFormattingOptions ) { const v = typeof value === 'string' ? parseFloat ( value ) : value ; const { isShortForm , noUnit , locale } = formattingOptions ; const digitsInfo = isShortForm ? '1.0-4' : '1.0-8' ; const unit = noUnit ? '' : CurrencySymbol + ' ' ; return `${ unit }${ formatNumber ( v , locale , digitsInfo ) }` ; }