0.1.2 • Published 2 years ago

@knownout/amount-formatter v0.1.2

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
2 years ago

🧱 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

#НаименованиеОписание
1amountFormatterFunction to format string-like amounts
2trimTailingZerosFunction to remove zeros at the end of the amount
3amountPrettierFunction 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") // => 01

amountPrettier

  • Signature: (value: string, maxFractionLength = 6) => string.

Function for splitting the amount into groups and for adding other embellishments.

amountPrettier("12345.") // => 12 345

re-knownout - https://github.com/re-knownout/ knownout@hotmail.com

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago