country-state-city
Advanced tools
Comparing version 0.1.8 to 1.0.0
@@ -0,22 +1,11 @@ | ||
import { ICountry, ICity, IState } from './src/interface'; | ||
export { ICountry, ICity, IState } from './src/interface'; | ||
declare const _default: { | ||
getCountryById: (id: string) => any; | ||
getStateById: (id: string) => any; | ||
getCityById: (id: string) => any; | ||
getStatesOfCountry: (countryId: string) => { | ||
"id": string; | ||
"name": string; | ||
"country_id": string; | ||
}[]; | ||
getCitiesOfState: (stateId: string) => { | ||
"id": string; | ||
"name": string; | ||
"state_id": string; | ||
}[]; | ||
getAllCountries: () => { | ||
"id": string; | ||
"sortname": string; | ||
"name": string; | ||
"phonecode": string; | ||
}[]; | ||
getCountryById: (id: string) => ICountry; | ||
getStateById: (id: string) => IState; | ||
getCityById: (id: string) => ICity; | ||
getStatesOfCountry: (countryId: string) => IState[]; | ||
getCitiesOfState: (stateId: string) => ICity[]; | ||
getAllCountries: () => ICountry[]; | ||
}; | ||
export = _default; | ||
export default _default; |
@@ -5,21 +5,7 @@ "use strict"; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var country_json_1 = __importDefault(require("./lib/country.json")); | ||
var state_json_1 = __importDefault(require("./lib/state.json")); | ||
var city_json_1 = __importDefault(require("./lib/city.json")); | ||
var _findEntry = function (source, id) { | ||
if (id && source != null) { | ||
var idx = source.findIndex(function (c) { return c.id === id; }); | ||
return (idx !== -1) ? source[idx] : ""; | ||
} | ||
else | ||
return ""; | ||
}; | ||
function compare(a, b) { | ||
if (a.name < b.name) | ||
return -1; | ||
if (a.name > b.name) | ||
return 1; | ||
return 0; | ||
} | ||
module.exports = { | ||
exports.default = { | ||
getCountryById: function (id) { | ||
@@ -50,1 +36,16 @@ return _findEntry(country_json_1.default, id); | ||
}; | ||
var _findEntry = function (source, id) { | ||
if (id && source != null) { | ||
var idx = source.findIndex(function (c) { return c.id === id; }); | ||
return (idx !== -1) ? source[idx] : ""; | ||
} | ||
else | ||
return ""; | ||
}; | ||
function compare(a, b) { | ||
if (a.name < b.name) | ||
return -1; | ||
if (a.name > b.name) | ||
return 1; | ||
return 0; | ||
} |
{ | ||
"name": "country-state-city", | ||
"version": "0.1.8", | ||
"version": "1.0.0", | ||
"description": "Library for fetching Country, its States and Cities", | ||
@@ -44,3 +44,4 @@ "main": "dist/index.js", | ||
"typescript": "^3.4.5" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -12,2 +12,25 @@ 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 | ||
@@ -20,3 +43,3 @@ | ||
type: *json* | ||
type: **json | ICountry** | ||
@@ -37,3 +60,3 @@ ```js | ||
type: *json* | ||
type: **json | IState** | ||
@@ -53,3 +76,3 @@ ```js | ||
type: *json* | ||
type: **json | ICity** | ||
@@ -69,3 +92,3 @@ ```js | ||
type: *array of json* | ||
type: **array of json | IState** | ||
@@ -87,3 +110,3 @@ ```js | ||
type: *array of json* | ||
type: **array of json | ICity** | ||
@@ -103,5 +126,5 @@ ```js | ||
--------------- | ||
It returns *all Countries* | ||
It returns **all Countries** | ||
type: *array of json* | ||
type: **array of json | ICountry** | ||
@@ -127,8 +150,18 @@ ```js | ||
**V0.1.3** | ||
**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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8407890
15
287301
0
160
0