Socket
Socket
Sign inDemoInstall

@blossomfinance/iso-4217-currencies

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
334
increased by138.57%
Maintainers
1
Install size
49.5 kB
Created
Weekly downloads
 

Readme

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

Last updated on 23 Nov 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc