Skip to content

Commit

Permalink
swap country-name_to_iso3 file for country-regex package
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Apr 21, 2016
1 parent 3180b12 commit 0d12595
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 273 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"alpha-shape": "^1.0.0",
"arraytools": "^1.0.0",
"convex-hull": "^1.0.3",
"country-regex": "^1.0.0",
"d3": "^3.5.12",
"delaunay-triangulate": "^1.1.6",
"es6-promise": "^3.0.2",
Expand Down
268 changes: 0 additions & 268 deletions src/constants/country-name_to_iso3.js

This file was deleted.

8 changes: 3 additions & 5 deletions src/lib/geo_location_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@

'use strict';

var countryRegex = require('country-regex');
var locationUtils = module.exports = {};

var Plotly = require('../plotly');

// an hash object iso3 to regex string
var countryNameData = require('../constants/country-name_to_iso3');

// make list of all country iso3 ids from at runtime
var countryIds = Object.keys(countryNameData);
var countryIds = Object.keys(countryRegex);

var locationmodeToIdFinder = {
'ISO-3': Plotly.Lib.identity,
Expand Down Expand Up @@ -51,7 +49,7 @@ function countryNameToISO3(countryName) {

for(var i = 0; i < countryIds.length; i++) {
iso3 = countryIds[i];
regex = new RegExp(countryNameData[iso3]);
regex = new RegExp(countryRegex[iso3]);

if(regex.test(countryName.toLowerCase())) return iso3;
}
Expand Down

0 comments on commit 0d12595

Please sign in to comment.