去除字符串空白字符
/**
*remove String Blanks
*@string {String}
*@isGlobal {Boolean}
*@return {String}
*/
function RemoveStringBlanks(string,isGlobal=false){
var res = string.replace(/(^\s+)|(\s+$)/g,"");
if(isGlobal === 'true' || isGlobal === true){
res = string.replace(/\s+/g,"");
}
return res;
}
Object 深度拷贝自己拥有的属性
/**
* @target: target Object
* @source: source Object
*/
export const assignOwnProperty = function(target, source){
for(let key in source) {
if(target.hasOwnProperty(key)) {
target[key] = source[key];
}
}
return target;
}
获取文件的扩展名
/**
* Get file etx name.
*/
function etxname(filename) {
if(filename.match(/\.[^\.]+/g) && !filename.match(/^\./g)) {
return filename.match(/\.[^\.]+/g).pop();
}
retunr "";
}
网友评论