@visulima/iso-locale 0.0.1 → 1.0.0-alpha.11
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/CHANGELOG.md +137 -0
- package/LICENSE.md +27 -0
- package/README.md +173 -29
- package/dist/countries.d.ts +117 -0
- package/dist/countries.js +1 -0
- package/dist/currencies.d.ts +68 -0
- package/dist/currencies.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1 -0
- package/dist/locale.d.ts +44 -0
- package/dist/locale.js +1 -0
- package/dist/packem_shared/iso6393To6391-BuOs0Bzd.js +1 -0
- package/dist/regions.d.ts +48 -0
- package/dist/regions.js +1 -0
- package/dist/timezones.d.ts +39 -0
- package/dist/timezones.js +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.js +0 -0
- package/package.json +112 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
## @visulima/iso-locale [1.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.10...@visulima/iso-locale@1.0.0-alpha.11) (2026-06-04)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **iso-locale:** 2 bug fixes + 1 perf ([5a75216](https://github.com/visulima/visulima/commit/5a752163531e8bd458dffa264e05466e33f9d444))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* apply eslint + prettier autofixes across packages ([c1bb784](https://github.com/visulima/visulima/commit/c1bb7848a0d93d0dfe2960c77e3cda22239c79a0))
|
|
10
|
+
|
|
11
|
+
### Tests
|
|
12
|
+
|
|
13
|
+
* improve coverage across packages ([91bd6d3](https://github.com/visulima/visulima/commit/91bd6d3b61736e3c8bd1fc59b0b5955f76a5d323))
|
|
14
|
+
* **iso-locale:** cover numeric country lookups, currency fallbacks, and bcp47 parse branches ([695bf35](https://github.com/visulima/visulima/commit/695bf354daac3699c166b6a3a671cec15bd639ee))
|
|
15
|
+
|
|
16
|
+
## @visulima/iso-locale [1.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.9...@visulima/iso-locale@1.0.0-alpha.10) (2026-05-27)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **storage-client:** percent-encode user fields in defaultFingerprint ([7c78a0f](https://github.com/visulima/visulima/commit/7c78a0f9512e2a673b941d80839e9f1e86b7b5d0))
|
|
21
|
+
|
|
22
|
+
### Documentation
|
|
23
|
+
|
|
24
|
+
* prettier-format agent instructions ([71b6414](https://github.com/visulima/visulima/commit/71b6414528780ac82c4e0bb25b5f4f11faba5549))
|
|
25
|
+
|
|
26
|
+
### Miscellaneous Chores
|
|
27
|
+
|
|
28
|
+
* sorted package.json ([b47c545](https://github.com/visulima/visulima/commit/b47c545591600fdab17d5cd3a3fbc68b61e199da))
|
|
29
|
+
|
|
30
|
+
## @visulima/iso-locale [1.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.8...@visulima/iso-locale@1.0.0-alpha.9) (2026-05-26)
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* **security:** address codeql findings across packages ([3366f9c](https://github.com/visulima/visulima/commit/3366f9c07d54bdde5242fbd90780baa4634de179))
|
|
35
|
+
|
|
36
|
+
### Miscellaneous Chores
|
|
37
|
+
|
|
38
|
+
* **ci-stability:** green CI across vis, native, lint, tests, attw ([#651](https://github.com/visulima/visulima/issues/651)) ([d4eb684](https://github.com/visulima/visulima/commit/d4eb684b5f75c818c9251048c605a0ed54a268e3))
|
|
39
|
+
* **iso-locale:** housekeeping cleanup ([326d3e4](https://github.com/visulima/visulima/commit/326d3e4be152fdcb828da32a67341fae0c274709))
|
|
40
|
+
* **iso-locale:** upgrade packem to 2.0.0-alpha.76 ([9908d9c](https://github.com/visulima/visulima/commit/9908d9c57641ade481016ea711981e03d53c746c))
|
|
41
|
+
* re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
|
|
42
|
+
* **repo:** sort package.json keys across all packages ([e1fd9ab](https://github.com/visulima/visulima/commit/e1fd9ab467ef96a98c777da1572ff6a50fcf7e71))
|
|
43
|
+
|
|
44
|
+
### Tests
|
|
45
|
+
|
|
46
|
+
* **repo:** add dist runtime + types integration tests ([32ee300](https://github.com/visulima/visulima/commit/32ee300b7184117a0ddf9f9d390f75f8932d5ed9))
|
|
47
|
+
|
|
48
|
+
## @visulima/iso-locale [1.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.7...@visulima/iso-locale@1.0.0-alpha.8) (2026-04-22)
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
|
|
53
|
+
|
|
54
|
+
### Miscellaneous Chores
|
|
55
|
+
|
|
56
|
+
* bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
|
|
57
|
+
* fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
|
|
58
|
+
|
|
59
|
+
## @visulima/iso-locale [1.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.6...@visulima/iso-locale@1.0.0-alpha.7) (2026-04-15)
|
|
60
|
+
|
|
61
|
+
### Bug Fixes
|
|
62
|
+
|
|
63
|
+
* **data-manipulation:** resolve eslint and type-safety issues ([f1682c2](https://github.com/visulima/visulima/commit/f1682c2611cbcc6c85d4bbea520d43464b42e7ee))
|
|
64
|
+
* **iso-locale:** cast readonly Country array to mutable type for public export ([b93bc50](https://github.com/visulima/visulima/commit/b93bc5064e123c541140b1ab072c280989087afc))
|
|
65
|
+
|
|
66
|
+
## @visulima/iso-locale [1.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.5...@visulima/iso-locale@1.0.0-alpha.6) (2026-04-08)
|
|
67
|
+
|
|
68
|
+
### Bug Fixes
|
|
69
|
+
|
|
70
|
+
* **iso-locale:** resolve eslint errors ([8f24691](https://github.com/visulima/visulima/commit/8f246919ecf1c5d08a3f85a019d8857bcbf31c4f))
|
|
71
|
+
|
|
72
|
+
### Miscellaneous Chores
|
|
73
|
+
|
|
74
|
+
* apply linting and formatting fixes across packages ([5d150a5](https://github.com/visulima/visulima/commit/5d150a578f9ce861c791843c683deeb849b774a9))
|
|
75
|
+
* **data-manipulation:** remove empty dependency objects from package.json ([c0e8f76](https://github.com/visulima/visulima/commit/c0e8f7689a2da413f771494f6ecb07babc4b5e06))
|
|
76
|
+
* **iso-locale:** add tsconfig.eslint.json for type-aware linting ([0322596](https://github.com/visulima/visulima/commit/0322596031774fef5e1bbbce188de31d2033824b))
|
|
77
|
+
* **iso-locale:** apply prettier formatting ([420b06e](https://github.com/visulima/visulima/commit/420b06e28f37beea0679b16f2ada733518e2cffe))
|
|
78
|
+
* **iso-locale:** migrate .prettierrc.cjs to prettier.config.js ([ecc98a0](https://github.com/visulima/visulima/commit/ecc98a0b65de3b5c97cc5b12bd55732e193b2dc9))
|
|
79
|
+
|
|
80
|
+
## @visulima/iso-locale [1.0.0-alpha.5](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.4...@visulima/iso-locale@1.0.0-alpha.5) (2026-03-26)
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
* **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
|
|
85
|
+
|
|
86
|
+
## @visulima/iso-locale [1.0.0-alpha.4](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.3...@visulima/iso-locale@1.0.0-alpha.4) (2026-03-26)
|
|
87
|
+
|
|
88
|
+
### Bug Fixes
|
|
89
|
+
|
|
90
|
+
* **web:** improve build setup with incremental stats caching and prod install ([fe33e75](https://github.com/visulima/visulima/commit/fe33e75827586779b4b3a0c6d57b39f889ee6207))
|
|
91
|
+
|
|
92
|
+
### Miscellaneous Chores
|
|
93
|
+
|
|
94
|
+
* **iso-locale:** migrate deps to pnpm catalogs ([77a0af9](https://github.com/visulima/visulima/commit/77a0af94f3ee1c405cfca1df1db16af6c6b288ea))
|
|
95
|
+
* **iso-locale:** update dependencies ([171ce31](https://github.com/visulima/visulima/commit/171ce31272306c952d35018dea8ec4072f11cd52))
|
|
96
|
+
* visulima website ([#591](https://github.com/visulima/visulima/issues/591)) ([59ab2e2](https://github.com/visulima/visulima/commit/59ab2e2befb03e51cd2088956f83d9b87de6d033))
|
|
97
|
+
|
|
98
|
+
## @visulima/iso-locale [1.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.2...@visulima/iso-locale@1.0.0-alpha.3) (2026-03-06)
|
|
99
|
+
|
|
100
|
+
### Bug Fixes
|
|
101
|
+
|
|
102
|
+
* **iso-locale:** update packem to 2.0.0-alpha.54 ([17ce847](https://github.com/visulima/visulima/commit/17ce8479d65e21f26da08674cedadfd69bf8fbeb))
|
|
103
|
+
|
|
104
|
+
### Documentation
|
|
105
|
+
|
|
106
|
+
* **humanizer,html,iso-locale,package,tsconfig:** add comprehensive Fumadocs documentation ([19781ce](https://github.com/visulima/visulima/commit/19781ce5d27605971a9f2fdf0a99863effd98091))
|
|
107
|
+
|
|
108
|
+
### Miscellaneous Chores
|
|
109
|
+
|
|
110
|
+
* **data-manipulation:** update dependencies ([49458ab](https://github.com/visulima/visulima/commit/49458ab8f8e17d875840b1b4fe8b5efe12ff3513))
|
|
111
|
+
* **iso-locale:** update dependencies ([78c7b5e](https://github.com/visulima/visulima/commit/78c7b5e3528c2ec4a32cab44449c5840664fa94d))
|
|
112
|
+
* update lock file maintenance ([d83e716](https://github.com/visulima/visulima/commit/d83e71697b75d24704185b66bb521a934d2db02d))
|
|
113
|
+
* year update ([47f4105](https://github.com/visulima/visulima/commit/47f410596ce7190cfea36a073db32e0cec50bbcd))
|
|
114
|
+
|
|
115
|
+
## @visulima/iso-locale [1.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.1...@visulima/iso-locale@1.0.0-alpha.2) (2026-01-17)
|
|
116
|
+
|
|
117
|
+
### Bug Fixes
|
|
118
|
+
|
|
119
|
+
* added missing og image ([7712247](https://github.com/visulima/visulima/commit/771224739f29e977d5684849dcf015486c75ff00))
|
|
120
|
+
|
|
121
|
+
### Miscellaneous Chores
|
|
122
|
+
|
|
123
|
+
* fixed changelog ([6ebdc5b](https://github.com/visulima/visulima/commit/6ebdc5b56e94054f4ac88d2bc2235a2c14d3d608))
|
|
124
|
+
* sorting package.json ([430ed68](https://github.com/visulima/visulima/commit/430ed683d3e38e4c5c5530f787ca832f083b17e4))
|
|
125
|
+
|
|
126
|
+
## @visulima/iso-locale 1.0.0-alpha.1 (2026-01-17)
|
|
127
|
+
|
|
128
|
+
### Features
|
|
129
|
+
|
|
130
|
+
* add new exports for countries, currencies, regions, timezones, and types in iso-locale package ([acb2104](https://github.com/visulima/visulima/commit/acb210457cd57160cadd49b84a22c1098ada70eb))
|
|
131
|
+
* create new iso-locale package ([#584](https://github.com/visulima/visulima/issues/584)) ([3436f36](https://github.com/visulima/visulima/commit/3436f36aa96636c08f74df1a4eed28a6a29881fb))
|
|
132
|
+
* update imports and add new data files for countries, currencies, regions, and timezones in iso-locale package ([639dd6e](https://github.com/visulima/visulima/commit/639dd6ee41ac89a21539f8eac17f1db298bce5ee))
|
|
133
|
+
|
|
134
|
+
### Code Refactoring
|
|
135
|
+
|
|
136
|
+
* streamline installation instructions and enhance data structure for countries, currencies, and regions in iso-locale package ([17b9e20](https://github.com/visulima/visulima/commit/17b9e201fef738ff80c6439da4998c4d1da7fbd3))
|
|
137
|
+
* update ESLint configuration, improve data handling in regions and timezones, and enhance currency data structure in iso-locale package ([229680d](https://github.com/visulima/visulima/commit/229680d0ecd6b422b594893b8f13e3de504d5475))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 visulima
|
|
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.
|
|
22
|
+
|
|
23
|
+
<!-- DEPENDENCIES -->
|
|
24
|
+
<!-- /DEPENDENCIES -->
|
|
25
|
+
|
|
26
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
27
|
+
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -1,45 +1,189 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<a href="https://www.anolilab.com/open-source" align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<img src="__assets__/package-og.svg" alt="iso-locale" />
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
</a>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
<h3 align="center">ISO data for countries, currencies, regions, timezones, and BCP 47 locale support.</h3>
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@visulima/iso-locale`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
11
|
+
<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
<br />
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
<div align="center">
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
[![typescript-image][typescript-badge]][typescript-url]
|
|
18
|
+
[![mit licence][license-badge]][license]
|
|
19
|
+
[![npm downloads][npm-downloads-badge]][npm-downloads]
|
|
20
|
+
[![Chat][chat-badge]][chat]
|
|
21
|
+
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
</div>
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
25
|
+
---
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
<div align="center">
|
|
28
|
+
<p>
|
|
29
|
+
<sup>
|
|
30
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
31
|
+
</sup>
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
35
|
+
---
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Install
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
```sh
|
|
40
|
+
npm install @visulima/iso-locale
|
|
41
|
+
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
```sh
|
|
44
|
+
yarn add @visulima/iso-locale
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pnpm add @visulima/iso-locale
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### Countries
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { getByAlpha2, getCountryByName, getEmoji, getCallingCode, getLanguages } from "@visulima/iso-locale";
|
|
57
|
+
|
|
58
|
+
// Get country by code
|
|
59
|
+
const country = getByAlpha2("US");
|
|
60
|
+
console.log(country.name); // "United States"
|
|
61
|
+
|
|
62
|
+
// Get country by name
|
|
63
|
+
const country2 = getCountryByName("United States");
|
|
64
|
+
|
|
65
|
+
// Get flag emoji
|
|
66
|
+
console.log(getEmoji("US")); // "🇺🇸"
|
|
67
|
+
|
|
68
|
+
// Get calling code
|
|
69
|
+
console.log(getCallingCode("US")); // "+1"
|
|
70
|
+
|
|
71
|
+
// Get languages
|
|
72
|
+
console.log(getLanguages("US")); // ["eng"]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Currencies
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { getByCode, getSymbol, getByCountry, getCountriesByCurrency } from "@visulima/iso-locale";
|
|
79
|
+
|
|
80
|
+
// Get currency by code
|
|
81
|
+
const currency = getByCode("USD");
|
|
82
|
+
console.log(currency.name); // "United States dollar"
|
|
83
|
+
console.log(currency.symbol); // "$"
|
|
84
|
+
|
|
85
|
+
// Get currency symbol
|
|
86
|
+
console.log(getSymbol("USD")); // "$"
|
|
87
|
+
|
|
88
|
+
// Get currencies for a country
|
|
89
|
+
const currencies = getByCountry("US");
|
|
90
|
+
console.log(currencies[0].code); // "USD"
|
|
91
|
+
|
|
92
|
+
// Get countries using a currency
|
|
93
|
+
const countries = getCountriesByCurrency("EUR");
|
|
94
|
+
console.log(countries); // ["FR", "DE", "ES", ...]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Regions
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { getRegionsForCountry, getCountriesInContinent, getCountriesInSubregion } from "@visulima/iso-locale";
|
|
101
|
+
|
|
102
|
+
// Get region for a country
|
|
103
|
+
const region = getRegionsForCountry("US");
|
|
104
|
+
console.log(region.continent); // "Americas"
|
|
105
|
+
console.log(region.subregion); // "Northern America"
|
|
106
|
+
|
|
107
|
+
// Get countries in a continent
|
|
108
|
+
const africanCountries = getCountriesInContinent("Africa");
|
|
109
|
+
|
|
110
|
+
// Get countries in a subregion
|
|
111
|
+
const westernEurope = getCountriesInSubregion("Western Europe");
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Timezones
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { getTimezonesByCountry, getPrimaryTimezone, getCountriesForTimezone } from "@visulima/iso-locale";
|
|
118
|
+
|
|
119
|
+
// Get timezones for a country
|
|
120
|
+
const timezones = getTimezonesByCountry("US");
|
|
121
|
+
console.log(timezones);
|
|
122
|
+
// ["America/New_York", "America/Los_Angeles", ...]
|
|
123
|
+
|
|
124
|
+
// Get primary timezone
|
|
125
|
+
console.log(getPrimaryTimezone("GB")); // "Europe/London"
|
|
126
|
+
|
|
127
|
+
// Get countries using a timezone
|
|
128
|
+
const countries = getCountriesForTimezone("Europe/London");
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Locale & BCP 47
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { getCurrency, getBCP47Tags, parseBCP47Tag, generateBCP47Tag } from "@visulima/iso-locale";
|
|
135
|
+
|
|
136
|
+
// Get currency from locale
|
|
137
|
+
console.log(getCurrency("en-US")); // "USD"
|
|
138
|
+
console.log(getCurrency("pt-BR")); // "BRL"
|
|
139
|
+
|
|
140
|
+
// Get BCP 47 tags for a country
|
|
141
|
+
console.log(getBCP47Tags("CA")); // ["en-CA", "fr-CA"]
|
|
142
|
+
|
|
143
|
+
// Parse BCP 47 tag
|
|
144
|
+
const parsed = parseBCP47Tag("zh-Hant-TW");
|
|
145
|
+
console.log(parsed);
|
|
146
|
+
// { language: "zh", script: "Hant", country: "TW" }
|
|
147
|
+
|
|
148
|
+
// Generate BCP 47 tag
|
|
149
|
+
console.log(generateBCP47Tag("en", "US")); // "en-US"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Related
|
|
153
|
+
|
|
154
|
+
## Supported Node.js Versions
|
|
155
|
+
|
|
156
|
+
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
157
|
+
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
158
|
+
|
|
159
|
+
## Contributing
|
|
160
|
+
|
|
161
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md) guidelines.
|
|
162
|
+
|
|
163
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
164
|
+
|
|
165
|
+
## Credits
|
|
166
|
+
|
|
167
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
168
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
169
|
+
|
|
170
|
+
## Made with ❤️ at Anolilab
|
|
171
|
+
|
|
172
|
+
This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
The visulima iso-locale is open-sourced software licensed under the [MIT][license]
|
|
177
|
+
|
|
178
|
+
<!-- badges -->
|
|
44
179
|
|
|
45
|
-
|
|
180
|
+
[license-badge]: https://img.shields.io/npm/l/@visulima/iso-locale?style=for-the-badge
|
|
181
|
+
[license]: https://github.com/visulima/visulima/blob/main/LICENSE
|
|
182
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/iso-locale?style=for-the-badge
|
|
183
|
+
[npm-downloads]: https://www.npmjs.com/package/@visulima/iso-locale
|
|
184
|
+
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
|
|
185
|
+
[prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
|
|
186
|
+
[chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
|
|
187
|
+
[chat]: https://discord.gg/TtFJY8xkFK
|
|
188
|
+
[typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
189
|
+
[typescript-url]: https://www.typescriptlang.org/
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Country } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get country by ISO 3166-1 alpha-2 code.
|
|
4
|
+
* @param code 2-letter country code (e.g., "US")
|
|
5
|
+
* @returns Country object or undefined
|
|
6
|
+
*/
|
|
7
|
+
declare const getByAlpha2: (code: string) => Country | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Get country by ISO 3166-1 alpha-3 code.
|
|
10
|
+
* @param code 3-letter country code (e.g., "USA")
|
|
11
|
+
* @returns Country object or undefined
|
|
12
|
+
*/
|
|
13
|
+
declare const getByAlpha3: (code: string) => Country | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get country by ISO 3166-1 numeric code.
|
|
16
|
+
* @param code 3-digit numeric code (e.g., "840")
|
|
17
|
+
* @returns Country object or undefined
|
|
18
|
+
*/
|
|
19
|
+
declare const getByNumeric: (code: string | number) => Country | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Convert alpha-2 code to alpha-3 code.
|
|
22
|
+
* @param alpha2 2-letter country code
|
|
23
|
+
* @returns 3-letter country code or undefined
|
|
24
|
+
*/
|
|
25
|
+
declare const alpha2ToAlpha3: (alpha2: string) => string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Convert alpha-3 code to alpha-2 code.
|
|
28
|
+
* @param alpha3 3-letter country code
|
|
29
|
+
* @returns 2-letter country code or undefined
|
|
30
|
+
*/
|
|
31
|
+
declare const alpha3ToAlpha2: (alpha3: string) => string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Convert alpha-2 code to numeric code.
|
|
34
|
+
* @param alpha2 2-letter country code
|
|
35
|
+
* @returns 3-digit numeric code or undefined
|
|
36
|
+
*/
|
|
37
|
+
declare const alpha2ToNumeric: (alpha2: string) => string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Convert alpha-3 code to numeric code.
|
|
40
|
+
* @param alpha3 3-letter country code
|
|
41
|
+
* @returns 3-digit numeric code or undefined
|
|
42
|
+
*/
|
|
43
|
+
declare const alpha3ToNumeric: (alpha3: string) => string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Convert numeric code to alpha-2 code.
|
|
46
|
+
* @param numeric 3-digit numeric code
|
|
47
|
+
* @returns 2-letter country code or undefined
|
|
48
|
+
*/
|
|
49
|
+
declare const numericToAlpha2: (numeric: string | number) => string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Convert numeric code to alpha-3 code.
|
|
52
|
+
* @param numeric 3-digit numeric code
|
|
53
|
+
* @returns 3-letter country code or undefined
|
|
54
|
+
*/
|
|
55
|
+
declare const numericToAlpha3: (numeric: string | number) => string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a country code is valid (supports alpha-2, alpha-3, or numeric).
|
|
58
|
+
* @param code Country code in any format
|
|
59
|
+
* @returns true if valid, false otherwise
|
|
60
|
+
*/
|
|
61
|
+
declare const isValid: (code: string | number) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Countries indexed by alpha-2 code.
|
|
64
|
+
*/
|
|
65
|
+
declare const byAlpha2: Readonly<Record<string, Country>>;
|
|
66
|
+
/**
|
|
67
|
+
* Countries indexed by alpha-3 code.
|
|
68
|
+
*/
|
|
69
|
+
declare const byAlpha3: Readonly<Record<string, Country>>;
|
|
70
|
+
/**
|
|
71
|
+
* Countries indexed by numeric code.
|
|
72
|
+
*/
|
|
73
|
+
declare const byNumeric: Readonly<Record<string, Country>>;
|
|
74
|
+
/**
|
|
75
|
+
* Get flag emoji for a country.
|
|
76
|
+
* @param countryCode ISO 3166-1 alpha-2, alpha-3, or numeric code
|
|
77
|
+
* @returns Flag emoji or undefined
|
|
78
|
+
*/
|
|
79
|
+
declare const getEmoji: (countryCode: string | number) => string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Get country calling code (phone prefix) for a country.
|
|
82
|
+
* @param countryCode ISO 3166-1 alpha-2, alpha-3, or numeric code
|
|
83
|
+
* @returns First calling code or undefined
|
|
84
|
+
*/
|
|
85
|
+
declare const getCallingCode: (countryCode: string | number) => string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Get all calling codes for a country.
|
|
88
|
+
* @param countryCode ISO 3166-1 alpha-2, alpha-3, or numeric code
|
|
89
|
+
* @returns Array of calling codes or empty array
|
|
90
|
+
*/
|
|
91
|
+
declare const getCallingCodes: (countryCode: string | number) => string[];
|
|
92
|
+
/**
|
|
93
|
+
* Get languages for a country.
|
|
94
|
+
* @param countryCode ISO 3166-1 alpha-2, alpha-3, or numeric code
|
|
95
|
+
* @returns Array of ISO 639 language codes or empty array
|
|
96
|
+
*/
|
|
97
|
+
declare const getLanguages: (countryCode: string | number) => string[];
|
|
98
|
+
/**
|
|
99
|
+
* Get International Olympic Committee code for a country.
|
|
100
|
+
* @param countryCode ISO 3166-1 alpha-2, alpha-3, or numeric code
|
|
101
|
+
* @returns IOC code or undefined
|
|
102
|
+
*/
|
|
103
|
+
declare const getIOC: (countryCode: string | number) => string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Get country by name (exact match, case-insensitive).
|
|
106
|
+
* @param name Country name (e.g., "United States")
|
|
107
|
+
* @returns Country object or undefined
|
|
108
|
+
*/
|
|
109
|
+
declare const getCountryByName: (name: string) => Country | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Search countries by name (partial match, case-insensitive).
|
|
112
|
+
* @param query Search query (e.g., "united")
|
|
113
|
+
* @returns Array of matching Country objects
|
|
114
|
+
*/
|
|
115
|
+
declare const searchCountries: (query: string) => Country[];
|
|
116
|
+
declare const all: Country[];
|
|
117
|
+
export { all, alpha2ToAlpha3, alpha2ToNumeric, alpha3ToAlpha2, alpha3ToNumeric, byAlpha2, byAlpha3, byNumeric, getByAlpha2, getByAlpha3, getByNumeric, getCallingCode, getCallingCodes, getCountryByName, getEmoji, getIOC, getLanguages, isValid, numericToAlpha2, numericToAlpha3, searchCountries };
|