countrynormalizer 0.0.1 β†’ 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,12 +34,13 @@ The guaranteed unique fields are:
34
34
  * `formal_order`: The naturally spoken order of a country's formal name from the ISO 3166 standard. For instance, the `english_clean` for the Netherlands is `Netherlands, Kingdom of the`, while the `formal_order` is `Kingdom of the Netherlands` β€” the way the country would be referenced in formal international or political conversation.
35
35
  * `common_reference`: Maps country names to how they would be referred to in normal casual conversation. So `Kingdom of the Netherlands` is just `Netherlands`. The `Holy See` is `Vatican City`. You can probably use common sense to arrive at most of these.
36
36
  * `flag_emoji`: The Unicode standard dictates that all ISO 3166 countries shall have an emoji flag. As such you can search the emoji of a flag as input and retrieve all data for that country.
37
+ * `tld (top-level domain)` - Searches for the countries top-level domain match.
37
38
 
38
39
  The returned country structure will match the `AllCountryFields` type and look like this...
39
40
 
40
41
  ```
41
42
  {
42
- common_reference: "United States of America",
43
+ common_reference: "United States",
43
44
  english_clean: "United States of America",
44
45
  formal_order: "United States of America",
45
46
  alpha_2: "US",
@@ -65,7 +66,7 @@ A common example of this is calling codes. Most of North America uses the `+1` c
65
66
 
66
67
  ```
67
68
  {
68
- "common_reference": "United States of America",
69
+ "common_reference": "United States",
69
70
  "english_clean": "United States of America",
70
71
  "formal_order": "United States of America",
71
72
  "alpha_2": "US",
@@ -82,7 +83,7 @@ A common example of this is calling codes. Most of North America uses the `+1` c
82
83
  "continent": "North America"
83
84
  },
84
85
  {
85
- "common_reference": "United States Minor Outlying Islands",
86
+ "common_reference": "US Territories",
86
87
  "english_clean": "United States Minor Outlying Islands",
87
88
  "formal_order": "United States Minor Outlying Islands",
88
89
  "alpha_2": "UM",
@@ -144,6 +145,82 @@ This function still supports singular lookup. Entering something like `findAllMa
144
145
 
145
146
  Entering a text value into this function that yields no results will return an empty (`[]`) array.
146
147
 
148
+ ### Get Countries Contact Fields:
149
+ It is common for applications to want to get the contact fields such as calling code blocks for the country, the flag of the country for visual identification, or top-level domains.
150
+
151
+ In order to keep a smaller object available to work with and for tree-shaking consumer facing apps you can call `getContactFieldsByAlpha2(alpha2: string): ContactCountryFields | null` in order to get a response object of only the countries contact fields.
152
+
153
+ ```
154
+ {
155
+ "tld": ".gn",
156
+ "flag_emoji": "πŸ‡¬πŸ‡³",
157
+ "calling_code": [
158
+ "224"
159
+ ]
160
+ }
161
+ ```
162
+
163
+ If the input does not match a valid ISO Alpha 2 value function returns `null`. The inputs ARE NOT keyed and open ended. Since this kind of data lookup is often times done based on open ended user input it is easier to simply check any string coming in and handle it vs making applications have to typecheck the input lookup.
164
+
165
+ ### Get All Countries For Continent:
166
+ In cases where you need to make a location selection you may want to query all countries located on a continent.
167
+
168
+ You can use `getCountriesByContinent(searchContinent: ContinentNames): ContinentTrimmedFields[]` function. This function requires a specifically matched enum input of continent names. It can be imported via `ContinentNames`.
169
+
170
+ This function returns a trimmed down set of country data for each country on the continent. You'll receive all the guaranteed unique identifier and display fields, with globally standardized contact data trimmed away. For example the response for Antarctica would look like this...
171
+
172
+ ```
173
+ [
174
+ {
175
+ "english_clean": "Antarctica",
176
+ "formal_order": "Antarctica",
177
+ "alpha_2": "AQ",
178
+ "alpha_3": "ATA",
179
+ "num_code": 10,
180
+ "tld": ".aq",
181
+ "flag_emoji": "πŸ‡¦πŸ‡Ά"
182
+ },
183
+ {
184
+ "english_clean": "Bouvet Island",
185
+ "formal_order": "Bouvet Island",
186
+ "alpha_2": "BV",
187
+ "alpha_3": "BVT",
188
+ "num_code": 74,
189
+ "tld": ".bv",
190
+ "flag_emoji": "πŸ‡§πŸ‡»"
191
+ },
192
+ {
193
+ "english_clean": "Heard Island and McDonald Islands",
194
+ "formal_order": "Heard Island and McDonald Islands",
195
+ "alpha_2": "HM",
196
+ "alpha_3": "HMD",
197
+ "num_code": 334,
198
+ "tld": ".hm",
199
+ "flag_emoji": "πŸ‡­πŸ‡²"
200
+ },
201
+ {
202
+ "english_clean": "South Georgia and the South Sandwich Islands",
203
+ "formal_order": "South Georgia and the South Sandwich Islands",
204
+ "alpha_2": "GS",
205
+ "alpha_3": "SGS",
206
+ "num_code": 239,
207
+ "tld": ".gs",
208
+ "flag_emoji": "πŸ‡¬πŸ‡Έ"
209
+ },
210
+ {
211
+ "english_clean": "Svalbard and Jan Mayen",
212
+ "formal_order": "Svalbard and Jan Mayen",
213
+ "alpha_2": "SJ",
214
+ "alpha_3": "SJM",
215
+ "num_code": 744,
216
+ "tld": ".sj",
217
+ "flag_emoji": "πŸ‡ΈπŸ‡―"
218
+ }
219
+ ]
220
+ ```
221
+
222
+ If you need absolutely all information about every country on a continent use the `findAllMatchedCountries()` function with a continent entered.
223
+
147
224
  ## To-Do List:
148
225
  This package was started as part of language classification and news analytics projects I'm working on in my personal time.
149
226
 
@@ -151,7 +228,7 @@ I've enjoyed building it out but wanted to publish something for starters so I d
151
228
 
152
229
  Over the next few weeks (hopefully) I plan to build out the following...
153
230
 
154
- * tld search support should be added to unique lookups since these are unique values.
231
+ * ~~tld search support should be added to unique lookups since these are unique values.~~
155
232
  * Optimize the search order of data when performing lookups.
156
233
  * Clean up some of the `common_reference` values. A lot of these are executive decisions I quickly made and could be better researched or refined.
157
234
  * Provide better documentation on the data sources for each of these fields to help assure people of data validity and no collisions of unique data points.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { findCountryByUnique, findAllMatchedCountries } from "./src/findCountryByUnqiue";
2
- import type { AllCountryFields } from "./types/core";
3
- export { findCountryByUnique, findAllMatchedCountries };
4
- export type { AllCountryFields };
2
+ import { getContactFieldsByAlpha2 } from "./src/getCountryContactData";
3
+ import { getCountriesByContinent } from "./src/getCountriesByContinent";
4
+ import type { AllCountryFields, ContactCountryFields, ContinentNames, ContinentTrimmedFields } from "./types/core";
5
+ export { findCountryByUnique, findAllMatchedCountries, getContactFieldsByAlpha2, getCountriesByContinent, };
6
+ export type { AllCountryFields, ContactCountryFields, ContinentNames, ContinentTrimmedFields, };