npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

addres-parse-weidian

v3.2.1

Published

cn address parse

Downloads

10

Readme

CN Address Parse

数据源更新 有其他问题请关注下方原作者 如有识别不准的地址请 issuse

Install

npm install addres-parse-weidian --save

Start

import AddressParse from 'addres-parse-weidian';

const [result] = AddressParse.parse('福建省福州市福清市石竹街道义明综合楼3F,15000000000,asseek');
console.log(result);
/* 
{
  'province': '福建省',
  'city': '福州市',
  'area': '福清市',
  'details': '石竹街道义明综合楼3F',
  'name': 'asseek',
  'code': '350181',
  '__type': 'parseByProvince',     //结果解析使用函数 parseByProvince parseByCity parseByArea
  '__parse': true,                 //为true的结果可信度高
  'mobile': '15000000000',
  'zip_code': '',
  'phone': '',
};
*/

parse默认识别到第一个可信结果就会返回内容,但这不一定准确,特别是没有正确省市区的地址
这时如果传入第二个参数会执行所有解析方法,并将所有解析内容返回
内部有进行判断,可信度较高的地址会在数组前面

const [result, ...results] = AddressParse.parse('张l,15222222222,和林格尔 盛乐经济工业园区内蒙古师范大学盛乐校区', true);
import AddressParse, {AREA, Utils} from 'address-parse';

const {
  province_list,  // 以地区编码为键名的省份对象
  city_list,      // 以地区编码为键名的城市对象
  area_list,      // 以地区编码为键名的地区对象
} = AREA;

// 通过地区编码返回省市区对象
const {province, city, area, code} = Utils.getAreaByCode('350181');

// 根据省市县类型和对应的code获取数据列表 
const list = Utils.getTargetAreaListByCode('city', '350000'); //获得福建所有城市

list = Utils.getTargetAreaListByCode('area', '350000'); //获得福建所有地区

// 传入第三个参数返回code父级
const [province, city] = Utils.getTargetAreaListByCode('province', '350181', true);
const [city] = Utils.getTargetAreaListByCode('city', '350181', true);

// 非标准地区对象转换为标准地区对象
const result = Utils.getAreaByAddress({province: '福建', city: '福州', area: '福清'});
// {"code":"350181","province":"福建省","city":"福州市","area":"福清市"}