2-letter country codes to English and vice-versa
JavaScript CoffeeScript
Pull request Compare This branch is 17 commits ahead, 15 commits behind fannarsh:master.
Latest commit 89ef9da Feb 25, 2015 @EvanHahn 0.1.1
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE.txt LICENSE -> LICENSE.txt Feb 24, 2015
README.md Update readme Feb 24, 2015
country-list.js ready for first release Jul 9, 2014
package.json

README.md

ISO 3166 country list

Maps ISO 3166 codes to English country names and vice versa. I built this because I couldn't find something that did exactly what I wanted and worked in the browser.

In the browser:

<script src="country-list.js"></script>
<script>
countryList.name("DE")  // "Germany"
</script>

In Node/Browserify, run npm install iso-3166-country-list:

var countryList = require("iso-3166-country-list");
countryList.code("Germany")  // "DE"

Here are some usage examples:

countryList.name("DE")       // "Germany"
countryList.code("Germany")  // "DE"

countryList.name("de")       // "Germany"
countryList.code("germany")  // "DE"

countryList.codes  // ["AF", "AX", "AL", ...]
countryList.names  // ["Afghanistan", "Åland Islands", "Albania", ...]
countryList        // [
                   //   { "code": "AF", "name": "Afghanistan" },
                   //   { "code": "AX", "name": "Åland Islands" },
                   //   { "code": "AL", "name": "Albania" },
                   //   ...
                   // ]

countryList.name("something-unknown")  // undefined
countryList.code("something-unknown")  // undefined