新增StringUtils.isNullOrEmpty方法

This commit is contained in:
yhh
2021-08-26 13:58:09 +08:00
parent 5d1609111c
commit a4b971bba0
4 changed files with 555 additions and 519 deletions

View File

@@ -2093,7 +2093,8 @@ declare module es {
updateLists(): void; updateLists(): void;
} }
} }
declare class StringUtils { declare module es {
class StringUtils {
/** /**
* 特殊符号字符串 * 特殊符号字符串
*/ */
@@ -2128,6 +2129,12 @@ declare class StringUtils {
* @return 返回该字符是否为空白字符 * @return 返回该字符是否为空白字符
*/ */
static isWhiteSpace(str: string): boolean; static isWhiteSpace(str: string): boolean;
/**
* 返回该字符是否为空字符或者为null
* @param str
* @returns
*/
static isNullOrEmpty(str: string): boolean;
/** /**
* 返回执行替换后的字符串 * 返回执行替换后的字符串
* @param mainStr 待查找字符串 * @param mainStr 待查找字符串
@@ -2175,6 +2182,7 @@ declare class StringUtils {
static strReplace(str: string, rStr: string[]): string; static strReplace(str: string, rStr: string[]): string;
static format(str: string, ...args: any[]): string; static format(str: string, ...args: any[]): string;
} }
}
declare module es { declare module es {
/** 提供帧定时信息 */ /** 提供帧定时信息 */
class Time { class Time {

View File

@@ -301,19 +301,19 @@ var es;
} }
switch (type) { switch (type) {
case LogType.error: case LogType.error:
console.error(type + ": " + StringUtils.format(format, args)); console.error(type + ": " + es.StringUtils.format(format, args));
break; break;
case LogType.warn: case LogType.warn:
console.warn(type + ": " + StringUtils.format(format, args)); console.warn(type + ": " + es.StringUtils.format(format, args));
break; break;
case LogType.log: case LogType.log:
console.log(type + ": " + StringUtils.format(format, args)); console.log(type + ": " + es.StringUtils.format(format, args));
break; break;
case LogType.info: case LogType.info:
console.info(type + ": " + StringUtils.format(format, args)); console.info(type + ": " + es.StringUtils.format(format, args));
break; break;
case LogType.trace: case LogType.trace:
console.trace(type + ": " + StringUtils.format(format, args)); console.trace(type + ": " + es.StringUtils.format(format, args));
break; break;
default: default:
throw new Error('argument out of range'); throw new Error('argument out of range');
@@ -360,7 +360,7 @@ var es;
console.assert(false); console.assert(false);
} }
else { else {
console.assert(false, StringUtils.format(message, args)); console.assert(false, es.StringUtils.format(message, args));
} }
}; };
Insist.isTrue = function (condition, message) { Insist.isTrue = function (condition, message) {
@@ -5468,6 +5468,8 @@ var es;
}()); }());
es.RenderableComponentList = RenderableComponentList; es.RenderableComponentList = RenderableComponentList;
})(es || (es = {})); })(es || (es = {}));
var es;
(function (es) {
var StringUtils = /** @class */ (function () { var StringUtils = /** @class */ (function () {
function StringUtils() { function StringUtils() {
} }
@@ -5526,6 +5528,16 @@ var StringUtils = /** @class */ (function () {
return true; return true;
return false; return false;
}; };
/**
* 返回该字符是否为空字符或者为null
* @param str
* @returns
*/
StringUtils.isNullOrEmpty = function (str) {
if (str == "" || str == null || str == undefined)
return true;
return false;
};
/** /**
* 返回执行替换后的字符串 * 返回执行替换后的字符串
* @param mainStr 待查找字符串 * @param mainStr 待查找字符串
@@ -5691,6 +5703,8 @@ var StringUtils = /** @class */ (function () {
]; ];
return StringUtils; return StringUtils;
}()); }());
es.StringUtils = StringUtils;
})(es || (es = {}));
var es; var es;
(function (es) { (function (es) {
/** 提供帧定时信息 */ /** 提供帧定时信息 */

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
class StringUtils { module es {
export class StringUtils {
/** /**
* 特殊符号字符串 * 特殊符号字符串
*/ */
@@ -73,6 +74,18 @@ class StringUtils {
return false; return false;
} }
/**
* 返回该字符是否为空字符或者为null
* @param str
* @returns
*/
public static isNullOrEmpty(str: string): boolean {
if (str == "" || str == null || str == undefined)
return true;
return false;
}
/** /**
* 返回执行替换后的字符串 * 返回执行替换后的字符串
* @param mainStr 待查找字符串 * @param mainStr 待查找字符串
@@ -229,3 +242,4 @@ class StringUtils {
return str; return str;
} }
} }
}