Socket
Socket
Sign inDemoInstall

kennitala

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kennitala - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

test/test.js

23

kennitala.js

@@ -5,6 +5,6 @@ (function () {

kennitala.isValidCompany = function(){
kennitala.isValidPerson = function(kennitala){
var kt = formatKennitala(kennitala);
if (!isCompany(kt)) {
if (!isPerson(kt)) {
return false;

@@ -22,8 +22,8 @@ };

return (remainder == 11 && secretNr == 0) || remainder == secretNr;
}
};
kennitala.isValidPerson = function(kennitala){
kennitala.isValidCompany = function(kennitala){
var kt = formatKennitala(kennitala);
if (!isPerson(kt)) {
if (!isCompany(kt)) {
return false;

@@ -41,4 +41,9 @@ };

return (remainder == 11 && secretNr == 0) || remainder == secretNr;
}
};
kennitala.clean = function(kennitala){
return formatKennitala(kennitala);
};
// People have first two characters between 1-31
function isPerson(kt){

@@ -50,2 +55,3 @@ var d = kt.substr(0, 2);

// Companies have first two characters between 41-71
function isCompany(kt){

@@ -57,7 +63,6 @@ var d = kt.substr(0, 2);

// Ensures datatype is string, then removes all non-digit characters from kennitala
function formatKennitala(p_kennitala){
// Make sure kennitala is string
var kennitala = ""+p_kennitala;
// Remove unwanted characters from kennitala
kennitala = kennitala.replace(/[^0-9]/, '');

@@ -68,3 +73,3 @@

// AMD/CommonJS/PlainJS wrapper
// UMD wrapper
if(typeof module !== 'undefined' && module.exports) {

@@ -71,0 +76,0 @@ module.exports = kennitala;

{
"name": "kennitala",
"version": "1.0.2",
"version": "1.0.3",
"description": "A validator module to check the checksum of Icelandic kennitölur",

@@ -11,3 +11,6 @@ "main": "kennitala.js",

"url" : "https://github.com/HermannBjorgvin/Kennitala.git"
},
"scripts": {
"test": "node test/test.js"
}
}

@@ -11,1 +11,7 @@ # Kennitala

Based off of old code, so defintiely not bullet proof, if you have a pull request it will almost definitely get accepted.
### Things to add:
Kennitala generator, for both people and companies
Unit tests for everything
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