Comparing version 1.5.1 to 1.6.0
@@ -62,42 +62,55 @@ (function(scope) { | ||
this.checkArgs = function(args, names) { | ||
var msg = '', | ||
template = '', | ||
name = '', | ||
lenNames = names.length, | ||
lenArgs = args.length, | ||
lessArgs = lenArgs < lenNames; | ||
this.check = new checkProto(); | ||
function checkProto() { | ||
/** | ||
* Check is all arguments with names present | ||
* | ||
* @param name | ||
* @param arg | ||
* @param type | ||
*/ | ||
var check = function check(args, names) { | ||
var msg = '', | ||
template = '', | ||
name = '', | ||
lenNames = names.length, | ||
lenArgs = args.length, | ||
lessArgs = lenArgs < lenNames; | ||
if (lessArgs) { | ||
template = '{{ name }} coud not be empty!'; | ||
name = names[lenNames - 1]; | ||
msg = Util.render(template, { | ||
name: name | ||
}); | ||
throw(Error(msg)); | ||
} | ||
return check; | ||
}; | ||
if (lessArgs) { | ||
template = '{{ name }} coud not be empty!'; | ||
name = names[lenNames - 1]; | ||
/** | ||
* Check is type of arg with name is equal to type | ||
* | ||
* @param name | ||
* @param arg | ||
* @param type | ||
*/ | ||
check.type = function(name, arg, type) { | ||
var is = Util.type(arg) === type; | ||
msg = Util.render(template, { | ||
name: name | ||
}); | ||
if (!is) | ||
throw(Error(name + ' should be ' + type)); | ||
throw(Error(msg)); | ||
} | ||
return check; | ||
}; | ||
return this; | ||
}; | ||
return check; | ||
} | ||
/** | ||
* Check is type of arg with name is equal to type | ||
* | ||
* @param name | ||
* @param arg | ||
* @param type | ||
*/ | ||
this.checkType = function(name, arg, type) { | ||
var is = Util.type(arg) === type; | ||
if (!is) | ||
throw(Error(name + ' should be ' + type)); | ||
return this; | ||
}; | ||
/** | ||
* Copy properties from from to to | ||
@@ -557,3 +570,3 @@ * | ||
Util.checkArgs(arguments, ['funcs', 'callback']); | ||
Util.check(arguments, ['funcs', 'callback']); | ||
@@ -560,0 +573,0 @@ switch(type) { |
{ | ||
"name": "util-io", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -5,0 +5,0 @@ "description": "Util-io - utilites for vanila js", |
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
29334
639