0.1.2 • Published 4 years ago
@knownout/amount-formatter v0.1.2
🧱 Amount formatting functions
Select documentation language: English (selected), Русский
This project is a set of functions for formatting numbers that reflect the amount of something (in monetary terms equivalent)
Functions
| # | Наименование | Описание |
|---|---|---|
| 1 | amountFormatter | Function to format string-like amounts |
| 2 | trimTailingZeros | Function to remove zeros at the end of the amount |
| 3 | amountPrettier | Function for splitting the amount into groups and for adding other embellishments |
amountFormatter
-
Signature: export default function amountFormatter(value: string, options?: Partial<IAmountFormatterOptions>) => string
.
A function to format string-like amount using BigNumber (to work with large numbers).
amountFormatter("123456781.1245667", DEFAULT_FORMATTER_OPTIONS) // => 123 456 781...trimTailingZeros
- Signature:
(value: string) => string.
Function to remove zeros at the end of the amount.
trimTailingZeros("010000") // => 01amountPrettier
- Signature:
(value: string, maxFractionLength = 6) => string.
Function for splitting the amount into groups and for adding other embellishments.
amountPrettier("12345.") // => 12 345re-knownout - https://github.com/re-knownout/ knownout@hotmail.com