quick note: this project was made for own use, but it's my gift to the public so everyone can enjoy, feel free to give it another life. If there are some countries missing, let me know or open a pull-request
Just run the npm i @greifmatthias/iso-countries
in your Node project.
All these functionalities are based on a ISO 3166-1 alpha-2 code.
This function returns a list of alle the supported countries
Example:
import { getAll } from '@greifmatthias/iso-countries';
const countries = getAll();
This function returns a Unicode based Flag Emoji like follow: 🇧🇪 for Belgium. If the emoji is displayed like 🇧 🇪, it means that your current environment doesn't support these Unicode emoji yet.
Example: Greetings from 🇧🇪
import { getFlag } from '@greifmatthias/iso-countries';
const flag = getFlag('BE');
console.log(`Greetings from ${flag}`);
This function returns the name of the country in English.
Example: Greetings from Belgium
import { getName } from '@greifmatthias/iso-countries';
const name = getName('BE');
console.log(`Greetings from ${name}`);
This function returns the 3-letter-version ISO for a country.
Example: Greetings from BEL
import { getIsoThree } from '@greifmatthias/iso-countries';
const iso = getIsoThree('BE');
console.log(`Greetings from ${iso}`);