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

chinese-idcard

v1.0.6

Published

chinese-idcard ===================== - 18位身份证校验 - 支持步进模式: 分批输入 /后退取消 - 普通整体输入模式 - 随机生成 指定开始{y:,m:,d:} 结束{y:,m:,d:} - 连续生成 generator 指定生成范围

Downloads

6

Readme

chinese-idcard

  • 18位身份证校验
  • 支持步进模式: 分批输入 /后退取消
  • 普通整体输入模式
  • 随机生成 指定开始{y:,m:,d:} 结束{y:,m:,d:}
  • 连续生成 generator 指定生成范围

install

  • npm install chinese-idcard

usage

const {
    ID,
    parse,
    unparse,
    SERROR,
    SERROR_DICT,
    STATE_DICT,
    random,
    gen
} = require("chinese-idcard");

example

###普通模式 18位整体输入

> var d = parse("659001197012113369")
> d
{
  province: '新疆维吾尔自治区',
  city: '自治区直辖县级行政单位',
  county: '石河子市',
  year: 1970,
  month: 12,
  day: 11,
  police: '33',
  sex: '女',
  sex_code: 6,
  parity: '9'
}

unparse(d)
> unparse(d)
'659001197012113369'
>

###步进模式

var id=new ID()
////
id.next("658")
id.prev(1)
id.next("9001")
////
id.next("19701")
id.next("211")
////
id.next("33")
id.next("6")
id.next("9")

////
id.next()

> id.next("658")
ID {
  cache: [ '6', '5', '8' ],
  state: 'waiting_area',
  rslt: {},
  error: { pl: [], msg: '' }
}
> id.prev(1)
ID {
  cache: [ '6', '5' ],
  state: 'waiting_area',
  rslt: {},
  error: { pl: [], msg: '' }
}
> id.next("9001")
ID {
  cache: [ '6', '5', '9', '0', '0', '1' ],
  state: 'waiting_birth',
  rslt: { province: '新疆维吾尔自治区', city: '自治区直辖县级行政单位', county: '石河子市' },
  error: { pl: [], msg: '' }
}
>
>
>
> id.next("19701")
ID {
  cache: [
    '6', '5', '9', '0',
    '0', '1', '1', '9',
    '7', '0', '1'
  ],
  state: 'waiting_birth',
  rslt: { province: '新疆维吾尔自治区', city: '自治区直辖县级行政单位', county: '石河子市' },
  error: { pl: [], msg: '' }
}
> id.next("211")
ID {
  cache: [
    '6', '5', '9', '0',
    '0', '1', '1', '9',
    '7', '0', '1', '2',
    '1', '1'
  ],
  state: 'waiting_police',
  rslt: {
    province: '新疆维吾尔自治区',
    city: '自治区直辖县级行政单位',
    county: '石河子市',
    year: 1970,
    month: 12,
    day: 11
  },
  error: { pl: [], msg: '' }
}
>
> id.next("33")
ID {
  cache: [
    '6', '5', '9', '0',
    '0', '1', '1', '9',
    '7', '0', '1', '2',
    '1', '1', '3', '3'
  ],
  state: 'waiting_sex',
  rslt: {
    province: '新疆维吾尔自治区',
    city: '自治区直辖县级行政单位',
    county: '石河子市',
    year: 1970,
    month: 12,
    day: 11,
    police: '33'
  },
  error: { pl: [], msg: '' }
}
> id.next("6")
ID {
  cache: [
    '6', '5', '9', '0', '0',
    '1', '1', '9', '7', '0',
    '1', '2', '1', '1', '3',
    '3', '6'
  ],
  state: 'waiting_parity',
  rslt: {
    province: '新疆维吾尔自治区',
    city: '自治区直辖县级行政单位',
    county: '石河子市',
    year: 1970,
    month: 12,
    day: 11,
    police: '33',
    sex: '女',
    sex_code: 6
  },
  error: { pl: [], msg: '' }
}
> id.next("9")
ID {
  cache: [
    '6', '5', '9', '0', '0',
    '1', '1', '9', '7', '0',
    '1', '2', '1', '1', '3',
    '3', '6', '9'
  ],
  state: 'finished',
  rslt: {
    province: '新疆维吾尔自治区',
    city: '自治区直辖县级行政单位',
    county: '石河子市',
    year: 1970,
    month: 12,
    day: 11,
    police: '33',
    sex: '女',
    sex_code: 6,
    parity: '9'
  },
  error: { pl: [], msg: '' }
}
>
> id.next()
ID {
  cache: [],
  state: 'waiting_area',
  rslt: {},
  error: { pl: [], msg: '' }
}
>
>

随机生成

> random()
'450501197303029919'
> random()
'331181195210270070'
> random()
'340601198609161554'
> random()
'130925197404294656'
> random()
'430181199905138077'
> random()
'45032519970602656X'
> random()
'140525201501128325'
> random()
'37040319870903391X'
> random()
'652327195707296100'

GENERATOR

//配置格式如下
var cfg = {
    area:['654002','654003','654028'],
    birth:{
        start:{y:1999,m:1,d:1},
        end:{y:2030,m:12,d:31}
    },
    police:{start:0,end:99},
    sex:{
        sex:"男", //"男" "女" "任意"
        sex_codes:[3,5]
    }
}



> var g = gen(cfg)
> g.next()
{ value: '654002195001010033', done: false }
> g.next()
{ value: '65400219500101005X', done: false }
> g.next()
{ value: '65400219500101013X', done: false }
> g.next()
{ value: '654002195001010156', done: false }
> g.next()
{ value: '654002195001010236', done: false }
> g.next()
{ value: '654002195001010252', done: false }
> g.next()
{ value: '654002195001010332', done: false }
> g.next()
{ value: '654002195001010359', done: false }
> g.next()
{ value: '654002195001010439', done: false }
> g.next()
{ value: '654002195001010455', done: false }
> g.next()
{ value: '654002195001010535', done: false }
> g.next()
{ value: '654002195001010551', done: false }
> g.next()
{ value: '654002195001010631', done: false }
>

LICENSE

  • ISC