national-metadata 0.1.0

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) 2025 Expatria, Inc
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 ADDED
@@ -0,0 +1,261 @@
1
+ # 🌍 Jiang Hu
2
+
3
+ The internet's most helpful npm package for comprehensive country data, including utility functions to help work with ISO codes, names, continents, and mercator coordinates.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install jiang-hu
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { helloWorld, getCountryNameFromCode, convertTwoToThree } from 'jiang-hu';
15
+
16
+ // Hello World function
17
+ console.log(helloWorld()); // "Mr World Wide is here"
18
+
19
+ // Convert ISO codes
20
+ console.log(getCountryNameFromCode('US')); // "United States"
21
+ console.log(convertTwoToThree('US')); // "USA"
22
+ ```
23
+
24
+ ## API Reference
25
+
26
+ ### Hello World Function
27
+
28
+ ```typescript
29
+ helloWorld(): string
30
+ ```
31
+ Returns the signature greeting: "Mr World Wide is here"
32
+
33
+ ### Country Code Conversion
34
+
35
+ #### `convertTwoToThree(twoDigitCode: string): string | undefined`
36
+ Converts 2-digit ISO country codes to 3-digit codes.
37
+
38
+ ```typescript
39
+ convertTwoToThree('US'); // "USA"
40
+ convertTwoToThree('GB'); // "GBR"
41
+ convertTwoToThree('DE'); // "DEU"
42
+ ```
43
+
44
+ #### `convertThreeToTwo(threeDigitCode: string): string | undefined`
45
+ Converts 3-digit ISO country codes to 2-digit codes.
46
+
47
+ ```typescript
48
+ convertThreeToTwo('USA'); // "US"
49
+ convertThreeToTwo('GBR'); // "GB"
50
+ convertThreeToTwo('DEU'); // "DE"
51
+ ```
52
+
53
+ ### Country Name Functions
54
+
55
+ #### `getCountryNameFromCode(code: string): string | undefined`
56
+ Gets country name from 2-digit ISO code.
57
+
58
+ ```typescript
59
+ getCountryNameFromCode('US'); // "United States"
60
+ getCountryNameFromCode('FR'); // "France"
61
+ getCountryNameFromCode('JP'); // "Japan"
62
+ ```
63
+
64
+ #### `getCountryCodeFromName(countryName: string): string | undefined`
65
+ Gets 2-digit ISO code from country name.
66
+
67
+ ```typescript
68
+ getCountryCodeFromName('United States'); // "US"
69
+ getCountryCodeFromName('France'); // "FR"
70
+ getCountryCodeFromName('Japan'); // "JP"
71
+ ```
72
+
73
+ ### Geographic Data
74
+
75
+ #### `getMercatorCoordinates(threeDigitCode: string): [number, number] | undefined`
76
+ Gets mercator coordinates [longitude, latitude] for a country.
77
+
78
+ ```typescript
79
+ getMercatorCoordinates('USA'); // [-95.71, 37.09]
80
+ getMercatorCoordinates('GBR'); // [-3.48, 52.35]
81
+ getMercatorCoordinates('JPN'); // [139.75, 35.68]
82
+ ```
83
+
84
+ #### `getCountrySizeScale(threeDigitCode: string): number | undefined`
85
+ Gets the size scale factor for map visualization.
86
+
87
+ ```typescript
88
+ getCountrySizeScale('USA'); // 300
89
+ getCountrySizeScale('GBR'); // 800
90
+ getCountrySizeScale('MCO'); // 2500 (Monaco - smaller countries have higher scale)
91
+ ```
92
+
93
+ ## Data Exports
94
+
95
+ ### Raw Data Objects
96
+
97
+ ```typescript
98
+ import {
99
+ code_to_country,
100
+ country_to_code,
101
+ list_of_countries,
102
+ country_name_strings,
103
+ mercator_hash,
104
+ countrySizeScales,
105
+ twoToThree,
106
+ threeToTwo
107
+ } from 'jiang-hu';
108
+ ```
109
+
110
+ #### `code_to_country`
111
+ Object mapping 2-digit ISO codes to country names.
112
+
113
+ ```typescript
114
+ code_to_country['US']; // "United States"
115
+ code_to_country['GB']; // "United Kingdom"
116
+ ```
117
+
118
+ #### `country_to_code`
119
+ Object mapping country names to 2-digit ISO codes.
120
+
121
+ ```typescript
122
+ country_to_code['United States']; // "US"
123
+ country_to_code['United Kingdom']; // "UK"
124
+ ```
125
+
126
+ #### `list_of_countries`
127
+ Array of country objects with ISO code, name, and continent.
128
+
129
+ ```typescript
130
+ // Returns array of objects like:
131
+ {
132
+ iso_two: "US",
133
+ name: "United States of America",
134
+ continent: "North America"
135
+ }
136
+ ```
137
+
138
+ #### `country_name_strings`
139
+ Simple array of country names.
140
+
141
+ ```typescript
142
+ // ["United States", "Afghanistan", "Albania", ...]
143
+ ```
144
+
145
+ #### `mercator_hash`
146
+ Object mapping 3-digit ISO codes to [longitude, latitude] coordinates.
147
+
148
+ ```typescript
149
+ mercator_hash['USA']; // [-95.71, 37.09]
150
+ ```
151
+
152
+ #### `countrySizeScales`
153
+ Object mapping 3-digit ISO codes to size scale factors for visualization.
154
+
155
+ ```typescript
156
+ countrySizeScales['USA']; // 300
157
+ ```
158
+
159
+ ## TypeScript Support
160
+
161
+ Full TypeScript support with exported types:
162
+
163
+ ```typescript
164
+ import type {
165
+ Country,
166
+ CountryMapping,
167
+ MercatorCoordinate,
168
+ CountryCode,
169
+ CountryName,
170
+ ThreeDigitCode,
171
+ TwoDigitCode
172
+ } from 'jiang-hu';
173
+
174
+ // Country interface
175
+ interface Country {
176
+ iso_two: string;
177
+ name: string;
178
+ continent: string;
179
+ }
180
+
181
+ // Type-safe country codes
182
+ type CountryCode = keyof typeof code_to_country;
183
+ type CountryName = keyof typeof country_to_code;
184
+ ```
185
+
186
+ ## Use Cases
187
+
188
+ - **Geographic Applications**: Use mercator coordinates for map plotting
189
+ - **Form Validation**: Validate country codes and names
190
+ - **Data Normalization**: Convert between different ISO code formats
191
+ - **Analytics**: Group data by continent using the country list
192
+ - **Internationalization**: Display localized country names
193
+
194
+ ## Examples
195
+
196
+ ### Building a Country Selector
197
+
198
+ ```typescript
199
+ import { list_of_countries, getCountryCodeFromName } from 'jiang-hu';
200
+
201
+ // Create dropdown options
202
+ const countryOptions = list_of_countries.map(country => ({
203
+ value: country.iso_two,
204
+ label: country.name,
205
+ continent: country.continent
206
+ }));
207
+
208
+ // Group by continent
209
+ const continentGroups = countryOptions.reduce((groups, country) => {
210
+ const continent = country.continent;
211
+ if (!groups[continent]) groups[continent] = [];
212
+ groups[continent].push(country);
213
+ return groups;
214
+ }, {} as Record<string, typeof countryOptions>);
215
+ ```
216
+
217
+ ### Map Visualization
218
+
219
+ ```typescript
220
+ import { mercator_hash, countrySizeScales } from 'jiang-hu';
221
+
222
+ // Plot countries on a map
223
+ Object.entries(mercator_hash).forEach(([code, [lng, lat]]) => {
224
+ const scale = countrySizeScales[code] || 1000;
225
+ plotCountryOnMap(code, lng, lat, scale);
226
+ });
227
+ ```
228
+
229
+ ### Data Validation
230
+
231
+ ```typescript
232
+ import { convertTwoToThree, getCountryNameFromCode } from 'jiang-hu';
233
+
234
+ function validateCountryCode(code: string): boolean {
235
+ return getCountryNameFromCode(code) !== undefined;
236
+ }
237
+
238
+ function normalizeCountryCode(code: string): string | null {
239
+ if (code.length === 2) {
240
+ return convertTwoToThree(code) || null;
241
+ }
242
+ return code.length === 3 ? code : null;
243
+ }
244
+ ```
245
+
246
+ ## Contributing
247
+
248
+ We welcome contributions! Please see our contributing guidelines for more details.
249
+
250
+ ## License
251
+
252
+ MIT License - see LICENSE file for details.
253
+
254
+ ## Changelog
255
+
256
+ ### v1.0.0
257
+ - Initial release with comprehensive country data
258
+ - ISO code conversion utilities
259
+ - Mercator coordinates for map visualization
260
+ - Full TypeScript support
261
+ - Hello World function: "Mr World Wide is here"
@@ -0,0 +1,225 @@
1
+ export declare const code_to_country: {
2
+ AF: string;
3
+ AL: string;
4
+ DZ: string;
5
+ AD: string;
6
+ AO: string;
7
+ AQ: string;
8
+ AG: string;
9
+ AR: string;
10
+ AM: string;
11
+ AW: string;
12
+ AU: string;
13
+ AT: string;
14
+ AZ: string;
15
+ BS: string;
16
+ BH: string;
17
+ BD: string;
18
+ BB: string;
19
+ BY: string;
20
+ BE: string;
21
+ GD: string;
22
+ BJ: string;
23
+ BM: string;
24
+ BT: string;
25
+ BO: string;
26
+ BQ: string;
27
+ BA: string;
28
+ BW: string;
29
+ BR: string;
30
+ BN: string;
31
+ BG: string;
32
+ BI: string;
33
+ BF: string;
34
+ CV: string;
35
+ KH: string;
36
+ CM: string;
37
+ CA: string;
38
+ KY: string;
39
+ CF: string;
40
+ TD: string;
41
+ CL: string;
42
+ CN: string;
43
+ CO: string;
44
+ KM: string;
45
+ CK: string;
46
+ CG: string;
47
+ CD: string;
48
+ CR: string;
49
+ HR: string;
50
+ CU: string;
51
+ CW: string;
52
+ CY: string;
53
+ CZ: string;
54
+ DK: string;
55
+ DJ: string;
56
+ DM: string;
57
+ DO: string;
58
+ EC: string;
59
+ EG: string;
60
+ SV: string;
61
+ GW: string;
62
+ GQ: string;
63
+ ER: string;
64
+ SZ: string;
65
+ EE: string;
66
+ ET: string;
67
+ FK: string;
68
+ FM: string;
69
+ FJ: string;
70
+ FI: string;
71
+ FR: string;
72
+ GF: string;
73
+ GA: string;
74
+ GM: string;
75
+ GE: string;
76
+ DE: string;
77
+ GH: string;
78
+ GI: string;
79
+ GR: string;
80
+ GL: string;
81
+ GU: string;
82
+ GP: string;
83
+ GT: string;
84
+ GG: string;
85
+ GN: string;
86
+ GY: string;
87
+ HT: string;
88
+ HN: string;
89
+ HK: string;
90
+ HU: string;
91
+ IS: string;
92
+ IN: string;
93
+ ID: string;
94
+ IR: string;
95
+ IQ: string;
96
+ IE: string;
97
+ IM: string;
98
+ IL: string;
99
+ IT: string;
100
+ CI: string;
101
+ JM: string;
102
+ JP: string;
103
+ JE: string;
104
+ JO: string;
105
+ KZ: string;
106
+ KE: string;
107
+ KI: string;
108
+ KR: string;
109
+ KP: string;
110
+ XK: string;
111
+ KW: string;
112
+ KG: string;
113
+ LA: string;
114
+ LV: string;
115
+ LB: string;
116
+ LR: string;
117
+ LY: string;
118
+ LS: string;
119
+ LI: string;
120
+ LT: string;
121
+ LU: string;
122
+ MH: string;
123
+ MO: string;
124
+ MG: string;
125
+ MW: string;
126
+ MY: string;
127
+ MV: string;
128
+ ML: string;
129
+ MT: string;
130
+ MR: string;
131
+ MU: string;
132
+ MX: string;
133
+ MD: string;
134
+ MC: string;
135
+ MN: string;
136
+ ME: string;
137
+ MA: string;
138
+ MZ: string;
139
+ MM: string;
140
+ NA: string;
141
+ NR: string;
142
+ NL: string;
143
+ NP: string;
144
+ NC: string;
145
+ NZ: string;
146
+ NI: string;
147
+ NE: string;
148
+ NG: string;
149
+ MK: string;
150
+ NO: string;
151
+ OM: string;
152
+ PK: string;
153
+ PW: string;
154
+ PS: string;
155
+ PA: string;
156
+ PG: string;
157
+ PY: string;
158
+ PE: string;
159
+ PH: string;
160
+ PL: string;
161
+ PT: string;
162
+ PR: string;
163
+ QA: string;
164
+ RO: string;
165
+ RU: string;
166
+ RW: string;
167
+ SH: string;
168
+ KN: string;
169
+ LC: string;
170
+ VC: string;
171
+ WS: string;
172
+ SM: string;
173
+ ST: string;
174
+ SA: string;
175
+ SN: string;
176
+ RS: string;
177
+ SC: string;
178
+ SL: string;
179
+ SG: string;
180
+ SX: string;
181
+ SK: string;
182
+ SI: string;
183
+ SB: string;
184
+ SO: string;
185
+ ZA: string;
186
+ GS: string;
187
+ SS: string;
188
+ ES: string;
189
+ LK: string;
190
+ SD: string;
191
+ SR: string;
192
+ SE: string;
193
+ CH: string;
194
+ SY: string;
195
+ TW: string;
196
+ TJ: string;
197
+ TZ: string;
198
+ TH: string;
199
+ TL: string;
200
+ TG: string;
201
+ TO: string;
202
+ TT: string;
203
+ TN: string;
204
+ TR: string;
205
+ TM: string;
206
+ TV: string;
207
+ UG: string;
208
+ UA: string;
209
+ AE: string;
210
+ UK: string;
211
+ US: string;
212
+ UY: string;
213
+ UZ: string;
214
+ VU: string;
215
+ VA: string;
216
+ VE: string;
217
+ VN: string;
218
+ VI: string;
219
+ VG: string;
220
+ EH: string;
221
+ YE: string;
222
+ ZM: string;
223
+ ZW: string;
224
+ };
225
+ //# sourceMappingURL=code-to-country.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-to-country.d.ts","sourceRoot":"","sources":["../src/code-to-country.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+NzB,CAAC"}