Wondering what’s next for npm?Check out our public roadmap! »

country-to-currencyTypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

country-to-currency

Maps country codes (ISO 3166-1 alpha-2) to their default currency codes (ISO 4217).

⚡ Just 3 KB and no external dependencies.

🎯 Works with browsers, NodeJS and DenoJS (JavaScript and TypeScript).

Install

npm install country-to-currency

Usage

This library exports a default object that maps country codes to currency codes.

Available formats include UMD (therefore AMD and CommonJS) and ESM.

Browser - without installing anything

<script type="module" >
    import currency from "https://unpkg.com/country-to-currency/index.esm.js";
    console.log( currency ); // {AF: "AFN", AX: "EUR", ... }
    console.log( currency[ 'US' ] ); // USD
    console.log( currency[ 'DE' ] ); // EUR
    console.log( currency[ 'BR' ] ); // BRL
</script> 

Note: UMD is available in index.umd.js.

NodeJS

const currency = require( 'country-to-currency' );
console.log( currency ); // {AF: "AFN", AX: "EUR", ... }

DenoJS

import currency from "https://unpkg.com/country-to-currency/index.esm.js";
console.log( currency ); // {AF: "AFN", AX: "EUR", ... }

Notes

  • All the countries included (currently 249).
  • For Antarctica (AQ), the currency US Dollars (USD) is being assumed.
  • For Palestine (PS), the currency New Israeli Sheqel (ILS) is being assumed.

Suggestions? Please open an Issue.

License

This library is inspired by currency-code-map from Michael Rhodes. This project adds new currencies, offers support to browsers and DenoJS, updates dependencies and provide new internal scripts.

MIT © Thiago Delgado Pinto

Install

npm i country-to-currency

DownloadsWeekly Downloads

26

Version

1.0.2

License

MIT

Unpacked Size

40.5 kB

Total Files

13

Last publish

Collaborators

  • avatar