From 393fd621cb0d7e3a31841e9fe5f965c860eac312 Mon Sep 17 00:00:00 2001 From: Dknight Date: Sun, 18 Feb 2018 10:35:35 +0200 Subject: [PATCH] Fix rebuild version and typos --- isikukood.js | 2 +- isikukood.min.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/isikukood.js b/isikukood.js index 20757ca..c2e8815 100644 --- a/isikukood.js +++ b/isikukood.js @@ -251,7 +251,7 @@ throw new Error(err); } - // Make it available for Browsers and + // Make it available for browsers and node if (typeof module !== 'undefined' && module.exports) { module.exports = Isikukood; } else { diff --git a/isikukood.min.js b/isikukood.min.js index ff87801..d7ac044 100644 --- a/isikukood.min.js +++ b/isikukood.min.js @@ -1,5 +1,5 @@ /* -isikukood - v1.2.0 +isikukood - v1.2.2 https://github.com/dknight/Isikukood-js/ */ !function(a){function b(a){"use strict";this.code=a,this.getControlNumber=function(){for(var a,b=[1,2,3,4,5,6,7,8,9,1],c=[3,4,5,6,7,8,9,1,2,3],d=0,e=0;e<10;e++)d+=this.code.charAt(e)*b[e];if(a=d%11,d=0,10===a){for(e=0;e<10;e++)d+=this.code.charAt(e)*c[e];a=d%11,10===a&&(a=0)}return a},this.validate=function(){if(11!==this.code.length)return!1;var b=this.getControlNumber(a);if(b!==parseInt(this.code.charAt(10)))return!1;var c=Number(this.code.substr(1,2)),d=Number(this.code.substr(3,2)),e=Number(this.code.substr(5,2)),f=this.getBirthday();return c===f.getFullYear()%100&&f.getMonth()+1===d&&e===f.getDate()},this.getGender=function(){var a=this.code.charAt(0),b="";switch(a){case"1":case"3":case"5":b="male";break;case"2":case"4":case"6":b="female";break;default:b="unknown"}return b},this.getAge=function(){return Math.floor(((new Date).getTime()-this.getBirthday().getTime())/864e5/365.25)},this.getBirthday=function(){var a=parseInt(this.code.substring(1,3)),b=parseInt(this.code.substring(3,5).replace(/^0/,""))-1,c=this.code.substring(5,7).replace(/^0/,""),d=this.code.charAt(0);return a+="1"===d||"2"===d?1800:"3"===d||"4"===d?1900:"5"===d||"6"===d?2e3:2100,new Date(a,b,c)}}function c(a){throw new Error(a)}b.generate=function(a){"use strict";a=a||{};var d,e,f,g=a.gender||(0===Math.round(Math.random())?"male":"female"),h="",i=["00","01","02","22","27","37","42","47","49","52","57","60","65","70","95"];if("female"!==g&&"male"!==g)throw new c('gender param accepts only "male" or "female" values.');if(d=a.birthYear?a.birthYear:Math.round(100*Math.random()+1900+((new Date).getFullYear()-2e3)),e=a.birthMonth?a.birthMonth:Math.floor(12*Math.random())+1,a.birthDay)f=a.birthDay;else{var j=new Date(d,e,0).getDate();f=Math.floor(Math.random()*j)+1}return"male"===g&&d>=1800&&d<=1899?h+="1":"female"===g&&d>=1800&&d<=1899?h+="2":"male"===g&&d>=1900&&d<=1999?h+="3":"female"===g&&d>=1900&&d<=1999?h+="4":"male"===g&&d>=2e3?h+="5":"female"===g&&d>=2e3&&(h+="6"),h+=parseInt(d,0).toString().substring(2,4),h+=1===e.toString().length?"0"+e:e,h+=1===f.toString().length?"0"+f:f,h+=i[Math.floor(Math.random()*i.length)],h+=Math.floor(10*Math.random()),h+=new b(h).getControlNumber()},"undefined"!=typeof module&&module.exports?module.exports=b:a.Isikukood=b}(this); \ No newline at end of file diff --git a/package.json b/package.json index ef02f96..19fc58f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "isikukood", - "version": "1.2.1", + "version": "1.2.2", "description": "Estonian personal ID (isikukood) JavaScript module", "main": "isikukood.js", "directories": {