UNPKG

yubinbango-ts

Version:

郵便番号から住所を取得するTypeScriptライブラリ

44 lines (42 loc) 1.35 kB
/** * 郵便番号から住所を取得するためのクラス * 下記ライブラリのコードを流用してTS化したコード * @refs: https://github.com/yubinbango/yubinbango */ type YubinBangoData = { [key: string]: string[]; }; declare global { interface Window { $yubin: (data: YubinBangoData) => void; } } declare global { var $yubin: ((data: YubinBangoData) => void) | undefined; } type Address = ReturnType<YubinBango['addrDic']>; declare const YUBINBANGO_PREFECTURE: { value: string; id: string; label: string; }[]; interface YubinBangoOptions { url?: string; } declare class YubinBango { URL: string; PREFECTURE: (string | null)[]; constructor(yubinBango?: string, callback?: (addr: Address) => void, options?: YubinBangoOptions); chk7(val: string): string | undefined; addrDic(prefecture_id?: string, prefecture?: string | null, city?: string, street?: string, building?: string): { prefecture_id: string; prefecture: string; city: string; street: string; building: string; }; selectAddr(addr: string[]): Address; jsonp(url: string, fn: (data: YubinBangoData) => void): void; getAddr(yubin7: string, fn?: (addr: Address) => void): void; } export { Address, YUBINBANGO_PREFECTURE, YubinBango, YubinBangoOptions };