X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils%2FUtils.ts;h=1d422af2fb102ede225366fb4443ac51fb837b2a;hb=87f82a940257f8d6814cf6af47fa8f1b66573eea;hp=d396cfa959f930167978cd35dd240eae08ff29cd;hpb=b3aa9f53cdbf6dac72396c4392e11dcc4c37df65;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index d396cfa9..1d422af2 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -172,7 +172,7 @@ export default class Utils { } 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 { @@ -195,7 +195,15 @@ export default class Utils { } 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 =>