countrynormalizer 0.1.1 → 0.2.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 JackMcE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,23 @@
1
1
  # 🌎 Country Data Lookup And Normalizer 🌍
2
2
 
3
+ [![CI](https://github.com/JackMcE/CountryNormalizer/actions/workflows/ci.yml/badge.svg)](https://github.com/JackMcE/CountryNormalizer/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/countrynormalizer.svg)](https://www.npmjs.com/package/countrynormalizer)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![Coverage](https://codecov.io/gh/JackMcE/CountryNormalizer/branch/main/graph/badge.svg)](https://codecov.io/gh/JackMcE/CountryNormalizer)
7
+ [![npm downloads](https://img.shields.io/npm/dm/countrynormalizer.svg)](https://www.npmjs.com/package/countrynormalizer)
8
+
3
9
  A simple library for consolidation and reverse lookup of common ISO country data fields and calling codes all in one place.
4
10
 
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install countrynormalizer
15
+ ```
16
+
17
+ ```bash
18
+ bun add countrynormalizer
19
+ ```
20
+
5
21
  Developers routinely need to mix and match pieces of country data across an application.
6
22
 
7
23
  Some common examples are:
@@ -221,6 +237,34 @@ This function returns a trimmed down set of country data for each country on the
221
237
 
222
238
  If you need absolutely all information about every country on a continent use the `findAllMatchedCountries()` function with a continent entered.
223
239
 
240
+ ### List All Countries:
241
+
242
+ You can call `getAllCountries()` to return the complete countries data set. The response is properly typed so it should be decently easy to work with.
243
+
244
+ This is a massive array of objects for every country on Earth contained in the ISO 3166 list.
245
+
246
+ This may be helpful for understanding the data shapes, visualizing all the data, or shaping information in ways the package functions/APIs do not support natively.
247
+
248
+ ## Data Sources:
249
+ This data is compiled from a wide array of sources. To give transparency to this I want to document the primary source or reason for each field.
250
+
251
+ * common_reference: This is a field made up by me as the publisher. This is how people might "commonly refer to a country" in conversation. The full name of Iran formally is "Iran, Islamic Republic of" but most people just say "Iran." That is the idea behind this field. Easily lookup how most English speakers would refer to a country.
252
+ * english_clean: This comes off of the "country name using title case" column on the wikipedia Alpha 2 documentation for ISO 3166: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
253
+ * formal_order: On Wikipedia and other sources for easy Alpabetization they order countries by common names. So "Netherlands, Kingdom of the", this just puts it in order as "Kingdom of the Netherlands."
254
+ * alpha_2: ISO 3166 Alpha 2 values as listed on wikipedia: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
255
+ * alpha_3: Taken from Wikipedia ISO 3166 master table: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
256
+ * num_code: Taken from Wikipedia ISO 3166 master table: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
257
+ * demonym_male: ChatGTP deep research compiled CSV dataset asking it to align ISO Alpha 3 codes to demonym by country for both male and female.
258
+ * demonym_female: ChatGTP deep research compiled CSV dataset asking it to align ISO Alpha 3 codes to demonym by country for both male and female.
259
+ * gendered_demonym: Manual alignment in Google Sheet by me comparing `demonym_male` and `demonym_male` for string differences and setting a boolean.
260
+ * tld: Taken from Wikipedia ISO 3166 master table: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
261
+ * flag_emoji: Used table available on Flagepedia and then cleaned up the data for easy usage in CSVs and JSON objects: https://flagpedia.net/emoji
262
+ * calling_code: ChatGPT compiled deep research task. Instructed to rely primarily on these data sources to make data easily worked with in a CSV and as JSON objects.
263
+ * * https://en.wikipedia.org/wiki/Trunk_prefix
264
+ * * https://en.wikipedia.org/wiki/List_of_telephone_country_codes
265
+ * * https://www.countrycode.org/
266
+ * continent: ChatGPT deep research compiled list asking to align all ISO Alpha 3 country codes to their continent.
267
+
224
268
  ## To-Do List:
225
269
  This package was started as part of language classification and news analytics projects I'm working on in my personal time.
226
270
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { findCountryByUnique, findAllMatchedCountries } from "./src/findCountryByUnqiue";
2
2
  import { getContactFieldsByAlpha2 } from "./src/getCountryContactData";
3
3
  import { getCountriesByContinent } from "./src/getCountriesByContinent";
4
+ import { getAllCountries } from "./src/getAllCountries";
4
5
  import type { AllCountryFields, ContactCountryFields, ContinentNames, ContinentTrimmedFields } from "./types/core";
5
- export { findCountryByUnique, findAllMatchedCountries, getContactFieldsByAlpha2, getCountriesByContinent, };
6
+ export { findCountryByUnique, findAllMatchedCountries, getContactFieldsByAlpha2, getCountriesByContinent, getAllCountries, };
6
7
  export type { AllCountryFields, ContactCountryFields, ContinentNames, ContinentTrimmedFields, };