gastonmesseri / numerable

Number formatting library for Javascript and Node.js apps
MIT License
82 stars 1 forks source link

abbreviate currency numbers #1

Closed ianstormtaylor closed 3 years ago

ianstormtaylor commented 3 years ago

It looks like there is the a format for abbreviated numbers (which is awesome!) but you can't use a and $ together. I was hoping to have something like:

$150K
$1M
...
gastonmesseri commented 3 years ago

Hi @ianstormtaylor ,

You can use the abbreviation (a) and currency ($) together.

You can try running the following example: format(1234, '$0,0.00a', { currency: 'USD' }); // Returns "$1.23K"

In order to format currency, you need to specify the currency in the options object (e.g. { currency: 'USD' }). I'll upload soon some detailed documentation, so I hope that helps understanding better how the library works.

Thanks for reporting anyway :)

ianstormtaylor commented 3 years ago

Ah my bad I totally missed that! Works perfectly.

Thanks for this library btw, it's amazingly simple but does exactly what's needed.