country-state-city
Advanced tools
Comparing version 2.2.0 to 3.0.0
@@ -1,14 +0,6 @@ | ||
import { ICountry, ICity, IState } from './src/interface'; | ||
export { ICountry, ICity, IState } from './src/interface'; | ||
declare const _default: { | ||
getStatesOfCountry(countryCode: string): IState[]; | ||
getCitiesOfState(countryCode: string, stateCode: string): ICity[]; | ||
getCitiesOfCountry(countryCode: string): ICity[]; | ||
getAllCountries(): ICountry[]; | ||
getAllStates(): IState[]; | ||
getAllCities(): ICity[]; | ||
getCountryByCode(isoCode: string): ICountry; | ||
getStateByCode(isoCode: string): IState; | ||
getStateByCodeAndCountry(isoCode: string, countryCode: string): IState; | ||
}; | ||
export default _default; | ||
import Country from './lib/country'; | ||
import State from './lib/state'; | ||
import City from './lib/city'; | ||
export { Country }; | ||
export { State }; | ||
export { City }; |
@@ -6,70 +6,8 @@ "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 _findEntryByCode = function (source, code) { | ||
if (code && source != null) { | ||
var codex = source.findIndex(function (c) { | ||
return c.isoCode === code; | ||
}); | ||
return codex !== -1 ? source[codex] : ''; | ||
} | ||
return ''; | ||
}; | ||
var _findStateByCodeAndCountryCode = function (source, code, countryCode) { | ||
if (code && countryCode && source != null) { | ||
var codex = source.findIndex(function (c) { | ||
return c.isoCode === code && c.countryCode === countryCode; | ||
}); | ||
return codex !== -1 ? source[codex] : ''; | ||
} | ||
return ''; | ||
}; | ||
var compare = function (a, b) { | ||
if (a.name < b.name) | ||
return -1; | ||
if (a.name > b.name) | ||
return 1; | ||
return 0; | ||
}; | ||
exports.default = { | ||
getStatesOfCountry: function (countryCode) { | ||
var states = state_json_1.default.filter(function (value) { | ||
return value.countryCode === countryCode; | ||
}); | ||
return states.sort(compare); | ||
}, | ||
getCitiesOfState: function (countryCode, stateCode) { | ||
var cities = city_json_1.default.filter(function (value) { | ||
return value.countryCode === countryCode && value.stateCode === stateCode; | ||
}); | ||
return cities.sort(compare); | ||
}, | ||
getCitiesOfCountry: function (countryCode) { | ||
var cities = city_json_1.default.filter(function (value) { | ||
return value.countryCode === countryCode; | ||
}); | ||
return cities.sort(compare); | ||
}, | ||
getAllCountries: function () { | ||
return country_json_1.default; | ||
}, | ||
getAllStates: function () { | ||
return state_json_1.default; | ||
}, | ||
getAllCities: function () { | ||
return city_json_1.default; | ||
}, | ||
getCountryByCode: function (isoCode) { | ||
return _findEntryByCode(country_json_1.default, isoCode); | ||
}, | ||
// to be deprecate | ||
getStateByCode: function (isoCode) { | ||
// eslint-disable-next-line no-console | ||
console.warn("WARNING! 'getStateByCode' has been deprecated, please use the new 'getStateByCodeAndCountry' function instead!"); | ||
return _findEntryByCode(state_json_1.default, isoCode); | ||
}, | ||
getStateByCodeAndCountry: function (isoCode, countryCode) { | ||
return _findStateByCodeAndCountryCode(state_json_1.default, isoCode, countryCode); | ||
}, | ||
}; | ||
exports.City = exports.State = exports.Country = void 0; | ||
var country_1 = __importDefault(require("./lib/country")); | ||
exports.Country = country_1.default; | ||
var state_1 = __importDefault(require("./lib/state")); | ||
exports.State = state_1.default; | ||
var city_1 = __importDefault(require("./lib/city")); | ||
exports.City = city_1.default; |
{ | ||
"name": "country-state-city", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Library for fetching Country, its States and Cities", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
"test": "jest", | ||
"build": "tsc -p tsconfig.json", | ||
"build-ts": "tsc -p tsconfig.json", | ||
"build": "npm run build-ts", | ||
"lint": "eslint index.ts __test__ --fix" | ||
@@ -52,7 +54,13 @@ }, | ||
"jest": "^26.6.3", | ||
"json-minimizer-webpack-plugin": "^3.0.0", | ||
"prettier": "^2.2.1", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.3" | ||
"ts-loader": "^9.2.3", | ||
"typescript": "^4.3.2", | ||
"webpack": "^5.38.1", | ||
"webpack-cli": "^4.7.2" | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"copy-webpack-plugin": "^9.0.0" | ||
} | ||
} |
@@ -14,10 +14,14 @@ country-state-city | ||
## Release : `v2.0.0` (Major Version Release - Not backward compatible) | ||
## Release : `v3.0.0` (Major Version Release - Not backward compatible) | ||
- ES6 Module usage | ||
```js | ||
import csc from 'country-state-city' | ||
// Latest version - v3.0.0 with Tree Shaking to reduce bundle size | ||
import { Country, State, City } from 'country-state-city'; | ||
console.log(Country.getAllCountries()) | ||
console.log(State.getAllStates()) | ||
// Import Interfaces` | ||
import { ICountry, IState, ICity } from 'country-state-city' | ||
import { ICountry, IState, ICity } from 'country-state-city' | ||
``` | ||
@@ -27,7 +31,13 @@ - AMD Module usage | ||
```js | ||
let csc = require('country-state-city').default | ||
// Latest version - v3.0.0 | ||
let Country = require('country-state-city').Country; | ||
let State = require('country-state-city').State; | ||
console.log(Country.getAllCountries()) | ||
console.log(State.getAllStates()) | ||
``` | ||
## For versions `v0.1.8 and below` | ||
## For versions `below v2.2.0 and above v0.1.8` | ||
@@ -37,3 +47,3 @@ - ES6 Module usage | ||
```js | ||
import csc from 'country-state-city' | ||
import csc from 'country-state-city'; | ||
``` | ||
@@ -44,3 +54,3 @@ | ||
```js | ||
let csc = require('country-state-city') | ||
let csc = require('country-state-city').default; | ||
``` | ||
@@ -227,38 +237,2 @@ | ||
Change Logs | ||
--------------- | ||
**v2.2.0** :: | ||
1. State, City Database update by (dr5hn)](https://github.com/dr5hn/countries-states-cities-database) | ||
**v2.1.0** :: | ||
1. Fix [#53](https://github.com/harpreetkhalsagtbit/country-state-city/issues/53): returns wrong state as state codes can ne duplicate for different countries. | ||
2. **Deprecate warning**: `getStateByCode` | ||
3. New function - `getStateByCodeAndCountry` | ||
**v2.0.0 (Backward Incompatible)** :: [Data Source (dr5hn)](https://github.com/dr5hn/countries-states-cities-database) | ||
1. Not backward compatible with previous versions. | ||
2. New and updated API functions. | ||
3. Removed proprietor Indexed Id's for uniquely identifying Country, State, City. Instead now using standard isoCodes. | ||
4. Data taken from more robust and accurate database. | ||
5. Countries with their respective flags, isoCode, currencies, latitude, longitude & timezones. | ||
6. States & cities with their latitude & longitude. | ||
**v1.0.0** :: [Data Source (hiiamrohit)](https://github.com/hiiamrohit/Countries-States-Cities-database) | ||
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** :: [Data Source (hiiamrohit)](https://github.com/hiiamrohit/Countries-States-Cities-database) | ||
1. Development code - Javascript to Typescript conversion: [#12](https://github.com/harpreetkhalsagtbit/country-state-city/pull/12) | ||
**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 | ||
[taylorthurlow](https://github.com/taylorthurlow) - For pointing into right direction - Module Tree Shaking |
@@ -17,2 +17,2 @@ { | ||
] | ||
} | ||
} |
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
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
52484459
31
82065
1
19
234
1
+ Addedcopy-webpack-plugin@^9.0.0
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/source-map@0.3.6(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@types/eslint@9.6.1(transitive)
+ Added@types/eslint-scope@3.7.7(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/json-schema@7.0.15(transitive)
+ Added@types/node@22.10.2(transitive)
+ Added@webassemblyjs/ast@1.14.1(transitive)
+ Added@webassemblyjs/floating-point-hex-parser@1.13.2(transitive)
+ Added@webassemblyjs/helper-api-error@1.13.2(transitive)
+ Added@webassemblyjs/helper-buffer@1.14.1(transitive)
+ Added@webassemblyjs/helper-numbers@1.13.2(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.13.2(transitive)
+ Added@webassemblyjs/helper-wasm-section@1.14.1(transitive)
+ Added@webassemblyjs/ieee754@1.13.2(transitive)
+ Added@webassemblyjs/leb128@1.13.2(transitive)
+ Added@webassemblyjs/utf8@1.13.2(transitive)
+ Added@webassemblyjs/wasm-edit@1.14.1(transitive)
+ Added@webassemblyjs/wasm-gen@1.14.1(transitive)
+ Added@webassemblyjs/wasm-opt@1.14.1(transitive)
+ Added@webassemblyjs/wasm-parser@1.14.1(transitive)
+ Added@webassemblyjs/wast-printer@1.14.1(transitive)
+ Added@xtuc/ieee754@1.2.0(transitive)
+ Added@xtuc/long@4.2.2(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedajv@6.12.68.17.1(transitive)
+ Addedajv-formats@2.1.1(transitive)
+ Addedajv-keywords@3.5.25.1.0(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbrowserslist@4.24.3(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcaniuse-lite@1.0.30001688(transitive)
+ Addedchrome-trace-event@1.0.4(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcopy-webpack-plugin@9.1.0(transitive)
+ Addeddir-glob@3.0.1(transitive)
+ Addedelectron-to-chromium@1.5.73(transitive)
+ Addedenhanced-resolve@5.17.1(transitive)
+ Addedes-module-lexer@1.5.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedeslint-scope@5.1.1(transitive)
+ Addedesrecurse@4.3.0(transitive)
+ Addedestraverse@4.3.05.3.0(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfast-uri@3.0.3(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedglob-parent@5.1.26.0.2(transitive)
+ Addedglob-to-regexp@0.4.1(transitive)
+ Addedglobby@11.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedjest-worker@27.5.1(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedjson-schema-traverse@0.4.11.0.0(transitive)
+ Addedloader-runner@4.3.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addednode-releases@2.0.19(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedschema-utils@3.3.04.3.0(transitive)
+ Addedserialize-javascript@6.0.2(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedsupports-color@8.1.1(transitive)
+ Addedtapable@2.2.1(transitive)
+ Addedterser@5.37.0(transitive)
+ Addedterser-webpack-plugin@5.3.11(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedwatchpack@2.4.2(transitive)
+ Addedwebpack@5.97.1(transitive)
+ Addedwebpack-sources@3.2.3(transitive)