GithubHelp home page GithubHelp logo

kfwebdev / iso-4217-currencies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matmar10/iso-4217-currencies

0.0 0.0 0.0 749 KB

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

License: MIT License

JavaScript 100.00%

iso-4217-currencies's Introduction

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

iso-4217-currencies's People

Contributors

matmar10 avatar mreduar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.