Skip to content

Commit

Permalink
better builds. better usage
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Nov 15, 2016
1 parent 331e752 commit d41f618
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
lib/
.DS_Store
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import isoLib from 'src/iso3166';
import isoLib from './src/iso3166.js';

export default isoLib;
7 changes: 6 additions & 1 deletion lib/iso3166.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ var findRegionByCode = function findRegionByCode(code, dispute) {
};

var reduce = function reduce(dataset, lang, countryList) {
var reduceElement = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (a) {
return a;
};

var result = {};
Object.keys(dataset).forEach(function (iso1) {
if (countryList && countryList.indexOf(iso1) < 0) {
Expand All @@ -127,12 +131,13 @@ var reduce = function reduce(dataset, lang, countryList) {
country.name = country.names[lang] || country.name;
delete country.names;
var regions = country.regions;
country = reduceElement(country);
country.regions = [];
regions.forEach(function (oldRegion) {
var region = _extends({}, oldRegion);
region.name = region.names[lang] || region.name;
delete region.names;
country.regions.push(region);
country.regions.push(reduceElement(region));
});

result[iso1] = country;
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "iso3166-2-db",
"version": "1.0.3",
"version": "1.0.4",
"description": "Provides information about countries and stated of the world",
"main": "index.js",
"main": "lib/iso3166.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src -d lib"
"build": "babel src -d lib",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,4 +34,4 @@
"babel-preset-latest": "^6.16.0",
"babel-preset-stage-1": "^6.16.0"
}
}
}
4 changes: 2 additions & 2 deletions src/iso3166.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import calculateDispute from './disputedBorders';
import patchNameProvider from './nameProvider'

let DEFAULT_DISPUTE = 'en';
let NAMES_SET = 'wikipedia'
let NAMES_SET = 'wikipedia';

const changeDispute = (newValue) => (DEFAULT_DISPUTE = newValue);
const changeNameProvider = (newValue) => (NAMES_SET = newValue);
Expand Down Expand Up @@ -32,7 +32,7 @@ const getDataSet = (dispute = DEFAULT_DISPUTE) => {
data: patchNameProvider(getDisputedData(dataFile, dispute), NAMES_SET)
};
return lastDisputedData.data;
}
};

const getFlatData = (dispute = DEFAULT_DISPUTE) => {
const list = getDataSet(dispute);
Expand Down

0 comments on commit d41f618

Please sign in to comment.