New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@blossomfinance/iso-4217-currencies

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blossomfinance/iso-4217-currencies

Simply a list of ISO-4217 currencies with name, code, symbol, & decimal rounding

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
985
decreased by-23.76%
Maintainers
1
Weekly downloads
 
Created
Source

ISO-4217 Currencies

Simply a list of ISO-4217 currencies with name, code, symbol, & decimal rounding. Also, support for figuring out the currency based on ISO-3166-1 Alpha-2 country code.

Basic Usage


// include it
const lib = require('@blossomfinance/iso-4217-currencies');

// get metadata for a specific currency code
const usd = lib.currency('USD');
// {
//   "symbol": "$",
//   "name": "US Dollar",
//   "symbolNative": "$",
//   "decimalDigits": 2,
//   "rounding": 0,
//   "code": "USD",
//   "namePlural": "US dollars"
// }

// get currency metadata by country code
const eur = lib.currency('FR');
// {
//   "symbol": "€",
//   "name": "Euro",
//   "symbolNative": "€",
//   "decimalDigits": 2,
//   "rounding": 0,
//   "code": "EUR",
//   "namePlural": "euros"
// }

// get currency code for a country code
const code = lib.codeForCountry('CM');
// "XAF"

Exported API

const lib = require('@blossomfinance/iso-4217-currencies');

const {
  // array of currency codes
  // ['AED', 'AFN', ...]
  codes,

  // array of currency metadata
  // [
  //   {
  //     "symbol": "AED",
  //     "name": "United Arab Emirates Dirham",
  //     "symbolNative": "د.إ.‏",
  //     "decimalDigits": 2,
  //     "rounding": 0,
  //     "code": "AED",
  //     "namePlural": "UAE dirhams"
  //   },
  //   ...
  // ]
  currencies,

  // hash map of currency metadata indexed by currency code
  // {
  //   "AED": {
  //     "symbol": "AED",
  //     "name": "United Arab Emirates Dirham",
  //     "symbolNative": "د.إ.‏",
  //     "decimalDigits": 2,
  //     "rounding": 0,
  //     "code": "AED",
  //     "namePlural": "UAE dirhams"
  //   },
  //   ...
  // }
  map,

  // domain-specific errors thrown if currency code was not found:
  CurrencyNotFoundError,

  // domain-specific errors thrown if no currency code found for country code:
  CountryCurrencyNotFoundError,

} = lib;

Why?

Most solutions available are super overkill, not distributed as packages (e.g. gist), and/or out of date.

Credits

Original inspiration was from Kent Safranski in the form of this helpful Gist

Keywords

FAQs

Package last updated on 23 Nov 2021

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