mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
refactor(util) removeStr
This commit is contained in:
parent
73806c4eae
commit
3239e38e8f
1 changed files with 14 additions and 14 deletions
28
lib/util.js
28
lib/util.js
|
|
@ -486,26 +486,26 @@
|
|||
|
||||
/**
|
||||
* function remove substring from string
|
||||
* @param pStr
|
||||
* @param pSubStr
|
||||
* @param str
|
||||
* @param substr
|
||||
*/
|
||||
this.removeStr = function(pStr, pSubStr) {
|
||||
var lRet = Util.isString(pStr) && pSubStr;
|
||||
this.removeStr = function(str, substr) {
|
||||
var n, isArray,
|
||||
isString = Util.isString(str);
|
||||
|
||||
if ( lRet ) {
|
||||
var n = pSubStr.length;
|
||||
if (isString && substr) {
|
||||
n = substr.length;
|
||||
isArray = Util.isArray(substr);
|
||||
|
||||
if ( Util.isArray(pSubStr) )
|
||||
Util.fori(n, function(i) {
|
||||
lRet = pStr = Util.replaceStr(pStr, pSubStr[i], '');
|
||||
});
|
||||
if (!isArray)
|
||||
str = Util.replaceStr(str, substr, '');
|
||||
else
|
||||
lRet = Util.replaceStr(pStr, pSubStr, '');
|
||||
Util.fori(n, function(i) {
|
||||
str = Util.replaceStr(str, substr[i], '');
|
||||
});
|
||||
}
|
||||
else
|
||||
lRet = pStr;
|
||||
|
||||
return lRet;
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue