{"id":25687078,"url":"https://github.com/holyshared/zip-code-jp","last_synced_at":"2025-04-23T23:43:56.030Z","repository":{"id":39458745,"uuid":"46412670","full_name":"holyshared/zip-code-jp","owner":"holyshared","description":"Address search from zip code for japanese","archived":false,"fork":false,"pushed_at":"2016-08-24T07:10:48.000Z","size":4015,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-21T17:58:38.327Z","etag":null,"topics":["csv","jp","nodejs","zip-code"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/holyshared.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-18T10:49:59.000Z","updated_at":"2024-08-08T14:36:21.000Z","dependencies_parsed_at":"2022-09-16T07:21:38.145Z","dependency_job_id":null,"html_url":"https://github.com/holyshared/zip-code-jp","commit_stats":null,"previous_names":["holyshared/postal-code-jp"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fzip-code-jp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fzip-code-jp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fzip-code-jp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fzip-code-jp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/holyshared","download_url":"https://codeload.github.com/holyshared/zip-code-jp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535057,"owners_count":21446503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","jp","nodejs","zip-code"],"created_at":"2025-02-24T20:08:05.989Z","updated_at":"2025-04-23T23:43:55.101Z","avatar_url":"https://github.com/holyshared.png","language":"JavaScript","readme":"# zip-code-jp\n\n郵便番号から、住所を検索できるモジュールです。  \n郵便番号データのソースは[郵便事業株式会社（旧郵政省）](http://www.post.japanpost.jp/zipcode/download.html)提供のデータを使用しています。\n\n[postal-code-jp](https://www.npmjs.com/package/postal-code-jp)を使用している場合は、代わりに[zip-code-jp](https://www.npmjs.com/package/zip-code-jp)を使用してください。\n\n[![npm version](https://badge.fury.io/js/zip-code-jp.svg)](https://badge.fury.io/js/zip-code-jp)\n[![Build Status](https://travis-ci.org/holyshared/zip-code-jp.svg?branch=master)](https://travis-ci.org/holyshared/zip-code-jp)\n[![codecov.io](https://codecov.io/github/holyshared/zip-code-jp/coverage.svg?branch=master)](https://codecov.io/github/holyshared/zip-code-jp?branch=master)\n[![dependencies Status](https://david-dm.org/holyshared/zip-code-jp/status.svg)](https://david-dm.org/holyshared/zip-code-jp)\n\n## インストール方法\n\n下記のコマンドでインストールできます。\n\n\tnpm install zip-code-jp\n\n## 基本的な使用方法\n\n郵便番号から、住所の情報を返します。\n\n```js\nimport AddressResolver from 'zip-code-jp';\n\nconst resolver = new AddressResolver();\n\nresolver.find('0010933').then((results) =\u003e {\n  console.log(results[0].prefecture); // 都道府県\n  console.log(results[0].city); // 市区町村名\n  console.log(results[0].area); // 町域名\n  console.log(results[0].street); // 番地\n});\n```\n\n## 検索結果のキャッシュ\n\nキャッシュに利用するアダプタを変えることで、独自のキャッシュ処理に切り替えることができます。  \nデフォルトでは、**MemoryCacheAdapter**を使用して、メモリにキャッシュします。\n\n```js\nimport AddressResolver from 'zip-code-jp';\nimport { cache } from 'zip-code-jp';\n\nconst memoryAdapter = new cache.MemoryCacheAdapter();\nconst resolver = new AddressResolver(memoryAdapter);\n\nresolver.find('0010933').then((results) =\u003e {\n  console.log(results[0].prefecture); // 都道府県\n  console.log(results[0].city); // 市区町村名\n  console.log(results[0].area); // 町域名\n  console.log(results[0].street); // 番地\n});\n```\n\n## 独自アダプタの実装\n\n**CacheAdapter**をサブクラス化して、独自のアダプタを使用できるようになります。  \n下記のメソッドを実装する必要があります。\n\n* find(prefix) - 郵便番号の頭3桁を引数に取り、該当する辞書を返します。\n* store(prefix, store) - 郵便番号の頭3桁と、辞書を受け取り、キャッシュします。\n\n```js\nimport AddressResolver from 'zip-code-jp';\nimport { cache } from 'zip-code-jp';\n\nclass CustomAdapter extends cache.CacheAdapter {\n  constructor() {\n    super();\n  }\n\n  /**\n   * Search the dictionary from the cache\n   *\n   * @param {string} prefix\n   * @return Promise\u003cObject\u003e\n   */\n  find(prefix) {\n  }\n\n  /**\n   * Cache the dictionary\n   *\n   * @param {string} prefix\n   * @param {Object} dict\n   * @return Promise\u003cvoid\u003e\n   */\n  store(prefix, dict) {\n  }\n}\n\nconst resolver = new AddressResolver(new CustomAdapter());\n\nresolver.find('0010933').then((results) =\u003e {\n  console.log(results[0].prefecture); // 都道府県\n  console.log(results[0].city); // 市区町村名\n  console.log(results[0].area); // 町域名\n  console.log(results[0].street); // 番地\n});\n```\n\n## 辞書ファイルの更新\n\n\tnpm run index\n\n## テストの実行\n\n次のコマンドで、テストを実行できます。\n\n\tnpm install\n\tnpm test\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fzip-code-jp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholyshared%2Fzip-code-jp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fzip-code-jp/lists"}