Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

country-state-city

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

country-state-city - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

1

dist/index.d.ts

@@ -12,3 +12,4 @@ import { ICountry, ICity, IState } from './src/interface';

getStateByCode(isoCode: string): IState;
getStateByCodeAndCountry(isoCode: string, countryCode: string): IState;
};
export default _default;

@@ -18,2 +18,11 @@ "use strict";

};
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) {

@@ -57,5 +66,11 @@ if (a.name < b.name)

},
// 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);
},
};

2

package.json
{
"name": "country-state-city",
"version": "2.0.0",
"version": "2.1.0",
"description": "Library for fetching Country, its States and Cities",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -14,3 +14,3 @@ country-state-city

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

@@ -47,3 +47,3 @@

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

@@ -76,2 +76,19 @@

getStateByCodeAndCountry(stateCode, countryCode)
---------------
It accepts a valid `StateCode` eg: `'TG'` `CountryCode` eg: `'IN'` and returns *State Details*
type: **json | ICountry**
```js
{
"name": "Telangana",
"isoCode": "TG",
"countryCode": "IN",
"latitude": "18.11243720",
"longitude": "79.01929970"
}
```
getStatesOfCountry(countryCode)

@@ -87,7 +104,7 @@ ---------------

{
"name": "Delhi",
"isoCode": "DL",
"countryCode": "IN",
"latitude": "28.70405920",
"longitude": "77.10249020"
"name": "Delhi",
"isoCode": "DL",
"countryCode": "IN",
"latitude": "28.70405920",
"longitude": "77.10249020"
}

@@ -107,7 +124,7 @@ ]

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

@@ -128,7 +145,7 @@ ]

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

@@ -177,7 +194,7 @@ ]

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

@@ -197,7 +214,7 @@ }

{
"name": "Delhi",
"isoCode": "DL",
"countryCode": "IN",
"latitude": "28.70405920",
"longitude": "77.10249020"
"name": "Delhi",
"isoCode": "DL",
"countryCode": "IN",
"latitude": "28.70405920",
"longitude": "77.10249020"
}

@@ -211,2 +228,3 @@ ]

[@baywet](https://github.com/baywet) - For mentoring Javascript to Typescript Conversion
[@dr5hn](https://github.com/dr5hn) - For updated World Data Dictionary

@@ -216,2 +234,8 @@

---------------
**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)

@@ -218,0 +242,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc