Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
country-state-picker
Advanced tools
NPM package to get the list of countries and their states.
npm i country-state-picker --save
getCountries()
This function will return the array of all the countries.
[
{
"name": "Afghanistan",
"code": "af",
"dial_code": "+93"
},
{
"name": "Albania",
"code": "al",
"dial_code": "+355"
},
{
"name": "Algeria",
"code": "dz",
"dial_code": "+213"
},
{
"name": "Andorra",
"code": "ad",
"dial_code": "+376"
}
...
]
getStates(<country_code>)
This function will return the array of all the states of a given country.
To get the list of all the states of INDIA, the function call will look like:
let states = getStates('in');
console.log(states)
[
"Assam",
"Goa",
"Madhya Pradesh",
"Manipur",
"Meghalaya",
"Mizoram",
"National Capital Territory of Delhi",
"Sikkim",
"Andhra Pradesh",
"Arunachal Pradesh",
"Bihar",
"Chhattisgarh",
"Gujarat",
"Haryana",
"Himachal Pradesh",
"Jammu and Kashmir",
"Jharkhand",
"Karnataka",
"Kerala",
"Maharashtra",
"Nagaland",
"Odisha",
"Punjab",
"Rajasthan",
"Tamil Nad",
"Uttarakhand",
"Telangana",
"Tripura",
"Andaman and Nicobar Islands",
"Chandigarh",
"Dadra and Nagar Haveli",
"Daman and Di",
"Lakshadweep",
"Puducherry",
"Uttar Pradesh",
"West Bengal"
]
getCountry(<country_name | country_code | dial_code>)
This function will return the country corresponding to the argument passed.
To get the country having dial code "+91", the function call will look like:
let country = getCountry('+91');
console.log(country)
{
"name": "India",
"code": "in",
"dial_code": "+91"
}
getFilteredCountries([<country_name | country_code | dial_code>])
This function will receive an array of arguments and return the array of countries corresponding to the argument.
To get only India, USA and Australia country objects, the function call will look like:
let filteredCountries = getFilteredCountries(['+91', 'us', 'Australia']);
console.log(filteredCountries)
[
{
"name": "India",
"code": "in",
"dial_code": "+91"
},
{
"name": "United States of America",
"code": "us",
"dial_code": "+1"
},
{
"name": "Australia",
"code": "au",
"dial_code": "+61"
}
]
FAQs
NPM package to get the list of countries and their states.
The npm package country-state-picker receives a total of 2,178 weekly downloads. As such, country-state-picker popularity was classified as popular.
We found that country-state-picker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.