Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

id-parser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

id-parser - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

test/index.spec.js

14

index.js

@@ -11,11 +11,11 @@ var moment = require('moment');

function get(id) {
if(typeof id !== 'string' || id.length !== 18) {
var id = String(id);
if(id.length !== 18) {
return;
}
var localCode = id.substring(0,6);
var division = gb.get(localCode);
var homeTown = division!==null ? division.toString() : '无对应数据';
var division = gb.get(id.substring(0,6));
var hometown = division!==null ? division.toString() : '无对应数据';
var date = moment(id.substring(6,14),'YYYYMMDD');
return {
homeTown,
hometown,
birthday: date.isValid() ? date : moment(),

@@ -26,6 +26,2 @@ sex: id.substring(16,17)%2 === 0 ? '女' : '男'

// console.log(get('45222319950814004X'));
// console.log(get('330722197609192116'));
// console.log(get('430421197710177894'));
exports.get = get;
{
"name": "id-parser",
"version": "0.0.2",
"version": "0.0.3",
"description": "中国身份证号码解析器,传入身份证号,返回 【户籍地】【出生年月】【性别】",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node test/index.spec.js"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -10,9 +10,9 @@ # id-resolver

```javascript
var idResolver = require('id-parser');
var idParser = require('id-parser');
//只处理 18位字符串
console.log(idResolver.get('430421197710177894'));
// { locale: '湖南省 衡阳市 衡阳县', birthday: moment("1977-10-17T00:00:00.000"), sex: '男' }
console.log(idResolver.get('45222319950814004X'));
// { locale: '无对应数据', birthday: moment("1995-08-14T00:00:00.000"), sex: '女' }
console.log(idParser.get('430421197710177894'));
// { hometown: '湖南省 衡阳市 衡阳县', birthday: moment("1977-10-17T00:00:00.000"), sex: '男' }
console.log(idParser.get('45222319950814004X'));
// { hometown: '无对应数据', birthday: moment("1995-08-14T00:00:00.000"), sex: '女' }
```

@@ -19,0 +19,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc