egg-address
Advanced tools
+1
-1
| { | ||
| "name": "egg-address", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "智能识别地址", | ||
@@ -5,0 +5,0 @@ "eggPlugin": { |
+55
-15
@@ -1,2 +0,2 @@ | ||
| # egg-egg-address | ||
| # egg-address | ||
@@ -10,14 +10,14 @@ [![NPM version][npm-image]][npm-url] | ||
| [npm-image]: https://img.shields.io/npm/v/egg-egg-address.svg?style=flat-square | ||
| [npm-url]: https://npmjs.org/package/egg-egg-address | ||
| [travis-image]: https://img.shields.io/travis/eggjs/egg-egg-address.svg?style=flat-square | ||
| [travis-url]: https://travis-ci.org/eggjs/egg-egg-address | ||
| [codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-egg-address.svg?style=flat-square | ||
| [codecov-url]: https://codecov.io/github/eggjs/egg-egg-address?branch=master | ||
| [david-image]: https://img.shields.io/david/eggjs/egg-egg-address.svg?style=flat-square | ||
| [david-url]: https://david-dm.org/eggjs/egg-egg-address | ||
| [snyk-image]: https://snyk.io/test/npm/egg-egg-address/badge.svg?style=flat-square | ||
| [snyk-url]: https://snyk.io/test/npm/egg-egg-address | ||
| [download-image]: https://img.shields.io/npm/dm/egg-egg-address.svg?style=flat-square | ||
| [download-url]: https://npmjs.org/package/egg-egg-address | ||
| [npm-image]: https://img.shields.io/npm/v/egg-address.svg?style=flat-square | ||
| [npm-url]: https://npmjs.org/package/egg-address | ||
| [travis-image]: https://img.shields.io/travis/eggjs/egg-address.svg?style=flat-square | ||
| [travis-url]: https://travis-ci.org/eggjs/egg-address | ||
| [codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-address.svg?style=flat-square | ||
| [codecov-url]: https://codecov.io/github/eggjs/egg-address?branch=master | ||
| [david-image]: https://img.shields.io/david/eggjs/egg-address.svg?style=flat-square | ||
| [david-url]: https://david-dm.org/eggjs/egg-address | ||
| [snyk-image]: https://snyk.io/test/npm/egg-address/badge.svg?style=flat-square | ||
| [snyk-url]: https://snyk.io/test/npm/egg-address | ||
| [download-image]: https://img.shields.io/npm/dm/egg-address.svg?style=flat-square | ||
| [download-url]: https://npmjs.org/package/egg-address | ||
@@ -31,3 +31,3 @@ <!-- | ||
| ```bash | ||
| $ npm i egg-egg-address --save | ||
| $ npm i egg-address --save | ||
| ``` | ||
@@ -41,3 +41,3 @@ | ||
| enable: true, | ||
| package: 'egg-egg-address', | ||
| package: 'egg-address', | ||
| }; | ||
@@ -60,2 +60,42 @@ ``` | ||
| ```js | ||
| it('get area', () => { | ||
| const ctx = app.mockContext(); | ||
| const areaDate = ctx.service.address.area(); | ||
| assert(areaDate['district_list'][0].label === '华东'); | ||
| }); | ||
| it('parse', async () => { | ||
| const ctx = app.mockContext(); | ||
| console.log(`输入内容:${list[0][0]}`); | ||
| const result = await ctx.service.address.parse(list[0][0]); | ||
| console.log(`解析结果:${JSON.stringify(result)}`); | ||
| assert(result[0].province === '福建省'); | ||
| assert(result[0].city === '福州市'); | ||
| assert(result[0].area === '福清市'); | ||
| assert(result[0].details === '石竹街道义明综合楼3F'); | ||
| assert(result[0].name === '张小明'); | ||
| assert(result[0].mobile === '15000000000'); | ||
| }); | ||
| it('parse ALL', async () => { | ||
| const ctx = app.mockContext(); | ||
| for (const item of list) { | ||
| const address = Array.isArray(item) ? item[0] : item; | ||
| const options = Array.isArray(item) ? item[1] : ''; | ||
| const code = typeof options === 'object' ? options.code : options; | ||
| const [result, ...results] = await ctx.service.address.parse(address, true); | ||
| let status = code ? result.code === code : result.__parse; | ||
| if (typeof options === 'object') { | ||
| for (const key in options) { | ||
| assert(result[key] === options[key]); | ||
| } | ||
| } | ||
| if (!status) { | ||
| console.log('addressParseTest->fail', `${address} [${code}->${result.code}]`, result, results, options); | ||
| } | ||
| } | ||
| }); | ||
| ``` | ||
| ## Questions & Suggestions | ||
@@ -62,0 +102,0 @@ |
151546
0.93%104
62.5%