Skip to content

Commit

Permalink
Add documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
keichan34 committed Oct 9, 2024
1 parent e95069b commit 64211b9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export type SinglePrefecture = {

cities: SingleCity[];
};

/**
* SinglePrefecture から都道府県名を取得します。
* @param pref SinglePrefecture
* @returns string
*/
export function prefectureName(pref: SinglePrefecture): string {
return pref.pref;
}
Expand Down Expand Up @@ -45,6 +51,11 @@ export type SingleCity = {
point: LngLat;
};

/**
* SingleCity から市区町村名を取得します。郡名と政令市区名を含めます。
* @param city SingleCity
* @returns string
*/
export function cityName(city: SingleCity): string {
return `${city.county || ''}${city.city}${city.ward || ''}`;
}
Expand Down Expand Up @@ -79,6 +90,11 @@ export type SingleMachiAza = {
}
};

/**
* SingleMachiAza から町字名を取得します。大字・丁目・小字を含めます。
* @param machiAza SingleMachiAza
* @returns string
*/
export function machiAzaName(machiAza: SingleMachiAza): string {
return `${machiAza.oaza_cho || ''}${machiAza.chome || ''}${machiAza.koaza || ''}`;
}
Expand Down Expand Up @@ -131,6 +147,11 @@ export type SingleChiban = {
point?: LngLat;
};

/**
* SingleChiban の地番1・地番2・地番3を `-` で区切った文字列を返します。
* @param chiban SingleChiban
* @returns string
*/
export function chibanToString(chiban: SingleChiban): string {
return [chiban.prc_num1, chiban.prc_num2, chiban.prc_num3]
.filter(Boolean)
Expand Down

0 comments on commit 64211b9

Please sign in to comment.