export function isDefined(x: T | null | undefined): x is T { return x != undefined; } export function isNotDefined( x: T | null | undefined, ): x is null | undefined { return x == undefined; } export type ObjectWithLength = { length: number }; export function isEmpty(x: T): boolean { return x.length === 0; } export function isNotEmpty(x: T): boolean { return x.length > 0; } export function isDefinedAndNotEmpty( x: T | null | undefined, ): x is T { return isDefined(x) && isNotEmpty(x); } export function isNotDefinedOrEmpty( x: T | null | undefined, ): x is null | undefined { return isNotDefined(x) || isEmpty(x); }