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

ddidcardutils

v1.7.0

Published

utils for IdCard

Downloads

5

Readme

这是一个身份证解析小工具,封装为类,主要具备获取籍贯信息,生日信息,性别信息的功能。

一、安装

npm install ddidcardutils

二、使用

import { IdCardUtils } from 'ddidcardutils/lib'
const idCardUtils = new IdCardUtils()

image-20211223160057096

三、主要方法

1. isValidateCard

校验身份证号合法性(支持15位和18位校验),合法返回false,不合法返回true

idCard.isValidateCard('530323199005250516') // false 合法
idCard.isValidateCard('53032319900525051') // true 不合法

后面的方法只针对18位的身份证

2. getOriginObject

获取籍贯省市县三级结构,其中code为标准的行政区域代码,省级2位,市级4位,县级6位

530323

idCard.getOriginObject('530323199005250516')
//返回值如下
{
  province: {
    code: '53',
    name: '云南省'
  },
  city: {
    code: '5303',
    name: '曲靖市'
  },
  county: {
    code: '530323',
    name: '师宗县'
  }
}

3. getOriginName

获取籍贯汉语全称

idCard.getOriginName('530323199005250516')
// 云南省曲靖市师宗县

4. getBirth

获取生日,返回值是YYYYMMDD格式的字符串

idCard.getBirth('530323199005250516')
//19900525

5. getBirthYear

获取生日-年,YYYY

idCard.getBirthYear('530323199005250516')
//1990

6. getBirthMonth

获取生日-月,MM(01-12)

idCard.getBirthMonth('530323199005250516')
//05

7. getBirthDate

获取生日-日,DD(01-31)

idCard.getBirthDate('530323199005250516')
//25

8. getAge

获取年龄,生日当天算已经满周岁

idCard.getAge('530323199005250516')
//31

9. getSex

获取性别

idCard.getSex('530323199005250516')
// 男
idCard.getSex('530323199005250526')
// 女