-
Notifications
You must be signed in to change notification settings - Fork 0
/
cities.ts
39 lines (34 loc) · 871 Bytes
/
cities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { cityList } from '../db/citiesDb';
import { ICity } from '../interfaces';
/**
* get all cities
*
* @return {*} {ICity[]}
*/
const getAllCities = (): ICity[] => {
return cityList;
}
/**
* get all cities of state by state code & country code
*
* @param {string} stateCode
* @param {string} countryCode
* @return {*} {ICity[]}
*/
const getAllCitiesOfState = (stateCode: string,countryCode:string): ICity[] => {
return cityList.filter(city => city.stateCode === stateCode && city.countryCode === countryCode);
}
/**
* get all cities of state by country code
*
* @param {string} countryCode
* @return {*} {ICity[]}
*/
const getAllCitiesByCountry = (countryCode: string): ICity[] => {
return cityList.filter(city => city.countryCode === countryCode);
}
export {
getAllCities,
getAllCitiesOfState,
getAllCitiesByCountry
};