Skip to content

Commit

Permalink
refactor codebase, build system
Browse files Browse the repository at this point in the history
isCityCodeLike, castCityCode, isCityNameLike, castCityName methods removed
  • Loading branch information
muratgozel committed Mar 31, 2024
1 parent 1dc9f25 commit af63e11
Show file tree
Hide file tree
Showing 287 changed files with 799,388 additions and 1,663,781 deletions.
3 changes: 0 additions & 3 deletions .browserslistrc

This file was deleted.

38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.idea
src/data/*.xlsx
src/data/*.zip

storage/resources/neighbourhoods/*
storage/resources/distances/*
!storage/resources/neighbourhoods/etag
!storage/resources/distances/etag
.idea

**/.DS_Store

Expand Down
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
# turkey-neighbourhoods
Always up to date names of cities, districts and neighbourhoods of Turkey, available as JSON and JS. Refer to https://muratgozel.github.io/turkey-neighbourhoods/ for full api documentation.
Always up to date names of cities, districts and neighbourhoods of Turkey.

**In Turkish: **
JSON ve JS formatında, her zaman güncel, Türkiye şehir, posta kodu, plaka kodu, ilçe ve mahalle listesi.

## ⭐ Breaking Changes in v3
In v3, I extended the scope of the package, basically made it a module that has the necessary methods to interact with the data.

## ⭐️ New Feature: City Distances (as of v2.1)
Now there is map that contains the distances between two cities in json format.
Her zaman güncel, Türkiye şehir, posta kodu, plaka kodu, ilçe ve mahalle listesi.

## Install
```sh
npm i turkey-neighbourhoods
```
or inject with script tag:
```html
<script type="module" src="https://cdn.jsdelivr.net/npm/turkey-neighbourhoods@4/dist/index.js"></script>
```

## Usage
The package contains large amount of data which is not suitable for browser environment. Benefit from tree-shaking might work if you are interested in small chunks of it.

There are couple of methods to interact with the data:
```js
import {isCityCode, isCityCodeLike, castCityCode, isCityName, isCityNameLike, castCityName,
findDistance, findClosestCities} from 'turkey-neighbourhoods'
import {
isCityCode,
isCityName,
isPostalCode,
getCityNames,
getCityCodes,
getCities,
getPostalCodes,
getDistrictsByCityCode,
getDistrictsOfEachCity,
getDistrictsAndNeighbourhoodsByCityCode,
getDistrictsAndNeighbourhoodsOfEachCity,
getNeighbourhoodsByCityCodeAndDistrict,
findDistance,
findClosestCities
} from 'turkey-neighbourhoods'

isCityCode('01') // true
isCityCode('82') // false
isCityCode(1) // false
isCityCodeLike(1) // true

castCityCode(' 01 ') // "01"
castCityCode('abc') // ""

isCityName('İstanbul') // true
isCityName('istanbul') // false, because city names are always title cased
isCityNameLike('istanbul') // true

castCityName('istanbul') // "İstanbul"

getCityCodes() // ["01", "02", ... "67"] sorted by name, 81 in total
getCityNames() // ["Adana", "Adıyaman", ... "Zonguldak"]
Expand All @@ -59,7 +64,7 @@ findClosestCities('16', 200, 3) // [{code: '77', distance: 69}, ...]
Have a look at the tests, types and source for more info.

## Keeping Data Up To Date
Data updates published regularly as `minor` releases so you only need to update the package as new version comes in. If you have a kind of manual setup, you can run `npm run setup`, `compile`, `build` and `test` to fetch the new data. The module is smart enough to detect if the existing data is fresh or not.
Data updates published regularly as `minor` releases so check regularly for updates. The data source updates it every month.

## Contributing
If you're interested in contributing, read the [CONTRIBUTING.md](https://github.com/muratgozel/muratgozel/blob/main/CONTRIBUTING.md) first, please.
Expand Down
83 changes: 0 additions & 83 deletions build/data/city/codes.js

This file was deleted.

Loading

0 comments on commit af63e11

Please sign in to comment.