repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Disable web ui sonar CI action
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
Utils.ts
diff --git
a/src/utils/Utils.ts
b/src/utils/Utils.ts
index d396cfa959f930167978cd35dd240eae08ff29cd..bc957c24a497ce38e5d02da80b1e7d3931bdf027 100644
(file)
--- a/
src/utils/Utils.ts
+++ b/
src/utils/Utils.ts
@@
-16,7
+16,9
@@
export default class Utils {
}
public static validateUUID(uuid: string): boolean {
}
public static validateUUID(uuid: string): boolean {
- return /\/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$\/i/.test(uuid);
+ return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(
+ uuid
+ );
}
public static async sleep(milliSeconds: number): Promise<NodeJS.Timeout> {
}
public static async sleep(milliSeconds: number): Promise<NodeJS.Timeout> {
@@
-172,7
+174,7
@@
export default class Utils {
}
public static isEmptyString(value: unknown): boolean {
}
public static isEmptyString(value: unknown): boolean {
- return Utils.isString(value) && (value as string).length === 0;
+ return Utils.isString(value) && (value as string).
trim().
length === 0;
}
public static isUndefined(value: unknown): boolean {
}
public static isUndefined(value: unknown): boolean {
@@
-185,17
+187,25
@@
export default class Utils {
}
public static isEmptyArray(object: unknown): boolean {
}
public static isEmptyArray(object: unknown): boolean {
- if (!
object
) {
- return
tru
e;
+ if (!
Array.isArray(object)
) {
+ return
fals
e;
}
}
- if (
Array.isArray(object) === true &&
(object as unknown[]).length > 0) {
+ if ((object as unknown[]).length > 0) {
return false;
}
return true;
}
public static isEmptyObject(obj: object): boolean {
return false;
}
return true;
}
public static isEmptyObject(obj: object): boolean {
- return !Object.keys(obj).length;
+ if (obj?.constructor !== Object) {
+ return false;
+ }
+ // Iterates over the keys of an object, if
+ // any exist, return false.
+ for (const _ in obj) {
+ return false;
+ }
+ return true;
}
public static insertAt = (str: string, subStr: string, pos: number): string =>
}
public static insertAt = (str: string, subStr: string, pos: number): string =>