forked from xcarpentier/react-native-country-picker-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45bb61f
commit e41c67c
Showing
13 changed files
with
8,104 additions
and
8,953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
["AF","AL","DZ","AS","AD","AO","AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","VG","BN","BG","BF","BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM","CK","CR","HR","CU","CW","CY","CZ","CD","DK","DJ","DM","DO","EC","EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","GF","PF","TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GG","GN","GW","GY","HT","HM","HN","HK","HU","IS","IN","ID","IR","IQ","IE","IM","IL","IT","CI","JM","JP","JE","JO","KZ","KE","KI","XK","KW","KG","LA","LV","LB","LS","LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH","MQ","MR","MU","YT","MX","FM","MD","MC","MN","ME","MS","MA","MZ","MM","NA","NR","NP","NL","NC","NZ","NI","NE","NG","NU","NF","KP","MP","NO","OM","PK","PW","PS","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","CG","RO","RU","RW","RE","BL","KN","LC","MF","PM","VC","WS","SM","SA","SN","RS","SC","SL","SG","SX","SK","SI","SB","SO","ZA","GS","KR","SS","ES","LK","SD","SR","SJ","SZ","SE","CH","SY","ST","TW","TJ","TZ","TH","TL","TG","TK","TO","TT","TN","TR","TM","TC","TV","UG","UA","AE","GB","US","UM","VI","UY","UZ","VU","VA","VE","VN","WF","EH","YE","ZM","ZW","AX"] | ||
["AF","AL","DZ","AS","AD","AO","AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","VG","BN","BG","BF","BI","KH","CM","CA","CV","BQ","KY","CF","TD","CL","CN","CX","CC","CO","KM","CK","CR","HR","CU","CW","CY","CZ","CD","DK","DJ","DM","DO","EC","EG","SV","GQ","ER","EE","SZ","ET","FK","FO","FJ","FI","FR","GF","PF","TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GG","GN","GW","GY","HT","HM","HN","HU","IS","IN","ID","IR","IQ","IE","IM","IL","IT","CI","JM","JP","JE","JO","KZ","KE","XK","KW","KG","LA","LV","LB","LS","LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH","MQ","MR","MU","YT","MX","FM","MD","MC","MN","ME","MS","MA","MZ","MM","NA","NR","NP","NL","NC","NZ","NI","NE","NG","NU","NF","KP","MP","NO","OM","PK","PW","PS","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","CG","RO","RU","RW","RE","BL","SH","KN","LC","MF","PM","VC","WS","SM","SA","SN","RS","SC","SL","SG","SX","SK","SI","SB","SO","ZA","GS","KR","SS","ES","LK","SD","SR","SJ","SE","CH","SY","ST","TW","TJ","TZ","TH","TL","TG","TK","TO","TT","TN","TR","TM","TC","TV","UG","UA","AE","GB","US","UM","VI","UY","UZ","VU","VA","VE","VN","WF","EH","YE","ZM","ZW","KI","HK","AX"] |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
import countries from 'world-countries'; | ||
import flags from '../src/countryFlags'; | ||
#!/usr/bin/env node | ||
|
||
const isEmoji = process.argv.includes('--emoji'); | ||
const isCca2 = process.argv.includes('--cca2'); | ||
const countries = require('world-countries') | ||
const flags = require('./countryFlags') | ||
|
||
const getCountryNames = (common, translations) => Object | ||
.keys(translations) | ||
const isEmoji = process.argv.includes('--emoji') | ||
const isCca2 = process.argv.includes('--cca2') | ||
|
||
const getCountryNames = (common, translations) => | ||
Object.keys(translations) | ||
.filter(k => k !== 'common') | ||
.map(key => ({ [key]: translations[key].common })) | ||
.reduce((prev, cur) => ({ ...prev, [Object.keys(cur)[0]]: cur[Object.keys(cur)[0]] }), {}); | ||
.reduce( | ||
(prev, cur) => ({ | ||
...prev, | ||
[Object.keys(cur)[0]]: cur[Object.keys(cur)[0]] | ||
}), | ||
{} | ||
) | ||
|
||
const newcountries = countries | ||
.map( | ||
({ cca2, currency, callingCode, name: { common }, translations }) => ({ | ||
[cca2]: { | ||
currency: currency[0], | ||
callingCode: callingCode[0], | ||
flag: isEmoji ? `flag-${cca2.toLowerCase()}` : flags[cca2], | ||
name: { common, ...getCountryNames(common, translations) }, | ||
}, | ||
}) | ||
) | ||
.map(({ cca2, currency, callingCode, name: { common }, translations }) => ({ | ||
[cca2]: { | ||
currency: currency[0], | ||
callingCode: callingCode[0], | ||
flag: isEmoji ? `flag-${cca2.toLowerCase()}` : flags[cca2], | ||
name: { common, ...getCountryNames(common, translations) } | ||
} | ||
})) | ||
.sort((a, b) => { | ||
if (a[Object.keys(a)[0]].name.common === b[Object.keys(b)[0]].name.common) { | ||
return 0; | ||
} else if (a[Object.keys(a)[0]].name.common < b[Object.keys(b)[0]].name.common) { | ||
return -1; | ||
return 0 | ||
} else if ( | ||
a[Object.keys(a)[0]].name.common < b[Object.keys(b)[0]].name.common | ||
) { | ||
return -1 | ||
} | ||
return 1; | ||
return 1 | ||
}) | ||
.reduce( | ||
(prev, cur) => | ||
({ | ||
(prev, cur) => ({ | ||
...prev, | ||
[Object.keys(cur)[0]]: cur[Object.keys(cur)[0]], | ||
[Object.keys(cur)[0]]: cur[Object.keys(cur)[0]] | ||
}), | ||
{}); | ||
{} | ||
) | ||
|
||
if (!isCca2) { | ||
console.log(JSON.stringify(newcountries)); // eslint-disable-line | ||
console.log(JSON.stringify(newcountries)) | ||
} else { | ||
console.log(JSON.stringify(Object.keys(newcountries))); // eslint-disable-line | ||
console.log(JSON.stringify(Object.keys(newcountries))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.