9
9
10
10
'use strict' ;
11
11
12
- var locationUtils = module . exports = { } ;
12
+ var countryRegex = require ( 'country-regex' ) ;
13
+ var Lib = require ( './' ) ;
13
14
14
- var Plotly = require ( '../plotly' ) ;
15
-
16
- // an hash object iso3 to regex string
17
- var countryNameData = require ( '../constants/country-name_to_iso3' ) ;
18
15
19
16
// make list of all country iso3 ids from at runtime
20
- var countryIds = Object . keys ( countryNameData ) ;
17
+ var countryIds = Object . keys ( countryRegex ) ;
21
18
22
19
var locationmodeToIdFinder = {
23
- 'ISO-3' : Plotly . Lib . identity ,
24
- 'USA-states' : Plotly . Lib . identity ,
20
+ 'ISO-3' : Lib . identity ,
21
+ 'USA-states' : Lib . identity ,
25
22
'country names' : countryNameToISO3
26
23
} ;
27
24
28
- locationUtils . locationToFeature = function ( locationmode , location , features ) {
25
+ exports . locationToFeature = function ( locationmode , location , features ) {
29
26
var locationId = getLocationId ( locationmode , location ) ;
30
27
var feature ;
31
28
@@ -51,7 +48,7 @@ function countryNameToISO3(countryName) {
51
48
52
49
for ( var i = 0 ; i < countryIds . length ; i ++ ) {
53
50
iso3 = countryIds [ i ] ;
54
- regex = new RegExp ( countryNameData [ iso3 ] ) ;
51
+ regex = new RegExp ( countryRegex [ iso3 ] ) ;
55
52
56
53
if ( regex . test ( countryName . toLowerCase ( ) ) ) return iso3 ;
57
54
}
0 commit comments