mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
refactor(util) rmStr
This commit is contained in:
parent
85eb6a8027
commit
8b0ae4fca7
1 changed files with 9 additions and 7 deletions
16
lib/util.js
16
lib/util.js
|
|
@ -477,7 +477,14 @@
|
|||
var replace,
|
||||
strArray = [],
|
||||
isString = Util.isString(str),
|
||||
isArray = Util.isArray(substr);
|
||||
isArray = Util.isArray(substr),
|
||||
replaceStr = function(str, strItem) {
|
||||
var ret = str.replace(strItem, '');
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
replace = isOnce ? replaceStr : Util.replaceStr;
|
||||
|
||||
if (isString && substr) {
|
||||
if (isArray)
|
||||
|
|
@ -485,13 +492,8 @@
|
|||
else
|
||||
strArray.push(substr);
|
||||
|
||||
if (isOnce)
|
||||
replace = str.replace.bind(str);
|
||||
else
|
||||
replace = Util.replaceStr.bind(null, str);
|
||||
|
||||
strArray.forEach(function(strItem) {
|
||||
str = replace(strItem, '');
|
||||
str = replace(str, strItem, '');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue