@coinify/currency
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@coinify/currency", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Helper functions for managing amounts in different currencies", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,1 +0,41 @@ | ||
# node-currency | ||
# node-currency | ||
## Installation | ||
Run the following command | ||
``` | ||
npm install --save @coinify/currency | ||
``` | ||
## Usage | ||
```js | ||
const currency = require('@coinify/currency'); | ||
``` | ||
`currency` exposes the following functions: | ||
### `getDecimalsForCurrency(currency)` | ||
_Returns the number of decimals after the floating point, with which the amount should be formatted, depending on the currency._ | ||
### `fromSmallestSubunit(amount, currency)` | ||
_Convert an amount of money from the smallest sub-unit of the currency to the main-unit._ | ||
### `toSmallestSubunit(amount, currency)` | ||
_Convert an amount of money from the main-unit of the currency to the smallest sub-unit._ | ||
### `convertSubunitAmount(amountSubUnit, rate, fromCurrency, toCurrency)` | ||
_Convert between sub-unit amounts of two currencies with a given rate, correctly converting between sub-units with different decimal amounts._ | ||
### `computeRateBetweenSubunitAmounts(fromCurrency, fromAmount, toCurrency, toAmount)` | ||
_Computes a rate between two amounts in two different currencies._ | ||
### `isValidCurrency(code)` | ||
_Is the provided currency code a valid currency? (fiat or crypto)_ | ||
### `isValidFiatCurrency(code)` | ||
_Is the provided currency code a valid fiat currency?_ | ||
### `isValidCryptoCurrency(code)` | ||
_Is the provided currency code a valid crypto currency?_ |
@@ -21,3 +21,3 @@ const _ = require('lodash'); | ||
/** | ||
* Convert an amount of money to the smallest sub-unit of the currency. | ||
* Convert an amount of money from the smallest sub-unit of the currency. | ||
* For example, for a BTC account, this function will convert | ||
@@ -24,0 +24,0 @@ * 12345678 to 0.12345678. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36129
42