Socket
Socket
Sign inDemoInstall

@ntegral/country-state-city

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

9

dist/index.d.ts
import { ICountry, IState } from "./interfaces/csc.interface";
export { ICountry, IState } from "./interfaces/csc.interface";
declare let csc: {
getAllCountries(): ICountry[];
getCountryById(id: number): ICountry;
getCountryByCode(code: string): ICountry;
getStatesByCountry(countryId: number): IState[];
};
export default csc;
export { ICountry, IState };

27

dist/index.js

@@ -5,9 +5,9 @@ "use strict";

const states = require("./data/states.json");
let csc = {
class csc {
getAllCountries() {
return countries;
},
}
getCountryById(id) {
return countries.find(c => c.id === id);
},
}
getCountryByCode(code) {

@@ -20,17 +20,16 @@ if (code.length === 3) {

}
},
}
getStatesByCountry(countryId) {
let result = states.filter(s => s.country_id === countryId);
return result.sort(compare);
return result.sort(this.compare);
}
};
exports.default = csc;
function compare(a, b) {
if (a.name < b.name) {
return -1;
compare(a, b) {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
}
if (a.name > b.name) {
return 1;
}
return 0;
}
import countries = require("./data/countries.json");
import states = require("./data/states.json");
import { ICountry, IState } from "./interfaces/csc.interface";
export { ICountry, IState } from "./interfaces/csc.interface";
export { ICountry, IState };
let csc = {
class csc {
getAllCountries(): ICountry[] {
return countries as ICountry[];
}
getCountryById(id: number): ICountry {
return countries.find(c => c.id === id) as ICountry;
}
getCountryByCode(code: string): ICountry {
if (code.length === 3) {
return countries.find(c => c.iso3 === code) as ICountry;
} else {
return countries.find(c => c.iso2 === code) as ICountry;
}
}
getStatesByCountry(countryId:number): IState[] {
let result = states.filter(s => s.country_id === countryId) as IState[];
return result.sort(this.compare);
}
private compare(a:any,b:any) {
if(a.name < b.name) {
return -1;
}
if(a.name > b.name) {
return 1;
}
return 0;
}
}
/* let csc = return {
getAllCountries(): ICountry[] {
return countries as ICountry[];
},

@@ -26,12 +60,2 @@ getCountryById(id: number): ICountry {

}
export default csc;
function compare(a:any,b:any) {
if(a.name < b.name) {
return -1;
}
if(a.name > b.name) {
return 1;
}
return 0;
}
export default csc; */

@@ -10,3 +10,3 @@ {

"name": "@ntegral/country-state-city",
"version": "1.0.1",
"version": "1.0.2",
"description": "Full database of city, state and countries",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc