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 0.1.8 to 2.0.0-beta-1

dist/src/interface.d.ts

29

dist/index.d.ts

@@ -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": "2.0.0-beta-1",
"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
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