@koshmoney/countries 1.0.1-beta.3 → 1.0.1-beta.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 +47 -8
  2. package/package.json +29 -1
package/README.md CHANGED
@@ -36,8 +36,27 @@ yarn add @koshmoney/countries
36
36
  pnpm add @koshmoney/countries
37
37
  ```
38
38
 
39
+ ### TypeScript Configuration
40
+
41
+ Subpath imports work automatically with modern TypeScript settings (`moduleResolution: "node16"`, `"nodenext"`, or `"bundler"`).
42
+
43
+ For older configurations (`moduleResolution: "node"`), the library includes `typesVersions` fallback, so no additional configuration is needed.
44
+
45
+ ## Module Types
46
+
47
+ This library separates modules for optimal bundle size:
48
+
49
+ | Type | Modules | Import Path |
50
+ |------|---------|-------------|
51
+ | **Core** | `country`, `subdivision`, `postalCode` | `@koshmoney/countries` |
52
+ | **Specialized** | `currency`, `dialCode`, `geography`, `membership` | `@koshmoney/countries/{module}` |
53
+
54
+ **Core modules** are included in the main bundle. **Specialized modules** require subpath imports to keep your bundle small.
55
+
39
56
  ## Quick Start
40
57
 
58
+ ### Core Modules
59
+
41
60
  ```typescript
42
61
  import { country, subdivision, postalCode } from '@koshmoney/countries';
43
62
 
@@ -66,7 +85,11 @@ postalCode.isValid('US', '90210'); // true
66
85
  postalCode.isValid('GB', 'SW1A 1AA'); // true
67
86
  postalCode.getName('US'); // 'ZIP Code'
68
87
  postalCode.getName('IN'); // 'PIN Code'
88
+ ```
89
+
90
+ ### Specialized Modules (subpath imports)
69
91
 
92
+ ```typescript
70
93
  // Currency data
71
94
  import { currency } from '@koshmoney/countries/currency';
72
95
  currency.getCurrency('US');
@@ -214,9 +237,14 @@ currency.getCurrencyCode('DE'); // 'EUR'
214
237
  currency.getCurrencySymbol('IN'); // '₹'
215
238
  currency.getCurrencyName('BR'); // 'Brazilian Real'
216
239
 
217
- // Reverse lookup
218
- currency.getCountriesByCurrency('EUR');
240
+ // Check if country uses a specific currency
241
+ currency.usesCurrency('FR', 'EUR'); // true
242
+ currency.usesCurrency('GB', 'EUR'); // false
243
+
244
+ // Reverse lookup - get all countries using a currency
245
+ currency.countriesUsingCurrency('EUR');
219
246
  // ['AD', 'AT', 'BE', 'CY', 'DE', 'EE', 'ES', 'FI', 'FR', ...]
247
+ currency.getCountriesByCurrency('EUR'); // alias for countriesUsingCurrency
220
248
  ```
221
249
 
222
250
  ### Dial Code Functions
@@ -267,12 +295,14 @@ geography.getRegion('BR'); // 'South America'
267
295
  geography.getGeography('FR');
268
296
  // { continent: 'Europe', region: 'Western Europe' }
269
297
 
270
- // Reverse lookups
271
- geography.getCountriesByContinent('Europe');
298
+ // Reverse lookups - get all countries in a continent/region
299
+ geography.countriesInContinent('Europe');
272
300
  // ['AD', 'AL', 'AT', 'AX', 'BA', 'BE', ...]
301
+ geography.getCountriesByContinent('Europe'); // alias for countriesInContinent
273
302
 
274
- geography.getCountriesByRegion('Eastern Asia');
303
+ geography.countriesInRegion('Eastern Asia');
275
304
  // ['CN', 'HK', 'JP', 'KP', 'KR', 'MO', 'MN', 'TW']
305
+ geography.getCountriesByRegion('Eastern Asia'); // alias for countriesInRegion
276
306
 
277
307
  // Get all continents/regions
278
308
  geography.getContinents();
@@ -311,6 +341,10 @@ membership.isEurozone('SE'); // false (Sweden uses SEK)
311
341
  membership.isSchengen('FR'); // true
312
342
  membership.isSchengen('IE'); // false (Ireland not in Schengen)
313
343
 
344
+ // Generic membership check
345
+ membership.isMember('FR', 'EU'); // true
346
+ membership.isMember('CH', 'SEPA'); // true
347
+
314
348
  // Get all memberships at once
315
349
  membership.getMemberships('FR');
316
350
  // { EU: true, SEPA: true, EEA: true, Eurozone: true, Schengen: true }
@@ -364,7 +398,9 @@ import {
364
398
  getCurrencyCode,
365
399
  getCurrencySymbol,
366
400
  getCurrencyName,
367
- getCountriesByCurrency,
401
+ usesCurrency,
402
+ countriesUsingCurrency,
403
+ getCountriesByCurrency, // alias for countriesUsingCurrency
368
404
  } from '@koshmoney/countries/currency';
369
405
 
370
406
  // Dial code functions
@@ -381,8 +417,10 @@ import {
381
417
  getContinent,
382
418
  getRegion,
383
419
  getGeography,
384
- getCountriesByContinent,
385
- getCountriesByRegion,
420
+ countriesInContinent,
421
+ countriesInRegion,
422
+ getCountriesByContinent, // alias for countriesInContinent
423
+ getCountriesByRegion, // alias for countriesInRegion
386
424
  getContinents,
387
425
  getRegions,
388
426
  } from '@koshmoney/countries/geography';
@@ -394,6 +432,7 @@ import {
394
432
  isEEA,
395
433
  isEurozone,
396
434
  isSchengen,
435
+ isMember,
397
436
  getMemberships,
398
437
  getMembers,
399
438
  } from '@koshmoney/countries/membership';
package/package.json CHANGED
@@ -1,11 +1,39 @@
1
1
  {
2
2
  "name": "@koshmoney/countries",
3
- "version": "1.0.1-beta.3",
3
+ "version": "1.0.1-beta.4",
4
4
  "description": "Complete ISO 3166-1 (countries) and ISO 3166-2 (subdivisions) lookup library with full TypeScript support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "typesVersions": {
10
+ "*": {
11
+ "country": [
12
+ "./dist/country/index.d.ts"
13
+ ],
14
+ "subdivision": [
15
+ "./dist/subdivision/index.d.ts"
16
+ ],
17
+ "subdivision/*": [
18
+ "./dist/subdivision/data/*.d.ts"
19
+ ],
20
+ "postalCode": [
21
+ "./dist/postalCode/index.d.ts"
22
+ ],
23
+ "currency": [
24
+ "./dist/currency/index.d.ts"
25
+ ],
26
+ "dialCode": [
27
+ "./dist/dialCode/index.d.ts"
28
+ ],
29
+ "geography": [
30
+ "./dist/geography/index.d.ts"
31
+ ],
32
+ "membership": [
33
+ "./dist/membership/index.d.ts"
34
+ ]
35
+ }
36
+ },
9
37
  "sideEffects": [
10
38
  "./dist/subdivision/data/*.js",
11
39
  "./dist/subdivision/data/*.cjs",