Skip to content

Commit

Permalink
Map countries to different format
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicbartl committed Apr 28, 2017
1 parent 072826d commit 6c97def
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

# Created by https://www.gitignore.io/api/node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


# End of https://www.gitignore.io/api/node
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const countries = require('world-countries/countries');
const EU = ['AUT','BEL','BGR','CYP','CZE','DEU','DNK','ESP','EST','FIN','FRA','GBR','GRC','HRV','HUN','IRL','ITA','LTU','LUX','LVA','MLT','NLD','POL','PRT','ROU','SVK','SVN','SWE'];

let mapped = countries.map((country) => {
return {
cca2: country.cca2,
ccn3: country.ccn3,
cca3: country.cca3,
currency: country.currency[0],
name: country.name.common,
in_eu: EU.indexOf(country.cca2) >= 0,
translations: {
en: country.name.common,
de: country.translations.deu.common
}
}
});

module.exports = mapped;
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "countries",
"version": "1.0.0",
"description": "A list of countries",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Dominic Bartl",
"license": "MIT",
"dependencies": {
"world-countries": "^1.8.1"
}
}

0 comments on commit 6c97def

Please sign in to comment.