# idcard-basic

> 🇨🇳 中国居民身份证校验

Latest version **0.1.0** (published 2022-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install idcard-basic
pnpm add idcard-basic
yarn add idcard-basic
bun add idcard-basic
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-01-05 |
| First published | 2021-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | xlslucky |
| Maintainers | xlslucky |
| Keywords | idcard, verify, info, constellation, chinese, 中国, 身份证, 校验 |

## Links

- npm: https://www.npmjs.com/package/idcard-basic
- Repository: https://github.com/xlslucky/idcard-basic
- Homepage: https://github.com/xlslucky/idcard-basic#readme
- Issues: https://github.com/xlslucky/idcard-basic/issues
- npm.io page: https://npm.io/package/idcard-basic

## Recent versions

- 0.1.0 (latest) — 2022-01-05
- 0.0.6 — 2021-11-12
- 0.0.5 — 2021-11-12
- 0.0.4 — 2021-11-12
- 0.0.3 — 2021-11-12
- 0.0.2 — 2021-11-12

## README

# idcard-basic

***借鉴 [idcard](https://github.com/navyxie/idcard)，由于 `idcard` 代码库引用地区json体积太大，所以写了个简易版。idcard-basic [demo](https://codepen.io/xlslucky/pen/KKvxRdq)。***

## 安装

```shell
$ npm i idcard-basic
# or
$ yarn add idcard-basic
# or
$ pnpm i idcard-basic
```

## 使用

### verify

```js
const { verify } = require('idcard-basic')
const idcard = 'xxxxxxxxxxxxxxxxxx' // 身份证号码
verify(idcard) // false | true
```

### info

```js
const { info } = require('idcard-basic')
const idcard = 'xxxxxxxxxxxxxxxxxx' // 身份证号码
info(idcard)
// 成功
/* {
  valid: true,
  gender: 'M',
  genderText: '男',
  birthday: '20000101',
  age: 21,
  constellation: '摩羯',
  cardType: 1,
  cardText: '大陆'
} */

// 失败
/* {
  valid: false
} */
```

### constellation

```js
const { constellation } = require('idcard-basic')
constellation('20000101') // 摩羯
```

---
_Source: https://npm.io/package/idcard-basic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
