a tool for shared writing and social publishing
at update/reader 324 lines 9.2 kB view raw
1export const countryCodes: CountryData[] = [ 2 ["Afghanistan", "af", "93"], 3 ["Albania", "al", "355"], 4 ["Algeria", "dz", "213"], 5 ["Andorra", "ad", "376"], 6 ["Angola", "ao", "244"], 7 ["Antigua and Barbuda", "ag", "1268"], 8 ["Argentina", "ar", "54", "(..) ........", 0], 9 ["Armenia", "am", "374", ".. ......"], 10 ["Aruba", "aw", "297"], 11 [ 12 "Australia", 13 "au", 14 "61", 15 { 16 default: ". .... ....", 17 "/^4/": "... ... ...", 18 "/^5(?!50)/": "... ... ...", 19 "/^1(3|8)00/": ".... ... ...", 20 "/^13/": ".. .. ..", 21 "/^180/": "... ....", 22 }, 23 0, 24 [], 25 ], 26 ["Austria", "at", "43"], 27 ["Azerbaijan", "az", "994", "(..) ... .. .."], 28 ["Bahamas", "bs", "1242"], 29 ["Bahrain", "bh", "973"], 30 ["Bangladesh", "bd", "880"], 31 ["Barbados", "bb", "1246"], 32 ["Belarus", "by", "375", "(..) ... .. .."], 33 ["Belgium", "be", "32", "... .. .. .."], 34 ["Belize", "bz", "501"], 35 ["Benin", "bj", "229"], 36 ["Bhutan", "bt", "975"], 37 ["Bolivia", "bo", "591"], 38 ["Bosnia and Herzegovina", "ba", "387"], 39 ["Botswana", "bw", "267"], 40 ["Brazil", "br", "55", "(..) ........."], 41 ["British Indian Ocean Territory", "io", "246"], 42 ["Brunei", "bn", "673"], 43 ["Bulgaria", "bg", "359"], 44 ["Burkina Faso", "bf", "226"], 45 ["Burundi", "bi", "257"], 46 ["Cambodia", "kh", "855"], 47 ["Cameroon", "cm", "237"], 48 [ 49 "Canada", 50 "ca", 51 "1", 52 "(...) ...-....", 53 1, 54 [ 55 "204", 56 "226", 57 "236", 58 "249", 59 "250", 60 "289", 61 "306", 62 "343", 63 "365", 64 "387", 65 "403", 66 "416", 67 "418", 68 "431", 69 "437", 70 "438", 71 "450", 72 "506", 73 "514", 74 "519", 75 "548", 76 "579", 77 "581", 78 "587", 79 "604", 80 "613", 81 "639", 82 "647", 83 "672", 84 "705", 85 "709", 86 "742", 87 "778", 88 "780", 89 "782", 90 "807", 91 "819", 92 "825", 93 "867", 94 "873", 95 "902", 96 "905", 97 ], 98 ], 99 ["Cape Verde", "cv", "238"], 100 ["Caribbean Netherlands", "bq", "599", "", 1], 101 ["Cayman Islands", "ky", "1", "... ... ....", 4, ["345"]], 102 ["Central African Republic", "cf", "236"], 103 ["Chad", "td", "235"], 104 ["Chile", "cl", "56"], 105 ["China", "cn", "86", "... .... ...."], 106 ["Colombia", "co", "57", "... ... ...."], 107 ["Comoros", "km", "269"], 108 ["Congo", "cd", "243"], 109 ["Congo", "cg", "242"], 110 ["Costa Rica", "cr", "506", "....-...."], 111 ["Côte d'Ivoire", "ci", "225", ".. .. .. .. .."], 112 ["Croatia", "hr", "385"], 113 ["Cuba", "cu", "53"], 114 ["Curaçao", "cw", "599", "", 0], 115 ["Cyprus", "cy", "357", ".. ......"], 116 ["Czech Republic", "cz", "420", "... ... ..."], 117 ["Denmark", "dk", "45", ".. .. .. .."], 118 ["Djibouti", "dj", "253"], 119 ["Dominica", "dm", "1767"], 120 ["Dominican Republic", "do", "1", "(...) ...-....", 2, ["809", "829", "849"]], 121 ["Ecuador", "ec", "593"], 122 ["Egypt", "eg", "20"], 123 ["El Salvador", "sv", "503", "....-...."], 124 ["Equatorial Guinea", "gq", "240"], 125 ["Eritrea", "er", "291"], 126 ["Estonia", "ee", "372", ".... ......"], 127 ["Ethiopia", "et", "251"], 128 ["Fiji", "fj", "679"], 129 ["Finland", "fi", "358", ".. ... .. .."], 130 ["France", "fr", "33", ". .. .. .. .."], 131 ["French Guiana", "gf", "594"], 132 ["French Polynesia", "pf", "689"], 133 ["Gabon", "ga", "241"], 134 ["Gambia", "gm", "220"], 135 ["Georgia", "ge", "995"], 136 ["Germany", "de", "49", "... ........."], 137 ["Ghana", "gh", "233"], 138 ["Greece", "gr", "30"], 139 ["Greenland", "gl", "299", ".. .. .."], 140 ["Grenada", "gd", "1473"], 141 ["Guadeloupe", "gp", "590", "", 0], 142 ["Guam", "gu", "1671"], 143 ["Guatemala", "gt", "502", "....-...."], 144 ["Guinea", "gn", "224"], 145 ["Guinea-Bissau", "gw", "245"], 146 ["Guyana", "gy", "592"], 147 ["Haiti", "ht", "509", "....-...."], 148 ["Honduras", "hn", "504"], 149 ["Hong Kong", "hk", "852", ".... ...."], 150 ["Hungary", "hu", "36"], 151 ["Iceland", "is", "354", "... ...."], 152 ["India", "in", "91", ".....-....."], 153 ["Indonesia", "id", "62"], 154 ["Iran", "ir", "98", "... ... ...."], 155 ["Iraq", "iq", "964"], 156 ["Ireland", "ie", "353", ".. ......."], 157 ["Israel", "il", "972", "... ... ...."], 158 ["Italy", "it", "39", "... .......", 0], 159 ["Jamaica", "jm", "1876"], 160 ["Japan", "jp", "81", ".. .... ...."], 161 ["Jordan", "jo", "962"], 162 ["Kazakhstan", "kz", "7", "... ...-..-..", 0], 163 ["Kenya", "ke", "254"], 164 ["Kiribati", "ki", "686"], 165 ["Kosovo", "xk", "383"], 166 ["Kuwait", "kw", "965"], 167 ["Kyrgyzstan", "kg", "996", "... ... ..."], 168 ["Laos", "la", "856"], 169 ["Latvia", "lv", "371", ".. ... ..."], 170 ["Lebanon", "lb", "961"], 171 ["Lesotho", "ls", "266"], 172 ["Liberia", "lr", "231"], 173 ["Libya", "ly", "218"], 174 ["Liechtenstein", "li", "423"], 175 ["Lithuania", "lt", "370"], 176 ["Luxembourg", "lu", "352"], 177 ["Macau", "mo", "853"], 178 ["Macedonia", "mk", "389"], 179 ["Madagascar", "mg", "261"], 180 ["Malawi", "mw", "265"], 181 ["Malaysia", "my", "60", "..-....-...."], 182 ["Maldives", "mv", "960"], 183 ["Mali", "ml", "223"], 184 ["Malta", "mt", "356"], 185 ["Marshall Islands", "mh", "692"], 186 ["Martinique", "mq", "596"], 187 ["Mauritania", "mr", "222"], 188 ["Mauritius", "mu", "230"], 189 ["Mexico", "mx", "52", "... ... ....", 0], 190 ["Micronesia", "fm", "691"], 191 ["Moldova", "md", "373", "(..) ..-..-.."], 192 ["Monaco", "mc", "377"], 193 ["Mongolia", "mn", "976"], 194 ["Montenegro", "me", "382"], 195 ["Morocco", "ma", "212"], 196 ["Mozambique", "mz", "258"], 197 ["Myanmar", "mm", "95"], 198 ["Namibia", "na", "264"], 199 ["Nauru", "nr", "674"], 200 ["Nepal", "np", "977"], 201 [ 202 "Netherlands", 203 "nl", 204 "31", 205 { 206 "/^06/": "(.). .........", 207 "/^6/": ". .........", 208 "/^0(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/": 209 "(.).. ........", 210 "/^(10|13|14|15|20|23|24|26|30|33|35|36|38|40|43|44|45|46|50|53|55|58|70|71|72|73|74|75|76|77|78|79|82|84|85|87|88|91)/": 211 ".. ........", 212 "/^0/": "(.)... .......", 213 default: "... .......", 214 }, 215 ], 216 ["New Caledonia", "nc", "687"], 217 ["New Zealand", "nz", "64", "...-...-...."], 218 ["Nicaragua", "ni", "505"], 219 ["Niger", "ne", "227"], 220 ["Nigeria", "ng", "234"], 221 ["North Korea", "kp", "850"], 222 ["Norway", "no", "47", "... .. ..."], 223 ["Oman", "om", "968"], 224 ["Pakistan", "pk", "92", "...-......."], 225 ["Palau", "pw", "680"], 226 ["Palestine", "ps", "970"], 227 ["Panama", "pa", "507"], 228 ["Papua New Guinea", "pg", "675"], 229 ["Paraguay", "py", "595"], 230 ["Peru", "pe", "51"], 231 ["Philippines", "ph", "63", "... ... ...."], 232 ["Poland", "pl", "48", "...-...-..."], 233 ["Portugal", "pt", "351"], 234 ["Puerto Rico", "pr", "1", "(...) ...-....", 3, ["787", "939"]], 235 ["Qatar", "qa", "974"], 236 ["Réunion", "re", "262"], 237 ["Romania", "ro", "40"], 238 ["Russia", "ru", "7", "(...) ...-..-..", 1], 239 ["Rwanda", "rw", "250"], 240 ["Saint Kitts and Nevis", "kn", "1869"], 241 ["Saint Lucia", "lc", "1758"], 242 ["Saint Vincent and the Grenadines", "vc", "1784"], 243 ["Samoa", "ws", "685"], 244 ["San Marino", "sm", "378"], 245 ["São Tomé and Príncipe", "st", "239"], 246 ["Saudi Arabia", "sa", "966"], 247 ["Senegal", "sn", "221"], 248 ["Serbia", "rs", "381"], 249 ["Seychelles", "sc", "248"], 250 ["Sierra Leone", "sl", "232"], 251 ["Singapore", "sg", "65", "....-...."], 252 ["Slovakia", "sk", "421"], 253 ["Slovenia", "si", "386"], 254 ["Solomon Islands", "sb", "677"], 255 ["Somalia", "so", "252"], 256 ["South Africa", "za", "27"], 257 ["South Korea", "kr", "82", "... .... ...."], 258 ["South Sudan", "ss", "211"], 259 ["Spain", "es", "34", "... ... ..."], 260 ["Sri Lanka", "lk", "94"], 261 ["Sudan", "sd", "249"], 262 ["Suriname", "sr", "597"], 263 ["Swaziland", "sz", "268"], 264 ["Sweden", "se", "46", "... ... ..."], 265 ["Switzerland", "ch", "41", ".. ... .. .."], 266 ["Syria", "sy", "963"], 267 ["Taiwan", "tw", "886"], 268 ["Tajikistan", "tj", "992"], 269 ["Tanzania", "tz", "255"], 270 ["Thailand", "th", "66"], 271 ["Timor-Leste", "tl", "670"], 272 ["Togo", "tg", "228"], 273 ["Tonga", "to", "676"], 274 ["Trinidad and Tobago", "tt", "1868"], 275 ["Tunisia", "tn", "216"], 276 ["Turkey", "tr", "90", "... ... .. .."], 277 ["Turkmenistan", "tm", "993"], 278 ["Tuvalu", "tv", "688"], 279 ["Uganda", "ug", "256"], 280 ["Ukraine", "ua", "380", "(..) ... .. .."], 281 ["United Arab Emirates", "ae", "971"], 282 ["United Kingdom", "gb", "44", ".... ......"], 283 ["United States", "us", "1", "(...) ...-....", 0], 284 ["Uruguay", "uy", "598"], 285 ["Uzbekistan", "uz", "998", ".. ... .. .."], 286 ["Vanuatu", "vu", "678"], 287 ["Vatican City", "va", "39", ".. .... ....", 1], 288 ["Venezuela", "ve", "58"], 289 ["Vietnam", "vn", "84"], 290 ["Yemen", "ye", "967"], 291 ["Zambia", "zm", "260"], 292 ["Zimbabwe", "zw", "263"], 293]; 294 295type BaseCountryData = [ 296 string, // country name 297 string, // iso2 code 298 string, // international dial code 299]; 300 301type FormatConfig = Record<string, string> & { 302 default: string; // can pass any string, but "default" key is required 303}; 304 305type CountryDataWithFormat = [ 306 ...BaseCountryData, 307 FormatConfig | string, // format 308]; 309 310type CountryDataWithOrder = [ 311 ...CountryDataWithFormat, 312 number, // order priority 313]; 314 315type CountryDataAreaCodes = [ 316 ...CountryDataWithOrder, 317 string[], // area codes 318]; 319 320export type CountryData = 321 | BaseCountryData 322 | CountryDataWithFormat 323 | CountryDataWithOrder 324 | CountryDataAreaCodes;