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

country-state-picker

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

country-state-picker

NPM package to get the list of countries and their states.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-59.84%
Maintainers
1
Weekly downloads
 
Created
Source

Country State Picker

NPM package to get the list of countries and their states.

Installation

npm i country-state-picker --save

Usage

getCountries()

This function will return the array of all the countries.

Output
[
    {
        name: 'Afghanistan',
        code: 'af'
    },
    {
      name: 'Albania',
      code: 'al'
    },
    {
      name: 'Algeria',
      code: 'dz'
    },
    {
      name: 'Andorra',
      code: 'ad'
    }
  ...
]

getStates(<country_code>)

This function will return the array of all the states of a given country.

Example

To get the list of all the states of INDIA, the function call will look like:

let states = getStates('in');

console.log(states)
Output
[
    "Assam",
    "Goa",
    "Madhya Pradesh",
    "Manipur",
    "Meghalaya",
    "Mizoram",
    "National Capital Territory of Delhi",
    "Sikkim",
    "State of Andhra Pradesh",
    "State of Arunachal Pradesh",
    "State of Bihar",
    "State of Chhattisgarh",
    "State of Gujarat",
    "State of Haryana",
    "State of Himachal Pradesh",
    "State of Jammu and Kashmir",
    "State of Jharkhand",
    "State of Karnataka",
    "State of Kerala",
    "State of Maharashtra",
    "State of Nagaland",
    "State of Odisha",
    "State of Punjab",
    "State of Rajasthan",
    "State of Tamil Nad",
    "State of Uttarakhand",
    "Telangana",
    "Tripura",
    "Union Territory of Andaman and Nicobar Islands",
    "Union Territory of Chandigarh",
    "Union Territory of Dadra and Nagar Haveli",
    "Union Territory of Daman and Di",
    "Union Territory of Lakshadweep",
    "Union Territory of Puducherry",
    "Uttar Pradesh",
    "West Bengal"
]

Keywords

FAQs

Package last updated on 14 Aug 2019

Did you know?

Socket

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.

Install

Related posts

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