add country data
This commit is contained in:
parent
24770e825e
commit
cd1716290c
5 changed files with 266 additions and 0 deletions
14
tools/gen-countries.js
Normal file
14
tools/gen-countries.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
const fs = require('fs')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const rawCountries = require('../raw-countries.json')
|
||||
|
||||
const topCodes = ['US', 'GB', 'CA', 'AU']
|
||||
|
||||
const countries = rawCountries
|
||||
.map(r => ({code: r.cca2, display: r.name.common}))
|
||||
|
||||
const topCountries = topCodes.map(c => countries.find(_.matchesProperty('code', c)))
|
||||
const final = _.uniqBy(_.get('code'), _.concat(topCountries, countries))
|
||||
|
||||
fs.writeFileSync('countries.json', JSON.stringify(final))
|
||||
Loading…
Add table
Add a link
Reference in a new issue