Installations
npm install country-to-currency
Developer Guide
Typescript
Yes
Module System
ESM, UMD
Node Version
20.15.0
NPM Version
10.8.1
Score
98.6
Supply Chain
99.5
Quality
81
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (72.87%)
TypeScript (27.13%)
Developer
thiagodp
Download Statistics
Total Downloads
2,257,433
Last Day
5,901
Last Week
26,191
Last Month
111,367
Last Year
1,200,056
GitHub Statistics
49 Stars
65 Commits
9 Forks
2 Watching
1 Branches
3 Contributors
Bundle Size
2.36 kB
Minified
1.17 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.2
Package Id
country-to-currency@2.0.2
Unpacked Size
33.41 kB
Size
8.41 kB
File Count
9
NPM Version
10.8.1
Node Version
20.15.0
Publised On
11 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
2,257,433
Last day
-7.1%
5,901
Compared to previous day
Last week
-12.3%
26,191
Compared to previous week
Last month
12.4%
111,367
Compared to previous month
Last year
61.5%
1,200,056
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
country-to-currency
Maps country codes (ISO 3166-1 alpha-2) to their default currency codes (ISO 4217).
âš¡ Just 2.3 KB (uncompressed), no external dependencies.
🎯 Work with browsers, NodeJS, and DenoJS. JavaScript and TypeScript.
Install
1npm i 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.
👉 Examples available in the folder examples.
TypeScript
From version 1.1.0
on, there are two union types available (TypeScript 3.4+ only):
Currencies
, that contains all the currencies;Countries
, that contains all the countries.
Example using TypeScript on NodeJS:
1 import countryToCurrency, { Currencies, Countries } from "country-to-currency";
Browser - without installing anything
Global:
1<script crossorigin src="https://unpkg.com/country-to-currency" ></script> 2<script> 3 console.log( countryToCurrency ); // {AF: "AFN", AX: "EUR", ... } 4 console.log( countryToCurrency[ 'US' ] ); // USD 5 console.log( countryToCurrency[ 'DE' ] ); // EUR 6 console.log( countryToCurrency[ 'BR' ] ); // BRL 7</script>
ESM:
1<script type="module" > 2 import countryToCurrency from "https://unpkg.com/country-to-currency/index.esm.js"; 3 console.log( countryToCurrency[ 'US' ] ); // USD 4</script>
NodeJS
1const countryToCurrency = require( 'country-to-currency/index.cjs' ); // '/index.cjs' needed since version 2.0 2console.log( countryToCurrency[ 'US' ] ); // USD
Deno
1import countryToCurrency from "https://unpkg.com/country-to-currency/index.esm.js"; 2console.log( countryToCurrency[ 'US' ] ); // USD
Notes
- Countries included:
251
- Imported:
249
- Included:
2
- Fixed:
17
- Imported:
- Currencies assumed:
Country | Currency | Details | Thanks to |
---|---|---|---|
Antarctica (AQ ) | USD | Antarctica has no official currency | @thiagodp |
Palestine (PS ) | ILS | @thiagodp | |
Turkey (TR ) | TRY | Wikipedia | @kylem123, @thiagodp |
South Korea (KR ) | KRW | ISO 4217 | @MunjaeLee, @thiagodp |
Switzerland (CH ) | CHF | Wikipedia | @betabong, @thiagodp |
Chile (CL ) | CLP | CLF is a non-circulating currency. Wikipedia | @thiagodp |
Uruguay (UY ) | UYU | Wikipedia | @marneborn, @thiagodp |
Croatia (HR ) | EUR | Since January 1st, 2023. Wikipedia and Stripe | @xaphod, @thiagodp |
Netherlands Antilles (AN ) | ANG | ISO 4217 | @jayPare, @thiagodp |
El Salvador (SV ) | USD | Since 2001. Wikipedia | @chaitanya-d, @thiagodp |
South Georgia and the South Sandwich Islands (GS ) | FKP | Wikipedia and https://gov.gs | @danielrentz, @thiagodp |
Cuba (CU ) | CUP | Wikipedia | @jasongitmail, @thiagodp |
Hungary (HU ) | HUF | Wikipedia | @jasongitmail, @thiagodp |
Samoa (WS ) | WST | Wikipedia | @jasongitmail, @thiagodp |
Niger (NE ) | XOF | Wikipedia | @danielrentz, @thiagodp |
Republic of the Congo (CG ) | XAF | Wikipedia | @jasongitmail, @thiagodp |
Dominican Republic (DM ) | XCD | Wikipedia | @jasongitmail, @thiagodp |
Sierra Leone (SL ) | SLE | Wikipedia and European Union | @jasongitmail, @thiagodp |
Kosovo (XK ) | EUR | Wikipedia and Geo Names | @dukesilverr, @thiagodp |
Contribute
Suggestions? Please open an Issue. Pull Requests? Make sure to edit generate.js instead of index.ts.
License
This library is inspired by Michael Rhodes' currency-code-map. The current project adds new currencies, fixes, offers support to browsers and DenoJS, updates dependencies, and provides new internal scripts.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
10 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
4.2
/10
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to country-to-currency
locale-currency
A map of i18n country codes to ISO 4217 currency codes. Originally generated from the output of java.util.Currency.getInstance(locale)
currency-to-country
Get country information via currency code
currency-to-country-map
Maps currency codes to their corresponding country names
country-currency-utils
An npm package with list of countries, currencies, and utility functions to round, format and display monetory amounts