Gathering detailed insights and metrics for iso3166-lookup
Gathering detailed insights and metrics for iso3166-lookup
Gathering detailed insights and metrics for iso3166-lookup
Gathering detailed insights and metrics for iso3166-lookup
ISO 3166-1:2020 country and codes lookup. The supported country code types are alpha-2, alpha-3 and num-3.
npm install iso3166-lookup
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
40,274
Last Day
48
Last Week
266
Last Month
1,133
Last Year
19,906
4 Stars
27 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
iso3166-lookup@1.1.0
Unpacked Size
78.95 kB
Size
14.95 kB
File Count
14
NPM Version
8.11.0
Node Version
16.15.1
Cumulative downloads
Total Downloads
Last day
45.5%
48
Compared to previous day
Last week
-2.9%
266
Compared to previous week
Last month
-11.8%
1,133
Compared to previous month
Last year
10.9%
19,906
Compared to previous year
7
ISO 3166-1:2020 country and codes lookup. The supported country code types are alpha-2, alpha-3 and num-3.
Install using npm
1npm install iso3166-lookup
Using ISO 3166-1:2020 Codes lookup package into your code (import / require)
1import iso3166Lookup from "iso3166-lookup";
OR
1const iso3166Lookup = require('iso3166-lookup');
Get all countries
1console.log(iso3166Lookup.getAllCountries()); 2/** Returns: 3 [ 4 { 5 alpha2: "AD", 6 alpha3: "AND", 7 country: "Andorra", 8 num3: "020", 9 }, 10 { 11 alpha2: "AE", 12 alpha3: "ARE", 13 country: "United Arab Emirates", 14 num3: "784", 15 },... 16 ] 17*/
Get all Country Names
1console.log(iso3166Lookup.getAllCountryNames()); 2/** Returns: 3 [ 4 "Andorra", "United Arab Emirates",... 5 ] 6*/
Get all Alpha-2 Codes
1console.log(iso3166Lookup.getAllAlpha2()); 2/** Returns: 3 [ 4 "AD", "AE",... 5 ] 6*/
Get all Alpha-3 Codes
1console.log(iso3166Lookup.getAllAlpha2()); 2/** Returns: 3 [ 4 "AND", "ARE",... 5 ] 6*/
Find country details by country name
1console.log(iso3166Lookup.findCountry('India')); 2/** Returns: 3 { 4 country: 'India', 5 alpha2: 'IN', 6 alpha3: 'IND', 7 numeric: '356' 8 } 9*/
Find country details by ISO 3166-1 Alpha-2
1console.log(iso3166Lookup.findAlpha2('in')); 2/** Returns: 3 { 4 country: 'India', 5 alpha2: 'IN', 6 alpha3: 'IND', 7 numeric: '356' 8 } 9*/
Find country details by ISO 3166-1 Alpha-3
1console.log(iso3166Lookup.findAlpha3('ind')); 2/** Returns: 3 { 4 country: 'India', 5 alpha2: 'IN', 6 alpha3: 'IND', 7 numeric: '356' 8 } 9*/
Find country details by ISO 3166-1 Num-3 (Numeric)
1console.log(iso3166Lookup.findNum3(356)); 2/** Returns: 3 { 4 country: 'India', 5 alpha2: 'IN', 6 alpha3: 'IND', 7 numeric: '356' 8 } 9*/
Specify Return/Output types for find functions
You can optionally pass second param to find functions (viz. - findCountry, findAlpha2, findAlpha3, findNum3) to specify desired output format. By default functions will return country object if the parameter is not supplied. You can specify any value from the following: "obj", "name", "alpha2", "alpha3", "num3".
For example you can specify "name" to recieve output Country name as string or can specify "obj" to get Country object in return.
1console.log(iso3166Lookup.findCountry("india")); // will return country object for India 2console.log(iso3166Lookup.findCountry("india", "obj")); // will return country object for India 3console.log(iso3166Lookup.findAlpha2("in", "name")); // will return "India" 4console.log(iso3166Lookup.findAlpha3("ind", "alpha2")); // will return "IN" 5console.log(iso3166Lookup.findNum3(356, "alpha3")); // will return "IND" 6console.log(iso3166Lookup.findCountry("india", "num3")); // will return "356"
You can check following links for more information:
MIT License Copyright (c) 2022 Omkar Tapale
No vulnerabilities found.
No security vulnerabilities found.