@coinify/currency
Version:
Helper functions for managing amounts in different currencies
44 lines (28 loc) • 1.42 kB
Markdown
[](https://badge.fury.io/js/%40coinify%2Fcurrency)
Run the following command
```
npm install --save @coinify/currency
```
```js
const currency = require('@coinify/currency');
```
`currency` exposes the following functions:
_Returns the number of decimals after the floating point, with which the amount should be formatted, depending on the currency._
_Convert an amount of money from the smallest sub-unit of the currency to the main-unit._
_Convert an amount of money from the main-unit of the currency to the smallest sub-unit._
_Convert between sub-unit amounts of two currencies with a given rate, correctly converting between sub-units with different decimal amounts._
_Computes a rate between two amounts in two different currencies._
_Is the provided currency code a valid currency? (fiat or crypto)_
_Is the provided currency code a valid fiat currency?_
_Is the provided currency code a valid crypto currency?_