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

pycn

v2.0.1

Published

[![npm][npm]][npm-url] ![GitHub][license]

Downloads

44

Readme

pycn

npm GitHub

中国行政区域(省/市/区/街道)拼音,支持 es cjs umd 格式,方便 node/es6/浏览器使用。

适用以下场景:

  • 字母索引城市列表选择
  • 拼音搜索省/市/区/街道数据

如果不使用拼音,需要注意一些多音字处理,比如 亳(bo,不是 hao)州市、厦(xia,不是 sha)门、长(chang,不是 zhang)春市 ...

数据来源:高德地图-行政区域查询

数据格式

| 文件模块 | 描述 | | --- | --- | | py-data.ts | 省/市/区/街道 | | py-province-city-district.ts | 省/市/区 | | py-province-city.ts | 省/市 | | py-province.ts | 省 | | py-city.ts | 市 | | py-district.ts | 区 | | py-street.ts | 街道 |

安装

  • node/es
npm install pycn
  • 浏览器

html 直接引入 unpkg 对应的文件,注意不同模块对应不同的全局变量,如 py-city.js 全局变量为 pyCity

使用

所有文件模块都存放在 escjsumd 文件夹下,通过模块引入不同文件使用不同数据。

注意:尽量只使用其中一个数据,否则会使项目构建体积变大。

// 省/市/区/街道
import pyData from 'pycn/es/py-data';

// 省/市/区
import pyProvinceCityDistrict from 'pycn/es/py-province-city-district';

// 省/市
import pyProvinceCity from 'pycn/es/py-province-city';

// 省
import pyProvince from 'pycn/es/py-province';

// 市
import pyCity from 'pycn/es/py-city';

// 区
import pyDistrict from 'pycn/es/py-district';

// 街道
import pyStreet from 'pycn/es/py-street';

示例

  • 所有城市按字母排序
import pyCity from 'pycn/es/py-city';

const result = pyCity.sort((a, b) => a.py.localeCompare(b.py, 'zh'));

console.log(result);

参考