Skip to content

Commit 0d12595

Browse files
committed
swap country-name_to_iso3 file for country-regex package
1 parent 3180b12 commit 0d12595

File tree

3 files changed

+4
-273
lines changed

3 files changed

+4
-273
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"alpha-shape": "^1.0.0",
4949
"arraytools": "^1.0.0",
5050
"convex-hull": "^1.0.3",
51+
"country-regex": "^1.0.0",
5152
"d3": "^3.5.12",
5253
"delaunay-triangulate": "^1.1.6",
5354
"es6-promise": "^3.0.2",

src/constants/country-name_to_iso3.js

Lines changed: 0 additions & 268 deletions
This file was deleted.

src/lib/geo_location_utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
'use strict';
1111

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

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

16-
// an hash object iso3 to regex string
17-
var countryNameData = require('../constants/country-name_to_iso3');
18-
1917
// make list of all country iso3 ids from at runtime
20-
var countryIds = Object.keys(countryNameData);
18+
var countryIds = Object.keys(countryRegex);
2119

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

5250
for(var i = 0; i < countryIds.length; i++) {
5351
iso3 = countryIds[i];
54-
regex = new RegExp(countryNameData[iso3]);
52+
regex = new RegExp(countryRegex[iso3]);
5553

5654
if(regex.test(countryName.toLowerCase())) return iso3;
5755
}

0 commit comments

Comments
 (0)