Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

world-information

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

world-information - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

json/states.json

23

index.js
const continentList = require("./json/continents.json");
const countryList = require("./json/countries.json");
const stateList = require("./json/states.json");

@@ -14,6 +15,21 @@ /**

const getCountryByContinentName = (continent) => {
return countryList.filter((country) => country.continent === continent);
return countryList.filter((country) => country.continent?.toLowerCase() === continent.toLowerCase());
}
/**
* Get states by country name
* @param {('Afghanistan' | 'Albania' | 'Algeria' | 'Andorra' | 'Angola' | 'Antigua and Barbuda' | 'Argentina' | 'Armenia' | 'Australia' | 'Austria' | 'Azerbaijan' | 'Bahamas' | 'Bahrain' | 'Bangladesh' | 'Barbados' | 'Belarus' | 'Belgium' | 'Belize' | 'Benin' | 'Bhutan' | 'Bolivia' | 'Bosnia and Herzegovina' | 'Botswana' | 'Brazil' | 'Brunei' | 'Bulgaria' | 'Burkina Faso' | 'Burundi' | 'Cabo Verde' | 'Cambodia' | 'Cameroon' | 'Canada' | 'Central African Republic' | 'Chad' | 'Chile' | 'China' | 'Colombia' | 'Comoros' | 'Congo' | 'Costa Rica' | 'Croatia' | 'Cuba' | 'Cyprus' | 'Czech Republic' | 'Denmark' | 'Djibouti' | 'Dominica' | 'Dominican Republic' | 'Ecuador' | 'Egypt' | 'El Salvador' | 'Equatorial Guinea' | 'Eritrea' | 'Estonia' | 'Eswatini' | 'Ethiopia' | 'Fiji' | 'Finland' | 'France' | 'Gabon' | 'Gambia' | 'Georgia' | 'Germany' | 'Ghana' | 'Greece' | 'Grenada' | 'Guatemala' | 'Guinea' | 'Guinea-Bissau' | 'Guyana' | 'Haiti' | 'Honduras' | 'Hungary' | 'Iceland' | 'India' | 'Indonesia' | 'Iran' | 'Iraq' | 'Ireland' | 'Israel' | 'Italy' | 'Jamaica' | 'Japan' | 'Jordan' | 'Kazakhstan' | 'Kenya' | 'Kiribati' | 'Korea, North' | 'Korea, South' | 'Kuwait' | 'Kyrgyzstan' | 'Laos' | 'Latvia' | 'Lebanon' | 'Lesotho' | 'Liberia' | 'Libya' | 'Liechtenstein' | 'Lithuania' | 'Luxembourg' | 'Madagascar' | 'Malawi' | 'Malaysia' | 'Maldives' | 'Mali' | 'Malta' | 'Marshall Islands' | 'Mauritania' | 'Mauritius' | 'Mexico' | 'Micronesia' | 'Moldova' | 'Monaco' | 'Mongolia' | 'Montenegro' | 'Morocco' | 'Mozambique' | 'Myanmar' | 'Namibia' | 'Nauru' | 'Nepal' | 'Netherlands' | 'New Zealand' | 'Nicaragua' | 'Niger' | 'Nigeria' | 'North Macedonia' | 'Norway' | 'Oman' | 'Pakistan' | 'Palau' | 'Panama' | 'Papua New Guinea' | 'Paraguay' | 'Peru' | 'Philippines' | 'Poland' | 'Portugal' | 'Qatar' | 'Romania' | 'Russia' | 'Rwanda' | 'Saint Kitts and Nevis' | 'Saint Lucia' | 'Saint Vincent and the Grenadines' | 'Samoa' | 'San Marino' | 'Sao Tome and Principe' | 'Saudi Arabia' | 'Senegal' | 'Serbia' | 'Seychelles' | 'Sierra Leone' | 'Singapore' | 'Slovakia' | 'Slovenia' | 'Solomon Islands' | 'Somalia' | 'South Africa' | 'South Sudan' | 'Spain' | 'Sri Lanka' | 'Sudan' | 'Suriname' | 'Sweden' | 'Switzerland' | 'Syria' | 'Taiwan' | 'Tajikistan' | 'Tanzania' | 'Thailand' | 'Timor-Leste' | 'Togo' | 'Tonga' | 'Trinidad and Tobago' | 'Tunisia' | 'Turkey' | 'Turkmenistan' | 'Tuvalu' | 'Uganda' | 'Ukraine' | 'United Arab Emirates' | 'United Kingdom' | 'United States' | 'Uruguay' | 'Uzbekistan' | 'Vanuatu' | 'Vatican City' | 'Venezuela' | 'Vietnam' | 'Yemen' | 'Zambia' | 'Zimbabwe')} country - The name of the country
* @returns {Object[]} Array of states in the given country
* @typedef {Object} State
* @property {string} name - The name of the state
* @property {string} code - The ISO code of the state
* @property {string} country - The country where the state is located
*/
const getStateByCountryName = (country) => {
return stateList.filter((state) => state.country?.toLowerCase() === country.toLowerCase());
}
module.exports = {

@@ -24,3 +40,6 @@ /* GET A LIST OF CONTINENTS */

countryList,
getCountryByContinentName
/* GET A LIST OF COUNTRIES */
stateList,
getCountryByContinentName,
getStateByCountryName
}

8

json/countries.json

@@ -40,4 +40,4 @@ [

{ "name": "Comoros", "alpha-2": "KM", "alpha-3": "COM", "numeric": "174", "continent": "Africa" },
{ "name": "Congo, Democratic Republic of the", "alpha-2": "CD", "alpha-3": "COD", "numeric": "180", "continent": "Africa" },
{ "name": "Congo, Republic of the", "alpha-2": "CG", "alpha-3": "COG", "numeric": "178", "continent": "Africa" },
{ "name": "Democratic Republic of the Congo", "alpha-2": "CD", "alpha-3": "COD", "numeric": "180", "continent": "Africa" },
{ "name": "Republic of the Congo", "alpha-2": "CG", "alpha-3": "COG", "numeric": "178", "continent": "Africa" },
{ "name": "Costa Rica", "alpha-2": "CR", "alpha-3": "CRI", "numeric": "188", "continent": "North America" },

@@ -91,4 +91,4 @@ { "name": "Croatia", "alpha-2": "HR", "alpha-3": "HRV", "numeric": "191", "continent": "Europe" },

{ "name": "Kiribati", "alpha-2": "KI", "alpha-3": "KIR", "numeric": "296", "continent": "Oceania" },
{ "name": "Korea, North", "alpha-2": "KP", "alpha-3": "PRK", "numeric": "408", "continent": "Asia" },
{ "name": "Korea, South", "alpha-2": "KR", "alpha-3": "KOR", "numeric": "410", "continent": "Asia" },
{ "name": "North Korea", "alpha-2": "KP", "alpha-3": "PRK", "numeric": "408", "continent": "Asia" },
{ "name": "South Korea", "alpha-2": "KR", "alpha-3": "KOR", "numeric": "410", "continent": "Asia" },
{ "name": "Kuwait", "alpha-2": "KW", "alpha-3": "KWT", "numeric": "414", "continent": "Asia" },

@@ -95,0 +95,0 @@ { "name": "Kyrgyzstan", "alpha-2": "KG", "alpha-3": "KGZ", "numeric": "417", "continent": "Asia" },

{
"name": "world-information",
"version": "0.0.4",
"version": "0.0.5",
"author": "harish",

@@ -16,6 +16,16 @@ "description": "world-information is a comprehensive npm package designed to provide detailed geographical information. It includes data on continents, countries, states, and cities, making it an essential tool for applications that require location-based data.",

"keywords": [
"CONTINENTS",
"COUNTRIES",
"STATES",
"CITIES"
"world",
"global",
"countries",
"capitals",
"geography",
"data",
"information",
"country-codes",
"world-data",
"international",
"geolocation",
"regions",
"metadata",
"API"
],

@@ -22,0 +32,0 @@ "license": "ISC",

@@ -24,3 +24,5 @@ ## WORLD INFORMATION

Country array
State array
getCountryByContinentName(continentName);
getStateByCountryName(countryName);

@@ -30,5 +32,3 @@

States
Cities
getStatesByCountryName(countryName);
getCitiesByStateName(stateName);

@@ -84,3 +84,5 @@

/*
Make sure the argument name is one of the below continent. I have also configured the JSDoc Annotations, So you will get the suggestions too.
Make sure the argument name is one of the below continent.
I have also configured the JSDoc Annotations, So you will get the suggestions too.
The argument value(continent name) is case insensitive.
'Africa' | 'Antarctica' | 'Asia' | 'Europe' | 'North America' | 'Oceania' | 'South America'

@@ -99,2 +101,26 @@ */

##### EXAMPLE TO FILTER STATE LIST BY COUNTRY NAME :
const {getStateByCountryName} = require("world-information");
/*
Make sure the argument name is one of the below country.
I have also configured the JSDoc Annotations, So you will get the suggestions too.
The argument value(country name) is case insensitive.
'Afghanistan' | 'Albania' | 'Algeria' | 'Andorra' | 'Angola' | 'Antigua and Barbuda' | 'Argentina' | 'Armenia' | 'Australia' | 'Austria' | 'Azerbaijan' | 'Bahamas' | 'Bahrain' | 'Bangladesh' | 'Barbados' | 'Belarus' | 'Belgium' | 'Belize' | 'Benin' | 'Bhutan' | 'Bolivia' | 'Bosnia and Herzegovina' | 'Botswana' | 'Brazil' | 'Brunei' | 'Bulgaria' | 'Burkina Faso' | 'Burundi' | 'Cabo Verde' | 'Cambodia' | 'Cameroon' | 'Canada' | 'Central African Republic' | 'Chad' | 'Chile' | 'China' | 'Colombia' | 'Comoros' | 'Congo' | 'Costa Rica' | 'Croatia' | 'Cuba' | 'Cyprus' | 'Czech Republic' | 'Denmark' | 'Djibouti' | 'Dominica' | 'Dominican Republic' | 'Ecuador' | 'Egypt' | 'El Salvador' | 'Equatorial Guinea' | 'Eritrea' | 'Estonia' | 'Eswatini' | 'Ethiopia' | 'Fiji' | 'Finland' | 'France' | 'Gabon' | 'Gambia' | 'Georgia' | 'Germany' | 'Ghana' | 'Greece' | 'Grenada' | 'Guatemala' | 'Guinea' | 'Guinea-Bissau' | 'Guyana' | 'Haiti' | 'Honduras' | 'Hungary' | 'Iceland' | 'India' | 'Indonesia' | 'Iran' | 'Iraq' | 'Ireland' | 'Israel' | 'Italy' | 'Jamaica' | 'Japan' | 'Jordan' | 'Kazakhstan' | 'Kenya' | 'Kiribati' | 'Korea, North' | 'Korea, South' | 'Kuwait' | 'Kyrgyzstan' | 'Laos' | 'Latvia' | 'Lebanon' | 'Lesotho' | 'Liberia' | 'Libya' | 'Liechtenstein' | 'Lithuania' | 'Luxembourg' | 'Madagascar' | 'Malawi' | 'Malaysia' | 'Maldives' | 'Mali' | 'Malta' | 'Marshall Islands' | 'Mauritania' | 'Mauritius' | 'Mexico' | 'Micronesia' | 'Moldova' | 'Monaco' | 'Mongolia' | 'Montenegro' | 'Morocco' | 'Mozambique' | 'Myanmar' | 'Namibia' | 'Nauru' | 'Nepal' | 'Netherlands' | 'New Zealand' | 'Nicaragua' | 'Niger' | 'Nigeria' | 'North Macedonia' | 'Norway' | 'Oman' | 'Pakistan' | 'Palau' | 'Panama' | 'Papua New Guinea' | 'Paraguay' | 'Peru' | 'Philippines' | 'Poland' | 'Portugal' | 'Qatar' | 'Romania' | 'Russia' | 'Rwanda' | 'Saint Kitts and Nevis' | 'Saint Lucia' | 'Saint Vincent and the Grenadines' | 'Samoa' | 'San Marino' | 'Sao Tome and Principe' | 'Saudi Arabia' | 'Senegal' | 'Serbia' | 'Seychelles' | 'Sierra Leone' | 'Singapore' | 'Slovakia' | 'Slovenia' | 'Solomon Islands' | 'Somalia' | 'South Africa' | 'South Sudan' | 'Spain' | 'Sri Lanka' | 'Sudan' | 'Suriname' | 'Sweden' | 'Switzerland' | 'Syria' | 'Taiwan' | 'Tajikistan' | 'Tanzania' | 'Thailand' | 'Timor-Leste' | 'Togo' | 'Tonga' | 'Trinidad and Tobago' | 'Tunisia' | 'Turkey' | 'Turkmenistan' | 'Tuvalu' | 'Uganda' | 'Ukraine' | 'United Arab Emirates' | 'United Kingdom' | 'United States' | 'Uruguay' | 'Uzbekistan' | 'Vanuatu' | 'Vatican City' | 'Venezuela' | 'Vietnam' | 'Yemen' | 'Zambia' | 'Zimbabwe'
*/
// Get a list of states in india
const indianStates = getStateByCountryName("India");
console.log(indianStates);
// Output (sample)
[
{name: 'Andhra Pradesh', code: 'IN-AP', country: 'India'},
{name: 'Arunachal Pradesh', code: 'IN-AR', country: 'India'},
...
{name: 'Puducherry', code: 'IN-PY', country: 'India'}
]
#### CONTRIBUTING:

@@ -101,0 +127,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc