Installations
npm install country-locale-map
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
22.3.0
NPM Version
10.8.1
Releases
Unable to fetch releases
Contributors
Languages
JavaScript (100%)
Developer
atnmorrison
Download Statistics
Total Downloads
5,007,461
Last Day
4,923
Last Week
21,784
Last Month
96,130
Last Year
2,287,516
GitHub Statistics
45 Stars
242 Commits
43 Forks
3 Watching
1 Branches
17 Contributors
Bundle Size
253.65 kB
Minified
64.44 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.9.9
Package Id
country-locale-map@1.9.9
Unpacked Size
221.63 kB
Size
42.67 kB
File Count
10
NPM Version
10.8.1
Node Version
22.3.0
Publised On
19 Nov 2024
Total Downloads
Cumulative downloads
Total Downloads
5,007,461
Last day
-4.6%
4,923
Compared to previous day
Last week
-14.3%
21,784
Compared to previous week
Last month
4%
96,130
Compared to previous month
Last year
13%
2,287,516
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
6
Country Locale Map
Provides easy conversion between country codes and names as well as a default locale for each country. Includes fuzzy matching for country name lookups. Methods return undefined if no matches are found
Usage
1const clm = require('country-locale-map'); 2clm.getAlpha3ByAlpha2('CA'); //returns 'CAN'
If you would like locales to be returned with - instead of_ you can set an environment variable
CLM_MODE='INTL' in a .env file using dotenv just make sure that dotenv is required before requiring the country local map library
Functions
Alpha2
- getAlpha3ByAlpha2(alpha2)
1clm.getAlpha3ByAlpha2('CA'); //returns 'CAN'
- getLocaleByAlpha2(alpha2)
1clm.getLocaleByAlpha2('CA'); //returns 'en_CA'
- getCountryNameByAlpha2(alpha2)
1clm.getCountryNameByAlpha2('CA'); //returns 'Canada'
- getNumericByAlpha2(alpha2)
1clm.getNumericByAlpha2('CA'); //returns '124'
- getCurrencyByAlpha2(alpha2)
1clm.getCurrencyByAlpha2('CA'); //returns 'CAD'
- getCountryByAlpha2(alpha2)
1clm.getCountryByAlpha2('CA'); 2 3/*returns 4 5 { 6 "name":"Canada", 7 "alpha2":"CA", 8 "alpha3":"CAN", 9 "numeric":"124", 10 "locales":["en_CA","fr_CA"], 11 "default_locale":"en_CA", 12 "currency":"CAD", 13 "languages":["en","fr"], 14 "capital":"Ottawa", 15 "emoji":"🇨🇦", 16 "emojiU":"U+1F1E8 U+1F1E6", 17 "fips":"CA", 18 "internet":"CA", 19 "continent":"Americas", 20 "region":"North America" 21 } 22 23*/
Alpha3
- getAlpha2ByAlpha3(alpha3)
1clm.getAlpha3ByAlpha2('CAN'); //returns 'CA'
- getLocaleByAlpha3(alpha3)
1clm.getLocaleByAlpha3('CAN'); //returns 'en_CA'
- getCountryNameByAlpha3(alpha3)
1clm.getCountryNameByAlpha3('CAN'); //returns 'Canada'
- getNumericByAlpha3(alpha3)
1clm.getNumericByAlpha3('CAN'); //returns '124'
- getCurrencyByAlpha3(alpha3)
1clm.getCurrencyByAlpha3('CAN'); //returns 'CAD'
- getCountryByAlpha3(alpha3)
1clm.getCountryByAlpha3('CAN'); 2 3 4/*returns 5 6 { 7 "name":"Canada", 8 "alpha2":"CA", 9 "alpha3":"CAN", 10 "numeric":"124", 11 "locales":["en_CA","fr_CA"], 12 "default_locale":"en_CA", 13 "currency":"CAD", 14 "languages":["en","fr"], 15 "capital":"Ottawa", 16 "emoji":"🇨🇦", 17 "emojiU":"U+1F1E8 U+1F1E6", 18 "fips":"CA", 19 "internet":"CA", 20 "continent":"Americas", 21 "region":"North America" 22 } 23 24*/ 25
Numeric
- getAlpha2ByNumeric(numeric)
1clm.getAlpha2ByNumeric('123'); //returns 'CA'
- getAlpha3ByNumeric(numeric)
1clm.getAlpha3ByNumeric('124'); //returns 'CAN'
- getLocaleByNumeric(numeric)
1clm.getLocaleByNumeric('124'); //returns 'en_CA'
- getCountryNameByNumeric(numeric)
1clm.getCountryNameByNumeric('124'); //returns 'Canada'
- getCurrencyByNumeric(numeric)
1clm.getCurrencyByNumeric('124'); //returns 'CAD'
- getCountryByNumeric(numeric)
1clm.getCountryByNumeric('124'); 2 3 4/*returns 5 6 { 7 "name":"Canada", 8 "alpha2":"CA", 9 "alpha3":"CAN", 10 "numeric":"124", 11 "locales":["en_CA","fr_CA"], 12 "default_locale":"en_CA", 13 "currency":"CAD", 14 "languages":["en","fr"], 15 "capital":"Ottawa", 16 "emoji":"🇨🇦", 17 "emojiU":"U+1F1E8 U+1F1E6", 18 "fips":"CA", 19 "internet":"CA", 20 "continent":"Americas", 21 "region":"North America" 22 } 23 24*/ 25 26
Name
- getAlpha2ByName(country, fuzzy)
1clm.getAlpha2ByName('Canada'); //returns 'CA'
- getAlpha3ByName(country, fuzzy)
1clm.getAlpha3ByName('Canada'); //returns 'CAN'
- getLocaleByName(country, fuzzy)
1clm.getLocaleByName('Canada'); //returns 'en_CA'
- getNumericByName(country, fuzzy)
1clm.getNumericByName('Canada'); //returns '124'
- getCurrencyByName(country, fuzzy)
1clm.getCurrencyByName('Canada'); //returns 'CAD'
- getCountryByName(country, fuzzy)
1clm.getCountryByName('Canada'); 2 3/*returns 4 5 { 6 "name":"Canada", 7 "alpha2":"CA", 8 "alpha3":"CAN", 9 "numeric":"124", 10 "locales":["en_CA","fr_CA"], 11 "default_locale":"en_CA", 12 "currency":"CAD", 13 "languages":["en","fr"], 14 "capital":"Ottawa", 15 "emoji":"🇨🇦", 16 "emojiU":"U+1F1E8 U+1F1E6", 17 "fips":"CA", 18 "internet":"CA", 19 "continent":"Americas", 20 "region":"North America" 21 } 22 23*/ 24
if true is passed for fuzzy these functions will do a fuzzy match if it can't find an exact match eg:
1clm.getCountryByName('Candaa', true); 2 3/*returns 4 5 { 6 "name":"Canada", 7 "alpha2":"CA", 8 "alpha3":"CAN", 9 "numeric":"124", 10 "locales":["en_CA","fr_CA"], 11 "default_locale":"en_CA", 12 "currency":"CAD", 13 "languages":["en","fr"], 14 "capital":"Ottawa", 15 "emoji":"🇨🇦", 16 "emojiU":"U+1F1E8 U+1F1E6", 17 "fips":"CA", 18 "internet":"CA", 19 "continent":"Americas", 20 "region":"North America" 21 } 22 23*/ 24
- getAllCountries()
1clm.getAllCountries(); 2 3/*returns 4 the list of all countries 5*/ 6
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
Reason
Found 4/24 approved changesets -- score normalized to 1
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
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'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 10 are checked with a SAST tool
Score
3
/10
Last Scanned on 2025-01-27
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 More