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

@coinify/currency

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coinify/currency

Helper functions for managing amounts in different currencies

  • 1.3.28
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
145
decreased by-57.73%
Maintainers
2
Weekly downloads
 
Created
Source

node-currency

npm version

Installation

Run the following command

npm install --save @coinify/currency

Usage

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?

Keywords

FAQs

Package last updated on 08 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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