New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@jbreneman/country-state-list

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jbreneman/country-state-list

A package optimized for bundle splitting country/state data

  • 1.0.8
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Country State List

This project generates a more browser friendly npm package based on countryjs.

Installing

npm i @jbreneman/country-state-list

Usage

import { getCountries } from '@jbreneman/country-state-list';

To get a list of all countries with states, you can run getCountries() without any arguments:

const countries = getCountries();
/* Returns an array that looks like:
[{
    "name": "United States",
    "code": "US",
    "states": ["Alabama", ...]
}, ...]
*/

You can optionally pass in an array of country codes (2 letter ISO code) and get a filtered list that should knock your bundle size down:

const countries = getCountries(['us', 'ca', 'mx']);
/* Returns an array that only includes these 3 countries
*/

To get an individual country, you can pull in the getCountry() method and use that instead. It accepts a single countryCode parameter and outputs a single country object:

const US = getCountry('us');
/* Returns:
{
    "name": "United States",
    "code": "US",
    "states": ["Alabama", ...]
}
*/

Build

To rebuild the index, run npm run compile. This will regenerate the entire dist folder.

Contributing

Submit a PR.

FAQs

Package last updated on 30 Oct 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