UNPKG

@empathyco/x-components

Version:
32 lines (18 loc) 1.73 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [currencyFormatter](./x-components.currencyformatter.md) ## currencyFormatter() function Format a value with a given format. **Signature:** ```typescript export declare function currencyFormatter(value: number, format?: string): string; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | value | number | Numeric value to be formatted. | | format | string | _(Optional)_ Format or mask to be defined as string. | **Returns:** string Formatted number. ## Remarks Format: - Use 'i' to define integer numbers. - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the doesn't include decimals, it is filled with zeros until reach the length defined with 'd's. - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group. - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more than one character. - Set whatever you need around the integers and decimals marks. - Default mask: 'i.iii,dd' which returns '1.345,67'. - If you want to hide the decimal part if it's zero (non significant), you can add the `?` symbol after the decimal characters (e.g. 'i.iii,dd?', for `1234` you would get `1.234` instead of `1.234,00`<!-- -->). It defines the value of `hideIntegerDecimals`<!-- -->: - If true (exists) and the value is an integer without decimals, the decimal non significant zeroes are hidden. - If false, the default behaviour will fill with zeros the remaining length until getting the one defined with the 'd's.