Skip to content

Commit

Permalink
Merge pull request #15 from harpreetkhalsagtbit/add-type-interfaces
Browse files Browse the repository at this point in the history
Add: Type Interface for methods returning Country, State , City inste…
  • Loading branch information
harpreetkhalsagtbit authored May 27, 2019
2 parents 51702b9 + c25e734 commit d2d8ac3
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 207 deletions.
51 changes: 42 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,37 @@ https://github.com/hiiamrohit/Countries-States-Cities-database
# Install
`npm i country-state-city`

# Usage

## Latest Release : `v1.0.0` (First Major Version Release - Not backword compatible)
- ES6 Module usage

`import csc from 'country-state-city'`

- AMD Module usage

`let csc = require('country-state-city').default`


## For versions `v0.1.8 and below`

- ES6 Module usage

`import csc from 'country-state-city'`

- AMD Module usage

`let csc = require('country-state-city')`


# Docs

getCountryById(id)
---------------

It accepts a valid `CountryId` and returns *Country Details*

type: *json*
type: **json | ICountry**

```js
{
Expand All @@ -32,7 +55,7 @@ getStateById(id)

It accepts a valid `StateId` and returns *State Details*

type: *json*
type: **json | IState**

```js
{
Expand All @@ -47,7 +70,7 @@ getCityById(id)

It accepts a valid `CityId` and returns *City Details*

type: *json*
type: **json | ICity**

```js
{
Expand All @@ -62,7 +85,7 @@ getStatesOfCountry(countryId)

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

type: *array of json*
type: **array of json | IState**

```js
[
Expand All @@ -79,7 +102,7 @@ getCitiesOfState(stateId)

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

type: *array of json*
type: **array of json | ICity**

```js
[
Expand All @@ -94,9 +117,9 @@ type: *array of json*

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

type: *array of json*
type: **array of json | ICountry**

```js
[
Expand All @@ -117,10 +140,20 @@ Special Thanks
Change Logs
---------------

**V0.1.8**
**v1.0.0**

1. `export = {}` changed to `export default` in index.ts.
2. `Interface` type `re-exported` from `index.ts`.
3. `Compatible` with `ES6` module syntax.
4. `Compatible` with `AMD` module - using `require('../index').default`.
5. Add tests for Interface Re-Exports.
6. Test cases for both AMD modules and ES6 modules usage.
7. Common Test Cases are being shared between AMD and ES6 modules test files.

**v0.1.8**
1. Development code - Javascript to Typescript conversion: [#12](https://github.com/harpreetkhalsagtbit/country-state-city/pull/12)

**V0.1.0**
**v0.1.0**
1. Fix: [#2](https://github.com/harpreetkhalsagtbit/country-state-city/issues/2)
2. Fix: [#3](https://github.com/harpreetkhalsagtbit/country-state-city/issues/3)
3. Added some missing states and cities for Canada and US
4 changes: 4 additions & 0 deletions __test__/amdModule.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let csc = require('../index').default;

let executeAllTests = require('./index.test').default;
executeAllTests(csc)
Loading

0 comments on commit d2d8ac3

Please sign in to comment.