-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
25 lines (22 loc) · 795 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const cities = require('./cities.json');
const regions = require('./region-country-map.json');
let regionCountryMap = Object.assign({}, regions);
const fs = require('fs')
for(region in regionCountryMap) {
for(i in regionCountryMap[region]) {
for(j in cities) {
if(cities[j]['country'] === regionCountryMap[region][i]['code']) {
if(regionCountryMap[region][i]['cities'] === undefined)
regionCountryMap[region][i]['cities'] = [];
regionCountryMap[region][i]['cities'].push(cities[j]);
}
}
}
}
let hash = JSON.stringify(regionCountryMap);
fs.writeFile("./final-cities.txt", hash, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});