Simple country codes
GitHub | NPM | @jelmerdemaat
Retrieve country names by giving country codes.
All this is:
- A JSON object of all country codes and their country names
- A function to safely retrieve items from that object
Features:
- ES6 ready
- Case insensitive ('gb' and 'GB' both work)
- Function
getCountry
checks existance of property withobject.hasOwnProperty
- Returns
false
if your query does not exist
Usage
Add to your local dependencies using npm:
npm install --save simple-country-codes
Import and use in your own JavaScript:
import { getCountry } from 'simple-country-codes';
getCountry('gb'); // Returns "United Kingdom"
getCountry('nl'); // Returns "Netherlands"
getCountry('poop'); // Returns false