Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coinify/currency

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coinify/currency - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc