simple-country-codes

0.2.0 • Public • Published

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 with object.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

Package Sidebar

Install

npm i simple-country-codes

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

7.44 kB

Total Files

5

Last publish

Collaborators

  • jelmer