-
Notifications
You must be signed in to change notification settings - Fork 0
/
kennitala.min.js
2 lines (2 loc) · 1.31 KB
/
kennitala.min.js
1
2
// Generated by CoffeeScript 1.4.0
(function(){var e="length",t=!1,n="reverse",r="push",i="getFullYear",s,o,u,a,f;f=function(i){var s,o,u;return i=i.replace(/\s/g,"").replace(/^(\d{6})[\s-]?(\d{4})$/,"$1$2"),i[e]!==10||!/[90]$/.test(i)?t:/010130(2(12|20|39|47|55|63|71|98)|3(01|36)|4(33|92)|506|778)9/.test(i)?t:(u=[3,2,7,6,5,4,3,2,1][n](),function(){var t,a,f,l;f=i.split("")[n]().slice(1,10),l=[];for(o=t=0,a=f[e];t<a;o=++t)s=f[o],l[r](+s*u[o]);return l}().reduce(function(e,t){return e+t})%11?t:!0)},a=function(){var t,n;return n=Math.floor(Math.random()*99+1),String(n[e])===1?[0,n]:function(){var i,s,o,u;o=String(n).split(""),u=[];for(i=0,s=o[e];i<s;i++)t=o[i],u[r](+t);return u}()},o=function(t){var n,s,o,u;return o=[],n=String(t.getDay()),o[r](n[e]===1?"0"+n:n),s=String(t.getMonth()+1),o[r](s[e]===1?"0"+s:s),u=String(t[i]()),o[r](u.slice(2)),o.join("").split("")},u=function(s){var u,f,l,c,h,p,d,v,m,g,y,b;d=o(s),m=t;while(!m){p=a(),l=function(){var t,n,i,s;i=d.join(""),s=[];for(t=0,n=i[e];t<n;t++)f=i[t],s[r](+f);return s}().concat(p),v=0,b=[2,3,4,5,6,7,2,3][n]();for(c=g=0,y=b[e];g<y;c=++g)f=b[c],v+=l[c]*f;h=v%11,u=11-h,h===0&&(u=0),u<10&&(d[r](p.join("")),d[r](u),d[r](String(s[i]())[1]),m=!0)}return d.join("")},s=typeof exports!="undefined"&&exports!==null&&exports||(this.Kennitala={}),s.validate=f,s.generate=u}).call(this);