|
| 1 | +`zipcode-ja` |
| 2 | +--- |
| 3 | + |
| 4 | +<p align="right"> |
| 5 | + <a href="https://npmjs.org/package/zipcode-ja"> |
| 6 | + <img src="https://img.shields.io/npm/v/zipcode-ja.svg?style=flat-square"> |
| 7 | + </a> |
| 8 | + <a href="https://travis-ci.org/59naga/zipcode-ja"> |
| 9 | + <img src="http://img.shields.io/travis/59naga/zipcode-ja.svg?style=flat-square"> |
| 10 | + </a> |
| 11 | + <a href="https://codeclimate.com/github/59naga/zipcode-ja/coverage"> |
| 12 | + <img src="https://img.shields.io/codeclimate/github/59naga/zipcode-ja.svg?style=flat-square"> |
| 13 | + </a> |
| 14 | + <a href="https://codeclimate.com/github/59naga/zipcode-ja"> |
| 15 | + <img src="https://img.shields.io/codeclimate/coverage/github/59naga/zipcode-ja.svg?style=flat-square"> |
| 16 | + </a> |
| 17 | + <a href="https://gemnasium.com/59naga/zipcode-ja"> |
| 18 | + <img src="https://img.shields.io/gemnasium/59naga/zipcode-ja.svg?style=flat-square"> |
| 19 | + </a> |
| 20 | +</p> |
| 21 | + |
| 22 | +<p align="center"> |
| 23 | + <a href="https://saucelabs.com/u/59798"> |
| 24 | + <img src="http://soysauce.berabou.me/u/59798/zipcode-ja.svg"> |
| 25 | + </a> |
| 26 | +</p> |
| 27 | + |
| 28 | +[日本郵便 平成28年5月31日更新 郵便番号データ](http://www.post.japanpost.jp/zipcode/dl/kogaki-zip.html) NodeJS / ブラウザ用 JavaScript |
| 29 | + |
| 30 | +インストール |
| 31 | +--- |
| 32 | + |
| 33 | +**NodeJS** |
| 34 | +```bash |
| 35 | +npm install zipcode-ja --save |
| 36 | +``` |
| 37 | + |
| 38 | +```js |
| 39 | +import zipcodeJa from 'zipcode-ja'; |
| 40 | +console.log(zipcodeJa.version, zipcodeJa.lastModified); // '0.0.0', '2016-05-31' |
| 41 | +``` |
| 42 | + |
| 43 | +**ブラウザ**([Download Latest](https://npmcdn.com/zipcode-ja/lib/zipcode-ja.js)) |
| 44 | +```html |
| 45 | +<script src="https://npmcdn.com/zipcode-ja/lib/zipcode-ja.js"></script> |
| 46 | +<script> |
| 47 | +console.log(zipcodeJa.version, zipcodeJa.lastModified); // '0.0.0', '2016-05-31' |
| 48 | +</script> |
| 49 | +``` |
| 50 | + |
| 51 | +使用方法 |
| 52 | +--- |
| 53 | + |
| 54 | +`zipcodeJa`は、一つの巨大なオブジェクトです。実在する住所をキーとして与えると、対応する住所を返します。 |
| 55 | + |
| 56 | +```js |
| 57 | +console.log(zipcodeJa['1000002']); |
| 58 | +// { |
| 59 | +// zipcode: '1000002', |
| 60 | +// zipcodeOld: '100', |
| 61 | +// jisX0402: '13101', |
| 62 | +// address: [ |
| 63 | +// '東京都', |
| 64 | +// '千代田区', |
| 65 | +// '皇居外苑' |
| 66 | +// ], |
| 67 | +// ruby: [ |
| 68 | +// 'とうきょうと', |
| 69 | +// 'ちよだく', |
| 70 | +// 'こうきょがいえん' |
| 71 | +// ], |
| 72 | +// status: [ |
| 73 | +// 0, |
| 74 | +// 0, |
| 75 | +// 0, |
| 76 | +// 0, |
| 77 | +// 0, |
| 78 | +// 0 |
| 79 | +// ] |
| 80 | +// } |
| 81 | +``` |
| 82 | + |
| 83 | +それぞれのプロパティは、元データである[郵便番号データの説明](http://www.post.japanpost.jp/zipcode/dl/readme.html)の情報に対応しています。 |
| 84 | + |
| 85 | +* `zipcode` … `郵便番号(7桁)` |
| 86 | +* `zipcodeOld` … `(旧)郵便番号(5桁)` |
| 87 | +* `jisX0402` … `全国地方公共団体コード(JIS X0401、X0402)` |
| 88 | +* `address` … `都道府県名/漢字`, `市区町村名/漢字`, `町域名/漢字` |
| 89 | +* `ruby` … `都道府県名/半角カタカナ`, `市区町村名/半角カタカナ`, `町域名/半角カタカナ` |
| 90 | +* `status` |
| 91 | + 0. `一町域が二以上の郵便番号で表される場合の表示` |
| 92 | + 1. `小字毎に番地が起番されている町域の表示` |
| 93 | + 2. `丁目を有する町域の場合の表示` |
| 94 | + 3. `一つの郵便番号で二以上の町域を表す場合の表示` |
| 95 | + 4. `更新の表示` |
| 96 | + 5. `変更理由` |
| 97 | + |
| 98 | +注意事項として |
| 99 | + * `address`の`町域名`が「以下に掲載がない場合」を「」に置換 |
| 100 | + * `ruby`は半角カタカナではなく、全角ひらがなに置換 |
| 101 | +を行っています。これは、他のスクリプトから利用する際の手順を省略するための調整です。 |
| 102 | + |
| 103 | +他のライブラリとの差異 |
| 104 | +--- |
| 105 | +* [AjaxZip3/yubinbango](https://github.com/ajaxzip3/ajaxzip3.github.io#readme) と違い、DOM依存を行わない |
| 106 | +* [japan-postal-code](https://github.com/mzp/japan-postal-code#readme) と違い、コールバック関数を用いない |
| 107 | + |
| 108 | +開発環境 |
| 109 | +--- |
| 110 | +下記が[グローバルインストール](https://github.com/creationix/nvm#readme)されていることが前提です。 |
| 111 | +* NodeJS v6.2.1 |
| 112 | +* Npm v3.9.3 (or [pnpm](https://github.com/rstacruz/pnpm)) |
| 113 | + |
| 114 | +```bash |
| 115 | +git clone https://github.com/59naga/zipcode-ja |
| 116 | +cd zipcode-ja |
| 117 | +npm install |
| 118 | + |
| 119 | +npm test |
| 120 | +``` |
| 121 | + |
| 122 | +License |
| 123 | +--- |
| 124 | +[MIT](http://59naga.mit-license.org/) |
0 commit comments