refactor(util) strCmp

This commit is contained in:
coderaiser 2014-05-12 02:12:23 -04:00
parent 59f7ef4c7d
commit 4a2cec4625

View file

@ -266,25 +266,29 @@
/**
* function check is strings are equal
* @param pStr1
* @param pStr2
* @param {String} str1
* @param {String, Array} str2
*/
this.strCmp = function(pStr1, pStr2) {
var i, n,
ret = Util.isString(pStr1);
this.strCmp = function(str1, str2) {
var ret,
isStr = Util.isString(str1),
type = Util.getType(str2);
if (ret)
if (Util.isArray(pStr2))
for (i = 0, n = pStr2.length; i < n; i++) {
ret = Util.strCmp(pStr1, pStr2[i]);
if (isStr)
switch(type) {
case 'array':
str2.some(function(str) {
ret = Util.strCmp(str1, str);
if (ret)
break;
}
else if (Util.isString(pStr2))
ret = Util.isContainStr(pStr1, pStr2) &&
pStr1.length === pStr2.length;
return ret;
});
break;
case 'string':
ret = !str1.indexOf(str2);
break;
}
return ret;
};