country-code-kit 1.0.0 → 1.0.2

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) 2026 Shrikanta Mazumder
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,6 +1,6 @@
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
 
@@ -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:
@@ -56,6 +63,8 @@ const { getName } = require("country-kit");
56
63
  | `getCountryByName(name)` | `Country \| undefined` (case-insensitive) |
57
64
  | `getCountryByFlag(flag)` | `Country \| undefined` |
58
65
  | `getFlag(code)` / `getName(code)` | `string \| undefined` |
66
+ | `getDialCode(code)` | `string \| null \| undefined` — `null` for territories with no dial code |
67
+ | `getCountriesByDialCode(dialCode)` | `Country[]` — all countries sharing a dial code (e.g. `"+1"`) |
59
68
  | `isValidCode(code)` | `boolean` |
60
69
  | `searchCountries(query)` | `Country[]` ranked by match quality |
61
70
  | `codeToFlag(code)` | `string` (throws on invalid input) |
@@ -63,24 +72,13 @@ const { getName } = require("country-kit");
63
72
 
64
73
  ```ts
65
74
  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. "🇮🇳"
75
+ code: string; // ISO 3166-1 alpha-2, e.g. "IN"
76
+ name: string; // English short name, e.g. "India"
77
+ flag: string; // Flag emoji, e.g. "🇮🇳"
78
+ dialCode: string | null; // ITU calling code incl. "+", e.g. "+880". Null for territories with no assigned code.
69
79
  }
70
80
  ```
71
81
 
72
- ## Scripts
73
-
74
- ```bash
75
- npm run build # compile ESM + CJS to dist/
76
- npm test # run Node's built-in test runner
77
- ```
78
-
79
- ## Publishing
80
-
81
- 1. Pick a unique name in `package.json` (check `npm view <name>` first — `country-kit` may be taken).
82
- 2. `npm login`
83
- 3. `npm publish` (runs build + tests automatically via `prepublishOnly`)
84
82
 
85
83
  ## License
86
84