jpostcode
Version:
A library for finding Japanese addresses by postal code.
3 lines (2 loc) • 838 B
JavaScript
import*as r from"fs";import*as a from"path";var e=class{constructor(s){this.data=s}get prefecture(){return this.data.prefecture}get prefectureKana(){return this.data.prefecture_kana}get prefectureCode(){return this.data.prefecture_code}get city(){return this.data.city}get cityKana(){return this.data.city_kana}get town(){return this.data.town}get townKana(){return this.data.town_kana}get zipCode(){return this.data.postcode}},c=class{static{this.DATA_DIR=a.join(__dirname,"../dist/jpostcode-data/data/json")}static find(s){let n=s.replace("-",""),o=n.substring(0,3),u=n.substring(3),i=a.join(this.DATA_DIR,`${o}.json`);if(!r.existsSync(i))return[];let t=JSON.parse(r.readFileSync(i).toString())[u];return t?t instanceof Array?t.map(p=>new e(p)):[new e(t)]:[]}};export{e as Address,c as Jpostcode};
//# sourceMappingURL=index.esm.js.map