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

identity-card

v1.2.0

Published

node/javascript version for php package douyasi/identity-card

Downloads

105

Readme

Identity-Card [id.js]

NPM version NPM downloads

身份证校验及其属地查询类库, 是对PHP douyasi/identity-card 包的 Typescript/Node/Javascript 实现版本 。

demo

PS : 本来包名想叫 idjsid.js 的,但是 npm 有相似包名不允许上传,所以干脆跟 php 包名相同了。

安装与使用

使用 npm 下载安装:

npm install identity-card
cd node_modules/identity-card

使用 git 下载安装:

git clone https://github.com/ycrao/id.js
cd id.js
npm install

使用命令:

npm link
# 命令行工具
id-parse
# 编译所有
npm run build
# 使用tsc编译 [会覆盖 dist 目录下 js 文件]
npm run build:tsc
# 使用webpack编译压缩 [会覆盖 id.min.js 文件]
npm run build:webpack
# 执行开发测试 [使用 node 和 ts-node 运行示例代码]
npm run dev
npm run ts-dev

命令行工具

id-parse

  Usage: id-parse [options]

  Options:

    -V, --version  output the version number
    -h, --help     output usage information
    {identity card number}  Get identity card number information

  Example:

    id-parse 42032319930606629x

数据回显

在终端运行 id-parse 42032319930606629X 命令,会回显以下数据:

identity card number is 42032319930606629X
{ is_pass: true,
  area:
   { status: true,
     result: '湖北省 十堰市竹山县',
     province: '湖北省',
     city: '十堰市',
     county: '竹山县',
     using: 1 },
  gender: 'm',
  birthday: '19930606',
  age: 24,
  constellation: '双子座' }

浏览器端使用

已提供浏览器端 id.min.js ,请参考 example/index.html 示例使用。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <script type="text/javascript" src="../id.min.js"></script>
</head>
<body>
    <script>
    var IdCard = '42032319930606629x';
    var id = new IdentityCard(IdCard);
    console.log('identity card number:', IdCard);
    console.log('result: %j', id.info());
    </script>
</body>
</html>

IdentityCard 类暴露以下公共方法,注意,请在调用 validate()true 之后,再调用其它获取信息接口。

  • validate() : 校验结果
  • info() : 所有信息组合
  • area() : 归属地信息
  • gender() : 性别
  • age() : 年龄
  • birthday() : 生日
  • constellation() : 星座

其他版本实现

联系作者

Email: raoyc2009#gmail.com (请修改改#@
QQ群:260655062