country-codes-list 1.6.10 → 1.6.12
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/README.md +14 -8
- package/countriesData.js +20 -4
- package/index.d.ts +35 -42
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# country-codes-list
|
|
2
|
+
|
|
2
3
|
Module with list of codes per country, which includes:
|
|
3
4
|
|
|
4
5
|
- Country code (ISO 3166-1 alpha-2): Obtained from [Wikipedia](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
|
@@ -9,12 +10,13 @@ Module with list of codes per country, which includes:
|
|
|
9
10
|
- TIN Name: Obtained from [Wikipedia](https://en.wikipedia.org/wiki/VAT_identification_number)
|
|
10
11
|
- Official language code (usually from ISO 639-1, or ISO 639-3 otherwise)): Obtained from [Open Street Map](https://wiki.openstreetmap.org/wiki/Nominatim/Country_Codes). Returns only the first official language code per country
|
|
11
12
|
- Official language name: Each name in english and in the local country language
|
|
12
|
-
- Country Calling Code: The phone calling code for the country. Obtained from [Wikipedia](https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_listing_by_country_or_region).
|
|
13
|
+
- Country Calling Code: The phone calling code for the country. Obtained from [Wikipedia](https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_listing_by_country_or_region).
|
|
13
14
|
- Region: The Regional Classifications are from the [International Telecommunications Union](http://www.itu.int/ITU-D/ict/definitions/regions/index.html). Seen [here](https://meta.wikimedia.org/wiki/List_of_countries_by_regional_classification)
|
|
14
15
|
|
|
15
|
-
|
|
16
16
|
# Installation
|
|
17
|
+
|
|
17
18
|
## Install the NPM module
|
|
19
|
+
|
|
18
20
|
```bash
|
|
19
21
|
npm install --save country-codes-list
|
|
20
22
|
```
|
|
@@ -23,9 +25,10 @@ Module with list of codes per country, which includes:
|
|
|
23
25
|
|
|
24
26
|
### customList method:
|
|
25
27
|
|
|
26
|
-
Just import the module and call the customList method. The first parameter must be the key you want for your object, and the second parameter must be a string with placeholders written as you need. The placeholders are defined between brackets (`{placeholder}
|
|
28
|
+
Just import the module and call the customList method. The first parameter must be the key you want for your object, and the second parameter must be a string with placeholders written as you need. The placeholders are defined between brackets (`{placeholder}`).
|
|
29
|
+
|
|
30
|
+
The possible values for the object key and the placeholders are:
|
|
27
31
|
|
|
28
|
-
The possible values for the object key and the placeholders are:
|
|
29
32
|
- countryNameEn
|
|
30
33
|
- countryNameLocal
|
|
31
34
|
- countryCode
|
|
@@ -43,12 +46,15 @@ The possible values for the object key and the placeholders are:
|
|
|
43
46
|
#### Example
|
|
44
47
|
|
|
45
48
|
```js
|
|
46
|
-
const countryCodes = require(
|
|
49
|
+
const countryCodes = require("country-codes-list");
|
|
47
50
|
|
|
48
|
-
const myCountryCodesObject = countryCodes.customList(
|
|
51
|
+
const myCountryCodesObject = countryCodes.customList(
|
|
52
|
+
"countryCode",
|
|
53
|
+
"[{countryCode}] {countryNameEn}: +{countryCallingCode}"
|
|
54
|
+
);
|
|
49
55
|
```
|
|
50
56
|
|
|
51
|
-
This will return an object like this one:
|
|
57
|
+
This will return an object like this one:
|
|
52
58
|
|
|
53
59
|
```js
|
|
54
60
|
{
|
|
@@ -69,4 +75,4 @@ This will return an object like this one:
|
|
|
69
75
|
...
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
```
|
|
78
|
+
```
|
package/countriesData.js
CHANGED
|
@@ -935,9 +935,9 @@ module.exports = [
|
|
|
935
935
|
"currencyNameEn": "Euro",
|
|
936
936
|
"tinType": "NIF (CIF)",
|
|
937
937
|
"tinName": "Número de Identificación Fiscal (formerly named Código de Identificación Fiscal)",
|
|
938
|
-
"officialLanguageCode": "
|
|
939
|
-
"officialLanguageNameEn": "",
|
|
940
|
-
"officialLanguageNameLocal": "",
|
|
938
|
+
"officialLanguageCode": "es",
|
|
939
|
+
"officialLanguageNameEn": "Spanish, Castilian",
|
|
940
|
+
"officialLanguageNameLocal": "Español",
|
|
941
941
|
"countryCallingCode": "34",
|
|
942
942
|
"areaCodes": [],
|
|
943
943
|
"region": "Europe",
|
|
@@ -1455,6 +1455,22 @@ module.exports = [
|
|
|
1455
1455
|
"region": "Asia & Pacific",
|
|
1456
1456
|
"flag": "🇮🇳"
|
|
1457
1457
|
},
|
|
1458
|
+
{
|
|
1459
|
+
"countryNameEn": "British Indian Ocean Territories",
|
|
1460
|
+
"countryNameLocal": "British Indian Ocean Territories",
|
|
1461
|
+
"countryCode": "IO",
|
|
1462
|
+
"currencyCode": "USD",
|
|
1463
|
+
"currencyNameEn": "United States dollar",
|
|
1464
|
+
"tinType": "",
|
|
1465
|
+
"tinName": "",
|
|
1466
|
+
"officialLanguageCode": "en",
|
|
1467
|
+
"officialLanguageNameEn": "English",
|
|
1468
|
+
"officialLanguageNameLocal": "English",
|
|
1469
|
+
"countryCallingCode": "246",
|
|
1470
|
+
"areaCodes": [],
|
|
1471
|
+
"region": "Indian Ocean",
|
|
1472
|
+
"flag": "🇮🇴",
|
|
1473
|
+
},
|
|
1458
1474
|
{
|
|
1459
1475
|
"countryNameEn": "Iraq",
|
|
1460
1476
|
"countryNameLocal": "العراق, Iraq",
|
|
@@ -3962,7 +3978,7 @@ module.exports = [
|
|
|
3962
3978
|
"officialLanguageCode": "en",
|
|
3963
3979
|
"officialLanguageNameEn": "English",
|
|
3964
3980
|
"officialLanguageNameLocal": "English",
|
|
3965
|
-
"countryCallingCode": "
|
|
3981
|
+
"countryCallingCode": "1",
|
|
3966
3982
|
"areaCodes": [],
|
|
3967
3983
|
"region": "Pacific Ocean",
|
|
3968
3984
|
"flag": "🇺🇲",
|
package/index.d.ts
CHANGED
|
@@ -2,60 +2,53 @@
|
|
|
2
2
|
// by jakeisnt, Feb. 2022
|
|
3
3
|
|
|
4
4
|
declare module 'country-codes-list' {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
|
|
6
|
+
export type CountryData = {
|
|
7
|
+
countryNameEn: string
|
|
8
|
+
countryNameLocal: string
|
|
9
|
+
countryCode: string
|
|
10
|
+
currencyCode: string
|
|
11
|
+
currencyNameEn: string
|
|
12
|
+
tinType: string
|
|
13
|
+
tinName: string
|
|
14
|
+
officialLanguageCode: string
|
|
15
|
+
officialLanguageNameEn: string
|
|
16
|
+
officialLanguageNameLocal: string
|
|
17
|
+
countryCallingCode: string
|
|
18
|
+
region: string
|
|
19
|
+
flag: string
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
type
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[CountryProperty.countryCode]: string,
|
|
25
|
-
[CountryProperty.currencyCode]: string,
|
|
26
|
-
[CountryProperty.currencyNameEn]: string,
|
|
27
|
-
[CountryProperty.tinType]: string,
|
|
28
|
-
[CountryProperty.tinName]: string,
|
|
29
|
-
[CountryProperty.officialLanguageCode]: string,
|
|
30
|
-
[CountryProperty.officialLanguageNameEn]: string,
|
|
31
|
-
[CountryProperty.officialLanguageNameLocal]: string,
|
|
32
|
-
[CountryProperty.countryCallingCode]: string,
|
|
33
|
-
[CountryProperty.region]: string,
|
|
34
|
-
[CountryProperty.flag]: string,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
type Filter<T> = (element: T, index: number, array: T[]) => T[];
|
|
22
|
+
export type CountryProperty = keyof CountryData
|
|
23
|
+
|
|
24
|
+
type Filter<T> = (element: T, index: number, array: T[]) => T[]
|
|
38
25
|
|
|
39
26
|
type CustomArraySettings = {
|
|
40
|
-
sortDataBy?: CountryProperty
|
|
41
|
-
sortBy?: any
|
|
42
|
-
filter?: Filter<CountryData
|
|
43
|
-
}
|
|
27
|
+
sortDataBy?: CountryProperty
|
|
28
|
+
sortBy?: any
|
|
29
|
+
filter?: Filter<CountryData>
|
|
30
|
+
}
|
|
44
31
|
|
|
45
|
-
export function all(): CountryData[]
|
|
32
|
+
export function all(): CountryData[]
|
|
46
33
|
|
|
47
|
-
export function filter(
|
|
34
|
+
export function filter(
|
|
35
|
+
countryProperty: CountryProperty,
|
|
36
|
+
value: string,
|
|
37
|
+
): CountryData[]
|
|
48
38
|
|
|
49
|
-
export function findOne(
|
|
39
|
+
export function findOne(
|
|
40
|
+
countryProperty: CountryProperty,
|
|
41
|
+
value: string,
|
|
42
|
+
): CountryData
|
|
50
43
|
|
|
51
44
|
export function customArray(
|
|
52
|
-
fields?:
|
|
53
|
-
settings?: CustomArraySettings
|
|
54
|
-
): string[]
|
|
45
|
+
fields?: Record<string, string>,
|
|
46
|
+
settings?: CustomArraySettings,
|
|
47
|
+
): Record<string, string>[]
|
|
55
48
|
|
|
56
49
|
export function customList(
|
|
57
50
|
key?: CountryProperty,
|
|
58
51
|
label?: string,
|
|
59
52
|
settings?: CustomArraySettings,
|
|
60
|
-
): { [CountryProperty]: string }
|
|
53
|
+
): { [key in CountryProperty]: string }
|
|
61
54
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "country-codes-list",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.12",
|
|
4
4
|
"description": "List of codes per country (languages, calling codes, currency codes, etc)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\"
|
|
8
|
+
"test": "echo \"Error: no test specified\""
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
"url": "https://github.com/LucianoGanga/country-codes/issues"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/LucianoGanga/country-codes#readme"
|
|
37
|
-
}
|
|
37
|
+
}
|