Comparing version 1.2.0 to 1.2.1
@@ -0,0 +0,0 @@ { |
@@ -1,2 +0,2 @@ | ||
!function(n,r){!function(){function n(n,r){var t=i(n);if(10!==t.length)return!1;if(r&&!r(t))return!1;var e=t.split("").reduce(function(n,r,t){return n+r*f[t]},0),u=11-e%11,a=parseInt(t.substr(8,1),0);return 11==u&&0===a||u===a}function r(n){var r=parseInt(n.substr(0,2),10);return r>0&&r<=31}function t(n){var r=parseInt(n.substr(0,2),10);return r>40&&r<=71}function e(n,r){function t(){for(var n=""+Math.floor(10*Math.random())+Math.floor(10*Math.random()),r=e+n,u=0,a=0;a<8;a++)u+=r[a]*f[a];return u=11-u%11,u=11==u?0:u,10==u?t():n+u}var e="",u=n.getDate();u<10&&(u="0"+u),u=""+u,u=r(u),e+=u;var a=n.getMonth();a+=1,a<10&&(a="0"+a),a=""+a,e+=a;var i=n.getFullYear();i=""+i,i=i[2]+i[3],e+=i,e+=t();var i=n.getFullYear();return i=""+i,e+=i[1]}function u(n){return n}function a(n){return""+(parseInt(n,10)+40)}function i(n){var r=""+n;return r=r.replace(/(\D)+/g,""),9===r.length&&(r="0"+r),r}var o={};o.isValid=function(r){var t=n(r,t),e=n(r,e);return t||e},o.isPerson=function(t){return n(t,r)},o.isCompany=function(r){return n(r,t)},o.clean=function(n){return i(n)},o.format=function(n,r){var t=i(n);return r=void 0!==r?r:"-",t=t.substring(0,6)+r+t.substring(6,10)},o.generatePerson=function(n){return e(n,u)},o.generateCompany=function(n){return e(n,a)},o.info=function(e){var u={};u.kt=i(e);var a=n(e,r),o=n(e,t);if(a||o){u.valid=!0,u.type=!0===a?"person":"company";var f=i(e),s=f.substring(0,2);s>31&&(s-=40);var c=f.substring(2,4),v=(0==f.substring(9,10)?20:19)+f.substring(4,6),d=new Date(v,c-1,s);u.birthday=d,u.birthdayReadable=d.toDateString();var l=new Date,g=l-d,p=Math.floor(g/(864e5*365.2422));return u.age=p,u}return u.valid=!1,u};var f=[3,2,7,6,5,4,3,2,0,0];"undefined"!=typeof module&&module.exports?module.exports=o:"function"==typeof define&&define.amd?define(o):window&&(window.kennitala=o)}(),r[""]=n}({},function(){return this}()); | ||
!function(n,r){!function(){function n(n,r){var t=o(n);if(10!==t.length)return!1;if(r&&!r(t))return!1;var e=t.split("").reduce(function(n,r,t){return n+r*f[t]},0),a=11-e%11,u=parseInt(t.substr(8,1),0);return 11==a&&0===u||a===u}function r(n){var r=parseInt(n.substr(0,2),10);return r>0&&r<=31}function t(n){var r=parseInt(n.substr(0,2),10);return r>40&&r<=71}function e(n,t){function e(n){var t=""+Math.floor(10*Math.random()),a=""+Math.floor(10*Math.random());if(r(n))var t=""+Math.floor(8*Math.random()+2);for(var u=n+t+a,o=0,i=0;i<8;i++)o+=u[i]*f[i];return o=11-o%11,o=11==o?0:o,10==o?e(n):t+a+o}var a="",u=n.getDate();u<10&&(u="0"+u),u=""+u,u=t(u),a+=u;var o=n.getMonth();o+=1,o<10&&(o="0"+o),o=""+o,a+=o;var i=n.getFullYear();i=""+i,i=i[2]+i[3],a+=i,a+=e(a);var i=n.getFullYear();return i=""+i,a+=i[1]}function a(n){return n}function u(n){return""+(parseInt(n,10)+40)}function o(n){var r=""+n;return r=r.replace(/(\D)+/g,""),9===r.length&&(r="0"+r),r}var i={};i.isValid=function(r){var t=n(r,t),e=n(r,e);return t||e},i.isPerson=function(t){return n(t,r)},i.isCompany=function(r){return n(r,t)},i.clean=function(n){return o(n)},i.format=function(n,r){var t=o(n);return r=void 0!==r?r:"-",t=t.substring(0,6)+r+t.substring(6,10)},i.generatePerson=function(n){return e(n,a)},i.generateCompany=function(n){return e(n,u)},i.info=function(e){var a={};a.kt=o(e);var u=n(e,r),i=n(e,t);if(u||i){a.valid=!0,a.type=!0===u?"person":"company";var f=o(e),s=f.substring(0,2);s>31&&(s-=40);var c=f.substring(2,4),v=(0==f.substring(9,10)?20:19)+f.substring(4,6),d=new Date(v,c-1,s);a.birthday=d,a.birthdayReadable=d.toDateString();var l=new Date,g=l-d,p=Math.floor(g/(864e5*365.2422));return a.age=p,a}return a.valid=!1,a};var f=[3,2,7,6,5,4,3,2,0,0];"undefined"!=typeof module&&module.exports?module.exports=i:"function"==typeof define&&define.amd?define(i):window&&(window.kennitala=i)}(),r[""]=n}({},function(){return this}()); | ||
//# sourceMappingURL=kennitala.min.js.map |
@@ -181,8 +181,16 @@ (function(){ | ||
*/ | ||
function randomAndChecksum() { | ||
// 7th and 8th characters are random | ||
var twoRandomDigits = "" + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) | ||
function randomAndChecksum(kt) { | ||
/* | ||
7th and 8th characters are seemingly random for companies | ||
but are incrementing from 20-99 for individuals | ||
*/ | ||
var digit7 = "" + Math.floor(Math.random() * 10); | ||
var digit8 = "" + Math.floor(Math.random() * 10); | ||
var tempKt = kt + twoRandomDigits; | ||
if (isPerson(kt)) { | ||
var digit7 = "" + Math.floor(Math.random() * 8 + 2); | ||
} | ||
var tempKt = kt + digit7 + digit8; | ||
// Ninth number | ||
@@ -198,6 +206,6 @@ var sum = 0; | ||
if (sum == 10) { | ||
return randomAndChecksum(); | ||
return randomAndChecksum(kt); | ||
} | ||
else{ | ||
return twoRandomDigits + sum; | ||
return digit7 + digit8 + sum; | ||
}; | ||
@@ -207,3 +215,3 @@ } | ||
// 7-9th characters | ||
kt += randomAndChecksum(); | ||
kt += randomAndChecksum(kt); | ||
@@ -210,0 +218,0 @@ // 10th character is century |
{ | ||
"name": "kennitala", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Icelandic social security number (kennitölur) utilities for servers and clients", | ||
@@ -5,0 +5,0 @@ "main": "dist/kennitala.min.js", |
@@ -1,8 +0,7 @@ | ||
# Kennitala | ||
<h1 align=left>Kennitala</h1> | ||
Icelandic social security number (kennitölur) utilities for servers and clients. | ||
[![Build Status](https://travis-ci.org/HermannBjorgvin/Kennitala.svg?branch=master)](https://travis-ci.org/HermannBjorgvin/Kennitala) | ||
[![npm](https://img.shields.io/npm/v/kennitala.svg)](https://github.com/HermannBjorgvin/Kennitala) | ||
[![Bower](https://img.shields.io/bower/v/kennitala.svg)](https://github.com/HermannBjorgvin/kennitala) | ||
[![npm](https://img.shields.io/npm/dm/kennitala.svg)](https://github.com/HermannBjorgvin/Kennitala/) | ||
[![npm](https://img.shields.io/npm/v/kennitala.svg)](https://www.npmjs.com/package/kennitala) | ||
[![npm](https://img.shields.io/npm/dm/kennitala.svg)](https://www.npmjs.com/package/kennitala) | ||
@@ -21,10 +20,4 @@ Install with npm: | ||
Install with bower: | ||
<h3 align=left>Examples</h3> | ||
```bash | ||
bower install kennitala | ||
``` | ||
<h3 align=center>Examples</h3> | ||
``` Javascript | ||
@@ -78,7 +71,7 @@ const kennitala = require('kennitala'); | ||
birthdayReadable: 'Sat Aug 31 1996', | ||
age: 21 | ||
age: 22 | ||
} | ||
``` | ||
<h3 align=center>API documentation</h3> | ||
<h3 align=left>API documentation</h3> | ||
@@ -145,1 +138,10 @@ kennitala.isValid([string, int]); | ||
To build the project, you can type `npm run dist`, which minifies the script and generates a source map, and places both in the `dist/` folder. | ||
### Sponsored by BrowserStack | ||
Since Oct 2nd 2018 we are proudly sponsored in part by BrowserStack which sponsors thousands of open source projects. The plan is to implement automated testing for older browsers which will give us and our users good overview of the support they can expect for older browsers and operating systems. | ||
<img width=300 src="https://raw.github.com/HermannBjorgvin/Kennitala/master/Browserstack-logo.svg?sanitize=true"> | ||
> I am using BrowserStack to easily test this library accross different browsers and operating systems from the comfort of my personal Linux machines, no need to set up a Windows or MacOS machine for testing. | ||
> - Hermann Björgvin |
@@ -0,0 +0,0 @@ var kennitala = require('../kennitala.js'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28604
10
270
145