Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
country-name-code
Advanced tools
Maps ISO 3166-1-alpha-2 codes to English country names and vice versa, plus short country names.
Maps ISO 3166-1-alpha-2 codes to English country names and vice versa.
Uses data from https://www.iso.org/iso-3166-country-codes.html
You can find version 1.* of country-list here.
const { getCode, getName, getShortName } = require('country-list');
console.log(getName('GB')); // United Kingdom of Great Britain and Northern Ireland
console.log(getShortName('GB')); // United Kingdom
console.log(getCode('United Kingdom of Great Britain and Northern Ireland')); // GB
console.log(getCode('Nowhere-to-be-found-land')); // undefined
And how to change the name of a country
const { overwrite, getName } = require('country-list');
overwrite([{
code: 'TW',
name: 'Taiwan'
}])
console.log(getName('TW')); // Taiwan
Usage:
const countryList = require('country-list');
All input is case-insensitive.
Expects an array of country objects containing code
and name
properties.
[{
code: 'TW',
name: 'Taiwan'
}]
Expects a two-digit country code.
Returns the name for that country.
If not found, it returns undefined
.
Expects a two-digit country code.
Returns the short name for that country or the country name if short name is not defined in the data.json
. For example, the short name for United Kingdom of Great Britain and Northern Ireland
is United Kingdom
.
If not found, it returns undefined
.
Expects the English country name.
Returns the code for that country.
If not found, it returns undefined
.
Returns an array of all country names.
Returns an array of all country codes.
Returns a key-value object of all countries using the name as key.
Returns a key-value object of all countries using the code as key.
Returns an array of all country information, in the same format as it gets imported.
npm install country-list
MIT
ISO makes the list of alpha-2 country codes available for internal use and non-commercial purposes free of charge.
FAQs
Maps ISO 3166-1-alpha-2 codes to English country names and vice versa, plus short country names.
The npm package country-name-code receives a total of 2 weekly downloads. As such, country-name-code popularity was classified as not popular.
We found that country-name-code demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.