99
1010'use strict' ;
1111
12- var locationUtils = module . exports = { } ;
12+ var countryRegex = require ( 'country-regex' ) ;
13+ var Lib = require ( './' ) ;
1314
14- var Plotly = require ( '../plotly' ) ;
15-
16- // an hash object iso3 to regex string
17- var countryNameData = require ( '../constants/country-name_to_iso3' ) ;
1815
1916// make list of all country iso3 ids from at runtime
20- var countryIds = Object . keys ( countryNameData ) ;
17+ var countryIds = Object . keys ( countryRegex ) ;
2118
2219var locationmodeToIdFinder = {
23- 'ISO-3' : Plotly . Lib . identity ,
24- 'USA-states' : Plotly . Lib . identity ,
20+ 'ISO-3' : Lib . identity ,
21+ 'USA-states' : Lib . identity ,
2522 'country names' : countryNameToISO3
2623} ;
2724
28- locationUtils . locationToFeature = function ( locationmode , location , features ) {
25+ exports . locationToFeature = function ( locationmode , location , features ) {
2926 var locationId = getLocationId ( locationmode , location ) ;
3027 var feature ;
3128
@@ -51,7 +48,7 @@ function countryNameToISO3(countryName) {
5148
5249 for ( var i = 0 ; i < countryIds . length ; i ++ ) {
5350 iso3 = countryIds [ i ] ;
54- regex = new RegExp ( countryNameData [ iso3 ] ) ;
51+ regex = new RegExp ( countryRegex [ iso3 ] ) ;
5552
5653 if ( regex . test ( countryName . toLowerCase ( ) ) ) return iso3 ;
5754 }
0 commit comments