Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jelmerdemaat/simple-country-codes
Retrieve country names by giving country codes.
https://github.com/jelmerdemaat/simple-country-codes
codes countries country-codes list module
Last synced: 4 days ago
JSON representation
Retrieve country names by giving country codes.
- Host: GitHub
- URL: https://github.com/jelmerdemaat/simple-country-codes
- Owner: jelmerdemaat
- License: other
- Created: 2018-04-10T13:35:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-10T13:57:29.000Z (over 6 years ago)
- Last Synced: 2024-10-12T19:28:14.995Z (about 1 month ago)
- Topics: codes, countries, country-codes, list, module
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple country codes
[GitHub](https://github.com/jelmerdemaat/simple-country-codes) | [NPM](https://www.npmjs.com/package/simple-country-codes) | [@jelmerdemaat](https://twitter.com/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 objectFeatures:
* 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](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```bash
npm install --save simple-country-codes
```[Import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) and use in your own JavaScript:
```js
import { getCountry } from 'simple-country-codes';getCountry('gb'); // Returns "United Kingdom"
getCountry('nl'); // Returns "Netherlands"
getCountry('poop'); // Returns false
```