Comparing version 0.0.2 to 0.0.3
23
index.js
@@ -24,3 +24,5 @@ /* | ||
Number.isInteger = function isInteger (nVal) { | ||
return typeof nVal === "number" && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal; | ||
return typeof nVal === "number" && isFinite(nVal) | ||
&& nVal > -9007199254740992 && nVal < 9007199254740992 | ||
&& Math.floor(nVal) === nVal; | ||
}; | ||
@@ -30,2 +32,9 @@ } | ||
function ChecktypeError(key, type, object) | ||
{ | ||
return SyntaxError(key + ' param should be a ' + (type.name || type) | ||
+ ', not ' + value.constructor.name); | ||
} | ||
// | ||
@@ -38,3 +47,3 @@ // Basic types | ||
if(!(value instanceof Array)) | ||
throw SyntaxError(key+' param should be an Array of '+type+', not '+typeof value); | ||
throw ChecktypeError(key, 'Array of '+type, value); | ||
@@ -48,3 +57,3 @@ for(var i=0, item; item=value[i]; i++) | ||
if(typeof value != 'boolean') | ||
throw SyntaxError(key+' param should be a Boolean, not '+typeof value); | ||
throw ChecktypeError(key, Boolean, value); | ||
}; | ||
@@ -55,3 +64,3 @@ | ||
if(typeof value != 'number') | ||
throw SyntaxError(key+' param should be a Number, not '+typeof value); | ||
throw ChecktypeError(key, Number, value); | ||
}; | ||
@@ -62,3 +71,3 @@ | ||
if(!Number.isInteger(value)) | ||
throw SyntaxError(key+' param should be an Integer, not '+typeof value); | ||
throw ChecktypeError(key, Integer, value); | ||
}; | ||
@@ -69,3 +78,3 @@ | ||
if(typeof value != 'object') | ||
throw SyntaxError(key+' param should be an Object, not '+typeof value); | ||
throw ChecktypeError(key, Object, value); | ||
}; | ||
@@ -76,3 +85,3 @@ | ||
if(typeof value != 'string') | ||
throw SyntaxError(key+' param should be a String, not '+typeof value); | ||
throw ChecktypeError(key, String, value); | ||
}; | ||
@@ -79,0 +88,0 @@ |
{ | ||
"name": "checktype", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Check the type of variables and parametes, also user defined", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4555
126
0