# lazy-country-city-state

> This is the library to process country city state.

Latest version **0.0.4** (published 2021-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install lazy-country-city-state
pnpm add lazy-country-city-state
yarn add lazy-country-city-state
bun add lazy-country-city-state
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2021-02-26 |
| First published | 2021-02-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ursa |

## Links

- npm: https://www.npmjs.com/package/lazy-country-city-state
- npm.io page: https://npm.io/package/lazy-country-city-state

## Recent versions

- 0.0.4 (latest) — 2021-02-26
- 0.0.3 — 2021-02-26
- 0.0.2 — 2021-02-26
- 0.0.1 — 2021-02-26

## README

This is the library to process country city state.

Basic library for Country, State and City

**Data Source:**

It's a customization of https://github.com/harpreetkhalsagtbit/country-state-city/tree/master/lib

### Lazy load to use

Due to its size, we need to lazy load it. But don't worry, we have a hook to do that. Just put it in the component that you want to use the lazyLoad.

```
import { useLazyLoad } from 'lazy-country-city-state';
```

```
  const { ready: countryReady } = useLazyLoad('country');
  const { ready: stateReady } = useLazyLoad('state');
  const { ready: cityReady } = useLazyLoad('city');
```

**Note:** If you want to use it outside of the component, please using `loadData`

```
import { loadData } from 'lazy-country-city-state';
```


### Docs
# Docs

getCountryByCode(code)
---------------

It accepts a valid `CountryCode` eg: `'AS'` and   returns *Country Details*

type: **json | ICountry**

```js
{
	"isoCode": "IN",
	"name": "India",
	"phonecode": "91",
	"flag": "🇮🇳",
	"currency": "INR",
	"latitude": "20.00000000",
	"longitude": "77.00000000",
	"timezones": [
		{
			"zoneName": "Asia\/Kolkata",
			"gmtOffset": 19800,
			"gmtOffsetName": "UTC+05:30",
			"abbreviation": "IST",
			"tzName": "Indian Standard Time"
		}
	]
}
```

getStatesOfCountry(countryCode)
---------------

It accepts a valid `CountryCode` and returns *all States* as Array of JSON

type: **array of json | IState**

```js
[
	{
		"name": "Delhi",
		"isoCode": "DL",
		"countryCode": "IN",
		"latitude": "28.70405920",
		"longitude": "77.10249020"
	}
]

```
getCitiesOfState(countryCode, stateCode)
---------------

It accepts a valid `CountryCode`, `StateCode` and returns *all Cities* as Array of JSON

type: **array of json | ICity**

```js
[
	{
		"name": "New Delhi",
		"countryCode": "IN",
		"stateCode": "DL",
		"latitude": "28.63576000",
		"longitude": "77.22445000"
	}
]

```

getCitiesOfCountry(countryCode)
---------------

It accepts a valid `CountryCode` and returns *all Cities* as Array of JSON

type: **array of json | ICity**

```js
[
	{
		"name": "New Delhi",
		"countryCode": "IN",
		"stateCode": "DL",
		"latitude": "28.63576000",
		"longitude": "77.22445000"
	}
]

```

getAllCountries
---------------
It returns **all Countries**

type: **array of json | ICountry**

```js
[
	{
		"isoCode": "IN",
		"name": "India",
		"phonecode": "91",
		"flag": "🇮🇳",
		"currency": "INR",
		"latitude": "20.00000000",
		"longitude": "77.00000000",
		"timezones": [
			{
				"zoneName": "Asia\/Kolkata",
				"gmtOffset": 19800,
				"gmtOffsetName": "UTC+05:30",
				"abbreviation": "IST",
				"tzName": "Indian Standard Time"
			}
		]
	}
]
```

getAllStates
---------------
It returns **all States**

type: **array of json | IState**

```js
[
	{
		"name": "Delhi",
		"isoCode": "DL",
		"countryCode": "IN",
		"latitude": "28.70405920",
		"longitude": "77.10249020"

	}
]
```

getAllCities
---------------
It returns **all Cities**

type: **array of json | ICity**

```js
[
	{
		"name": "Delhi",
		"isoCode": "DL",
		"countryCode": "IN",
		"latitude": "28.70405920",
		"longitude": "77.10249020"
	}
]
```

*** Contribution guide ***

- Update new data source from It's a customization of https://github.com/harpreetkhalsagtbit/country-state-city/tree/master/lib


- change the `processData.js` if needed

- Run command

```
yarn processData
```

- Copy all files in `build` folder to `public` folder

---
_Source: https://npm.io/package/lazy-country-city-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
