This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@blossomfinance/iso-4217-currencies

0.2.5 • Public • Published

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

Dependents (0)

Package Sidebar

Install

npm i @blossomfinance/iso-4217-currencies

Weekly Downloads

238

Version

0.2.5

License

MIT

Unpacked Size

50.6 kB

Total Files

15

Last publish

Collaborators

  • matmar10