cs-list
v1.0.5
Published
Country States list
Downloads
181
Readme
countries-and-states
Get list of countries and list of states per country worldwide
Installation
yarn add cs-list
# or
npm install cs-list
Types
type Country = {
name: string,
code: string
}
type State = {
name: string,
code: string,
countryCode: string
}
Methods
getCountries() => Country[]
getStates() => State[]
getStatesByCode(countryCode: string) => State[]
getStatesByName(countryName: string) => State[]
Usage
- Get countries list
import { getCountries } from "cs-list";
const countries = getCountries();
- Get states list
import { getStates } from "cs-list";
const states = getStates();
- By country code
import { getStatesByCode } from "cs-list";
const australiaStates = getStatesByCode("AU");
- By country name
import { getStatesByName } from "cs-list";
const philippineStates = getStatesByName("Philippines");
/** Not case-sensitive
* const philippineStates = getStatesByName("philPPiNeS") -> WILL WORK;
*/
Made with ❤️ and ☕ by Prince Carlo Juguilon