@ribeiroevandro/helpers v0.0.18
MyTool - Helpers
Functionalities
Helper function that assists in applying monetary mask.
How to use:
Install
Install the library using yarn
or npm
:
yarn add @ribeiroevandro/helpers
or
npm install @ribeiroevandro/helpers
Using
Import the library like this:
import { normalizeMoney } from '@ribeiroevandro/helpers';
To use, just run it where you want and provide the necessary parameters, for example:
normalizeMoney(100, 'pt-BR');
// Ex: R$ 100,00
The function expects two arguments, an integer and a string. The number is the value you want to format and the string, which mask should be applied, by default if only the number is passed, the function will apply the Real (BRL) mask, but it is possible to format in Dollars (USD), it is enough that, in the second argument, it is passed 'en-US' and the return will be: A função espera dois argumentos, sendo um número inteiro e uma string. O número é o valor que deseja formatar e a string, qual máscara deverá ser aplicada, que pode ser 'pt-BR' para Real(BRL) ou 'en-US' para Dóllar(USD):
{
normalizeMoney(100, 'pt-BR');
}
// Ex: R$ 100,00
// or
{
normalizeMoney(100, 'en-US');
}
// Ex: $100.00
So far, these are the supported formats: pt-BR
& en-US