country-code-kit 1.0.1 → 1.0.4

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.
Files changed (2) hide show
  1. package/README.md +38 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # country-kit
2
2
 
3
- Zero-dependency TypeScript package with all **249 ISO 3166-1 countries** — alpha-2 code, English name, and flag emoji — plus fast lookup and search helpers. Ships dual ESM + CJS builds with full type declarations. Works in Node and browsers, tree-shakeable, ~10 KB.
3
+ Zero-dependency TypeScript package with all **249 ISO 3166-1 countries** — alpha-2 code, English name, flag emoji, and ITU dial code — plus fast lookup and search helpers. Ships dual ESM + CJS builds with full type declarations. Works in Node and browsers, tree-shakeable, ~10 KB.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm install country-kit
8
+ npm i country-code-kit
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -18,27 +18,34 @@ import {
18
18
  getCountryByFlag,
19
19
  getFlag,
20
20
  getName,
21
+ getDialCode,
22
+ getCountriesByDialCode,
21
23
  isValidCode,
22
24
  searchCountries,
23
25
  codeToFlag,
24
26
  flagToCode,
25
27
  } from "country-kit";
26
28
 
27
- countries.length; // 249
28
- getCountryByCode("in"); // { code: "IN", name: "India", flag: "🇮🇳" }
29
- getCountryByName("Japan"); // { code: "JP", name: "Japan", flag: "🇯🇵" }
30
- getCountryByFlag("🇩🇪"); // { code: "DE", name: "Germany", flag: "🇩🇪" }
29
+ countries.length; // 249
30
+ getCountryByCode("in"); // { code: "IN", name: "India", flag: "🇮🇳", dialCode: "+91" }
31
+ getCountryByName("Japan"); // { code: "JP", name: "Japan", flag: "🇯🇵", dialCode: "+81" }
32
+ getCountryByFlag("🇩🇪"); // { code: "DE", name: "Germany", flag: "🇩🇪", dialCode: "+49" }
31
33
 
32
- getFlag("BD"); // "🇧🇩"
33
- getName("FR"); // "France"
34
- isValidCode("zz"); // false
34
+ getFlag("BD"); // "🇧🇩"
35
+ getName("FR"); // "France"
36
+ getDialCode("BD"); // "+880"
37
+ getDialCode("AQ"); // null (territory with no assigned dial code)
38
+ isValidCode("zz"); // false
39
+
40
+ getCountriesByDialCode("+1");
41
+ // [{ code: "US", ... }, { code: "CA", ... }, ...] — all territories sharing +1
35
42
 
36
43
  searchCountries("uni");
37
44
  // [United Arab Emirates, United Kingdom, United States, ...]
38
45
  // ranked: exact match → prefix match → substring match
39
46
 
40
- codeToFlag("NP"); // "🇳🇵" (no lookup table needed)
41
- flagToCode("🇳🇵"); // "NP"
47
+ codeToFlag("NP"); // "🇳🇵" (no lookup table needed)
48
+ flagToCode("🇳🇵"); // "NP"
42
49
  ```
43
50
 
44
51
  CommonJS works too:
@@ -49,27 +56,31 @@ const { getName } = require("country-kit");
49
56
 
50
57
  ## API
51
58
 
52
- | Function | Returns |
53
- |---|---|
54
- | `countries` | `readonly Country[]` — all 249 entries |
55
- | `getCountryByCode(code)` | `Country \| undefined` (case-insensitive) |
56
- | `getCountryByName(name)` | `Country \| undefined` (case-insensitive) |
57
- | `getCountryByFlag(flag)` | `Country \| undefined` |
58
- | `getFlag(code)` / `getName(code)` | `string \| undefined` |
59
- | `isValidCode(code)` | `boolean` |
60
- | `searchCountries(query)` | `Country[]` ranked by match quality |
61
- | `codeToFlag(code)` | `string` (throws on invalid input) |
62
- | `flagToCode(flag)` | `string \| undefined` |
59
+
60
+ | Function | Returns |
61
+ | ---------------------------------- | ---------------------------------------------------------------------- |
62
+ | `countries` | `readonly Country[]` all 249 entries |
63
+ | `getCountryByCode(code)` | `Country | undefined` (case-insensitive) |
64
+ | `getCountryByName(name)` | `Country | undefined` (case-insensitive) |
65
+ | `getCountryByFlag(flag)` | `Country | undefined` |
66
+ | `getFlag(code)` / `getName(code)` | `string | undefined` |
67
+ | `getDialCode(code)` | `string | null | undefined``null` for territories with no dial code |
68
+ | `getCountriesByDialCode(dialCode)` | `Country[]` all countries sharing a dial code (e.g. `"+1"`) |
69
+ | `isValidCode(code)` | `boolean` |
70
+ | `searchCountries(query)` | `Country[]` ranked by match quality |
71
+ | `codeToFlag(code)` | `string` (throws on invalid input) |
72
+ | `flagToCode(flag)` | `string | undefined` |
73
+
63
74
 
64
75
  ```ts
65
76
  interface Country {
66
- code: string; // ISO 3166-1 alpha-2, e.g. "IN"
67
- name: string; // English short name, e.g. "India"
68
- flag: string; // Flag emoji, e.g. "🇮🇳"
77
+ code: string; // ISO 3166-1 alpha-2, e.g. "IN"
78
+ name: string; // English short name, e.g. "India"
79
+ flag: string; // Flag emoji, e.g. "🇮🇳"
80
+ dialCode: string | null; // ITU calling code incl. "+", e.g. "+880". Null for territories with no assigned code.
69
81
  }
70
82
  ```
71
83
 
72
-
73
84
  ## License
74
85
 
75
- MIT
86
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "country-code-kit",
3
- "version": "1.0.1",
3
+ "version": "v1.0.4",
4
4
  "description": "Zero-dependency list of all 249 ISO 3166-1 countries with code, name, and flag emoji. Lookup and search helpers included. Tree-shakeable, works in Node and browsers.",
5
5
  "keywords": [
6
6
  "country",