1.0.3 • Published 11 months ago

br-currency-formatter v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

br-currency-formatter

Simple package that converts any passed number to currency value. Below:

Usage

  npm install br-currency-formatter

or

  yarn add br-currency-formatter

to use inside project, use:

import anyNumberToBrCurrency from 'br-currency-formatter';

Returns

anyNumberToBrCurrency("12345")
//12.345,00
anyNumberToBrCurrency("12345,00")
//12.345,00
anyNumberToBrCurrency("1,456.00")
//1.456,00
anyNumberToBrCurrency("1.456,00")
//1.456,00
anyNumberToBrCurrency("1,456,00")
//1.456,00
anyNumberToBrCurrency("1.456.00")
//1.456,00

Works with invalid numbers too

anyNumberToBrCurrency("1..,456.,.00")
//1.456,00
anyNumberToBrCurrency("1..,,,,.,.456.,.00")
//1.456,00

Sign

To put the sign "R$" in all formatations, pass true on second function call parameter, like this:

  anyNumberToBrCurrency("45655,43", true)
  //R$ 45.655,43

More decimal places

To show more decimal places, use this:

  anyNumberToBrCurrency("45655,435", true, 3)
  //R$ 45.655,435

Enjoy it!

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago