parse-cn-idcard

解析中国身份证号码(地址,性别,生日,星座),支持 18 位和 15 位身份证

Usage no npm install needed!

<script type="module">
  import parseCnIdcard from 'https://cdn.skypack.dev/parse-cn-idcard';
</script>

README

parse-cn-idcard

解析中国身份证号码(地址,性别,生日,星座),支持 18 位和 15 位身份证

Deps npm npm GitHub license

Installation

$ npm install --save parse-cn-idcard

or

$ npm install -g parse-cn-idcard

Test

$ npm test

Usage

api

var parse_id = require('parse-cn-idcard');

var result = parse_id('110105199410221234');

console.log(result);
{
    area: {
        id: '110105',
        name: '北京市朝阳区'
    },
    birthday: {
        date: '19941022',
        constellation_cn: '天秤座',
        constellation_en: 'Libra'
    },
    gender: {
        cn: '男',
        en: 'Male'
    }
}

cli

Usage: parse-id [options]

Options:

  -h, --help     output usage information
  -V, --version  output the version number

Usage:

  $ parse-id [idcard number]    查询特定的身份证号码

Examples:

  $ parse-id 110105199410221234

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

this repo is released under the MIT License.