cn-adcode-efzcode
Version:
中国行政区划代码和经济功能区代码集合
119 lines (111 loc) • 3.56 kB
text/typescript
type DataCounty = {
name: string,
short: string | null,
deprecated: string | null,
ended: true,
}
type DataZone = {
name: string,
short: string | null,
deprecated: string | null,
ended: true,
parent: string | null,
}
type DataCounties = {
[county: string]: DataCounty,
}
type DataZones = {
[county: string]: DataZone,
}
type DataPrefecture = {
name: string,
short: string | null,
deprecated: string | null,
ended: boolean,
children: DataCounties,
}
type DataClassification = {
name: string,
short: string | null,
deprecated: string | null,
ended: boolean,
children: DataZones,
}
type DataPrefectures = {
[prefecture: string]: DataPrefecture,
}
type DataClassifications = {
[classification: string]: DataClassification,
}
type DataProvince<T extends DataPrefectures | DataClassifications> = {
name: string,
short: string | null,
deprecated: string | null,
ended: boolean,
children: T,
}
type Data<T extends DataPrefectures | DataClassifications> = {
[province: string]: DataProvince<T>,
}
declare class Region {
private readonly level;
private readonly codeS;
private readonly codeI;
private readonly name;
private readonly short;
private readonly deprecated;
private readonly ended;
constructor(level: 0 | 1 | 2 | 3, code: string, name: string, short: string | null, deprecated: string | null, ended: boolean);
getLevel(): 0 | 1 | 2 | 3;
getCodeString(): string;
getCodeInteger(): number;
getName(): string;
getShortName(): string;
isDeprecated(): boolean;
isEnded(): boolean;
}
declare class County extends Region {
private readonly parent;
constructor(code: string, data: DataCounty | DataZone, parent: Prefecture);
getFullCodeString(): string;
getFullCodeInteger(): number;
getFullName(separator?: string): string;
getFullShortName(separator?: string): string;
getParent(): Prefecture;
}
declare class Prefecture extends Region {
private readonly children;
private readonly childrenNotDeprecated;
private readonly parent;
constructor(code: string, data: DataPrefecture | DataClassification, parent: Province);
getFullCodeString(): string;
getFullCodeInteger(): number;
getFullName(separator?: string): string;
getFullShortName(separator?: string): string;
listChildren(includeDeprecated?: boolean): County[];
private getChildren;
getParent(): Province;
getChild(code: string | number, couldBeDeprecated?: boolean): County | null;
}
declare class Province extends Region {
private readonly children;
private readonly childrenNotDeprecated;
constructor(code: string, data: DataProvince<DataPrefectures | DataClassifications>);
getFullCodeString(): string;
getFullCodeInteger(): number;
getFullName(_?: string): string;
getFullShortName(_?: string): string;
listChildren(includeDeprecated?: boolean): Prefecture[];
private getChildren;
getChild(code: string | number, couldBeDeprecated?: boolean): Prefecture | null;
}
declare class China extends Region {
private readonly children;
private readonly childrenNotDeprecated;
constructor(data: Data<DataPrefectures | DataClassifications>);
listChildren(includeDeprecated?: boolean): Province[];
private getChildren;
getChild(code: string | number, couldBeDeprecated?: boolean): Province | null;
}
declare const _default: China;
export { County, Prefecture, Province, _default as default };