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.
@@ -10,6 +10,7 @@ import type { AllCountryFields } from "../types/core";
10
10
  * - `formal_order` — naturally spoken order of the formal country name
11
11
  * - `flag_emoji` — Unicode flag emoji for the country
12
12
  * - `common_reference` — casual/colloquial country name
13
+ * - `tld (top-level domain)` - Searches for the countries top-level domain match.
13
14
  *
14
15
  * This will **not** search non-unique fields like calling codes, continents, or demonyms.
15
16
  * Use {@link findAllMatchedCountries} for those lookups.
@@ -0,0 +1,16 @@
1
+ import type { ContinentNames, ContinentTrimmedFields } from "../types/core";
2
+ /**
3
+ * Returns a trimmed set of country data for every country on the specified continent.
4
+ *
5
+ * The returned fields include the guaranteed unique identifier and display fields,
6
+ * with calling codes, demonyms, and other contact fields omitted.
7
+ * Use {@link findAllMatchedCountries} with a continent name if you need full country data for each entry.
8
+ *
9
+ * @param searchContinent - A continent name from the {@link ContinentNames} enum.
10
+ * @returns An array of trimmed country data for all countries on the given continent.
11
+ *
12
+ * @example
13
+ * getCountriesByContinent(ContinentNames.Antarctica); // Returns trimmed data for all Antarctic territories
14
+ * getCountriesByContinent(ContinentNames.Asia); // Returns trimmed data for all Asian countries
15
+ */
16
+ export declare const getCountriesByContinent: (searchContinent: ContinentNames) => ContinentTrimmedFields[];
@@ -0,0 +1,16 @@
1
+ import type { ContactCountryFields } from "../types/core";
2
+ /**
3
+ * Returns the contact fields — calling code(s), flag emoji, and top-level domain — for a country
4
+ * identified by its ISO 3166-1 alpha-2 code.
5
+ *
6
+ * Since contact field lookups are commonly performed on open-ended user input, the input
7
+ * is matched case-insensitively. If the input is not exactly 2 characters, `null` is returned.
8
+ *
9
+ * @param inputAlpha2 - A 2-character ISO 3166-1 alpha-2 country code (e.g. `"US"`, `"GB"`).
10
+ * @returns The contact fields for the matching country, or `null` if no match is found.
11
+ *
12
+ * @example
13
+ * getContactFieldsByAlpha2("GN"); // Returns { tld: ".gn", flag_emoji: "🇬🇳", calling_code: ["224"] }
14
+ * getContactFieldsByAlpha2("XX"); // Returns null
15
+ */
16
+ export declare const getContactFieldsByAlpha2: (inputAlpha2: string) => ContactCountryFields | null;
@@ -14,4 +14,14 @@ export interface AllCountryFields {
14
14
  continent: string;
15
15
  }
16
16
  export type ContactCountryFields = Pick<AllCountryFields, "tld" | "flag_emoji" | "calling_code">;
17
- export type UniqueCountryFields = Pick<AllCountryFields, "english_clean" | "formal_order" | "alpha_2" | "alpha_3" | "num_code">;
17
+ export declare enum ContinentNames {
18
+ NorthAmerica = "north_america",
19
+ Asia = "asia",
20
+ Africa = "africa",
21
+ Europe = "europe",
22
+ SouthAmerica = "south_america",
23
+ Oceania = "oceania",
24
+ Antarctica = "antarctica"
25
+ }
26
+ export type ContinentTrimmedFields = Pick<AllCountryFields, "english_clean" | "formal_order" | "alpha_2" | "alpha_3" | "num_code" | "tld" | "flag_emoji">;
27
+ export type CountriesByContinent = Record<ContinentNames, ContinentTrimmedFields[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "countrynormalizer",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",