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
Implement an optimized (20x) version of isEmptyObject()
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
Utils.ts
diff --git
a/src/utils/Utils.ts
b/src/utils/Utils.ts
index d396cfa959f930167978cd35dd240eae08ff29cd..1d422af2fb102ede225366fb4443ac51fb837b2a 100644
(file)
--- a/
src/utils/Utils.ts
+++ b/
src/utils/Utils.ts
@@
-172,7
+172,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 {
@@
-195,7
+195,15
@@
export default class Utils {
}
public static isEmptyObject(obj: object): boolean {
}
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 =>