-
Notifications
You must be signed in to change notification settings - Fork 1
/
temp.js
38 lines (27 loc) · 922 Bytes
/
temp.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
26
27
28
29
30
31
32
33
34
35
36
37
38
var fs = require('fs');
var savPath = __dirname + '/lib/countries.json';
var srcPath = __dirname + '/lib/count_uni.json';
function getData(srcPath) {
fs.readFile(srcPath, 'utf8', function (err, data) {
if (err)
console.log(err);
else {
var id=0;
var dataJson=JSON.parse(data);
var dataJso=dataJson.reduce((cum ,uni)=>{
if(cum.indexOf(uni.country) === -1)
cum.push(uni.country);
return cum;
},[])
console.log('data',dataJso);
fs.writeFile(savPath , JSON.stringify(dataJso) ,function() {
if(err)
console.log(err);
else {
console.log('Complete');
}
})
}
});
}
getData(srcPath);